|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef TRIGCONFDATA_DATASTRUCTURE_H
6 #define TRIGCONFDATA_DATASTRUCTURE_H
15 #include <type_traits>
17 #include "boost/property_tree/ptree.hpp"
72 virtual const std::string &
name()
const final;
85 throw std::runtime_error(
"Trying to access data of uninitialized object of type " +
className());
109 return data().get_value<T>();
117 auto v =
data().get_value_optional<T>();
118 return v ? std::optional<T>(std::move(*
v)) : std::nullopt;
134 bool isNull(
const std::string &
key)
const;
152 T
getAttribute(
const std::string &
key,
bool ignoreIfMissing =
false,
const T & def = T())
const {
153 const auto &
obj =
data().get_child_optional(
key);
155 if( ignoreIfMissing ) {
158 throw std::runtime_error(
className() +
"#" +
name() +
": structure '" +
key +
"' does not exist" );
161 return obj.get().get_value<T>();
166 const auto &
obj =
data().get_child_optional(
key);
170 auto v =
obj.get().get_value_optional<T>();
171 return v ? std::optional(std::move(*
v)) : std::nullopt;
174 const std::string &
getAttribute(
const std::string &
key,
bool ignoreIfMissing =
false,
const std::string & def =
"")
const;
183 std::vector<DataStructure>
getList(
const std::string & pathToChild,
bool ignoreIfMissing =
false)
const;
185 std::optional<std::vector<DataStructure> >
getList_optional(
const std::string & pathToChild)
const;
202 std::optional<TrigConf::DataStructure>
210 std::vector<std::string>
getKeys()
const;
224 void printRaw(std::ostream &
os = std::cout)
const;
229 virtual void print(std::ostream &
os = std::cout)
const;
240 std::ostream &
os = std::cout);
265 #ifndef TRIGCONF_STANDALONE
266 #ifndef XAOD_STANDALONE
271 #include "AthenaKernel/CondCont.h"
const ptree & data() const
Access to the underlying data, if needed.
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
virtual ~DataStructure()=default
Destructor.
DataStructure & operator=(DataStructure &&)=default
bool isInitialized() const
path
python interpreter configuration --------------------------------------—
std::optional< TrigConf::DataStructure > getObject_optional(const std::string &pathToChild) const
bool empty() const
Check if children exist.
static void printElement(const std::string &key, const ptree &data, uint level=0, std::ostream &os=std::cout)
Static function to print a ptree object.
void setName(const std::string &n)
Setting the configuration element name.
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.
std::optional< T > getAttribute_optional(const std::string &key) const
std::shared_ptr< ptree > m_dataSPtr
std::vector< std::string > getKeys() const
Access to the keys of an DataStructure which presents a dictionary.
bool const RAWDATA *ch2 const
virtual const std::string & name() const final
CONDCONT_DEF(TrigConf::DataStructure, 265887802)
void setData(const ptree &data)
Setting the configuration data.
Forward iterator to traverse the main components of the trigger configuration.
bool hasChild(const std::string &path) const
Check if child exists.
DataStructure(const DataStructure &)=default
std::string operator[](const std::string &key) const
Access to simple attribute.
virtual std::string className() const
A string that is the name of the class.
DataStructure(DataStructure &&)=default
boost::property_tree::ptree ptree
std::optional< std::vector< DataStructure > > getList_optional(const std::string &pathToChild) const
std::vector< DataStructure > getList(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to array structure.
bool m_initialized
if initialized, the underlying ptree is has been assigned to (can be empty)
void printRaw(std::ostream &os=std::cout) const
Base class for Trigger configuration data and wrapper around underlying representation.
DataStructure & operator=(const DataStructure &)=default
std::string getValue() const
Access to simple content.
bool isNull(const std::string &key) const
Check if an attribute is null.
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
std::optional< T > getValue_optional() const
access to content of the note Will return false if the value could not be converted into T
virtual void clear()
Clearing the configuration data.
virtual void print(std::ostream &os=std::cout) const
DataStructure()
Default constructor, leading to an uninitialized configuration object.
bool isValue() const
Check for attribute.
setBGCode setTAP setLVL2ErrorBits bool
boost::property_tree::ptree ptree
macros to associate a CLID to a type
bool hasAttribute(const std::string &key) const
Check for attribute.
virtual void update()
Update the internal data after modification of the data object.