8#ifndef FMTtheme_H_INCLUDED
9#define FMTtheme_H_INCLUDED
11#include <boost/dynamic_bitset_fwd.hpp>
12#include <boost/serialization/serialization.hpp>
16#include <boost/serialization/nvp.hpp>
17#include <boost/serialization/map.hpp>
18#include <boost/serialization/export.hpp>
19#include <boost/serialization/string.hpp>
22#include <unordered_map>
30 class FMTlandscapeparser;
62 friend class boost::serialization::access;
63 template<
class Archive>
64 void serialize(Archive& ar,
const unsigned int version)
67 ar & boost::serialization::make_nvp(
"FMTobject", boost::serialization::base_object<FMTobject>(*
this));
68 ar & BOOST_SERIALIZATION_NVP(
id);
69 ar & BOOST_SERIALIZATION_NVP(start);
70 ar & BOOST_SERIALIZATION_NVP(attributes);
71 ar & BOOST_SERIALIZATION_NVP(attributenames);
72 ar & BOOST_SERIALIZATION_NVP(aggregates);
73 ar & BOOST_SERIALIZATION_NVP(aggregatenames);
74 ar & BOOST_SERIALIZATION_NVP(indexes);
75 ar & BOOST_SERIALIZATION_NVP(name);
76 buildattributelocations();
79 _exhandler->printexceptions(
"",
"FMTtheme::serialize", __LINE__, __FILE__);
84 std::vector<std::string>attributes;
87 std::vector<std::string>attributenames;
90 std::vector<std::string>aggregates;
93 std::vector<std::vector<std::string>>aggregatenames;
96 std::vector<std::map<std::string, double>>indexes;
99 std::unordered_map<std::string, std::vector<size_t>>attribute_locations;
102 typedef typename std::unordered_map<std::string, std::vector<size_t>>::const_iterator lookiterator;
110 boost::dynamic_bitset<> strtobits(
const std::string& value)
const;
115 std::string bitstostr(
const boost::dynamic_bitset<>& bits)
const;
120 lookiterator getattribute(
const std::string& value,
bool raiseifnotfound =
false)
const;
126 void buildattributelocations();
131 void fillupaggregates(std::vector<int>& themeids, std::vector<std::string>& locattributes, std::vector<std::string>& locaggregates)
const;
136 void push_aggregate(
const std::string& aggregatename);
141 void push_aggregate_value(
const std::string& aggregatename,
const std::string& value);
157 FMTtheme(
const std::vector<std::string>& lattributes,
158 const std::vector<std::string>& lattributenames,
159 const std::vector<std::string>& laggregates,
160 const std::vector<std::vector<std::string>>& laggregatenames,
161 const std::vector<std::map<std::string, double>>& lindexes,
162 const size_t& lid,
const size_t& lstart,
const std::string& lname);
167 FMTtheme(
const std::vector<std::string>& lattributes,
168 const std::vector<std::string>& lattributenames,
169 const std::vector<std::string>& laggregates,
170 const std::vector<std::vector<std::string>>& laggregatenames,
171 const size_t& lid,
const size_t& lstart,
const std::string& lname);
176 FMTtheme(
const std::vector<std::string>& lattributes,
177 const size_t& lid,
const size_t& lstart,
const std::string& lname);
194 return (getattribute(value) != attribute_locations.end());
202 return (std::find(aggregates.begin(),aggregates.end(),value)!= aggregates.end());
208 bool isindex(
const std::string& attribute,
const std::string& value)
const;
223 double getindex(
const std::string& attribute,
const std::string& value)
const;
228 bool inaggregate(
const std::string& value,
const std::string& aggregate);
245 return attributes.size();
277 return attributes.empty();
284 std::vector<std::string>
getattributes(
const std::string& value,
bool aggregate_source =
false)
const;
299 return attributenames;
318 operator std::string()
const;
324 Rcpp::DataFrame getaggregatesasdataframe()
const;
329 Rcpp::DataFrame getattributesasdataframe()
const;
337 static bool validate(
const std::vector<Core::FMTtheme>& themes,
338 std::string& mask, std::string otherinformation = std::string());
344 static bool checkmask(
const std::vector<Core::FMTtheme>& themes,
345 const std::vector<std::string>& values, std::string& mask,
346 const std::string& otherinformation);
365 bool comparedwithpresolved;
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTmask.hpp:96
Definition: FMTmaskfilter.hpp:27
Definition: FMTobject.hpp:50
Definition: FMTtheme.hpp:47
static bool checkmask(const std::vector< Core::FMTtheme > &themes, const std::vector< std::string > &values, std::string &mask, const std::string &otherinformation)
bool isaggregate(const std::string &value) const
Definition: FMTtheme.hpp:200
size_t id
Id is the id of the theme first theme in the landscape section is number 1.
Definition: FMTtheme.hpp:53
FMTtheme(const std::vector< std::string > &lattributes, const std::vector< std::string > &lattributenames, const std::vector< std::string > &laggregates, const std::vector< std::vector< std::string > > &laggregatenames, const size_t &lid, const size_t &lstart, const std::string &lname)
static bool validate(const std::vector< Core::FMTtheme > &themes, std::string &mask, std::string otherinformation=std::string())
size_t size() const
Definition: FMTtheme.hpp:243
bool isindex(const std::string &attribute, const std::string &value) const
const std::vector< std::string > & getbaseattributes() const
Definition: FMTtheme.hpp:289
double getindex(const std::string &attribute, const std::string &value) const
FMTtheme(const std::vector< std::string > &lattributes, const std::vector< std::string > &lattributenames, const std::vector< std::string > &laggregates, const std::vector< std::vector< std::string > > &laggregatenames, const std::vector< std::map< std::string, double > > &lindexes, const size_t &lid, const size_t &lstart, const std::string &lname)
FMTtheme(const FMTtheme &rhs)
std::string getname() const
Definition: FMTtheme.hpp:267
bool isvalid(const std::string &value) const
bool inaggregate(const std::string &value, const std::string &aggregate)
size_t start
Start is the bit location in the FMTmask at which the attributes of the theme starts.
Definition: FMTtheme.hpp:56
const size_t & getid() const
Definition: FMTtheme.hpp:259
std::vector< std::string > getattributes(const std::string &value, bool aggregate_source=false) const
const std::vector< std::string > & getattributenames() const
Definition: FMTtheme.hpp:297
FMTtheme(const std::vector< std::string > &lattributes, const size_t &lid, const size_t &lstart, const std::string &lname)
bool isattribute(const std::string &value) const
Definition: FMTtheme.hpp:192
std::string updatefrommask(const Core::FMTmask &globalmask)
bool empty() const
Definition: FMTtheme.hpp:275
const size_t & getstart() const
Definition: FMTtheme.hpp:251
std::vector< std::string > getaggregates() const
bool isindex(const std::string &value) const
FMTtheme presolve(FMTmaskfilter &maskfilter, size_t &newid, size_t &newstart) const
Definition: FMTtheme.hpp:359
bool operator()(const FMTtheme &theme) const
FMTthemecomparator(const FMTtheme &lbase_theme, const bool &lcomparedwithpresolved=false)
Definition: FMTlandscapeparser.hpp:36
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
Namespace handling all FMT's parsers. Everything related to I/O should be located in this namespace.
Definition: FMTactionparser.hpp:26