1#ifndef __DUNEDAQ_CONFFWK_CONFIGURATION_HXX__
2#define __DUNEDAQ_CONFFWK_CONFIGURATION_HXX__
17 create(at, T::s_class_name,
id, obj);
32 Configuration::_get(
const std::string& name,
bool init_children,
bool init_object,
unsigned long rlevel,
const std::vector<std::string> * rclasses)
34 return m_registry.
get<T>(name, init_children, init_object, rlevel, rclasses);
65 Configuration::_get(std::vector<const T*>& result,
bool init_children,
bool init_object,
const std::string& query,
unsigned long rlevel,
const std::vector<std::string> * rclasses)
67 std::vector<ConfigObject> objs;
71 get(T::s_class_name, objs, query, rlevel, rclasses);
75 std::ostringstream text;
76 text <<
"wrong database schema, cannot find class \'" << ex.get_data() <<
'\'';
84 result.push_back(this->
_get<T>(i, init_children, init_object));
138template<
class T,
class V>
140 Configuration::referenced_by(
const T& obj, std::vector<const V*>& results,
const std::string& relationship_name,
bool check_composite_only,
bool init,
unsigned long rlevel,
const std::vector<std::string> * rclasses)
142 std::vector<ConfigObject> objs;
150 obj.p_obj.referenced_by(objs, relationship_name, check_composite_only, rlevel, rclasses);
154 if (
try_cast(V::s_class_name, i.class_name()) ==
true)
159 results.push_back(o);
294 return m_registry.is_valid(
object);
298template<
class T>
void
300 const std::vector<std::string>& removed,
301 const std::vector<std::string>& created)
noexcept
314 m_registry.update<T>(modified, removed, created);
317template<
class T>
void
371template<
class T>
void
374 std::lock_guard<std::mutex> scoped_lock(m_else_mutex);
376 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);
390 if (l != m_convert_map.end())
392 for (
const auto& i : *l->second)
404 if (l != m_convert_map.end())
406 for (
auto& j : value)
408 for (
const auto& i : *l->second)
Represents database objects.
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).
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.
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.
Generic configuration exception.
Try to access non-existent object or class.
void init(unordered_map< std::string, std::string > params)