ATLAS Offline Software
Loading...
Searching...
No Matches
TrigComposite Class Reference

The class is meant to store links (of type TrigFeatureLink) to trigger objects and arbitrary details (of type, float, int, string, or vectors of those) More...

#include <TrigComposite.h>

Collaboration diagram for TrigComposite:

Public Member Functions

 TrigComposite (const std::string &name)
 Constructs empty composite, no objects no details.
 TrigComposite (const std::string &name, std::string &label1, TrigFeatureLink t1, std::string &label2, TrigFeatureLink t2)
 Constructs composite with the links to two trigger objects/links to them The validity of the links is not checked during the construction.
const std::string & name () const
template<typename T>
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 content of the object (set the demand that the deail are set).
bool isValid () const
 Checks the validity of the format, i.e.
void lockFormat ()
 makes further addition of the details impossible
bool isFormatLocked () const
 return true if the format can not be further changed (no addDetail can be called)
void unlockFormat ()
 makes addition of further details possible again
void addObject (const std::string &key, TrigFeatureLink link)
 adds the link
void setObject (const std::string &key, TrigFeatureLink link)
 sets the link
bool hasObject (const std::string &key) const
 checks if the object has link to the object under the key
const TrigFeatureLinkgetObject (const std::string &key) const
 returns
template<typename T>
std::vector< TrigFeatureLinkgetObjectsByType (const std::string &keypart="") const
 get all links which point to objects of given type
template<typename T>
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 the format is locked the exception is thrown each time
template<typename T>
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, If the key does not exists, the exception is thrown
template<typename T>
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.
template<typename T>
const T & getDetail (const std::string &key) const
 return the value of the detail, if the key is absent the default is returned
template<class T>
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 allow to circumvent format fixing whcih may be defined for this object.
template<typename T>
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.
 TrigComposite ()
 Deafault constructor, should not be normally used, needed by the persistency layer.
 ~TrigComposite ()
 Destructor, does nothing special in fact, no links are touched.

Private Types

typedef std::set< std::string > MustSetList

Private Member Functions

template<class T>
void mustSet (const std::string &key)
template<typename T>
std::map< std::string, T > & detailsMap ()
template<typename T>
const std::map< std::string, T > & detailsMap () const
template<typename T>
MustSetListdetailsMustSetList ()
template<typename T>
const T & specimen () const

Private Attributes

std::map< std::string, TrigFeatureLinkm_links
MustSetList m_linksToBeSet
std::map< std::string, float > m_floats
MustSetList m_floatsToBeSet
std::map< std::string, int > m_ints
MustSetList m_intsToBeSet
std::map< std::string, std::string > m_strings
MustSetList m_stringsToBeSet
std::map< std::string, std::vector< float > > m_v_floats
MustSetList m_v_floatsToBeSet
std::map< std::string, std::vector< int > > m_v_ints
MustSetList m_v_intsToBeSet
std::map< std::string, std::vector< std::string > > m_v_strings
MustSetList m_v_stringsToBeSet
std::string m_name
bool m_locked

Detailed Description

The class is meant to store links (of type TrigFeatureLink) to trigger objects and arbitrary details (of type, float, int, string, or vectors of those)

Author
Camille Belanger-Champagne
Tomasz Bold

Definition at line 26 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

Member Typedef Documentation

◆ MustSetList

typedef std::set<std::string> TrigComposite::MustSetList
private

Constructor & Destructor Documentation

◆ TrigComposite() [1/3]

TrigComposite::TrigComposite ( const std::string & name)

◆ TrigComposite() [2/3]

TrigComposite::TrigComposite ( const std::string & name,
std::string & label1,
TrigFeatureLink t1,
std::string & label2,
TrigFeatureLink t2 )

Constructs composite with the links to two trigger objects/links to them The validity of the links is not checked during the construction.

Definition at line 26 of file TrigComposite.cxx.

27 : m_name(name),
28 m_locked(false)
29{
30 addObject(label1, t1);
31 addObject(label2, t2);
32}
void addObject(const std::string &key, TrigFeatureLink link)
adds the link

◆ TrigComposite() [3/3]

TrigComposite::TrigComposite ( )

Deafault constructor, should not be normally used, needed by the persistency layer.

Definition at line 13 of file TrigComposite.cxx.

14 : m_name("dummy"),
15 m_locked(false)
16{
17}

◆ ~TrigComposite()

TrigComposite::~TrigComposite ( )

Destructor, does nothing special in fact, no links are touched.

Definition at line 83 of file TrigComposite.cxx.

83{}

Member Function Documentation

◆ addDetail()

template<typename T>
void TrigComposite::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 the format is locked the exception is thrown each time

Definition at line 89 of file TrigComposite.cxx.

89 {
90 if ( isFormatLocked() )
91 throw std::invalid_argument("The format of TrigComposite object has been locked, addDetails can not be used anymore, see unlockFormat or setDetail");
92 if ( hasDetail<T>(key) )
93 throw std::invalid_argument("The TrigCompositeObejct already has key: "+ key);
94
95 // now it needs to fins appropriate collection and add to it the value
97}
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.
bool isFormatLocked() const
return true if the format can not be further changed (no addDetail can be called)
std::map< std::string, T > & detailsMap()

◆ addObject()

void TrigComposite::addObject ( const std::string & key,
TrigFeatureLink link )

adds the link

See also
TrigFeatuerLink to the object, link is not checked for the validity,
addDetail

Definition at line 54 of file TrigComposite.cxx.

54 {
55 addDetail(key, link);
56}
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 ...

◆ allDetails()

template<class T>
const std::map< std::string, T > & TrigComposite::allDetails ( ) const
inline

return the map of all the details Notie that the non-const version is not provided because it would allow to circumvent format fixing whcih may be defined for this object.

Definition at line 149 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

149 {
150 return detailsMap<T>();
151 }

◆ detailsMap() [1/2]

template<typename T>
std::map< std::string, T > & TrigComposite::detailsMap ( )
private

Definition at line 135 of file TrigComposite.cxx.

135 {
136 // this should never be needed, need to add compile error here
137 [[maybe_unused]]
138 int z =
139 sizeof(struct TrigComposite_does_not_support_that_type_as_a_detail);
140 std::abort();
141}
#define z

◆ detailsMap() [2/2]

template<typename T>
const std::map< std::string, T > & TrigComposite::detailsMap ( ) const
private

Definition at line 144 of file TrigComposite.cxx.

144 {
145 // this should never be needed, need to add compile error here
146 [[maybe_unused]]
147 int z =
148 sizeof(struct TrigComposite_does_not_support_that_type_as_a_detail);
149 std::abort();
150}

◆ detailsMustSetList()

template<typename T>
MustSetList & TrigComposite::detailsMustSetList ( )
private

◆ eraseDetail()

template<typename T>
void TrigComposite::eraseDetail ( const std::string & key)

erases the detail if it existed If the details inder that key did not exist, no action is performed.

Definition at line 129 of file TrigComposite.cxx.

129 {
130 detailsMap<T>().erase(key);
131}

◆ getDetail()

template<typename T>
const T & TrigComposite::getDetail ( const std::string & key) const

return the value of the detail, if the key is absent the default is returned

Definition at line 121 of file TrigComposite.cxx.

121 {
122 if ( hasDetail<T>(key) )
123 return detailsMap<T>().find(key)->second;
124 return specimen<T>();
125}
const T & specimen() const

◆ getObject()

const TrigFeatureLink & TrigComposite::getObject ( const std::string & key) const

returns

See also
TrigFeatureLink associated to the key, if there is none, the invalid TrigFeatureLink is returned

Definition at line 67 of file TrigComposite.cxx.

67 {
69}
const T & getDetail(const std::string &key) const
return the value of the detail, if the key is absent the default is returned

◆ getObjectsByType()

template<typename T>
std::vector< TrigFeatureLink > TrigComposite::getObjectsByType ( const std::string & keypart = "") const

get all links which point to objects of given type

  • keypart retrieve only objects with matching key, (checked by means of string::find)

Definition at line 225 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

225 {
226 const CLID requested_clid = ClassID_traits<T>::ID();
227 std::vector<TrigFeatureLink> result;
228 for ( std::map<std::string, TrigFeatureLink>::const_iterator i = m_links.begin(); i != m_links.end(); ++i ) {
229 if ( i->second.clid() == requested_clid and i->first.find(keypart) != std::string::npos)
230 result.push_back(i->second);
231 }
232 return result;
233}
uint32_t CLID
The Class ID type.

◆ hasDetail()

template<typename T>
bool TrigComposite::hasDetail ( const std::string & key) const

Checks if the object contains detail of the type T No verification is made if it is set.

Definition at line 112 of file TrigComposite.cxx.

112 {
113 return detailsMap<T>().find(key) != detailsMap<T>().end();
114}

◆ hasObject()

bool TrigComposite::hasObject ( const std::string & key) const

checks if the object has link to the object under the key

Definition at line 63 of file TrigComposite.cxx.

63 {
65}

◆ isFormatLocked()

bool TrigComposite::isFormatLocked ( ) const
inline

return true if the format can not be further changed (no addDetail can be called)

Definition at line 71 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

71{return m_locked; }

◆ isValid()

bool TrigComposite::isValid ( ) const

◆ lockFormat()

void TrigComposite::lockFormat ( )
inline

makes further addition of the details impossible

Definition at line 66 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

66{m_locked=true;}

◆ mustSet()

template<class T>
void TrigComposite::mustSet ( const std::string & key)
private

Definition at line 47 of file TrigComposite.cxx.

47 {
48 detailsMustSetList<T>().insert(key);
49}
MustSetList & detailsMustSetList()

◆ name()

const std::string & TrigComposite::name ( ) const
inline

◆ setDetail()

template<typename T>
void TrigComposite::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, If the key does not exists, the exception is thrown

Definition at line 101 of file TrigComposite.cxx.

101 {
102 if ( hasDetail<T>(key) == false )
103 throw std::invalid_argument("The TrigCompositeObejct does not have key: "+ key);
104
105 // now it needs to fins appropriate collection and set the value
107 detailsMustSetList<T>().erase(key);
108}

◆ setFormat()

template<typename T>
void TrigComposite::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 content of the object (set the demand that the deail are set).


Each type of the details can be fixed independently. Also the links can be demanded to be set this way.

This functionality can be used in some sort factories producing TrigComposite of fixed content/contract for the numer of algorithms which they will be "forced" to fill. The enforcement is weak, the isValid method can be then called and so the fulfillment of the contract.

Definition at line 37 of file TrigComposite.cxx.

37 {
38 for(const std::string& key : keys) {
39 addDetail<T>(key);
40 if (mustBeSet) {
41 mustSet<T>(key);
42 }
43 }
44}
void mustSet(const std::string &key)

◆ setObject()

void TrigComposite::setObject ( const std::string & key,
TrigFeatureLink link )

sets the link

See also
TrigFeatuerLink to the object, link is not checked for the validity
setDetail

Definition at line 58 of file TrigComposite.cxx.

58 {
59 setDetail(key, link);
60}
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,...

◆ specimen()

template<typename T>
const T & TrigComposite::specimen ( ) const
private

◆ unlockFormat()

void TrigComposite::unlockFormat ( )
inline

makes addition of further details possible again

Definition at line 77 of file Trigger/TrigEvent/TrigCombinedEvent/TrigCombinedEvent/TrigComposite.h.

77{m_locked=false;}

Member Data Documentation

◆ m_floats

std::map<std::string, float > TrigComposite::m_floats
private

◆ m_floatsToBeSet

MustSetList TrigComposite::m_floatsToBeSet
private

◆ m_ints

std::map<std::string, int> TrigComposite::m_ints
private

◆ m_intsToBeSet

MustSetList TrigComposite::m_intsToBeSet
private

◆ m_links

std::map<std::string, TrigFeatureLink > TrigComposite::m_links
private

◆ m_linksToBeSet

MustSetList TrigComposite::m_linksToBeSet
private

◆ m_locked

bool TrigComposite::m_locked
private

◆ m_name

std::string TrigComposite::m_name
private

◆ m_strings

std::map<std::string, std::string> TrigComposite::m_strings
private

◆ m_stringsToBeSet

MustSetList TrigComposite::m_stringsToBeSet
private

◆ m_v_floats

std::map<std::string, std::vector<float> > TrigComposite::m_v_floats
private

◆ m_v_floatsToBeSet

MustSetList TrigComposite::m_v_floatsToBeSet
private

◆ m_v_ints

std::map<std::string, std::vector<int> > TrigComposite::m_v_ints
private

◆ m_v_intsToBeSet

MustSetList TrigComposite::m_v_intsToBeSet
private

◆ m_v_strings

std::map<std::string, std::vector<std::string> > TrigComposite::m_v_strings
private

◆ m_v_stringsToBeSet

MustSetList TrigComposite::m_v_stringsToBeSet
private

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