Jpp  18.0.0-rc.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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< __pF__ > JEEP::JFunctionAdaptorHelper< bool(*)(const JFit &, const JFit &)> JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t)> JEEP::JFunctionAdaptorHelper< JReturn_t(*)(JFirst_t, JSecond_t)> JLANG::JSharedPointer< JClass_t, JMemory_t > JNET::JDispatch JLANG::JSharedPointer< const TFormula > JLANG::JSharedPointer< JAbstractAutoPointer< JBase_t > > JLANG::JSharedPointer< JAccessibleObjectIterator< JDAQSummaryslice > > JLANG::JSharedPointer< JAccessibleObjectIterator< JHead_t > > JLANG::JSharedPointer< JAccessibleObjectIterator< JNullType > > JLANG::JSharedPointer< JAccessibleObjectIterator< JTail_t > > JLANG::JSharedPointer< JAccessibleObjectIterator< KM3NETDAQ::KM3NETDAQ::JDAQEvent > > JLANG::JSharedPointer< JAccessibleObjectIterator< T > > JLANG::JSharedPointer< JAccessibleObjectOutput< T > > JLANG::JSharedPointer< JBase_t > JLANG::JSharedPointer< JDiffuseFlux > JLANG::JSharedPointer< JEvtWeight > JLANG::JSharedPointer< JEvtWeightFactor > JLANG::JSharedPointer< JEvtWeightFactor_t > JLANG::JSharedPointer< JExceptionHandler > JLANG::JSharedPointer< JFIT::JMEstimator > JLANG::JSharedPointer< JLOGGER::JLogger > JLANG::JSharedPointer< JNET::JControlHost > JLANG::JSharedPointer< JObjectIterator< T > > JLANG::JSharedPointer< JObjectOutput< JHead_t > > JLANG::JSharedPointer< JObjectOutput< JTail_t > > JLANG::JSharedPointer< JObjectOutput< T > > JLANG::JSharedPointer< JOscProb > JLANG::JSharedPointer< JParserElementInterface > JLANG::JSharedPointer< JPropertiesElementInterface > JLANG::JSharedPointer< JRadiation > JLANG::JSharedPointer< JRewindableObjectIterator< const T > > JLANG::JSharedPointer< JRewindableObjectIterator< JHead_t > > JLANG::JSharedPointer< JRewindableObjectIterator< JTail_t > > JLANG::JSharedPointer< JRewindableObjectIterator< T > > JLANG::JSharedPointer< JTOOLS::JMultiMapTransformer > JLANG::JSharedPointer< JTRIGGER::JDAQHitSelector > JLANG::JSharedPointer< JTRIGGER::JMatch > JLANG::JSharedPointer< match_type >

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

JLANG::JSharedCounter::JSharedCounter ( )
inline

Default constructor.

Definition at line 25 of file JSharedCounter.hh.

25  :
26  counter(NULL)
27  {}

Member Function Documentation

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  }
bool detach()
Detach.
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  }
bool detach()
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  }
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

int* JLANG::JSharedCounter::counter
protected

Definition at line 94 of file JSharedCounter.hh.


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