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::const_iterator 
const_iterator
 
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
 
typedef registry_type::size_type size_type
 

Public Member Functions

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

Protected Member Functions

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

Protected Attributes

bool readOnly_
 
registry_type reg_
 

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::const_iterator DDI::Store< N, I, K >::const_iterator

Definition at line 60 of file Store.h.

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

Definition at line 59 of file Store.h.

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

Definition at line 43 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 56 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 58 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 44 of file Store.h.

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

Definition at line 61 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 88 of file Store.h.

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

Definition at line 157 of file Store.h.

158  {
159  typename registry_type::iterator it = reg_.begin();
160  for(; it != reg_.end(); ++it) {
161  // std::cout << "deleting " << it->first << std::endl;
162  delete it->second->second; it->second->second = 0;
163  delete it->second; it->second = 0;
164  }
165  }
registry_type reg_
Definition: Store.h:92
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>
iterator DDI::Store< N, I, K >::begin ( void  )
inline

Definition at line 63 of file Store.h.

63 { return reg_.begin(); }
registry_type reg_
Definition: Store.h:92
template<class N, class I, class K = I>
const_iterator DDI::Store< N, I, K >::begin ( void  ) const
inline

Definition at line 64 of file Store.h.

64 { return reg_.begin(); }
registry_type reg_
Definition: Store.h:92
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 121 of file Store.h.

References edm::hlt::Exception, Exhume::I, query::result, and tmp.

122  {
123  prep_type tmp = 0;
124  std::pair<typename registry_type::iterator,bool> result
125  = reg_.insert(std::make_pair(n,tmp));
126  if (result.second) {
127  if (readOnly_) throw cms::Exception("DetectorDescriptionStore")<<" Store has been locked. Illegal attempt to add " << n << " to a global store.";
128  // ELSE
129  result.first->second = new Rep_type(n,(I)0);
130  }
131  return result.first->second;
132  }
Rep_type * prep_type
Definition: Store.h:56
rep_type< name_type, pimpl_type > Rep_type
Definition: Store.h:44
bool readOnly_
Definition: Store.h:95
tuple result
Definition: query.py:137
const std::complex< double > I
Definition: I.h:8
registry_type reg_
Definition: Store.h:92
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 137 of file Store.h.

References edm::hlt::Exception, AlCaHLTBitMon_ParallelJobs::p, query::result, and tmp.

139  {
140  if (readOnly_) throw cms::Exception("DetectorDescriptionStore")<<" Store has been locked. Illegal attempt to add " << n << " to a global store.";
141  // ELSE
142  prep_type tmp = 0;
143  std::pair<typename registry_type::iterator,bool> result
144  = reg_.insert(std::make_pair(n,tmp));
145  if (!result.second) {
146  delete result.first->second->second;
147  result.first->second->second = p;
148  //delete result.first->second->swap(p);
149  }
150  else {
151  result.first->second = new Rep_type(n,p);
152  }
153  return result.first->second;
154  }
Rep_type * prep_type
Definition: Store.h:56
rep_type< name_type, pimpl_type > Rep_type
Definition: Store.h:44
bool readOnly_
Definition: Store.h:95
tuple result
Definition: query.py:137
registry_type reg_
Definition: Store.h:92
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
template<class N, class I, class K = I>
iterator DDI::Store< N, I, K >::end ( void  )
inline

Definition at line 65 of file Store.h.

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

65 { return reg_.end(); }
registry_type reg_
Definition: Store.h:92
template<class N, class I, class K = I>
const_iterator DDI::Store< N, I, K >::end ( void  ) const
inline

Definition at line 66 of file Store.h.

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

66 { return reg_.end(); }
registry_type reg_
Definition: Store.h:92
template<class N , class I , class K >
bool DDI::Store< N, I, K >::isDefined ( const name_type n) const

Definition at line 176 of file Store.h.

References query::result.

177  {
178  if (readOnly_) edm::LogWarning("DetectorDescriptionStore") << " Store is locked and most likely empty. isDefined will be false.";
179  typename registry_type::const_iterator it = reg_.find(n);
180  bool result(false);
181  if (it != reg_.end()) {
182  if (it->second->second) {
183  result=true;
184  }
185  }
186  return result;
187  }
bool readOnly_
Definition: Store.h:95
tuple result
Definition: query.py:137
registry_type reg_
Definition: Store.h:92
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 86 of file Store.h.

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

Definition at line 85 of file Store.h.

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

Definition at line 67 of file Store.h.

67 { return reg_.size(); }
registry_type reg_
Definition: Store.h:92
template<class N , class I , class K >
void DDI::Store< N, I, K >::swap ( Store< N, I, K > &  storeToSwap)

Definition at line 190 of file Store.h.

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

190  {
191  reg_.swap(storeToSwap.reg_);
192  storeToSwap.readOnly_ = readOnly_;
193  }
bool readOnly_
Definition: Store.h:95
registry_type reg_
Definition: Store.h:92

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>
registry_type DDI::Store< N, I, K >::reg_
protected