Jpp
 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 JDETECTOR::JModuleRouter > 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< JTypeList< JDAQEvent, JTypelist_t > > > JLANG::JSharedPointer< JAccessibleObjectIterator< KM3NETDAQ::KM3NETDAQ::JDAQEvent > > JLANG::JSharedPointer< JAccessibleObjectIterator< T > > JLANG::JSharedPointer< JAccessibleObjectOutput< T > > JLANG::JSharedPointer< JBase_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< JParserElementInterface > JLANG::JSharedPointer< JPHYSICS::JRadiation > JLANG::JSharedPointer< JPropertiesElementInterface > 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< 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...
 

Protected Attributes

int * counter
 

Detailed Description

Shared counter.

Definition at line 18 of file JSharedCounter.hh.

Constructor & Destructor Documentation

JLANG::JSharedCounter::JSharedCounter ( )
inline

Default constructor.

Definition at line 24 of file JSharedCounter.hh.

24  :
25  counter(NULL)
26  {}

Member Function Documentation

void JLANG::JSharedCounter::initialise ( )
inline

Initialise counter.

Definition at line 32 of file JSharedCounter.hh.

33  {
34  detach();
35 
36  counter = new int(1);
37  }
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 45 of file JSharedCounter.hh.

46  {
47  detach();
48 
49  counter = object.counter;
50 
51  if (counter != NULL) {
52  ++(*counter);
53  }
54  }
bool detach()
Detach.
bool JLANG::JSharedCounter::detach ( )
inline

Detach.

Returns
true if counter at zero; else false

Definition at line 62 of file JSharedCounter.hh.

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

Member Data Documentation

int* JLANG::JSharedCounter::counter
protected

Definition at line 82 of file JSharedCounter.hh.


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