FMT 0.9.8
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTaction.hpp
Go to the documentation of this file.
1/*
2Copyright (c) 2019 Gouvernement du Québec
3
4SPDX-License-Identifier: LiLiQ-R-1.1
5License-Filename: LICENSES/EN/LiLiQ-R11unicode.txt
6*/
7
8
9#ifndef FMTACT_H_INCLUDED
10#define FMTACT_H_INCLUDED
11
13#include "FMTlist.hpp"
14#include "FMTbounds.hpp"
15#include <boost/serialization/string.hpp>
16#include <boost/serialization/serialization.hpp>
17#include <boost/serialization/nvp.hpp>
18#include <string>
19#include <vector>
20#include <unordered_set>
21#include <boost/serialization/export.hpp>
22
23
24#define FMTGCBMDEATHID 15
25#define FMTGCBMGROWTHID 16
26#define FMTGCBMUNKNOWNID 17
27#define FMTGCBMWILDFIREID 10
28
29
30namespace Core
31{
32
34// DocString: FMTaction
41class FMTEXPORT FMTaction : public FMTlist<FMTspec>
42 {
43 friend class FMTactioncomparator;
44 public:
45 // DocString: FMTaction::operator+=
51 FMTaction& operator+=(const FMTaction & OtherAction);
52 // DocString: FMTaction()
57 // DocString: ~FMTaction()
61 virtual ~FMTaction() = default;
62 // DocString: FMTaction(const std::string&)
66 FMTaction(const std::string& lname);
67 // DocString: FMTaction(const std::string&,const bool&,const bool&)
71 FMTaction(const std::string& lname, const bool& lock, const bool& reset);
72 // DocString: FMTaction::push_aggregate
76 void push_aggregate(const std::string& aggregate);
77 // DocString: FMTaction::push_partials
81 void push_partials(const std::string& yield);
82 // DocString: FMTaction(const FMTaction&)
86 FMTaction(const FMTaction& rhs);
87 // DocString: FMTaction::operator=
91 FMTaction& operator = (const FMTaction& rhs);
92 // DocString: FMTaction::update
98 void update() override;
99 // DocString: FMTaction::presolve
105 const std::vector<FMTtheme>& originalthemes,
106 std::vector<FMTtheme>& newthemes, bool compressdata = false) const;
107 // DocString: FMTaction::getagelowerbound
111 inline const int& getagelowerbound() const
112 {
113 return agelowerbound;
114 }
115 // DocString: FMTaction::getageupperbound
119 inline const int& getageupperbound() const
120 {
121 return ageupperbound;
122 }
123 // DocString: FMTaction::getperiodlowerbound
127 inline const int& getperiodlowerbound() const
128 {
129 return periodlowerbound;
130 }
131 // DocString: FMTaction::getperiodupperbound
135 inline const int& getperiodupperbound() const
136 {
137 return periodupperbound;
138 }
139 // DocString: FMTaction::hash
143 inline size_t hash() const
144 {
145 return boost::hash<std::string>()(name);
146 }
147 // DocString: FMTaction::getname
151 inline std::string getname() const
152 {
153 return name;
154 }
155 // DocString: FMTaction::dorespectlock
160 inline bool dorespectlock() const
161 {
162 return lock;
163 }
164 // DocString: FMTaction::isresetage
169 inline bool isresetage() const
170 {
171 return reset;
172 }
173 // DocString: FMTaction::ispartofaserie
177 inline bool ispartofaserie() const
178 {
179 return !series.empty();
180 }
181 // DocString: FMTaction::isallowedinserie
186 bool isallowedinserie(const std::vector<std::string>& serie) const;
187 // DocString: FMTaction::getseriesnames
191 std::vector<std::string>getseriesnames() const;
192 // DocString: FMTaction::getlargestseriesize
196 size_t getlargestseriesize() const;
197 // DocString: FMTaction::setseries
202 void setseries(std::vector<std::vector<std::string>> seriesnames);
203 // DocString: FMTaction::useyield
207 bool useyield(const std::string& yldname) const;
208 // DocString: FMTaction::getaggregates
212 std::vector<std::string>getaggregates() const;
213 // DocString: FMTaction::setaggregates
218 void setaggregates(const std::vector<std::string>& p_aggregates);
219 // DocString: FMTaction::getpartials
223 std::vector<std::string>getpartials() const;
224 // DocString: FMTaction::operator<
228 bool operator < (const FMTaction& rhs) const;
229 // DocString: FMTaction::operator==
233 bool operator == (const FMTaction& rhs) const;
234 // DocString: FMTaction::operator!=
238 bool operator != (const FMTaction& rhs) const;
239 // DocString: FMTaction::operator std::string
243 operator std::string() const;
244 // DocString: FMTaction::partial
248 bool partial(const std::string& yield) const;
249 // DocString: FMTaction::getGCBMactionid
253 int getGCBMactionid() const;
254 // DocString: FMTaction::getGCBMactionname
258 std::string getGCBMactionname() const;
259 protected:
260 // DocString: FMTaction::aggregates
262 std::vector<std::string>aggregates;
263 // DocString: FMTaction::partials
265 std::vector<std::string>partials;
266 // DocString: FMTaction::agelowerbound
269 int agelowerbound, ageupperbound, periodlowerbound, periodupperbound;
270 // DocString: FMTaction::name
272 std::string name;
273 // DocString: FMTaction::lock
275 bool lock;
276 // DocString: FMTaction::reset
278 bool reset;
279 // DocString: FMTaction::series
281 std::vector<std::vector<std::string>>series;
282 // DocString: FMTaction::setbounds
287 void setbounds();
288 // DocString: FMTaction::getGCBMactiondef
292 std::vector<std::string>getGCBMactiondef() const;
293 private:
294 // DocString: FMTaction::serialize
298 friend class boost::serialization::access;
299 template<class Archive>
300 void serialize(Archive& ar, const unsigned int version)
301 {
302 try {
303 ar& boost::serialization::make_nvp("specs", boost::serialization::base_object<FMTlist<FMTspec>>(*this));
304 ar& BOOST_SERIALIZATION_NVP(partials);
305 ar& BOOST_SERIALIZATION_NVP(agelowerbound);
306 ar& BOOST_SERIALIZATION_NVP(ageupperbound);
307 ar& BOOST_SERIALIZATION_NVP(periodlowerbound);
308 ar& BOOST_SERIALIZATION_NVP(periodupperbound);
309 ar& BOOST_SERIALIZATION_NVP(name);
310 ar& BOOST_SERIALIZATION_NVP(aggregates);
311 ar& BOOST_SERIALIZATION_NVP(lock);
312 ar& BOOST_SERIALIZATION_NVP(reset);
313 }
314 catch (...)
315 {
316 _exhandler->printexceptions("", "FMTaction::serialize", __LINE__, __FILE__);
317 }
318 }
319 };
320
321// DocString: FMTactioncomparator
327 {
328 // DocString: FMTactioncomparator::action_name
330 std::string action_name;
331 // DocString: FMTactioncomparator::checkaggregate
333 bool checkaggregate;
334 public:
335 // DocString: FMTactioncomparator(std::string,bool)
340 FMTactioncomparator(std::string name, bool lcheckaggregate = false);
341 // DocString: FMTactioncomparator::getallaggregates
346 std::vector<const FMTaction*>getallaggregates(const std::vector<FMTaction>&actions,bool aggregateonly = false) const;
347 // DocString: FMTactioncomparator::getallaggregatesset
352 std::unordered_set<int>getallaggregatesset(const std::vector<FMTaction>&actions, bool aggregateonly = false) const;
353 // DocString: FMTactioncomparator::operator()(const FMTaction&)
357 bool operator()(const FMTaction& action) const;
358
359 };
360
361
362}
363
364namespace boost {
365
369 template <>
370 struct hash<Core::FMTaction>
371 {
372 std::size_t operator()(const Core::FMTaction& act) const
373 {
374 return (act.hash());
375 }
376 };
377
378
379}
380BOOST_CLASS_EXPORT_KEY(Core::FMTaction)
381#endif // FMTACT_H_INCLUDED
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTaction.hpp:42
std::vector< std::string > getaggregates() const
bool dorespectlock() const
Definition: FMTaction.hpp:160
bool isresetage() const
Definition: FMTaction.hpp:169
FMTaction(const FMTaction &rhs)
std::vector< std::vector< std::string > > series
The action series that the action is part of.
Definition: FMTaction.hpp:281
bool isallowedinserie(const std::vector< std::string > &serie) const
void setaggregates(const std::vector< std::string > &p_aggregates)
Set a new vector of aggregates.
std::string getname() const
Definition: FMTaction.hpp:151
std::string name
The name of the action.
Definition: FMTaction.hpp:272
bool lock
If lock is true the action is not _lockexempt when false the action is _LOCKEXEMPT.
Definition: FMTaction.hpp:275
bool reset
If reset is true then the action is age reset Y else the action doen't reset age.
Definition: FMTaction.hpp:278
virtual ~FMTaction()=default
void push_aggregate(const std::string &aggregate)
bool useyield(const std::string &yldname) const
FMTaction & operator+=(const FMTaction &OtherAction)
append OtherAction to this action actions need to be the same kind of age reset otherwise it will thr...
std::vector< std::string > getGCBMactiondef() const
FMTaction presolve(const FMTmaskfilter &filter, const std::vector< FMTtheme > &originalthemes, std::vector< FMTtheme > &newthemes, bool compressdata=false) const
void update() override
std::vector< std::string > aggregates
An action can be part of a aggregate so this data member gets the name of all aggregate the action is...
Definition: FMTaction.hpp:262
size_t hash() const
Definition: FMTaction.hpp:143
const int & getperiodlowerbound() const
Definition: FMTaction.hpp:127
FMTaction(const std::string &lname)
int getGCBMactionid() const
bool ispartofaserie() const
Definition: FMTaction.hpp:177
std::vector< std::string > partials
Keeps the yields name for determining the amount of wood harvested in case of partial cut.
Definition: FMTaction.hpp:265
void push_partials(const std::string &yield)
size_t getlargestseriesize() const
std::vector< std::string > getpartials() const
std::string getGCBMactionname() const
std::vector< std::string > getseriesnames() const
const int & getagelowerbound() const
Definition: FMTaction.hpp:111
FMTaction(const std::string &lname, const bool &lock, const bool &reset)
const int & getperiodupperbound() const
Definition: FMTaction.hpp:135
int agelowerbound
Definition: FMTaction.hpp:269
void setseries(std::vector< std::vector< std::string > > seriesnames)
bool partial(const std::string &yield) const
const int & getageupperbound() const
Definition: FMTaction.hpp:119
Definition: FMTaction.hpp:327
std::vector< const FMTaction * > getallaggregates(const std::vector< FMTaction > &actions, bool aggregateonly=false) const
std::unordered_set< int > getallaggregatesset(const std::vector< FMTaction > &actions, bool aggregateonly=false) const
bool operator()(const FMTaction &action) const
FMTactioncomparator(std::string name, bool lcheckaggregate=false)
Definition: FMTlist.hpp:46
Definition: FMTmaskfilter.hpp:27
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Definition: FMTaction.hpp:364
std::size_t operator()(const Core::FMTaction &act) const
Definition: FMTaction.hpp:372