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

#include <ConfigObjectFactory.hpp>

Collaboration diagram for dunedaq::appmodel::ConfigObjectFactory:
[legend]

Public Member Functions

 ConfigObjectFactory (const SmartDaqApplication *)
 
 ~ConfigObjectFactory ()
 
conffwk::ConfigObject create (const std::string &class_name, const std::string &id) const
 
conffwk::ConfigObject create_queue_obj (const QueueDescriptor *qdesc, std::string uid="") const
 
conffwk::ConfigObject create_queue_sid_obj (const QueueDescriptor *qdesc, uint32_t src_id) const
 
conffwk::ConfigObject create_queue_sid_obj (const QueueDescriptor *qdesc, const confmodel::DetectorStream *stream) const
 
conffwk::ConfigObject create_net_obj (const NetworkConnectionDescriptor *ndesc, std::string uid) const
 Helper function that gets a network connection config.
 
conffwk::ConfigObject create_net_obj (const NetworkConnectionDescriptor *ndesc) const
 
template<class T >
const T * get_dal (std::string uid) const
 
template<class T >
const T * get_dal (conffwk::ConfigObject &obj) const
 
void update_modules (const std::vector< const confmodel::DaqModule * > &modules)
 

Private Attributes

conffwk::Configurationm_config
 
std::string m_dbfile
 
std::string m_app_uid
 

Detailed Description

Definition at line 30 of file ConfigObjectFactory.hpp.

Constructor & Destructor Documentation

◆ ConfigObjectFactory()

dunedaq::appmodel::ConfigObjectFactory::ConfigObjectFactory ( const SmartDaqApplication * parent)
explicit

Definition at line 11 of file ConfigObjectFactory.cpp.

11 :
12 m_config(&parent->configuration()),
13 m_dbfile(parent->config_object().contained_in()),
14 m_app_uid(parent->UID()) {
15
16 //FIXME: remove this hacky hack
18}
static void set_nolock_mode(bool nl)
Definition file.hpp:385

◆ ~ConfigObjectFactory()

dunedaq::appmodel::ConfigObjectFactory::~ConfigObjectFactory ( )

Definition at line 20 of file ConfigObjectFactory.cpp.

20 {
21 //FIXME: remove this hacky hack
23}

Member Function Documentation

◆ create()

conffwk::ConfigObject dunedaq::appmodel::ConfigObjectFactory::create ( const std::string & class_name,
const std::string & id ) const
nodiscard

Definition at line 26 of file ConfigObjectFactory.cpp.

27 {
29 m_config->create(m_dbfile, class_name, id, cfg_obj);
30 return cfg_obj;
31}
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_net_obj() [1/2]

conffwk::ConfigObject dunedaq::appmodel::ConfigObjectFactory::create_net_obj ( const NetworkConnectionDescriptor * ndesc) const
nodiscard

Definition at line 94 of file ConfigObjectFactory.cpp.

94 {
95 return create_net_obj(ndesc, this->m_app_uid);
96}
conffwk::ConfigObject create_net_obj(const NetworkConnectionDescriptor *ndesc, std::string uid) const
Helper function that gets a network connection config.

◆ create_net_obj() [2/2]

conffwk::ConfigObject dunedaq::appmodel::ConfigObjectFactory::create_net_obj ( const NetworkConnectionDescriptor * ndesc,
std::string app_uid ) const
nodiscard

Helper function that gets a network connection config.

Parameters
uidUnique ID name of the config object
ndescNetwork connection descriptor object

\ret OKS configuration object for the network connection

Definition at line 78 of file ConfigObjectFactory.cpp.

79 {
80
81 auto svc_obj = ndesc->get_associated_service()->config_object();
82 std::string net_id = ndesc->get_uid_base() + app_uid;
83 auto net_obj = create("NetworkConnection", net_id);
84
85 net_obj.set_by_val<std::string>("data_type", ndesc->get_data_type());
86 net_obj.set_by_val<std::string>("connection_type", ndesc->get_connection_type());
87 net_obj.set_by_val<uint32_t>("capacity", ndesc->get_capacity());
88 net_obj.set_obj("associated_service", &svc_obj);
89
90 return net_obj;
91}
conffwk::ConfigObject create(const std::string &class_name, const std::string &id) const

◆ create_queue_obj()

conffwk::ConfigObject dunedaq::appmodel::ConfigObjectFactory::create_queue_obj ( const QueueDescriptor * qdesc,
std::string uid = "" ) const
nodiscard

Definition at line 35 of file ConfigObjectFactory.cpp.

35 {
36
37 std::string queue_uid(qdesc->get_uid_base() + uid);
38 auto queue_obj = create("Queue", queue_uid);
39 queue_obj.set_by_val<std::string>("data_type", qdesc->get_data_type());
40 queue_obj.set_by_val<std::string>("queue_type", qdesc->get_queue_type());
41 queue_obj.set_by_val<uint32_t>("capacity", qdesc->get_capacity());
42
43 return queue_obj;
44}

◆ create_queue_sid_obj() [1/2]

conffwk::ConfigObject dunedaq::appmodel::ConfigObjectFactory::create_queue_sid_obj ( const QueueDescriptor * qdesc,
const confmodel::DetectorStream * stream ) const
nodiscard

Definition at line 62 of file ConfigObjectFactory.cpp.

63 {
64return create_queue_sid_obj(qdesc, stream->get_source_id());
65}
conffwk::ConfigObject create_queue_sid_obj(const QueueDescriptor *qdesc, uint32_t src_id) const

◆ create_queue_sid_obj() [2/2]

conffwk::ConfigObject dunedaq::appmodel::ConfigObjectFactory::create_queue_sid_obj ( const QueueDescriptor * qdesc,
uint32_t src_id ) const
nodiscard

Definition at line 48 of file ConfigObjectFactory.cpp.

48 {
49 std::string queue_uid(fmt::format("{}{}", qdesc->get_uid_base(), src_id));
50 auto queue_obj = create("QueueWithSourceId", queue_uid);
51
52 queue_obj.set_by_val<std::string>("data_type", qdesc->get_data_type());
53 queue_obj.set_by_val<std::string>("queue_type", qdesc->get_queue_type());
54 queue_obj.set_by_val<uint32_t>("capacity", qdesc->get_capacity());
55 queue_obj.set_by_val<uint32_t>("source_id", src_id);
56
57 return queue_obj;
58}

◆ get_dal() [1/2]

template<class T >
const T * dunedaq::appmodel::ConfigObjectFactory::get_dal ( conffwk::ConfigObject & obj) const
inline

Definition at line 78 of file ConfigObjectFactory.hpp.

78 {
79 return m_config->get<T>(obj);
80 }
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).
msgpack::object obj

◆ get_dal() [2/2]

template<class T >
const T * dunedaq::appmodel::ConfigObjectFactory::get_dal ( std::string uid) const
inline

Definition at line 73 of file ConfigObjectFactory.hpp.

73 {
74 return m_config->get<T>(uid);
75 }

◆ update_modules()

void dunedaq::appmodel::ConfigObjectFactory::update_modules ( const std::vector< const confmodel::DaqModule * > & modules)
inline

Definition at line 83 of file ConfigObjectFactory.hpp.

83 {
84 auto app = m_config->get<SmartDaqApplication>(m_app_uid);
85 if (!app->get_modules().empty()) {
86 throw (BadConf(ERS_HERE,
87 "SmartDaqApplication contains DaqModules which would be overwritten by generated DaqModules"));
88 }
89 if (!modules.empty()) {
90 const_cast<SmartDaqApplication*>(app)->set_modules(modules);
91 m_config->update<SmartDaqApplication>({m_app_uid}, {}, {});
92 }
93 }
#define ERS_HERE
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.

Member Data Documentation

◆ m_app_uid

std::string dunedaq::appmodel::ConfigObjectFactory::m_app_uid
private

Definition at line 35 of file ConfigObjectFactory.hpp.

◆ m_config

conffwk::Configuration* dunedaq::appmodel::ConfigObjectFactory::m_config
private

Definition at line 33 of file ConfigObjectFactory.hpp.

◆ m_dbfile

std::string dunedaq::appmodel::ConfigObjectFactory::m_dbfile
private

Definition at line 34 of file ConfigObjectFactory.hpp.


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