The Gaudi Framework  v29r0 (ff2e7097)
Tuples::ItemStore< VALUE > Class Template Referencefinal

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 ()=default
 constructor : create empty map More...
 

Private Types

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

Private Member Functions

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

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, std::unique_ptr<NTuple::Item<VALUE> > > Tuples::ItemStore< VALUE >::Store
private

Definition at line 43 of file TuplePut.h.

Constructor & Destructor Documentation

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

constructor : create empty map

template<class VALUE>
Tuples::ItemStore< VALUE >::ItemStore ( const ItemStore< VALUE > &  )
privatedelete

Member Function Documentation

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

the only one method:

Definition at line 51 of file TuplePut.h.

52  {
53  // find the item by name
54  auto ifound = m_map.find( key );
55  // existing item?
56  if ( m_map.end() != ifound ) {
57  return ifound->second.get();
58  } // RETURN
59  // check the tuple for booking:
60  if ( !tuple ) {
61  return nullptr;
62  }
63  // check the existence of the name
64  if ( !tuple->goodItem( key ) ) {
65  tuple->Error( "ItemStore::getItem('" + key + "') item name is not unique" ).ignore();
66  return nullptr; // RETURN
67  }
68  // get the underlying object
69  NTuple::Tuple* tup = tuple->tuple();
70  if ( !tup ) {
71  tuple->Error( "ItemStore::getItem('" + key + "') invalid NTuple::Tuple*" ).ignore();
72  return nullptr; // RETURN
73  }
74  // create new item:
75  // add the newly created item into the store:
77  if ( !stored.second ) {
78  tuple->Warning( "ItemStore::getItem('" + key + "') item already exists, new one not inserted!" ).ignore();
79  return nullptr;
80  }
81  auto& item = stored.first->second;
82  // add it into N-tuple
83  StatusCode sc = tup->addItem( key, *item ); // ATTENTION!
84  if ( sc.isFailure() ) {
85  tuple->Error( "ItemStore::getItem('" + key + "') cannot addItem", sc ).ignore();
86  m_map.erase( stored.first );
87  return nullptr; // RETURN
88  }
89  // check the name again
90  if ( !tuple->addItem( key, System::typeinfoName( typeid( VALUE ) ) ) ) {
91  tuple->Warning( "ItemStore::getItem('" + key + "') the item not unique " ).ignore();
92  m_map.erase( stored.first );
93  return nullptr;
94  }
95  //
96  return item.get(); // RETURN
97  }
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1935
bool goodItem(const std::string &name) const
check the uniqueness of the name
Definition: TupleObj.h:1995
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:329
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
virtual StatusCode Warning(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:1986
iterator end()
Definition: Map.h:134
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Store m_map
the underlying map
Definition: TuplePut.h:106
iterator find(const key_type &key)
Definition: Map.h:151
std::pair< iterator, bool > emplace(Args &&...args)
Definition: Map.h:169
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:412
STL class.
iterator erase(const_iterator pos)
Definition: Map.h:192
virtual StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
Definition: NTuple.h:572
void ignore() const
Definition: StatusCode.h:109
template<class VALUE>
ItemStore& Tuples::ItemStore< VALUE >::operator= ( const ItemStore< VALUE > &  )
privatedelete

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 106 of file TuplePut.h.


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