Line data Source code
1 : /**
2 : * @file QueueRegistry.cpp
3 : *
4 : * The QueueRegistry class implementation
5 : *
6 : * This is part of the DUNE DAQ Application Framework, copyright 2020.
7 : * Licensing/copyright details are in the COPYING file that you should have
8 : * received with this code.
9 : */
10 :
11 : #include "iomanager/queue/QueueRegistry.hpp"
12 :
13 : #include <map>
14 : #include <memory>
15 : #include <set>
16 : #include <string>
17 : #include <vector>
18 :
19 : namespace dunedaq::iomanager {
20 :
21 : std::unique_ptr<QueueRegistry> QueueRegistry::s_instance = nullptr;
22 :
23 : QueueRegistry&
24 326 : QueueRegistry::get()
25 : {
26 326 : if (!s_instance) {
27 68 : s_instance.reset(new QueueRegistry());
28 : }
29 326 : return *s_instance;
30 : }
31 :
32 : void
33 55 : QueueRegistry::configure(const std::vector<const confmodel::Queue*>& configs, opmonlib::OpMonManager& mgr)
34 : {
35 55 : if (m_configured) {
36 1 : throw QueueRegistryConfigured(ERS_HERE);
37 : }
38 :
39 54 : m_queue_configs = configs;
40 :
41 54 : mgr.register_node("queues", m_opmon_link);
42 :
43 54 : m_configured = true;
44 54 : }
45 :
46 : bool
47 128 : QueueRegistry::has_queue(const std::string& uid, const std::string& data_type) const
48 : {
49 334 : for (auto& config : m_queue_configs) {
50 275 : if (config->UID() == uid && config->get_data_type() == data_type) {
51 69 : return true;
52 : }
53 : }
54 :
55 59 : return false;
56 : }
57 :
58 : std::set<std::string>
59 4 : QueueRegistry::get_datatypes(const std::string& uid) const
60 : {
61 4 : std::set<std::string> output;
62 :
63 12 : for (auto& config : m_queue_configs) {
64 8 : if (config->UID() == uid) {
65 2 : output.insert(config->get_data_type());
66 : }
67 : }
68 :
69 4 : return output;
70 0 : }
71 :
72 : } // namespace dunedaq::iomanager
|