Antares Simulator
Power System Simulator
FunctionNode.h
1 /*
2 ** Copyright 2007-2025, RTE (https://www.rte-france.com)
3 ** See AUTHORS.txt
4 ** SPDX-License-Identifier: MPL-2.0
5 ** This file is part of Antares-Simulator,
6 ** Adequacy and Performance assessment for interconnected energy networks.
7 **
8 ** Antares_Simulator is free software: you can redistribute it and/or modify
9 ** it under the terms of the Mozilla Public Licence 2.0 as published by
10 ** the Mozilla Foundation, either version 2 of the License, or
11 ** (at your option) any later version.
12 **
13 ** Antares_Simulator is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ** Mozilla Public Licence 2.0 for more details.
17 **
18 ** You should have received a copy of the Mozilla Public Licence 2.0
19 ** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20 */
21 #pragma once
22 
23 #include <string>
24 
25 #include "antares/expressions/nodes/ParentNode.h"
26 
27 namespace Antares::Expressions::Nodes
28 {
29 
33 enum class FunctionNodeType
34 {
35  reduced_cost,
36  dual,
37  max,
38  min,
39  pow,
40 };
41 
48 std::string FunctionNodeTypeToString(FunctionNodeType type);
49 
62 class FunctionNode final: public ParentNode
63 {
64 public:
72  template<typename... NodePtr>
73  explicit FunctionNode(FunctionNodeType type, NodePtr... operands):
74  ParentNode(operands...),
75  type_(type)
76 
77  {
78  }
79 
86  explicit FunctionNode(FunctionNodeType type, const std::vector<Node*>& operands):
87  ParentNode(operands),
88  type_(type)
89  {
90  }
91 
98  explicit FunctionNode(FunctionNodeType type, std::vector<Node*>&& operands):
99  ParentNode(std::move(operands)),
100  type_(type)
101  {
102  }
103 
107  std::string name() const override
108  {
109  return "FunctionNode::" + FunctionNodeTypeToString(type_);
110  }
111 
115  FunctionNodeType type() const
116  {
117  return type_;
118  }
119 
123  std::string typeToString() const
124  {
125  return FunctionNodeTypeToString(type_);
126  }
127 
128 private:
129  FunctionNodeType type_;
130 };
131 } // namespace Antares::Expressions::Nodes
AST node representing a function expression (max, min, pow, ...).
Definition: FunctionNode.h:63
std::string name() const override
Definition: FunctionNode.h:107
FunctionNode(FunctionNodeType type, const std::vector< Node * > &operands)
Construct a FunctionNode from an existing vector of operands.
Definition: FunctionNode.h:86
FunctionNodeType type() const
Definition: FunctionNode.h:115
FunctionNode(FunctionNodeType type, NodePtr... operands)
Construct a FunctionNode from a list of operands.
Definition: FunctionNode.h:73
FunctionNode(FunctionNodeType type, std::vector< Node * > &&operands)
Construct a FunctionNode by moving operand vector.
Definition: FunctionNode.h:98
std::string typeToString() const
Definition: FunctionNode.h:123
Definition: ParentNode.h:41