ATLAS Offline Software
Loading...
Searching...
No Matches
TIDAFeatureStore.h
Go to the documentation of this file.
1/* emacs: this is -*- c++ -*- */
13
14
15#ifndef TIDA_FEATURESTORE_H
16#define TIDA_FEATURESTORE_H
17
18#include <iostream>
19#include <map>
20
21#include "TIDAFeature.h"
22
23
24namespace TIDA {
25
26class FeatureStore : public std::map<std::string, TIDA::FeatureBase*> {
27
28public:
29
30 typedef std::map<std::string, FeatureBase*> map_type;
31
32public:
33
35
37 const_iterator itr = begin();
38 const_iterator iend = end();
39 while( itr!=iend ) delete (itr++)->second;
40 }
41
42
43 template<typename T>
44 void insert( T* t, const std::string& key ) {
46 _insert( tt, key );
47 }
48
49
50 template<typename T>
51 int find( T*& t, const std::string& key ) {
52 TIDA::FeatureBase* f = _find(key);
53 if ( f ) {
54 TIDA::Feature<T>* fdptr = dynamic_cast<TIDA::Feature<T>*>(f);
55 if ( fdptr ) {
56 t = fdptr->cptr();
57 return 0;
58 }
59 else return -2;
60 }
61 return -1;
62 }
63
64private:
65
66 void _insert( TIDA::FeatureBase* f, const std::string& key ) {
67 map_type::insert( value_type( key, f ) );
68 }
69
70 TIDA::FeatureBase* _find( const std::string& key ) {
71 iterator itr=map_type::find(key);
72 if ( itr!=end() ) return itr->second;
73 else return 0;
74 }
75
76
77};
78
79}
80
81
82
83inline std::ostream& operator<<( std::ostream& s, const TIDA::FeatureStore& f ) {
84 TIDA::FeatureStore::const_iterator itr = f.begin();
85 TIDA::FeatureStore::const_iterator iend = f.end();
86 while( itr!=iend ) {
87 if ( itr->first.size()>5 ) s << "\t[ " << itr->first << ":\t" << itr->second << " ]\n";
88 else s << "\t[ " << itr->first << ":\t\t" << itr->second << " ]\n";
89 ++itr;
90 }
91 return s;
92}
93
94
95#endif // FEATURESTORE_H
96
97
98
99
100
101
102
103
104
105
std::ostream & operator<<(std::ostream &s, const TIDA::FeatureStore &f)
wrapper class to wrap objects such that they can be added to a generic store
very basic Feature base class just so that we can store derived classes onto the store
Definition TIDAFeature.h:29
TIDA::FeatureBase * _find(const std::string &key)
void insert(T *t, const std::string &key)
std::map< std::string, FeatureBase * > map_type
int find(T *&t, const std::string &key)
void _insert(TIDA::FeatureBase *f, const std::string &key)
actual template of the Feature wrapper - stores a pointer to an object and inherits from FeatureBase
Definition TIDAFeature.h:55
Test for xAOD.