8#ifndef FMTYLDDATA_Hm_included
9#define FMTYLDDATA_Hm_included
13#include <unordered_map>
14#include <unordered_set>
16#include <boost/serialization/serialization.hpp>
17#include <boost/serialization/nvp.hpp>
22#include "FMTBounds.hpp"
43 inline bool operator()(
const std::string& p_first,
const std::string& p_second)
const noexcept
45 const size_t FIRST_LENGTH = p_first.length();
46 const size_t SECOND_LENGTH = p_second.length();
47 bool lessThan =
false;
48 if (FIRST_LENGTH != SECOND_LENGTH)
50 lessThan = FIRST_LENGTH < SECOND_LENGTH;
53 size_t i = FIRST_LENGTH;
54 bool gotValue =
false;
55 while (!gotValue && i > 0)
58 if (p_first[i] != p_second[i])
60 if (p_first[i] < p_second[i])
137 double getLinearValue(
const std::vector<double>& dls,
const int& agetarget,
bool allowoutofrange)
const;
174 void setBase(
const std::vector<int>& allvalues);
204 virtual bool pushData(
const std::string& yld,
const double& value);
219 virtual std::vector<std::string>
indexes(
const std::vector<std::string>& names)
const;
225 virtual operator std::string()
const;
232 virtual std::vector<std::string>
compare(
const std::vector<std::string>& keys)
const;
238 virtual std::unique_ptr<FMTYieldHandler>
clone()
const;
277 virtual const FMTData&
at(
const std::string& yldname)
const;
309 virtual std::map<std::string, std::vector<double>>
getAllYieldsData(
const int& maxbase)
const;
317 virtual std::unique_ptr<FMTYieldHandler>
preSolve(
const FMTMaskFilter& filter,
const std::vector<FMTTheme>& newthemes)
const;
325 virtual std::unique_ptr<FMTYieldHandler>
postSolve(
const FMTMaskFilter& filter,
const std::vector<FMTTheme>& basethemes)
const;
333 virtual std::unique_ptr<FMTYieldHandler>
getFromFactor(
const double& factor,
334 std::vector<std::string>yieldnames = std::vector<std::string>())
const;
344 virtual int getEndPoint(
const std::string& yld,
const int& lowerstep,
const double& bound,
const double& value)
const;
383 static bool _basePushData(std::map<std::string, FMTData, cmpYieldString>& elements,
const std::string& yld,
const double& value);
392 static bool _basePushData(std::map<std::string, FMTData, cmpYieldString>& elements,
const std::string& yld,
const FMTData& data);
409 friend class boost::serialization::access;
417 template<
class Archive>
418 void serialize(Archive& ar,
const unsigned int version)
420 ar& boost::serialization::make_nvp(
"mask", m_mask);
421 ar& boost::serialization::make_nvp(
"bases", m_bases);
#define FMTEXPORT
Definition: FMTutility.h:125
Data of a yield holding the values, sources and operators used to compute complex yields.
Definition: FMTData.h:36
Filter built from masks used to preSolve and postsolve FMTMask objects.
Definition: FMTMaskFilter.h:31
Core class holding, as a boost dynamic bitset, which theme attributes are part of a mask.
Definition: FMTMask.h:96
Base class of multiple FMT classes holding a shared exception handler pointer and logger.
Definition: FMTObject.h:49
Base class for yield handlers, holding a mask and the base ages of the yields.
Definition: FMTYieldHandler.h:80
virtual const FMTData & at(const std::string &yldname) const
Access the data of a yield.
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.
int _getMaxBase(const FMTYieldRequest &request) const
Return the maximum base age for a request.
virtual bool empty() const
Return true if the handler is empty.
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 bool pushData(const std::string &yld, const FMTData &data)
Push data for a yield.
virtual std::map< std::string, std::vector< double > > getAllYieldsData(const int &maxbase) const
Return all the yield data up to a maximum base age.
std::vector< int > m_bases
Definition: FMTYieldHandler.h:373
void setBase(const std::vector< int > &allvalues)
Set the base ages of the handler.
virtual std::unique_ptr< FMTYieldHandler > getFromFactor(const double &factor, std::vector< std::string >yieldnames=std::vector< std::string >()) const
Multiply the handler by a factor and return a new handler.
bool pushBase(const int &base)
Push a base age to the handler.
FMTYieldHandler()=default
Default constructor for FMTYieldHandler.
virtual double getPeak(const FMTYieldRequest &request, const std::string &yld, const int &targetage) const
Return the peak value of a yield for a request.
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.
virtual void clearCache()
Clear the cache of the handler.
virtual ~FMTYieldHandler()=default
Default virtual destructor for FMTYieldHandler.
virtual std::unique_ptr< FMTYieldHandler > postSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &basethemes) const
Return a postsolved copy of the handler.
virtual std::vector< size_t > getTabous() const
Return the tabou indexes of the handler.
virtual std::unique_ptr< FMTYieldHandler > preSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &newthemes) const
Return a presolved copy of the handler.
virtual double getLastValue(const std::string yld) const
Return the last value of a yield.
virtual int getLastBase() const
Return the last base age of the handler.
FMTMask m_mask
Definition: FMTYieldHandler.h:372
FMTYieldHandler(const FMTMask &lmask)
Construct a yield handler from a mask.
virtual void setOverrideIndex(const size_t &newindex)
Set the override index of the handler.
std::unordered_set< std::string > m_lookat
Definition: FMTYieldHandler.h:374
double _getChangesFrom(const int &targetage, const int &peakstep) const
Return the change of value from a target age over a peak step.
FMTYieldHandler(const FMTYieldHandler &rhs)=default
Copy constructor for FMTYieldHandler.
virtual FMTData & operator[](const std::string &yldname)
Access the data of a yield.
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 std::vector< std::string > compare(const std::vector< std::string > &keys) const
Return the keys that match the handler.
virtual size_t getOverrideIndex() const
Return the override index of the handler.
virtual size_t size() const
Return the number of yields in the handler.
virtual bool isNullYield(const std::string &yldname) const
Return true if a yield is a null yield.
virtual FMTyldtype getType() const
Return the type of the yield handler.
bool inLookAt(const std::string &yld) const
Return true if a yield is in the look at set.
virtual bool pushData(const std::string &yld, const double &value)
Push a value for a yield.
void setMask(const FMTMask &p_mask)
Set the mask of the handler.
virtual bool containsYield(const std::string &yldname) const
Return true if the handler contains a given yield.
virtual std::vector< std::string > getYieldNames() const
Return the yield names of the handler.
FMTMask getMask() const
Return the mask of the handler.
double getLinearValue(const std::vector< double > &dls, const int &agetarget, bool allowoutofrange) const
Return the linearly interpolated value at a target age.
virtual int getAge(const FMTYieldRequest &request, const FMTSpec &spec) const
Return the age of a development from a request and a specification.
virtual double get(const std::string &yld, const FMTYieldRequest &request) const
Get the value of a yield for a request.
const std::vector< int > & getBases() const
Return the base ages of the handler.
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.
virtual std::unique_ptr< FMTYieldHandler > clone() const
Clone the yield handler.
Request for yield values using a development and optionally a graph vertex.
Definition: FMTYieldRequest.h:37
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
FMTyldtype
Enumerator describing the type of a yield (age, time, complex, model).
Definition: FMTutility.h:62
Comparator ordering yield names by length then by content from the end.
Definition: FMTYieldHandler.h:35
bool operator()(const std::string &p_first, const std::string &p_second) const noexcept
Compare two yield names.
Definition: FMTYieldHandler.h:43