Jpp 19.3.0
the software that should make you happy
Loading...
Searching...
No Matches
parser.h
Go to the documentation of this file.
1#ifndef KM3NET_ADF_CONFIG_PARSER_H
2#define KM3NET_ADF_CONFIG_PARSER_H
3
4#include <map>
5#include <string>
6#include <vector>
7#include <optional>
8#include <iostream>
9
10class Parser
11{
12public:
13
14 Parser(const std::string& d, char t);
15
16 std::vector<std::string> Find(const std::string& tag);
17
18 std::string Find(const std::string& tag, size_t index,
19 std::string value = "");
20
21private:
22
24};
25
26template<typename T>
28{
29 int id;
31
32 bool operator==(const Waveform<T>& rhs) const
33 {
34 return rhs.id == id && samples == rhs.samples;
35 }
36 bool operator!=(const Waveform<T>& rhs) const
37 {
38 return !(*this == rhs);
39 }
40
41 friend std::ostream& operator<<(std::ostream& out, const Waveform<T>& waveform)
42 {
43 out << waveform.id << " " << waveform.samples.size() << " ";
44 for (const auto& sample : waveform.samples) {
45 out << sample << " ";
46 }
47 return out;
48 }
49};
50
51
52template<typename T>
53std::optional<Waveform<T>> parseWaveformSamples(const std::string& adf_waveform_line);
54
55/** A pair (id,threshold) representing basic information about one probe
56 */
58{
59 int id; // id of the probe (aka waveform)
60 int threshold; // quality threshold to apply to the cross correlation for that probe
61};
62
63/** The configuration information for one DOM
64 */
66{
67 int dom_id; // dom identifier
68 std::vector<ProbeConfig> probe_configs; // list of probe configurations
69 int write_to_debug_flag; // whether or not this DOM acoustics data should be output to a debug file
70};
71
72/** Parse a line that should contain the ADF configuration for a single DOM.
73 *
74 * @param line: the DOM configuration for a single DOM, which
75 * should be of the form :
76 *
77 * DOMID N id_0 threshold_0 ... id_(N-1) threshold_(N-1) debug_write
78 *
79 * where N is the number of (id,threshold) pairs to be found on the line
80 * (id = probe id, threshold = where to cut the signal)
81 *
82 * write_to_debug_flag is an integer that indicate (if non zero)
83 * to write the acoustic data from this DOM should be written to a debug file
84 *
85 * @returns a DOMConfig object if the line is valid DOM configuration,
86 * otherwise std::nullopt
87 *
88 */
89std::optional<DOMConfig> parseDOMConfiguration(const std::string& dom_configuration_line);
90
91#endif
std::vector< std::string > Find(const std::string &tag)
Definition parser.cc:23
Parser(const std::string &d, char t)
Definition parser.cc:7
std::multimap< std::string, std::string > mmap
Definition parser.h:23
std::optional< DOMConfig > parseDOMConfiguration(const std::string &dom_configuration_line)
Parse a line that should contain the ADF configuration for a single DOM.
Definition parser.cc:102
std::optional< Waveform< T > > parseWaveformSamples(const std::string &adf_waveform_line)
Definition parser.cc:46
The configuration information for one DOM.
Definition parser.h:66
int dom_id
Definition parser.h:67
std::vector< ProbeConfig > probe_configs
Definition parser.h:68
int write_to_debug_flag
Definition parser.h:69
A pair (id,threshold) representing basic information about one probe.
Definition parser.h:58
int threshold
Definition parser.h:60
std::vector< T > samples
Definition parser.h:30
friend std::ostream & operator<<(std::ostream &out, const Waveform< T > &waveform)
Definition parser.h:41
int id
Definition parser.h:29
bool operator==(const Waveform< T > &rhs) const
Definition parser.h:32
bool operator!=(const Waveform< T > &rhs) const
Definition parser.h:36