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

#include <dynamicgrowthcurvetransform.h>

Inherits ITransform.

Collaboration diagram for DynamicGrowthCurveTransform:
Collaboration graph

Public Member Functions

 DynamicGrowthCurveTransform (std::shared_ptr< std::map< std::tuple< std::string, double, double >, DynamicVar >> gcIdCache, std::shared_ptr< std::map< int, std::map< std::string, DynamicVar >>> gcCache, std::shared_ptr< Poco::Mutex > cacheLock, std::shared_ptr< std::atomic< int >> nextGcId)
 
void configure (DynamicObject config, const flint::ILandUnitController &landUnitController, datarepository::DataRepository &dataRepository) override
 
void controllerChanged (const flint::ILandUnitController &controller) override
 
const DynamicVar & value () const override
 

Private Attributes

int _maxAge = 300
 
int _incrementLength = 10
 
bool _debug = false
 
const flint::ILandUnitController * _landUnitController
 
const flint::IVariable * _csetVar
 
const flint::IVariable * _precipitationVar
 
const flint::IVariable * _growingDaysVar
 
const flint::IVariable * _volToBioVar
 
const flint::IVariable * _growthAndYieldParamsVar
 
DynamicVar _value
 
std::shared_ptr< std::map< std::tuple< std::string, double, double >, DynamicVar > > _gcIdCache
 
std::shared_ptr< std::map< int, std::map< std::string, DynamicVar > > > _gcCache
 
std::shared_ptr< Poco::Mutex > _cacheLock
 
std::shared_ptr< std::atomic< int > > _nextGcId
 

Constructor & Destructor Documentation

◆ DynamicGrowthCurveTransform()

DynamicGrowthCurveTransform ( std::shared_ptr< std::map< std::tuple< std::string, double, double >, DynamicVar >>  gcIdCache,
std::shared_ptr< std::map< int, std::map< std::string, DynamicVar >>>  gcCache,
std::shared_ptr< Poco::Mutex >  cacheLock,
std::shared_ptr< std::atomic< int >>  nextGcId 
)

Member Function Documentation

◆ configure()

void configure ( DynamicObject  config,
const flint::ILandUnitController &  landUnitController,
datarepository::DataRepository &  dataRepository 
)
override

Configuration function

Assign DynamicGrowthCurveTransform._landUnitController as parameter &landUnitController,
Assign values of variables "classifier_set", "mean_annual_precipitation", "mean_annual_growing_days", "volume_to_biomass_parameters", "growth_and_yield_parameters" in DynamicGrowthCurveTransform._landUnitController
to DynamicGrowthCurveTransform._csetVar, DynamicGrowthCurveTransform._precipitationVar, DynamicGrowthCurveTransform._growingDaysVar, DynamicGrowthCurveTransform._volToBioVar, DynamicGrowthCurveTransform._growthAndYieldParamsVar
If parameter config contains "age", "increment_length", "debugging_enabled", assign it to DynamicGrowthCurveTransform._maxAge, DynamicGrowthCurveTransform._incrementLength, DynamicGrowthCurveTransform._debug

Parameters
configDynamicObject
landUnitControllerflint::ILandUnitController&
dataRepositorydatarepository::DataRepository&
Returns
void

◆ controllerChanged()

void controllerChanged ( const flint::ILandUnitController &  controller)
override

Assign DynamicGrowthCurveTransform._landUnitController as paramter &controller

Parameters
controllerflint::ILandUnitController&flint::ILandUnitController&
Returns
void

◆ value()

const DynamicVar & value ( ) const
override

If the value of DynamicGrowthCurveTransform._csetVar or DynamicGrowthCurveTransform._precipitationVar or DynamicGrowthCurveTransform._growingDaysVar is empty, assign DynamicGrowthCurveTransform._value as an object of Poco::Dynamic::Var, and return DynamicGrowthCurveTransform._value
Assign a variable key, to the tuple, species (value of "Species" in DynamicGrowthCurveTransform._csetVar), precipitation (value of DynamicGrowthCurveTransform._precipitationVar) and growingDays (value of DynamicGrowthCurveTransform._growingDaysVar)
If key exists in DynamicGrowthCurveTransform._gcIdCache return it
Apply Poco::Mutex::ScopedLock, generate a new Growth Curvce and check again in case of a race condition
If value of _growthAndYieldParamsVar is empty, add variable key, -1 to DynamicGrowthCurveTransform._gcIdCache, assign DynamicGrowthCurveTransform._value as an object of Poco::Dynamic::Var, and return DynamicGrowthCurveTransform._value
Return value of variable key in DynamicGrowthCurveTransform._gcIdCache

Returns
DynamicVar&

Member Data Documentation

◆ _cacheLock

std::shared_ptr<Poco::Mutex> _cacheLock
private

◆ _csetVar

const flint::IVariable* _csetVar
mutableprivate

◆ _debug

bool _debug = false
mutableprivate

◆ _gcCache

std::shared_ptr<std::map<int, std::map<std::string, DynamicVar> > > _gcCache
private

◆ _gcIdCache

std::shared_ptr<std::map<std::tuple<std::string, double, double>, DynamicVar> > _gcIdCache
private

◆ _growingDaysVar

const flint::IVariable* _growingDaysVar
mutableprivate

◆ _growthAndYieldParamsVar

const flint::IVariable* _growthAndYieldParamsVar
mutableprivate

◆ _incrementLength

int _incrementLength = 10
mutableprivate

◆ _landUnitController

const flint::ILandUnitController* _landUnitController
private

◆ _maxAge

int _maxAge = 300
mutableprivate

◆ _nextGcId

std::shared_ptr<std::atomic<int> > _nextGcId
private

◆ _precipitationVar

const flint::IVariable* _precipitationVar
mutableprivate

◆ _value

DynamicVar _value
mutableprivate

◆ _volToBioVar

const flint::IVariable* _volToBioVar
mutableprivate

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