Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JSharedCounter Class Reference

Shared counter. More...

#include <JSharedCounter.hh>

Inheritance diagram for JLANG::JSharedCounter:
JEEP::JFunctionAdaptorHelper< bool(*)(Args...)> JEEP::JFunctionAdaptorHelper< void(*)(Args...)> JLANG::JSharedPointer< JPropertiesElementInterface > JLANG::JSharedPointer< JAccessibleObjectIterator< T > > JLANG::JSharedPointer< JAccessibleObjectOutput< T > > JLANG::JSharedPointer< JObjectIterator< T > > JLANG::JSharedPointer< JObjectOutput< T > > JLANG::JSharedPointer< JRewindableObjectIterator< T > > JLANG::JSharedPointer< JRewindableObjectIterator< JHead_t > > JLANG::JSharedPointer< JRewindableObjectIterator< JTail_t > > JLANG::JSharedPointer< JObjectOutput< JHead_t > > JLANG::JSharedPointer< JObjectOutput< JTail_t > > JLANG::JSharedPointer< JParserElementInterface > JLANG::JSharedPointer< JRadiation > JLANG::JSharedPointer< JAccessibleObjectIterator< Evt > > JLANG::JSharedPointer< JAccessibleObjectIterator< JHead_t > > JLANG::JSharedPointer< JAccessibleObjectIterator< JTail_t > > JLANG::JSharedPointer< JAccessibleObjectIterator< JDAQSummaryslice > > JLANG::JSharedPointer< JAccessibleObjectIterator< JTypeList< JDAQEvent, JNullType > > > JLANG::JSharedPointer< JBase_t > JLANG::JSharedPointer< JAbstractAutoPointer< JBase_t > > JLANG::JSharedPointer< JTRIGGER::JMatch > JLANG::JSharedPointer< JTRIGGER::JDAQHitSelector > JLANG::JSharedPointer< JFIT::JMEstimator > JLANG::JSharedPointer< JLOGGER::JLogger > JLANG::JSharedPointer< JTOOLS::JMultiMapTransformer > JLANG::JSharedPointer< JRewindableObjectIterator< const event_type > > JLANG::JSharedPointer< match_type > JLANG::JSharedPointer< JNET::JControlHost > JLANG::JSharedPointer< JAccessibleObjectIterator< KM3NETDAQ::JDAQEvent > > JEEP::JFunctionAdaptorHelper< __pF__ > JLANG::JSharedPointer< JClass_t, JMemory_t > JNET::JDispatch

Public Member Functions

 JSharedCounter ()
 Default constructor.
 
void initialise ()
 Initialise counter.
 
void attach (const JSharedCounter &object)
 Attach this counter to given shared counter object.
 
bool detach ()
 Detach.
 
const int getCount ()
 Get count.
 

Protected Attributes

int * counter
 

Detailed Description

Shared counter.

Definition at line 19 of file JSharedCounter.hh.

Constructor & Destructor Documentation

◆ JSharedCounter()

JLANG::JSharedCounter::JSharedCounter ( )
inline

Default constructor.

Definition at line 25 of file JSharedCounter.hh.

25 :
26 counter(NULL)
27 {}

Member Function Documentation

◆ initialise()

void JLANG::JSharedCounter::initialise ( )
inline

Initialise counter.

Definition at line 33 of file JSharedCounter.hh.

34 {
35 detach();
36
37 counter = new int(1);
38 }

◆ attach()

void JLANG::JSharedCounter::attach ( const JSharedCounter & object)
inline

Attach this counter to given shared counter object.

Parameters
objectshared counter

Definition at line 46 of file JSharedCounter.hh.

47 {
48 detach();
49
50 counter = object.counter;
51
52 if (counter != NULL) {
53 ++(*counter);
54 }
55 }

◆ detach()

bool JLANG::JSharedCounter::detach ( )
inline

Detach.

Returns
true if counter at zero; else false

Definition at line 63 of file JSharedCounter.hh.

64 {
65 if (counter != NULL) {
66
67 if (--(*counter) == 0) {
68
69 delete counter;
70
71 counter = NULL;
72
73 return true;
74 }
75
76 counter = NULL;
77 }
78
79 return false;
80 }

◆ getCount()

const int JLANG::JSharedCounter::getCount ( )
inline

Get count.

Returns
count

Definition at line 88 of file JSharedCounter.hh.

89 {
90 return (counter != NULL ? *counter : 0);
91 }

Member Data Documentation

◆ counter

int* JLANG::JSharedCounter::counter
protected

Definition at line 94 of file JSharedCounter.hh.


The documentation for this class was generated from the following file: