1#ifndef __DUNEDAQ_CONFFWK_CONFIGURATION_HXX__
2#define __DUNEDAQ_CONFFWK_CONFIGURATION_HXX__
34 const std::vector<std::string>* rclasses)
36 return m_registry.
get<T>(name, init_children, init_object, rlevel, rclasses);
70 const std::string& query,
72 const std::vector<std::string>* rclasses)
74 std::vector<ConfigObject> objs;
77 get(T::s_class_name, objs, query, rlevel, rclasses);
78 }
catch (dunedaq::conffwk::NotFound& ex) {
79 std::ostringstream text;
80 text <<
"wrong database schema, cannot find class \'" << ex.get_data() <<
'\'';
81 throw dunedaq::conffwk::Generic(
ERS_HERE, text.str().c_str());
85 for (
auto& i : objs) {
86 result.push_back(this->
_get<T>(i, init_children, init_object));
141template<
class T,
class V>
144 std::vector<const V*>& results,
145 const std::string& relationship_name,
146 bool check_composite_only,
148 unsigned long rlevel,
149 const std::vector<std::string>* rclasses)
151 std::vector<ConfigObject> objs;
158 obj.p_obj.referenced_by(objs, relationship_name, check_composite_only, rlevel, rclasses);
160 for (
auto& i : objs) {
161 if (
try_cast(V::s_class_name, i.class_name()) ==
true) {
164 results.push_back(o);
168 }
catch (dunedaq::conffwk::Generic& ex) {
169 throw(dunedaq::conffwk::Generic(
301 const std::vector<std::string>& removed,
302 const std::vector<std::string>& created)
noexcept
315 m_registry.update<T>(modified, removed, created);
377 std::list<AttributeConverterBase*>* c =
m_convert_map[
typeid(T).name()];
379 c =
m_convert_map[
typeid(T).name()] =
new std::list<AttributeConverterBase*>();
382 c->push_back(
object);
391 for (
const auto& i : *l->second) {
403 for (
auto& j : value) {
404 for (
const auto& i : *l->second) {
void register_converter(AttributeConverter< T > *object) noexcept
Register user function for attribute conversion.
const T * _find(const std::string &id)
Multi-thread unsafe version of find(const std::string&) method.
void _get(const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel, const std::vector< std::string > *rclasses)
void get(const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
Get object by class name and object id (multi-thread safe).
friend class ConfigObject
void destroy_obj(ConfigObject &object)
Destroy object.
void update(const std::vector< std::string > &modified, const std::vector< std::string > &removed, const std::vector< std::string > &created) noexcept
Update cache of objects in case of modification.
void referenced_by(const T &obj, std::vector< const V * > &objects, const std::string &relationship_name="*", bool check_composite_only=true, bool init=false, unsigned long rlevel=0, const std::vector< std::string > *rclasses=nullptr)
Get template DAL objects holding references on this object via given relationship (multi-thread safe)...
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.
const T * _ref(ConfigObject &obj, const std::string &name, bool read_children)
Multi-thread unsafe version of ref(ConfigObject&, const std::string&, bool); The method should not be...
void _reset_objects() noexcept
Update state of objects after abort operations.
void destroy(T &obj)
Destroy object of given class.
conffwk::map< std::list< AttributeConverterBase * > * > m_convert_map
static std::string mk_ref_by_ex_text(const std::string &cname, const std::string &rname, const ConfigObject &obj) noexcept
void convert(T &value, const ConfigObject &obj, const std::string &attr_name) noexcept
Converts single value.
bool try_cast(const std::string &target, const std::string &source) noexcept
Checks if cast from source class to target class is allowed.
void convert2(std::vector< T > &value, const ConfigObject &obj, const std::string &attr_name) noexcept
Converts vector of single values.
bool is_valid(const T *object) noexcept
Checks validity of pointer to an objects of given user class.
DalObject * get(ConfigObject &obj, bool upcast_unregistered=false)
void _reset_objects()
Update state of objects after abort operations.
const T * _ref(ConfigObject &obj, const std::string &name, bool read_children)
Get signle value of object's relation and instantiate result with it (multi-thread safe).
T * find(const std::string &id)
Find template object using ID.
void init(unordered_map< std::string, std::string > params)