Line data Source code
1 : /**
2 : * @file DefaultParserImpl.hpp FELIX's packetformat default block/chunk parser
3 : *
4 : * This is part of the DUNE DAQ , copyright 2020.
5 : * Licensing/copyright details are in the COPYING file that you should have
6 : * received with this code.
7 : */
8 : #ifndef FLXLIBS_SRC_DEFAULTPARSERIMPL_HPP_
9 : #define FLXLIBS_SRC_DEFAULTPARSERIMPL_HPP_
10 :
11 : // 3rdparty, external
12 : #include "packetformat/block_format.hpp"
13 : #include "packetformat/block_parser.hpp"
14 :
15 : #include "FelixIssues.hpp"
16 : //#include "ReadoutTypes.hpp"
17 : #include "FelixStatistics.hpp"
18 :
19 : // From STD
20 : #include <functional>
21 : #include <iomanip>
22 :
23 : namespace dunedaq::flxlibs {
24 :
25 : class DefaultParserImpl : public felix::packetformat::ParserOperations
26 : {
27 : public:
28 : DefaultParserImpl();
29 : ~DefaultParserImpl();
30 : DefaultParserImpl(const DefaultParserImpl&) = delete; ///< DefaultParserImpl is not copy-constructible
31 : DefaultParserImpl& operator=(const DefaultParserImpl&) = delete; ///< DefaultParserImpl is not copy-assignable
32 : DefaultParserImpl(DefaultParserImpl&&) = delete; ///< DefaultParserImpl is not move-constructible
33 : DefaultParserImpl& operator=(DefaultParserImpl&&) = delete; ///< DefaultParserImpl is not move-assignable
34 :
35 : stats::ParserStats& get_stats();
36 :
37 : // Public functions for re-bind
38 : std::function<void(const felix::packetformat::chunk& chunk)> process_chunk_func;
39 : std::function<void(const felix::packetformat::shortchunk& shortchunk)> process_shortchunk_func;
40 : std::function<void(const felix::packetformat::subchunk& subchunk)> process_subchunk_func;
41 : std::function<void(const felix::packetformat::block& block)> process_block_func;
42 : std::function<void(const felix::packetformat::chunk& chunk)> process_chunk_with_error_func;
43 : std::function<void(const felix::packetformat::subchunk& subchunk)> process_subchunk_with_error_func;
44 : std::function<void(const felix::packetformat::shortchunk& shortchunk)> process_shortchunk_with_error_func;
45 : std::function<void(const felix::packetformat::block& block)> process_block_with_error_func;
46 :
47 : // Implementation of ParserOperations: They invoke the functions above
48 : void chunk_processed(const felix::packetformat::chunk& chunk);
49 : void shortchunk_processed(const felix::packetformat::shortchunk& shortchunk);
50 : void subchunk_processed(const felix::packetformat::subchunk& subchunk);
51 : void block_processed(const felix::packetformat::block& block);
52 : void chunk_processed_with_error(const felix::packetformat::chunk& chunk);
53 : void subchunk_processed_with_error(const felix::packetformat::subchunk& subchunk);
54 : void shortchunk_process_with_error(const felix::packetformat::shortchunk& shortchunk);
55 : void block_processed_with_error(const felix::packetformat::block& block);
56 :
57 : private:
58 : // Default/empty implementations: No-op "processing"
59 0 : void process_chunk(const felix::packetformat::chunk& /*chunk*/) {}
60 0 : void process_shortchunk(const felix::packetformat::shortchunk& /*shortchunk*/) {}
61 0 : void process_subchunk(const felix::packetformat::subchunk& /*subchunk*/) {}
62 0 : void process_block(const felix::packetformat::block& /*block*/) {}
63 0 : void process_chunk_with_error(const felix::packetformat::chunk& /*chunk*/) {}
64 0 : void process_subchunk_with_error(const felix::packetformat::subchunk& /*subchunk*/) {}
65 0 : void process_shortchunk_with_error(const felix::packetformat::shortchunk& /*shortchunk*/) {}
66 0 : void process_block_with_error(const felix::packetformat::block& /*block*/) {}
67 :
68 : // Statistics
69 : stats::ParserStats m_stats;
70 : };
71 :
72 : } // namespace dunedaq::flxlibs
73 :
74 : #endif // FLXLIBS_SRC_DEFAULTPARSERIMPL_HPP_
|