All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Tuples::ItemStore< VALUE > Class Template Reference

Simple class, which represents the local storage of N-tuple items of the given type. More...

#include <GaudiAlg/TuplePut.h>

Collaboration diagram for Tuples::ItemStore< VALUE >:

Public Member Functions

 ItemStore ()
 constructor : create empty map More...
 
 ~ItemStore ()
 destructor : delete all known entries More...
 

Protected Member Functions

NTuple::Item< VALUE > * getItem (const std::string &key, Tuples::TupleObj *tuple)
 the only one method: More...
 

Private Types

typedef GaudiUtils::HashMap
< std::string, NTuple::Item
< VALUE > * > 
Store
 

Private Member Functions

 ItemStore (const ItemStore &)
 no copy is allowed More...
 
ItemStoreoperator= (const ItemStore &)
 no assignment is allowed More...
 

Private Attributes

Store m_map
 the underlying map More...
 

Friends

class TupleObj
 

Detailed Description

template<class VALUE>
class Tuples::ItemStore< VALUE >

Simple class, which represents the local storage of N-tuple items of the given type.

Essentially it is a restricted GaudiUtils::HashMap with the ownership of the newly created entries

Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-04-08

Definition at line 38 of file TuplePut.h.

Member Typedef Documentation

template<class VALUE>
typedef GaudiUtils::HashMap<std::string,NTuple::Item<VALUE>*> Tuples::ItemStore< VALUE >::Store
private

Definition at line 42 of file TuplePut.h.

Constructor & Destructor Documentation

template<class VALUE>
Tuples::ItemStore< VALUE >::ItemStore ( )
inline

constructor : create empty map

Definition at line 45 of file TuplePut.h.

45 : m_map() {}
Store m_map
the underlying map
Definition: TuplePut.h:111
template<class VALUE>
Tuples::ItemStore< VALUE >::~ItemStore ( )
inline

destructor : delete all known entries

Definition at line 47 of file TuplePut.h.

48  {
49  for ( typename Store::iterator ientry = m_map.begin() ;
50  m_map.end() != ientry ; ++ientry )
51  { if ( 0 != ientry->second ) { delete ientry->second ; } }
52  }
iterator end()
Definition: Map.h:131
Store m_map
the underlying map
Definition: TuplePut.h:111
iterator begin()
Definition: Map.h:130
template<class VALUE>
Tuples::ItemStore< VALUE >::ItemStore ( const ItemStore< VALUE > &  )
private

no copy is allowed

Member Function Documentation

template<class VALUE>
NTuple::Item<VALUE>* Tuples::ItemStore< VALUE >::getItem ( const std::string &  key,
Tuples::TupleObj tuple 
)
inlineprotected

the only one method:

Definition at line 56 of file TuplePut.h.

57  {
58  // find the item by name
59  typename Store::iterator ifound = m_map.find( key ) ;
60  // existing item?
61  if ( m_map.end() != ifound ) { return ifound->second ; } // RETURN
62  // check the tuple for booking:
63  if ( 0 == tuple ) { return 0 ; }
64  // check the existence of the name
65  if ( !tuple->goodItem ( key ) )
66  {
67  tuple -> Error ( "ItemStore::getItem('" + key
68  + "') item name is not unique").ignore() ;
69  return 0 ; // RETURN
70  }
71  // get the underlying object
72  NTuple::Tuple* tup = tuple->tuple() ;
73  if ( 0 == tup )
74  {
75  tuple -> Error ( "ItemStore::getItem('" + key
76  + "') invalid NTuple::Tuple*" ).ignore() ;
77  return 0 ; // RETURN
78  }
79  // create new item:
81  // add it into N-tuple
82  StatusCode sc = tup->addItem( key , *item ) ; // ATTENTION!
83  if ( sc.isFailure() )
84  {
85  tuple -> Error ( "ItemStore::getItem('" + key
86  + "') cannot addItem" , sc ).ignore() ;
87  return 0 ; // RETURN
88  }
89  // check the name again
90  if ( !tuple->addItem( key , System::typeinfoName ( typeid ( VALUE ) ) ) )
91  {
92  tuple -> Warning ( "ItemStore::getItem('" + key
93  + "') the item not unique " ).ignore() ;
94  }
95  // add the newly created item into the store:
96  if ( !m_map.insert ( std::make_pair ( key , item ) ).second )
97  {
98  tuple -> Warning ( "ItemStore::getItem('" + key
99  + "') item is not inserted!" ).ignore() ;
100  }
101  //
102  return item ; // RETURN
103  }
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:2142
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:2088
std::pair< iterator, bool > insert(const value_type &val)
Definition: Map.h:165
iterator end()
Definition: Map.h:131
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
Store m_map
the underlying map
Definition: TuplePut.h:111
iterator find(const key_type &key)
Definition: Map.h:148
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:367
bool addItem(const std::string &name, const std::string &type)
add the item name into the list of known items
Definition: TupleObj.h:2134
tuple item
print s1,s2
Definition: ana.py:146
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
Definition: NTuple.h:551
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:43
template<class VALUE>
ItemStore& Tuples::ItemStore< VALUE >::operator= ( const ItemStore< VALUE > &  )
private

no assignment is allowed

Friends And Related Function Documentation

template<class VALUE>
friend class TupleObj
friend

Definition at line 40 of file TuplePut.h.

Member Data Documentation

template<class VALUE>
Store Tuples::ItemStore< VALUE >::m_map
private

the underlying map

the underlying map

Definition at line 111 of file TuplePut.h.


The documentation for this class was generated from the following file: