#include <DataMoveCallbackRegistry.hpp>
◆ DataMoveCallbackRegistry() [1/3]
◆ DataMoveCallbackRegistry() [2/3]
◆ DataMoveCallbackRegistry() [3/3]
dunedaq::datahandlinglibs::DataMoveCallbackRegistry::DataMoveCallbackRegistry |
( |
| ) |
|
|
inlineprivate |
◆ get()
Definition at line 48 of file DataMoveCallbackRegistry.hpp.
49 {
52
54 }
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 std::string & | id | ) |
|
|
inline |
Gets the callback function registered with the given ID.
- Template Parameters
-
DataType | The expected parameter type of the callback function |
- Parameters
-
id | 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 23 of file DataMoveCallbackRegistry.hxx.
24{
25 std::lock_guard<std::mutex> guard(
m_mutex);
27 TLOG() <<
"Providing DataMoveCallback with ID: " << id;
28 if (
auto callback =
dynamic_cast<DataMoveCallback<DataType>*
>(
m_callback_map[
id].
get()); callback !=
nullptr) {
29 return callback->m_callback;
30 } else {
31
34 std::format("Callback cast failed for function signature with datatypes (expected vs. registered) : {} vs. {}",
35 typeid(DataMoveCallback<DataType>).name(),
37 }
38 } else {
39 TLOG() <<
"No callback registered with ID: " <<
id <<
" Returning nullptr.";
40 return nullptr;
41 }
42}
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 std::string & | id, |
|
|
std::function< void(DataType &&)> | callback ) |
|
inline |
Definition at line 11 of file DataMoveCallbackRegistry.hxx.
11 {
12 std::lock_guard<std::mutex> guard(
m_mutex);
14 TLOG() <<
"Registering DataMoveCallback with ID: " << id;
15 m_callback_map[id] = std::make_shared<DataMoveCallback<DataType>>(DataMoveCallback(
id, callback));
16 } else {
17 TLOG() <<
"Callback is already registered with ID: " <<
id <<
" Ignoring this registration.";
18 }
19}
◆ 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: