1 #ifndef ConditionsMap_h
2 #define ConditionsMap_h
7 #include "EVENT/LCCollection.h"
8 #include "Exceptions.h"
10 #include "lccd/IConditionsChangeListener.hh"
27 template <
class KEY,
class LCCONDOBJECT>
32 typedef typename std::map< KEY, LCCONDOBJECT >::iterator MapIter ;
35 typedef KEY (LCCONDOBJECT::*PMF)() ;
39 typedef KEY (LCCONDOBJECT::*PMFC)()
const ;
43 ConditionsMap( PMF pmf ) : _pmf(pmf), _pmfc(NULL) { _isPMFconst =
false; }
47 ConditionsMap( PMFC pmfc ) : _pmf(NULL), _pmfc(pmfc) { _isPMFconst =
true; }
54 const std::map< KEY, LCCONDOBJECT> &
map() {
return _map ; }
59 LCCONDOBJECT&
find( KEY key) {
61 MapIter it = _map.find( key ) ;
63 if( it == _map.end() ){
64 std::stringstream err ;
65 err <<
"ConditionsMap::find: no entry for key: " << key ;
80 for(
int i=0; i< col->getNumberOfElements() ; i++ ){
83 LCCONDOBJECT obj( col->getElementAt( i ) ) ;
86 if(_isPMFconst ==
false) {
88 _map.insert( std::make_pair( (obj.*_pmf)() , obj) ) ;
90 }
else if(_isPMFconst ==
true) {
92 _map.insert( std::make_pair( (obj.*_pmfc)() , obj) ) ;
109 os <<
"ConditionsMap"
115 for( MapIter it = _map.begin() ;
119 os <<
" key: " << it->first <<
" - [" << it->second.id() <<
"]"
120 <<
" - " <<
typeid( it->second ).name()
132 std::map< KEY, LCCONDOBJECT > _map{} ;
141 #endif // ConditionsMap_h
ConditionsMap(PMFC pmfc)
Constructor: provide the pointer to the member fuction that returns the key if it is declared const...
Definition: ConditionsMap.hh:47
void conditionsChanged(lcio::LCCollection *col)
Repopulate the map with new conditions data.
Definition: ConditionsMap.hh:75
Simple interface that allows notification of implementation classes if a conditions data set has chan...
Definition: IConditionsChangeListener.hh:22
virtual ~ConditionsMap()
The d'tor.
Definition: ConditionsMap.hh:50
ConditionsMap(PMF pmf)
Constructor: provide the pointer to the member fuction that returns the key.
Definition: ConditionsMap.hh:43
const std::map< KEY, LCCONDOBJECT > & map()
The map.
Definition: ConditionsMap.hh:54
Exception used for data not available.
Definition: lccd_exceptions.h:56
ConditionsMap()
No default c'tor.
Definition: ConditionsMap.hh:130
LCCONDOBJECT & find(KEY key)
Returns a reference to the conditions object for key.
Definition: ConditionsMap.hh:59
Template class for maps of conditions data.
Definition: ConditionsMap.hh:28
void print(std::ostream &os)
Print the conditions map to the specified output stream.
Definition: ConditionsMap.hh:107