Jpp  19.1.0-rc.1
the software that should make you happy
Public Member Functions | Protected Attributes | List of all members
JLANG::JSharedCounter Class Reference

Shared counter. More...

#include <JSharedCounter.hh>

Inheritance diagram for JLANG::JSharedCounter:
JEEP::JFunctionAdaptorHelper< void(*)(Args...)> JLANG::JSharedPointer< JObjectIterator< T > > JLANG::JSharedPointer< const TFormula > JLANG::JSharedPointer< JFIT::JMEstimator > JLANG::JSharedPointer< JAbstractAutoPointer< JBase_t > > JLANG::JSharedPointer< JTRIGGER::JDAQHitSelector > JLANG::JSharedPointer< match_type > JLANG::JSharedPointer< JLOGGER::JLogger > JLANG::JSharedPointer< JParserElementInterface > JLANG::JSharedPointer< JAccessibleObjectIterator< T > > JLANG::JSharedPointer< JExceptionHandler > JLANG::JSharedPointer< JTRIGGER::JMatch > JLANG::JSharedPointer< JBase_t > JLANG::JSharedPointer< JObjectOutput< T > > JLANG::JSharedPointer< JPropertiesElementInterface > JLANG::JSharedPointer< JRewindableObjectIterator< T > > JLANG::JSharedPointer< JAccessibleObjectOutput< T > > JLANG::JSharedPointer< JNET::JControlHost > JLANG::JSharedPointer< JTOOLS::JMultiMapTransformer > JLANG::JSharedPointer< JRadiation > JEEP::JFunctionAdaptorHelper< __pF__ > JLANG::JSharedPointer< JClass_t, JMemory_t > JNET::JDispatch

Public Member Functions

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

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: