5#ifndef TRIGCONFDATA_DATASTRUCTURE_H
6#define TRIGCONFDATA_DATASTRUCTURE_H
17#include "boost/property_tree/ptree.hpp"
40 using ptree = boost::property_tree::ptree;
67 void setName(
const std::string& n);
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;
140 bool hasChild(
const std::string & path)
const;
145 std::string
operator[](
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"
#define CONDCONT_DEF(...)
macros to associate a CLID to a type
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
char data[hepevt_bytes_allocation_ATLAS]
boost::property_tree::ptree ptree
Base class for Trigger configuration data and wrapper around underlying representation.
std::optional< TrigConf::DataStructure > getObject_optional(const std::string &pathToChild) const
void setName(const std::string &n)
Setting the configuration element name.
std::shared_ptr< ptree > m_dataSPtr
virtual const std::string & name() const final
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)
bool isInitialized() const
const ptree & data() const
Access to the underlying data, if needed.
bool hasAttribute(const std::string &key) const
Check for attribute.
std::optional< std::vector< DataStructure > > getList_optional(const std::string &pathToChild) const
DataStructure()
Default constructor, leading to an uninitialized configuration object.
void setData(const ptree &data)
Setting the configuration data.
virtual void clear()
Clearing the configuration data.
bool empty() const
Check if children exist.
DataStructure & operator=(const DataStructure &)=default
std::optional< T > getAttribute_optional(const std::string &key) const
std::vector< std::string > getKeys() const
Access to the keys of an DataStructure which presents a dictionary.
DataStructure(DataStructure &&)=default
virtual std::string className() const
A string that is the name of the class.
std::string getValue() const
Access to simple content.
T getAttribute(const std::string &key, bool ignoreIfMissing=false, const T &def=T()) const
Access to simple attribute.
bool isNull(const std::string &key) const
Check if an attribute is null.
void printRaw(std::ostream &os=std::cout) const
virtual void update()
Update the internal data after modification of the data object.
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.
bool hasChild(const std::string &path) const
Check if child exists.
DataStructure getObject(const std::string &pathToChild, bool ignoreIfMissing=false) const
Access to configuration object.
std::string operator[](const std::string &key) const
Access to simple attribute.
virtual ~DataStructure()=default
Destructor.
boost::property_tree::ptree ptree
std::optional< T > getValue_optional() const
access to content of the note Will return false if the value could not be converted into T
DataStructure & operator=(DataStructure &&)=default
bool isValue() const
Check for attribute.
virtual void print(std::ostream &os=std::cout) const
DataStructure(const DataStructure &)=default
Forward iterator to traverse the main components of the trigger configuration.