CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
edm::eventsetup::DataKey Class Reference

#include <DataKey.h>

Public Types

enum  DoNotCopyMemory { kDoNotCopyMemory }
 

Public Member Functions

 DataKey ()
 
 DataKey (const DataKey &iRHS)
 
 DataKey (const TypeTag &iType, const IdTags &iId)
 
 DataKey (const TypeTag &iType, const IdTags &iId, DoNotCopyMemory)
 
 DataKey (DataKey &&iRHS)
 
const NameTagname () const
 
bool operator!= (const DataKey &iRHS) const
 
bool operator< (const DataKey &iRHS) const
 
DataKeyoperator= (const DataKey &)
 
DataKeyoperator= (DataKey &&)
 
bool operator== (const DataKey &iRHS) const
 
const TypeTagtype () const
 
 ~DataKey ()
 

Static Public Member Functions

template<class T >
static TypeTag makeTypeTag ()
 

Private Member Functions

void deleteMemory ()
 
void makeCopyOfMemory ()
 
void releaseMemory ()
 
void swap (DataKey &)
 

Private Attributes

NameTag name_ {}
 
bool ownMemory_ {false}
 
TypeTag type_ {}
 

Friends

void swap (DataKey &, DataKey &)
 

Detailed Description

Definition at line 29 of file DataKey.h.

Member Enumeration Documentation

◆ DoNotCopyMemory

Enumerator
kDoNotCopyMemory 

Definition at line 33 of file DataKey.h.

Constructor & Destructor Documentation

◆ DataKey() [1/5]

DataKey::DataKey ( )
default

◆ DataKey() [2/5]

edm::eventsetup::DataKey::DataKey ( const TypeTag iType,
const IdTags iId 
)
inline

Definition at line 36 of file DataKey.h.

36 : type_(iType), name_(iId), ownMemory_() { makeCopyOfMemory(); }

References makeCopyOfMemory().

◆ DataKey() [3/5]

edm::eventsetup::DataKey::DataKey ( const TypeTag iType,
const IdTags iId,
DoNotCopyMemory   
)
inline

Definition at line 38 of file DataKey.h.

38 : type_(iType), name_(iId), ownMemory_(false) {}

◆ DataKey() [4/5]

edm::eventsetup::DataKey::DataKey ( const DataKey iRHS)
inline

Definition at line 40 of file DataKey.h.

40 : type_(iRHS.type_), name_(iRHS.name_), ownMemory_() { makeCopyOfMemory(); }

References makeCopyOfMemory().

◆ DataKey() [5/5]

edm::eventsetup::DataKey::DataKey ( DataKey &&  iRHS)
inline

Definition at line 42 of file DataKey.h.

42  : type_(iRHS.type_), name_(iRHS.name_), ownMemory_(iRHS.ownMemory_) {
43  iRHS.ownMemory_ = false;
44  }

◆ ~DataKey()

edm::eventsetup::DataKey::~DataKey ( )
inline

Definition at line 49 of file DataKey.h.

49 { releaseMemory(); }

References releaseMemory().

Member Function Documentation

◆ deleteMemory()

void DataKey::deleteMemory ( )
private

Definition at line 100 of file DataKey.cc.

100  {
101  if (kBlank[0] != name().value()[0]) {
102  delete[] const_cast<char*>(name().value());
103  }
104  }

References name(), and relativeConstraints::value.

Referenced by releaseMemory().

◆ makeCopyOfMemory()

void DataKey::makeCopyOfMemory ( )
private

Definition at line 80 of file DataKey.cc.

80  {
81  //empty string is the most common case, so handle it special
82 
83  char* pName = const_cast<char*>(kBlank);
84  //NOTE: if in the future additional tags are added then
85  // I should make sure that pName gets deleted in the case
86  // where an exception is thrown
87  ArrayHolder pNameHolder;
88  if (kBlank[0] != name().value()[0]) {
89  size_t const nBytes = std::strlen(name().value()) + 1;
90  pName = new char[nBytes];
91  ArrayHolder t(pName);
92  pNameHolder.swap(t);
93  std::strncpy(pName, name().value(), nBytes);
94  }
95  name_ = NameTag(pName);
96  ownMemory_ = true;
97  pNameHolder.release();
98  }

References name(), name_, ownMemory_, submitPVValidationJobs::t, and relativeConstraints::value.

Referenced by DataKey().

◆ makeTypeTag()

template<class T >
static TypeTag edm::eventsetup::DataKey::makeTypeTag ( )
inlinestatic

Definition at line 61 of file DataKey.h.

61  {
62  return heterocontainer::HCTypeTag::make<T>();
63  }

◆ name()

const NameTag& edm::eventsetup::DataKey::name ( void  ) const
inline

◆ operator!=()

bool edm::eventsetup::DataKey::operator!= ( const DataKey iRHS) const
inline

Definition at line 56 of file DataKey.h.

56 { return not(*this == iRHS); }

◆ operator<()

bool DataKey::operator< ( const DataKey iRHS) const

Definition at line 111 of file DataKey.cc.

111  {
112  return (type_ < iRHS.type_) || ((type_ == iRHS.type_) && (name_ < iRHS.name_));
113  }

References name_, and type_.

◆ operator=() [1/2]

DataKey & DataKey::operator= ( const DataKey rhs)

Definition at line 32 of file DataKey.cc.

32  {
33  //An exception safe implementation is
34  DataKey temp(rhs);
35  swap(temp);
36 
37  return *this;
38  }

References swap, and groupFilesInBlocks::temp.

◆ operator=() [2/2]

DataKey & DataKey::operator= ( DataKey &&  rhs)

Definition at line 40 of file DataKey.cc.

40  {
41  //An exception safe implementation is
42  DataKey temp(std::move(rhs));
43  swap(temp);
44 
45  return *this;
46  }

References eostools::move(), swap, and groupFilesInBlocks::temp.

◆ operator==()

bool DataKey::operator== ( const DataKey iRHS) const

Definition at line 109 of file DataKey.cc.

109 { return ((type_ == iRHS.type_) && (name_ == iRHS.name_)); }

References name_, and type_.

◆ releaseMemory()

void edm::eventsetup::DataKey::releaseMemory ( )
inlineprivate

Definition at line 69 of file DataKey.h.

69  {
70  if (ownMemory_) {
71  deleteMemory();
72  ownMemory_ = false;
73  }
74  }

References deleteMemory(), and ownMemory_.

Referenced by ~DataKey().

◆ swap()

void DataKey::swap ( DataKey iOther)
private

Definition at line 51 of file DataKey.cc.

51  {
52  std::swap(ownMemory_, iOther.ownMemory_);
53  // unqualified swap is used for user defined classes.
54  // The using directive is needed so that std::swap will be used if there is no other matching swap.
55  using std::swap;
56  swap(type_, iOther.type_);
57  swap(name_, iOther.name_);
58  }

References name_, ownMemory_, swap, std::swap(), and type_.

◆ type()

const TypeTag& edm::eventsetup::DataKey::type ( ) const
inline

Friends And Related Function Documentation

◆ swap

void swap ( DataKey a,
DataKey b 
)
friend

Definition at line 85 of file DataKey.h.

85 { a.swap(b); }

Referenced by operator=(), and swap().

Member Data Documentation

◆ name_

NameTag edm::eventsetup::DataKey::name_ {}
private

Definition at line 80 of file DataKey.h.

Referenced by makeCopyOfMemory(), name(), operator<(), operator==(), and swap().

◆ ownMemory_

bool edm::eventsetup::DataKey::ownMemory_ {false}
private

Definition at line 81 of file DataKey.h.

Referenced by makeCopyOfMemory(), releaseMemory(), and swap().

◆ type_

TypeTag edm::eventsetup::DataKey::type_ {}
private
DataKey
edm::eventsetup::DataKey::makeCopyOfMemory
void makeCopyOfMemory()
Definition: DataKey.cc:80
edm::eventsetup::DataKey::name_
NameTag name_
Definition: DataKey.h:80
edm::eventsetup::DataKey::type_
TypeTag type_
Definition: DataKey.h:79
edm::eventsetup::DataKey::swap
friend void swap(DataKey &, DataKey &)
Definition: DataKey.h:85
edm::eventsetup::DataKey::deleteMemory
void deleteMemory()
Definition: DataKey.cc:100
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
edm::eventsetup::DataKey::name
const NameTag & name() const
Definition: DataKey.h:53
edm::eventsetup::DataKey::ownMemory_
bool ownMemory_
Definition: DataKey.h:81
edm::eventsetup::DataKey::releaseMemory
void releaseMemory()
Definition: DataKey.h:69
b
double b
Definition: hdecay.h:118
a
double a
Definition: hdecay.h:119
eostools.move
def move(src, dest)
Definition: eostools.py:511
relativeConstraints.value
value
Definition: relativeConstraints.py:53
edm::eventsetup::DataKey::kDoNotCopyMemory
Definition: DataKey.h:33
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644