codac 2.0.0
|
A base class for expressions representing operations with multiple operands. More...
#include <codac2_ExprBase.h>
Public Member Functions | |
OperationExprBase (std::shared_ptr< X >... x) | |
Constructs an OperationExprBase with operand expressions. | |
OperationExprBase (const OperationExprBase< X... > &e) | |
Copy constructor. | |
void | replace_arg (const ExprID &old_arg_id, const std::shared_ptr< ExprBase > &new_expr) |
Replaces a variable by a new expression. | |
Static Protected Member Functions | |
template<typename X_> | |
static std::shared_ptr< X_ > | __copy (const std::shared_ptr< X_ > &x) |
Helper function to copy a single operand expression. | |
template<typename D> | |
static void | __replace_arg (std::shared_ptr< D > &x, const ExprID &old_arg_id, const std::shared_ptr< ExprBase > &new_expr) |
Helper function to replace a variable by a new expression. | |
Protected Attributes | |
std::tuple< std::shared_ptr< X >... > | _x |
tuple storing the operand expressions | |
A base class for expressions representing operations with multiple operands.
The OperationExprBase
class is a templated class designed to represent operations (e.g., addition, multiplication, squared root) that involve one or multiple operand expressions. The class holds a tuple of operand expressions, supports copying of operands, and provides functionality to replace specific expressions within the operation. The class is designed to be inherited by concrete operation expression classes, where the operands will be specialized.
X | The types of the operands in the operation. It supports an arbitrary number of operand types via variadic templates. |
|
inline |
Constructs an OperationExprBase
with operand expressions.
This constructor initializes the operation expression with a set of operand expressions, which are passed as shared pointers. These operands are stored in a tuple for efficient access and manipulation.
x | A variadic list of shared pointers to the operand expressions. |
|
inline |
Copy constructor.
This constructor creates a new OperationExprBase
by copying the operand expressions from another instance. Each operand is deep-copied using the copy()
method of the underlying expression objects, ensuring that the new instance has independent copies of the operands.
e | The OperationExprBase instance to copy from. |
|
inline |
Replaces a variable by a new expression.
This method replaces, in the current expression, a specific variable (corresponding to the old_arg_id
) with a new expression.
old_arg_id | The ExprID of the variable to replace. |
new_expr | A shared pointer to the new expression to insert. |
|
inlinestaticprotected |
Helper function to copy a single operand expression.
This function performs a deep copy of an operand expression.
X_ | The type of the operand expression. |
x | A shared pointer to the operand expression to copy. |
|
inlinestaticprotected |
Helper function to replace a variable by a new expression.
This function replaces, in the expression pointed by x
, a specific variable (an argument, corresponding to the old_arg_id
) with a new expression.
D | The type of the current expression. |
x | A reference to the shared pointer of the current expression. |
old_arg_id | The ExprID of the variable to replace. |
new_expr | A shared pointer to the new expression to insert. |