Modular Megafauna Model 1.1.5
A physiological, dynamic herbivore simulator in C++.
Loading...
Searching...
No Matches
Fauna::Output::Aggregator Class Reference

Aggregates output from different simulation units over time. More...

#include <aggregator.h>

Public Member Functions

void add (const Date &today, const std::string &aggregation_unit, const CombinedData &output)
 Add output data of one SimulationUnit for completed simulation day. More...
 
const DateIntervalget_interval () const
 The time span covered by the currently added data. More...
 
std::vector< Datapointretrieve ()
 Get the aggregated data and reset object state. More...
 

Private Member Functions

Datapointget_datapoint (const std::string &agg_unit)
 Find the datapoint for a given aggregation unit (create it if missing). More...
 

Private Attributes

std::vector< Datapointdatapoints
 
DateInterval interval = DateInterval(Date(0, 0), Date(0, 0))
 

Detailed Description

Aggregates output from different simulation units over time.

Use this to aggregate output data for every day and from all simulation units until one output interval is completed and the data can be sent to the output writer.

All the Datapoint objects in this class have the same date interval because the purpose of this class is to produce one consistent set of aggregated data that is ready to be sent to output.

Member Function Documentation

◆ add()

void Aggregator::add ( const Date today,
const std::string &  aggregation_unit,
const CombinedData output 
)

Add output data of one SimulationUnit for completed simulation day.

Parameters
todayDate of the given output data.
aggregation_unitThe identifier for spatial aggregation: Fauna::Habitat::get_aggregation_unit().
outputThe data from one simulation in given day: Fauna::SimulationUnit::get_output().

◆ get_datapoint()

Datapoint & Aggregator::get_datapoint ( const std::string &  agg_unit)
private

Find the datapoint for a given aggregation unit (create it if missing).

◆ get_interval()

const DateInterval & Aggregator::get_interval ( ) const

The time span covered by the currently added data.

Exceptions
std::logic_errorIf no data have been added yet.

◆ retrieve()

std::vector< Datapoint > Aggregator::retrieve ( )

Get the aggregated data and reset object state.

Returns
The aggregated data as one datapoint per aggregation unit. All datapoints have the same date interval. If no data added yet, the vector is empty.

Member Data Documentation

◆ datapoints

std::vector<Datapoint> Fauna::Output::Aggregator::datapoints
private

◆ interval

DateInterval Fauna::Output::Aggregator::interval = DateInterval(Date(0, 0), Date(0, 0))
private

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