Line data Source code
1 : #include "conffwk/DalObject.hpp"
2 :
3 : namespace dunedaq {
4 : namespace conffwk {
5 :
6 : bool
7 0 : DalObject::get_rel_objects(const std::string& name, bool upcast_unregistered, std::vector<const DalObject*>& objs) const
8 : {
9 0 : std::vector<conffwk::ConfigObject> c_objs;
10 :
11 0 : if (const_cast<conffwk::ConfigObject*>(&p_obj)->rel(name, c_objs)) {
12 : // Fixme: what about the lock?
13 : // std::lock_guard<std::mutex> scoped_lock(p_registry.m_tmpl_mutex);
14 0 : p_registry.get(c_objs, upcast_unregistered).swap(objs);
15 0 : return true;
16 : }
17 :
18 : return false;
19 0 : }
20 :
21 : bool
22 0 : DalObject::get_algo_objects(const std::string& /* name */, std::vector<const DalObject*>& /* objs */) const
23 : {
24 : // FIXME: Remove
25 : // const std::string &suitable_dal_class = DalFactory::instance().class4algo(p_registry, class_name(), name);
26 :
27 : // TLOG_DEBUG(2) << "suitable class for algorithm " << name << " on object " << this << " is " <<
28 : // suitable_dal_class;
29 :
30 : // if (!suitable_dal_class.empty())
31 : // if (const DalObject *obj = p_registry.make_dal_object(const_cast<conffwk::ConfigObject&>(p_obj), UID(),
32 : // suitable_dal_class))
33 : // {
34 : // obj->get(name, false).swap(objs);
35 : // return true;
36 : // }
37 :
38 0 : return false;
39 : }
40 :
41 : // DalObject helper
42 :
43 : void
44 0 : DalObject::p_null(std::ostream& s)
45 : {
46 0 : s << "(null)";
47 0 : }
48 :
49 : void
50 0 : DalObject::p_rm(std::ostream& s)
51 : {
52 0 : s << "(deleted object)";
53 0 : }
54 :
55 : void
56 0 : DalObject::p_error(std::ostream& s, dunedaq::conffwk::Exception& ex)
57 : {
58 0 : s << "ERROR in generated DAL print method:\n\twas caused by: " << ex << std::endl;
59 0 : }
60 :
61 : void
62 0 : DalObject::p_hdr(std::ostream& s, unsigned int indent, const std::string& cl, const char* nm) const
63 : {
64 0 : const std::string str(indent, ' ');
65 0 : s << str;
66 0 : if (nm)
67 0 : s << nm << ' ';
68 0 : s << cl << " object:\n" << str << " id: \'" << UID() << "\', class name: \'" << DalObject::class_name() << "\'\n";
69 0 : }
70 :
71 : void
72 0 : DalObject::throw_init_ex(dunedaq::conffwk::Exception& ex)
73 : {
74 0 : std::ostringstream text;
75 0 : text << "failed to init " << this << ":\n\twas caused by: " << ex << std::endl;
76 0 : p_was_read = false;
77 0 : throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
78 0 : }
79 :
80 : void
81 0 : DalObject::throw_get_ex(const std::string& what, const std::string& class_name, const DalObject* obj)
82 : {
83 0 : std::ostringstream text;
84 0 : text << "cannot find relationship or algorithm \"" << what << "\" in c++ class \"" << class_name << "\" for object "
85 0 : << obj;
86 0 : throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
87 0 : }
88 :
89 : std::ostream&
90 0 : operator<<(std::ostream& s, const DalObject* obj)
91 : {
92 0 : if (obj == nullptr)
93 0 : DalObject::p_null(s);
94 0 : else if (obj->is_deleted())
95 0 : s << "(deleted object " << obj->UID() << '@' << obj->class_name() << ')';
96 : else
97 0 : s << '\'' << obj->UID() << '@' << obj->class_name() << '\'';
98 :
99 0 : return s;
100 : }
101 :
102 : void
103 0 : p_sv_rel(std::ostream& s, const std::string& str, const std::string& name, const DalObject* obj)
104 : {
105 0 : s << str << name << ": " << obj << '\n';
106 0 : }
107 :
108 : } // namespace conffwk
109 :
110 : } // namespace dunedaq
|