Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
Token Class Reference

This class provides a token that identifies in a unique way objects on the persistent storage. More...

#include <Token.h>

Inheritance diagram for Token:
Collaboration diagram for Token:

Classes

struct  OID_t
 

Public Member Functions

 Token ()
 Standard Constructor. More...
 
 Token (const Token *source)
 Constructor with data assignment. More...
 
 Token (Token &&source)
 Allow move. More...
 
virtual ~Token ()
 Standard destructor: release all allocated resources. More...
 
bool operator< (const Token &refToken) const
 Operator < to allow ordering. More...
 
bool operator> (const Token &refToken) const
 Operator > to allow ordering. More...
 
bool operator== (const Token &refToken) const
 Equality operator. More...
 
bool operator!= (const Token &refToken) const
 Equality operator. More...
 
virtual bool less (const Token &pTok) const
 Fast token comparison: operator less. More...
 
virtual bool equal (const Token &pTok) const
 Fast token comparison: operator equals. More...
 
int release ()
 Release token: Decrease reference count and eventually delete. More...
 
int addRef ()
 Increase reference count. More...
 
const GuiddbID () const
 Access database identifier. More...
 
TokensetDb (const Guid &db)
 Set database name. More...
 
TokensetDb (const std::string &db)
 
const std::string & contID () const
 Access container identifier. More...
 
TokensetCont (const std::string &cnt)
 Set container name. More...
 
const GuidclassID () const
 Access database identifier. More...
 
TokensetClassID (const Guid &cl_id)
 Access database identifier. More...
 
int technology () const
 Access technology type. More...
 
TokensetTechnology (int t)
 Set technology type. More...
 
const OID_toid () const
 Access object identifier. More...
 
OID_toid ()
 Access object identifier. More...
 
TokensetOid (const OID_t &oid)
 Set object identifier. More...
 
int type () const
 Access token type. More...
 
TokensetType (int t)
 Set token type. More...
 
const std::string & auxString () const
 Access auxiliary string. More...
 
TokensetAuxString (const std::string &auxString)
 Set auxiliary string. More...
 
virtual const std::string toString () const
 Retrieve the string representation of the token. More...
 
virtual const std::string key () const
 Retrieve token key. More...
 
TokenfromString (const std::string &from)
 Build from the string representation of a token. More...
 
const Tokenset (Token *pToken) const
 Set token information. More...
 
const TokensetData (Token *pToken) const
 Set all the data part of the token. More...
 

Static Public Member Functions

static int numInstances ()
 expose Token instance counter for debugging More...
 

Private Member Functions

 Token (const Token &copy)
 No copy allowed: put prototype to disable bit-wise copy. More...
 
Tokenoperator= (const Token &copy)
 No assignment allowed: put prototype to disable bit-wise assignment. More...
 

Private Attributes

int m_refCount
 Reference count. More...
 
unsigned int m_technology
 Technology identifier. More...
 
Guid m_dbID
 Database identifier. More...
 
std::string m_cntID
 Container identifier. More...
 
Guid m_classID
 Object global identifier. More...
 
OID_t m_oid
 Persistent object identifier. More...
 
int m_type
 Token type. More...
 
std::string m_auxString
 Auxiliary string. More...
 

Detailed Description

This class provides a token that identifies in a unique way objects on the persistent storage.

Definition at line 21 of file Token.h.

Constructor & Destructor Documentation

◆ Token() [1/4]

Token::Token ( const Token copy)
private

No copy allowed: put prototype to disable bit-wise copy.

Copy constructor.

Definition at line 32 of file Token.cxx.

32  : m_refCount(1),
33  m_technology(copy.m_technology),
34  m_dbID(copy.m_dbID),
35  m_classID(copy.m_classID),
36  m_oid(copy.m_oid),
37  m_type(0) {
38  copy.setData(this);
39  s_numCount++;
40 }

◆ Token() [2/4]

Token::Token ( )

Standard Constructor.

Standard Constructor(1): Empty constructor.

Definition at line 22 of file Token.cxx.

22  : m_refCount(1),
23  m_technology(0),
24  m_dbID(Guid::null()),
26  m_oid(OID_t(~0x0LL, ~0x0LL)),
27  m_type(0) {
28  s_numCount++;
29 }

◆ Token() [3/4]

Token::Token ( const Token source)
explicit

Constructor with data assignment.

Copy constructor.

Definition at line 43 of file Token.cxx.

43  : m_refCount(1),
44  m_technology(0),
45  m_dbID(Guid::null()),
47  m_oid(OID_t(~0x0LL, ~0x0LL)),
48  m_type(0) {
49  if (source != 0) {
50  source->setData(this);
51  }
52  s_numCount++;
53 }

◆ Token() [4/4]

Token::Token ( Token &&  source)
explicit

Allow move.

Move constructor.

Definition at line 56 of file Token.cxx.

57  : m_refCount (1),
58  m_technology (source.m_technology),
59  m_dbID (std::move (source.m_dbID)),
60  m_cntID (std::move (source.m_cntID)),
61  m_classID (std::move (source.m_classID)),
62  m_oid (std::move (source.m_oid)),
63  m_type (source.m_type),
64  m_auxString (std::move (source.m_auxString))
65 {
66  s_numCount++;
67 }

◆ ~Token()

Token::~Token ( )
virtual

Standard destructor: release all allocated resources.

Definition at line 70 of file Token.cxx.

70  {
71  s_numCount--;
72 }

Member Function Documentation

◆ addRef()

int Token::addRef ( )
inline

Increase reference count.

Definition at line 62 of file Token.h.

62 { return ++m_refCount; }

◆ auxString()

const std::string& Token::auxString ( ) const
inline

Access auxiliary string.

Definition at line 91 of file Token.h.

91 { return m_auxString; }

◆ classID()

const Guid& Token::classID ( ) const
inline

Access database identifier.

Definition at line 73 of file Token.h.

73 { return m_classID; }

◆ contID()

const std::string& Token::contID ( ) const
inline

Access container identifier.

Definition at line 69 of file Token.h.

69 { return m_cntID; }

◆ dbID()

const Guid& Token::dbID ( ) const
inline

Access database identifier.

Definition at line 64 of file Token.h.

64 { return m_dbID; }

◆ equal()

bool Token::equal ( const Token pTok) const
virtual

Fast token comparison: operator equals.

Equality operator.

Reimplemented in pool::DbToken.

Definition at line 92 of file Token.cxx.

92  {
93  if (&copy != this) {
94  if (m_oid.second == copy.m_oid.second) {
95  if (m_classID == copy.m_classID) {
96  if (m_dbID == copy.m_dbID) {
97  if (m_cntID == copy.m_cntID) {
98  return true;
99  }
100  }
101  }
102  }
103  return false;
104  }
105  return true;
106 }

◆ fromString()

Token & Token::fromString ( const std::string &  from)

Build from the string representation of a token.

Definition at line 148 of file Token.cxx.

148  {
149  m_auxString.clear();
150  for (const char* p1 = source.c_str(); p1; p1 = ::strchr(++p1,'[')) {
151  const char* p2 = ::strchr(p1, '=');
152  const char* p3 = ::strchr(p1, ']');
153  if (p2 != 0 && p3 != 0) {
154  if (::strncmp("[DB=", p1, 4) == 0) {
155  m_dbID.fromString(p1 + 4);
156  } else if (::strncmp("[CNT=", p1, 5) == 0) {
157  m_cntID.assign (p2+1, p3-p2-1);
158  } else if (::strncmp(fmt_oid, p1, 5) == 0) {
159  long long unsigned int first, second;
160  if (::strncmp("]", p1 + 22, 1) == 0) { // 5 + 8(int) + 1(minus) + 8(int) = 22
161  ::sscanf(p1, fmt_oid_old, &first, &second);
162  if (int(first) == ~0x0) first = ~0x0LL;
163  if (int(second) == ~0x0) second = ~0x0LL;
164  } else {
165  ::sscanf(p1, fmt_oid, &first, &second);
166  }
167  m_oid.first = first;
168  m_oid.second = second;
169  } else if (::strncmp(fmt_clid, p1, 6) == 0) {
170  m_classID.fromString(p1 + 6);
171  } else if (::strncmp(fmt_tech, p1, 6) == 0) {
172  ::sscanf(p1, fmt_tech, &m_technology);
173  } else {
174  while (*(p2 + 1) == '[' && p3 && *(++p3) != 0 && *p3 != ']') {
175  p3 = ::strchr(p3, ']');
176  }
177  if (!p3) p3 = source.c_str() + source.size();
178  m_auxString.append (p1, p3-p1);
179  m_auxString += ']';
180  }
181  }
182  }
183  return *this;
184 }

◆ key()

const std::string Token::key ( ) const
virtual

Retrieve token key.

Retrieve the string representation of the token.

Definition at line 187 of file Token.cxx.

187  {
188  char text[1024];
189  int s = ::sprintf(text, "][TECH=%08X]", m_technology & KEY_MASK);
190  std::string k = "[DB=";
191  k += m_dbID.toString();
192  k += "][CNT=";
193  k += m_cntID;
194  k += "][CLID=";
195  k += m_classID.toString();
196  k.append(text, s);
197  return k;
198 }

◆ less()

bool Token::less ( const Token pTok) const
virtual

Fast token comparison: operator less.

Operator to allow ordering.

Reimplemented in pool::DbToken.

Definition at line 109 of file Token.cxx.

109  {
110  if (&copy != this) {
111  if (m_oid.second < copy.m_oid.second)
112  return true;
113  else if (m_oid.second > copy.m_oid.second)
114  return false;
115  if (!(m_classID == copy.m_classID)) {
116  return (m_classID < copy.m_classID);
117  }
118  if (!(m_dbID == copy.m_dbID)) {
119  return (m_dbID < copy.m_dbID);
120  }
121  int res = m_cntID.compare(copy.m_cntID);
122  if (res != 0) {
123  return (res < 0);
124  }
125  }
126  return false;
127 }

◆ numInstances()

int Token::numInstances ( )
static

expose Token instance counter for debugging

Definition at line 19 of file Token.cxx.

19 { return s_numCount; }

◆ oid() [1/2]

OID_t& Token::oid ( )
inline

Access object identifier.

Definition at line 83 of file Token.h.

83 { return m_oid; }

◆ oid() [2/2]

const OID_t& Token::oid ( ) const
inline

Access object identifier.

Definition at line 81 of file Token.h.

81 { return m_oid; }

◆ operator!=()

bool Token::operator!= ( const Token refToken) const
inline

Equality operator.

Definition at line 54 of file Token.h.

54 { return !equal(refToken); }

◆ operator<()

bool Token::operator< ( const Token refToken) const
inline

Operator < to allow ordering.

Definition at line 45 of file Token.h.

45 { return less(refToken); }

◆ operator=()

Token & Token::operator= ( const Token copy)
private

No assignment allowed: put prototype to disable bit-wise assignment.

Assignment operator.

Definition at line 84 of file Token.cxx.

84  {
85  if (&copy != this) {
86  copy.setData(this);
87  }
88  return *this;
89 }

◆ operator==()

bool Token::operator== ( const Token refToken) const
inline

Equality operator.

Definition at line 52 of file Token.h.

52 { return equal(refToken); }

◆ operator>()

bool Token::operator> ( const Token refToken) const
inline

Operator > to allow ordering.

Definition at line 47 of file Token.h.

47  {
48  if (less(refToken)) return false;
49  return !equal(refToken);
50  }

◆ release()

int Token::release ( )

Release token: Decrease reference count and eventually delete.

Definition at line 75 of file Token.cxx.

75  {
76  int cnt = --m_refCount;
77  if (0 >= cnt) {
78  delete this;
79  }
80  return cnt;
81 }

◆ set()

const Token & Token::set ( Token pToken) const

Set token information.

Definition at line 200 of file Token.cxx.

200  {
201  pToken->m_technology = m_technology;
202  pToken->m_dbID = m_dbID;
203  pToken->m_cntID = m_cntID;
204  pToken->m_classID = m_classID;
205  pToken->m_oid.first = m_oid.first;
206  return *this;
207 }

◆ setAuxString()

Token& Token::setAuxString ( const std::string &  auxString)
inline

Set auxiliary string.

Definition at line 93 of file Token.h.

93 { m_auxString = auxString; return *this; }

◆ setClassID()

Token& Token::setClassID ( const Guid cl_id)
inline

Access database identifier.

Definition at line 75 of file Token.h.

75 { m_classID = cl_id; return *this; }

◆ setCont()

Token& Token::setCont ( const std::string &  cnt)
inline

Set container name.

Definition at line 71 of file Token.h.

71 { m_cntID = cnt; return *this; }

◆ setData()

const Token & Token::setData ( Token pToken) const

Set all the data part of the token.

Definition at line 209 of file Token.cxx.

209  {
210  this->set(pToken);
211  pToken->m_oid.second = m_oid.second;
212  pToken->m_type = m_type;
213  pToken->m_auxString = m_auxString;
214  return *this;
215 }

◆ setDb() [1/2]

Token& Token::setDb ( const Guid db)
inline

Set database name.

Definition at line 66 of file Token.h.

66 { m_dbID = db; return *this; }

◆ setDb() [2/2]

Token& Token::setDb ( const std::string &  db)
inline

Definition at line 67 of file Token.h.

67 { m_dbID.fromString(db); return *this; }

◆ setOid()

Token& Token::setOid ( const OID_t oid)
inline

Set object identifier.

Definition at line 85 of file Token.h.

85 { m_oid = oid; return *this; }

◆ setTechnology()

Token& Token::setTechnology ( int  t)
inline

Set technology type.

Definition at line 79 of file Token.h.

79 { m_technology = t; return *this; }

◆ setType()

Token& Token::setType ( int  t)
inline

Set token type.

Definition at line 89 of file Token.h.

89 { m_type = t; return *this; }

◆ technology()

int Token::technology ( ) const
inline

Access technology type.

Definition at line 77 of file Token.h.

77 { return m_technology; }

◆ toString()

const std::string Token::toString ( ) const
virtual

Retrieve the string representation of the token.

Definition at line 129 of file Token.cxx.

129  {
130  char text1[128];
131  int s1 = sprintf(text1, fmt_tech, m_technology);
132  char text2[128];
133  int s2 = sprintf(text2, fmt_oid, m_oid.first, m_oid.second);
134  std::string str = "[DB=";
135  str.reserve(32);
136  str += m_dbID.toString();
137  str += "][CNT=";
138  str += m_cntID;
139  str += "][CLID=";
140  str += m_classID.toString();
141  str += ']';
142  str.append(text1, s1);
143  str.append(text2, s2);
144  str += m_auxString;
145  return str;
146 }

◆ type()

int Token::type ( ) const
inline

Access token type.

Definition at line 87 of file Token.h.

87 { return m_type; }

Member Data Documentation

◆ m_auxString

std::string Token::m_auxString
private

Auxiliary string.

Definition at line 125 of file Token.h.

◆ m_classID

Guid Token::m_classID
private

Object global identifier.

Definition at line 119 of file Token.h.

◆ m_cntID

std::string Token::m_cntID
private

Container identifier.

Definition at line 117 of file Token.h.

◆ m_dbID

Guid Token::m_dbID
private

Database identifier.

Definition at line 115 of file Token.h.

◆ m_oid

OID_t Token::m_oid
private

Persistent object identifier.

Definition at line 121 of file Token.h.

◆ m_refCount

int Token::m_refCount
private

Reference count.

Definition at line 111 of file Token.h.

◆ m_technology

unsigned int Token::m_technology
private

Technology identifier.

Definition at line 113 of file Token.h.

◆ m_type

int Token::m_type
private

Token type.

Definition at line 123 of file Token.h.


The documentation for this class was generated from the following files:
Token::m_type
int m_type
Token type.
Definition: Token.h:123
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
ReadCellNoiseFromCoolCompare.s1
s1
Definition: ReadCellNoiseFromCoolCompare.py:378
Guid::null
static const Guid & null()
NULL-Guid: static class method.
Definition: Guid.cxx:18
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
Token::auxString
const std::string & auxString() const
Access auxiliary string.
Definition: Token.h:91
Token::m_dbID
Guid m_dbID
Database identifier.
Definition: Token.h:115
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
Guid::toString
const std::string toString() const
Automatic conversion to string representation.
Definition: Guid.cxx:58
Token::m_technology
unsigned int m_technology
Technology identifier.
Definition: Token.h:113
Token::less
virtual bool less(const Token &pTok) const
Fast token comparison: operator less.
Definition: Token.cxx:109
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Token::m_classID
Guid m_classID
Object global identifier.
Definition: Token.h:119
Token::m_cntID
std::string m_cntID
Container identifier.
Definition: Token.h:117
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
Token::equal
virtual bool equal(const Token &pTok) const
Fast token comparison: operator equals.
Definition: Token.cxx:92
python.CaloAddPedShiftConfig.str
str
Definition: CaloAddPedShiftConfig.py:42
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
Token::m_oid
OID_t m_oid
Persistent object identifier.
Definition: Token.h:121
Token::m_auxString
std::string m_auxString
Auxiliary string.
Definition: Token.h:125
trigbs_pickEvents.cnt
cnt
Definition: trigbs_pickEvents.py:71
Token::oid
const OID_t & oid() const
Access object identifier.
Definition: Token.h:81
DeMoScan.first
bool first
Definition: DeMoScan.py:536
ReadCellNoiseFromCoolCompare.s2
s2
Definition: ReadCellNoiseFromCoolCompare.py:379
Guid::fromString
const Guid & fromString(const std::string &s)
Automatic conversion from string representation.
Definition: Guid.cxx:65
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
copySelective.source
string source
Definition: copySelective.py:32
str
Definition: BTagTrackIpAccessor.cxx:11
calibdata.copy
bool copy
Definition: calibdata.py:27
Token::m_refCount
int m_refCount
Reference count.
Definition: Token.h:111
TRTCalib_cfilter.p3
p3
Definition: TRTCalib_cfilter.py:132
Token::set
const Token & set(Token *pToken) const
Set token information.
Definition: Token.cxx:200
fitman.k
k
Definition: fitman.py:528