DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dunedaq::conffwk::Configuration Class Reference

Defines base class for cache of template objects. More...

#include <Configuration.hpp>

Collaboration diagram for dunedaq::conffwk::Configuration:
[legend]

Classes

class  AttributeConverter
 Virtual converter class. More...
 
class  AttributeConverterBase
 
struct  CallbackPreSubscription
 
struct  CallbackSubscription
 

Public Types

typedef void(*) notify(const std::vector< ConfigurationChange * > &changed_classes, void *parameter)
 The user notification callback function which is invoked in case of changes.
 
typedef void(*) pre_notify(void *parameter)
 The user notification callback function which is invoked before changes are going to be applied.
 
typedef CallbackSubscriptionCallbackId
 Callback identifier.
 

Public Member Functions

 Configuration (const std::string &spec)
 Constructor to build a configuration object using implementation plug-in.
 
 Configuration ()
 
const std::string & get_impl_spec () const noexcept
 
const std::string & get_impl_name () const noexcept
 
const std::string & get_impl_param () const noexcept
 
 ~Configuration () noexcept
 Destructor to destroy a configuration object.
 
CallbackId subscribe (const ConfigurationSubscriptionCriteria &criteria, notify user_cb, void *user_param=nullptr)
 Subscribe on configuration changes.
 
CallbackId subscribe (pre_notify user_cb, void *user_param=nullptr)
 Subscribe on pre-notification on configuration changes.
 
void unsubscribe (CallbackId cb_handler=0)
 Remove callback function.
 
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) noexcept
 Update cache of objects in case of modification.
 
void update_cache (std::vector< ConfigurationChange * > &changes) noexcept
 System function invoked in case of modifications.
 
template<class T >
void _reset_objects () noexcept
 Update state of objects after abort operations.
 
void unread_all_objects (bool unread_implementation_objs=false) noexcept
 Mark object of given template class as unread (multi-thread unsafe).
 
void unread_template_objects () noexcept
 Unread all template (i.e. set their state as uninitialized) objects.
 
void unread_implementation_objects (dunedaq::conffwk::ObjectState state) noexcept
 Unread implementation objects (i.e. clear their cache).
 
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.
 
void create (const ConfigObject &at, const std::string &class_name, const std::string &id, ConfigObject &object)
 Create new object by class name and object id.
 
template<class T >
const T * create (const std::string &at, const std::string &id, bool init_object=false)
 Create object of given class by identity and instantiate the template parameter with it.
 
template<class T >
const T * create (const DalObject &at, const std::string &id, bool init_object=false)
 Create object of given class by identity and instantiate the template parameter with it.
 
void destroy_obj (ConfigObject &object)
 Destroy object.
 
template<class T >
void destroy (T &obj)
 Destroy object of given class.
 
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 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 get (const std::string &class_name, std::vector< ConfigObject > &objects, const std::string &query="", unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
 Get all objects of class.
 
void get (const ConfigObject &obj_from, const std::string &query, std::vector< ConfigObject > &objects, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
 Get path between objects.
 
template<class T >
const T * get (const std::string &id, bool init_children=false, bool init=true, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
 Get object of given class by identity and instantiate the template parameter with it (multi-thread safe).
 
template<class T >
const T * get (ConfigObject &obj, bool init_children=false, bool init=true)
 Get object of given class by object reference and instantiate the template parameter with it (multi-thread safe).
 
template<class T >
void get (std::vector< const T * > &objects, bool init_children=false, bool init=true, const std::string &query="", unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
 Get all objects of given class and instantiate a vector of the template parameters object with it (multi-thread safe).
 
template<class T >
const T * get (ConfigObject &obj, const std::string &id)
 Generate object of given class by object reference and instantiate the template parameter with it (multi-thread safe).
 
template<class T >
const T * find (const std::string &id)
 Find object of given class (multi-thread safe).
 
template<class T >
const T * ref (ConfigObject &obj, const std::string &name, bool init=false)
 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 * > &objects, bool init=false)
 Get multiple values of object's relation and instantiate result with them (multi-thread safe).
 
template<class T , class V >
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).
 
std::vector< const DalObject * > referenced_by (const DalObject &obj, const std::string &relationship_name="*", bool check_composite_only=true, bool upcast_unregistered=true, bool init=false, unsigned long rlevel=0, const std::vector< std::string > *rclasses=nullptr)
 Get DAL objects holding references on this object via given relationship (multi-thread safe).
 
template<class TARGET , class SOURCE >
const TARGET * cast (const SOURCE *s) noexcept
 Cast objects from one class to another (multi-thread safe).
 
template<class T >
void downcast_dal_objects (const std::vector< const T * > &objs, bool, std::vector< const DalObject * > &result)
 
template<class T >
void downcast_dal_object (const T *obj, bool, std::vector< const DalObject * > &result)
 
template<class T >
const T * _find (const std::string &id)
 Multi-thread unsafe version of find(const std::string&) method.
 
template<class T >
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 used by user.
 
template<class T >
void _ref (ConfigObject &obj, const std::string &name, std::vector< const T * > &results, bool read_children)
 Multi-thread unsafe version of ref(ConfigObject&, const std::string&, std::vector<const T*>&, bool); The method should not be used by user.
 
bool try_cast (const std::string &target, const std::string &source) noexcept
 Checks if cast from source class to target class is allowed.
 
bool try_cast (const std::string *target, const std::string *source) noexcept
 
bool is_superclass_of (const std::string &target, const std::string &source) noexcept
 
bool is_superclass_of (const std::string *target, const std::string *source) noexcept
 
bool loaded () const noexcept
 Check if database is correctly loaded.
 
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 environment variables.
 
void unload ()
 Unload database.
 
void create (const std::string &db_name, const std::list< std::string > &includes)
 Create database.
 
bool is_writable (const std::string &db_name) const
 Get write access status.
 
void add_include (const std::string &db_name, const std::string &include)
 Add include file to existing database.
 
void remove_include (const std::string &db_name, const std::string &include)
 Remove include file.
 
void get_includes (const std::string &db_name, std::list< std::string > &includes) const
 Get include files.
 
void get_updated_dbs (std::list< std::string > &dbs) const
 Get list of updated files to be committed.
 
void set_commit_credentials (const std::string &user, const std::string &password)
 Set commit credentials.
 
void commit (const std::string &log_message="")
 Commit database changes.
 
void abort ()
 Abort database changes.
 
void prefetch_all_data ()
 Prefetch all data into client cache.
 
std::vector< dunedaq::conffwk::Versionget_changes ()
 Get new conffwk versions.
 
std::vector< dunedaq::conffwk::Versionget_versions (const std::string &since, const std::string &until, dunedaq::conffwk::Version::QueryType type=dunedaq::conffwk::Version::query_by_date, bool skip_irrelevant=true)
 Get repository versions in interval.
 
const dunedaq::conffwk::class_tget_class_info (const std::string &class_name, bool direct_only=false)
 The method provides access to description of class.
 
void export_schema (boost::property_tree::ptree &tree, const std::string &classes="", bool direct_only=false)
 Export configuration schema into ptree.
 
void export_data (boost::property_tree::ptree &tree, const std::string &classes="", const std::string &objects="", const std::string &files="", const std::string &empty_array_item="")
 Export configuration data into ptree.
 
template<class T >
void register_converter (AttributeConverter< T > *object) noexcept
 Register user function for attribute conversion.
 
template<class T >
void convert (T &value, const ConfigObject &obj, const std::string &attr_name) noexcept
 Converts single value.
 
template<class T >
void convert2 (std::vector< T > &value, const ConfigObject &obj, const std::string &attr_name) noexcept
 Converts vector of single values.
 
void print_profiling_info () noexcept
 Print out profiling information.
 
const conffwk::fmap< conffwk::fset > & superclasses () const noexcept
 
const conffwk::fmap< conffwk::fset > & subclasses () const
 
std::vector< std::string > classes_in_python () const
 
void print (std::ostream &) const noexcept
 Prints out details of configuration object.
 
void add_action (ConfigAction *ac)
 
void remove_action (ConfigAction *ac)
 
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > attributes_pybind (const std::string &class_name, bool all)
 
std::vector< std::string > get_class_list () const
 
ConfigObjectcreate_and_return_obj_pybind (const std::string &at, const std::string &class_name, const std::string &id)
 
ConfigObjectcreate_and_return_obj_pybind (const ConfigObject &at, const std::string &class_name, const std::string &id)
 
ConfigObjectget_obj_pybind (const std::string &class_name, const std::string &id)
 
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 > > relations_pybind (const std::string &class_name, bool all)
 
std::list< std::string > * return_includes_pybind (const std::string &db_name)
 
std::vector< std::string > subclasses_pybind (const std::string &class_name, bool all)
 
std::vector< std::string > superclasses_pybind (const std::string &class_name, bool all)
 

Static Public Member Functions

static void system_cb (std::vector< ConfigurationChange * > &, Configuration *) noexcept
 System callback function invoked in case of modifications.
 
static void system_pre_cb (Configuration *) noexcept
 System callback function invoked in case of pre-modifications.
 

Private Types

typedef std::set< CallbackSubscription *, std::less< CallbackSubscription * > > CallbackSet
 
typedef std::set< CallbackPreSubscription *, std::less< CallbackPreSubscription * > > PreCallbackSet
 

Private Member Functions

void reset_subscription ()
 
void _unread_template_objects () noexcept
 
void _unread_implementation_objects (dunedaq::conffwk::ObjectState state) noexcept
 
void _get (const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel, const std::vector< std::string > *rclasses)
 
template<class T >
const T * _get (const std::string &id, bool init_children=false, bool init=true, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
 
template<class T >
const T * _get (ConfigObject &obj, bool init_children=false, bool init=true)
 
template<class T >
void _get (std::vector< const T * > &objects, bool init_children=false, bool init=true, const std::string &query="", unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
 
template<class T >
DalObject_make_instance (ConfigObject &obj, const std::string &uid)
 
const dunedaq::conffwk::class_t_get_class_info (const std::string &class_name, bool direct_only=false)
 
void set_subclasses () noexcept
 
void set_class_domain_map ()
 
void update_classes () noexcept
 
std::deque< std::set< std::string > > find_class_domains ()
 
void rename_object (ConfigObject &obj, const std::string &new_id)
 Cache of template object of given type.
 
CallbackSubscriptionfind_callback (CallbackId cb_handler) const
 
void action_on_update (const ConfigObject &obj, const std::string &name)
 
 Configuration (const Configuration &)
 
Configurationoperator= (const Configuration &)
 

Static Private Member Functions

static void update_impl_objects (conffwk::pmap< conffwk::map< ConfigObjectImpl * > * > &cache, ConfigurationChange &change, const std::string *class_name)
 
static std::string mk_ref_ex_text (const char *what, const std::string &cname, const std::string &rname, const ConfigObject &obj) noexcept
 
static std::string mk_ref_by_ex_text (const std::string &cname, const std::string &rname, const ConfigObject &obj) noexcept
 

Private Attributes

conffwk::map< dunedaq::conffwk::class_t * > p_direct_classes_desc_cache
 
conffwk::map< dunedaq::conffwk::class_t * > p_all_classes_desc_cache
 
std::atomic< uint_least64_t > p_number_of_cache_hits
 
std::atomic< uint_least64_t > p_number_of_template_object_created
 
std::atomic< uint_least64_t > p_number_of_template_object_read
 
conffwk::fmap< conffwk::fsetp_superclasses
 
conffwk::fmap< conffwk::fsetp_subclasses
 
conffwk::fmap< uint > p_class_domain_map
 
conffwk::map< std::list< AttributeConverterBase * > * > m_convert_map
 
ConfigurationImplm_impl
 
std::string m_impl_spec
 
std::string m_impl_name
 
std::string m_impl_param
 
void * m_shlib_h
 
CallbackSet m_callbacks
 
PreCallbackSet m_pre_callbacks
 
std::list< ConfigAction * > m_actions
 
DalRegistry m_registry
 
std::mutex m_impl_mutex
 
std::mutex m_tmpl_mutex
 
std::mutex m_actn_mutex
 
std::mutex m_else_mutex
 

Friends

class DalObject
 
class ConfigObject
 
class ConfigurationImpl
 
class DalRegistry
 

Detailed Description

Defines base class for cache of template objects.

The class is used as a base class for any cached template object. It defines:

  • virtual destructor
  • DAL factory functions Method for configuration profiling
    \brief Provides abstract interface to database data.
    
     The class provides interfaces to data access and notification on data changes
     which are independent from the database implementation.
    
     The class is an entry point to the database information. It provides access
     to the database objects by name of the class and optionally (for named objects)
     by object identities. Normally, user should use this class to open/close database
     and to access objects via template \c get methods invoked with classes generated
     by the genconffwk utility.
    
     Below there is brief description of main methods. Most of then can only be used
     after successful initialization (i.e. database load) of the Configuration object.
    
     Methods throw exceptions in case of an error unless \b noexcept is explicitly
     used in their specification. The following exceptions can be thrown:
     - dunedaq::conffwk::Generic        is used to report most of the problems (bad DB, wrong parameter, plug-in specific, etc.)
     - dunedaq::conffwk::NotFound       the conffwk object accessed by ID is not found, class accessed by name is not found
     - dunedaq::conffwk::DeletedObject  accessing template object that has been deleted (via notification or by the user's code)
    
     All above exceptions have common class dunedaq::conffwk::Exception, that can be used to catch all of them.
    
try {
// load database using oks file /tmp/mydb.data.xml
Configuration db("oksconflibs:/tmp/mydb.data.xml");
// get object "foo@bar"
db.get("bar", "foo", obj);
// print object to the standard output stream
obj.print_ref(std::cout, db);
}
// the catch of dunedaq::conffwk::NotFound exception is optional:
// it is only used to distinguish NotFound exception from other possible once
std::cerr << "Object foo@bar is not found: " << ex << std::endl;
}
// always catch this exception: it can come unexpectedly from DBMS implementation,
// e.g. because of hardware problems or lack of computer resources
catch (dunedaq::conffwk::Exception & ex) {
std::cerr << "ERROR: " << ex << std::endl;
}
Represents database objects.
Defines base class for cache of template objects.
Try to access non-existent object or class.
Definition Errors.hpp:47


Database Manipulation

To get data a database can be opened, closed and it's state can be checked by the following methods:

  • load() open database (by default, the database is opened by the constructor)
  • unload() closes database (by default, the database is closed by the destructor)
  • loaded() returns true, if a database is correctly loaded

To create or to modify data a database the following methods can be used:

  • create(const std::string&, const std::string&, const std::list<std::string>&) create new database
  • add_include() add include to an existing database
  • remove_include() remove include from an existing database
  • commit() save chain of changes
  • abort() cancel all previous changes
Objects Access

The access to the objects is provided via two main methods:

Below there is example to read all computer objects

try {
Configuration db("oksconflibs:daq/partitions/part_hlt.data.xml");
// read all objects of "Computer" class
std::vector<ConfigObject> hosts;
db.get("Computer", hosts);
// print details of the Computer objects
for (const auto& x : objects)
x.print_ref(std::cout, db);
}
catch (dunedaq::conffwk::Exception & ex) {
std::cerr << "ERROR: " << ex << std::endl;
}
 For objects of classes generated by genconffwk there are analogous template methods which
 in addition store pointers to objects in the cache and which to be used by end-user:
 - get(const std::string& id, bool, bool, unsigned long, const std::vector<std::string> *) return const pointer to object of given user class
 - get(std::vector<const T*>& objects, bool, bool, const std::string& query, unsigned long, const std::vector<std::string> *) fills vector of objects of given user class

 Below there is an example for generated \b dal package:
// include generated files for classes used below
#include "dal/Variable.h"
#include "dal/Segment.h"
try {
Configuration db("oksconflibs:daq/partitions/part_hlt.data.xml");
// read all variables with Name = "TDAQ_DB_NAME"
std::vector<const daq::core::Variable*> vars;
db.get(vars, false, true, "(all (\"Name\" \"TDAQ_ERS_INFO\" =))");
// print variables
std::cout << "Got " << vars.size() << " variables with name TDAQ_ERS_INFO:\n";
for (const auto& x : vars)
std::cout << "object " << x << " => " << x->get_Value() << std::endl;
// get segment with id = "online" and print if found
if (const daq::core::Segment * p = db.get<daq::core::Segment>("online"))
std::cout << "The segment object is: " << *p << std::endl;
}
catch (dunedaq::conffwk::Exception & ex) {
std::cerr << "ERROR: " << ex << std::endl;
}
 \par Notification

 To subscribe and unsubscribe on changes it is necessary to create a subscription criteria
 (see ConfigurationSubscriptionCriteria class for more information).
 When a subscription criteria object is created, the following methods can be used:
 - subscribe() subscribe on any changes according criteria
 - unsubscribe() unsubscribe above changes (the CallbackId is returned by above method)

Definition at line 221 of file Configuration.hpp.

Member Typedef Documentation

◆ CallbackId

Callback identifier.

It uniquely identifies a callback inside given process. It is returned by subscribe() method and must be used as parameter for the unsubscribe() methods.

Definition at line 330 of file Configuration.hpp.

◆ CallbackSet

Definition at line 1677 of file Configuration.hpp.

◆ notify

void(*) dunedaq::conffwk::Configuration::notify(const std::vector< ConfigurationChange * > &changed_classes, void *parameter)

The user notification callback function which is invoked in case of changes.

Parameters
changed_classesvector of changed classes
parameteruser-defined parameter

Definition at line 287 of file Configuration.hpp.

◆ pre_notify

void(*) dunedaq::conffwk::Configuration::pre_notify(void *parameter)

The user notification callback function which is invoked before changes are going to be applied.

Parameters
parameteruser-defined parameter

Definition at line 299 of file Configuration.hpp.

◆ PreCallbackSet

Constructor & Destructor Documentation

◆ Configuration() [1/3]

dunedaq::Configuration::Configuration ( const std::string & spec)

Constructor to build a configuration object using implementation plug-in.

The constructor expects parameter in format "plugin-name:plugin-parameter". The plugin-name is used to get implementation shared library by adding "lib" prefix and ".so" suffix, e.g. "oksconflibs" -> "liboksconflibs.so". The plugin-parameter is optional; if non-empty, it is passed to the plug-in constructor.

Parameters
specdatabase name to be understood by the database implementation
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 102 of file Configuration.cpp.

102 :
104{
105 std::string s;
106
107 if (spec.empty())
108 {
109 if (const char *env = getenv("TDAQ_DB"))
110 m_impl_spec = env;
111 }
112 else
113 {
114 m_impl_spec = spec;
115 }
116
117 if (m_impl_spec.empty())
118 throw dunedaq::conffwk::Generic(ERS_HERE, "no database parameter found (check parameter of the constructor or value of TDAQ_DB environment variable)");
119
120 std::string::size_type idx = m_impl_spec.find_first_of(':');
121
122 if (idx == std::string::npos)
123 {
125 }
126 else
127 {
128 m_impl_name = m_impl_spec.substr(0, idx);
129 m_impl_param = m_impl_spec.substr(idx + 1);
130 }
131
132 std::string plugin_name = std::string("lib") + m_impl_name + ".so";
133 std::string impl_creator = std::string("_") + m_impl_name + "_creator_";
134
135 // load plug-in
136 m_shlib_h = dlopen(plugin_name.c_str(), RTLD_LAZY | RTLD_GLOBAL);
137
138 if (!m_shlib_h)
139 {
140 std::ostringstream text;
141 text << "failed to load implementation plug-in \'" << plugin_name << "\': \"" << dlerror() << '\"';
142 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
143 }
144
145 // search in plug-in implementation creator function
146
148 (*f)(const std::string& spec);
149
151 (*)(const std::string&))dlsym(m_shlib_h, impl_creator.c_str());
152
153 char * error = 0;
154
155 if ((error = dlerror()) != 0)
156 {
157 std::ostringstream text;
158 text << "failed to find implementation creator function \'" << impl_creator << "\' in plug-in \'" << plugin_name << "\': \"" << error << '\"';
159 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
160 }
161
162
163 // create implementation
164
165 m_impl = (*f)(m_impl_param);
166
167 if (m_impl)
168 {
169 // m_impl->get_superclasses(p_superclasses);
170 // set_subclasses();
172 m_impl->set(this);
173 }
174
177
178 TLOG_DEBUG(2) << "\n*** DUMP CONFIGURATION ***\n" << *this;
179}
#define ERS_HERE
virtual void prefetch_all_data()=0
Prefetch all data into client cache.
void set(Configuration *db) noexcept
set configuration object
std::atomic< uint_least64_t > p_number_of_template_object_created
std::atomic< uint_least64_t > p_number_of_template_object_read
std::atomic< uint_least64_t > p_number_of_cache_hits
Generic configuration exception.
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112
static bool check_prefetch_needs()
Factory couldn t std::string alg_name Invalid configuration error
Definition Issues.hpp:34

◆ Configuration() [2/3]

dunedaq::Configuration::Configuration ( )

Definition at line 97 of file Configuration.cpp.

◆ ~Configuration()

dunedaq::Configuration::~Configuration ( )
noexcept

Destructor to destroy a configuration object.

The destructor unloads database for given database implementation and destroys all user objects in cache.

Definition at line 214 of file Configuration.cpp.

215{
216 if (::getenv("TDAQ_DUMP_CONFFWK_PROFILER_INFO"))
218
219 try
220 {
221 unload();
222
223 if (m_shlib_h)
224 {
225 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
226
227 delete m_impl;
228 m_impl = 0;
229 //dlclose(m_shlib_h);
230 m_shlib_h = 0;
231 }
232 }
233 catch (dunedaq::conffwk::Generic& ex)
234 {
235 ers::error(ex);
236 }
237}
void print_profiling_info() noexcept
Print out profiling information.
void unload()
Unload database.
void error(const Issue &issue)
Definition ers.hpp:81

◆ Configuration() [3/3]

dunedaq::conffwk::Configuration::Configuration ( const Configuration & )
private

Member Function Documentation

◆ _find()

template<class T >
const T * dunedaq::conffwk::Configuration::_find ( const std::string & id)

Multi-thread unsafe version of find(const std::string&) method.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 55 of file Configuration.hxx.

56 {
57 // auto it = m_cache_map.find(&T::s_class_name);
58 // return (it != m_cache_map.end() ? static_cast<Cache<T>*>(it->second)->find(id) : nullptr);
59 return m_registry.find<T>(id);
60 }
T * find(const std::string &id)
Find template object using ID.

◆ _get() [1/4]

template<class T >
const T * dunedaq::conffwk::Configuration::_get ( ConfigObject & obj,
bool init_children = false,
bool init = true )
private
Exceptions
dunedaq::conffwk::Generic

Definition at line 40 of file Configuration.hxx.

41 {
42 return m_registry.get<T>(obj, init_children, init_object);
43 }
DalObject * get(ConfigObject &obj, bool upcast_unregistered=false)

◆ _get() [2/4]

void dunedaq::conffwk::Configuration::_get ( const std::string & class_name,
const std::string & id,
ConfigObject & object,
unsigned long rlevel,
const std::vector< std::string > * rclasses )
private

◆ _get() [3/4]

template<class T >
const T * dunedaq::conffwk::Configuration::_get ( const std::string & id,
bool init_children = false,
bool init = true,
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = 0 )
private
Exceptions
dunedaq::conffwk::Generic

Definition at line 32 of file Configuration.hxx.

33 {
34 return m_registry.get<T>(name, init_children, init_object, rlevel, rclasses);
35 }

◆ _get() [4/4]

template<class T >
void dunedaq::conffwk::Configuration::_get ( std::vector< const T * > & objects,
bool init_children = false,
bool init = true,
const std::string & query = "",
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = 0 )
private
Exceptions
dunedaq::conffwk::Generic

Definition at line 65 of file Configuration.hxx.

66 {
67 std::vector<ConfigObject> objs;
68
69 try
70 {
71 get(T::s_class_name, objs, query, rlevel, rclasses);
72 }
74 {
75 std::ostringstream text;
76 text << "wrong database schema, cannot find class \'" << ex.get_data() << '\'';
77 throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
78 }
79
80 if (!objs.empty())
81 {
82 for (auto& i : objs)
83 {
84 result.push_back(this->_get<T>(i, init_children, init_object));
85 }
86 }
87 }
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).

◆ _get_class_info()

const dunedaq::conffwk::class_t & dunedaq::Configuration::_get_class_info ( const std::string & class_name,
bool direct_only = false )
private

Definition at line 895 of file Configuration.cpp.

896{
897 conffwk::map<dunedaq::conffwk::class_t *>& d_cache(direct_only ? p_direct_classes_desc_cache : p_all_classes_desc_cache);
898
899 conffwk::map<dunedaq::conffwk::class_t *>::const_iterator i = d_cache.find(class_name);
900
901 if (i != d_cache.end())
902 return *(i->second);
903
904 try
905 {
906 dunedaq::conffwk::class_t * d = m_impl->get(class_name, direct_only);
907 d_cache[class_name] = d;
908 return *d;
909 }
910 // catch Generic exception only; the NotFound is forwarded from implementation
911 catch (dunedaq::conffwk::Generic& ex)
912 {
913 std::ostringstream text;
914 text << "failed to get description of class \'" << class_name << '\'';
915 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
916 }
917}
virtual void get(const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel, const std::vector< std::string > *rclasses)=0
Get object of class by id.
conffwk::map< dunedaq::conffwk::class_t * > p_all_classes_desc_cache
conffwk::map< dunedaq::conffwk::class_t * > p_direct_classes_desc_cache

◆ _make_instance()

template<class T >
DalObject * dunedaq::conffwk::Configuration::_make_instance ( ConfigObject & obj,
const std::string & uid )
inlineprivate
Exceptions
dunedaq::conffwk::Generic

Definition at line 973 of file Configuration.hpp.

974 {
975 // note upcast since the _get() returns pointer to T
976 return const_cast<T*>(_get<T>(obj, uid));
977 }

◆ _ref() [1/2]

template<class T >
const T * dunedaq::conffwk::Configuration::_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 used by user.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 93 of file Configuration.hxx.

94 {
95 return m_registry._ref<T>(obj, name, read_children);
96 // ConfigObject res;
97
98 // try
99 // {
100 // obj.get(name, res);
101 // }
102 // catch (dunedaq::conffwk::Generic & ex)
103 // {
104 // throw(dunedaq::conffwk::Generic( ERS_HERE, mk_ref_ex_text("an object", T::s_class_name, name, obj).c_str(), ex ) );
105 // }
106
107 // return ((!res.is_null()) ? get_cache<T>(res.class_name())->get(*this, res, read_children, read_children) : nullptr);
108 }
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).

◆ _ref() [2/2]

template<class T >
void dunedaq::conffwk::Configuration::_ref ( ConfigObject & obj,
const std::string & name,
std::vector< const T * > & results,
bool read_children )

Multi-thread unsafe version of ref(ConfigObject&, const std::string&, std::vector<const T*>&, bool); The method should not be used by user.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 114 of file Configuration.hxx.

115 {
116
117 return m_registry._ref<T>(obj, name, results, read_children);
118 // std::vector<ConfigObject> objs;
119
120 // results.clear();
121
122 // try
123 // {
124 // obj.get(name, objs);
125 // results.reserve(objs.size());
126
127 // for (auto& i : objs)
128 // {
129 // results.push_back(get_cache<T>(i.class_name())->get(*this, i, read_children, read_children));
130 // }
131 // }
132 // catch (dunedaq::conffwk::Generic & ex)
133 // {
134 // throw(dunedaq::conffwk::Generic( ERS_HERE, mk_ref_ex_text("objects", T::s_class_name, name, obj).c_str(), ex ) );
135 // }
136 }

◆ _reset_objects()

template<class T >
void dunedaq::conffwk::Configuration::_reset_objects ( )
noexcept

Update state of objects after abort operations.

It is used by automatically generated data access libraries.

Definition at line 318 of file Configuration.hxx.

319 {
320 // auto j = m_cache_map.find(&T::s_class_name);
321
322 // if (j != m_cache_map.end())
323 // {
324 // _unread_objects(static_cast<Cache<T>*>(j->second));
325 // }
327 }
void _reset_objects()
Update state of objects after abort operations.

◆ _unread_implementation_objects()

void dunedaq::Configuration::_unread_implementation_objects ( dunedaq::conffwk::ObjectState state)
privatenoexcept

Definition at line 661 of file Configuration.cpp.

662{
663 for (auto &i : m_impl->m_impl_objects)
664 for (auto &j : *i.second)
665 {
666 std::lock_guard<std::mutex> scoped_lock(j.second->m_mutex);
667 j.second->clear();
668 j.second->m_state = state;
669 }
670
671 for (auto& x : m_impl->m_tangled_objects)
672 {
673 std::lock_guard<std::mutex> scoped_lock(x->m_mutex);
674 x->clear();
675 x->m_state = state;
676 }
677}
std::vector< ConfigObjectImpl * > m_tangled_objects
conffwk::pmap< conffwk::map< ConfigObjectImpl * > * > m_impl_objects
cache of implementation objects (class-name::->object_id->implementation)

◆ _unread_template_objects()

void dunedaq::Configuration::_unread_template_objects ( )
privatenoexcept

Definition at line 655 of file Configuration.cpp.

656{
658}
void unread_all()
Set the status of all objects in cache to unread.

◆ abort()

void dunedaq::Configuration::abort ( )

Abort database changes.

The method rolls back non-committed database modifications.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 601 of file Configuration.cpp.

602{
603 TLOG_DEBUG(1) << "call abort";
604
605 if (m_impl == nullptr)
606 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded");
607
608 std::lock_guard<std::mutex> scoped_lock1(m_tmpl_mutex); // always lock template objects mutex first
609 std::lock_guard<std::mutex> scoped_lock2(m_impl_mutex);
610
611 try
612 {
613 m_impl->abort();
616 // m_impl->get_superclasses(p_superclasses);
617 // set_subclasses();
619
620 }
621 catch (dunedaq::conffwk::Generic & ex)
622 {
623 throw(dunedaq::conffwk::Generic( ERS_HERE, "abort failed", ex));
624 }
625}
virtual void abort()=0
Abort database changes.
void _unread_implementation_objects(dunedaq::conffwk::ObjectState state) noexcept

◆ action_on_update()

void dunedaq::Configuration::action_on_update ( const ConfigObject & obj,
const std::string & name )
private

Definition at line 80 of file Configuration.cpp.

81{
82 std::lock_guard<std::mutex> scoped_lock(m_actn_mutex);
83 for (auto &i : m_actions)
84 i->update(obj, name);
85}
std::list< ConfigAction * > m_actions

◆ add_action()

void dunedaq::Configuration::add_action ( ConfigAction * ac)

Add global action performed by user code on db [un]load and updates.

Definition at line 66 of file Configuration.cpp.

67{
68 std::lock_guard<std::mutex> scoped_lock(m_actn_mutex);
69 m_actions.push_back(ac);
70}

◆ add_include()

void dunedaq::Configuration::add_include ( const std::string & db_name,
const std::string & include )

Add include file to existing database.

The method adds (and loads) existing include file to the database.

Parameters
db_namename of database file to be included
includefile to be included
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 474 of file Configuration.cpp.

475{
476 if (m_impl == nullptr)
477 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
478
479 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
480
481 try
482 {
483 m_impl->add_include(db_name, include);
484 // m_impl->get_superclasses(p_superclasses);
485 // set_subclasses();
487 }
488 catch(dunedaq::conffwk::Generic & ex)
489 {
490 std::ostringstream text;
491 text << "failed to add include \'" << include << "\' to database \'" << db_name<< '\'';
492 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
493 }
494}
virtual void add_include(const std::string &db_name, const std::string &include)=0
Add include file.

◆ attributes_pybind()

std::unordered_map< std::string, std::unordered_map< std::string, std::string > > dunedaq::Configuration::attributes_pybind ( const std::string & class_name,
bool all )

Definition at line 1999 of file Configuration.cpp.

1999 {
2000
2001 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> all_attributes_properties;
2002
2003 const dunedaq::conffwk::class_t& c = this->get_class_info(class_name, !all);
2004
2005 for (const auto& ap : c.p_attributes) {
2006 std::unordered_map<std::string, std::string> attribute_properties;
2007 attribute_properties["type"] = dunedaq::conffwk::attribute_t::type(ap.p_type);
2008
2009 attribute_properties["range"] = ap.p_range.empty() ? "None" : ap.p_range;
2010
2011 attribute_properties["description"] = ap.p_description;
2012
2013 attribute_properties["multivalue"] = ap.p_is_multi_value ? "True" : "False";
2014
2015 attribute_properties["not-null"] = ap.p_is_not_null ? "True" : "False";
2016
2017 attribute_properties["init-value"] = ap.p_default_value.empty() ? "None" : ap.p_default_value;
2018
2019 all_attributes_properties[ap.p_name] = attribute_properties;
2020 }
2021
2022 return all_attributes_properties;
2023}
const dunedaq::conffwk::class_t & get_class_info(const std::string &class_name, bool direct_only=false)
The method provides access to description of class.
static const char * type(type_t type)

◆ cast()

template<class TARGET , class SOURCE >
const TARGET * dunedaq::conffwk::Configuration::cast ( const SOURCE * s)
inlinenoexcept

Cast objects from one class to another (multi-thread safe).

Try to cast object SOURCE to TARGET. Returns 0 if not successful. Do not use the normal dynamic_cast<T>() for database classes.

Returns
Return nullptr if the cast is not successful.

Definition at line 950 of file Configuration.hpp.

950 {
951 return s->template cast<TARGET>();
952 }
const TARGET * cast(const SOURCE *s) noexcept
Cast objects from one class to another (multi-thread safe).

◆ classes_in_python()

std::vector< std::string > dunedaq::conffwk::Configuration::classes_in_python ( ) const

◆ commit()

void dunedaq::Configuration::commit ( const std::string & log_message = "")

Commit database changes.

The method commits the changes after a database was modified.

Parameters
log_messagelog information
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 580 of file Configuration.cpp.

581{
582 TLOG_DEBUG(1) << "call commit";
583
584 if (m_impl == nullptr)
585 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded");
586
587 std::lock_guard<std::mutex> scoped_lock1(m_tmpl_mutex); // always lock template objects mutex first
588 std::lock_guard<std::mutex> scoped_lock2(m_impl_mutex);
589
590 try
591 {
592 m_impl->commit(log_message);
593 }
594 catch (dunedaq::conffwk::Generic & ex)
595 {
596 throw(dunedaq::conffwk::Generic( ERS_HERE, "commit failed", ex ) );
597 }
598}
virtual void commit(const std::string &log_message)=0
Commit database changes.

◆ convert()

template<class T >
void dunedaq::conffwk::Configuration::convert ( T & value,
const ConfigObject & obj,
const std::string & attr_name )
noexcept

Converts single value.

The method is used by the code generated by the genconffwk utility.

Definition at line 387 of file Configuration.hxx.

388 {
389 conffwk::map<std::list<AttributeConverterBase*> *>::const_iterator l = m_convert_map.find(typeid(T).name());
390 if (l != m_convert_map.end())
391 {
392 for (const auto& i : *l->second)
393 {
394 static_cast<AttributeConverter<T>*>(i)->convert(value, *this, obj, attr_name);
395 }
396 }
397 }
conffwk::map< std::list< AttributeConverterBase * > * > m_convert_map
void convert(T &value, const ConfigObject &obj, const std::string &attr_name) noexcept
Converts single value.

◆ convert2()

template<class T >
void dunedaq::conffwk::Configuration::convert2 ( std::vector< T > & value,
const ConfigObject & obj,
const std::string & attr_name )
noexcept

Converts vector of single values.

The method is used by the code generated by the genconffwk utility.

Definition at line 401 of file Configuration.hxx.

402 {
403 conffwk::map<std::list<AttributeConverterBase*> *>::const_iterator l = m_convert_map.find(typeid(T).name());
404 if (l != m_convert_map.end())
405 {
406 for (auto& j : value)
407 {
408 for (const auto& i : *l->second)
409 {
410 static_cast<AttributeConverter<T>*>(i)->convert(j, *this, obj, attr_name);
411 }
412 }
413 }
414 }

◆ create() [1/5]

void dunedaq::Configuration::create ( const ConfigObject & at,
const std::string & class_name,
const std::string & id,
ConfigObject & object )

Create new object by class name and object id.

The method tries to create an object with given id in given class. If found, the method fills 'object' reference.

Parameters
atcreate new object at the same database file where 'at' object is located
class_namename of the class
idobject identity
objectreturned value in case of success
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 807 of file Configuration.cpp.

808{
809 try
810 {
811 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
812 m_impl->create(at, class_name, id, object);
813 }
814 catch (dunedaq::conffwk::Generic& ex)
815 {
816 std::ostringstream text;
817 text << "failed to create object \'" << id << '@' << class_name << '\'';
818 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
819 }
820}
virtual void create(const std::string &db_name, const std::list< std::string > &includes)=0
Create database.

◆ create() [2/5]

template<class T >
const T * dunedaq::conffwk::Configuration::create ( const DalObject & at,
const std::string & id,
bool init_object = false )

Create object of given class by identity and instantiate the template parameter with it.

Such method to be used for user classes generated by the genconffwk utility.

Parameters
atan existing object of class generated by genconffwk to define location of the file where to store new object
idobject identity
init_objectif true, initialize object's attributes and relationships
Returns
non-null pointer to created object.
Exceptions
dunedaq::conffwk::Genericin case of an error

◆ create() [3/5]

void dunedaq::Configuration::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.

The method tries to create an object with given id in given class. If found, the method fills 'object' reference.

Parameters
atdatabase file where to create new object
class_namename of the class
idobject identity
objectreturned value in case of success
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 791 of file Configuration.cpp.

792{
793 try
794 {
795 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
796 m_impl->create(at, class_name, id, object);
797 }
798 catch (dunedaq::conffwk::Generic& ex)
799 {
800 std::ostringstream text;
801 text << "failed to create object \'" << id << '@' << class_name << '\'';
802 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
803 }
804}

◆ create() [4/5]

template<class T >
const T * dunedaq::conffwk::Configuration::create ( const std::string & at,
const std::string & id,
bool init_object = false )

Create object of given class by identity and instantiate the template parameter with it.

Such method to be used for user classes generated by the genconffwk utility.

Parameters
atdatabase file where to create new object
idobject identity
init_objectif true, initialise object's attributes and relationships
Returns
non-null pointer to created object.
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 12 of file Configuration.hxx.

13 {
15
16 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
17 create(at, T::s_class_name, id, obj);
18 return m_registry.get<T>(obj, false, init_object);
19 }
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.

◆ create() [5/5]

void dunedaq::Configuration::create ( const std::string & db_name,
const std::list< std::string > & includes )

Create database.

The method creates database according to the name and list of others database files to be included.

Parameters
db_namename of new database file (must be an absolute path to non-existing file)
includesoptional list of others database files to be included
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 431 of file Configuration.cpp.

432{
433 if (m_impl == nullptr)
434 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
435
436 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
437
438 try
439 {
440 m_impl->create(db_name, includes);
442 }
443 catch(dunedaq::conffwk::Generic & ex)
444 {
445 std::ostringstream text;
446 text << "failed to create database \'" << db_name << '\'';
447 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
448 }
449}

◆ create_and_return_obj_pybind() [1/2]

ConfigObject * dunedaq::Configuration::create_and_return_obj_pybind ( const ConfigObject & at,
const std::string & class_name,
const std::string & id )

Definition at line 2043 of file Configuration.cpp.

2044{
2045 auto co = new ConfigObject;
2046 this->create(at, class_name, id, *co);
2047 return co;
2048}

◆ create_and_return_obj_pybind() [2/2]

ConfigObject * dunedaq::Configuration::create_and_return_obj_pybind ( const std::string & at,
const std::string & class_name,
const std::string & id )

Definition at line 2036 of file Configuration.cpp.

2036 {
2037 auto co = new ConfigObject;
2038 this->create(at, class_name, id, *co);
2039 return co;
2040}

◆ destroy()

template<class T >
void dunedaq::conffwk::Configuration::destroy ( T & obj)

Destroy object of given class.

The method tries to destoy given object.

Parameters
objthe object's reference
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 24 of file Configuration.hxx.

25 {
26 destroy_obj(const_cast<ConfigObject&>(obj.config_object()));
27 }
void destroy_obj(ConfigObject &object)
Destroy object.

◆ destroy_obj()

void dunedaq::Configuration::destroy_obj ( ConfigObject & object)

Destroy object.

The method tries to destroy given object.

Parameters
objectthe object's reference
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 824 of file Configuration.cpp.

825{
826 try
827 {
828 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
829 std::lock_guard<std::mutex> scoped_lock2(m_tmpl_mutex);
830 m_impl->destroy(object);
831 }
832 catch (dunedaq::conffwk::Generic& ex)
833 {
834 std::ostringstream text;
835 text << "failed to destroy object \'" << object << '\'';
836 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
837 }
838}
virtual void destroy(ConfigObject &object)=0
Destroy object of class by id.

◆ downcast_dal_object()

template<class T >
void dunedaq::conffwk::Configuration::downcast_dal_object ( const T * obj,
bool ,
std::vector< const DalObject * > & result )
inline

Definition at line 999 of file Configuration.hpp.

1000 {
1001 if(obj)
1002 result.push_back(obj);
1003 }

◆ downcast_dal_objects()

template<class T >
void dunedaq::conffwk::Configuration::downcast_dal_objects ( const std::vector< const T * > & objs,
bool ,
std::vector< const DalObject * > & result )
inline

Definition at line 990 of file Configuration.hpp.

992 {
993 for (auto& i : objs)
994 result.push_back(i);
995 }

◆ export_data()

void dunedaq::Configuration::export_data ( boost::property_tree::ptree & tree,
const std::string & classes = "",
const std::string & objects = "",
const std::string & files = "",
const std::string & empty_array_item = "" )

Export configuration data into ptree.

Parameters
treeoutput ptree object
classesregex defining class names; ignore if empty
objectsregex defining object IDs; ignore if empty
filesregex defining data file names; ignore if empty
empty_array_itemif provided, add this item to mark empty arrays
Exceptions
dunedaq::conffwk::Genericin case of a problem

Definition at line 1092 of file Configuration.cpp.

1093{
1094 std::unique_ptr<std::regex> classes_regex, objects_regex, files_regex;
1095
1096 init_regex(classes_regex, classes_str, "classes");
1097 init_regex(objects_regex, objects_str, "objects");
1098 init_regex(files_regex, files_str, "files");
1099
1100 auto cmp_str_ptr = [](const std::string * s1, const std::string * s2) { return *s1 < *s2; };
1101 std::set<const std::string *, decltype(cmp_str_ptr)> sorted_classes(cmp_str_ptr);
1102
1103 for (const auto &c : superclasses())
1104 if (classes_str.empty() || std::regex_match(*c.first, *classes_regex.get()))
1105 sorted_classes.insert(c.first);
1106
1107 for (const auto &c : sorted_classes)
1108 if (classes_str.empty() || std::regex_match(*c, *classes_regex.get()))
1109 {
1111
1112 boost::property_tree::ptree pt_objects;
1113
1114 std::vector<ConfigObject> objects;
1115 get(*c, objects);
1116
1117 auto comp_obj_ptr = [](const ConfigObject * o1, const ConfigObject * o2) { return o1->UID() < o2->UID(); };
1118 std::set<const ConfigObject *, decltype(comp_obj_ptr)> sorted_objects(comp_obj_ptr);
1119
1120 for (const auto& x : objects)
1121 if (objects_str.empty() || std::regex_match(x.UID(), *objects_regex.get()))
1122 if (x.class_name() == *c)
1123 if(files_str.empty() || std::regex_match(x.contained_in(), *files_regex.get()))
1124 sorted_objects.insert(&x);
1125
1126 if (!sorted_objects.empty())
1127 {
1128 boost::property_tree::ptree pt_objects;
1129
1130 for (const auto& x : sorted_objects)
1131 {
1132 boost::property_tree::ptree data;
1133
1134 for (const auto &a : info.p_attributes)
1135 switch (a.p_type)
1136 {
1138 add_data<bool>(data, *x, a, empty_array_item);
1139 break;
1141 add_data<int8_t>(data, *x, a, empty_array_item);
1142 break;
1144 add_data<uint8_t>(data, *x, a, empty_array_item);
1145 break;
1147 add_data<int16_t>(data, *x, a, empty_array_item);
1148 break;
1150 add_data<uint16_t>(data, *x, a, empty_array_item);
1151 break;
1153 add_data<int32_t>(data, *x, a, empty_array_item);
1154 break;
1156 add_data<uint32_t>(data, *x, a, empty_array_item);
1157 break;
1159 add_data<int64_t>(data, *x, a, empty_array_item);
1160 break;
1162 add_data<uint64_t>(data, *x, a, empty_array_item);
1163 break;
1165 add_data<float>(data, *x, a, empty_array_item);
1166 break;
1168 add_data<double>(data, *x, a, empty_array_item);
1169 break;
1175 add_data<std::string>(data, *x, a, empty_array_item);
1176 break;
1177 default:
1178 throw std::runtime_error("Invalid type of attribute " + a.p_name);
1179
1180 }
1181
1182 for (const auto &r : info.p_relationships)
1183 add_data(data, *x, r, empty_array_item);
1184
1185 pt_objects.push_back(boost::property_tree::ptree::value_type(x->UID(), data));
1186 }
1187
1188 pt.put_child(boost::property_tree::ptree::path_type(*c), pt_objects);
1189 }
1190 }
1191}
const conffwk::fmap< conffwk::fset > & superclasses() const noexcept
static void init_regex(std::unique_ptr< std::regex > &ptr, const std::string &str, const char *what)
static void add_data(boost::property_tree::ptree &pt, const ConfigObject &obj, const dunedaq::conffwk::attribute_t &attribute, const std::string &empty_array_item)

◆ export_schema()

void dunedaq::Configuration::export_schema ( boost::property_tree::ptree & tree,
const std::string & classes = "",
bool direct_only = false )

Export configuration schema into ptree.

Parameters
treeoutput ptree object
classesregex defining class names; all classes if empty
direct_onlyif true is set explicitly, return descriptions of direct attributes, relationships, super- and subclasses; by default return all descriptions taking into account inheritance
Exceptions
dunedaq::conffwk::Genericin case of a problem

Definition at line 948 of file Configuration.cpp.

949{
950 std::unique_ptr<std::regex> classes_regex;
951
952 init_regex(classes_regex, classes_str, "classes");
953
954 auto cmp_str_ptr = [](const std::string * s1, const std::string * s2) { return *s1 < *s2; };
955 std::set<const std::string *, decltype(cmp_str_ptr)> sorted_classes(cmp_str_ptr);
956
957 for (const auto &c : superclasses())
958 if (classes_str.empty() || std::regex_match(*c.first, *classes_regex.get()))
959 sorted_classes.insert(c.first);
960
961 for (const auto &c : sorted_classes)
962 if (classes_str.empty() || std::regex_match(*c, *classes_regex.get()))
963 {
964 const dunedaq::conffwk::class_t& info(get_class_info(*c, direct_only));
965
966 boost::property_tree::ptree class_pt;
967
968 class_pt.put("abstract", info.p_abstract);
969 if (!info.p_description.empty())
970 class_pt.put("description", info.p_description);
971
972 if (!info.p_superclasses.empty())
973 {
974 boost::property_tree::ptree superclasses;
975
976 for (const auto &x : info.p_superclasses)
978
979 class_pt.add_child("superclasses", superclasses);
980 }
981
982 if (!info.p_attributes.empty())
983 {
984 boost::property_tree::ptree attributes;
985
986 for (const auto &x : info.p_attributes)
987 {
988 boost::property_tree::ptree attribute;
989
990 attribute.put("type", dunedaq::conffwk::attribute_t::type(x.p_type));
991 if (!x.p_range.empty())
992 attribute.put("range", x.p_range);
993 if (x.p_int_format != dunedaq::conffwk::na_int_format)
994 attribute.put("format", dunedaq::conffwk::attribute_t::format2str(x.p_int_format));
995 if (x.p_is_not_null)
996 attribute.put("is-not-null", x.p_is_not_null);
997 if (x.p_is_multi_value)
998 attribute.put("is-multi-value", x.p_is_multi_value);
999 if (!x.p_default_value.empty())
1000 attribute.put("default-value", x.p_default_value);
1001 if (!x.p_description.empty())
1002 attribute.put("description", x.p_description);
1003
1004 attributes.push_back(boost::property_tree::ptree::value_type(x.p_name, attribute));
1005 }
1006
1007 class_pt.add_child("attributes", attributes);
1008 }
1009
1010 if (!info.p_relationships.empty())
1011 {
1012 boost::property_tree::ptree relationships;
1013
1014 for (const auto &x : info.p_relationships)
1015 {
1016 boost::property_tree::ptree relationship;
1017
1018 relationship.put("type", x.p_type);
1019 relationship.put("cardinality", dunedaq::conffwk::relationship_t::card2str(x.p_cardinality));
1020 if (!x.p_is_aggregation)
1021 relationship.put("is-aggregation", x.p_is_aggregation);
1022 if (!x.p_description.empty())
1023 relationship.put("description", x.p_description);
1024
1025 relationships.push_back(boost::property_tree::ptree::value_type(x.p_name, relationship));
1026 }
1027
1028 class_pt.add_child("relationships", relationships);
1029 }
1030
1031 pt.put_child(boost::property_tree::ptree::path_type(*c), class_pt);
1032 }
1033}
std::vector< T > attributes(tref const &item)
T attribute(tref item, dunedaq::conffwk::attribute_t const &attr)
static void add_array_item(boost::property_tree::ptree &pt, const T &val)
static const char * format2str(int_format_t format)
static const char * card2str(cardinality_t cardinality)

◆ find()

template<class T >
const T * dunedaq::conffwk::Configuration::find ( const std::string & id)
inline

Find object of given class (multi-thread safe).

Could be used for generated template objects.

Parameters
idID of object
Returns
Return pointer to object or nullptr if there is no such object
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 838 of file Configuration.hpp.

839 {
840 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
841 return _find<T>(id);
842 }
const T * _find(const std::string &id)
Multi-thread unsafe version of find(const std::string&) method.

◆ find_callback()

Configuration::CallbackSubscription * dunedaq::Configuration::find_callback ( CallbackId cb_handler) const
private

Definition at line 1243 of file Configuration.cpp.

1244{
1245 return ((!cb_handler || (m_callbacks.find(cb_handler) == m_callbacks.end())) ? 0 : cb_handler);
1246}

◆ find_class_domains()

std::deque< std::set< std::string > > dunedaq::Configuration::find_class_domains ( )
private

Definition at line 702 of file Configuration.cpp.

703{
704 std::deque<std::set<std::string>> domains;
705
706 std::deque<dunedaq::conffwk::class_t> seeds;
707 for (const auto& c : get_class_list()) {
708 auto ci = this->_get_class_info(c);
709 if (ci.p_superclasses.empty())
710 seeds.push_back(ci);
711 }
712
713 for (const auto& ci : seeds) {
714 // Make a candidate domain based using the seed subclasses
715 std::set<std::string> class_domain;
716 class_domain.insert(ci.p_name);
717 class_domain.insert(ci.p_subclasses.begin(), ci.p_subclasses.end());
718
719 // Look for overlaps with other domains
720 std::deque<std::set<std::string>> overlapping;
721 for (auto& d : domains) {
722 std::set<std::string> intersection;
723 std::set_intersection(d.begin(), d.end(), class_domain.begin(), class_domain.end(), std::inserter(intersection, intersection.begin()));
724 // non-zero intersection, overlap found
725 if (intersection.size() > 0) {
726 overlapping.push_back(d);
727 }
728 }
729
730 // If overlapping are found, add all overlapping to
731 // the new domain and remove them from the domain list
732 if ( !overlapping.empty() ) {
733 for( auto& d : overlapping ) {
734 // merge the existing cluster in class_domain
735 class_domain.insert(d.begin(), d.end());
736 // Remove the old cluster from the list
737 auto it = std::find(domains.begin(), domains.end(), d);
738 if (it!= domains.end()) {
739 domains.erase(it);
740 }
741 }
742 }
743
744 domains.push_back(class_domain);
745 }
746
747 return domains;
748}
const dunedaq::conffwk::class_t & _get_class_info(const std::string &class_name, bool direct_only=false)
std::vector< std::string > get_class_list() const

◆ get() [1/7]

template<class T >
const T * dunedaq::conffwk::Configuration::get ( ConfigObject & obj,
bool init_children = false,
bool init = true )
inline

Get object of given class by object reference and instantiate the template parameter with it (multi-thread safe).

Such method to be used for user classes generated by the genconffwk utility.

Parameters
objreference to conffwk object, that is used to instantiate template object
init_childrenif true, the referenced objects are initialized
initif true, the object's attributes and relationships are read
Returns
Return pointer to object.
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 771 of file Configuration.hpp.

772 {
773 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
774 return _get<T>(obj, init_children, init);
775 }
void init(unordered_map< std::string, std::string > params)

◆ get() [2/7]

template<class T >
const T * dunedaq::conffwk::Configuration::get ( ConfigObject & obj,
const std::string & id )
inline

Generate object of given class by object reference and instantiate the template parameter with it (multi-thread safe).

Such method to be used to generate template objects.

Parameters
objreference to conffwk object, that is used to instantiate template object
idID of generated object could be different from obj.UID()
Returns
Return pointer to object.
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 817 of file Configuration.hpp.

818 {
819 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
820 return _get<T>(obj, id);
821 }

◆ get() [3/7]

void dunedaq::Configuration::get ( const ConfigObject & obj_from,
const std::string & query,
std::vector< ConfigObject > & objects,
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = 0 )

Get path between objects.

The method returns all objects which are in the path starting from source object matching to the path query pattern.

Parameters
obj_fromobject to start from
querypath query
objectsreturned value in case of success
rleveloptional references level to optimize performance (defines how many objects referenced by found objects have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 282 of file Configuration.cpp.

283{
284 try
285 {
286 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
287 m_impl->get(obj_from, query, objects, rlevel, rclasses);
288 }
289 catch (dunedaq::conffwk::Generic& ex)
290 {
291 std::ostringstream text;
292 text << "failed to get path \'" << query << "\' from object \'" << obj_from << '\'';
293 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
294 }
295}

◆ get() [4/7]

void dunedaq::Configuration::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).

The method searches an object with given id within the class and all derived subclasses.

Parameters
class_namename of the class
idobject identity
objectreturned value in case of success
rleveloptional references level to optimize performance (defines how many objects referenced by given object have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Exceptions
dunedaq::conffwk::NotFoundexception if there is no such object or dunedaq::conffwk::Generic in case of an error

Definition at line 240 of file Configuration.cpp.

241{
242 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
243 _get(class_name, id, object, rlevel, rclasses);
244}

◆ get() [5/7]

void dunedaq::Configuration::get ( const std::string & class_name,
std::vector< ConfigObject > & objects,
const std::string & query = "",
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = 0 )

Get all objects of class.

The method returns all objects of given class and objects of subclasses derived from it.

Parameters
class_namename of the class
objectsreturned value in case of success
queryoptional parameter defining selection criteria for objects of given class
rleveloptional references level to optimize performance (defines how many objects referenced by found objects have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Exceptions
dunedaq::conffwk::NotFoundexception if there is no such class or dunedaq::conffwk::Generic in case of an error

Definition at line 262 of file Configuration.cpp.

263{
264 try
265 {
266 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
267 m_impl->get(class_name, objects, query, rlevel, rclasses);
268 }
269 catch (dunedaq::conffwk::Generic& ex)
270 {
271 std::ostringstream text;
272 text << "failed to get objects of class \'" << class_name << '\'';
273 if (!query.empty())
274 {
275 text << " with query \'" << query << '\'';
276 }
277 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
278 }
279}

◆ get() [6/7]

template<class T >
const T * dunedaq::conffwk::Configuration::get ( const std::string & id,
bool init_children = false,
bool init = true,
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = 0 )
inline

Get object of given class by identity and instantiate the template parameter with it (multi-thread safe).

Such method to be used for user classes generated by the genconffwk utility.

Parameters
idobject identity
init_childrenif true, the referenced objects are initialized
initif true, the object's attributes and relationships are read
rleveloptional references level to optimize performance (defines how many objects referenced by given object have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Returns
Return 0 if there is no object with such id or pointer to object otherwise.
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 747 of file Configuration.hpp.

748 {
749 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
750 return _get<T>(id, init_children, init, rlevel, rclasses);
751 }

◆ get() [7/7]

template<class T >
void dunedaq::conffwk::Configuration::get ( std::vector< const T * > & objects,
bool init_children = false,
bool init = true,
const std::string & query = "",
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = 0 )
inline

Get all objects of given class and instantiate a vector of the template parameters object with it (multi-thread safe).

Such method to be used for user classes generated by the genconffwk utility.

Parameters
objectsthe vector is filled by the method
init_childrenif true, the referenced objects are initialized
initif true, the object's attributes and relationships are read
queryoptional parameter defining selection criteria for objects of given class
rleveloptional references level to optimize performance (defines how many objects referenced by found objects have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Exceptions
dunedaq::conffwk::Genericin case of a problem (e.g. no such class, plug-in specific problem)

Definition at line 796 of file Configuration.hpp.

797 {
798 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
799 _get<T>(objects, init_children, init, query, rlevel, rclasses);
800 }

◆ get_changes()

std::vector< dunedaq::conffwk::Version > dunedaq::Configuration::get_changes ( )

Get new conffwk versions.

Returns
repository changes: new versions created on remote origin after current HEAD version, or externally modified files
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 1203 of file Configuration.cpp.

1204{
1205 try
1206 {
1207 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
1208 return m_impl->get_changes();
1209 }
1210 catch (dunedaq::conffwk::Generic& ex)
1211 {
1212 throw dunedaq::conffwk::Generic( ERS_HERE, "failed to get new versions", ex );
1213 }
1214}
virtual std::vector< dunedaq::conffwk::Version > get_changes()=0
Get newly available versions.

◆ get_class_info()

const dunedaq::conffwk::class_t & dunedaq::Configuration::get_class_info ( const std::string & class_name,
bool direct_only = false )

The method provides access to description of class.

Parameters
class_namename of the class
direct_onlyif true is set explicitly, return descriptions of direct attributes, relationships, super- and subclasses; by default return all descriptions taking into account inheritance
Returns
Return pointer to class description object.
Exceptions
dunedaq::conffwk::NotFoundexception if there is no class with such name or dunedaq::conffwk::Generic in case of a problem

Definition at line 886 of file Configuration.cpp.

887{
888 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
889
890 return this->_get_class_info(class_name, direct_only);
891}

◆ get_class_list()

std::vector< std::string > dunedaq::Configuration::get_class_list ( ) const

Definition at line 2026 of file Configuration.cpp.

2026 {
2027 std::vector<std::string> classes;
2028 for (const auto& it : this->superclasses()) {
2029 classes.push_back(*it.first);
2030 }
2031
2032 return classes;
2033}

◆ get_impl_name()

const std::string & dunedaq::conffwk::Configuration::get_impl_name ( ) const
inlinenoexcept

Get implementation plug-in name used to build conffwk object

Definition at line 259 of file Configuration.hpp.

259{return m_impl_name;}

◆ get_impl_param()

const std::string & dunedaq::conffwk::Configuration::get_impl_param ( ) const
inlinenoexcept

Get implementation plug-in parameter used to build conffwk object

Definition at line 264 of file Configuration.hpp.

264{return m_impl_param;}

◆ get_impl_spec()

const std::string & dunedaq::conffwk::Configuration::get_impl_spec ( ) const
inlinenoexcept

Get implementation plug-in and it's parameter used to build conffwk object

Definition at line 254 of file Configuration.hpp.

254{return m_impl_spec;}

◆ get_includes()

void dunedaq::Configuration::get_includes ( const std::string & db_name,
std::list< std::string > & includes ) const

Get include files.

The method returns list of files included by given database.

Parameters
db_namename of database file
includesreturned list of include files
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 521 of file Configuration.cpp.

522{
523 if (m_impl == nullptr)
524 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
525
526 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
527
528 try
529 {
530 m_impl->get_includes(db_name, includes);
531 }
532 catch(dunedaq::conffwk::Generic & ex)
533 {
534 std::ostringstream text;
535 text << "failed to get includes of database \'" << db_name<< '\'';
536 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
537 }
538}
virtual void get_includes(const std::string &db_name, std::list< std::string > &includes) const =0
Get included files.

◆ get_obj_pybind()

ConfigObject * dunedaq::Configuration::get_obj_pybind ( const std::string & class_name,
const std::string & id )

Definition at line 2051 of file Configuration.cpp.

2052{
2053 auto co = new ConfigObject;
2054 this->get(class_name, id, *co);
2055 if (co->is_null()) {
2056 delete co;
2057 co = nullptr;
2058 }
2059 return co;
2060}

◆ get_objs_pybind()

std::vector< ConfigObject > * dunedaq::Configuration::get_objs_pybind ( const std::string & class_name,
const std::string & query = "" )

Definition at line 2063 of file Configuration.cpp.

2063 {
2064 auto objs = new std::vector<ConfigObject>;
2065 this->get(class_name, *objs, query);
2066 return objs;
2067}

◆ get_updated_dbs()

void dunedaq::Configuration::get_updated_dbs ( std::list< std::string > & dbs) const

Get list of updated files to be committed.

The method returns list of uncommitted database files.

Parameters
dbsreturned list of uncommitted database files
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 542 of file Configuration.cpp.

543{
544 if (m_impl == nullptr)
545 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
546
547 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
548
549 try
550 {
552 }
553 catch(dunedaq::conffwk::Generic & ex)
554 {
555 throw ( dunedaq::conffwk::Generic( ERS_HERE, "get_updated_dbs failed", ex ) );
556 }
557}
virtual void get_updated_dbs(std::list< std::string > &dbs) const =0
Get uncommitted files.

◆ get_versions()

std::vector< dunedaq::conffwk::Version > dunedaq::Configuration::get_versions ( const std::string & since,
const std::string & until,
dunedaq::conffwk::Version::QueryType type = dunedaq::conffwk::Version::query_by_date,
bool skip_irrelevant = true )

Get repository versions in interval.

Access historical versions.

The date/time format has to be either a date in format "yyyy-mm-dd" or date-and-time in format "yyyy-mm-dd hh:mm:ss" (UTC).

Parameters
sincelimit the versions committed on-or-after the specified hash key, tag or date/time; if empty, start from earliest available
untillimit the versions committed on-or-before the specified hash key, tag or date/time; if empty, retrieve all versions until latest available
typedefine query type
skip_irrelevantif true, ignore changes not affecting loaded configuration
Returns
repository versions satisfying query
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 1218 of file Configuration.cpp.

1219{
1220 try
1221 {
1222 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
1223 return m_impl->get_versions(since, until, type, skip_irrelevant);
1224 }
1225 catch (dunedaq::conffwk::Generic& ex)
1226 {
1227 throw dunedaq::conffwk::Generic( ERS_HERE, "failed to get versions", ex );
1228 }
1229}
virtual std::vector< dunedaq::conffwk::Version > get_versions(const std::string &since, const std::string &until, dunedaq::conffwk::Version::QueryType type, bool skip_irrelevant)=0
Get archived versions.

◆ is_superclass_of() [1/2]

bool dunedaq::conffwk::Configuration::is_superclass_of ( const std::string & target,
const std::string & source )
noexcept

◆ is_superclass_of() [2/2]

bool dunedaq::conffwk::Configuration::is_superclass_of ( const std::string * target,
const std::string * source )
noexcept

◆ is_valid()

template<class T >
bool dunedaq::conffwk::Configuration::is_valid ( const T * object)
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.

Returns
Return true if the pointer is valid and false otherwise.

Definition at line 275 of file Configuration.hxx.

276 {
277 // std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
278
279 // auto j = m_cache_map.find(&T::s_class_name);
280
281 // if (j != m_cache_map.end())
282 // {
283 // Cache<T> *c = static_cast<Cache<T>*>(j->second);
284
285 // for (const auto& i : c->m_cache)
286 // {
287 // if (i->second == object)
288 // return true;
289 // }
290 // }
291
292 // return false;
293
294 return m_registry.is_valid(object);
295 }
bool is_valid(const T *object) noexcept
Checks validity of pointer to an objects of given user class.

◆ is_writable()

bool dunedaq::Configuration::is_writable ( const std::string & db_name) const

Get write access status.

Check if given database file is writable by current user.

Parameters
db_namename of database
Returns
true, if database file is writable and false otherwise.
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 453 of file Configuration.cpp.

454{
455 if (m_impl == nullptr)
456 throw(dunedaq::conffwk::Generic(ERS_HERE, "no implementation loaded" ) );
457
458 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
459
460 try
461 {
462 return m_impl->is_writable(db_name);
463 }
464 catch(dunedaq::conffwk::Generic & ex)
465 {
466 std::ostringstream text;
467 text << "failed to get write access status for database \'" << db_name<< '\'';
468 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
469 }
470}
virtual bool is_writable(const std::string &db_name)=0
Return write access status.

◆ load()

void dunedaq::Configuration::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 environment variables.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 304 of file Configuration.cpp.

305{
306 std::string name;
307
308 if (db_name.empty())
309 {
310 if (!m_impl_spec.empty() && !m_impl_param.empty())
311 {
312 name = m_impl_param;
313 }
314 else
315 {
316 const char * s = ::getenv("TDAQ_DB_NAME");
317 if (s == 0 || *s == 0)
318 s = ::getenv("TDAQ_DB_DATA");
319
320 if (s && *s)
321 {
322 name = s;
323 }
324 else
325 {
326 throw(dunedaq::conffwk::Generic( ERS_HERE, "no database name was provided" ) );
327 }
328 }
329 }
330 else
331 {
332 name = db_name;
333 }
334
335 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
336
337 // call conffwk actions if any
338 {
339 std::lock_guard<std::mutex> scoped_lock(m_actn_mutex);
340 for (auto & i : m_actions)
341 {
342 i->load();
343 }
344 }
345
346 if (m_impl)
347 {
348 m_impl->open_db(name);
349 // m_impl->get_superclasses(p_superclasses);
350 // set_subclasses();
352 m_impl->set(this);
353
355 {
357 }
358
359 TLOG_DEBUG(2) << "\n*** DUMP CONFIGURATION ***\n" << *this;
360 }
361 else
362 {
363 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
364 }
365}
virtual void open_db(const std::string &db_name)=0
Open database implementation in accordance with given name.

◆ loaded()

bool dunedaq::Configuration::loaded ( ) const
noexcept

Check if database is correctly loaded.

Check state of the database after configuration object creation.

Returns
true if the database was successfully loaded and false otherwise.

Definition at line 298 of file Configuration.cpp.

299{
300 return (m_impl != nullptr) ? m_impl->loaded() : false;
301}
virtual bool loaded() const noexcept=0
Check if a database is loaded.

◆ mk_ref_by_ex_text()

std::string dunedaq::Configuration::mk_ref_by_ex_text ( const std::string & cname,
const std::string & rname,
const ConfigObject & obj )
staticprivatenoexcept

Helper method to prepare exception text when template referenced_by() method fails

Definition at line 1949 of file Configuration.cpp.

1950{
1951 std::ostringstream text;
1952 text << "failed to get objects of class \'" << cname << "\' referencing object \'" << obj << "\' via relationship \'" << rname << '\'';
1953 return text.str();
1954}

◆ mk_ref_ex_text()

std::string dunedaq::Configuration::mk_ref_ex_text ( const char * what,
const std::string & cname,
const std::string & rname,
const ConfigObject & obj )
staticprivatenoexcept

Helper method to prepare exception text when template ref() method fails

Definition at line 1940 of file Configuration.cpp.

1941{
1942 std::ostringstream text;
1943 text << "failed to get " << what << " of class \'" << cname << "\' via relationship \'" << rname << "\' of object \'" << obj << '\'';
1944 return text.str();
1945}

◆ operator=()

Configuration & dunedaq::conffwk::Configuration::operator= ( const Configuration & )
private

◆ prefetch_all_data()

void dunedaq::Configuration::prefetch_all_data ( )

Prefetch all data into client cache.

The method reads all objects defined in database into client cache.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 628 of file Configuration.cpp.

629{
630 std::lock_guard<std::mutex> scoped_lock1(m_tmpl_mutex); // always lock template objects mutex first
631 std::lock_guard<std::mutex> scoped_lock2(m_impl_mutex);
632
633 try
634 {
636 }
637 catch (dunedaq::conffwk::Generic & ex)
638 {
639 throw(dunedaq::conffwk::Generic( ERS_HERE, "prefetch all data failed", ex));
640 }
641}

◆ print()

void dunedaq::Configuration::print ( std::ostream & s) const
noexcept

Prints out details of configuration object.

For the moment only inheritance hierarchy of configuration database is printed. In future it is planned to add more details, such as:

  • conffwk objects
  • status of template cache
  • profiling info

Definition at line 1838 of file Configuration.cpp.

1839{
1840 s << "Configuration object:\n Inheritance Hierarchy (class - all it's superclasses):\n";
1841
1842 for (const auto &i : p_superclasses)
1843 {
1844 s << " * \'" << *i.first << "\' - ";
1845 if (i.second.empty())
1846 s << "(null)";
1847 else
1848 for (auto j = i.second.begin(); j != i.second.end(); ++j)
1849 {
1850 if (j != i.second.begin())
1851 s << ", ";
1852 s << '\'' << **j << '\'';
1853 }
1854 s << std::endl;
1855 }
1856}
conffwk::fmap< conffwk::fset > p_superclasses

◆ print_profiling_info()

void dunedaq::Configuration::print_profiling_info ( )
noexcept

Print out profiling information.

The method prints out to the standard output stream profiling information of configuration object and it's implementation.

Definition at line 183 of file Configuration.cpp.

184{
185 std::lock_guard < std::mutex > scoped_lock(m_impl_mutex);
186
187 std::cout << "Configuration profiler report:\n"
188 " number of created template objects: " << p_number_of_template_object_created << "\n"
189 " number of read template objects: " << p_number_of_template_object_read << "\n"
190 " number of cache hits: " << p_number_of_cache_hits << std::endl;
191
192 // FIXME: re-implement for the dal registry
193 // const char * s = ::getenv("TDAQ_DUMP_CONFFWK_PROFILER_INFO");
194 // if (s && !strcmp(s, "DEBUG"))
195 // {
196 // std::cout << " Details of accessed objects:\n";
197
198 // for (auto & i : m_cache_map)
199 // {
200 // Cache<DalObject> *c = static_cast<Cache<DalObject>*>(i.second);
201 // std::cout << " *** " << c->m_cache.size() << " objects is class \'" << *i.first << "\' were accessed ***\n";
202 // for (auto & j : c->m_cache)
203 // std::cout << " - object \'" << j.first << '\'' << std::endl;
204 // }
205 // }
206
207 if (m_impl)
208 {
211 }
212}
virtual void print_profiling_info() noexcept=0
Print implementation specific profiling information.
void print_cache_info() noexcept
Print profiling information about objects in cache.

◆ ref() [1/2]

template<class T >
const T * dunedaq::conffwk::Configuration::ref ( ConfigObject & obj,
const std::string & name,
bool init = false )
inline

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.

Parameters
objobject
namename of the relationship
initif true, the object and it's referenced objects are initialized
Returns
Return non-null pointer to object of user class in case if relationship with such name exists and it's value is set. Otherwise the method returns 0.
Exceptions
dunedaq::conffwk::Genericin case of a problem (e.g. no relationship with such name, plug-in specific problem)

Definition at line 861 of file Configuration.hpp.

861 {
862 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
863 return _ref<T>(obj, name, init);
864 }
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...

◆ ref() [2/2]

template<class T >
void dunedaq::conffwk::Configuration::ref ( ConfigObject & obj,
const std::string & name,
std::vector< const T * > & objects,
bool init = false )
inline

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.

Parameters
objobject
namename of the relationship
objectsreturned value
initif true, the objects and their referenced objects are initialized
Exceptions
dunedaq::conffwk::Genericin case of a problem (e.g. no relationship with such name, plug-in specific problem)

Definition at line 881 of file Configuration.hpp.

881 {
882 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
883 _ref<T>(obj, name, objects, init);
884 }

◆ referenced_by() [1/2]

std::vector< const DalObject * > dunedaq::conffwk::Configuration::referenced_by ( const DalObject & obj,
const std::string & relationship_name = "*",
bool check_composite_only = true,
bool upcast_unregistered = true,
bool init = false,
unsigned long rlevel = 0,
const std::vector< std::string > * rclasses = nullptr )

Get DAL objects holding references on this object via given relationship (multi-thread safe).

The method returns vector of DalObject, which have references on given object via explicitly provided relationship name. If the relationship name is set to "*", then the method takes into account all relationships of all objects.

It is expected that the DAL for returned objects is generated and linked with user code. If this is not the case, then an exception will be thrown. The parameter upcast_unregistered allows to select one of the registered base classes instead. Note, this will be a random base class, not the closest based one.

The method is efficient only for composite relationships (i.e. when a parent has composite reference on this object). For generic relationships the method performs full scan of all database objects. It is not recommended at large scale to build complete graph of relations between all database object.

Parameters
objobject
relationship_namename of the relationship, via which the object is referenced
upcast_unregisteredif true, try to upcast objects of classes which DAL classes are not loaded; otherwise throw exception if such DAL class is not registered
check_composite_onlyonly returned composite parent objects
initif true, the returned objects and their referenced objects are initialized
rleveloptional references level to optimize performance (defines how many objects referenced by found objects have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Returns
objects referencing given one
Exceptions
dunedaq::conffwk::Genericin case of an error

◆ referenced_by() [2/2]

template<class T , class V >
void dunedaq::conffwk::Configuration::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).

The method returns objects of class V, which have references on given object via explicitly provided relationship name. If the relationship name is set to "*", then the method takes into account all relationships of all objects. The method is efficient only for composite relationships (i.e. when a parent has composite reference on this object). For generic relationships the method performs full scan of all database objects. It is not recommended at large scale to build complete graph of relations between all database object.

Parameters
objobject
objectsreturned value
relationship_namename of the relationship, via which the object is referenced
check_composite_onlyonly returned composite parent objects
initif true, the returned objects and their referenced objects are initialized
rleveloptional references level to optimize performance (defines how many objects referenced by found objects have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 140 of file Configuration.hxx.

141 {
142 std::vector<ConfigObject> objs;
143
144 results.clear();
145
146 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
147
148 try
149 {
150 obj.p_obj.referenced_by(objs, relationship_name, check_composite_only, rlevel, rclasses);
151
152 for (auto& i : objs)
153 {
154 if (try_cast(V::s_class_name, i.class_name()) == true)
155 {
156 // if (const V * o = get_cache<V>()->get(*this, i, init, init))
157 if (const V * o = m_registry.get<V>(i, init, init))
158 {
159 results.push_back(o);
160 }
161 }
162 }
163 }
164 catch (dunedaq::conffwk::Generic & ex)
165 {
166 throw(dunedaq::conffwk::Generic( ERS_HERE, mk_ref_by_ex_text(V::s_class_name, relationship_name, obj.p_obj).c_str(), ex ) );
167 }
168 }
static std::string mk_ref_by_ex_text(const std::string &cname, const std::string &rname, const ConfigObject &obj) noexcept
bool try_cast(const std::string &target, const std::string &source) noexcept
Checks if cast from source class to target class is allowed.

◆ register_converter()

template<class T >
void dunedaq::conffwk::Configuration::register_converter ( AttributeConverter< T > * object)
noexcept

Register user function for attribute conversion.

The user can register several objects which are used for attribute values conversion. The attributes conversion type is defined by the template parameter, e.g. given object to be used for string attribute values conversion, another object to be used for short unsigned integers, etc. It is possible to define several converters for each type. There is no check that given object was already registered or not. It is registered several times, the conversion will be done several times.

Parameters
objectthe converter object

Definition at line 372 of file Configuration.hxx.

373 {
374 std::lock_guard<std::mutex> scoped_lock(m_else_mutex);
375
376 std::list<AttributeConverterBase*> * c = m_convert_map[typeid(T).name()];
377 if (c == 0)
378 {
379 c = m_convert_map[typeid(T).name()] = new std::list<AttributeConverterBase*>();
380 }
381
382 c->push_back(object);
383 }

◆ relations_pybind()

std::unordered_map< std::string, std::unordered_map< std::string, std::string > > dunedaq::Configuration::relations_pybind ( const std::string & class_name,
bool all )

Definition at line 2071 of file Configuration.cpp.

2071 {
2072
2073 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> all_relationships_properties;
2074
2075 const dunedaq::conffwk::class_t& c = this->get_class_info(class_name, !all);
2076
2077 for (const auto& rp : c.p_relationships) {
2078 std::unordered_map<std::string, std::string> relationship_properties;
2079
2080 relationship_properties["type"] = rp.p_type;
2081 relationship_properties["description"] = rp.p_description;
2082 relationship_properties["multivalue"] = (rp.p_cardinality == dunedaq::conffwk::zero_or_many || rp.p_cardinality == dunedaq::conffwk::one_or_many) ? "True" : "False";
2083 relationship_properties["aggregation"] = rp.p_is_aggregation ? "True" : "False";
2084 relationship_properties["not-null"] = (rp.p_cardinality == dunedaq::conffwk::only_one || rp.p_cardinality == dunedaq::conffwk::one_or_many) ? "True" : "False";
2085
2086 all_relationships_properties[rp.p_name] = relationship_properties;
2087 }
2088
2089 return all_relationships_properties;
2090}

◆ remove_action()

void dunedaq::Configuration::remove_action ( ConfigAction * ac)

Remove global action performed by user code on db [un]load and updates.

Definition at line 73 of file Configuration.cpp.

74{
75 std::lock_guard<std::mutex> scoped_lock(m_actn_mutex);
76 m_actions.remove(ac);
77}

◆ remove_include()

void dunedaq::Configuration::remove_include ( const std::string & db_name,
const std::string & include )

Remove include file.

The method removes existing include file from the database.

Parameters
db_namename of database file from which the include to be removed
includefile to be removed from includes
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 497 of file Configuration.cpp.

498{
499 if (m_impl == nullptr)
500 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
501
502 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
503 std::lock_guard<std::mutex> scoped_lock2(m_tmpl_mutex);
504
505 try
506 {
507 m_impl->remove_include(db_name, include);
508 // m_impl->get_superclasses(p_superclasses);
509 // set_subclasses();
511 }
512 catch(dunedaq::conffwk::Generic & ex)
513 {
514 std::ostringstream text;
515 text << "failed to remove include \'" << include << "\' from database \'" << db_name<< '\'';
516 throw ( dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex ) );
517 }
518}
virtual void remove_include(const std::string &db_name, const std::string &include)=0
Remove include file.

◆ rename_object()

void dunedaq::Configuration::rename_object ( ConfigObject & obj,
const std::string & new_id )
private

Cache of template object of given type.

The class defines the cache of template objects of given type. The objects are stored in cache, where the key is object-ID and the value is a pointer on template object.

The access to cache and objects insertion are provided via two get() methods:

  • T * get(Configuration&, ConfigObject&, bool, bool) - get template object for given conffwk object
  • T * get(Configuration&, const std::string&, bool, bool, unsigned long, const std::vector<std::string> *) - get template object for given object ID
    \brief 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.

Parameters
conffwkthe configuration object
objthe conffwk object used to set for the template object
init_childrenif true, the referenced objects are initialized (only applicable during creation of new object)
init_objectif true, the object's attributes and relationships are read(only applicable during creation of new object)
Returns
Return pointer to object.
Exceptions
dunedaq::conffwk::Genericis no such class for loaded configuration DB schema or in case of an error

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.

Parameters
conffwkthe configuration object
nameobject identity
init_childrenif true, the referenced objects are initialized (only applicable during creation of new object)
init_objectif true, the object's attributes and relationships are read(only applicable during creation of new object)
rleveloptional 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)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache during creation of new object)
Returns
Return pointer to object. It can be null, if there is no such object found.
Exceptions
dunedaq::conffwk::Genericis no such class for loaded configuration DB schema or in case of an error

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.

Parameters
idID of generated object
Returns
Return pointer to object.
Exceptions
dunedaq::conffwk::Genericis no such class for loaded configuration DB schema or in case of an error

Generate template object using conffwk object and ID.

The method searches an object with id of given conffwk object within the cache using given ID. 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.

Parameters
conffwkthe configuration object
objthe conffwk object used to set for the template object
idID of generated object
Returns
Return pointer to object.
Exceptions
dunedaq::conffwk::Genericis no such class for loaded configuration DB schema or in case of an error

Definition at line 842 of file Configuration.cpp.

843{
844 std::lock_guard<std::mutex> scoped_impl_lock(m_tmpl_mutex); // always lock template objects mutex first
845 std::lock_guard<std::mutex> scoped_tmpl_lock(m_impl_mutex);
846
847 std::lock_guard<std::mutex> scoped_obj_lock(obj.m_impl->m_mutex);
848
849 const std::string old_id(obj.m_impl->m_id);
850
851 obj.m_impl->throw_if_deleted();
852 obj.m_impl->rename(new_id);
853 obj.m_impl->m_id = new_id;
854 m_impl->rename_impl_object(obj.m_impl->m_class_name, old_id, new_id);
855
856 TLOG_DEBUG(3) << " * call rename \'" << old_id << "\' to \'" << new_id << "\' in class \'" << obj.class_name() << "\')";
857
858 m_registry._rename_object(obj.class_name(), old_id, new_id);
859
860 // conffwk::fmap<CacheBase*>::iterator j = m_cache_map.find(&obj.class_name());
861 // if (j != m_cache_map.end())
862 // j->second->m_functions.m_rename_object_fn(j->second, old_id, new_id);
863
864 // conffwk::fmap<conffwk::fset>::const_iterator sc = p_superclasses.find(&obj.class_name());
865
866 // if (sc != p_superclasses.end())
867 // for (conffwk::fset::const_iterator c = sc->second.begin(); c != sc->second.end(); ++c)
868 // {
869 // conffwk::fmap<CacheBase*>::iterator j = m_cache_map.find(*c);
870
871 // if (j != m_cache_map.end())
872 // j->second->m_functions.m_rename_object_fn(j->second, old_id, new_id);
873 // }
874}
void rename_impl_object(const std::string *class_name, const std::string &old_id, const std::string &new_id) noexcept
rename object in cache
void _rename_object(std::string class_name, std::string old_id, std::string new_id)
Rename object of given template class (multi-thread unsafe).

◆ reset_subscription()

void dunedaq::Configuration::reset_subscription ( )
private
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 1359 of file Configuration.cpp.

1360{
1361 // check that there is no at least one subscription
1362 // if NO, then unsubscribe
1363
1364 if (m_callbacks.empty())
1365 {
1367 return;
1368 }
1369
1370 // prepare subscription criteria
1371
1373 std::set<std::string> class_subscriptions;
1374
1375 // among existing subscriptions find one who has all subscriptions
1376
1377 bool found_subscribe_all = false;
1378
1379 for (const auto &i : m_callbacks)
1380 if (i->m_criteria.get_classes_subscription().empty() && i->m_criteria.get_objects_subscription().empty())
1381 {
1382 found_subscribe_all = true;
1383 break;
1384 }
1385
1386 if (found_subscribe_all == false)
1387 {
1388 // build list of all classes for which there is a subscription
1389 for (const auto &i : m_callbacks)
1390 for (const auto &j : i->m_criteria.get_classes_subscription())
1391 class_subscriptions.insert(j);
1392
1393 // build list of all objects for which there is a subscription (if there is no such class)
1394 for (const auto &i : m_callbacks)
1395 for (const auto &j : i->m_criteria.get_objects_subscription())
1396 {
1397 const std::string &obj_class_name = j.first;
1398 if (class_subscriptions.find(obj_class_name) == class_subscriptions.end())
1399 for (const auto &k : j.second)
1400 obj_subscriptions[obj_class_name].insert(k);
1401 }
1402 }
1403
1404 m_impl->subscribe(class_subscriptions, obj_subscriptions, system_cb, system_pre_cb);
1405}
virtual void subscribe(const std::set< std::string > &class_names, const std::map< std::string, std::set< std::string > > &objs, notify cb, pre_notify pre_cb)=0
Subscribe on database changes.
virtual void unsubscribe()=0
Remove subscription on database changes.
std::map< std::string, std::set< std::string > > ObjectMap
The map stores full subsription information.
static void system_cb(std::vector< ConfigurationChange * > &, Configuration *) noexcept
System callback function invoked in case of modifications.
static void system_pre_cb(Configuration *) noexcept
System callback function invoked in case of pre-modifications.

◆ return_includes_pybind()

std::list< std::string > * dunedaq::Configuration::return_includes_pybind ( const std::string & db_name)

Definition at line 2093 of file Configuration.cpp.

2093 {
2094 auto l = new std::list<std::string>;
2095 this->get_includes(db_name, *l);
2096 return l;
2097}
void get_includes(const std::string &db_name, std::list< std::string > &includes) const
Get include files.

◆ set_class_domain_map()

void dunedaq::Configuration::set_class_domain_map ( )
private

Definition at line 752 of file Configuration.cpp.

752 {
753
754 p_class_domain_map.clear();
755
756 auto domains = this->find_class_domains();
757 for( size_t i(0); i<domains.size(); ++i ) {
758 const auto& dom = domains[i];
759 for( const auto& class_name : dom ) {
760 p_class_domain_map[&conffwk::DalFactory::instance().get_known_class_name_ref(class_name)] = i;
761 }
762 }
763}
std::deque< std::set< std::string > > find_class_domains()
conffwk::fmap< uint > p_class_domain_map

◆ set_commit_credentials()

void dunedaq::Configuration::set_commit_credentials ( const std::string & user,
const std::string & password )

Set commit credentials.

The method sets credentials used by commit method.

Parameters
useruser name
passworduser password
Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 561 of file Configuration.cpp.

562{
563 if (m_impl == nullptr)
564 throw dunedaq::conffwk::Generic( ERS_HERE, "no implementation loaded" );
565
566 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
567
568 try
569 {
570 m_impl->set_commit_credentials(user, password);
571 }
572 catch(dunedaq::conffwk::Generic & ex)
573 {
574 throw ( dunedaq::conffwk::Generic( ERS_HERE, "set_commit_credentials failed", ex ) );
575 }
576}
virtual void set_commit_credentials(const std::string &user, const std::string &password)=0
Set commit credentials.

◆ set_subclasses()

void dunedaq::Configuration::set_subclasses ( )
privatenoexcept

Definition at line 681 of file Configuration.cpp.

682{
683 p_subclasses.clear();
684
685 for (const auto &i : p_superclasses)
686 for (const auto &j : i.second)
687 p_subclasses[j].insert(i.first);
688}
conffwk::fmap< conffwk::fset > p_subclasses

◆ subclasses()

const conffwk::fmap< conffwk::fset > & dunedaq::conffwk::Configuration::subclasses ( ) const
inline

Get names of subclasses for each class

Definition at line 1450 of file Configuration.hpp.

1450{return p_subclasses;}

◆ subclasses_pybind()

std::vector< std::string > dunedaq::Configuration::subclasses_pybind ( const std::string & class_name,
bool all )

Definition at line 2100 of file Configuration.cpp.

2100 {
2101
2102 const dunedaq::conffwk::class_t& c = this->get_class_info(class_name, !all);
2103 return c.p_subclasses;
2104}

◆ subscribe() [1/2]

CallbackId dunedaq::conffwk::Configuration::subscribe ( const ConfigurationSubscriptionCriteria & criteria,
notify user_cb,
void * user_param = nullptr )

Subscribe on configuration changes.

The method is used to make a subscription. The returned value is a subscription handler.

When subscribed changes occurred, the user callback function is invoked with changes description and parameter 'user_param' defined by user.

Parameters
criteriasubscription criteria
user_cbuser-defined callback function
user_paramoptional user-defined parameter
Returns
non-null value in case of success (the value to be used for unsubscribe() method).
Exceptions
dunedaq::conffwk::Genericin case of an error

◆ subscribe() [2/2]

CallbackId dunedaq::conffwk::Configuration::subscribe ( pre_notify user_cb,
void * user_param = nullptr )

Subscribe on pre-notification on configuration changes.

The method is used to make complimentary subscription on pre-notification about changes, that can only be used together with real subscription on changes, i.e. using subscribe(const ConfigurationSubscriptionCriteria&, notify, void *) method.

When subscribed changes occurred, but before they are going to be applied, the user callback function is invoked with parameter 'user_param' defined by user. This subscription can be used to be informed, that some changes are took place already and will be applied immediately after user's code exits given callback function.

Parameters
user_cbuser-defined callback function
user_paramoptional user-defined parameter
Returns
non-null value in case of success (the value to be used for unsubscribe() method).
Exceptions
dunedaq::conffwk::Genericin case of an error

◆ superclasses()

const conffwk::fmap< conffwk::fset > & dunedaq::conffwk::Configuration::superclasses ( ) const
inlinenoexcept

Get names of superclasses for each class

Definition at line 1445 of file Configuration.hpp.

1445{return p_superclasses;}

◆ superclasses_pybind()

std::vector< std::string > dunedaq::Configuration::superclasses_pybind ( const std::string & class_name,
bool all )

Definition at line 2107 of file Configuration.cpp.

2107 {
2108
2109 const dunedaq::conffwk::class_t& c = this->get_class_info(class_name, !all);
2110 return c.p_superclasses;
2111}

◆ system_cb()

void dunedaq::Configuration::system_cb ( std::vector< ConfigurationChange * > & changes,
Configuration * conf )
staticnoexcept

System callback function invoked in case of modifications.

It is used by the database implementation. Only is called, when a user subscription to related class is set.

Definition at line 1574 of file Configuration.cpp.

1575{
1576
1577 TLOG_DEBUG(3) <<
1578 "*** Enter Configuration::system_cb()\n"
1579 "*** Number of user subscriptions: " << conf->m_callbacks.size()
1580 ;
1581
1582 // call conffwk actions if any
1583 {
1584 std::lock_guard<std::mutex> scoped_lock(conf->m_impl_mutex);
1585 std::lock_guard<std::mutex> scoped_lock2(conf->m_actn_mutex);
1586 for (auto & i : conf->m_actions)
1587 i->notify(changes);
1588 }
1589
1590
1591 // update template objects in cache
1592 {
1593 std::lock_guard<std::mutex> scoped_lock(conf->m_tmpl_mutex); // always lock template objects mutex first
1594 std::lock_guard<std::mutex> scoped_lock2(conf->m_impl_mutex);
1595 conf->update_cache(changes);
1596 }
1597
1598
1599 // user removed all subscriptions
1600 if(conf->m_callbacks.empty()) return;
1601
1602 // note, one cannot lock m_tmpl_mutex or m_impl_mutex here,
1603 // since user callback may call arbitrary get() methods to access conffwk
1604 // and template objects locking above two mutexes
1605 std::lock_guard<std::mutex> scoped_lock(conf->m_else_mutex);
1606
1607 // check if there is only one subscription
1608 if (conf->m_callbacks.size() == 1)
1609 {
1610 auto j = *conf->m_callbacks.begin();
1611 (*(j->m_cb))(changes, j->m_param);
1612 }
1613 // may need to calculate the changes for each subscription
1614 else
1615 {
1616 for (const auto &j : conf->m_callbacks)
1617 {
1618
1619 if (ers::debug_level() >= 3)
1620 {
1621 std::ostringstream text;
1622
1623 text <<
1624 "*** Process subscription " << (void*) j << "\n"
1625 " class subscription done for " << j->m_criteria.get_classes_subscription().size() << " classes:\n";
1626
1627 for (const auto &i1 : j->m_criteria.get_classes_subscription())
1628 text << " * class \"" << i1 << "\"\n";
1629
1630 text << " object subscription done in " << j->m_criteria.get_objects_subscription().size() << " classes:\n";
1631
1632 for (const auto &i2 : j->m_criteria.get_objects_subscription())
1633 {
1634 text << " * class \"" << (i2.first) << "\":\n";
1635 for (const auto &i3 : i2.second)
1636 text << " - \"" << i3 << "\"\n";
1637 }
1638
1639 TLOG_DEBUG(3) << text.str();
1640 }
1641
1642 if (j->m_criteria.get_classes_subscription().empty() && j->m_criteria.get_objects_subscription().empty())
1643 {
1644 try
1645 {
1646 TLOG_DEBUG(3) << "*** Invoke callback " << (void *)j << " with\n" << changes;
1647 (*(j->m_cb))(changes, j->m_param);
1648 }
1649 catch (const ers::Issue &ex)
1650 {
1651 ers::error(dunedaq::conffwk::Generic( ERS_HERE, "user callback thrown ers exception", ex));
1652 }
1653 catch (const std::exception &ex)
1654 {
1655 ers::error(dunedaq::conffwk::Generic( ERS_HERE, "user callback thrown std exception", ex));
1656 }
1657 catch (...)
1658 {
1659 ers::error(dunedaq::conffwk::Generic( ERS_HERE, "user callback thrown unknown exception"));
1660 }
1661 }
1662 else
1663 {
1664 std::vector<ConfigurationChange*> changes1;
1665
1666 for (const auto &i : changes)
1667 {
1668 const std::string &cname = i->get_class_name();
1669 ConfigurationChange *class_changes = nullptr;
1670
1671 ConfigurationSubscriptionCriteria::ObjectMap::const_iterator p = j->m_criteria.get_objects_subscription().find(cname);
1672 const bool found_obj_subscription(p != j->m_criteria.get_objects_subscription().end());
1673 const bool found_class_subscription(j->m_criteria.get_classes_subscription().find(cname) != j->m_criteria.get_classes_subscription().end());
1674
1675 if (found_class_subscription || found_obj_subscription)
1676 class_changes = new ConfigurationChange(cname);
1677
1678 if (found_class_subscription)
1679 {
1680 for (const auto &k : i->m_modified)
1681 class_changes->m_modified.push_back(k);
1682
1683 for (const auto &k : i->m_created)
1684 class_changes->m_created.push_back(k);
1685
1686 for (const auto &k : i->m_removed)
1687 class_changes->m_removed.push_back(k);
1688 }
1689
1690 if (found_obj_subscription)
1691 {
1692 for (const auto &obj_id : i->m_modified)
1693 if (p->second.find(obj_id) != p->second.end())
1694 class_changes->m_modified.push_back(obj_id);
1695
1696 for (const auto &obj_id : i->m_removed)
1697 if (p->second.find(obj_id) != p->second.end())
1698 class_changes->m_removed.push_back(obj_id);
1699 }
1700
1701 // the changes for given class can be empty if there is subscription on objects of given class, but no such objects were modified
1702 if (class_changes)
1703 {
1704 if (class_changes->m_modified.empty() && class_changes->m_created.empty() && class_changes->m_removed.empty())
1705 delete class_changes;
1706 else
1707 changes1.push_back(class_changes);
1708 }
1709 }
1710
1711 if (!changes1.empty())
1712 {
1713 TLOG_DEBUG(3) << "*** Invoke callback " << (void *)j << " with\n" << changes1;
1714
1715 try
1716 {
1717 (*(j->m_cb))(changes1, j->m_param);
1718 }
1719 catch (const ers::Issue &ex)
1720 {
1721 ers::error(dunedaq::conffwk::Generic( ERS_HERE, "user callback thrown ers exception", ex));
1722 }
1723 catch (const std::exception &ex)
1724 {
1725 ers::error(dunedaq::conffwk::Generic( ERS_HERE, "user callback thrown std exception", ex));
1726 }
1727 catch (...)
1728 {
1729 ers::error(dunedaq::conffwk::Generic( ERS_HERE, "user callback thrown unknown exception"));
1730 }
1731
1732 for (const auto &i : changes1)
1733 delete i;
1734 }
1735 }
1736 }
1737 }
1738
1739 TLOG_DEBUG(3) <<"*** Leave Configuration::system_cb()";
1740}
Base class for any user define issue.
Definition Issue.hpp:69
int debug_level()
Definition ers.hpp:66

◆ system_pre_cb()

void dunedaq::Configuration::system_pre_cb ( Configuration * conf)
staticnoexcept

System callback function invoked in case of pre-modifications.

It is used by the database implementation. Only is called, when a user subscription is set.

Definition at line 1744 of file Configuration.cpp.

1745{
1746 TLOG_DEBUG(3) <<"*** Enter Configuration::system_pre_cb()";
1747
1748 std::lock_guard<std::mutex> scoped_lock(conf->m_else_mutex);
1749
1750 for(auto& j : conf->m_pre_callbacks)
1751 {
1752 TLOG_DEBUG(3) << "*** Invoke callback " << (void *)(j);
1753 (*(j->m_cb))(j->m_param);
1754 }
1755
1756 TLOG_DEBUG(3) <<"*** Leave Configuration::system_pre_cb()";
1757}

◆ test_object()

bool dunedaq::Configuration::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.

The method searches an object with given id within the class and all derived subclasses. If found, the method returns true, otherwise the method return false.

Parameters
class_namename of the class
idobject identity
rleveloptional references level to optimize performance (defines how many objects referenced by given object have also to be read to the implementation cache)
rclassesoptional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache)
Exceptions
dunedaq::conffwk::Genericif there is no such class or in case of an error

Definition at line 775 of file Configuration.cpp.

776{
777 try
778 {
779 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
780 return m_impl->test_object(class_name, id, rlevel, rclasses);
781 }
782 catch (dunedaq::conffwk::Generic& ex)
783 {
784 std::ostringstream text;
785 text << "failed to test existence of object \'" << id << '@' << class_name << '\'';
786 throw dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str(), ex );
787 }
788}
virtual bool test_object(const std::string &class_name, const std::string &id, unsigned long rlevel, const std::vector< std::string > *rclasses)=0
Test object existence (used by Python binding)

◆ try_cast() [1/2]

bool dunedaq::Configuration::try_cast ( const std::string & target,
const std::string & source )
noexcept

Checks if cast from source class to target class is allowed.

Parameters
targetname of desired class (e.g. try to cast object of "source" class to this "target" one)
sourcename of casted object class
Returns
Return true if the cast is allowed by database schema

Definition at line 1860 of file Configuration.cpp.

1861{
1862 return is_superclass_of(target, source);
1863}
bool is_superclass_of(const std::string &target, const std::string &source) noexcept

◆ try_cast() [2/2]

bool dunedaq::Configuration::try_cast ( const std::string * target,
const std::string * source )
noexcept

Definition at line 1866 of file Configuration.cpp.

1867{
1868 return is_superclass_of(target, source);
1869}

◆ unload()

void dunedaq::Configuration::unload ( )

Unload database.

The database should be previously loaded. The method destroys all user objects from cache (i.e. created via conffwk and template get methods) and frees all DB resources allocated by the implementation plug-in.

Exceptions
dunedaq::conffwk::Genericin case of an error

Definition at line 368 of file Configuration.cpp.

369{
370 if (m_impl == nullptr)
371 throw dunedaq::conffwk::Generic( ERS_HERE, "nothing to unload" );
372
373 std::lock_guard<std::mutex> scoped_lock1(m_tmpl_mutex); // always lock template objects mutex first
374 std::lock_guard<std::mutex> scoped_lock2(m_impl_mutex);
375
376 // call conffwk actions if any
377 {
378 std::lock_guard<std::mutex> scoped_lock(m_actn_mutex);
379 for(auto & i : m_actions)
380 {
381 i->unload();
382 }
383 }
384
385 // for (auto& i : m_cache_map) {
386 // delete i.second;
387 // }
388
389 // m_cache_map.clear();
391
392 {
393 std::lock_guard<std::mutex> scoped_lock3(m_else_mutex);
394
395 for (auto& cb : m_callbacks)
396 delete cb;
397
398 for (auto& cb : m_pre_callbacks)
399 delete cb;
400
401 m_callbacks.clear();
402 m_pre_callbacks.clear();
403
405
406 for (auto& l : m_convert_map) {
407 for (auto& a : *l.second)
408 delete a;
409
410 delete l.second;
411 }
412
413 m_convert_map.clear();
414 }
415
416 p_superclasses.clear();
417
418 for(auto& j : p_direct_classes_desc_cache)
419 delete j.second;
420
421 for(auto& j : p_all_classes_desc_cache)
422 delete j.second;
423
426
427 m_impl->close_db();
428}
virtual void close_db()=0
Close database implementation.
void clear()
Clear the content of the registy.

◆ unread_all_objects()

void dunedaq::Configuration::unread_all_objects ( bool unread_implementation_objs = false)
noexcept

Mark object of given template class as unread (multi-thread unsafe).

Is used by automatically generated data access libraries code after reading parameters for substitution, since cache contains objects with non-substituted attributes. Should not be explicitly used by user.

The method is used by the unread_all_objects() method.

Parameters
cache_ptrpointer to the cache of template object of given template class (has to be downcasted)

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.

Parameters
cache_ptrpointer to the cache of template object of given template class (has to be downcasted)
old_idold object ID
new_idnew object ID

Update state of all objects in cache after abort / commit operations.

It is used by automatically generated data access libraries.

Unread all template (i.e. set their state as uninitialized) and implementation objects (i.e. clear their cache).

Unread template objects result changing their state to uninitialized. They will be re-initialized, when accessed by user code. This feature is used by attribute converter methods using unread_all_objects().

Unread implementation objects result removing any information from implementation cache, e.g. clear any object attributes data read from server. One may use the unread_all_objects() to re-read database after reload.

Parameters
unread_implementation_objsif true, clear implementation objects; otherwise only template objects are unread and the implementation conffwk objects are still valid.

Definition at line 644 of file Configuration.cpp.

645{
646 if (unread_implementation_objs)
648
650}
void unread_template_objects() noexcept
Unread all template (i.e. set their state as uninitialized) objects.
void unread_implementation_objects(dunedaq::conffwk::ObjectState state) noexcept
Unread implementation objects (i.e. clear their cache).

◆ unread_implementation_objects()

void dunedaq::conffwk::Configuration::unread_implementation_objects ( dunedaq::conffwk::ObjectState state)
inlinenoexcept

Unread implementation objects (i.e. clear their cache).

This results removing any information from implementation cache, e.g. clear any object attributes data read from server.

Parameters
stateset state of implementation objects after unread; is set to "Unknown" after abort()

Definition at line 543 of file Configuration.hpp.

544 {
545 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
547 }

◆ unread_template_objects()

void dunedaq::conffwk::Configuration::unread_template_objects ( )
inlinenoexcept

Unread all template (i.e. set their state as uninitialized) objects.

Unread template objects result changing their state to uninitialized. They will be re-initialized, when accessed by user code. This feature is used by attribute converter methods using unread_all_objects().

Definition at line 527 of file Configuration.hpp.

528 {
529 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
531 }

◆ unsubscribe()

void dunedaq::Configuration::unsubscribe ( CallbackId cb_handler = 0)

Remove callback function.

Remove callback function previously added by the subscribe() methods. If the parameter is a non-null value, it must be equal to id returned by the add_callback() method. Otherwise the method stops all subscription.

Exceptions
dunedaq::conffwk::Genericin case of an error (e.g. bad ID, plugin-specific problems)

Definition at line 1310 of file Configuration.cpp.

1311{
1312 std::lock_guard < std::mutex > scoped_lock(m_else_mutex);
1313
1314 if (id)
1315 {
1316 CallbackSet::iterator i = m_callbacks.find(id);
1317 PreCallbackSet::iterator j = m_pre_callbacks.find(reinterpret_cast<CallbackPreSubscription *>(id));
1318
1319 if (i != m_callbacks.end())
1320 {
1321 delete id;
1322 m_callbacks.erase(i);
1323 }
1324 else if (j != m_pre_callbacks.end())
1325 {
1326 delete reinterpret_cast<CallbackPreSubscription *>(id);
1327 m_pre_callbacks.erase(j);
1328 }
1329 else
1330 {
1331 std::ostringstream text;
1332 text << "unsubscription failed for CallbackId = " << (void *) id << " (no such callback id found)";
1333 throw(dunedaq::conffwk::Generic( ERS_HERE, text.str().c_str() ) );
1334 }
1335 }
1336 else
1337 {
1338 for (auto &i : m_callbacks)
1339 delete i;
1340
1341 for (auto &i : m_pre_callbacks)
1342 delete i;
1343
1344 m_callbacks.clear();
1345 m_pre_callbacks.clear();
1346 }
1347
1348 try
1349 {
1351 }
1352 catch (dunedaq::conffwk::Generic& ex)
1353 {
1354 throw dunedaq::conffwk::Generic( ERS_HERE, "unsubscription failed", ex );
1355 }
1356}

◆ update()

template<class T >
void dunedaq::conffwk::Configuration::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.

Only is called, when a user subscription to related class is set. It is used by automatically generated data access libraries.

Parameters
modifiedvector of modified objects of given user class (objects to be re-read in cache)
removedvector of removed objects of given user class (objects to be removed from cache)
createdvector of created objects of given user class (objects to be reset in cache, if they were removed)

Definition at line 299 of file Configuration.hxx.

302 {
303 // auto j = m_cache_map.find(&T::s_class_name);
304
305 // TLOG_DEBUG(4) << "call for class \'" << T::s_class_name << '\'';
306
307 // if (j != m_cache_map.end())
308 // {
309 // Cache<T> *c = static_cast<Cache<T>*>(j->second);
310 // set_cache_unread(removed, *c);
311 // set_cache_unread(created, *c);
312 // set_cache_unread(modified, *c);
313 // }
314 m_registry.update<T>(modified, removed, created);
315 }
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.

◆ update_cache()

void dunedaq::Configuration::update_cache ( std::vector< ConfigurationChange * > & changes)
noexcept

System function invoked in case of modifications.

It is used by the database implementation. Update cache of template DB objects.

Definition at line 1481 of file Configuration.cpp.

1482{
1483 TLOG_DEBUG(3) << "*** Enter Configuration::update_cache() with changes:\n" << changes;
1484
1485 // Remove deleted and update modified implementation objects first
1486 for (const auto& i : changes)
1487 {
1488 const std::string * class_name = &DalFactory::instance().get_known_class_name_ref(i->get_class_name());
1489
1490 update_impl_objects(m_impl->m_impl_objects, *i, class_name);
1491
1492 // delete/update implementation objects defined in superclasses
1493 conffwk::fmap<conffwk::fset>::const_iterator sc = p_superclasses.find(class_name);
1494
1495 if (sc != p_superclasses.end())
1496 for (const auto &c : sc->second)
1498
1499 // delete/update implementation objects defined in subclasses
1500 sc = p_subclasses.find(class_name);
1501
1502 if (sc != p_subclasses.end())
1503 for (const auto &c : sc->second)
1505 }
1506
1507 for (const auto& i : changes)
1508 {
1509
1510 m_registry.update(i->get_class_name(), i->get_modified_objs(), i->get_removed_objs(), i->get_created_objs());
1511
1512 // const std::string * class_name = &DalFactory::instance().get_known_class_name_ref(i->get_class_name()); // FIXME: optimise with above
1513
1514 // // invoke configuration update if there are template objects of given class
1515
1516 // {
1517 // conffwk::fmap<CacheBase*>::iterator j = m_cache_map.find(class_name);
1518
1519 // if (j != m_cache_map.end())
1520 // {
1521 // TLOG_DEBUG(3) << " * call update on \'" << j->first << "\' template objects";
1522 // j->second->m_functions.m_update_fn(*this, i);
1523 // }
1524 // }
1525
1526
1527 // // invoke configuration update if there are template objects in super-classes
1528
1529 // {
1530 // conffwk::fmap<conffwk::fset>::const_iterator sc = p_superclasses.find(class_name);
1531
1532 // if (sc != p_superclasses.end())
1533 // {
1534 // for (const auto& c : sc->second)
1535 // {
1536 // conffwk::fmap<CacheBase*>::iterator j = m_cache_map.find(c);
1537
1538 // if (j != m_cache_map.end())
1539 // {
1540 // TLOG_DEBUG(3) << " * call update on \'" << j->first << "\' template objects (as super-class of \'" << *class_name << "\')";
1541 // j->second->m_functions.m_update_fn(*this, i);
1542 // }
1543 // }
1544 // }
1545 // }
1546
1547
1548 // // invoke configuration update if there are template objects in sub-classes
1549
1550 // {
1551 // conffwk::fmap<conffwk::fset>::const_iterator sc = p_subclasses.find(class_name);
1552
1553 // if (sc != p_subclasses.end())
1554 // {
1555 // for (const auto& c : sc->second)
1556 // {
1557 // conffwk::fmap<CacheBase*>::iterator j = m_cache_map.find(c);
1558
1559 // if (j != m_cache_map.end())
1560 // {
1561 // TLOG_DEBUG(3) << " * call update on \'" << j->first << "\' template objects (as sub-class of \'" << *class_name << "\')";
1562 // j->second->m_functions.m_update_fn(*this, i);
1563 // }
1564 // }
1565 // }
1566 // }
1567
1568 }
1569
1570}
static void update_impl_objects(conffwk::pmap< conffwk::map< ConfigObjectImpl * > * > &cache, ConfigurationChange &change, const std::string *class_name)

◆ update_classes()

void dunedaq::Configuration::update_classes ( )
privatenoexcept

Definition at line 692 of file Configuration.cpp.

693{
695 this->set_subclasses();
696 this->set_class_domain_map();
698}
virtual void get_superclasses(conffwk::fmap< conffwk::fset > &schema)=0
Get inheritance hierarchy.
void update_class_maps()
Update the internal class domains map.

◆ update_impl_objects()

void dunedaq::Configuration::update_impl_objects ( conffwk::pmap< conffwk::map< ConfigObjectImpl * > * > & cache,
ConfigurationChange & change,
const std::string * class_name )
staticprivate

Definition at line 1409 of file Configuration.cpp.

1410{
1411 if (change.get_removed_objs().empty() == false)
1412 {
1413 conffwk::pmap<conffwk::map<ConfigObjectImpl *> *>::iterator i = cache.find(class_name);
1414
1415 if (i != cache.end())
1416 {
1417 for (auto & x : change.get_removed_objs())
1418 {
1419 conffwk::map<ConfigObjectImpl *>::iterator j = i->second->find(x);
1420 if (j != i->second->end())
1421 {
1422 TLOG_DEBUG( 2 ) << "set implementation object " << x << '@' << *class_name << " [" << (void *)j->second << "] deleted";
1423
1424 std::lock_guard<std::mutex> scoped_lock(j->second->m_mutex);
1425 j->second->m_state = dunedaq::conffwk::Deleted;
1426 j->second->clear();
1427 }
1428 }
1429 }
1430 }
1431
1432 if (change.get_created_objs().empty() == false)
1433 {
1434 conffwk::pmap<conffwk::map<ConfigObjectImpl *> *>::iterator i = cache.find(class_name);
1435
1436 if (i != cache.end())
1437 {
1438 for (auto & x : change.get_created_objs())
1439 {
1440 conffwk::map<ConfigObjectImpl *>::iterator j = i->second->find(x);
1441 if (j != i->second->end())
1442 {
1443 TLOG_DEBUG( 2 ) << "re-set created implementation object " << x << '@' << *class_name << " [" << (void *)j->second << ']';
1444
1445 std::lock_guard<std::mutex> scoped_lock(j->second->m_mutex);
1446 j->second->reset(); // it does not matter what the state was, always reset
1447 }
1448 }
1449 }
1450 }
1451
1452 if (change.get_modified_objs().empty() == false)
1453 {
1454 conffwk::pmap<conffwk::map<ConfigObjectImpl *> *>::iterator i = cache.find(class_name);
1455
1456 if (i != cache.end())
1457 {
1458 for (auto & x : change.get_modified_objs())
1459 {
1460 conffwk::map<ConfigObjectImpl *>::iterator j = i->second->find(x);
1461 if (j != i->second->end())
1462 {
1463 TLOG_DEBUG(2) << "clear implementation object " << x << '@' << *class_name << " [" << (void *)j->second << ']';
1464
1465 std::lock_guard<std::mutex> scoped_lock(j->second->m_mutex);
1466
1467 if(j->second->m_state != dunedaq::conffwk::Valid)
1468 j->second->reset();
1469 else
1470 j->second->clear();
1471 }
1472 }
1473 }
1474 }
1475}

Friends And Related Symbol Documentation

◆ ConfigObject

friend class ConfigObject
friend

Definition at line 224 of file Configuration.hpp.

◆ ConfigurationImpl

friend class ConfigurationImpl
friend

Definition at line 225 of file Configuration.hpp.

◆ DalObject

DalObject
friend

Definition at line 223 of file Configuration.hpp.

◆ DalRegistry

friend class DalRegistry
friend

Definition at line 228 of file Configuration.hpp.

Member Data Documentation

◆ m_actions

std::list<ConfigAction *> dunedaq::conffwk::Configuration::m_actions
private

Definition at line 1701 of file Configuration.hpp.

◆ m_actn_mutex

std::mutex dunedaq::conffwk::Configuration::m_actn_mutex
mutableprivate

Definition at line 1710 of file Configuration.hpp.

◆ m_callbacks

CallbackSet dunedaq::conffwk::Configuration::m_callbacks
private

Definition at line 1680 of file Configuration.hpp.

◆ m_convert_map

conffwk::map<std::list<AttributeConverterBase*> * > dunedaq::conffwk::Configuration::m_convert_map
private

Definition at line 1458 of file Configuration.hpp.

◆ m_else_mutex

std::mutex dunedaq::conffwk::Configuration::m_else_mutex
mutableprivate

Definition at line 1711 of file Configuration.hpp.

◆ m_impl

ConfigurationImpl* dunedaq::conffwk::Configuration::m_impl
private

Definition at line 1661 of file Configuration.hpp.

◆ m_impl_mutex

std::mutex dunedaq::conffwk::Configuration::m_impl_mutex
mutableprivate

Definition at line 1708 of file Configuration.hpp.

◆ m_impl_name

std::string dunedaq::conffwk::Configuration::m_impl_name
private

Definition at line 1663 of file Configuration.hpp.

◆ m_impl_param

std::string dunedaq::conffwk::Configuration::m_impl_param
private

Definition at line 1664 of file Configuration.hpp.

◆ m_impl_spec

std::string dunedaq::conffwk::Configuration::m_impl_spec
private

Definition at line 1662 of file Configuration.hpp.

◆ m_pre_callbacks

PreCallbackSet dunedaq::conffwk::Configuration::m_pre_callbacks
private

Definition at line 1681 of file Configuration.hpp.

◆ m_registry

DalRegistry dunedaq::conffwk::Configuration::m_registry
private

Definition at line 1706 of file Configuration.hpp.

◆ m_shlib_h

void* dunedaq::conffwk::Configuration::m_shlib_h
private

Definition at line 1668 of file Configuration.hpp.

◆ m_tmpl_mutex

std::mutex dunedaq::conffwk::Configuration::m_tmpl_mutex
mutableprivate

Definition at line 1709 of file Configuration.hpp.

◆ p_all_classes_desc_cache

conffwk::map<dunedaq::conffwk::class_t *> dunedaq::conffwk::Configuration::p_all_classes_desc_cache
private

Definition at line 1293 of file Configuration.hpp.

◆ p_class_domain_map

conffwk::fmap<uint> dunedaq::conffwk::Configuration::p_class_domain_map
private

Definition at line 1431 of file Configuration.hpp.

◆ p_direct_classes_desc_cache

conffwk::map<dunedaq::conffwk::class_t *> dunedaq::conffwk::Configuration::p_direct_classes_desc_cache
private

Definition at line 1292 of file Configuration.hpp.

◆ p_number_of_cache_hits

std::atomic<uint_least64_t> dunedaq::conffwk::Configuration::p_number_of_cache_hits
private

Definition at line 1422 of file Configuration.hpp.

◆ p_number_of_template_object_created

std::atomic<uint_least64_t> dunedaq::conffwk::Configuration::p_number_of_template_object_created
private

Definition at line 1423 of file Configuration.hpp.

◆ p_number_of_template_object_read

std::atomic<uint_least64_t> dunedaq::conffwk::Configuration::p_number_of_template_object_read
private

Definition at line 1424 of file Configuration.hpp.

◆ p_subclasses

conffwk::fmap<conffwk::fset> dunedaq::conffwk::Configuration::p_subclasses
private

Definition at line 1430 of file Configuration.hpp.

◆ p_superclasses

conffwk::fmap<conffwk::fset> dunedaq::conffwk::Configuration::p_superclasses
private

Definition at line 1429 of file Configuration.hpp.


The documentation for this class was generated from the following files: