DUNE-DAQ
DUNE Trigger and Data Acquisition software
|
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalObjecs. More...
#include <DalRegistry.hpp>
Classes | |
struct | DalDomain |
Public Member Functions | |
DalRegistry (Configuration &confdb) | |
Construct a new Dal Registry object. | |
~DalRegistry () | |
Configuration & | configuration () |
const Configuration & | configuration () const |
void | clear () |
Clear the content of the registy. | |
DalObject * | get (ConfigObject &obj, bool upcast_unregistered=false) |
std::vector< const DalObject * > | get (std::vector< ConfigObject > &objs, bool upcast_unregistered=false) |
template<class T > | |
T * | get (ConfigObject &obj, bool init_children=false, bool init_object=true) |
Get template object from cache by conffwk object. | |
template<class T > | |
T * | get (const std::string &name, bool init_children=false, bool init_object=true, unsigned long rlevel=0, const std::vector< std::string > *rclasses=nullptr) |
Get template object from cache by object's ID. | |
template<class T > | |
T * | find (const std::string &id) |
Find template object using ID. | |
template<class T > | |
bool | is_valid (const T *object) noexcept |
Checks validity of pointer to an objects of given user class. | |
template<class T > | |
void | update (const std::vector< std::string > &modified, const std::vector< std::string > &removed, const std::vector< std::string > &created) |
Update cache of objects in case of modification. | |
void | update (const std::string &class_name, const std::vector< std::string > &modified, const std::vector< std::string > &removed, const std::vector< std::string > &created) |
void | unread_all () |
Set the status of all objects in cache to unread. | |
template<class T > | |
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). | |
template<class T > | |
void | _ref (ConfigObject &obj, const std::string &name, std::vector< const T * > &results, bool read_children) |
Get multiple values of object's relation and instantiate result with them (multi-thread safe). | |
template<class T > | |
void | _reset_objects () |
Update state of objects after abort operations. | |
void | _rename_object (std::string class_name, std::string old_id, std::string new_id) |
Rename object of given template class (multi-thread unsafe). | |
void | update_class_maps () |
Update the internal class domains map. | |
Private Member Functions | |
void | update_class_domain_map () |
Private Attributes | |
Configuration & | m_confdb |
std::mutex | m_mutex |
conffwk::fmap< uint > | m_class_domain_map |
std::unordered_map< uint, DalDomain > | m_cache_domains |
Friends | |
class | DalObject |
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalObjecs.
Definition at line 19 of file DalRegistry.hpp.
dunedaq::conffwk::DalRegistry::DalRegistry | ( | conffwk::Configuration & | confdb | ) |
Construct a new Dal Registry object.
confdb | Reference to a Configuration object; |
Definition at line 8 of file DalRegistry.cpp.
dunedaq::conffwk::DalRegistry::~DalRegistry | ( | ) |
Definition at line 13 of file DalRegistry.cpp.
const T * dunedaq::conffwk::DalRegistry::_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).
The method is used by the code generated by the genconffwk utility.
obj | object |
name | name of the relationship |
init | if true, the object and it's referenced objects are initialized |
dunedaq::conffwk::Generic | in case of a problem (e.g. no relationship with such name, plug-in specific problem) |
Definition at line 164 of file DalRegistry.hxx.
void dunedaq::conffwk::DalRegistry::_ref | ( | ConfigObject & | obj, |
const std::string & | name, | ||
std::vector< const T * > & | results, | ||
bool | read_children ) |
Get multiple values of object's relation and instantiate result with them (multi-thread safe).
The method is used by the code generated by the genconffwk utility.
obj | object |
name | name of the relationship |
objects | returned value |
init | if true, the objects and their referenced objects are initialized |
dunedaq::conffwk::Generic | in case of a problem (e.g. no relationship with such name, plug-in specific problem) |
Definition at line 182 of file DalRegistry.hxx.
void dunedaq::conffwk::DalRegistry::_rename_object | ( | std::string | class_name, |
std::string | old_id, | ||
std::string | new_id ) |
Rename object of given template class (multi-thread unsafe).
Is used by automatically generated data access libraries when an object has been renamed by user's code. Should not be explicitly used by user.
The method is used by the unread_all_objects() method.
cache_ptr | pointer to the cache of template object of given template class (has to be downcasted) |
old_id | old object ID |
new_id | new object ID |
Definition at line 198 of file DalRegistry.cpp.
void dunedaq::conffwk::DalRegistry::_reset_objects | ( | ) |
Update state of objects after abort operations.
It is used by automatically generated data access libraries.
Definition at line 236 of file DalRegistry.hxx.
void dunedaq::conffwk::DalRegistry::clear | ( | ) |
Clear the content of the registy.
Definition at line 85 of file DalRegistry.cpp.
|
inline |
Definition at line 37 of file DalRegistry.hpp.
|
inline |
Definition at line 38 of file DalRegistry.hpp.
T * dunedaq::conffwk::DalRegistry::find | ( | const std::string & | id | ) |
Find template object using ID.
The method is suitable for generated template objects.
In case of success, the new object is put into cache and pointer to the object is returned. If there is no such object for given template class, then null pointer is returned.
id | ID of generated object |
dunedaq::conffwk::Generic | is no such class for loaded configuration DB schema or in case of an error |
Definition at line 146 of file DalRegistry.hxx.
T * dunedaq::conffwk::DalRegistry::get | ( | ConfigObject & | obj, |
bool | init_children = false, | ||
bool | init_object = true ) |
Get template object from cache by conffwk object.
The method searches an object with id of given conffwk object within the cache. If found, the method sets given conffwk object as implementation of the template object and returns pointer on the template object. If there is no such object in cache, then it is created from given conffwk object.
In case of success, the new object is put into cache and pointer to the object is returned. If there is no such object for given template class, then null pointer is returned.
conffwk | the configuration object |
obj | the conffwk object used to set for the template object |
init_children | if true, the referenced objects are initialized (only applicable during creation of new object) |
init_object | if true, the object's attributes and relationships are read(only applicable during creation of new object) |
dunedaq::conffwk::Generic | is no such class for loaded configuration DB schema or in case of an error |
Definition at line 12 of file DalRegistry.hxx.
DalObject * dunedaq::conffwk::DalRegistry::get | ( | ConfigObject & | obj, |
bool | upcast_unregistered = false ) |
Definition at line 98 of file DalRegistry.cpp.
T * dunedaq::conffwk::DalRegistry::get | ( | const std::string & | name, |
bool | init_children = false, | ||
bool | init_object = true, | ||
unsigned long | rlevel = 0, | ||
const std::vector< std::string > * | rclasses = nullptr ) |
Get template object from cache by object's ID.
The method searches an object with given id within the cache. If found, the method returns pointer on it. If there is no such object in cache, there is an attempt to create new object. In case of success, the new object is put into cache and pointer to the object is returned. If there is no such object for given template class, then null pointer is returned.
conffwk | the configuration object |
name | object identity |
init_children | if true, the referenced objects are initialized (only applicable during creation of new object) |
init_object | if true, the object's attributes and relationships are read(only applicable during creation of new object) |
rlevel | optional references level to optimize performance (defines how many objects referenced by given object have also to be read to the implementation cache during creation of new object) |
rclasses | optional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache during creation of new object) |
dunedaq::conffwk::Generic | is no such class for loaded configuration DB schema or in case of an error |
Definition at line 67 of file DalRegistry.hxx.
std::vector< const DalObject * > dunedaq::conffwk::DalRegistry::get | ( | std::vector< ConfigObject > & | objs, |
bool | upcast_unregistered = false ) |
Definition at line 127 of file DalRegistry.cpp.
|
noexcept |
Checks validity of pointer to an objects of given user class.
Check if the pointer to the object is a valid pointer in the cache. Dangling pointers to removed objects may appear after notification.
Definition at line 205 of file DalRegistry.hxx.
void dunedaq::conffwk::DalRegistry::unread_all | ( | ) |
Set the status of all objects in cache to unread.
Definition at line 182 of file DalRegistry.cpp.
void dunedaq::conffwk::DalRegistry::update | ( | const std::string & | class_name, |
const std::vector< std::string > & | modified, | ||
const std::vector< std::string > & | removed, | ||
const std::vector< std::string > & | created ) |
Definition at line 140 of file DalRegistry.cpp.
void dunedaq::conffwk::DalRegistry::update | ( | const std::vector< std::string > & | modified, |
const std::vector< std::string > & | removed, | ||
const std::vector< std::string > & | created ) |
Update cache of objects in case of modification.
Only is called, when a user subscription to related class is set. It is used by automatically generated data access libraries.
modified | vector of modified objects of given user class (objects to be re-read in cache) |
removed | vector of removed objects of given user class (objects to be removed from cache) |
created | vector of created objects of given user class (objects to be reset in cache, if they were removed) |
Definition at line 225 of file DalRegistry.hxx.
|
private |
Definition at line 68 of file DalRegistry.cpp.
|
inline |
Update the internal class domains map.
Definition at line 211 of file DalRegistry.hpp.
|
friend |
Definition at line 21 of file DalRegistry.hpp.
|
private |
Definition at line 226 of file DalRegistry.hpp.
|
private |
Definition at line 224 of file DalRegistry.hpp.
|
private |
Definition at line 218 of file DalRegistry.hpp.
|
mutableprivate |
Definition at line 220 of file DalRegistry.hpp.