Chrysalis - Pattern
Toggle main menu visibility
Loading...
Searching...
No Matches
BinaryFunctionArgument.h
Go to the documentation of this file.
1
#ifndef CHRYSALIS_BINARYFUNCTIONARGUMENT_H
2
#define CHRYSALIS_BINARYFUNCTIONARGUMENT_H
3
4
#include "
arguments/BaseCalculatedArgument.h
"
5
6
#define BINARY_FUNCTIONS (Add)(Subtract)(Multiply)(Divide)(Min)(Max)
7
11
namespace
Chrysalis
{
12
class
BinaryFunctionArgument
:
public
BaseCalculatedArgument
<double> {
13
SERIALIZE_DERIVED_FROM
(
BaseCalculatedArgument
)
14
protected
:
15
explicit
BinaryFunctionArgument
(
args::number
&& operand1,
args::number
&& operand2);
16
public
:
17
#define FORWARD_DECLARE(r, data, Name) class Name;
18
BOOST_PP_SEQ_FOR_EACH(
FORWARD_DECLARE
, _,
BINARY_FUNCTIONS
)
19
#undef FORWARD_DECLARE
20
protected
:
21
std::expected<double, Error>
calculate
()
const override
;
22
virtual
std::expected<double, Error>
evaluate
(
double
a,
double
b)
const
= 0;
23
25
args::number
operand1_
;
27
args::number
operand2_
;
28
};
29
30
#define DECLARE_BINARY_FUNCTION(r, data, Name) \
31
class BinaryFunctionArgument::Name: public BinaryFunctionArgument { \
32
PROVIDE_SERIALIZATION_ACCESS(BinaryFunctionArgument::Name) \
33
public: \
34
explicit Name(args::number&& operand1, args::number&& operand2) \
35
: BinaryFunctionArgument(std::move(operand1), std::move(operand2)) {} \
36
protected: \
37
std::expected<double, Error> evaluate(double a, double b) const override; \
38
}; \
39
SERIALIZE_DERIVED_CONSTRUCTION(BinaryFunctionArgument::Name, BinaryFunctionArgument, operand1_, operand2_);
40
BOOST_PP_SEQ_FOR_EACH(
DECLARE_BINARY_FUNCTION
, _,
BINARY_FUNCTIONS
)
41
#undef DECLARE_BINARY_FUNCTION
42
}
44
45
#endif
//CHRYSALIS_BINARYFUNCTIONARGUMENT_H
BaseCalculatedArgument.h
BINARY_FUNCTIONS
#define BINARY_FUNCTIONS
Definition
BinaryFunctionArgument.h:6
FORWARD_DECLARE
#define FORWARD_DECLARE(r, data, Name)
Definition
BinaryFunctionArgument.h:17
DECLARE_BINARY_FUNCTION
#define DECLARE_BINARY_FUNCTION(r, data, Name)
Definition
BinaryFunctionArgument.h:30
Chrysalis::BaseCalculatedArgument< double >::BaseCalculatedArgument
BaseCalculatedArgument()=default
Chrysalis::BinaryFunctionArgument::operand2_
args::number operand2_
Definition
BinaryFunctionArgument.h:27
Chrysalis::BinaryFunctionArgument::operand1_
args::number operand1_
Definition
BinaryFunctionArgument.h:25
Chrysalis::BinaryFunctionArgument::calculate
std::expected< double, Error > calculate() const override
Definition
BinaryFunctionArgument.cpp:8
Chrysalis::BinaryFunctionArgument::evaluate
virtual std::expected< double, Error > evaluate(double a, double b) const =0
Chrysalis::BinaryFunctionArgument::BinaryFunctionArgument
BinaryFunctionArgument(args::number &&operand1, args::number &&operand2)
Definition
BinaryFunctionArgument.cpp:5
Chrysalis::args::number
std::unique_ptr< BaseArgument< double > > number
Definition
BaseArgument.h:25
Chrysalis
Definition
Argument.h:9
SERIALIZE_DERIVED_FROM
#define SERIALIZE_DERIVED_FROM(Base,...)
Definition
serialization.h:71
pattern
include
arguments
BinaryFunctionArgument.h
Generated by
1.17.0