Jpp 21.0.0-rc.3
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...)> JEEP::JFunctionAdaptorHelper< __pF__ > JLANG::JSharedPointer< JClass_t, JMemory_t > JNET::JDispatch JEEP::JFunctionAdaptor< bool, const Trk &, const Evt & > JEEP::JFunctionAdaptor< bool, const JDAQEvent &, const JEvt &, const Evt *const > JEEP::JFunctionAdaptor< bool, const JFit &, const JFit & > JEEP::JFunctionAdaptor< JReturn_t, Args > JAANET::JEventSelector JRECONSTRUCTION::JEventSelector JRECONSTRUCTION::JQualitySorter

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: