DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
QueueRegistry.hxx
Go to the documentation of this file.
3
4#include <cxxabi.h>
5#include <memory>
6
7// Declarations
8namespace dunedaq::iomanager {
9
10template<typename T>
11std::shared_ptr<Queue<T>>
12QueueRegistry::get_queue(const std::string& name)
13{
14
15 auto queue_it = m_queue_registry.find(name);
16 if (queue_it != m_queue_registry.end()) {
17 auto queuePtr = std::dynamic_pointer_cast<Queue<T>>(queue_it->second.m_instance);
18
19 if (!queuePtr) {
20 // TODO: John Freeman (jcfree@fnal.gov), Jun-23-2020. Add checks for demangling status. Timescale 2 weeks.
21 int status = -999;
22 std::string realname_target = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status);
23 std::string realname_source = abi::__cxa_demangle(queue_it->second.m_type->name(), nullptr, nullptr, &status);
24
25 throw QueueTypeMismatch(ERS_HERE, name, realname_source, realname_target);
26 }
27
28 return queuePtr;
29 }
30
31 const confmodel::Queue* qptr = nullptr;
32 for(auto& qcfg : m_queue_configs) {
33 if (qcfg->UID() == name) {
34 qptr = qcfg;
35 break;
36 }
37 }
38 if (qptr != nullptr) {
39 QueueEntry entry = { qptr, &typeid(T), create_queue<T>(qptr) };
40 m_queue_registry[name] = entry;
41 return std::dynamic_pointer_cast<Queue<T>>(entry.m_instance);
42
43 } else {
44 // TODO: John Freeman (jcfree@fnal.gov), Jun-23-2020. Add checks for demangling status. Timescale 2 weeks.
45 int status = -999;
46 std::string realname_target = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status);
47 throw QueueNotFound(ERS_HERE, name, realname_target);
48 }
49}
50
51template<typename T>
52std::shared_ptr<QueueBase>
54{
55 std::shared_ptr<QueueBase> queue;
56 auto type = config->get_queue_type();
58 queue = std::make_shared<StdDeQueue<T>>(config->UID(), config->get_capacity());
60 queue = std::make_shared<FollySPSCQueue<T>>(config->UID(), config->get_capacity());
62 queue = std::make_shared<FollyMPMCQueue<T>>(config->UID(), config->get_capacity());
63 } else {
64 throw QueueTypeUnknown(ERS_HERE, config->get_queue_type());
65 }
66
67 m_opmon_link->register_node(config->UID(), queue);
68
69 return queue;
70}
71
72} // namespace dunedaq::iomanager
#define ERS_HERE
const std::string & UID() const noexcept
const std::string & get_queue_type() const
Get "queue_type" attribute value. Type of queue.
Definition Queue.hpp:139
uint32_t get_capacity() const
Get "capacity" attribute value.
Definition Queue.hpp:96
std::map< std::string, QueueEntry > m_queue_registry
std::shared_ptr< QueueBase > create_queue(const confmodel::Queue *config)
std::vector< const confmodel::Queue * > m_queue_configs
std::shared_ptr< opmonlib::OpMonLink > m_opmon_link
std::shared_ptr< Queue< T > > get_queue(const std::string &name)
Get a handle to a Queue.
static const std::string KStdDeQueue
Definition Queue.hpp:126
static const std::string KFollySPSCQueue
Definition Queue.hpp:127
static const std::string KFollyMPMCQueue
Definition Queue.hpp:128