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

#include <CTBSockets.hpp>

Inheritance diagram for dunedaq::appmodel::CTBSockets:
[legend]
Collaboration diagram for dunedaq::appmodel::CTBSockets:
[legend]

Public Member Functions

virtual void print (unsigned int offset, bool print_header, std::ostream &s) const
 Print details of the CTBSockets object.
 
virtual std::vector< const dunedaq::conffwk::DalObject * > get (const std::string &name, bool upcast_unregistered=true) const
 Get values of relationships and results of some algorithms as a vector of dunedaq::conffwk::DalObject pointers.
 
const dunedaq::appmodel::CTBReceiverSocketget_receiver () const
 Get "receiver" relationship value.
 
void set_receiver (const dunedaq::appmodel::CTBReceiverSocket *value)
 Set "receiver" relationship value.
 
const dunedaq::appmodel::CTBMonitorSocketget_monitor () const
 Get "monitor" relationship value.
 
void set_monitor (const dunedaq::appmodel::CTBMonitorSocket *value)
 Set "monitor" relationship value.
 
const dunedaq::appmodel::CTBStatisticsSocketget_statistics () const
 Get "statistics" relationship value.
 
void set_statistics (const dunedaq::appmodel::CTBStatisticsSocket *value)
 Set "statistics" relationship value.
 
nlohmann::json get_ctb_json (std::optional< std::string > socket_host=std::nullopt) const
 
virtual void print (unsigned int offset, bool print_header, std::ostream &s) const
 Print details of the CTBSockets object.
 
virtual std::vector< const dunedaq::conffwk::DalObject * > get (const std::string &name, bool upcast_unregistered=true) const
 Get values of relationships and results of some algorithms as a vector of dunedaq::conffwk::DalObject pointers.
 
const dunedaq::appmodel::CTBReceiverSocketget_receiver () const
 Get "receiver" relationship value.
 
void set_receiver (const dunedaq::appmodel::CTBReceiverSocket *value)
 Set "receiver" relationship value.
 
const dunedaq::appmodel::CTBMonitorSocketget_monitor () const
 Get "monitor" relationship value.
 
void set_monitor (const dunedaq::appmodel::CTBMonitorSocket *value)
 Set "monitor" relationship value.
 
const dunedaq::appmodel::CTBStatisticsSocketget_statistics () const
 Get "statistics" relationship value.
 
void set_statistics (const dunedaq::appmodel::CTBStatisticsSocket *value)
 Set "statistics" relationship value.
 
nlohmann::json get_ctb_json (std::optional< std::string > socket_host=std::nullopt) const
 
- Public Member Functions inherited from dunedaq::conffwk::DalObject
const std::string & UID () const noexcept
 
const std::string & class_name () const noexcept
 
bool castable (const std::string &target) const noexcept
 
bool castable (const std::string *target) const noexcept
 
template<class TARGET >
const TARGET * cast () const noexcept
 Casts object to different class.
 
std::string full_name () const noexcept
 
const ConfigObjectconfig_object () const
 
DalRegistryregistry () const noexcept
 
Configurationconfiguration () const noexcept
 
void unread ()
 
void set (const ConfigObject &o) noexcept
 
void move (const std::string &at)
 
void rename (const std::string &new_id)
 
void p_hdr (std::ostream &s, unsigned int indent, const std::string &cl, const char *nm=nullptr) const
 print object headers
 
std::ostream & print_object (std::ostream &s) const
 print object details
 
void throw_init_ex (dunedaq::conffwk::Exception &ex)
 throw object initialisation exception (i.e.
 

Static Public Member Functions

static const std::string & __get_receiver_str () noexcept
 
static const std::string & __get_monitor_str () noexcept
 
static const std::string & __get_statistics_str () noexcept
 
static const std::string & __get_receiver_str () noexcept
 
static const std::string & __get_monitor_str () noexcept
 
static const std::string & __get_statistics_str () noexcept
 
- Static Public Member Functions inherited from dunedaq::conffwk::DalObject
static void p_null (std::ostream &s)
 print "(null)"
 
static void p_rm (std::ostream &s)
 print "(deleted object)"
 
static void p_error (std::ostream &s, dunedaq::conffwk::Exception &ex)
 print error text
 
static void throw_get_ex (const std::string &what, const std::string &class_name, const DalObject *obj)
 throw exception in generated get method (i.e.
 
static bool is_null (const DalObject *ref) noexcept
 check a pointer on DAL object is null
 

Static Public Attributes

static const std::string & s_class_name
 
static const std::string s_receiver = "receiver"
 
static const std::string s_monitor = "monitor"
 
static const std::string s_statistics = "statistics"
 

Protected Member Functions

 CTBSockets (conffwk::DalRegistry &db, const conffwk::ConfigObject &obj) noexcept
 
virtual ~CTBSockets () noexcept
 
virtual void init (bool init_children)
 
bool get (const std::string &name, std::vector< const dunedaq::conffwk::DalObject * > &vec, bool upcast_unregistered, bool first_call) const
 
 CTBSockets (conffwk::DalRegistry &db, const conffwk::ConfigObject &obj) noexcept
 
virtual ~CTBSockets () noexcept
 
virtual void init (bool init_children)
 
bool get (const std::string &name, std::vector< const dunedaq::conffwk::DalObject * > &vec, bool upcast_unregistered, bool first_call) const
 
- Protected Member Functions inherited from dunedaq::conffwk::DalObject
 DalObject (DalRegistry &db, const ConfigObject &o) noexcept
 
virtual ~DalObject ()
 
void clear () noexcept
 
void check () const
 
bool is_deleted () const
 
void increment_created () noexcept
 
void increment_read () noexcept
 
void check_init () const
 Check and initialize object if necessary.
 
template<typename T >
void _set_object (const std::string &name, const T *value)
 Helper method for generated set single-value relationship methods.
 
template<typename T >
void _set_objects (const std::string &name, const std::vector< const T * > &value)
 Helper method for generated set multi-value relationship methods.
 
bool get_rel_objects (const std::string &name, bool upcast_unregistered, std::vector< const DalObject * > &objs) const
 Read relationship values as DAL objects using DAL factory.
 
bool get_algo_objects (const std::string &name, std::vector< const DalObject * > &objs) const
 Run algorithm and return result as DAL objects using DAL factory.
 

Private Attributes

const dunedaq::appmodel::CTBReceiverSocketm_receiver
 
const dunedaq::appmodel::CTBMonitorSocketm_monitor
 
const dunedaq::appmodel::CTBStatisticsSocketm_statistics
 

Friends

class conffwk::Configuration
 
class conffwk::DalObject
 
class conffwk::DalFactory
 
class conffwk::DalRegistry
 

Additional Inherited Members

- Protected Attributes inherited from dunedaq::conffwk::DalObject
std::mutex m_mutex
 Used to protect changes of DAL object.
 
bool p_was_read
 is true, if the object was read
 
DalRegistryp_registry
 Configuration object.
 
ConfigObject p_obj
 Config object used by given template object.
 
std::string p_UID
 Is used for template objects (see dqm_conffwk)
 

Detailed Description

Definition at line 36 of file CTBSockets.hpp.

Constructor & Destructor Documentation

◆ CTBSockets() [1/2]

dunedaq::appmodel::CTBSockets::CTBSockets ( conffwk::DalRegistry & db,
const conffwk::ConfigObject & obj )
protectednoexcept

Definition at line 33 of file CTBSockets.cpp.

33 :
35 m_receiver (nullptr),
36 m_monitor (nullptr),
37 m_statistics (nullptr)
38
39 {
40 ;
41 }
const dunedaq::appmodel::CTBStatisticsSocket * m_statistics
const dunedaq::appmodel::CTBReceiverSocket * m_receiver
const dunedaq::appmodel::CTBMonitorSocket * m_monitor
The base class for any generated DAL object.
Definition DalObject.hpp:45

◆ ~CTBSockets() [1/2]

dunedaq::appmodel::CTBSockets::~CTBSockets ( )
protectedvirtualnoexcept

Definition at line 83 of file CTBSockets.cpp.

84 {
85 }

◆ CTBSockets() [2/2]

dunedaq::appmodel::CTBSockets::CTBSockets ( conffwk::DalRegistry & db,
const conffwk::ConfigObject & obj )
protectednoexcept

◆ ~CTBSockets() [2/2]

virtual dunedaq::appmodel::CTBSockets::~CTBSockets ( )
protectedvirtualnoexcept

Member Function Documentation

◆ __get_monitor_str() [1/2]

static const std::string & dunedaq::appmodel::CTBSockets::__get_monitor_str ( )
inlinestaticnoexcept

Definition at line 101 of file CTBSockets.hpp.

101{ return s_monitor; }
static const std::string s_monitor

◆ __get_monitor_str() [2/2]

static const std::string & dunedaq::appmodel::CTBSockets::__get_monitor_str ( )
inlinestaticnoexcept

Definition at line 101 of file CTBSockets.hpp.

101{ return s_monitor; }

◆ __get_receiver_str() [1/2]

static const std::string & dunedaq::appmodel::CTBSockets::__get_receiver_str ( )
inlinestaticnoexcept

Definition at line 100 of file CTBSockets.hpp.

100{ return s_receiver; }
static const std::string s_receiver

◆ __get_receiver_str() [2/2]

static const std::string & dunedaq::appmodel::CTBSockets::__get_receiver_str ( )
inlinestaticnoexcept

Definition at line 100 of file CTBSockets.hpp.

100{ return s_receiver; }

◆ __get_statistics_str() [1/2]

static const std::string & dunedaq::appmodel::CTBSockets::__get_statistics_str ( )
inlinestaticnoexcept

Definition at line 102 of file CTBSockets.hpp.

102{ return s_statistics; }
static const std::string s_statistics

◆ __get_statistics_str() [2/2]

static const std::string & dunedaq::appmodel::CTBSockets::__get_statistics_str ( )
inlinestaticnoexcept

Definition at line 102 of file CTBSockets.hpp.

102{ return s_statistics; }

◆ get() [1/4]

std::vector< const dunedaq::conffwk::DalObject * > dunedaq::appmodel::CTBSockets::get ( const std::string & name,
bool upcast_unregistered = true ) const
virtual

Get values of relationships and results of some algorithms as a vector of dunedaq::conffwk::DalObject pointers.

Parameters are:

Parameters
namename of the relationship or algorithm
Returns
value of relationship or result of algorithm
Exceptions
std::exceptionif there is no relationship or algorithm with such name in this and base classes

Implements dunedaq::conffwk::DalObject.

Definition at line 87 of file CTBSockets.cpp.

88 {
89 std::vector<const dunedaq::conffwk::DalObject *> vec;
90
91 if (!get(name, vec, upcast_unregistered, true))
92 throw_get_ex(name, s_class_name, this);
93
94 return vec;
95 }
static const std::string & s_class_name
virtual std::vector< const dunedaq::conffwk::DalObject * > get(const std::string &name, bool upcast_unregistered=true) const
Get values of relationships and results of some algorithms as a vector of dunedaq::conffwk::DalObject...
static void throw_get_ex(const std::string &what, const std::string &class_name, const DalObject *obj)
throw exception in generated get method (i.e.
Definition DalObject.cpp:82

◆ get() [2/4]

virtual std::vector< const dunedaq::conffwk::DalObject * > dunedaq::appmodel::CTBSockets::get ( const std::string & name,
bool upcast_unregistered = true ) const
virtual

Get values of relationships and results of some algorithms as a vector of dunedaq::conffwk::DalObject pointers.

Parameters are:

Parameters
namename of the relationship or algorithm
Returns
value of relationship or result of algorithm
Exceptions
std::exceptionif there is no relationship or algorithm with such name in this and base classes

Implements dunedaq::conffwk::DalObject.

◆ get() [3/4]

bool dunedaq::appmodel::CTBSockets::get ( const std::string & name,
std::vector< const dunedaq::conffwk::DalObject * > & vec,
bool upcast_unregistered,
bool first_call ) const
protected

Definition at line 97 of file CTBSockets.cpp.

98 {
99 if (first_call)
100 {
101 std::lock_guard scoped_lock(m_mutex);
102
103 check();
104 check_init();
105
106 if (get_rel_objects(name, upcast_unregistered, vec))
107 return true;
108 }
109
110 if (first_call)
111 return get_algo_objects(name, vec);
112
113 return false;
114 }
bool get_rel_objects(const std::string &name, bool upcast_unregistered, std::vector< const DalObject * > &objs) const
Read relationship values as DAL objects using DAL factory.
Definition DalObject.cpp:8
std::mutex m_mutex
Used to protect changes of DAL object.
bool get_algo_objects(const std::string &name, std::vector< const DalObject * > &objs) const
Run algorithm and return result as DAL objects using DAL factory.
Definition DalObject.cpp:25
void check_init() const
Check and initialize object if necessary.

◆ get() [4/4]

bool dunedaq::appmodel::CTBSockets::get ( const std::string & name,
std::vector< const dunedaq::conffwk::DalObject * > & vec,
bool upcast_unregistered,
bool first_call ) const
protected

◆ get_ctb_json() [1/2]

nlohmann::json CTBSockets::get_ctb_json ( std::optional< std::string > socket_host = std::nullopt) const

Definition at line 416 of file CTBApplication.cpp.

416 {
417
418 nlohmann::json json;
419 json["receiver"] = get_receiver() -> get_ctb_json(socket_host);
420 json["monitor"] = get_monitor() -> get_ctb_json(socket_host);
421 json["statistics"] = get_statistics() -> to_json(false, true);
422 return json;
423
424}
const dunedaq::appmodel::CTBReceiverSocket * get_receiver() const
Get "receiver" relationship value.
const dunedaq::appmodel::CTBStatisticsSocket * get_statistics() const
Get "statistics" relationship value.
const dunedaq::appmodel::CTBMonitorSocket * get_monitor() const
Get "monitor" relationship value.
nlohmann::json get_ctb_json(std::optional< std::string > socket_host=std::nullopt) const
void to_json(data_t &j, const EndpointLocation &obj)
Definition Nljs.hpp:20

◆ get_ctb_json() [2/2]

nlohmann::json dunedaq::appmodel::CTBSockets::get_ctb_json ( std::optional< std::string > socket_host = std::nullopt) const

◆ get_monitor() [1/2]

const dunedaq::appmodel::CTBMonitorSocket * dunedaq::appmodel::CTBSockets::get_monitor ( ) const
inline

Get "monitor" relationship value.

Returns
the relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 143 of file CTBSockets.hpp.

144 {
145 std::lock_guard scoped_lock(m_mutex);
146 check();
147 check_init();
148 return m_monitor;
149 }

◆ get_monitor() [2/2]

const dunedaq::appmodel::CTBMonitorSocket * dunedaq::appmodel::CTBSockets::get_monitor ( ) const
inline

Get "monitor" relationship value.

Returns
the relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 143 of file CTBSockets.hpp.

144 {
145 std::lock_guard scoped_lock(m_mutex);
146 check();
147 check_init();
148 return m_monitor;
149 }

◆ get_receiver() [1/2]

const dunedaq::appmodel::CTBReceiverSocket * dunedaq::appmodel::CTBSockets::get_receiver ( ) const
inline

Get "receiver" relationship value.

Returns
the relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 112 of file CTBSockets.hpp.

113 {
114 std::lock_guard scoped_lock(m_mutex);
115 check();
116 check_init();
117 if (!m_receiver)
118 {
119 std::ostringstream text;
120 text << "relationship \"" << s_receiver << "\" of object " << this << " is not set";
121 throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
122 }
123 return m_receiver;
124 }
#define ERS_HERE
Generic configuration exception.

◆ get_receiver() [2/2]

const dunedaq::appmodel::CTBReceiverSocket * dunedaq::appmodel::CTBSockets::get_receiver ( ) const
inline

Get "receiver" relationship value.

Returns
the relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 112 of file CTBSockets.hpp.

113 {
114 std::lock_guard scoped_lock(m_mutex);
115 check();
116 check_init();
117 if (!m_receiver)
118 {
119 std::ostringstream text;
120 text << "relationship \"" << s_receiver << "\" of object " << this << " is not set";
121 throw dunedaq::conffwk::Generic(ERS_HERE, text.str().c_str());
122 }
123 return m_receiver;
124 }

◆ get_statistics() [1/2]

const dunedaq::appmodel::CTBStatisticsSocket * dunedaq::appmodel::CTBSockets::get_statistics ( ) const
inline

Get "statistics" relationship value.

Returns
the relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 168 of file CTBSockets.hpp.

169 {
170 std::lock_guard scoped_lock(m_mutex);
171 check();
172 check_init();
173 return m_statistics;
174 }

◆ get_statistics() [2/2]

const dunedaq::appmodel::CTBStatisticsSocket * dunedaq::appmodel::CTBSockets::get_statistics ( ) const
inline

Get "statistics" relationship value.

Returns
the relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 168 of file CTBSockets.hpp.

169 {
170 std::lock_guard scoped_lock(m_mutex);
171 check();
172 check_init();
173 return m_statistics;
174 }

◆ init() [1/2]

void dunedaq::appmodel::CTBSockets::init ( bool init_children)
protectedvirtual

Initialize object (method generated by genconffwk)

Parameters
init_childrenif true, initialize referenced objects

Implements dunedaq::conffwk::DalObject.

Definition at line 67 of file CTBSockets.cpp.

68 {
69 p_was_read = true;
71 TLOG_DEBUG(5) << "read object " << this << " (class " << s_class_name << ')';
72
73 try {
77 }
78 catch (dunedaq::conffwk::Exception & ex) {
79 throw_init_ex(ex);
80 }
81 }
void throw_init_ex(dunedaq::conffwk::Exception &ex)
throw object initialisation exception (i.e.
Definition DalObject.cpp:74
void increment_read() noexcept
DalRegistry & p_registry
Configuration object.
bool p_was_read
is true, if the object was read
ConfigObject p_obj
Config object used by given template object.
const T * _ref(ConfigObject &obj, const std::string &name, bool read_children)
Get signle value of object's relation and instantiate result with it (multi-thread safe).
#define TLOG_DEBUG(lvl,...)
Definition Logging.hpp:112

◆ init() [2/2]

virtual void dunedaq::appmodel::CTBSockets::init ( bool init_children)
protectedvirtual

Initialize object (method generated by genconffwk)

Parameters
init_childrenif true, initialize referenced objects

Implements dunedaq::conffwk::DalObject.

◆ print() [1/2]

void dunedaq::appmodel::CTBSockets::print ( unsigned int offset,
bool print_header,
std::ostream & s ) const
virtual

Print details of the CTBSockets object.

Parameters are:

Parameters
offsetnumber of spaces to shift object right (useful to print nested objects)
print_headerif false, do not print object header (to print attributes of base classes)
soutput stream

Implements dunedaq::conffwk::DalObject.

Definition at line 44 of file CTBSockets.cpp.

45 {
46 check_init();
47
48 try {
49 const std::string str(indent+2, ' ');
50
51 if (print_header)
52 p_hdr(s, indent, s_class_name, "dunedaq::appmodel");
53
54
55 // print direct relationships
56
60 }
61 catch (dunedaq::conffwk::Exception & ex) {
63 }
64 }
void p_hdr(std::ostream &s, unsigned int indent, const std::string &cl, const char *nm=nullptr) const
print object headers
Definition DalObject.cpp:65
static void p_error(std::ostream &s, dunedaq::conffwk::Exception &ex)
print error text
Definition DalObject.cpp:59
void p_sv_rel(std::ostream &s, const std::string &str, const std::string &name, const DalObject *obj)
print weak single-value relationship

◆ print() [2/2]

virtual void dunedaq::appmodel::CTBSockets::print ( unsigned int offset,
bool print_header,
std::ostream & s ) const
virtual

Print details of the CTBSockets object.

Parameters are:

Parameters
offsetnumber of spaces to shift object right (useful to print nested objects)
print_headerif false, do not print object header (to print attributes of base classes)
soutput stream

Implements dunedaq::conffwk::DalObject.

◆ set_monitor() [1/2]

void dunedaq::appmodel::CTBSockets::set_monitor ( const dunedaq::appmodel::CTBMonitorSocket * value)

Set "monitor" relationship value.

Parameters
valuenew relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 121 of file CTBSockets.cpp.

122 {
123 _set_object(s_monitor, value);
124 }
void _set_object(const std::string &name, const T *value)
Helper method for generated set single-value relationship methods.

◆ set_monitor() [2/2]

void dunedaq::appmodel::CTBSockets::set_monitor ( const dunedaq::appmodel::CTBMonitorSocket * value)

Set "monitor" relationship value.

Parameters
valuenew relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

◆ set_receiver() [1/2]

void dunedaq::appmodel::CTBSockets::set_receiver ( const dunedaq::appmodel::CTBReceiverSocket * value)

Set "receiver" relationship value.

Parameters
valuenew relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 116 of file CTBSockets.cpp.

117 {
118 _set_object(s_receiver, value);
119 }

◆ set_receiver() [2/2]

void dunedaq::appmodel::CTBSockets::set_receiver ( const dunedaq::appmodel::CTBReceiverSocket * value)

Set "receiver" relationship value.

Parameters
valuenew relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

◆ set_statistics() [1/2]

void dunedaq::appmodel::CTBSockets::set_statistics ( const dunedaq::appmodel::CTBStatisticsSocket * value)

Set "statistics" relationship value.

Parameters
valuenew relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Definition at line 126 of file CTBSockets.cpp.

127 {
129 }

◆ set_statistics() [2/2]

void dunedaq::appmodel::CTBSockets::set_statistics ( const dunedaq::appmodel::CTBStatisticsSocket * value)

Set "statistics" relationship value.

Parameters
valuenew relationship value
Exceptions
dunedaq::conffwk::Generic,dunedaq::conffwk::DeletedObject

Friends And Related Symbol Documentation

◆ conffwk::Configuration

Definition at line 38 of file CTBSockets.hpp.

◆ conffwk::DalFactory

conffwk::DalFactory
friend

Definition at line 40 of file CTBSockets.hpp.

◆ conffwk::DalObject

Definition at line 39 of file CTBSockets.hpp.

◆ conffwk::DalRegistry

Definition at line 41 of file CTBSockets.hpp.

Member Data Documentation

◆ m_monitor

const dunedaq::appmodel::CTBMonitorSocket * dunedaq::appmodel::CTBSockets::m_monitor
private

Definition at line 88 of file CTBSockets.hpp.

◆ m_receiver

const dunedaq::appmodel::CTBReceiverSocket * dunedaq::appmodel::CTBSockets::m_receiver
private

Definition at line 87 of file CTBSockets.hpp.

◆ m_statistics

const dunedaq::appmodel::CTBStatisticsSocket * dunedaq::appmodel::CTBSockets::m_statistics
private

Definition at line 89 of file CTBSockets.hpp.

◆ s_class_name

static const std::string & dunedaq::appmodel::CTBSockets::s_class_name
static

The name of the configuration class.

Definition at line 53 of file CTBSockets.hpp.

◆ s_monitor

static const std::string dunedaq::appmodel::CTBSockets::s_monitor = "monitor"
inlinestatic

Definition at line 97 of file CTBSockets.hpp.

◆ s_receiver

static const std::string dunedaq::appmodel::CTBSockets::s_receiver = "receiver"
inlinestatic

Definition at line 96 of file CTBSockets.hpp.

◆ s_statistics

static const std::string dunedaq::appmodel::CTBSockets::s_statistics = "statistics"
inlinestatic

Definition at line 98 of file CTBSockets.hpp.


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