CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
const NameTagname () const
 
bool operator< (const DataKey &iRHS) const
 
DataKeyoperator= (const 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_
 
TypeTag type_
 

Friends

void swap (DataKey &, DataKey &)
 

Detailed Description

Definition at line 30 of file DataKey.h.

Member Enumeration Documentation

Enumerator
kDoNotCopyMemory 

Definition at line 35 of file DataKey.h.

Constructor & Destructor Documentation

DataKey::DataKey ( )

Definition at line 36 of file DataKey.cc.

36  : type_(), name_(), ownMemory_(false)
37 {
38 }
edm::eventsetup::DataKey::DataKey ( const TypeTag iType,
const IdTags iId 
)
inline

Definition at line 38 of file DataKey.h.

References makeCopyOfMemory().

39  :
40  type_(iType),
41  name_(iId),
42  ownMemory_() {
44  }
edm::eventsetup::DataKey::DataKey ( const TypeTag iType,
const IdTags iId,
DoNotCopyMemory   
)
inline

Definition at line 46 of file DataKey.h.

48  :
49  type_(iType),
50  name_(iId),
51  ownMemory_(false) {}
edm::eventsetup::DataKey::DataKey ( const DataKey iRHS)
inline

Definition at line 53 of file DataKey.h.

References makeCopyOfMemory().

53  :
54  type_(iRHS.type_),
55  name_(iRHS.name_),
56  ownMemory_() {
58  }
edm::eventsetup::DataKey::~DataKey ( )
inline

Definition at line 62 of file DataKey.h.

References releaseMemory().

62 { releaseMemory(); }

Member Function Documentation

void DataKey::deleteMemory ( )
private

Definition at line 116 of file DataKey.cc.

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

Referenced by releaseMemory().

117 {
118  if(kBlank[0] != name().value()[0]) {
119  delete [] const_cast<char*>(name().value());
120  }
121 }
static const char kBlank[]
Definition: DataKey.cc:25
const NameTag & name() const
Definition: DataKey.h:66
const char * value() const
Definition: DataKeyTags.h:40
void DataKey::makeCopyOfMemory ( )
private

Definition at line 94 of file DataKey.cc.

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

Referenced by DataKey().

95 {
96  //empty string is the most common case, so handle it special
97 
98  char* pName = const_cast<char*>(kBlank);
99  //NOTE: if in the future additional tags are added then
100  // I should make sure that pName gets deleted in the case
101  // where an exception is thrown
102  ArrayHolder pNameHolder;
103  if(kBlank[0] != name().value()[0]) {
104  size_t const nBytes = std::strlen(name().value()) + 1;
105  pName = new char[nBytes];
106  ArrayHolder t(pName);
107  pNameHolder.swap(t);
108  std::strncpy(pName, name().value(), nBytes);
109  }
110  name_ = NameTag(pName);
111  ownMemory_ = true;
112  pNameHolder.release();
113 }
static const char kBlank[]
Definition: DataKey.cc:25
const NameTag & name() const
Definition: DataKey.h:66
const char * value() const
Definition: DataKeyTags.h:40
template<class T >
static TypeTag edm::eventsetup::DataKey::makeTypeTag ( )
inlinestatic

Definition at line 73 of file DataKey.h.

73  {
74  return heterocontainer::HCTypeTag::make<T>();
75  }
const NameTag& edm::eventsetup::DataKey::name ( void  ) const
inline
bool DataKey::operator< ( const DataKey iRHS) const

Definition at line 134 of file DataKey.cc.

References name_, and type_.

135 {
136  return (type_ < iRHS.type_) ||
137  ((type_ == iRHS.type_) && (name_ < iRHS.name_));
138 /*
139  if(type_ < iRHS.type_) {
140  return true;
141  } else if (type_ == iRHS.type_) {
142  if(name_ < iRHS.name_) {
143  return true;
144  }
145  return false;
146  */
147 }
DataKey & DataKey::operator= ( const DataKey rhs)

Definition at line 52 of file DataKey.cc.

References swap, and groupFilesInBlocks::temp.

53 {
54  //An exception safe implementation is
55  DataKey temp(rhs);
56  swap(temp);
57 
58  return *this;
59 }
friend void swap(DataKey &, DataKey &)
Definition: DataKey.h:99
bool DataKey::operator== ( const DataKey iRHS) const

Definition at line 127 of file DataKey.cc.

References name_, and type_.

128 {
129  return ((type_ == iRHS.type_) &&
130  (name_ == iRHS.name_));
131 }
void edm::eventsetup::DataKey::releaseMemory ( )
inlineprivate

Definition at line 81 of file DataKey.h.

References deleteMemory(), and ownMemory_.

Referenced by ~DataKey().

81  {
82  if(ownMemory_) {
83  deleteMemory();
84  ownMemory_ = false;
85  }
86  }
void DataKey::swap ( DataKey iOther)
private

Definition at line 65 of file DataKey.cc.

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

66 {
67  std::swap(ownMemory_, iOther.ownMemory_);
68  // unqualified swap is used for user defined classes.
69  // The using directive is needed so that std::swap will be used if there is no other matching swap.
70  using std::swap;
71  swap(type_, iOther.type_);
72  swap(name_, iOther.name_);
73 }
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
friend void swap(DataKey &, DataKey &)
Definition: DataKey.h:99
const TypeTag& edm::eventsetup::DataKey::type ( ) const
inline

Friends And Related Function Documentation

void swap ( DataKey a,
DataKey b 
)
friend

Definition at line 99 of file DataKey.h.

Referenced by operator=(), swap(), and edm::eventsetup::swap().

100  {
101  a.swap(b);
102  }

Member Data Documentation

NameTag edm::eventsetup::DataKey::name_
private

Definition at line 92 of file DataKey.h.

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

bool edm::eventsetup::DataKey::ownMemory_
private

Definition at line 93 of file DataKey.h.

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

TypeTag edm::eventsetup::DataKey::type_
private