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 TypeTag &iType, const IdTags &iId)
 
 DataKey (const TypeTag &iType, const IdTags &iId, DoNotCopyMemory)
 
 DataKey (const DataKey &iRHS)
 
 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.

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.

References makeCopyOfMemory().

40 : type_(iRHS.type_), name_(iRHS.name_), ownMemory_() { 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.

References releaseMemory().

49 { releaseMemory(); }

Member Function Documentation

◆ deleteMemory()

void DataKey::deleteMemory ( )
private

Definition at line 100 of file DataKey.cc.

References name(), edm::eventsetup::SimpleStringTag::value(), and relativeConstraints::value.

Referenced by releaseMemory().

100  {
101  if (kBlank[0] != name().value()[0]) {
102  delete[] const_cast<char*>(name().value());
103  }
104  }
const NameTag & name() const
Definition: DataKey.h:53
const char * value() const
Definition: DataKeyTags.h:39

◆ makeCopyOfMemory()

void DataKey::makeCopyOfMemory ( )
private

Definition at line 80 of file DataKey.cc.

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

Referenced by DataKey().

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  }
const NameTag & name() const
Definition: DataKey.h:53
const char * value() const
Definition: DataKeyTags.h:39

◆ 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.

References name_, and type_.

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

◆ operator=() [1/2]

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

Definition at line 32 of file DataKey.cc.

References swap, and groupFilesInBlocks::temp.

32  {
33  //An exception safe implementation is
34  DataKey temp(rhs);
35  swap(temp);
36 
37  return *this;
38  }
friend void swap(DataKey &, DataKey &)
Definition: DataKey.h:85

◆ operator=() [2/2]

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

Definition at line 40 of file DataKey.cc.

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

40  {
41  //An exception safe implementation is
42  DataKey temp(std::move(rhs));
43  swap(temp);
44 
45  return *this;
46  }
friend void swap(DataKey &, DataKey &)
Definition: DataKey.h:85
def move(src, dest)
Definition: eostools.py:511

◆ operator==()

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

Definition at line 109 of file DataKey.cc.

References name_, and type_.

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

◆ releaseMemory()

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

Definition at line 69 of file DataKey.h.

References deleteMemory(), and ownMemory_.

Referenced by ~DataKey().

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

◆ swap()

void DataKey::swap ( DataKey iOther)
private

Definition at line 51 of file DataKey.cc.

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

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  }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
friend void swap(DataKey &, DataKey &)
Definition: DataKey.h:85

◆ 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.

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

85 { a.swap(b); }
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119

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