FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Core::FMTYieldHandler Class Reference

Base class for yield handlers, holding a mask and the base ages of the yields. More...

#include <FMTYieldHandler.h>

Inheritance diagram for Core::FMTYieldHandler:
[legend]
Collaboration diagram for Core::FMTYieldHandler:
[legend]

Public Member Functions

virtual size_t getOverrideIndex () const
 Return the override index of the handler.
 
virtual std::vector< size_t > getTabous () const
 Return the tabou indexes of the handler.
 
virtual void setOverrideIndex (const size_t &newindex)
 Set the override index of the handler.
 
virtual ~FMTYieldHandler ()=default
 Default virtual destructor for FMTYieldHandler.
 
 FMTYieldHandler ()=default
 Default constructor for FMTYieldHandler.
 
 FMTYieldHandler (const FMTYieldHandler &rhs)=default
 Copy constructor for FMTYieldHandler.
 
FMTYieldHandleroperator= (const FMTYieldHandler &rhs)=default
 Copy assignment operator for FMTYieldHandler.
 
 FMTYieldHandler (const FMTMask &lmask)
 Construct a yield handler from a mask.
 
double getLinearValue (const std::vector< double > &dls, const int &agetarget, bool allowoutofrange) const
 Return the linearly interpolated value at a target age.
 
virtual int getLastBase () const
 Return the last base age of the handler.
 
const std::vector< int > & getBases () const
 Return the base ages of the handler.
 
FMTMask getMask () const
 Return the mask of the handler.
 
void setMask (const FMTMask &p_mask)
 Set the mask of the handler.
 
bool pushBase (const int &base)
 Push a base age to the handler.
 
void setBase (const std::vector< int > &allvalues)
 Set the base ages of the handler.
 
bool inLookAt (const std::string &yld) const
 Return true if a yield is in the look at set.
 
virtual double getLastValue (const std::string yld) const
 Return the last value of a yield.
 
virtual double get (const std::string &yld, const FMTYieldRequest &request) const
 Get the value of a yield for a request.
 
virtual bool pushData (const std::string &yld, const double &value)
 Push a value for a yield.
 
virtual bool pushData (const std::string &yld, const FMTData &data)
 Push data for a yield.
 
virtual std::vector< std::string > indexes (const std::vector< std::string > &names) const
 Return the yield names that are indexes among the given names.
 
virtual operator std::string () const
 Return the string representation of the yield handler.
 
virtual std::vector< std::string > compare (const std::vector< std::string > &keys) const
 Return the keys that match the handler.
 
virtual std::unique_ptr< FMTYieldHandlerclone () const
 Clone the yield handler.
 
virtual bool operator== (const FMTYieldHandler &rhs) const
 Equality comparison operator of FMTYieldHandler.
 
virtual bool empty () const
 Return true if the handler is empty.
 
virtual size_t size () const
 Return the number of yields in the handler.
 
virtual FMTyldtype getType () const
 Return the type of the yield handler.
 
virtual FMTDataoperator[] (const std::string &yldname)
 Access the data of a yield.
 
virtual const FMTDataat (const std::string &yldname) const
 Access the data of a yield.
 
virtual bool containsYield (const std::string &yldname) const
 Return true if the handler contains a given yield.
 
virtual bool isNullYield (const std::string &yldname) const
 Return true if a yield is a null yield.
 
virtual std::vector< std::string > getYieldNames () const
 Return the yield names of the handler.
 
virtual void clearCache ()
 Clear the cache of the handler.
 
virtual std::map< std::string, std::vector< double > > getAllYieldsData (const int &maxbase) const
 Return all the yield data up to a maximum base age.
 
virtual std::unique_ptr< FMTYieldHandlerpreSolve (const FMTMaskFilter &filter, const std::vector< FMTTheme > &newthemes) const
 Return a presolved copy of the handler.
 
virtual std::unique_ptr< FMTYieldHandlerpostSolve (const FMTMaskFilter &filter, const std::vector< FMTTheme > &basethemes) const
 Return a postsolved copy of the handler.
 
virtual std::unique_ptr< FMTYieldHandlergetFromFactor (const double &factor, std::vector< std::string >yieldnames=std::vector< std::string >()) const
 Multiply the handler by a factor and return a new handler.
 
virtual int getEndPoint (const std::string &yld, const int &lowerstep, const double &bound, const double &value) const
 Return the age at which a yield reaches a bound value.
 
virtual double getPeak (const FMTYieldRequest &request, const std::string &yld, const int &targetage) const
 Return the peak value of a yield for a request.
 
virtual int getAge (const FMTYieldRequest &request, const FMTSpec &spec) const
 Return the age of a development from a request and a specification.
 
virtual double getYieldLinearValue (const std::string &yldname, const FMTYieldRequest &request, bool allowoutofrange=true) const
 Return the linearly interpolated value of a yield for a request.
 
- Public Member Functions inherited from Core::FMTObject
 FMTObject ()
 Default constructor for FMTObject.
 
virtual ~FMTObject ()
 Default virtual destructor for FMTObject.
 
 FMTObject (const std::unique_ptr< Exception::FMTExceptionHandler > exhandler)
 Construct a FMTObject passing in the exception handler of another FMTObject.
 
 FMTObject (const FMTObject &rhs)
 Copy constructor for FMTObject.
 
FMTObjectoperator= (const FMTObject &rhs)
 Copy assignment operator for FMTObject.
 
virtual void passInLogger (const std::unique_ptr< Logging::FMTLogger > &logger)
 Pass in the logger of another FMTObject.
 
void passInExceptionHandler (const std::unique_ptr< Exception::FMTExceptionHandler > &exhandler)
 Pass in the exception handler of another FMTObject.
 
void redirectLogToFile (const std::string &location)
 Redirect the log to a specific file, appending to it.
 
virtual void setDefaultLogger ()
 Create and set a default logger to the FMTObject.
 
virtual void setQuietLogger ()
 Create and set a quiet logger to the FMTObject.
 
virtual void setTaskLogger ()
 Create and set a task logger to the FMTObject.
 
virtual void setDebugLogger ()
 Create and set a debug logger to the FMTObject.
 
void setDefaultExceptionHandler ()
 Create and set a default exception handler to the FMTObject.
 
void setQuietExceptionHandler ()
 Create and set a quiet exception handler to the FMTObject.
 
void setDebugExceptionHandler ()
 Create and set a debug exception handler to the FMTObject.
 
void setFreeExceptionHandler ()
 Create and set a free exception handler to the FMTObject.
 
void disableNestedExceptions ()
 Disable the nested exception throw of the exception handler.
 
void enableNestedExceptions ()
 Enable the nested exception throw of the exception handler.
 
void setErrorsToWarnings (const std::vector< Exception::FMTexc > &errors)
 Set a list of errors to be cast to warnings on the exception handler.
 
void setMaxWarningsBeforeSilenced (const size_t &maxwarningcount)
 Set the number of warnings raised before being silenced.
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Protected Member Functions

double _getChangesFrom (const int &targetage, const int &peakstep) const
 Return the change of value from a target age over a peak step.
 
int _getMaxBase (const FMTYieldRequest &request) const
 Return the maximum base age for a request.
 
- Protected Member Functions inherited from Core::FMTObject
template<class Archive >
void forceSave (Archive &ar, const unsigned int version) const
 Force the serialization to save useful information, which the default FMTObject serialization does not.
 
template<class Archive >
void forceLoad (Archive &ar, const unsigned int version)
 Force the serialization to load useful information, which the default FMTObject serialization does not.
 
void checkSignals () const
 Check if the user has sent a ctrl-c signal using boost::python to FMT.
 
void setCplHandler ()
 Pass the FMT exception handler to the GDAL exception handler (GDAL only).
 

Static Protected Member Functions

static bool _basePushData (std::map< std::string, FMTData, cmpYieldString > &elements, const std::string &yld, const double &value)
 Push a value for a yield into the given elements.
 
static bool _basePushData (std::map< std::string, FMTData, cmpYieldString > &elements, const std::string &yld, const FMTData &data)
 Push data for a yield into the given elements.
 
- Static Protected Member Functions inherited from Core::FMTObject
static std::chrono::time_point< std::chrono::high_resolution_clock > getClock ()
 Return a clock of the current time.
 
template<class chrono >
static double getDuration (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock as a double.
 
static std::string getDurationInSeconds (const std::chrono::time_point< std::chrono::high_resolution_clock > &startclock)
 Return the time elapsed since a start clock in seconds as a string.
 
static void _logStack ()
 Log the stack trace...
 
static void _terminate ()
 Raise an error with the boost stacktrace.
 
static void _abort (int p_signal)
 Raise an error with the boost stacktrace on abort.
 

Protected Attributes

FMTMask m_mask
 
std::vector< int > m_bases
 
std::unordered_set< std::string > m_lookat
 

Friends

class boost::serialization::access
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::FMTObject
static Logging::FMTLoggergetLogger ()
 get a pointer to the actual logger.
 
static Exception::FMTExceptionHandlergetExceptionHandler ()
 get a pointer to the actual exception handler.
 
static std::string getRuntimeLocation ()
 Return the location of the FMT shared library.
 
static unsigned long long getAvailableMemory ()
 Return the available memory in bytes.
 
static void setTerminateStack ()
 will write the stack in the log when terminate called and raise a function failed.
 
static void setAbortStack ()
 will write the stack in the log when abort called with SIGABRT and raise a function failed.
 
- Static Protected Attributes inherited from Core::FMTObject
static std::unique_ptr< Exception::FMTExceptionHandler_exhandler
 A shared pointer to the exception handler.
 
static std::unique_ptr< Logging::FMTLogger_logger
 A shared pointer to the logger.
 

Detailed Description

Base class for yield handlers, holding a mask and the base ages of the yields.

Constructor & Destructor Documentation

◆ ~FMTYieldHandler()

virtual Core::FMTYieldHandler::~FMTYieldHandler ( )
virtualdefault

Default virtual destructor for FMTYieldHandler.

◆ FMTYieldHandler() [1/3]

Core::FMTYieldHandler::FMTYieldHandler ( )
default

Default constructor for FMTYieldHandler.

◆ FMTYieldHandler() [2/3]

Core::FMTYieldHandler::FMTYieldHandler ( const FMTYieldHandler rhs)
default

Copy constructor for FMTYieldHandler.

Parameters
[in]rhsthe FMTYieldHandler to copy.

◆ FMTYieldHandler() [3/3]

Core::FMTYieldHandler::FMTYieldHandler ( const FMTMask lmask)

Construct a yield handler from a mask.

Parameters
[in]lmaskthe mask.

Member Function Documentation

◆ _basePushData() [1/2]

static bool Core::FMTYieldHandler::_basePushData ( std::map< std::string, FMTData, cmpYieldString > &  elements,
const std::string &  yld,
const double &  value 
)
staticprotected

Push a value for a yield into the given elements.

Parameters
[in,out]elementsthe elements.
[in]yldthe yield name.
[in]valuethe value.
Returns
true if the value is pushed else false.

◆ _basePushData() [2/2]

static bool Core::FMTYieldHandler::_basePushData ( std::map< std::string, FMTData, cmpYieldString > &  elements,
const std::string &  yld,
const FMTData data 
)
staticprotected

Push data for a yield into the given elements.

Parameters
[in,out]elementsthe elements.
[in]yldthe yield name.
[in]datathe data.
Returns
true if the data is pushed else false.

◆ _getChangesFrom()

double Core::FMTYieldHandler::_getChangesFrom ( const int &  targetage,
const int &  peakstep 
) const
protected

Return the change of value from a target age over a peak step.

Parameters
[in]targetagethe target age.
[in]peakstepthe peak step.
Returns
the change of value.

◆ _getMaxBase()

int Core::FMTYieldHandler::_getMaxBase ( const FMTYieldRequest request) const
protected

Return the maximum base age for a request.

Parameters
[in]requestthe yield request.
Returns
the maximum base age.

◆ at()

virtual const FMTData & Core::FMTYieldHandler::at ( const std::string &  yldname) const
virtual

Access the data of a yield.

Parameters
[in]yldnamethe yield name.
Returns
a const reference to the data of the yield.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, and Core::FMTTimeYieldHandler.

◆ clearCache()

virtual void Core::FMTYieldHandler::clearCache ( )
virtual

◆ clone()

virtual std::unique_ptr< FMTYieldHandler > Core::FMTYieldHandler::clone ( ) const
virtual

Clone the yield handler.

Returns
a unique pointer to the cloned yield handler.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ compare()

virtual std::vector< std::string > Core::FMTYieldHandler::compare ( const std::vector< std::string > &  keys) const
virtual

Return the keys that match the handler.

Parameters
[in]keysthe keys.
Returns
the matching keys.

◆ containsYield()

virtual bool Core::FMTYieldHandler::containsYield ( const std::string &  yldname) const
virtual

Return true if the handler contains a given yield.

Parameters
[in]yldnamethe yield name.
Returns
true if the handler contains the yield else false.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ empty()

virtual bool Core::FMTYieldHandler::empty ( ) const
virtual

Return true if the handler is empty.

Returns
true if the handler is empty else false.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ get()

virtual double Core::FMTYieldHandler::get ( const std::string &  yld,
const FMTYieldRequest request 
) const
virtual

Get the value of a yield for a request.

Parameters
[in]yldthe yield name.
[in]requestthe yield request.
Returns
the yield value.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ getAge()

virtual int Core::FMTYieldHandler::getAge ( const FMTYieldRequest request,
const FMTSpec &  spec 
) const
virtual

Return the age of a development from a request and a specification.

Parameters
[in]requestthe yield request.
[in]specthe specification.
Returns
the age.

Reimplemented in Core::FMTAgeYieldHandler, and Core::FMTComplexYieldHandler.

◆ getAllYieldsData()

virtual std::map< std::string, std::vector< double > > Core::FMTYieldHandler::getAllYieldsData ( const int &  maxbase) const
virtual

Return all the yield data up to a maximum base age.

Parameters
[in]maxbasethe maximum base age.
Returns
a map of yield names to their values.

Reimplemented in Core::FMTAgeYieldHandler, and Core::FMTTimeYieldHandler.

◆ getBases()

const std::vector< int > & Core::FMTYieldHandler::getBases ( ) const

Return the base ages of the handler.

Returns
a const reference to the base ages.

◆ getEndPoint()

virtual int Core::FMTYieldHandler::getEndPoint ( const std::string &  yld,
const int &  lowerstep,
const double &  bound,
const double &  value 
) const
virtual

Return the age at which a yield reaches a bound value.

Parameters
[in]yldthe yield name.
[in]lowerstepthe lower step.
[in]boundthe bound.
[in]valuethe value.
Returns
the end point age.

Reimplemented in Core::FMTAgeYieldHandler.

◆ getFromFactor()

virtual std::unique_ptr< FMTYieldHandler > Core::FMTYieldHandler::getFromFactor ( const double &  factor,
std::vector< std::string >  yieldnames = std::vector< std::string >() 
) const
virtual

Multiply the handler by a factor and return a new handler.

Parameters
[in]factorthe factor.
[in]yieldnamesthe yield names to multiply, all if empty.
Returns
the multiplied yield handler.

Reimplemented in Core::FMTAgeYieldHandler, and Core::FMTTimeYieldHandler.

◆ getLastBase()

virtual int Core::FMTYieldHandler::getLastBase ( ) const
virtual

Return the last base age of the handler.

Returns
the last base age.

Reimplemented in Core::FMTComplexYieldHandler.

◆ getLastValue()

virtual double Core::FMTYieldHandler::getLastValue ( const std::string  yld) const
virtual

Return the last value of a yield.

Parameters
[in]yldthe yield name.
Returns
the last value of the yield.

Reimplemented in Core::FMTAgeYieldHandler, and Core::FMTTimeYieldHandler.

◆ getLinearValue()

double Core::FMTYieldHandler::getLinearValue ( const std::vector< double > &  dls,
const int &  agetarget,
bool  allowoutofrange 
) const

Return the linearly interpolated value at a target age.

Parameters
[in]dlsthe values.
[in]agetargetthe target age.
[in]allowoutofrangeif true allows out of range values.
Returns
the linear value.

◆ getMask()

FMTMask Core::FMTYieldHandler::getMask ( ) const

Return the mask of the handler.

Returns
the mask.

◆ getOverrideIndex()

virtual size_t Core::FMTYieldHandler::getOverrideIndex ( ) const
virtual

Return the override index of the handler.

Returns
the override index.

Reimplemented in Core::FMTComplexYieldHandler.

◆ getPeak()

virtual double Core::FMTYieldHandler::getPeak ( const FMTYieldRequest request,
const std::string &  yld,
const int &  targetage 
) const
virtual

Return the peak value of a yield for a request.

Parameters
[in]requestthe yield request.
[in]yldthe yield name.
[in]targetagethe target age.
Returns
the peak value.

Reimplemented in Core::FMTAgeYieldHandler, and Core::FMTComplexYieldHandler.

◆ getTabous()

virtual std::vector< size_t > Core::FMTYieldHandler::getTabous ( ) const
virtual

Return the tabou indexes of the handler.

Returns
the tabou indexes.

Reimplemented in Core::FMTComplexYieldHandler.

◆ getType()

virtual FMTyldtype Core::FMTYieldHandler::getType ( ) const
virtual

Return the type of the yield handler.

Returns
the yield type.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ getYieldLinearValue()

virtual double Core::FMTYieldHandler::getYieldLinearValue ( const std::string &  yldname,
const FMTYieldRequest request,
bool  allowoutofrange = true 
) const
virtual

Return the linearly interpolated value of a yield for a request.

Parameters
[in]yldnamethe yield name.
[in]requestthe yield request.
[in]allowoutofrangeif true allows out of range values.
Returns
the linear yield value.

Reimplemented in Core::FMTAgeYieldHandler, and Core::FMTComplexYieldHandler.

◆ getYieldNames()

virtual std::vector< std::string > Core::FMTYieldHandler::getYieldNames ( ) const
virtual

Return the yield names of the handler.

Returns
the yield names.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ indexes()

virtual std::vector< std::string > Core::FMTYieldHandler::indexes ( const std::vector< std::string > &  names) const
virtual

Return the yield names that are indexes among the given names.

Parameters
[in]namesthe names.
Returns
the index names.

Reimplemented in Core::FMTComplexYieldHandler.

◆ inLookAt()

bool Core::FMTYieldHandler::inLookAt ( const std::string &  yld) const

Return true if a yield is in the look at set.

Parameters
[in]yldthe yield name.
Returns
true if the yield is in the look at set else false.

◆ isNullYield()

virtual bool Core::FMTYieldHandler::isNullYield ( const std::string &  yldname) const
virtual

Return true if a yield is a null yield.

Parameters
[in]yldnamethe yield name.
Returns
true if the yield is null else false.

Reimplemented in Core::FMTModelYieldHandler.

◆ operator std::string()

virtual Core::FMTYieldHandler::operator std::string ( ) const
virtual

Return the string representation of the yield handler.

Returns
the string representation.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

◆ operator=()

FMTYieldHandler & Core::FMTYieldHandler::operator= ( const FMTYieldHandler rhs)
default

Copy assignment operator for FMTYieldHandler.

Parameters
[in]rhsthe FMTYieldHandler to copy.
Returns
a reference to this FMTYieldHandler.

◆ operator==()

virtual bool Core::FMTYieldHandler::operator== ( const FMTYieldHandler rhs) const
virtual

Equality comparison operator of FMTYieldHandler.

Parameters
[in]rhsthe handler to compare with.
Returns
true if both handlers are equal else false.

◆ operator[]()

virtual FMTData & Core::FMTYieldHandler::operator[] ( const std::string &  yldname)
virtual

Access the data of a yield.

Parameters
[in]yldnamethe yield name.
Returns
a reference to the data of the yield.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, and Core::FMTTimeYieldHandler.

◆ postSolve()

virtual std::unique_ptr< FMTYieldHandler > Core::FMTYieldHandler::postSolve ( const FMTMaskFilter filter,
const std::vector< FMTTheme > &  basethemes 
) const
virtual

Return a postsolved copy of the handler.

Parameters
[in]filterthe mask filter.
[in]basethemesthe original themes.
Returns
the postsolved yield handler.

Reimplemented in Core::FMTModelYieldHandler.

◆ preSolve()

virtual std::unique_ptr< FMTYieldHandler > Core::FMTYieldHandler::preSolve ( const FMTMaskFilter filter,
const std::vector< FMTTheme > &  newthemes 
) const
virtual

Return a presolved copy of the handler.

Parameters
[in]filterthe mask filter.
[in]newthemesthe presolved themes.
Returns
the presolved yield handler.

Reimplemented in Core::FMTModelYieldHandler.

◆ pushBase()

bool Core::FMTYieldHandler::pushBase ( const int &  base)

Push a base age to the handler.

Parameters
[in]basethe base age.
Returns
true if the base age is pushed else false.

◆ pushData() [1/2]

virtual bool Core::FMTYieldHandler::pushData ( const std::string &  yld,
const double &  value 
)
virtual

Push a value for a yield.

Parameters
[in]yldthe yield name.
[in]valuethe value.
Returns
true if the value is pushed else false.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, and Core::FMTTimeYieldHandler.

◆ pushData() [2/2]

virtual bool Core::FMTYieldHandler::pushData ( const std::string &  yld,
const FMTData data 
)
virtual

Push data for a yield.

Parameters
[in]yldthe yield name.
[in]datathe data.
Returns
true if the data is pushed else false.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, and Core::FMTTimeYieldHandler.

◆ setBase()

void Core::FMTYieldHandler::setBase ( const std::vector< int > &  allvalues)

Set the base ages of the handler.

Parameters
[in]allvaluesthe base ages to set.

◆ setMask()

void Core::FMTYieldHandler::setMask ( const FMTMask p_mask)

Set the mask of the handler.

Parameters
[in]p_maskthe mask to set.

◆ setOverrideIndex()

virtual void Core::FMTYieldHandler::setOverrideIndex ( const size_t &  newindex)
virtual

Set the override index of the handler.

Parameters
[in]newindexthe override index to set.

Reimplemented in Core::FMTComplexYieldHandler.

◆ size()

virtual size_t Core::FMTYieldHandler::size ( ) const
virtual

Return the number of yields in the handler.

Returns
the number of yields.

Reimplemented in Core::FMTAgeYieldHandler, Core::FMTComplexYieldHandler, Core::FMTModelYieldHandler, and Core::FMTTimeYieldHandler.

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Member Data Documentation

◆ m_bases

std::vector<int> Core::FMTYieldHandler::m_bases
protected

◆ m_lookat

std::unordered_set<std::string> Core::FMTYieldHandler::m_lookat
mutableprotected

◆ m_mask

FMTMask Core::FMTYieldHandler::m_mask
protected

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