GCBM
cbmaggregatorcsvwriter.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMAGGREGATORCSVWRITER_H_
2 #define MOJA_MODULES_CBM_CBMAGGREGATORCSVWRITER_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
7 
8 #include <moja/flint/spatiallocationinfo.h>
9 
10 #include <vector>
11 
12 namespace Poco {
13  class File;
14  class FileOutputStream;
15  class TeeOutputStream;
16 }
17 
18 namespace moja {
19 namespace flint {
20  template<class TPersistable, class TRecord>
22 }
23 
24 namespace modules {
25 namespace cbm {
26 
27  class CBMFlatFile {
28  public:
29  CBMFlatFile(const std::string& path, const std::string& header);
30 
31  virtual ~CBMFlatFile() = default;
32 
33  void write(const std::string& text);
34  void save();
35 
36  private:
37  std::string _path;
38  std::string _tempPath;
39  std::unique_ptr<Poco::File> _outputFile;
40  std::unique_ptr<Poco::FileOutputStream> _streamFile;
41  std::unique_ptr<Poco::TeeOutputStream> _outputStream;
42  };
43 
44  class CBM_API CBMAggregatorCsvWriter : public CBMModuleBase {
45  public:
52  std::shared_ptr<std::vector<std::string>> classifierNames,
53  bool isPrimary = false)
54  : CBMModuleBase(),
55  _fluxDimension(fluxDimension),
56  _poolDimension(poolDimension),
57  _errorDimension(errorDimension),
58  _ageDimension(ageDimension),
59  _disturbanceDimension(disturbanceDimension),
60  _classifierNames(classifierNames),
61  _isPrimaryAggregator(isPrimary),
62  _separateYears(false) {}
63 
64  virtual ~CBMAggregatorCsvWriter() = default;
65 
66  void configure(const DynamicObject& config) override;
67  void subscribe(NotificationCenter& notificationCenter) override;
68 
69  flint::ModuleTypes moduleType() override { return flint::ModuleTypes::System; };
70 
71  void doSystemInit() override;
72  void doLocalDomainInit() override;
73  void doSystemShutdown() override;
74 
75  private:
76  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatFluxRecord>> _fluxDimension;
77  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatPoolRecord>> _poolDimension;
78  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatErrorRecord>> _errorDimension;
79  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatAgeAreaRecord>> _ageDimension;
80  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatDisturbanceRecord>> _disturbanceDimension;
81  std::shared_ptr<std::vector<std::string>> _classifierNames;
82 
83  std::shared_ptr<const flint::SpatialLocationInfo> _spatialLocationInfo;
84 
85  std::string _outputPath;
86  Int64 _jobId;
89 
90  template<typename TAccumulator>
91  void load(const std::string& outputPath,
92  const std::string& outputFilename,
93  std::shared_ptr<std::vector<std::string>> classifierNames,
94  std::shared_ptr<TAccumulator> dataDimension);
95  };
96 
97 }}} // namespace moja::modules::cbm
98 
99 #endif // MOJA_MODULES_CBM_CBMAGGREGATORCSVWRITER_H_
moja::modules::cbm::CBMAggregatorCsvWriter::_separateYears
bool _separateYears
Definition: cbmaggregatorcsvwriter.h:88
moja::modules::cbm::CBMAggregatorCsvWriter::_ageDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatAgeAreaRecord > > _ageDimension
Definition: cbmaggregatorcsvwriter.h:79
moja::modules::cbm
Definition: ageclasshelper.cpp:12
flatrecord.h
moja::flint::RecordAccumulatorWithMutex2
Definition: cbmaggregatorcsvwriter.h:21
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::CBMFlatFile::_streamFile
std::unique_ptr< Poco::FileOutputStream > _streamFile
Definition: cbmaggregatorcsvwriter.h:40
moja::modules::cbm::CBMFlatFile::save
void save()
Definition: cbmaggregatorcsvwriter.cpp:69
moja::modules::cbm::CBMAggregatorCsvWriter
Definition: cbmaggregatorcsvwriter.h:44
moja::modules::cbm::CBMFlatFile::CBMFlatFile
CBMFlatFile(const std::string &path, const std::string &header)
Definition: cbmaggregatorcsvwriter.cpp:44
moja::modules::cbm::CBMAggregatorCsvWriter::_isPrimaryAggregator
bool _isPrimaryAggregator
Definition: cbmaggregatorcsvwriter.h:87
Poco
Definition: cbmaggregatorcsvwriter.h:12
moja::modules::cbm::CBMAggregatorCsvWriter::_classifierNames
std::shared_ptr< std::vector< std::string > > _classifierNames
Definition: cbmaggregatorcsvwriter.h:81
moja::flint
Definition: cbmaggregatorcsvwriter.h:19
moja::modules::cbm::CBMFlatFile::_outputFile
std::unique_ptr< Poco::File > _outputFile
Definition: cbmaggregatorcsvwriter.h:39
moja::modules::cbm::CBMFlatFile::_outputStream
std::unique_ptr< Poco::TeeOutputStream > _outputStream
Definition: cbmaggregatorcsvwriter.h:41
moja::modules::cbm::CBMAggregatorCsvWriter::moduleType
flint::ModuleTypes moduleType() override
Definition: cbmaggregatorcsvwriter.h:69
moja::modules::cbm::CBMFlatFile::~CBMFlatFile
virtual ~CBMFlatFile()=default
moja::modules::cbm::CBMFlatFile::_tempPath
std::string _tempPath
Definition: cbmaggregatorcsvwriter.h:38
moja::modules::cbm::CBMAggregatorCsvWriter::_fluxDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatFluxRecord > > _fluxDimension
Definition: cbmaggregatorcsvwriter.h:76
moja::modules::cbm::CBMAggregatorCsvWriter::_spatialLocationInfo
std::shared_ptr< const flint::SpatialLocationInfo > _spatialLocationInfo
Definition: cbmaggregatorcsvwriter.h:83
moja::modules::cbm::CBMFlatFile::write
void write(const std::string &text)
Definition: cbmaggregatorcsvwriter.cpp:60
moja::modules::cbm::CBMFlatFile::_path
std::string _path
Definition: cbmaggregatorcsvwriter.h:37
moja::modules::cbm::CBMAggregatorCsvWriter::_jobId
Int64 _jobId
Definition: cbmaggregatorcsvwriter.h:86
moja::modules::cbm::CBMFlatFile
Definition: cbmaggregatorcsvwriter.h:27
moja::modules::cbm::CBMAggregatorCsvWriter::_poolDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatPoolRecord > > _poolDimension
Definition: cbmaggregatorcsvwriter.h:77
moja::modules::cbm::CBMAggregatorCsvWriter::_disturbanceDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatDisturbanceRecord > > _disturbanceDimension
Definition: cbmaggregatorcsvwriter.h:80
moja::modules::cbm::CBMAggregatorCsvWriter::CBMAggregatorCsvWriter
CBMAggregatorCsvWriter(std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatFluxRecord >> fluxDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatPoolRecord >> poolDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatErrorRecord >> errorDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatAgeAreaRecord >> ageDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatDisturbanceRecord >> disturbanceDimension, std::shared_ptr< std::vector< std::string >> classifierNames, bool isPrimary=false)
Definition: cbmaggregatorcsvwriter.h:46
moja::modules::cbm::CBMAggregatorCsvWriter::_outputPath
std::string _outputPath
Definition: cbmaggregatorcsvwriter.h:85
moja
Definition: ageclasshelper.cpp:10
cbmmodulebase.h
moja::modules::cbm::CBMAggregatorCsvWriter::_errorDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatErrorRecord > > _errorDimension
Definition: cbmaggregatorcsvwriter.h:78