8#ifndef FMTMASK_H_INCLUDED
9#define FMTMASK_H_INCLUDED
11#ifndef BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
12#define BOOST_DYNAMIC_BITSET_DONT_USE_FRIENDS
15#include <boost/dynamic_bitset.hpp>
16#include <boost/unordered_map.hpp>
17#include <boost/algorithm/string.hpp>
18#include <boost/algorithm/string/join.hpp>
19#include <boost/functional/hash.hpp>
20#include <boost/serialization/serialization.hpp>
21#include <boost/serialization/split_free.hpp>
22#include <boost/serialization/nvp.hpp>
23#include <boost/serialization/export.hpp>
24#include <boost/serialization/string.hpp>
25#include <boost/functional/hash.hpp>
35 namespace serialization {
37 template <
typename Ar,
typename Block,
typename Alloc>
38 void save(Ar& ar, dynamic_bitset<Block, Alloc>
const& bs,
unsigned) {
39 size_t num_bits = bs.size();
40 std::vector<Block> blocks(bs.num_blocks());
41 to_block_range(bs, blocks.begin());
43 ar & BOOST_SERIALIZATION_NVP(num_bits);
44 ar & BOOST_SERIALIZATION_NVP(blocks);
47 template <
typename Ar,
typename Block,
typename Alloc>
48 void load(Ar& ar, dynamic_bitset<Block, Alloc>& bs,
unsigned) {
50 std::vector<Block> blocks;
51 ar & BOOST_SERIALIZATION_NVP(num_bits);
52 ar & BOOST_SERIALIZATION_NVP(blocks);
55 from_block_range(blocks.begin(), blocks.end(), bs);
59 template <
typename Ar,
typename Block,
typename Alloc>
60 void serialize(Ar& ar, dynamic_bitset<Block, Alloc>& bs,
unsigned version) {
61 split_free(ar, bs, version);
69#if (BOOST_VERSION / 100 % 1000) < 71
71 template <
typename Block,
typename Alloc>
72 std::size_t
hash_value(
const boost::dynamic_bitset<Block, Alloc>& bs)
75 boost::hash_combine(hash, bs.m_bits);
102 friend class boost::serialization::access;
103 template<
class Archive>
104 void serialize(Archive& ar,
const unsigned int version)
106 ar & BOOST_SERIALIZATION_NVP(data);
107 ar & BOOST_SERIALIZATION_NVP(name);
114 boost::dynamic_bitset<> subset(
const FMTtheme& theme)
const;
119 void setsubset(
const FMTtheme& theme,
const boost::dynamic_bitset<>& subset);
125 boost::dynamic_bitset<> data;
156 explicit operator bool()
const;
161 FMTmask(
const std::string& mask,
const boost::dynamic_bitset<>& bits);
166 FMTmask(
const std::string& mask,
const std::vector<FMTtheme>& themes);
172 FMTmask(
const std::vector<std::string>& values,
const std::vector<FMTtheme>& themes);
198 std::string
get(
const std::vector<FMTtheme>& themes)
const;
213 void set(
const std::vector<FMTtheme>& themes,
const std::string& value);
249 void update(
const std::vector<FMTtheme>& themes);
260 void append(
const boost::dynamic_bitset<> &bits);
265 template <
class typetobinarize>
268 size_t location = data.size();
269 data.resize(data.size() + (
sizeof(typetobinarize) * 8));
270 const char* charelements =
reinterpret_cast<const char*
>(&element);
271 for (
size_t charit = 0; charit <
sizeof(typetobinarize); ++charit)
273 const char value = charelements[charit];
274 for (
int i = 7; i >= 0; --i)
276 data[location] = ((value & (1 << i)));
333 return boost::hash<boost::dynamic_bitset<>>()(data);
344 inline operator std::string()
const
352 inline bool issubsetof(
const boost::dynamic_bitset<>& rhs)
const
354 return data.is_subset_of(rhs);
362 return data.is_subset_of(rhs.data);
405template<>
inline void FMTmask::binarizedappend<std::string>(
const std::string& element)
407 size_t location = data.size();
408 data.resize(data.size() + (element.size() * 8));
409 const char* charelements = element.c_str();
410 for (
size_t charit = 0; charit < element.size(); ++charit)
412 const char value = charelements[charit];
413 for (
int i = 7; i >= 0; --i)
415 data[location] = ((value & (1 << i)));
421template<>
inline void FMTmask::binarizedappend<double>(
const double& element)
423 size_t location = data.size();
425 data.resize(data.size() + (
sizeof(int) * 8));
426 const char* charelements =
reinterpret_cast<const char*
>(&corrected);
427 for (
size_t charit = 0; charit <
sizeof(int); ++charit)
429 const char value = charelements[charit];
430 for (
int i = 7; i >= 0; --i)
432 data[location] = ((value & (1 << i)));
472 return (mask.
hash());
#define FMT_DBL_TOLERANCE
Definition: FMTutility.hpp:11
#define FMTEXPORT
Definition: FMTutility.hpp:92
Definition: FMTmask.hpp:96
std::vector< FMTtheme > getstaticthemes(const std::vector< FMTtheme > &themes) const
std::string getbitsstring() const
FMTmask(const boost::dynamic_bitset<> &bits)
std::string get(const std::vector< FMTtheme > &themes) const
FMTmask(const std::vector< FMTtheme > &themes)
FMTmask(const FMTmask &rhs)
FMTmask(const std::string &mask, const boost::dynamic_bitset<> &bits)
std::string get(const FMTtheme &theme) const
FMTmask resume(const boost::dynamic_bitset<> &rhs) const
FMTmask(const std::vector< std::string > &values, const std::vector< FMTtheme > &themes)
FMTmask(const std::string &mask, const std::vector< FMTtheme > &themes)
bool issubsetof(const FMTmask &rhs) const
Definition: FMTmask.hpp:360
void set(const std::vector< FMTtheme > &themes, const std::string &value)
const boost::dynamic_bitset & getbitsetreference() const
Definition: FMTmask.hpp:368
FMTmask presolve(const FMTmaskfilter &filter, const std::vector< FMTtheme > &presolvedthemes) const
void binarizedappend(const typetobinarize &element)
Definition: FMTmask.hpp:266
void set(const FMTtheme &theme, const std::string &value)
virtual ~FMTmask()=default
const std::string & getstringreference() const
Definition: FMTmask.hpp:376
FMTmask getintersect(const FMTmask &rhs) const
FMTmask getunion(const FMTmask &rhs) const
FMTmask refine(const FMTmask &mask, const std::vector< FMTtheme > &themes) const
bool issubsetof(const boost::dynamic_bitset<> &rhs) const
Definition: FMTmask.hpp:352
void update(const std::vector< FMTtheme > &themes)
FMTmask removeaggregates(const std::vector< FMTtheme > &themes, bool questionmarkonly=false) const
FMTmask resume(const std::vector< size_t > &indexes) const
FMTmask getpostsolvemask(const FMTmask &mask, const std::vector< FMTtheme > &themes) const
boost::dynamic_bitset getbitsetintersect(const FMTmask &rhs) const
size_t getsubsetcount(const FMTtheme &theme) const
void append(const boost::dynamic_bitset<> &bits)
FMTmask postsolve(const FMTmaskfilter &filter, const std::vector< FMTtheme > &basethemes) const
std::vector< FMTtheme > getselectedthemes(const std::vector< FMTtheme > &themes) const
size_t hash() const
Definition: FMTmask.hpp:331
bool isnotthemessubset(const FMTmask &rhs, const std::vector< FMTtheme > &themes) const
std::vector< FMTmask > decompose(const FMTtheme &theme) const
Definition: FMTmask.hpp:443
bool operator()(const FMTmask &mask) const
FMTmaskcomparator(const FMTmask &lbase_mask)
Definition: FMTmaskfilter.hpp:27
Definition: FMTtheme.hpp:47
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTaction.hpp:31
void load(Ar &ar, dynamic_bitset< Block, Alloc > &bs, unsigned)
Definition: FMTmask.hpp:48
void serialize(Ar &ar, dynamic_bitset< Block, Alloc > &bs, unsigned version)
Definition: FMTmask.hpp:60
void save(Ar &ar, dynamic_bitset< Block, Alloc > const &bs, unsigned)
Definition: FMTmask.hpp:38
Definition: FMTaction.hpp:364
std::size_t hash_value(const boost::dynamic_bitset< Block, Alloc > &bs)
Definition: FMTmask.hpp:72
std::size_t operator()(const Core::FMTmask &mask) const
Definition: FMTmask.hpp:470