21 #ifndef INSTRUMENTEDOBJECT_H
22 #define INSTRUMENTEDOBJECT_H
33 #define INIT_COUNTERS( instrumented_obj, intrumented_object_name ) \
35 int mutexLockResult##intrumented_object_name = pthread_mutex_lock( &( InstrumentedObject::ObjMutex ) ); \
36 if ( 0 != mutexLockResult##intrumented_object_name ) \
38 TRACE( "Unable to lock mutex for "#intrumented_object_name" [" << mutexLockResult##intrumented_object_name << "]" ); \
40 InstrumentedObject::Instance.registerCounter( typeid( *this ).name(), "_"#instrumented_obj, instrumented_obj ); \
41 int mutexUnlockResult##intrumented_object_name = pthread_mutex_unlock( &( InstrumentedObject::ObjMutex ) ); \
42 if ( 0 != mutexUnlockResult##intrumented_object_name ) \
44 TRACE( "Unable to unlock mutex for "#intrumented_object_name" [" << mutexUnlockResult##intrumented_object_name << "]" ); \
50 #define INIT_COUNTER( counterName ) ( void )m_Counters.insert( pair< string, unsigned long >( #counterName, 0 ) )
51 #define DESTROY_COUNTER( counterName ) if ( m_Counters.find( #counterName ) != m_Counters.end() ) ( void )m_Counters.erase( #counterName )
52 #define COUNTER( counterName ) m_Counters[ #counterName ]
54 #define INCREMENT_COUNTER( counterName ) COUNTER( counterName ) = COUNTER( counterName )+1
55 #define INCREMENT_COUNTER_ON( instance, counterName ) instance->COUNTER( counterName ) = instance->COUNTER( counterName )+1
56 #define INCREMENT_COUNTER_ON_T( instance, counterName )
57 #define RESET_COUNTER( counterName ) COUNTER( counterName ) = 0;
58 #define ASSIGN_COUNTER( counterName, value ) COUNTER( counterName ) = value;
78 string InternalGetCounters()
const;
85 static unsigned int GetIntrumentedInstanceNo()
87 return Instance.m_RegisteredObjects.size();
90 static void RemoveAllCounters()
92 Instance.m_RegisteredObjects.clear();
93 Instance.m_RegisterCounter = 0;
96 void registerCounter(
const string& ownerTypeName,
const string& counterName,
const InstrumentedObject* iobject );
97 static string Report();
98 static string Collect();
102 #endif //INSTRUMENTEDOBJECT_H