8#ifndef FMTOSR_Hm_included
9#define FMTOSR_Hm_included
11#include "FMTBounds.hpp"
14#include <boost/serialization/serialization.hpp>
17#include <unordered_set>
23 class FMTGraphVertexToYield;
28 class FMTOutputParser;
36 class FMTActualDevelopment;
37 class FMTDevelopmentPath;
67 std::string lyield=
"", std::string laction =
"",
int origin=-1,
int ttarget=-1);
78 std::vector<double>lvalues,
int origin = -1,
int ttarget=-1, std::string llevelname =
"");
91 const FMTotar ltarget, std::string lyield=
"",
92 std::string laction =
"",
int origin = -1,
int ttarget=-1);
111 operator std::string()
const override;
140 return m_outputorigin;
149 return m_themetarget;
277 return (m_target == FMTotar::level);
286 return (m_target == FMTotar::val);
295 return (!m_action.empty() && isLevel());
329 return (m_target == FMTotar::timeyld);
337 std::vector<const FMTAction*>
targets(
const std::vector<FMTAction>& actions)
const;
344 std::unordered_set<int>
targetsSet(
const std::vector<FMTAction>& actions)
const;
352 return (m_target == FMTotar::inventory);
361 return (m_target == FMTotar::inventory);
370 return (m_target == FMTotar::inventory && m_action.empty());
379 return (m_target == FMTotar::actual);
394 std::vector<FMTDevelopmentPath>
const * paths=
nullptr,
395 FMTAction const * p_action=
nullptr)
const;
457 const std::vector<Core::FMTAction>&actions,
const FMTYields& yields)
const;
465 size_t hash(
int period = -1,
bool withyield =
false)
const;
492 return !m_action.empty();
500 static std::string
trimDouble(
const std::string& string_number);
508 friend class boost::serialization::access;
517 template<
class Archive>
518 void serialize(Archive& ar,
const unsigned int version)
520 ar& boost::serialization::make_nvp(
"specification", boost::serialization::base_object<FMTSpec>(*
this));
521 ar& boost::serialization::make_nvp(
"mask", m_mask);
522 ar& boost::serialization::make_nvp(
"target", m_target);
523 ar& boost::serialization::make_nvp(
"action", m_action);
524 ar& boost::serialization::make_nvp(
"yield", m_yield);
525 ar& boost::serialization::make_nvp(
"values", m_values);
526 ar& boost::serialization::make_nvp(
"themetarget", m_themetarget);
530 std::string m_action, m_yield, m_levelname;
531 std::vector<double>m_values;
542 void _pushValues(
const std::vector<double>& newvalues);
576 struct hash<
Core::FMTOutputSource>
580 return p_source.
hash(-1,
true);
#define FMTEXPORT
Definition: FMTutility.h:125
List of specifications dictating the operability of a subset of developments to this action.
Definition: FMTAction.h:43
Base class of FMTActualDevelopment and FMTFuturDevelopment representing a forest stand.
Definition: FMTDevelopment.h:44
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
Mathematical operator usable in yield and output expressions.
Definition: FMTOperator.h:44
Comparator used to match output sources by whether they are variable.
Definition: FMTOutputSource.h:550
FMTOutputSourceComparator(bool lvariable)
Construct the comparator.
bool operator()(const FMTOutputSource &source) const
Matching test operator for the comparator.
Source of an output holding a mask, a target and values, used to compute an output.
Definition: FMTOutputSource.h:44
std::unordered_set< int > targetsSet(const std::vector< FMTAction > &actions) const
Return the ids of the actions targeted by the output source.
const std::vector< double > & getValues() const
Return a const reference to the values of the output source.
Definition: FMTOutputSource.h:311
void setAction(const std::string &actionname)
Set the action of the output source.
void fillHashSpec(Core::FMTMask &baseMask) const
Fill a base mask with the hash specification of the output source.
bool isNull(const FMTYields &ylds) const
Return true if the output source is null.
int getThemeTarget() const
Return the theme target.
Definition: FMTOutputSource.h:147
FMTOutputSource(const FMTotar ltarget, double lvalue=0, std::string lyield="", std::string laction="", int origin=-1, int ttarget=-1)
Construct an output source from a target and optional value, yield, action, origin and theme target.
FMTOutputSource(const FMTOutputSource &rhs)
Copy constructor for FMTOutputSource.
bool useOutEdges() const
Return true if the output source uses the out edges.
Definition: FMTOutputSource.h:377
int getOutputOrigin() const
Return the output origin.
Definition: FMTOutputSource.h:138
bool isNextPeriod() const
Return true if the output source targets the next period.
Definition: FMTOutputSource.h:368
void resetValues(const FMTOperator &op, const FMTOutputSource &other)
Reset the values of the output source using an operator and another output source.
const std::string & getAction() const
Return a const reference to the action of the output source.
Definition: FMTOutputSource.h:232
bool isVariable() const
Return true if the output source is a variable.
Definition: FMTOutputSource.h:266
bool useInEdges() const
Return true if the output source uses the in edges.
Definition: FMTOutputSource.h:359
bool isSum() const
Return true if the output source is a sum.
Definition: FMTOutputSource.h:438
bool isSameButDifferentAction(const FMTOutputSource &rhs) const
Return true if this output source is the same as another but with a different action.
double getConstantValue(const std::vector< Core::FMTActualDevelopment > &area, const std::vector< Core::FMTAction > &actions, const FMTYields &yields) const
Return the constant value of the output source.
bool isAverage() const
Return true if the output source is an average.
Definition: FMTOutputSource.h:424
void setMask(const FMTMask &newmask)
Set the mask of the output source.
void fillHashMask(Core::FMTMask &baseMask) const
Fill a base mask with the hash mask of the output source.
void setYield(const std::string &p_Yield)
set Yield to the output source.
const FMTotar & getTarget() const
Return a const reference to the target of the output source.
Definition: FMTOutputSource.h:250
~FMTOutputSource()=default
Default destructor for FMTOutputSource.
bool isLevel() const
Return true if the output source is a level.
Definition: FMTOutputSource.h:275
bool isVariableLevel() const
Return true if the output source is a variable level.
Definition: FMTOutputSource.h:293
double getCoef(const FMTDevelopment &development, const FMTYields &yields, const Graph::FMTGraphVertexToYield *graphinfo=nullptr, std::vector< FMTDevelopmentPath > const *paths=nullptr, FMTAction const *p_action=nullptr) const
Return the coefficient of the output source for a development based on the yields.
static std::string trimDouble(const std::string &string_number)
Trim the trailing zeros of a number in string format, for example 1400.0000 to 1400 or 14....
bool isTimeYield() const
Return true if the output source is a time yield.
Definition: FMTOutputSource.h:327
double getValue(int period=0) const
Return the value of the output source for a given period.
void setThemeTarget(const int &newttarget)
Set the theme target of the output source.
bool isSubsetOf(const FMTOutputSource &rhs) const
Return true if this output source is a subset of another.
bool isInventory() const
Return true if the output source targets the inventory.
Definition: FMTOutputSource.h:350
void setAverage()
Set the output source as an average.
bool isSubsetOf(const FMTOutputSource &rhs, const std::vector< Core::FMTAction > &actions) const
Return true if this output source is a subset of another considering the actions.
FMTOutputSource(const FMTSpec &spec, const FMTMask &lmask, const FMTotar ltarget, std::string lyield="", std::string laction="", int origin=-1, int ttarget=-1)
Construct an output source from a specification, a mask and a target.
const std::string & getYield() const
Return a const reference to the yield of the output source.
Definition: FMTOutputSource.h:241
void setSum()
Set the output source as a sum.
const FMTMask & getMask() const
Return a const reference to the mask of the output source.
Definition: FMTOutputSource.h:186
FMTOutputSource(const FMTotar ltarget, std::vector< double >lvalues, int origin=-1, int ttarget=-1, std::string llevelname="")
Construct an output source from a target and a vector of values.
bool isEqualByValue(const FMTOutputSource &rhs) const
Return true if this output source is equal by value to another.
bool use(const FMTDevelopment &development, const FMTYields &ylds, const Graph::FMTGraphVertexToYield *graphinfo=nullptr) const
Return true if the output source is used by a development based on the yields.
FMTOutputSource preSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &newthemes) const
Return a presolved copy of the output source.
FMTOutputSource()
Default constructor for FMTOutputSource.
bool isAction() const
Return true if the output source is an action.
Definition: FMTOutputSource.h:490
size_t hash(int period=-1, bool withyield=false) const
Return the hash of the output source.
std::vector< const FMTAction * > targets(const std::vector< FMTAction > &actions) const
Return the actions targeted by the output source.
void setTarget(const FMTotar &newtype)
Set the target of the output source.
void setOutputOrigin(const int &neworigin)
Set the output origin of the output source.
bool isConstant() const
Return true if the output source is a constant.
Definition: FMTOutputSource.h:284
bool isInAggregate(const FMTOutputSource &rhs, const std::vector< Core::FMTAction > &actions) const
Return true if this output source is in the same aggregate as another.
bool canBeDeducedToConstant() const
Return true if the output source can be deduced to a constant.
const std::string & getLevel() const
Return a const reference to the level of the output source.
Definition: FMTOutputSource.h:302
FMTList containing multiple yield handlers as seen in the yield section, holding the information rela...
Definition: FMTYields.h:44
Adapter pointing to a vertex of a line graph or a full graph and its model, used to answer a generic ...
Definition: FMTGraphVertexToYield.h:31
Parser reading and writing a vector of FMTOutput from or into a file.
Definition: FMTOutputParser.h:35
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
FMTotar
Enumerator describing the target of an output (inventory, actual, value, time yield,...
Definition: FMTutility.h:101
Definition: FMTAreaParser.h:35
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTActionParser.h:27
Definition: FMTAction.h:463
std::size_t operator()(const Core::FMTOutputSource &p_source) const
Definition: FMTOutputSource.h:578