00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : David BEILLOIN (Oct 2005) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_PERF_COUNTER_H_ 00026 #define _SO_PERF_COUNTER_H_ 00027 00028 #include <Inventor/stats/SoSubPerfCounter.h> 00029 #include <Inventor/threads/SbThreadMutex.h> 00030 00043 class SoPerfCounter { 00044 00045 public: 00046 00047 typedef double SoPerfCounterValue; 00048 00052 virtual void reset() = 0; 00053 00057 static SoType getClassTypeId(); 00058 00062 virtual SoType getTypeId() const; 00063 00067 char* getName() { return (char*)m_name.getString(); } 00068 00074 SoNONUNICODE char* getDescription() { return (char*)m_description.toLatin1(); } 00075 00079 SbString getStringDescription() { return m_description; } 00080 00084 SoPerfCounterValue getValue(); 00085 00089 virtual void setValue( SoPerfCounterValue value ) { m_mutex->lock(); m_value = value; m_mutex->unlock(); } 00090 00095 void setScale( SoPerfCounterValue scale ) { m_scale = scale; } 00096 00101 SoPerfCounterValue getScale() const { return m_scale; } 00102 00107 SbString getType() const { return m_type; } 00108 00113 SbString getModule() const { return m_module; } 00114 00119 SbString getStringLevel() const; 00120 00125 int getLevel() const { return m_level; } 00126 00131 bool isCustom() const { return m_isCustom; } 00132 00137 SbName getFirstParent() const { return m_firstParent; } 00138 00143 SbName getSecondParent() const { return m_secondParent; } 00144 00149 void setFirstParent( SbName firstParent ) { m_firstParent = firstParent; } 00150 00155 void setSecondParent( SbName secondParent ) { m_secondParent = secondParent; } 00156 00161 SbString getOperation() const { return m_operation; } 00162 00167 void setOperation( SbString operation ) { m_operation = operation; } 00168 00172 virtual void increment( SoPerfCounterValue value ) { m_mutex->lock(); m_value += value; m_mutex->unlock(); } 00173 virtual void decrement( SoPerfCounterValue value ) { m_mutex->lock(); m_value -= value; m_mutex->unlock(); } 00174 00178 void setID( int id ) { m_id = id; } 00179 int getID() { return m_id; } 00180 00184 void setEnable( bool e ) { m_enable = e; } 00185 bool isEnabled() { return m_enable; } 00186 00191 enum LevelEnum 00192 { 00193 LOW = 0, 00194 MEDIUM = 1, 00195 HIGH = 2 00196 }; 00197 00198 private: 00199 00203 static void initClass(); 00204 00208 static void exitClass(); 00209 00213 virtual ~SoPerfCounter(); 00214 00215 private: 00216 00227 SoPerfCounter( const SbString& name, const SbString& description, 00228 const SbString& module = "no module", const LevelEnum level = MEDIUM, bool custom = false ); 00229 00236 SbString m_type; 00237 00241 SbName m_name; 00242 00246 SbString m_description; 00247 00251 SoPerfCounterValue m_value; 00252 00257 SoPerfCounterValue m_scale; 00258 00264 enum LevelEnum m_level; 00265 00270 SbString m_module; 00271 00276 bool m_isCustom; 00277 00282 SbName m_firstParent; 00283 00288 SbName m_secondParent; 00289 00294 SbString m_operation; 00295 00299 SbThreadMutex* m_mutex; 00300 00301 private: 00302 00307 void init(); 00308 00309 static bool m_isInitialized; 00310 static SoType m_classTypeId; 00311 int m_id; 00312 bool m_enable; 00313 00314 }; 00315 00316 #endif // _SO_PERF_COUNTER_H_ 00317 00318 00319 00320 00321