test
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 | Protected Member Functions | Protected Attributes
DDI::Store< N, I, K > Class Template Reference

#include <Store.h>

Public Types

typedef registry_type::iterator iterator
 
typedef K key_type
 
typedef N name_type
 
typedef I pimpl_type
 
typedef Rep_typeprep_type
 
typedef std::map< name_type,
prep_type
registry_type
 
typedef rep_type< name_type,
pimpl_type
Rep_type
 

Public Member Functions

auto begin ()
 
void clear ()
 
prep_type create (const name_type &)
 
prep_type create (const name_type &, pimpl_type)
 
auto end ()
 
bool isDefined (const name_type &n) const
 
bool readOnly () const
 
void setReadOnly (bool b)
 
auto size () const
 
 Store ()
 
void swap (Store &)
 
 ~Store ()
 

Protected Member Functions

Storeoperator= (const Store &)
 
 Store (const Store &)
 

Protected Attributes

bool readOnly_
 
std::map< name_type, prep_typereg_
 

Detailed Description

template<class N, class I, class K = I>
class DDI::Store< N, I, K >

A Store provides a place for objects of type I which are uniquely identified by there name of type N. The objects themselves can be accessed indirectly by the prep_type of the Store like

typedef Store<std::string,double> NamedDouble; NamedDouble::prep_type d = NamedDouble("Four", new double(4.)); double val = *(d->second); std::string name = d->first;

K is the key_type which is used as an index in the storage. It must fulfill all requirements for a key in a sorted associative container. N is the user-friendly name_type, which must be mapped uniquely to the key_type and vice versa. N itself must also fulfill all requirements of a key in a sorted associative container. The reason to provide K is that one might save some memory by compacting common parts of information contained in different instances of N, e.g. if N is a pair<string,string>, the first string being a 'namespace' the second a 'name' then K could be a pair<int,string> thus compacting the namespace-string to a simple int. K and N must support following unique conversions:

Definition at line 37 of file Store.h.

Member Typedef Documentation

template<class N, class I, class K = I>
typedef registry_type::iterator DDI::Store< N, I, K >::iterator

Definition at line 46 of file Store.h.

template<class N, class I, class K = I>
typedef K DDI::Store< N, I, K >::key_type

Definition at line 42 of file Store.h.

template<class N, class I, class K = I>
typedef N DDI::Store< N, I, K >::name_type

Definition at line 40 of file Store.h.

template<class N, class I, class K = I>
typedef I DDI::Store< N, I, K >::pimpl_type

Definition at line 41 of file Store.h.

template<class N, class I, class K = I>
typedef Rep_type* DDI::Store< N, I, K >::prep_type

Definition at line 44 of file Store.h.

template<class N, class I, class K = I>
typedef std::map<name_type,prep_type> DDI::Store< N, I, K >::registry_type

Definition at line 45 of file Store.h.

template<class N, class I, class K = I>
typedef rep_type<name_type, pimpl_type> DDI::Store< N, I, K >::Rep_type

Definition at line 43 of file Store.h.

Constructor & Destructor Documentation

template<class N, class I, class K = I>
DDI::Store< N, I, K >::Store ( )
inline

Definition at line 68 of file Store.h.

68 : readOnly_(false) { }
bool readOnly_
Definition: Store.h:75
template<class N , class I , class K >
DDI::Store< N, I, K >::~Store ( )

Definition at line 112 of file Store.h.

113  {
114  for( auto it : reg_ ) {
115  delete it.second->second;
116  it.second->second = 0;
117  delete it.second;
118  it.second = 0;
119  }
120  }
std::map< name_type, prep_type > reg_
Definition: Store.h:72
template<class N, class I, class K = I>
DDI::Store< N, I, K >::Store ( const Store< N, I, K > &  )
protected

Member Function Documentation

template<class N, class I, class K = I>
auto DDI::Store< N, I, K >::begin ( void  )
inline

Definition at line 48 of file Store.h.

48 { return reg_.begin(); }
std::map< name_type, prep_type > reg_
Definition: Store.h:72
template<class N, class I, class K = I>
void DDI::Store< N, I, K >::clear ( )
template<class N , class I , class K >
Store< N, I, K >::prep_type DDI::Store< N, I, K >::create ( const name_type n)

Definition at line 80 of file Store.h.

References Exception, Exhume::I, mps_fire::result, and tmp.

81  {
82  prep_type tmp = 0;
83  auto result = reg_.insert(std::make_pair(n,tmp));
84  if (result.second) {
85  if (readOnly_) throw cms::Exception("DetectorDescriptionStore")<<" Store has been locked. Illegal attempt to add " << n << " to a global store.";
86  // ELSE
87  result.first->second = new Rep_type(n,(I)0);
88  }
89  return result.first->second;
90  }
Rep_type * prep_type
Definition: Store.h:44
tuple result
Definition: mps_fire.py:84
rep_type< name_type, pimpl_type > Rep_type
Definition: Store.h:43
bool readOnly_
Definition: Store.h:75
std::map< name_type, prep_type > reg_
Definition: Store.h:72
const std::complex< double > I
Definition: I.h:8
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
template<class N , class I , class K >
Store< N, I, K >::prep_type DDI::Store< N, I, K >::create ( const name_type n,
pimpl_type  p 
)

Definition at line 94 of file Store.h.

References Exception, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and tmp.

96  {
97  if (readOnly_) throw cms::Exception("DetectorDescriptionStore")<<" Store has been locked. Illegal attempt to add " << n << " to a global store.";
98  // ELSE
99  prep_type tmp = 0;
100  auto result = reg_.insert(std::make_pair(n,tmp));
101  if (!result.second) {
102  delete result.first->second->second;
103  result.first->second->second = p;
104  }
105  else {
106  result.first->second = new Rep_type(n,p);
107  }
108  return result.first->second;
109  }
Rep_type * prep_type
Definition: Store.h:44
tuple result
Definition: mps_fire.py:84
rep_type< name_type, pimpl_type > Rep_type
Definition: Store.h:43
bool readOnly_
Definition: Store.h:75
std::map< name_type, prep_type > reg_
Definition: Store.h:72
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
template<class N, class I, class K = I>
auto DDI::Store< N, I, K >::end ( void  )
inline

Definition at line 49 of file Store.h.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

49 { return reg_.end(); }
std::map< name_type, prep_type > reg_
Definition: Store.h:72
template<class N , class I , class K >
bool DDI::Store< N, I, K >::isDefined ( const name_type n) const

Definition at line 123 of file Store.h.

References mps_fire::result.

124  {
125  if (readOnly_) edm::LogWarning("DetectorDescriptionStore") << " Store is locked and most likely empty. isDefined will be false.";
126  auto it = reg_.find(n);
127  bool result(false);
128  if (it != reg_.end()) {
129  if (it.second->second) {
130  result=true;
131  }
132  }
133  return result;
134  }
tuple result
Definition: mps_fire.py:84
bool readOnly_
Definition: Store.h:75
std::map< name_type, prep_type > reg_
Definition: Store.h:72
template<class N, class I, class K = I>
Store& DDI::Store< N, I, K >::operator= ( const Store< N, I, K > &  )
protected
template<class N, class I, class K = I>
bool DDI::Store< N, I, K >::readOnly ( ) const
inline

Definition at line 66 of file Store.h.

66 { return readOnly_; }
bool readOnly_
Definition: Store.h:75
template<class N, class I, class K = I>
void DDI::Store< N, I, K >::setReadOnly ( bool  b)
inline

Definition at line 65 of file Store.h.

65 { readOnly_ = b; }
bool readOnly_
Definition: Store.h:75
double b
Definition: hdecay.h:120
template<class N, class I, class K = I>
auto DDI::Store< N, I, K >::size ( void  ) const
inline

Definition at line 50 of file Store.h.

50 { return reg_.size(); }
std::map< name_type, prep_type > reg_
Definition: Store.h:72
template<class N , class I , class K >
void DDI::Store< N, I, K >::swap ( Store< N, I, K > &  storeToSwap)

Definition at line 137 of file Store.h.

References DDI::Store< N, I, K >::readOnly_, and DDI::Store< N, I, K >::reg_.

137  {
138  reg_.swap(storeToSwap.reg_);
139  storeToSwap.readOnly_ = readOnly_;
140  }
bool readOnly_
Definition: Store.h:75
std::map< name_type, prep_type > reg_
Definition: Store.h:72

Member Data Documentation

template<class N, class I, class K = I>
bool DDI::Store< N, I, K >::readOnly_
protected
template<class N, class I, class K = I>
std::map<name_type,prep_type> DDI::Store< N, I, K >::reg_
protected