Open Inventor Release 2024.1.3
 
Loading...
Searching...
No Matches
SoPerfCounter.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : David BEILLOIN (Oct 2005)
22**=======================================================================*/
23
24
25#ifndef _SO_PERF_COUNTER_H_
26#define _SO_PERF_COUNTER_H_
27
28#include <Inventor/stats/SoSubPerfCounter.h>
29#include <Inventor/threads/SbThreadMutex.h>
30
44
45public:
46
47 typedef double SoPerfCounterValue;
48
52 virtual void reset() = 0;
53
58
62 virtual SoType getTypeId() const;
63
67 const char* getName() { return m_name.getString(); }
68
74 SoNONUNICODE const char* getDescription() { return m_description.toLatin1(); }
75
79 SbString getStringDescription() { return m_description; }
80
85
89 virtual void setValue( SoPerfCounterValue value ) { m_mutex->lock(); m_value = value; m_mutex->unlock(); }
90
95 void setScale( SoPerfCounterValue scale ) { m_scale = scale; }
96
101 SoPerfCounterValue getScale() const { return m_scale; }
102
107 SbString getType() const { return m_type; }
108
113 SbString getModule() const { return m_module; }
114
120
125 int getLevel() const { return m_level; }
126
131 bool isCustom() const { return m_isCustom; }
132
137 SbName getFirstParent() const { return m_firstParent; }
138
143 SbName getSecondParent() const { return m_secondParent; }
144
149 void setFirstParent( SbName firstParent ) { m_firstParent = firstParent; }
150
155 void setSecondParent( SbName secondParent ) { m_secondParent = secondParent; }
156
161 SbString getOperation() const { return m_operation; }
162
167 void setOperation( SbString operation ) { m_operation = operation; }
168
172 virtual void increment( SoPerfCounterValue value ) { m_mutex->lock(); m_value += value; m_mutex->unlock(); }
173 virtual void decrement( SoPerfCounterValue value ) { m_mutex->lock(); m_value -= value; m_mutex->unlock(); }
174
178 void setID( int id ) { m_id = id; }
179 int getID() { return m_id; }
180
184 void setEnable( bool e ) { m_enable = e; }
185 bool isEnabled() { return m_enable; }
186
192 {
193 LOW = 0,
195 HIGH = 2
196 };
197
198private:
199
203 static void initClass();
204
208 static void exitClass();
209
213 virtual ~SoPerfCounter();
214
215private:
216
227 SoPerfCounter( const SbString& name, const SbString& description,
228 const SbString& module = "no module", const LevelEnum level = MEDIUM, bool custom = false );
229
236 SbString m_type;
237
241 SbName m_name;
242
246 SbString m_description;
247
251 SoPerfCounterValue m_value;
252
257 SoPerfCounterValue m_scale;
258
264 enum LevelEnum m_level;
265
270 SbString m_module;
271
276 bool m_isCustom;
277
282 SbName m_firstParent;
283
288 SbName m_secondParent;
289
294 SbString m_operation;
295
299 SbThreadMutex* m_mutex;
300
301private:
302
307 void init();
308
309 static bool m_isInitialized;
310 static SoType m_classTypeId;
311 int m_id;
312 bool m_enable;
313
314};
315
316#endif // _SO_PERF_COUNTER_H_
317
318
319
320
Character string stored in a hash table.
Definition SbName.h:162
const char * getString() const
Returns pointer to the character string.
Definition SbName.h:192
Class for smart character strings.
Definition SbString.h:202
const char * toLatin1() const
Returns the string as a Latin-1/ASCII C string.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Portable mutex c...
int lock()
Locks the current thread on this mutex.
int unlock()
Relinquishes ownership of this mutex.
Abstract base class for Performance Counter.
void setOperation(SbString operation)
Sets the operation made between the two parents.
SbString getModule() const
Returns the module of the counter.
SbName getFirstParent() const
Returns the name of the first parent.
SoNONUNICODE const char * getDescription()
Returns the description of current counter;.
static SoType getClassTypeId()
Returns the Type of current class.
virtual void increment(SoPerfCounterValue value)
Increments/Decrements counter value by 'value'.
virtual SoType getTypeId() const
Returns the type of current instance.
SbString getOperation() const
Returns the operation made between the two parents.
void setScale(SoPerfCounterValue scale)
Sets the scale factor.
LevelEnum
Various levels for a counter.
const char * getName()
Returns the name of current counter;.
SbString getType() const
Returns the type of the counter.
SoPerfCounterValue getValue()
Returns the value of the counter.
SbString getStringDescription()
Returns the description of current counter;.
SoPerfCounterValue getScale() const
Returns the scale factor.
bool isCustom() const
Returns TRUE if the counter results of an operation between other counters.
SbString getStringLevel() const
Returns the level of the counter.
void setFirstParent(SbName firstParent)
Sets the name of the first parent.
void setID(int id)
Sets/Gets counter id.
int getLevel() const
Returns the level of the counter.
virtual void reset()=0
Reset the counter.
SbName getSecondParent() const
Returns the name of the second parent.
virtual void setValue(SoPerfCounterValue value)
Set the counter value.
double SoPerfCounterValue
void setSecondParent(SbName secondParent)
Sets the name of the second parent.
virtual void decrement(SoPerfCounterValue value)
void setEnable(bool e)
Sets/Gets the use state.
Stores runtime type information.
Definition SoType.h:98