Line data Source code
1 : /**
2 : * @file ListStorage.hpp
3 : *
4 : * ListStorage defines the data storage class used by the listrev modules
5 : *
6 : * This is part of the DUNE DAQ Software Suite, copyright 2020.
7 : * Licensing/copyright details are in the COPYING file that you should have
8 : * received with this code.
9 : */
10 :
11 : #ifndef LISTREV_SRC_LISTSTORAGE_HPP_
12 : #define LISTREV_SRC_LISTSTORAGE_HPP_
13 :
14 : #include "ListWrapper.hpp"
15 :
16 : #include <map>
17 : #include <mutex>
18 : #include <vector>
19 :
20 : namespace dunedaq::listrev {
21 :
22 : class ListStorage
23 : {
24 : public:
25 4 : ListStorage() {}
26 :
27 : bool has_list(const int& id) const;
28 : IntList get_list(const int& id) const;
29 : void add_list(IntList list, bool ignoreDuplicates = false);
30 :
31 : size_t size() const;
32 1 : void set_capacity(const size_t& capacity) { m_capacity = capacity; }
33 1 : size_t capacity() const { return m_capacity; }
34 : void flush();
35 :
36 : private:
37 : std::map<int, IntList> m_lists;
38 : mutable std::mutex m_lists_mutex;
39 : size_t m_capacity{ 1000 };
40 : };
41 : } // namespace dunedaq::listrev
42 :
43 : #endif // LISTREV_SRC_LISTSTORAGE_HPP_
|