9#ifndef FMTACT_Hm_included
10#define FMTACT_Hm_included
14#include "FMTBounds.hpp"
16#include <boost/serialization/string.hpp>
17#include <boost/serialization/serialization.hpp>
18#include <boost/serialization/nvp.hpp>
21#include <unordered_set>
22#include <boost/serialization/export.hpp>
26#define FMTGCBMDEATHID 15
27#define FMTGCBMGROWTHID 16
28#define FMTGCBMUNKNOWNID 17
29#define FMTGCBMWILDFIREID 10
30#define FMTMaxNumberOfActions _I8_MAX + 1
76 FMTAction(
const std::string& lname,
const bool& p_lock,
const bool& p_reset);
117 const std::vector<FMTTheme>& originalthemes,
118 std::vector<FMTTheme>& newthemes,
bool compressdata =
false)
const;
128 const std::vector<FMTTheme>& p_originalthemes,
129 std::vector<FMTTheme>& p_newthemes,
bool p_compressdata =
false);
137 return m_agelowerbound;
146 return m_ageupperbound;
155 return m_periodlowerbound;
164 return m_periodupperbound;
173 return boost::hash<std::string>()(m_name);
209 return !m_series.empty();
300 operator std::string()
const;
327 std::vector<Core::FMTAction>
split(
const std::vector<Core::FMTMask>& p_mask,
328 const std::vector<Core::FMTTheme>& p_themes)
const;
393 friend class boost::serialization::access;
394 template<
class Archive>
395 void serialize(Archive& ar,
const unsigned int version)
398 ar& boost::serialization::make_nvp(
"specs", boost::serialization::base_object<
FMTList<FMTSpec>>(*
this));
399 ar& boost::serialization::make_nvp(
"partials", m_partials);
400 ar& boost::serialization::make_nvp(
"agelowerbound", m_agelowerbound);
401 ar& boost::serialization::make_nvp(
"ageupperbound", m_ageupperbound);
402 ar& boost::serialization::make_nvp(
"periodlowerbound", m_periodlowerbound);
403 ar& boost::serialization::make_nvp(
"periodupperbound", m_periodupperbound);
404 ar& boost::serialization::make_nvp(
"name", m_name);
405 ar& boost::serialization::make_nvp(
"aggregates", m_aggregates);
406 ar& boost::serialization::make_nvp(
"lock", m_lock);
407 ar& boost::serialization::make_nvp(
"reset", m_reset);
411 _exhandler->printExceptions(
"",
"FMTAction::serialize", __LINE__, __FILE__);
437 std::vector<const FMTAction*>
getAllAggregates(
const std::vector<FMTAction>&actions,
bool aggregateonly =
false)
const;
445 std::unordered_set<int>
getAllAggregatesSet(
const std::vector<FMTAction>&actions,
bool aggregateonly =
false)
const;
456 std::string m_actionName;
459 bool m_checkAggregate;
#define FMTEXPORT
Definition: FMTutility.h:125
Comparator used to check if an action name (or aggregate) already exists in a std container.
Definition: FMTAction.h:421
FMTActionComparator(std::string p_name, bool lcheckaggregate=false)
Construct the comparator from the action name to match.
std::unordered_set< int > getAllAggregatesSet(const std::vector< FMTAction > &actions, bool aggregateonly=false) const
Return the ids of the actions matching the action name, or only the matching aggregates.
bool operator()(const FMTAction &action) const
Matching test operator for the comparator.
std::vector< const FMTAction * > getAllAggregates(const std::vector< FMTAction > &actions, bool aggregateonly=false) const
Return the actions matching the action name, or only the matching aggregates.
List of specifications dictating the operability of a subset of developments to this action.
Definition: FMTAction.h:43
const FMTSerie * getSerie(const std::vector< std::string > &p_SerieMask) const
get the serie with the partial mask p_SerieMask
bool isResetAge() const
Return true if the development age is reset to 0 when operated by this action.
Definition: FMTAction.h:198
FMTAction preSolve(const FMTMaskFilter &filter, const std::vector< FMTTheme > &originalthemes, std::vector< FMTTheme > &newthemes, bool compressdata=false) const
Presolve the action by eliminating specifications and presolving the masks; the returned action can b...
bool partial(const std::string &yield) const
Check if the yield needs to be considered as partial for this action.
size_t hash() const
Return the hash of the action based on its name.
Definition: FMTAction.h:171
bool useYield(const std::string &yldname) const
Return true if the yield is used by the action to set operability.
void setAggregates(const std::vector< std::string > &p_aggregates)
Set a new vector of aggregates.
void pushPartials(const std::string &yield)
Push a partial yield name to the partials of the action.
int m_agelowerbound
Definition: FMTAction.h:358
void setSeries(std::vector< Core::FMTSerie > p_series)
Set the series of the action, checking which ones the action is part of and building them.
std::string getGCBMActionName() const
Return the corresponding GCBM action name.
FMTAction & operator+=(const FMTAction &OtherAction)
Append another action to this action; actions need to have the same age reset otherwise an exception ...
void pushAggregate(const std::string &aggregate)
Push an aggregate to the aggregates of the action.
bool isPartOfASerie() const
Return true if the action is part of a serie.
Definition: FMTAction.h:207
std::vector< std::string > getAggregates() const
Return the names of the aggregates the action is part of.
bool isInSeries() const
return true if you find this action first in a serie
std::vector< std::string > m_aggregates
An action can be part of a aggregate so this data member gets the name of all aggregate the action is...
Definition: FMTAction.h:351
bool m_lock
If lock is true the action is not _lockexempt when false the action is _LOCKEXEMPT.
Definition: FMTAction.h:364
bool notUse() const
Check if all specs are period lower == 0 and upper == 0.
const int & getPeriodUpperBound() const
Get the period upper bound for all specifications.
Definition: FMTAction.h:162
std::vector< std::string > getSeriesNames() const
Return the series names of the action.
std::vector< std::string > m_partials
Keeps the yields name for determining the amount of wood harvested in case of partial cut.
Definition: FMTAction.h:354
bool isAllowedInSerie(const std::vector< std::string > &serie) const
Return true if the serie mask is part of one serie of the action.
const int & getAgeLowerBound() const
Get the age lower bound for all specifications.
Definition: FMTAction.h:135
void preSolveRef(const FMTMaskFilter &p_filter, const std::vector< FMTTheme > &p_originalthemes, std::vector< FMTTheme > &p_newthemes, bool p_compressdata=false)
Presolve the action in place by eliminating specifications and presolving the masks; the action can b...
void _setBounds()
Set the age and period bounds member data by iterating on the specifications, for optimization.
bool doRespectLock() const
Return true if the action needs to respect the lock state of the development.
Definition: FMTAction.h:189
const int & getPeriodLowerBound() const
Get the period lower bound for all specifications.
Definition: FMTAction.h:153
bool isPartOf(const std::string &p_name) const
Check if action is part of action name or aggregate.
const int & getAgeUpperBound() const
Get the age upper bound for all specifications.
Definition: FMTAction.h:144
std::string m_name
The name of the action.
Definition: FMTAction.h:361
size_t getLargestSerieSize() const
Return the size of the largest serie of the action.
FMTAction(const FMTAction &rhs)
Copy constructor for FMTAction.
const std::vector< FMTSerie > & getSeries() const
get all series of the actions
std::vector< std::string > getPartials() const
Return the partial yield names of the action.
virtual ~FMTAction()=default
Default virtual destructor for FMTAction.
std::vector< FMTSerie > m_series
The action series that the action is part of.
Definition: FMTAction.h:370
FMTAction(const std::string &lname, const bool &p_lock, const bool &p_reset)
Construct an empty action with a given name, respect lock and reset age flags.
void update() override
Update the action by setting the bounds and shrinking the list, for optimization.
int getGCBMActionId() const
Return the corresponding GCBM action id.
FMTAction()
Default constructor for FMTAction.
std::vector< Core::FMTAction > split(const std::vector< Core::FMTMask > &p_mask, const std::vector< Core::FMTTheme > &p_themes) const
Split the action into different actions using the masks.
FMTAction(const std::string &lname)
Construct an empty action with a given name.
bool m_reset
If reset is true then the action is age reset Y else the action doen't reset age.
Definition: FMTAction.h:367
bool m_InSerie
True if the actions is in a serie.
Definition: FMTAction.h:373
std::string getName() const
Get the name of the action.
Definition: FMTAction.h:180
std::vector< std::string > _getGCBMActionDef() const
Return the corresponding GCBM action definition.
Definition: FMTAreaParser.h:32
Filter built from masks used to preSolve and postsolve FMTMask objects.
Definition: FMTMaskFilter.h:31
Class keeping the information of a serie of actions in a given order.
Definition: FMTSerie.h:23
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
Definition: FMTAction.h:463
std::size_t operator()(const Core::FMTAction &act) const
Definition: FMTAction.h:471