-
Notifications
You must be signed in to change notification settings - Fork 0
/
Output.h
52 lines (39 loc) · 1.39 KB
/
Output.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Output definition module for simple analyzer
// Output is CSV format, optionally gzip-compressed
#ifndef PPODD_OUTPUT
#define PPODD_OUTPUT
#include "Podd.h"
#include <boost/iostreams/filtering_stream.hpp>
#include <string>
#include <vector>
#include <memory>
using ostrm_t = boost::iostreams::filtering_ostream;
class OutputElement {
public:
OutputElement() = default;
virtual ~OutputElement() = default;
[[nodiscard]] virtual const std::string& GetName() const = 0;
[[nodiscard]] virtual char GetType() const = 0;
virtual ostrm_t& write( ostrm_t& os, bool headerinfo ) const = 0;
};
class PlainVariable : public OutputElement {
public:
explicit PlainVariable( Variable* var ) : fVar(var) {}
[[nodiscard]] const std::string& GetName() const override;
[[nodiscard]] char GetType() const override { return (2<<5)+sizeof(double); }
ostrm_t& write( ostrm_t& os, bool headerinfo ) const override;
private:
Variable* fVar;
};
class EventNumberVariable : public OutputElement {
public:
explicit EventNumberVariable( const int& nev ) : fNev(nev) {}
[[nodiscard]] const std::string& GetName() const override { return fName; }
[[nodiscard]] char GetType() const override { return sizeof(int); }
ostrm_t& write( ostrm_t& os, bool headerinfo ) const override;
private:
static const std::string fName;
const int& fNev;
};
using voutp_t = std::vector<std::unique_ptr<OutputElement>>;
#endif