00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <memory>
00016
00017
00018 #include "FWCore/Framework/interface/DataKey.h"
00019
00020
00021
00022
00023
00024 namespace edm {
00025 namespace eventsetup {
00026
00027
00028
00029
00030
00031
00032
00033 DataKey::DataKey(): type_(), name_(), ownMemory_(false)
00034 {
00035 }
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 const DataKey& DataKey::operator=(const DataKey& rhs)
00050 {
00051
00052 DataKey temp(rhs);
00053 swap(temp);
00054
00055 return *this;
00056 }
00057
00058
00059
00060
00061 void
00062 DataKey::swap(DataKey& iOther)
00063 {
00064 std::swap(ownMemory_, iOther.ownMemory_);
00065
00066
00067 using std::swap;
00068 swap(type_, iOther.type_);
00069 swap(name_, iOther.name_);
00070 }
00071
00072 void
00073 DataKey::makeCopyOfMemory()
00074 {
00075
00076 static const char kBlank = '\0';
00077
00078 char* pName = const_cast<char*>(&kBlank);
00079
00080
00081
00082 std::auto_ptr<char> pNameHolder;
00083 if(kBlank != name().value()[0]) {
00084 pName = new char[ std::strlen(name().value()) + 1];
00085 pNameHolder = std::auto_ptr<char>(pName);
00086 std::strcpy(pName, name().value());
00087 }
00088 name_ = NameTag(pName);
00089 ownMemory_ = true;
00090 pNameHolder.release();
00091 }
00092
00093 void
00094 DataKey::deleteMemory()
00095 {
00096 static const char kBlank = '\0';
00097
00098 if(kBlank != name().value()[0]) {
00099 delete [] const_cast<char*>(name().value());
00100 }
00101 }
00102
00103
00104
00105
00106 bool
00107 DataKey::operator==(const DataKey& iRHS) const
00108 {
00109 return ((type_ == iRHS.type_) &&
00110 (name_ == iRHS.name_));
00111 }
00112
00113 bool
00114 DataKey::operator<(const DataKey& iRHS) const
00115 {
00116 return (type_ < iRHS.type_) ||
00117 ((type_ == iRHS.type_) && (name_ < iRHS.name_));
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 }
00128
00129
00130
00131
00132 }
00133 }
00134
00135 #include "FWCore/Framework/interface/HCTypeTag.icc"
00136 template class edm::eventsetup::heterocontainer::HCTypeTag<edm::eventsetup::DataKey>;