GCBM
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBMAggregatorCsvWriter Class Reference

#include <cbmaggregatorcsvwriter.h>

Inheritance diagram for CBMAggregatorCsvWriter:
Inheritance graph
Collaboration diagram for CBMAggregatorCsvWriter:
Collaboration graph

Public Member Functions

 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)
 
virtual ~CBMAggregatorCsvWriter ()=default
 
void configure (const DynamicObject &config) override
 
void subscribe (NotificationCenter &notificationCenter) override
 
flint::ModuleTypes moduleType () override
 
void doSystemInit () override
 
void doLocalDomainInit () override
 
void doSystemShutdown () override
 
- Public Member Functions inherited from CBMModuleBase
virtual ~CBMModuleBase ()=default
 
void onSystemInit () override
 
void onSystemShutdown () override
 
void onLocalDomainInit () override
 
void onLocalDomainShutdown () override
 
void onLocalDomainProcessingUnitInit () override
 
void onLocalDomainProcessingUnitShutdown () override
 
void onPreTimingSequence () override
 
void onTimingInit () override
 
void onTimingPrePostInit () override
 
void onTimingPostInit () override
 
void onTimingPostInit2 () override
 
void onTimingShutdown () override
 
void onTimingStep () override
 
void onTimingPreEndStep () override
 
void onTimingEndStep () override
 
void onTimingPostStep () override
 
void onOutputStep () override
 
void onPrePostDisturbanceEvent () override
 
void onPostDisturbanceEvent () override
 
void onPostDisturbanceEvent2 () override
 
void onError (std::string msg) override
 
void onDisturbanceEvent (DynamicVar e) override
 
void onPostNotification (short preMessageSignal) override
 
virtual void doLocalDomainShutdown ()
 
virtual void doLocalDomainProcessingUnitInit ()
 
virtual void doLocalDomainProcessingUnitShutdown ()
 
virtual void doPreTimingSequence ()
 
virtual void doTimingInit ()
 
virtual void doTimingPrePostInit ()
 
virtual void doTimingPostInit ()
 
virtual void doTimingPostInit2 ()
 
virtual void doTimingShutdown ()
 
virtual void doTimingStep ()
 
virtual void doTimingPreEndStep ()
 
virtual void doTimingEndStep ()
 
virtual void doTimingPostStep ()
 
virtual void doOutputStep ()
 
virtual void doError (std::string msg)
 
virtual void doDisturbanceEvent (DynamicVar)
 
virtual void doPrePostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent2 ()
 
virtual void doPostNotification (short preMessageSignal)
 

Private Member Functions

template<typename TAccumulator >
void load (const std::string &outputPath, const std::string &outputFilename, std::shared_ptr< std::vector< std::string >> classifierNames, std::shared_ptr< TAccumulator > dataDimension)
 

Private Attributes

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
 
std::shared_ptr< const flint::SpatialLocationInfo > _spatialLocationInfo
 
std::string _outputPath
 
Int64 _jobId
 
bool _isPrimaryAggregator
 
bool _separateYears
 

Constructor & Destructor Documentation

◆ 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 
)

◆ ~CBMAggregatorCsvWriter()

virtual ~CBMAggregatorCsvWriter ( )
virtualdefault

Member Function Documentation

◆ configure()

void configure ( const DynamicObject &  config)
override

Configuration function

Assign CBMFlatFile._outputPath value of "outptut_path" in parameter config,
CBMFlatFile._separateYears value of "separate_years", if it exists in parameter config

Parameters
configDynamicObject&
Returns
void

◆ doLocalDomainInit()

void doLocalDomainInit ( )
overridevirtual

Assign CBMAggregatorCsvWriter._jobId the value of variable "job_id" in _landUnitData, if it exists, else to 0

Returns
void

Reimplemented from CBMModuleBase.

◆ doSystemInit()

void doSystemInit ( )
overridevirtual

If CBMAggregatorCsvWriter._isPrimaryAggregator is true, then create output directories

Parameters
pathstring&
headerstring&
Returns
void
Exceptions
FileExistsException&if file already exists

Reimplemented from CBMModuleBase.

◆ doSystemShutdown()

void doSystemShutdown ( )
overridevirtual

If CBMAggregatorCsvWriter._isPrimaryAggregator is true and if, CBMAggregatorCsvWriter._classifierNames is not empty, load the flux, pool, error, age and disturbance data

Returns
void

Reimplemented from CBMModuleBase.

◆ load()

void load ( const std::string &  outputPath,
const std::string &  outputFilename,
std::shared_ptr< std::vector< std::string >>  classifierNames,
std::shared_ptr< TAccumulator >  dataDimension 
)
private

Inserting Records

Assign variable records as dataDimension->records(). If records is empty, return
If CBMAggregatorCsvWriter._separateYears is false, create output directories and write each record to the output stream
Else write the records to the output stream grouped based on the year

Parameters
outputPathstring&
outputFilenamestring&
classifierNamesshared_ptr<vector<string>>
Template Parameters
dataDimensionshared_ptr<TAccumulator>
Returns
void
Exceptions
FileExistsException&if the file already exists

◆ moduleType()

flint::ModuleTypes moduleType ( )
override

◆ subscribe()

void subscribe ( NotificationCenter &  notificationCenter)
override

Subscribe to the signals SystemInit, LocalDomainInit and SystemShutdown

Parameters
notificationCenterNotificationCenter&
Returns
void

Member Data Documentation

◆ _ageDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatAgeAreaRecord> > _ageDimension
private

◆ _classifierNames

std::shared_ptr<std::vector<std::string> > _classifierNames
private

◆ _disturbanceDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatDisturbanceRecord> > _disturbanceDimension
private

◆ _errorDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatErrorRecord> > _errorDimension
private

◆ _fluxDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatFluxRecord> > _fluxDimension
private

◆ _isPrimaryAggregator

bool _isPrimaryAggregator
private

◆ _jobId

Int64 _jobId
private

◆ _outputPath

std::string _outputPath
private

◆ _poolDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatPoolRecord> > _poolDimension
private

◆ _separateYears

bool _separateYears
private

◆ _spatialLocationInfo

std::shared_ptr<const flint::SpatialLocationInfo> _spatialLocationInfo
private

The documentation for this class was generated from the following files: