DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
DalFactory.hpp
Go to the documentation of this file.
1#ifndef DAL_FACTORY_H
2#define DAL_FACTORY_H
3
4#include <map>
5#include <mutex>
6#include <string>
7
8#include "ers/ers.hpp"
9
10#include "conffwk/set.hpp"
12
13#include "logging/Logging.hpp"
14
15namespace dunedaq {
16
17ERS_DECLARE_ISSUE(conffwk, DalPackageNameNotFound,
18 "Failed to find the dal package name for class " << class_name << " in its schema path '" << schema_path << "'",
19 ((std::string)class_name)((std::string)schema_path))
20
22 "Could not load dal shared library " << library,
23 ((std::string)library))
24
25namespace conffwk {
26
27class DalObject;
28class DalRegistry;
29
30class DalFactory
31{
32
33 typedef std::function<DalObject *(DalRegistry& db, ConfigObject& obj)> dal_object_instatiator_2g;
34
35public:
36
38 static DalFactory &
39 instance();
40
41 // /** register DAL object creator by class name*/
42 // template<class T>
43 // void
44 // register_dal_class(const std::string & name, const std::set<std::string>& algorithms);
45
47 template<class T>
48 void
49 register_dal_class(const std::string & name);
50
51 const std::string&
52 get_known_class_name_ref(const std::string& name);
53
66 DalObject *
67 get(Configuration& db, ConfigObject& obj, const std::string& uid, bool upcast_unregistered) const;
68
69 DalObject *
70 get(Configuration& db, ConfigObject& obj, const std::string& uid, const std::string& class_name) const;
71
72
82 const DalFactoryFunctions&
83 functions(Configuration& db, const std::string& name, bool upcast_unregistered);
84
85
86 const std::string&
87 class4algo(Configuration& db, const std::string& name, const std::string& algorithm) const;
88
96 const DalFactoryFunctions&
97 functions(const std::string& name) const;
98
99
103conffwk::DalObject* make(conffwk::DalRegistry& db, conffwk::ConfigObject& o, bool upcast_unregistered);
104
105conffwk::DalObject* make(conffwk::DalRegistry& db, conffwk::ConfigObject& o, const std::string& fallback_class="");
106
107private:
108
109 std::mutex m_class_mutex;
110 std::map<std::string, DalFactoryFunctions> m_classes;
111
112 // std::map<std::string, dal_object_instatiator> m_instantiators;
113 std::map<std::string, dal_object_instatiator_2g> m_creators;
114
115 std::mutex m_known_class_mutex;
116 conffwk::set m_known_classes;
117
118 // Move into a dedicated class/function
119 bool try_load_class_library(Configuration& db, const std::string& class_name);
120};
121
122} // namespace conffwk
123} // namespace dunedaq
124
125
126#include "details/DalFactory.hxx"
127
128#endif
#define ERS_DECLARE_ISSUE(namespace_name, class_name, message, attributes)
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...
std::unordered_set< std::string > set
Definition set.hpp:10
Including Qt Headers.