#include <DataMoveCallbackRegistry.hpp>
◆ DataMoveCallbackRegistry() [1/3]
◆ DataMoveCallbackRegistry() [2/3]
◆ DataMoveCallbackRegistry() [3/3]
| dunedaq::datahandlinglibs::DataMoveCallbackRegistry::DataMoveCallbackRegistry |
( |
| ) |
|
|
inlineprivate |
◆ get()
Definition at line 50 of file DataMoveCallbackRegistry.hpp.
51 {
54
56 }
DataMoveCallbackRegistry()
static std::shared_ptr< DataMoveCallbackRegistry > s_instance
◆ get_callback()
template<typename DataType >
| std::shared_ptr< std::function< void(DataType &&)> > dunedaq::datahandlinglibs::DataMoveCallbackRegistry::get_callback |
( |
const appmodel::DataMoveCallbackConf * | conf | ) |
|
|
inline |
Gets the callback function registered with the given configuration.
- Template Parameters
-
| DataType | The expected parameter type of the callback function |
- Parameters
-
| conf | The configuration object containing the unique identifier for the callback |
- Returns
- A shared pointer to the callback function
- Exceptions
-
| GenericConfigurationError | if the registered callback function's parameter type does not match DataType |
Definition at line 25 of file DataMoveCallbackRegistry.hxx.
26{
27 std::lock_guard<std::mutex> guard(
m_mutex);
28 std::string id = conf->UID();
30 TLOG() <<
"Providing DataMoveCallback with ID: " << id;
31 if (
auto callback =
dynamic_cast<DataMoveCallback<DataType>*
>(
m_callback_map[
id].
get()); callback !=
nullptr) {
32 return callback->m_callback;
33 } else {
34
35
38 std::format("Callback cast failed for function signature with datatypes (expected vs. registered) : {} vs. {}",
39 typeid(DataMoveCallback<DataType>).name(),
41 }
42 } else {
43 TLOG() <<
"No callback registered with ID: " <<
id <<
" Returning nullptr.";
44 return nullptr;
45 }
46}
static std::shared_ptr< DataMoveCallbackRegistry > get()
std::map< std::string, std::shared_ptr< CallbackConcept > > m_callback_map
SourceID[" << sourceid << "] Command daqdataformats::SourceID Readout Initialization std::string initerror Configuration std::string conferror GenericConfigurationError
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ register_callback()
template<typename DataType >
| void dunedaq::datahandlinglibs::DataMoveCallbackRegistry::register_callback |
( |
const appmodel::DataMoveCallbackConf * | conf, |
|
|
std::function< void(DataType &&)> | callback ) |
|
inline |
Registers a callback function with a configuration object.
- Template Parameters
-
| DataType | The parameter type of the callback function |
- Parameters
-
| conf | The configuration object containing the unique identifier for the callback |
| callback | The callback function to register |
Definition at line 11 of file DataMoveCallbackRegistry.hxx.
12{
13 std::lock_guard<std::mutex> guard(
m_mutex);
14 std::string id = conf->UID();
16 TLOG() <<
"Registering DataMoveCallback with ID: " << id;
17 m_callback_map[id] = std::make_shared<DataMoveCallback<DataType>>(DataMoveCallback(
id, callback));
18 } else {
19 TLOG() <<
"Callback is already registered with ID: " <<
id <<
" Ignoring this registration.";
20 }
21}
◆ m_callback_map
| std::map<std::string, std::shared_ptr<CallbackConcept> > dunedaq::datahandlinglibs::DataMoveCallbackRegistry::m_callback_map |
|
private |
◆ m_mutex
| std::mutex dunedaq::datahandlinglibs::DataMoveCallbackRegistry::m_mutex |
|
private |
◆ s_instance
The documentation for this class was generated from the following files: