ATLAS Offline Software
Loading...
Searching...
No Matches
Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGCOMBINEDEVENT_TRIGCOMPOSITE_H
6#define TRIGCOMBINEDEVENT_TRIGCOMPOSITE_H
7
9#include "GaudiKernel/ClassID.h"
11
12#include <string>
13#include <vector>
14#include <set>
15#include <map>
16
17class MsgStream;
18
19
20
28
29 public:
30
31
35 TrigComposite(const std::string& name);
36 //
40 TrigComposite() = default;
41 TrigComposite(TrigComposite&&) noexcept = default;
42 TrigComposite& operator=(TrigComposite&&) noexcept = default;
43 ~TrigComposite() = default;
44 //
49 TrigComposite(const std::string& name, std::string& label1, TrigFeatureLink t1, std::string& label2, TrigFeatureLink t2);
50
51
52 inline const std::string& name() const { return m_name; }
53
54
65 template<typename T>
66 void setFormat(const std::vector<std::string>& keys, bool mustBeSet=false);
67
71 bool isValid() const;
72
76 inline void lockFormat(){m_locked=true;}
77
81 inline bool isFormatLocked() const {return m_locked; }
82
83
87 inline void unlockFormat(){m_locked=false;}
88
89
94 void addObject(const std::string& key, TrigFeatureLink link);
95
96
101 void setObject(const std::string& key, TrigFeatureLink link);
102
106 bool hasObject(const std::string& key) const;
107
111 const TrigFeatureLink& getObject(const std::string& key) const;
112
113
118 template<typename T>
119 std::vector<TrigFeatureLink> getObjectsByType(const std::string& keypart="") const;
120
121
122
127 template<typename T>
128 void addDetail(const std::string& key, const T& value=T());
129
134 template<typename T>
135 void setDetail(const std::string& key, const T& value);
136
137
142 template<typename T>
143 bool hasDetail(const std::string& key) const;
144
145
149 template<typename T>
150 const T& getDetail(const std::string& key) const;
151
157
158 template<class T>
159 const std::map<std::string, T>& allDetails() const {
160 return detailsMap<T>();
161 }
162
163
168 template<typename T>
169 void eraseDetail(const std::string& key);
170
171
172
173private:
174 template<class T>
175 void mustSet(const std::string& key);
176
177 typedef std::set<std::string> MustSetList;
178
179 std::map<std::string, TrigFeatureLink > m_links;
181
182 std::map<std::string, float > m_floats;
184
185 std::map<std::string, int> m_ints;
187
188 std::map<std::string, std::string> m_strings;
190
191 std::map<std::string, std::vector<float> > m_v_floats;
193
194 std::map<std::string, std::vector<int> > m_v_ints;
196
197 std::map<std::string, std::vector<std::string> > m_v_strings;
199
200 template<typename T>
201 std::map<std::string, T>& detailsMap();
202
203 template<typename T>
204 const std::map<std::string, T>& detailsMap() const;
205
206 template<typename T>
208
209
210 template<typename T>
211 const T& specimen() const; // needed in order to produce the "NULL" detail
212
213
214 std::string m_name{"dummy"};
215 bool m_locked{false};
216
217};
218
222MsgStream& operator<< ( MsgStream& m, const TrigComposite& d );
223
224
225template<typename T>
226std::vector<TrigFeatureLink> TrigComposite::getObjectsByType(const std::string& keypart) const {
227 const CLID requested_clid = ClassID_traits<T>::ID();
228 std::vector<TrigFeatureLink> result;
229 for ( std::map<std::string, TrigFeatureLink>::const_iterator i = m_links.begin(); i != m_links.end(); ++i ) {
230 if ( i->second.clid() == requested_clid and i->first.find(keypart) != std::string::npos)
231 result.push_back(i->second);
232 }
233 return result;
234}
235
236
237
238
240CLASS_DEF( TrigComposite , 231914326 , 1 )
241
242
243
244#endif // __TrigComposite_h__
245
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
uint32_t CLID
The Class ID type.
MsgStream & operator<<(MsgStream &m, const TrigComposite &d)
Prints the content of the object.
The class is meant to store links (of type TrigFeatureLink) to trigger objects and arbitrary details ...
TrigComposite(TrigComposite &&) noexcept=default
const std::map< std::string, T > & allDetails() const
return the map of all the details Notie that the non-const version is not provided because it would a...
bool hasDetail(const std::string &key) const
Checks if the object contains detail of the type T No verification is made if it is set.
void eraseDetail(const std::string &key)
erases the detail if it existed If the details inder that key did not exist, no action is performed.
void setFormat(const std::vector< std::string > &keys, bool mustBeSet=false)
defines the content (details which must to be stored) The method can be used to enforce certain conte...
const T & specimen() const
void mustSet(const std::string &key)
bool isValid() const
Checks the validity of the format, i.e.
bool hasObject(const std::string &key) const
checks if the object has link to the object under the key
void lockFormat()
makes further addition of the details impossible
std::vector< TrigFeatureLink > getObjectsByType(const std::string &keypart="") const
get all links which point to objects of given type
void unlockFormat()
makes addition of further details possible again
std::map< std::string, std::vector< std::string > > m_v_strings
void setObject(const std::string &key, TrigFeatureLink link)
sets the link
bool isFormatLocked() const
return true if the format can not be further changed (no addDetail can be called)
const TrigFeatureLink & getObject(const std::string &key) const
returns
TrigComposite()=default
Default constructor should not be normally used, needed by the persistency layer.
const T & getDetail(const std::string &key) const
return the value of the detail, if the key is absent the default is returned
void setDetail(const std::string &key, const T &value)
sets the value user the key, if they detail under that key already exists it's value is overwritten,...
MustSetList & detailsMustSetList()
void addDetail(const std::string &key, const T &value=T())
adds the value user the key, if they detail under that key already exists the exception is thrown If ...
std::map< std::string, T > & detailsMap()
std::map< std::string, std::vector< float > > m_v_floats
TrigComposite(const std::string &name)
Constructs empty composite, no objects no details.
void addObject(const std::string &key, TrigFeatureLink link)
adds the link
STL namespace.