20#include "UniSetTypes.h"
21#include "Exceptions.h"
22#include "Configuration.h"
35 template<
typename T,
typename... _Args>
36 std::shared_ptr<T> make_object(
const std::string& idname,
const std::string& secname, _Args&& ... __args )
42 throw uniset::SystemError(
"(make_object<" + std::string(
typeid(T).name()) +
">): Not found ID for '" + idname +
"'");
44 auto xml = conf->getConfXML();
45 std::string s( (secname.empty() ? idname : secname) );
46 xmlNode* cnode = conf->findNode(xml->getFirstNode(), s, idname);
49 throw uniset::SystemError(
"(make_object<" + std::string(
typeid(T).name()) +
">): Not found xmlnode <" + s +
" name='" + idname +
"' ... >");
51 std::shared_ptr<T> obj = std::make_shared<T>(
id, cnode, std::forward<_Args>(__args)...);
61 template<
typename T,
typename... _Args>
62 std::shared_ptr<T> make_object_x( xmlNode* root,
const std::string& secname, _Args&& ... __args )
65 auto xml = conf->getConfXML();
66 xmlNode* cnode = conf->findNode(root, secname,
"");
69 throw uniset::SystemError(
"(make_object_x<" + std::string(
typeid(T).name()) +
">): Not found xmlnode <" + secname +
" ... >");
71 std::string idname = conf->getProp(cnode,
"name");
75 throw uniset::SystemError(
"(make_object_x<" + std::string(
typeid(T).name()) +
">): Not found ID for '" + idname +
"'");
77 return std::make_shared<T>(
id, cnode, std::forward<_Args>(__args)...);
87 template<
typename T,
typename M,
typename... _Args>
88 std::shared_ptr<T> make_child_object( M* m,
const std::string& idname,
const std::string& secname, _Args&& ... __args )
92 m->log()->info() << m->getName() <<
"(" << __FUNCTION__ <<
"): " <<
"create " << idname <<
"..." << std::endl;
93 auto o = uniset::make_object<T>(idname, secname, std::forward<_Args>(__args)...);
95 m->logAgregator()->add(o->logAgregator());
100 m->log()->crit() << m->getName() <<
"(" << __FUNCTION__ <<
"): " <<
"(create " << idname <<
"): " << ex << std::endl;
106 template<
typename T,
typename M,
typename... _Args>
107 std::shared_ptr<T> make_child_object_x( M* m, xmlNode* root,
const std::string& secname, _Args&& ... __args )
111 auto o = uniset::make_object_x<T>(root, secname, std::forward<_Args>(__args)...);
113 m->logAgregator()->add(o->logAgregator());
118 m->log()->crit() << m->getName() <<
"(" << __FUNCTION__ <<
"): " <<
"(create " << std::string(
typeid(T).name()) <<
"): " << ex << std::endl;
Definition Exceptions.h:46
Definition Exceptions.h:90
Definition Calibration.h:27
const ObjectId DefaultObjectId
Definition UniSetTypes.h:71
std::shared_ptr< Configuration > uniset_conf() noexcept
Definition Configuration.cc:90
long ObjectId
Definition UniSetTypes_i.idl:30