1 #ifndef stk_mesh_Trace_hpp
2 #define stk_mesh_Trace_hpp
53 #include <stk_mesh/base/DiagWriter.hpp>
54 #include <stk_mesh/base/EntityKey.hpp>
56 #include <stk_util/diag/WriterExt.hpp>
62 namespace stk_classic {
71 virtual const std::type_info& type()
const = 0;
72 virtual bool match(
const void* item_)
const = 0;
73 virtual void* item() = 0;
76 std::vector<Watch*>& watch_vector();
79 bool internal_is_watching(
const T& item)
81 for (std::vector<Watch*>::const_iterator
82 itr = watch_vector().begin(); itr != watch_vector().end(); ++itr) {
83 if ((*itr)->type() ==
typeid(T) &&
84 (*itr)->match(&item)) {
92 class WatchClass :
public Watch
95 WatchClass(
const T& watch_item) : m_watch_item(watch_item),
96 m_type_info(&typeid(T)) {
97 watch_vector().push_back(
this);
100 virtual const std::type_info& type()
const {
return *m_type_info; }
102 virtual bool match(
const void* item_)
const {
103 return *(
static_cast<const T*
>(item_)) == m_watch_item;
106 virtual void* item() {
return &m_watch_item; }
110 const std::type_info* m_type_info;
115 template <
typename T>
116 void watch(
const T& watch_item)
119 new WatchClass<T>(watch_item);
122 #ifdef STK_MESH_TRACE_ENABLED
124 inline void setStream(std::ostream& stream)
126 initDiagWriter(stream);
129 #define Trace_(location) stk_classic::mesh::Trace trace__(location)
131 #define TraceIf(location, mask) stk_classic::mesh::Trace trace__(location, mask)
133 #define TraceIfWatching(location, mask, item) \
134 stk_classic::mesh::Trace trace__(location, mask, stk_classic::mesh::internal_is_watching(item)); \
135 DiagIfWatching(mask, item, "Watched item is: " << item << stk_classic::diag::dendl)
139 #define TraceIfWatchingDec(location, mask, item, dec) \
140 stk_classic::mesh::Trace trace##dec__(location, mask, stk_classic::mesh::internal_is_watching(item)); \
141 DiagIfWatching(mask, item, "Watched item is: " << item << stk_classic::diag::dendl)
143 #define DiagIfWatching(mask, item, message) \
144 meshlog.w(stk_classic::mesh::internal_is_watching(item), mask) << message << stk_classic::diag::dendl
146 #define DiagIf(mask, message) \
147 meshlog.m(mask) << message << stk_classic::diag::dendl
153 inline void setStream(std::ostream& stream) { }
155 #define Trace_(location) ((void) (0))
156 #define TraceIf(location, mask) ((void) (0))
157 #define TraceIfWatching(location, mask, item) ((void) (0))
158 #define TraceIfWatchingDec(location, mask, item, dec) ((void) (0))
159 #define DiagIf(mask, message) ((void) (0))
160 #define DiagIfWatching(mask, item, message) ((void) (0))