Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
gar::rec::IDNumberGen Class Reference

#include <IDNumberGen.h>

Public Member Functions

IDNumber getNewOne ()
 
void newEventReset ()
 
 IDNumberGen (const IDNumberGen &arg)=delete
 
 IDNumberGen (const IDNumberGen &&arg)=delete
 
IDNumberGenoperator= (const IDNumberGen &arg)=delete
 
IDNumberGenoperator= (const IDNumberGen &&arg)=delete
 

Static Public Member Functions

static IDNumberGencreate (IDNumber iniValue=std::numeric_limits< IDNumber >::max())
 

Private Member Functions

 IDNumberGen ()
 
 ~IDNumberGen ()
 

Static Private Attributes

static std::atomic< gar::rec::IDNumbernextOneToMake = std::numeric_limits<IDNumber>::max()
 
static std::set< gar::rec::IDNumberpreviousInitializers = {}
 

Detailed Description

Definition at line 75 of file IDNumberGen.h.

Constructor & Destructor Documentation

gar::rec::IDNumberGen::IDNumberGen ( const IDNumberGen arg)
delete
gar::rec::IDNumberGen::IDNumberGen ( const IDNumberGen &&  arg)
delete
gar::rec::IDNumberGen::IDNumberGen ( )
private

Definition at line 58 of file IDNumberGen.cxx.

58 {}
gar::rec::IDNumberGen::~IDNumberGen ( )
private

Member Function Documentation

IDNumberGen * gar::rec::IDNumberGen::create ( IDNumber  iniValue = std::numeric_limits<IDNumber>::max())
static

Definition at line 18 of file IDNumberGen.cxx.

18  {
19 
20  // Repeated calls to new here do not create a memory leak.
21  // Some kind of wierd C++11 magic.
22  static IDNumberGen* tmp = new IDNumberGen();
23  // If creating an instance with an initial value
24  if (iniValue != std::numeric_limits<IDNumber>::max()) {
25  // and if the iniValue isn't one of the previously used ones
27  if (itr==previousInitializers.end()) {
28  previousInitializers.insert(iniValue);
29  nextOneToMake.store(iniValue);
30  }
31  }
32  // Even if nextOneToMake.store() not called, still fine that tmp is
33  // uninitialized as getNewOne() only pulls info from a static field.
34  return tmp;
35  }
intermediate_table::iterator iterator
static std::atomic< gar::rec::IDNumber > nextOneToMake
Definition: IDNumberGen.h:99
static std::set< gar::rec::IDNumber > previousInitializers
Definition: IDNumberGen.h:100
string tmp
Definition: languages.py:63
static int max(int a, int b)
gar::rec::IDNumber gar::rec::IDNumberGen::getNewOne ( )

Definition at line 39 of file IDNumberGen.cxx.

39  {
42  return retval;
43  }
static std::atomic< gar::rec::IDNumber > nextOneToMake
Definition: IDNumberGen.h:99
size_t IDNumber
Definition: IDNumberGen.h:71
void gar::rec::IDNumberGen::newEventReset ( )

Definition at line 47 of file IDNumberGen.cxx.

47  {
48  previousInitializers.clear();
50  return;
51  }
static std::atomic< gar::rec::IDNumber > nextOneToMake
Definition: IDNumberGen.h:99
static std::set< gar::rec::IDNumber > previousInitializers
Definition: IDNumberGen.h:100
static int max(int a, int b)
IDNumberGen& gar::rec::IDNumberGen::operator= ( const IDNumberGen arg)
delete
IDNumberGen& gar::rec::IDNumberGen::operator= ( const IDNumberGen &&  arg)
delete

Member Data Documentation

std::atomic< gar::rec::IDNumber > gar::rec::IDNumberGen::nextOneToMake = std::numeric_limits<IDNumber>::max()
staticprivate

Definition at line 99 of file IDNumberGen.h.

std::set< gar::rec::IDNumber > gar::rec::IDNumberGen::previousInitializers = {}
staticprivate

Definition at line 100 of file IDNumberGen.h.


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