7#define BOOST_BIND_GLOBAL_PLACEHOLDERS
8#include <boost/property_tree/ptree.hpp>
9#include <boost/property_tree/json_parser.hpp>
16using ptree = boost::property_tree::ptree;
31 if( std::filesystem::exists( filename ) ) {
36 if (!filename.empty() && filename[0] ==
'/') {
37 TRG_MSG_WARNING(
"Can not find file with absolute location " << filename);
46 boost::property_tree::ptree &
data,
47 const std::string & pathToChild )
const
58 boost::property_tree::read_json(
file,
data);
60 catch (
const boost::property_tree::json_parser_error& e) {
65 if( ! pathToChild.empty() ) {
68 boost::optional<ptree&> subtree =
data.get_child_optional(pathToChild);
84 const std::string & pathToChild )
const
86 boost::property_tree::ptree pt;
88 if( !
loadFile( filename, pt, pathToChild) )
91 data.setData(std::move(pt));
102 if ( filename ==
"" ) {
103 TRG_MSG_ERROR(
"Could not save to file, as specified filename is empty");
106 boost::property_tree::write_json(filename,
data.data());
116 std::string ft =
"UNKNOWN";
120 ft =
data.getAttribute(
"filetype",
true, ft);
129 std::string & level )
const
138 if (
data.hasChild(
"chains")) {
140 }
else if (
data.hasChild(
"items")) {
char data[hepevt_bytes_allocation_ATLAS]
boost::property_tree::ptree ptree
Loader class for Trigger configuration from Json.
#define TRG_MSG_WARNING(x)
Base class for Trigger configuration data and wrapper around underlying representation.
bool saveFile(const std::string &filename, const DataStructure &data) const
Save content of DataStructure (underlying ptree) to a file.
bool checkTriggerLevel(const std::string &filename, std::string &level) const
Checks the trigger level of a given json file.
JsonFileLoader()
Constructor.
std::string findFile(const std::string &filename) const
std::string getFileType(const std::string &filename) const
Checks the trigger level of a given json file.
bool loadFile(const std::string &filename, boost::property_tree::ptree &data, const std::string &pathToChild="") const
Load content of json file into a ptree.
TrigConfMessaging(const std::string &name)
Constructor with parameters.