CMS 3D CMS Logo

List of all members | Public Member Functions | Static Private Member Functions | Private Attributes
PhysicsTools::AtomicId Class Reference

Cheap generic unique keyword identifier class. More...

#include <AtomicId.h>

Public Member Functions

 AtomicId () throw ()
 
 AtomicId (const AtomicId &orig) throw ()
 
 AtomicId (const char *arg) throw ()
 constructs an AtomicId from a C string More...
 
 AtomicId (const std::string &arg) throw ()
 constructs an AtomicId from a STL string More...
 
 operator bool () const throw ()
 null value check operator More...
 
 operator const char * () const throw ()
 implicit cast to a C string More...
 
 operator std::string () const throw ()
 implicit cast to a STL string More...
 
bool operator!= (const AtomicId &second) const throw ()
 
bool operator< (const AtomicId &second) const throw ()
 
bool operator<= (const AtomicId &second) const throw ()
 
AtomicIdoperator= (const AtomicId &orig) throw ()
 
bool operator== (const AtomicId &second) const throw ()
 
bool operator> (const AtomicId &second) const throw ()
 
bool operator>= (const AtomicId &second) const throw ()
 
 ~AtomicId () throw ()
 

Static Private Member Functions

static AtomicId build (const char *arg) throw ()
 
static const char * lookup (const char *arg) throw ()
 

Private Attributes

const char * string
 

Detailed Description

Cheap generic unique keyword identifier class.

AtomicId is a lightweight class intended to be used for key values e.g. in STL maps. An atomic identifier can be transparently constructed from and converted back to a string, but an instance of AtomicId does not occupy and additional memory and the comparator operators are very cheap. An AtomicId instance requires the size of a pointer and is therefore suited for direct inlining.

Definition at line 31 of file AtomicId.h.

Constructor & Destructor Documentation

◆ AtomicId() [1/4]

PhysicsTools::AtomicId::AtomicId ( )
throw (
)
inline

Definition at line 33 of file AtomicId.h.

33 : string(nullptr) {}

◆ AtomicId() [2/4]

PhysicsTools::AtomicId::AtomicId ( const AtomicId orig)
throw (
)
inline

Definition at line 34 of file AtomicId.h.

34 : string(orig.string) {}

◆ AtomicId() [3/4]

PhysicsTools::AtomicId::AtomicId ( const char *  arg)
throw (
)
inline

constructs an AtomicId from a C string

Definition at line 36 of file AtomicId.h.

36 : string(lookup(arg)) {}

◆ AtomicId() [4/4]

PhysicsTools::AtomicId::AtomicId ( const std::string &  arg)
throw (
)
inline

constructs an AtomicId from a STL string

Definition at line 38 of file AtomicId.h.

38 : string(lookup(arg.c_str())) {}

◆ ~AtomicId()

PhysicsTools::AtomicId::~AtomicId ( )
throw (
)
inline

Definition at line 39 of file AtomicId.h.

39 {}

Member Function Documentation

◆ build()

static AtomicId PhysicsTools::AtomicId::build ( const char *  arg)
throw (
)
inlinestaticprivate

Definition at line 63 of file AtomicId.h.

63  {
64  AtomicId q;
65  q.string = arg;
66  return q;
67  }

References data-class-funcs::q.

◆ lookup()

const char * PhysicsTools::AtomicId::lookup ( const char *  arg)
throw (
)
staticprivate

Definition at line 59 of file AtomicId.cc.

59  {
60  if (string)
61  return getAtomicIdCache().findOrInsert(string);
62 
63  return nullptr;
64  }

References PhysicsTools::getAtomicIdCache().

◆ operator bool()

PhysicsTools::AtomicId::operator bool ( ) const
throw (
)
inline

null value check operator

Definition at line 50 of file AtomicId.h.

50 { return string != nullptr; }

◆ operator const char *()

PhysicsTools::AtomicId::operator const char * ( ) const
throw (
)
inline

implicit cast to a C string

Definition at line 47 of file AtomicId.h.

47 { return string; }

References string.

◆ operator std::string()

PhysicsTools::AtomicId::operator std::string ( ) const
throw (
)
inline

implicit cast to a STL string

Definition at line 53 of file AtomicId.h.

53 { return std::string(string); }

References AlCaHLTBitMon_QueryRunRegistry::string.

◆ operator!=()

bool PhysicsTools::AtomicId::operator!= ( const AtomicId second) const
throw (
)
inline

Definition at line 56 of file AtomicId.h.

56 { return string != second.string; }

References edm::second().

◆ operator<()

bool PhysicsTools::AtomicId::operator< ( const AtomicId second) const
throw (
)
inline

Definition at line 57 of file AtomicId.h.

57 { return string < second.string; }

References edm::second().

◆ operator<=()

bool PhysicsTools::AtomicId::operator<= ( const AtomicId second) const
throw (
)
inline

Definition at line 58 of file AtomicId.h.

58 { return string <= second.string; }

References edm::second().

◆ operator=()

AtomicId& PhysicsTools::AtomicId::operator= ( const AtomicId orig)
throw (
)
inline

Definition at line 41 of file AtomicId.h.

41  {
42  string = orig.string;
43  return *this;
44  }

References string.

◆ operator==()

bool PhysicsTools::AtomicId::operator== ( const AtomicId second) const
throw (
)
inline

Definition at line 55 of file AtomicId.h.

55 { return string == second.string; }

References edm::second().

◆ operator>()

bool PhysicsTools::AtomicId::operator> ( const AtomicId second) const
throw (
)
inline

Definition at line 59 of file AtomicId.h.

59 { return string > second.string; }

References edm::second().

◆ operator>=()

bool PhysicsTools::AtomicId::operator>= ( const AtomicId second) const
throw (
)
inline

Definition at line 60 of file AtomicId.h.

60 { return string >= second.string; }

References edm::second().

Member Data Documentation

◆ string

const char* PhysicsTools::AtomicId::string
private

Definition at line 70 of file AtomicId.h.

Referenced by operator const char *(), and operator=().

PhysicsTools::AtomicId::AtomicId
AtomicId()
Definition: AtomicId.h:33
data-class-funcs.q
q
Definition: data-class-funcs.py:169
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PhysicsTools::getAtomicIdCache
static IdCache & getAtomicIdCache()
Definition: AtomicId.cc:54
PhysicsTools::AtomicId::string
const char * string
Definition: AtomicId.h:70
PhysicsTools::AtomicId::lookup
static const char * lookup(const char *arg)
Definition: AtomicId.cc:59
funct::arg
A arg
Definition: Factorize.h:36