DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Configuration.hpp
Go to the documentation of this file.
1
9#ifndef CONFFWK_CONFIGURATION_H_
10#define CONFFWK_CONFIGURATION_H_
11
12#include <string.h>
13
14#include <atomic>
15#include <typeinfo>
16#include <string>
17#include <vector>
18#include <list>
19#include <set>
20
21#include <mutex>
22
23#include <boost/property_tree/ptree.hpp>
24
25#include "ers/ers.hpp"
26
30#include "conffwk/Errors.hpp"
33
34#include "conffwk/map.hpp"
35#include "conffwk/set.hpp"
36
37namespace dunedaq {
38namespace conffwk {
39
40class ConfigAction;
41class ConfigurationImpl;
42class ConfigurationChange;
43class DalObject;
44class DalRegistry;
45
46
47struct class_t;
48
49class Configuration;
50
60// class CacheBase
61// {
62
63// friend class Configuration;
64
65// protected:
66
67// CacheBase(const DalFactoryFunctions& f) :
68// m_functions(f)
69// {
70// ;
71// }
72
73// /** Method for configuration profiling */
74
75// void
76// increment_gets(Configuration& db) noexcept;
77
78// virtual
79// ~CacheBase() noexcept
80// {
81// ;
82// }
83
84// protected:
85
86// const DalFactoryFunctions& m_functions;
87
88// private:
89
90// conffwk::map<DalObject*> m_cache;
91// conffwk::multimap<DalObject*> m_t_cache;
92// };
93
94
222
223 friend class DalObject;
224 friend class ConfigObject;
225 friend class ConfigurationImpl;
226 // friend class CacheBase;
227 friend class DalObject;
228 friend class DalRegistry;
229
230 public:
231
232
247 Configuration(const std::string& spec);
248
250
251
254 const std::string& get_impl_spec() const noexcept {return m_impl_spec;}
255
256
259 const std::string& get_impl_name() const noexcept {return m_impl_name;}
260
261
264 const std::string& get_impl_param() const noexcept {return m_impl_param;}
265
266
274 ~Configuration() noexcept;
275
276
277 public:
278
287 typedef void (*notify)(
288 const std::vector<ConfigurationChange *> & changed_classes,
289 void * parameter
290 );
291
299 typedef void (*pre_notify)(
300 void * parameter
301 );
302
303
304 private: // Types to be used in public API below
305
306 // structure keeps information about callback subscriptions
307
313
318
319
320 public:
321
331
332
351 CallbackId subscribe(const ConfigurationSubscriptionCriteria& criteria, notify user_cb, void * user_param = nullptr);
352
353
374 CallbackId subscribe(pre_notify user_cb, void * user_param = nullptr);
375
376
387 void unsubscribe(CallbackId cb_handler = 0);
388
389
390
400 template<class T> bool is_valid(const T * object) noexcept;
401
402
403 private:
404
406 void reset_subscription();
407
408
409 public:
410
422 template<class T> void update(const std::vector<std::string>& modified,
423 const std::vector<std::string>& removed,
424 const std::vector<std::string>& created) noexcept;
425
426
434 void update_cache(std::vector<ConfigurationChange *>& changes) noexcept;
435
436
444 static void system_cb(std::vector<ConfigurationChange *>&, Configuration *) noexcept;
445
446
454 static void system_pre_cb(Configuration *) noexcept;
455
456
463 template<class T> void _reset_objects() noexcept;
464
465
466 // /**
467 // * \brief Mark object of given template class as unread (multi-thread unsafe).
468 // *
469 // * Is used by automatically generated data access libraries code after reading parameters for substitution,
470 // * since cache contains objects with non-substituted attributes. Should not be explicitly used by user.
471 // *
472 // * The method is used by the unread_all_objects() method.
473 // * \param cache_ptr pointer to the cache of template object of given template class (has to be downcasted)
474 // */
475
476 // template<class T> static void _unread_objects(CacheBase * cache_ptr) noexcept;
477
478
479 // /**
480 // * \brief Rename object of given template class (multi-thread unsafe).
481 // *
482 // * Is used by automatically generated data access libraries when an object has been renamed by user's code.
483 // * Should not be explicitly used by user.
484 // *
485 // * The method is used by the unread_all_objects() method.
486 // * \param cache_ptr pointer to the cache of template object of given template class (has to be downcasted)
487 // * \param old_id old object ID
488 // * \param new_id new object ID
489 // */
490
491 // template<class T> static void _rename_object(CacheBase* cache_ptr, const std::string& old_id, const std::string& new_id) noexcept;
492
493
494 // /**
495 // * \brief Update state of all objects in cache after abort / commit operations.
496 // *
497 // * It is used by automatically generated data access libraries.
498 // */
499
500 // void _reset_all_objects() noexcept;
501
502
515 void
516 unread_all_objects(bool unread_implementation_objs = false) noexcept;
517
518
526 void
528 {
529 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
531 }
532
533
542 void
544 {
545 std::lock_guard<std::mutex> scoped_lock(m_impl_mutex);
547 }
548
549
550 private:
551
552 static void
553 update_impl_objects(conffwk::pmap<conffwk::map<ConfigObjectImpl *> * >& cache, ConfigurationChange& change, const std::string * class_name);
554
555 void
556 _unread_template_objects() noexcept;
557
558 void
560
561
562 public:
563
578 void create(const std::string& at, const std::string& class_name, const std::string& id, ConfigObject& object);
579
580
595 void create(const ConfigObject& at, const std::string& class_name, const std::string& id, ConfigObject& object);
596
597
612 template<class T> const T * create(const std::string& at, const std::string& id, bool init_object = false);
613
614
629 template<class T> const T * create(const DalObject& at, const std::string& id, bool init_object = false);
630
631
642 void destroy_obj(ConfigObject& object);
643
644
655 template<class T> void destroy(T& obj);
656
657
658 public:
659
674 bool test_object(const std::string& class_name, const std::string& id, unsigned long rlevel = 0, const std::vector<std::string> * rclasses = 0);
675
676
691 void get(const std::string& class_name, const std::string& id, ConfigObject& object, unsigned long rlevel = 0, const std::vector<std::string> * rclasses = 0);
692
693
708 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);
709
710
726 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);
727
728
745 template<class T>
746 const T *
747 get(const std::string& id, bool init_children = false, bool init = true, unsigned long rlevel = 0, const std::vector<std::string> * rclasses = 0)
748 {
749 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
750 return _get<T>(id, init_children, init, rlevel, rclasses);
751 }
752
753
754
769 template<class T>
770 const T *
771 get(ConfigObject& obj, bool init_children = false, bool init = true)
772 {
773 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
774 return _get<T>(obj, init_children, init);
775 }
776
777
794 template<class T>
795 void
796 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)
797 {
798 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
799 _get<T>(objects, init_children, init, query, rlevel, rclasses);
800 }
801
815 template<class T>
816 const T *
817 get(ConfigObject& obj, const std::string& id)
818 {
819 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
820 return _get<T>(obj, id);
821 }
822
823
836 template<class T>
837 const T *
838 find(const std::string& id)
839 {
840 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
841 return _find<T>(id);
842 }
843
844
861 template<class T> const T * ref(ConfigObject& obj, const std::string& name, bool init = false) {
862 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
863 return _ref<T>(obj, name, init);
864 }
865
866
867
881 template<class T> void ref(ConfigObject& obj, const std::string& name, std::vector<const T*>& objects, bool init = false) {
882 std::lock_guard<std::mutex> scoped_lock(m_tmpl_mutex);
883 _ref<T>(obj, name, objects, init);
884 }
885
886
887
908 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);
909
910
937 std::vector<const DalObject*>
938 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);
939
940
950 template<class TARGET, class SOURCE> const TARGET *cast(const SOURCE *s) noexcept {
951 return s->template cast<TARGET>();
952 }
953
954
955 private:
956
958 void _get(const std::string& class_name, const std::string& id, ConfigObject& object, unsigned long rlevel, const std::vector<std::string> * rclasses);
959
961 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);
962
964 template<class T> const T * _get(ConfigObject& obj, bool init_children = false, bool init = true);
965
966 // /// \throw dunedaq::conffwk::Generic
967 // template<class T> const T * _get(ConfigObject& obj, const std::string& id);
968
970 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);
971
973 template<class T> DalObject * _make_instance(ConfigObject& obj, const std::string& uid)
974 {
975 // note upcast since the _get() returns pointer to T
976 return const_cast<T*>(_get<T>(obj, uid));
977 }
978
979 // std::vector<const DalObject*> make_dal_objects(std::vector<ConfigObject>& objs, bool upcast_unregistered);
980
981 // const DalObject* make_dal_object(ConfigObject& obj, const std::string& uid, const std::string& class_name);
982
983
984 // should be made private
985
986 public:
987
988 template<class T>
989 void
990 downcast_dal_objects(const std::vector<const T *>& objs,
991 bool /*upcast_unregistered*/, std::vector<const DalObject*>& result)
992 {
993 for (auto& i : objs)
994 result.push_back(i);
995 }
996
997 template<class T>
998 void
999 downcast_dal_object(const T * obj, bool /*upcast_unregistered*/, std::vector<const DalObject*>& result)
1000 {
1001 if(obj)
1002 result.push_back(obj);
1003 }
1004
1005
1011 template<class T> const T * _find(const std::string& id);
1012
1013
1020 template<class T> const T * _ref(ConfigObject& obj, const std::string& name, bool read_children);
1021
1022
1029 template<class T> void _ref(ConfigObject& obj, const std::string& name, std::vector<const T*>& results, bool read_children);
1030
1031
1041 bool try_cast(const std::string& target, const std::string& source) noexcept;
1042
1043 bool try_cast(const std::string* target, const std::string* source) noexcept;
1044
1045 bool is_superclass_of(const std::string& target, const std::string& source) noexcept;
1046
1047 bool is_superclass_of(const std::string* target, const std::string* source) noexcept;
1048
1049 private:
1050
1053 static std::string mk_ref_ex_text(const char * what, const std::string& cname, const std::string& rname, const ConfigObject& obj) noexcept;
1054
1055
1058 static std::string mk_ref_by_ex_text(const std::string& cname, const std::string& rname, const ConfigObject& obj) noexcept;
1059
1060
1061 // database manipulations
1062
1063 public:
1064
1073 bool loaded() const noexcept;
1074
1075
1084 void load(const std::string& db_name);
1085
1086
1098 void unload();
1099
1100
1113 void create(const std::string& db_name, const std::list<std::string>& includes);
1114
1115
1128 bool is_writable(const std::string& db_name) const;
1129
1130
1142 void add_include(const std::string& db_name, const std::string& include);
1143
1144
1156 void remove_include(const std::string& db_name, const std::string& include);
1157
1158
1170 void get_includes(const std::string& db_name, std::list<std::string>& includes) const;
1171
1172
1183 void get_updated_dbs(std::list<std::string>& dbs) const;
1184
1185
1197 void set_commit_credentials(const std::string& user, const std::string& password);
1198
1199
1210 void commit(const std::string& log_message = "");
1211
1212
1221 void abort();
1222
1223
1232 void prefetch_all_data();
1233
1234
1235 // access versions
1236
1237 public:
1238
1245 std::vector<dunedaq::conffwk::Version>
1246 get_changes();
1247
1248
1264 std::vector<dunedaq::conffwk::Version>
1265 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);
1266
1267
1268
1269 // access to schema description
1270
1271 public:
1272
1283 const dunedaq::conffwk::class_t& get_class_info(const std::string& class_name, bool direct_only = false);
1284
1285
1286 private:
1287
1288 const dunedaq::conffwk::class_t& _get_class_info(const std::string& class_name, bool direct_only = false);
1289
1290 // cache, storing descriptions of schema
1291
1294
1295 public:
1296
1307 void
1308 export_schema(boost::property_tree::ptree& tree, const std::string& classes = "", bool direct_only = false);
1309
1310
1323 void
1324 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 = "");
1325
1326
1327 // user-defined converters
1328
1329 public:
1330
1334
1335 public:
1336
1338
1339 };
1340
1341
1350 template<class T> class AttributeConverter : public AttributeConverterBase {
1351
1352 public:
1353
1368 virtual void convert(T& value, const Configuration& conf, const ConfigObject& obj, const std::string& attr_name) = 0;
1369
1370 };
1371
1372
1386 template<class T> void register_converter(AttributeConverter<T> * object) noexcept;
1387
1388
1395 template<class T> void convert(T& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
1396
1397
1404 template<class T> void convert2(std::vector<T>& value, const ConfigObject& obj, const std::string& attr_name) noexcept;
1405
1406
1407 public:
1408
1409
1417 void print_profiling_info() noexcept;
1418
1419
1420 private:
1421
1422 std::atomic<uint_least64_t> p_number_of_cache_hits;
1424 std::atomic<uint_least64_t> p_number_of_template_object_read;
1425
1426
1427 private:
1428
1432
1433 void set_subclasses() noexcept;
1434
1435 void set_class_domain_map();
1436
1437 void update_classes() noexcept;
1438
1439 std::deque<std::set<std::string>> find_class_domains();
1440
1441 public:
1442
1445 const conffwk::fmap<conffwk::fset>& superclasses() const noexcept {return p_superclasses;}
1446
1447
1451
1452 std::vector<std::string> classes_in_python() const;
1453
1454
1455
1456 private:
1457
1459
1460
1461 // cache of objects for user-defined classes
1462
1463 public:
1464
1477 // template<class T> class Cache : public CacheBase {
1478
1479 // friend class Configuration;
1480
1481 // public:
1482
1483 // Cache() :
1484 // CacheBase(DalFactory::instance().functions(T::s_class_name))
1485 // {
1486 // ;
1487 // }
1488
1489
1490 // virtual ~Cache() noexcept;
1491
1492
1493 // /**
1494 // * \brief Get template object from cache by conffwk object.
1495 // *
1496 // * The method searches an object with id of given conffwk object within the cache.
1497 // * If found, the method sets given conffwk object as implementation of the template
1498 // * object and returns pointer on the template object.
1499 // * If there is no such object in cache, then it is created from given conffwk object.
1500 // *
1501 // * In case of success, the new object is put into cache and pointer to the object is returned.
1502 // * If there is no such object for given template class, then \b null pointer is returned.
1503 // *
1504 // * \param conffwk the configuration object
1505 // * \param obj the conffwk object used to set for the template object
1506 // * \param init_children if true, the referenced objects are initialized (only applicable during creation of new object)
1507 // * \param init_object if true, the object's attributes and relationships are read(only applicable during creation of new object)
1508 // *
1509 // * \return Return pointer to object.
1510 // *
1511 // * \throw dunedaq::conffwk::Generic is no such class for loaded configuration DB schema or in case of an error
1512 // */
1513
1514 // T * get(Configuration& conffwk, ConfigObject& obj, bool init_children, bool init_object);
1515
1516
1517 // /**
1518 // * \brief Get template object from cache by object's ID.
1519 // *
1520 // * The method searches an object with given id within the cache.
1521 // * If found, the method returns pointer on it.
1522 // * If there is no such object in cache, there is an attempt to create new object.
1523 // * In case of success, the new object is put into cache and pointer to the object is returned.
1524 // * If there is no such object for given template class, then \b null pointer is returned.
1525 // *
1526 // * \param conffwk the configuration object
1527 // * \param name object identity
1528 // * \param init_children if true, the referenced objects are initialized (only applicable during creation of new object)
1529 // * \param init_object if true, the object's attributes and relationships are read(only applicable during creation of new object)
1530 // * \param rlevel optional references level to optimize performance (defines how many objects referenced by given object have also to be read to the implementation cache during creation of new object)
1531 // * \param rclasses optional array of class names to optimize performance (defines which referenced objects have to be read to the implementation cache during creation of new object)
1532 // *
1533 // * \return Return pointer to object. It can be \b null, if there is no such object found.
1534 // *
1535 // * \throw dunedaq::conffwk::Generic is no such class for loaded configuration DB schema or in case of an error
1536 // */
1537
1538 // T * get(Configuration& conffwk, const std::string& name, bool init_children, bool init_object, unsigned long rlevel, const std::vector<std::string> * rclasses);
1539
1540
1541 // /**
1542 // * \brief Find template object using ID.
1543 // *
1544 // * The method is suitable for generated template objects.
1545 // *
1546 // * In case of success, the new object is put into cache and pointer to the object is returned.
1547 // * If there is no such object for given template class, then \b null pointer is returned.
1548 // *
1549 // * \param id ID of generated object
1550 // *
1551 // * \return Return pointer to object.
1552 // *
1553 // * \throw dunedaq::conffwk::Generic is no such class for loaded configuration DB schema or in case of an error
1554 // */
1555
1556
1557 // T *
1558 // find(const std::string& id);
1559
1560
1561 // /**
1562 // * \brief Generate template object using conffwk object and ID.
1563 // *
1564 // * The method searches an object with id of given conffwk object within the cache using given ID.
1565 // * If found, the method sets given conffwk object as implementation of the template
1566 // * object and returns pointer on the template object.
1567 // * If there is no such object in cache, then it is created from given conffwk object.
1568 // *
1569 // * In case of success, the new object is put into cache and pointer to the object is returned.
1570 // * If there is no such object for given template class, then \b null pointer is returned.
1571 // *
1572 // * \param conffwk the configuration object
1573 // * \param obj the conffwk object used to set for the template object
1574 // * \param id ID of generated object
1575 // *
1576 // * \return Return pointer to object.
1577 // *
1578 // * \throw dunedaq::conffwk::Generic is no such class for loaded configuration DB schema or in case of an error
1579 // */
1580
1581 // T *
1582 // get(Configuration& conffwk, ConfigObject& obj, const std::string& id);
1583
1584
1585 // private:
1586
1587 // conffwk::map<T*> m_cache;
1588 // conffwk::multimap<T*> m_t_cache;
1589
1590
1591 // };
1592
1593 private:
1594
1595 // Get cache for this type of objects.
1596
1597 // template<class T> Cache<T> * get_cache() noexcept;
1598
1599 // template<class T> Cache<T> * get_cache( const std::string& class_name ) {
1600
1601 // const std::string& class_name_ref = DalFactory::instance().get_known_class_name_ref(class_name);
1602 // CacheBase*& c(m_cache_map[&class_name_ref]);
1603
1604 // if (c == nullptr)
1605 // // c = new CacheBase(DalFactory::instance().functions(class_name_ref));
1606 // c = new CacheBase(class_name_ref, DalFactory::instance().functions(*this, class_name_ref, true));
1607
1608 // return static_cast<Cache<T>*>(c);
1609
1610 // // return c;
1611 // }
1612
1613 // conffwk::fmap<CacheBase*> m_cache_map;
1614
1615 void rename_object(ConfigObject& obj, const std::string& new_id);
1616
1617 // template<class T>
1618 // void
1619 // set_cache_unread(const std::vector<std::string>& objects, Cache<T>& c) noexcept
1620 // {
1621 // for (const auto& i : objects)
1622 // {
1623 // // unread template objects
1624 // auto x = c.m_cache.find(i);
1625 // if (x != c.m_cache.end())
1626 // {
1627 // std::lock_guard<std::mutex> scoped_lock(x->second->m_mutex);
1628 // x->second->p_was_read = false;
1629 // }
1630
1631 // // unread generated objects if any
1632 // auto range = c.m_t_cache.equal_range(i);
1633 // for (auto it = range.first; it != range.second; it++)
1634 // {
1635 // std::lock_guard<std::mutex> scoped_lock(it->second->m_mutex);
1636 // it->second->p_was_read = false;
1637 // }
1638 // }
1639 // }
1640
1641
1642 public:
1643
1654 void print(std::ostream&) const noexcept;
1655
1656
1657 // representation
1658
1659 private:
1660
1662 std::string m_impl_spec;
1663 std::string m_impl_name;
1664 std::string m_impl_param;
1665
1666
1667
1669
1670
1671 // user notification
1672
1673 private:
1674
1675 // user callbacks with parameters
1676
1677 typedef std::set< CallbackSubscription * , std::less<CallbackSubscription *> > CallbackSet;
1678 typedef std::set< CallbackPreSubscription * , std::less<CallbackPreSubscription *> > PreCallbackSet;
1679
1682
1683
1684 // method to find callback by handler
1685
1686 CallbackSubscription * find_callback(CallbackId cb_handler) const;
1687
1688
1689 public:
1690
1692 void
1694
1696 void
1698
1699 private:
1700
1701 std::list<ConfigAction *> m_actions;
1702 void action_on_update(const ConfigObject& obj, const std::string& name);
1703
1704
1705 private:
1707
1708 mutable std::mutex m_impl_mutex; // mutex used to access implementation objects (i.e. ConfigObjectImpl objects)
1709 mutable std::mutex m_tmpl_mutex; // mutex used to access template objects (i.e. generated DAL)
1710 mutable std::mutex m_actn_mutex; // mutex is used to access actions
1711 mutable std::mutex m_else_mutex; // mutex used to access subscription, attribute converter, etc. objects
1712
1713
1714 // prevent copy constructor and operator=
1715
1716 private:
1717
1720
1721 public:
1722
1723 // JCF, Jan-1-2023: a set of functions written specifically for Python bindings
1724
1725 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> attributes_pybind(const std::string& class_name, bool all);
1726 std::vector<std::string> get_class_list() const;
1727 ConfigObject* create_and_return_obj_pybind(const std::string& at, const std::string& class_name, const std::string& id);
1728 ConfigObject* create_and_return_obj_pybind(const ConfigObject& at, const std::string& class_name, const std::string& id);
1729 ConfigObject* get_obj_pybind(const std::string& class_name, const std::string& id);
1730 std::vector<ConfigObject>* get_objs_pybind(const std::string& class_name, const std::string& query="");
1731 std::unordered_map<std::string, std::unordered_map<std::string, std::string>> relations_pybind(const std::string& class_name, bool all);
1732 std::list<std::string>* return_includes_pybind(const std::string& db_name);
1733 std::vector<std::string> subclasses_pybind(const std::string& class_name, bool all);
1734 std::vector<std::string> superclasses_pybind(const std::string& class_name, bool all);
1735};
1736
1741std::ostream& operator<<(std::ostream& s, const Configuration & c);
1742
1746
1747} // namespace conffwk
1748} // namespace dunedaq
1749
1751
1752
1753
1754
1755#endif // CONFFWK_CONFIGURATION_H_
Represents database objects.
Describes changes inside a class returned by the notification mechanism.
Definition Change.hpp:35
Provides pure virtual interface used by the Configuration class.
virtual void convert(T &value, const Configuration &conf, const ConfigObject &obj, const std::string &attr_name)=0
Defines base class for cache of template objects.
void register_converter(AttributeConverter< T > *object) noexcept
Register user function for attribute conversion.
const std::string & get_impl_name() const noexcept
const T * _find(const std::string &id)
Multi-thread unsafe version of find(const std::string&) method.
void update_cache(std::vector< ConfigurationChange * > &changes) noexcept
System function invoked in case of modifications.
std::vector< ConfigObject > * get_objs_pybind(const std::string &class_name, const std::string &query="")
void _get(const std::string &class_name, const std::string &id, ConfigObject &object, unsigned long rlevel, const std::vector< std::string > *rclasses)
const conffwk::fmap< conffwk::fset > & superclasses() const noexcept
static void update_impl_objects(conffwk::pmap< conffwk::map< ConfigObjectImpl * > * > &cache, ConfigurationChange &change, const std::string *class_name)
conffwk::map< std::list< AttributeConverterBase * > * > m_convert_map
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(*) pre_notify(void *parameter)
The user notification callback function which is invoked before changes are going to be applied.
void _unread_implementation_objects(dunedaq::conffwk::ObjectState state) noexcept
const TARGET * cast(const SOURCE *s) noexcept
Cast objects from one class to another (multi-thread safe).
static void system_cb(std::vector< ConfigurationChange * > &, Configuration *) noexcept
System callback function invoked in case of modifications.
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > attributes_pybind(const std::string &class_name, bool all)
void destroy_obj(ConfigObject &object)
Destroy object.
std::unordered_map< std::string, std::unordered_map< std::string, std::string > > relations_pybind(const std::string &class_name, bool all)
void remove_include(const std::string &db_name, const std::string &include)
Remove include file.
void get_updated_dbs(std::list< std::string > &dbs) const
Get list of updated files to be committed.
std::vector< std::string > classes_in_python() const
void prefetch_all_data()
Prefetch all data into client cache.
void load(const std::string &db_name)
Load database according to the name. If name is empty, take it from TDAQ_DB_NAME and TDAQ_DB_DATA env...
void action_on_update(const ConfigObject &obj, const std::string &name)
void remove_action(ConfigAction *ac)
Configuration & operator=(const Configuration &)
bool is_writable(const std::string &db_name) const
Get write access status.
std::list< ConfigAction * > m_actions
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 set_commit_credentials(const std::string &user, const std::string &password)
Set commit credentials.
void print(std::ostream &) const noexcept
Prints out details of configuration object.
~Configuration() noexcept
Destructor to destroy a configuration object.
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).
Configuration(const Configuration &)
void add_action(ConfigAction *ac)
std::atomic< uint_least64_t > p_number_of_template_object_created
void unread_template_objects() noexcept
Unread all template (i.e. set their state as uninitialized) objects.
const std::string & get_impl_param() const noexcept
static void system_pre_cb(Configuration *) noexcept
System callback function invoked in case of pre-modifications.
conffwk::fmap< conffwk::fset > p_subclasses
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< std::string > superclasses_pybind(const std::string &class_name, bool all)
CallbackSubscription * find_callback(CallbackId cb_handler) const
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.
static std::string mk_ref_ex_text(const char *what, const std::string &cname, const std::string &rname, const ConfigObject &obj) noexcept
const dunedaq::conffwk::class_t & _get_class_info(const std::string &class_name, bool direct_only=false)
std::vector< std::string > subclasses_pybind(const std::string &class_name, bool all)
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...
std::list< std::string > * return_includes_pybind(const std::string &db_name)
bool loaded() const noexcept
Check if database is correctly loaded.
DalObject * _make_instance(ConfigObject &obj, const std::string &uid)
std::vector< std::string > get_class_list() const
const conffwk::fmap< conffwk::fset > & subclasses() const
conffwk::map< dunedaq::conffwk::class_t * > p_all_classes_desc_cache
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).
std::deque< std::set< std::string > > find_class_domains()
CallbackSubscription * CallbackId
Callback identifier.
const std::string & get_impl_spec() const noexcept
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.
void destroy(T &obj)
Destroy object of given class.
void get_includes(const std::string &db_name, std::list< std::string > &includes) const
Get include files.
std::set< CallbackPreSubscription *, std::less< CallbackPreSubscription * > > PreCallbackSet
conffwk::fmap< conffwk::fset > p_superclasses
std::vector< dunedaq::conffwk::Version > get_changes()
Get new conffwk versions.
conffwk::map< dunedaq::conffwk::class_t * > p_direct_classes_desc_cache
void commit(const std::string &log_message="")
Commit database changes.
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).
void downcast_dal_object(const T *obj, bool, std::vector< const DalObject * > &result)
conffwk::fmap< uint > p_class_domain_map
bool is_superclass_of(const std::string &target, const std::string &source) noexcept
const T * get(ConfigObject &obj, const std::string &id)
Generate object of given class by object reference and instantiate the template parameter with it (mu...
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.
static std::string mk_ref_by_ex_text(const std::string &cname, const std::string &rname, const ConfigObject &obj) noexcept
void unread_implementation_objects(dunedaq::conffwk::ObjectState state) noexcept
Unread implementation objects (i.e. clear their cache).
ConfigObject * get_obj_pybind(const std::string &class_name, const std::string &id)
void downcast_dal_objects(const std::vector< const T * > &objs, bool, std::vector< const DalObject * > &result)
CallbackId subscribe(pre_notify user_cb, void *user_param=nullptr)
Subscribe on pre-notification on configuration changes.
void export_schema(boost::property_tree::ptree &tree, const std::string &classes="", bool direct_only=false)
Export configuration schema into ptree.
void unsubscribe(CallbackId cb_handler=0)
Remove callback function.
void(*) notify(const std::vector< ConfigurationChange * > &changed_classes, void *parameter)
The user notification callback function which is invoked in case of changes.
void print_profiling_info() noexcept
Print out profiling information.
std::vector< dunedaq::conffwk::Version > 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.
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).
std::atomic< uint_least64_t > p_number_of_template_object_read
void abort()
Abort database changes.
void unload()
Unload database.
bool test_object(const std::string &class_name, const std::string &id, unsigned long rlevel=0, const std::vector< std::string > *rclasses=0)
Test the object existence.
void add_include(const std::string &db_name, const std::string &include)
Add include file to existing database.
std::atomic< uint_least64_t > p_number_of_cache_hits
void convert(T &value, const ConfigObject &obj, const std::string &attr_name) noexcept
Converts single value.
std::set< CallbackSubscription *, std::less< CallbackSubscription * > > CallbackSet
ConfigObject * create_and_return_obj_pybind(const std::string &at, const std::string &class_name, const std::string &id)
CallbackId subscribe(const ConfigurationSubscriptionCriteria &criteria, notify user_cb, void *user_param=nullptr)
Subscribe on configuration changes.
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-t...
bool try_cast(const std::string &target, const std::string &source) noexcept
Checks if cast from source class to target class is allowed.
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 (mu...
const T * find(const std::string &id)
Find object of given class (multi-thread safe).
void convert2(std::vector< T > &value, const ConfigObject &obj, const std::string &attr_name) noexcept
Converts vector of single values.
void rename_object(ConfigObject &obj, const std::string &new_id)
Cache of template object of given type.
bool is_valid(const T *object) noexcept
Checks validity of pointer to an objects of given user class.
bool is_superclass_of(const std::string *target, const std::string *source) noexcept
The base class for any generated DAL object.
Definition DalObject.hpp:45
DalRegistry: A registry of DalObjects It provides a single interface to create, cache and manage DalO...
Represents configuration version.
void init(unordered_map< std::string, std::string > params)
Definition file.hpp:28
std::unordered_set< const std::string *, string_ptr_hash > fset
Definition set.hpp:13
std::unordered_set< std::string > set
Definition set.hpp:10
std::ostream & operator<<(std::ostream &, const ConfigurationChange &)
Including Qt Headers.