FMT 1.2.0
Forest management tools for forest planning
Loading...
Searching...
No Matches
FMTOperator.h
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#ifndef FMTOPE_Hm_included
9#define FMTOPE_Hm_included
10
11#include "FMTutility.h"
12#include <string>
13#include <vector>
14#include <boost/functional/hash.hpp>
15#include <boost/serialization/serialization.hpp>
16#include <boost/serialization/nvp.hpp>
17#include "FMTException.h"
18
19
20
21namespace Core
22{
23
24 // DocString: FMTokey
28 enum class FMTokey
29 {
30 multiply = 1,
31 divide = 2,
32 add = 3,
33 sub = 4,
34 comma = 5,
35 pow = 6,
36 notvalid = 7
37 };
38
39// DocString: FMTOperator
44{
45public:
46 // DocString: FMTOperator()
51 // DocString: ~FMTOperator()
55 ~FMTOperator() = default;
56 // DocString: FMTOperator(FMTokey)
62 // DocString: FMTOperator(std::string)
67 FMTOperator(std::string strkey);
68 // DocString: FMTOperator::operator==
74 bool operator == (const FMTOperator& rhs) const;
75 // DocString: FMTOperator::operator!=
81 bool operator != (const FMTOperator& rhs) const;
82 // DocString: FMTOperator::call
89 double call(const double& rhs1, const double& rhs2) const;
90 // DocString: FMTOperator(const FMTOperator&)
96 // DocString: FMTOperator::operator=
102 FMTOperator& operator = (const FMTOperator& rhs);
103 // DocString: FMTOperator::precedence
108 int precedence() const;
109 // DocString: FMTOperator::associativity
114 std::string associativity() const;
115 // DocString: FMTOperator::reverse
121 // DocString: FMTOperator::valid
126 bool valid() const;
127 // DocString: FMTOperator::hash
132 size_t hash() const;
133 // DocString: FMTOperator::isFactor
138 bool isFactor() const;
139 // DocString: FMTOperator::isDivide
144 bool isDivide() const;
145 // DocString: FMTOperator::getKey
151 // DocString: FMTOperator::operator std::string
156 operator std::string() const;
157private:
158 FMTokey m_key;
159 friend class boost::serialization::access;
160 // DocString: FMTOperator::serialize
167 template<class Archive>
168 void serialize(Archive& ar, const unsigned int version)
169 {
170 ar & boost::serialization::make_nvp("key", m_key);
171 }
172};
173
174}
175
176#endif // FMTOPE_Hm_included
#define FMTEXPORT
Definition: FMTutility.h:125
Mathematical operator usable in yield and output expressions.
Definition: FMTOperator.h:44
bool valid() const
Return true if the operator is valid.
std::string associativity() const
Return the associativity of the operator.
bool isDivide() const
Return true if the operator is a division.
double call(const double &rhs1, const double &rhs2) const
Apply the operator to two values.
FMTOperator()
Default constructor for FMTOperator.
bool isFactor() const
Return true if the operator is a multiplication or a division.
FMTokey getKey() const
Return the key of the operator.
FMTOperator(const FMTOperator &rhs)
Copy constructor for FMTOperator.
~FMTOperator()=default
Default destructor for FMTOperator.
FMTOperator(std::string strkey)
Construct a FMTOperator from a string key.
size_t hash() const
Return the hash of the operator.
FMTOperator(FMTokey lkey)
Construct a FMTOperator from an operator key.
FMTOperator reverse() const
Return the reversed operator.
int precedence() const
Return the precedence of the operator.
The Core namespace provides classes for simulating stands/strata growth/harvest through time.
Definition: FMTAction.h:34
FMTokey
Enumerator of the operators usable in an FMTOperator (multiply, divide, add, sub, comma,...
Definition: FMTOperator.h:29