14#include <pybind11/pybind11.h>
15#include <pybind11/stl.h>
16#include <pybind11/stl_bind.h>
22namespace py = pybind11;
30 py::class_<Configuration>(m,
"_Configuration")
32 .def(py::init<std::string>())
42 static_cast<void (
Configuration::*)(
const std::string&,
const std::list<std::string>&)
>(&
Configuration::create),
"Create a database from a list of files", py::arg(
"db_name"), py::arg(
"includes"))
44 py::overload_cast<const std::string&, const std::string&, const std::string&>(&
Configuration::create_and_return_obj_pybind),
"Create new object by class name and object id.", py::arg(
"at"), py::arg(
"class_name"), py::arg(
"id"))
46 py::overload_cast<const ConfigObject&, const std::string&, const std::string&>(&
Configuration::create_and_return_obj_pybind),
"Create new object by class name and object id.", py::arg(
"at"), py::arg(
"class_name"), py::arg(
"id"))
49 .def(
"get_impl_param",
56 &
Configuration::get_obj_pybind,
"Create a configuration object containing the desired entity from the database", py::arg(
"class_name"), py::arg(
"id"))
58 &
Configuration::get_objs_pybind,
"Create a list of configuration objects of a given class from the database", py::arg(
"class_name"), py::arg(
"query") =
"")
63 .def(
"remove_include",
72 &
Configuration::test_object,
"Test the existence of the object", py::arg(
"class_name"), py::arg(
"id"), py::arg(
"rlevel"), py::arg(
"rclasses"))
82 py::class_<ConfigObject>(m,
"_ConfigObject")
84 .def(py::init<const ConfigObject&>())
119 .def(
"get_string_vec",
139 .def(
"get_float_vec",
141 .def(
"get_double_vec",
146 &
ConfigObject::set_obj,
"Set relationship single-value", py::arg(
"name"), py::arg(
"o"), py::arg(
"skip_non_null_check") =
false)
148 &
ConfigObject::set_objs,
"Set relationship multi-value.", py::arg(
"name"), py::arg(
"o"), py::arg(
"skip_non_null_check") =
false)
150 py::overload_cast<const std::string&, const std::string&>(&
ConfigObject::set_class),
"Set the class name", py::arg(
"name"), py::arg(
"value"))
152 py::overload_cast<const std::string&, const std::string&>(&
ConfigObject::set_date),
"Set the date", py::arg(
"name"), py::arg(
"value"))
154 py::overload_cast<const std::string&, const std::string&>(&
ConfigObject::set_enum),
"Set the enum", py::arg(
"name"), py::arg(
"value"))
158 py::overload_cast<const std::string&, const std::string&>(&
ConfigObject::set_time),
"Set the time", py::arg(
"name"), py::arg(
"value"))
199 .def(
"set_float_vec",
201 .def(
"set_double_vec",
203 .def(
"set_class_vec",
209 .def(
"set_string_vec",
void set_time(const std::string &name, const std::string &value)
Set attribute time value.
void set_by_val(const std::string &name, T value)
Set attribute value.
ConfigObject * get_obj_pybind(const std::string &attrname)
T get_value_pybind(const std::string &attrname)
void set_date(const std::string &name, const std::string &value)
Set attribute date value.
void set_objs(const std::string &name, const std::vector< const ConfigObject * > &o, bool skip_non_null_check=false)
Set relationship multi-value.
const std::string & UID() const noexcept
Return object identity.
void set_class(const std::string &name, const std::string &value)
Set attribute class value.
void set_list_pybind(const std::string &attrname, std::vector< T > l)
void set_enum(const std::string &name, const std::string &value)
Set attribute enumeration value.
const std::string full_name() const noexcept
Return full object name.
void set_obj(const std::string &name, const ConfigObject *o, bool skip_non_null_check=false)
Set relationship single-value.
void rename(const std::string &new_id)
Rename object.
std::vector< T > get_list_pybind(const std::string &attrname)
const std::string & class_name() const noexcept
Return object's class name.
const std::string contained_in() const
Return the name of the database file this object belongs to.
Defines base class for cache of template objects.
std::vector< ConfigObject > * get_objs_pybind(const std::string &class_name, const std::string &query="")
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > attributes_pybind(const std::string &class_name, bool all)
void destroy_obj(ConfigObject &object)
Destroy object.
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > relations_pybind(const std::string &class_name, bool all)
void remove_include(const std::string &db_name, const std::string &include)
Remove include file.
void load(const std::string &db_name)
Load database according to the name. If name is empty, take it from TDAQ_DB_NAME and TDAQ_DB_DATA env...
const std::string & get_impl_param() const noexcept
std::vector< std::string > superclasses_pybind(const std::string &class_name, bool all)
void create(const std::string &at, const std::string &class_name, const std::string &id, ConfigObject &object)
Create new object by class name and object id.
std::vector< std::string > subclasses_pybind(const std::string &class_name, bool all)
std::list< std::string > * return_includes_pybind(const std::string &db_name)
bool loaded() const noexcept
Check if database is correctly loaded.
std::vector< std::string > get_class_list() const
const std::string & get_impl_spec() const noexcept
void commit(const std::string &log_message="")
Commit database changes.
ConfigObject * get_obj_pybind(const std::string &class_name, const std::string &id)
void unload()
Unload database.
bool test_object(const std::string &class_name, const std::string &id, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
Test the object existence.
void add_include(const std::string &db_name, const std::string &include)
Add include file to existing database.
ConfigObject * create_and_return_obj_pybind(const std::string &at, const std::string &class_name, const std::string &id)
void register_conffwk(py::module &m)
void register_conffwkobject(py::module &m)