18 #ifndef LIBCWD_MACRO_FORALLDEBUGOBJECTS_H
19 #define LIBCWD_MACRO_FORALLDEBUGOBJECTS_H
21 #ifndef LIBCWD_CONFIG_H
24 #ifndef LIBCWD_PRIVATE_ASSERT_H
27 #ifndef LIBCWD_PRIVATE_INTERNAL_VECTOR_H
41 class debug_objects_ct {
43 typedef internal_vector<debug_ct*> container_type;
45 container_type* WNS_debug_objects;
47 void init(LIBCWD_TSD_PARAM);
48 #if LIBCWD_THREAD_SAFE
49 void init_and_rdlock(
void);
52 container_type& write_locked(
void);
53 container_type
const& read_locked(
void)
const;
60 ~debug_objects_ct() { ST_uninit(); }
64 debug_objects_ct::container_type&
65 debug_objects_ct::write_locked(
void)
68 LIBCWD_ASSERT( WNS_debug_objects );
70 return *WNS_debug_objects;
74 debug_objects_ct::container_type
const&
75 debug_objects_ct::read_locked(
void)
const
78 LIBCWD_ASSERT( WNS_debug_objects );
80 return *WNS_debug_objects;
83 extern debug_objects_ct debug_objects;
88 #if LIBCWD_THREAD_SAFE
90 #define LIBCWD_ForAllDebugObjects_LOCK_TSD_DECLARATION LIBCWD_TSD_DECLARATION
92 #define LIBCWD_ForAllDebugObjects_LOCK_TSD_DECLARATION
94 #define LIBCWD_ForAllDebugObjects_LOCK \
95 LIBCWD_ForAllDebugObjects_LOCK_TSD_DECLARATION; \
96 LIBCWD_DEFER_CLEANUP_PUSH(&::libcwd::_private_::rwlock_tct< ::libcwd::_private_::debug_objects_instance>::cleanup, NULL); \
97 ::libcwd::_private_::debug_objects.init_and_rdlock()
98 #define LIBCWD_ForAllDebugObjects_UNLOCK \
99 ::libcwd::_private_::rwlock_tct< ::libcwd::_private_::debug_objects_instance>::rdunlock(); \
100 LIBCWD_CLEANUP_POP_RESTORE(false);
101 #else // !LIBCWD_THREAD_SAFE
102 #define LIBCWD_ForAllDebugObjects_LOCK ::libcwd::_private_::debug_objects.init(LIBCWD_TSD)
103 #define LIBCWD_ForAllDebugObjects_UNLOCK
104 #endif // !LIBCWD_THREAD_SAFE
106 #define LibcwdForAllDebugObjects(dc_namespace, STATEMENT...) \
108 LIBCWD_ForAllDebugObjects_LOCK; \
109 for( ::libcwd::_private_::debug_objects_ct::container_type::\
110 const_iterator __libcwd_i(::libcwd::_private_::debug_objects.read_locked().begin());\
111 __libcwd_i != ::libcwd::_private_::debug_objects.read_locked().end(); ++__libcwd_i) \
113 using namespace ::libcwd; \
114 using namespace dc_namespace; \
115 ::libcwd::debug_ct& debugObject(*(*__libcwd_i)); \
118 LIBCWD_ForAllDebugObjects_UNLOCK \
122 #endif // LIBCWD_MACRO_FORALLDEBUGOBJECTS_H