CMS 3D CMS Logo

DDI::Store< N, I, K > Class Template Reference

A Store provides a place for objects of type I which are uniquely identified by there name of type N. More...

#include <DetectorDescription/Base/interface/Store.h>

List of all members.

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

const_iterator begin () const
iterator begin ()
void clear ()
prep_type create (pimpl_type)
prep_type create (const name_type &, pimpl_type)
prep_type create (const name_type &)
const_iterator end () const
iterator end ()
bool isDefined (const name_type &n) const
bool readOnly () const
void setReadOnly (bool b)
size_type size () const
 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-fristdendly name_type, which must be std::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<std::string,std::string>, the first std::string being a 'namespace' the second a 'name' then K could be a pair<int,std::string> thus compacting the namespace-stdstring 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 85 of file Store.h.

00085 : readOnly_(false) { }

template<class N, class I, class K>
DDI::Store< N, I, K >::~Store (  )  [inline]

Definition at line 158 of file Store.h.

References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), it, and DDI::Store< N, I, K >::reg_.

00159  {
00160    typename registry_type::iterator it = reg_.begin();
00161    for(; it != reg_.end(); ++it) {
00162      std::cout << "deleting " << it->first << std::endl;
00163      delete it->second->second; it->second->second = 0;
00164      delete it->second; it->second = 0;
00165    }
00166  } 

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>
const_iterator DDI::Store< N, I, K >::begin (  )  const [inline]

Definition at line 64 of file Store.h.

00064 { return reg_.begin(); }

template<class N, class I, class K = I>
iterator DDI::Store< N, I, K >::begin (  )  [inline]

Definition at line 63 of file Store.h.

00063 { return reg_.begin(); }

template<class N, class I, class K>
void DDI::Store< N, I, K >::clear ( void   )  [inline]

Definition at line 105 of file Store.h.

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

00106 {
00107   typename registry_type::iterator it = reg_.begin();
00108   for (; it != reg_.end(); ++it) {
00109     delete it->second->second;
00110     delete it->second;
00111   }  
00112   reg_.clear();
00113 }

template<class N, class I, class K = I>
prep_type DDI::Store< N, I, K >::create ( pimpl_type   ) 

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 
) [inline]

Definition at line 131 of file Store.h.

References DDI::Store< N, I, K >::reg_, HLT_VtxMuL3::result, and tmp.

00133  {                                        
00134    prep_type tmp = 0;
00135      std::pair<typename registry_type::iterator,bool> result 
00136        = reg_.insert(std::make_pair(n,tmp));
00137      if (!result.second) {
00138        delete result.first->second->second;
00139        result.first->second->second = p;
00140        //delete result.first->second->swap(p);
00141      }
00142      else {
00143        result.first->second = new Rep_type(n,p);
00144      }
00145      return result.first->second;
00146  }

template<class N, class I, class K>
Store< N, I, K >::prep_type DDI::Store< N, I, K >::create ( const name_type n  )  [inline]

Definition at line 117 of file Store.h.

References I, DDI::Store< N, I, K >::reg_, HLT_VtxMuL3::result, and tmp.

00118  {
00119    prep_type tmp = 0;
00120    std::pair<typename registry_type::iterator,bool> result 
00121      = reg_.insert(std::make_pair(n,tmp));
00122    if (result.second) {
00123      result.first->second = new Rep_type(n,(I)0);
00124    }
00125    return result.first->second;    
00126  }

template<class N, class I, class K = I>
const_iterator DDI::Store< N, I, K >::end (  )  const [inline]

Definition at line 66 of file Store.h.

00066 { return reg_.end(); }

template<class N, class I, class K = I>
iterator DDI::Store< N, I, K >::end (  )  [inline]

Definition at line 65 of file Store.h.

00065 { return reg_.end(); }

template<class N, class I, class K>
bool DDI::Store< N, I, K >::isDefined ( const name_type n  )  const [inline]

Definition at line 169 of file Store.h.

References it, DDI::Store< N, I, K >::reg_, and HLT_VtxMuL3::result.

00170 {
00171   typename registry_type::const_iterator it = reg_.find(n);
00172   bool result(false);
00173   if (it != reg_.end()) {
00174     if (it->second->second) {
00175       result=true;
00176     }  
00177   }
00178   return result;
00179 }

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 83 of file Store.h.

00083 { return readOnly_; }

template<class N, class I, class K = I>
void DDI::Store< N, I, K >::setReadOnly ( bool  b  )  [inline]

Definition at line 82 of file Store.h.

00082 { readOnly_ = b; }

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.

00067 { return reg_.size(); } 


Member Data Documentation

template<class N, class I, class K = I>
bool DDI::Store< N, I, K >::readOnly_ [protected]

Definition at line 91 of file Store.h.

Referenced by DDI::Store< N, C >::readOnly(), and DDI::Store< N, C >::setReadOnly().

template<class N, class I, class K = I>
registry_type DDI::Store< N, I, K >::reg_ [protected]

Definition at line 90 of file Store.h.

Referenced by DDI::Store< N, C >::begin(), DDI::Store< N, I, K >::clear(), DDI::Store< N, I, K >::create(), DDI::Store< N, C >::end(), DDI::Store< N, I, K >::isDefined(), DDI::Store< N, C >::size(), and DDI::Store< N, I, K >::~Store().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:37:10 2009 for CMSSW by  doxygen 1.5.4