User Guide
factor_def.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Blue Brain Project, EPFL.
3  * See the top-level LICENSE file for details.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 ///
9 /// THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
10 ///
11 
12 #pragma once
13 
14 /**
15  * \dir
16  * \brief Auto generated AST Implementations
17  *
18  * \file
19  * \brief Auto generated AST classes declaration
20  */
21 
22 #include "ast/ast_decl.hpp"
23 #include "ast/expression.hpp"
24 
25 namespace nmodl::ast {
26 
27 /**
28  * \addtogroup ast_class
29  * \ingroup ast
30  * \{
31  */
32 
33 /**
34  * \brief TODO
35  *
36  *
37 */
38 class FactorDef : public Expression {
39  private:
40  /// TODO
41  std::shared_ptr<Name> name;
42  /// TODO
43  std::shared_ptr<Double> value;
44  /// TODO
45  std::shared_ptr<Unit> unit1;
46  /// Todo: Michael : rename variable gt as well
47  std::shared_ptr<Boolean> gt;
48  /// TODO
49  std::shared_ptr<Unit> unit2;
50  /// token with location information
51  std::shared_ptr<ModToken> token;
52 
53  public:
54  /// \name Ctor & dtor
55  /// \{
57  explicit FactorDef(std::shared_ptr<Name> name, std::shared_ptr<Double> value, std::shared_ptr<Unit> unit1, std::shared_ptr<Boolean> gt, std::shared_ptr<Unit> unit2);
58  FactorDef(const FactorDef& obj);
59  FactorDef() = default;
60  virtual ~FactorDef() = default;
61  /// \}
62 
63  /**
64  * \brief Check if the ast node is an instance of ast::FactorDef
65  * \return true as object is of type ast::FactorDef
66  */
67  bool is_factor_def () const noexcept override {
68  return true;
69  }
70 
71  /**
72  * \brief Return a copy of the current node
73  *
74  * Recursively make a new copy/clone of the current node including
75  * all members and return a pointer to the node. This is used for
76  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
77  * ast.
78  *
79  * \return pointer to the clone/copy of the current node
80  */
81  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
82  FactorDef* clone() const override {
83  return new FactorDef(*this);
84  }
85  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
86 
87  /// \name Getters
88  /// \{
89 
90  /**
91  * \brief Return type (ast::AstNodeType) of ast node
92  *
93  * Every node in the ast has a type defined in ast::AstNodeType and this
94  * function is used to retrieve the same.
95  *
96  * \return ast node type i.e. ast::AstNodeType::FACTOR_DEF
97  *
98  * \sa Ast::get_node_type_name
99  */
100  AstNodeType get_node_type() const noexcept override {
102  }
103 
104  /**
105  * \brief Return type (ast::AstNodeType) of ast node as std::string
106  *
107  * Every node in the ast has a type defined in ast::AstNodeType.
108  * This type name can be returned as a std::string for printing
109  * node to text/json form.
110  *
111  * \return name of the node type as a string i.e. "FactorDef"
112  *
113  * \sa Ast::get_node_name
114  */
115  std::string get_node_type_name() const noexcept override {
116  return "FactorDef";
117  }
118 
119 
120  /**
121  * \brief Get std::shared_ptr from `this` pointer of the current ast node
122  */
123  std::shared_ptr<Ast> get_shared_ptr() override {
124  return std::static_pointer_cast<FactorDef>(shared_from_this());
125  }
126 
127  /**
128  * \brief Get std::shared_ptr from `this` pointer of the current ast node
129  */
130  std::shared_ptr<const Ast> get_shared_ptr() const override {
131  return std::static_pointer_cast<const FactorDef>(shared_from_this());
132  }
133 
134  /**
135  * \brief Return associated token for the current ast node
136  *
137  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
138  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
139  * nullptr to store in the nmodl::symtab::SymbolTable.
140  *
141  * \return pointer to token if exist otherwise nullptr
142  */
143  const ModToken* get_token() const noexcept override {
144  return token.get();
145  }
146 
147 
148  /**
149  * \brief Return name of the node
150  *
151  * Some ast nodes have a member marked designated as node name. For example,
152  * in case of this ast::Name has name designated as a
153  * node name.
154  *
155  * \return name of the node as std::string
156  *
157  * \sa Ast::get_node_type_name
158  */
159  std::string get_node_name() const override;
160 
161  /**
162  * \brief Getter for member variable \ref FactorDef.name
163  */
164  std::shared_ptr<Name> get_name() const noexcept {
165  return name;
166  }
167 
168 
169 
170  /**
171  * \brief Getter for member variable \ref FactorDef.value
172  */
173  std::shared_ptr<Double> get_value() const noexcept {
174  return value;
175  }
176 
177 
178 
179  /**
180  * \brief Getter for member variable \ref FactorDef.unit1
181  */
182  std::shared_ptr<Unit> get_unit1() const noexcept {
183  return unit1;
184  }
185 
186 
187 
188  /**
189  * \brief Getter for member variable \ref FactorDef.gt
190  */
191  std::shared_ptr<Boolean> get_gt() const noexcept {
192  return gt;
193  }
194 
195 
196 
197  /**
198  * \brief Getter for member variable \ref FactorDef.unit2
199  */
200  std::shared_ptr<Unit> get_unit2() const noexcept {
201  return unit2;
202  }
203  /// \}
204 
205  /// \name Setters
206  /// \{
207  /**
208  * \brief Set token for the current ast node
209  */
210  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
211 
212  /**
213  * \brief Setter for member variable \ref FactorDef.name (rvalue reference)
214  */
215  void set_name(std::shared_ptr<Name>&& name);
216 
217  /**
218  * \brief Setter for member variable \ref FactorDef.name
219  */
220  void set_name(const std::shared_ptr<Name>& name);
221 
222 
223  /**
224  * \brief Setter for member variable \ref FactorDef.value (rvalue reference)
225  */
226  void set_value(std::shared_ptr<Double>&& value);
227 
228  /**
229  * \brief Setter for member variable \ref FactorDef.value
230  */
231  void set_value(const std::shared_ptr<Double>& value);
232 
233 
234  /**
235  * \brief Setter for member variable \ref FactorDef.unit1 (rvalue reference)
236  */
237  void set_unit1(std::shared_ptr<Unit>&& unit1);
238 
239  /**
240  * \brief Setter for member variable \ref FactorDef.unit1
241  */
242  void set_unit1(const std::shared_ptr<Unit>& unit1);
243 
244 
245  /**
246  * \brief Setter for member variable \ref FactorDef.gt (rvalue reference)
247  */
248  void set_gt(std::shared_ptr<Boolean>&& gt);
249 
250  /**
251  * \brief Setter for member variable \ref FactorDef.gt
252  */
253  void set_gt(const std::shared_ptr<Boolean>& gt);
254 
255 
256  /**
257  * \brief Setter for member variable \ref FactorDef.unit2 (rvalue reference)
258  */
259  void set_unit2(std::shared_ptr<Unit>&& unit2);
260 
261  /**
262  * \brief Setter for member variable \ref FactorDef.unit2
263  */
264  void set_unit2(const std::shared_ptr<Unit>& unit2);
265 
266  /// \}
267 
268  /// \name Visitor
269  /// \{
270  /**
271  * \brief visit children i.e. member variables of current node using provided visitor
272  *
273  * Different nodes in the AST have different members (i.e. children). This method
274  * recursively visits children using provided visitor.
275  *
276  * \param v Concrete visitor that will be used to recursively visit children
277  *
278  * \sa Ast::visit_children for example.
279  */
280  void visit_children(visitor::Visitor& v) override;
281 
282  /**
283  * \brief visit children i.e. member variables of current node using provided visitor
284  *
285  * Different nodes in the AST have different members (i.e. children). This method
286  * recursively visits children using provided visitor.
287  *
288  * \param v Concrete constant visitor that will be used to recursively visit children
289  *
290  * \sa Ast::visit_children for example.
291  */
292  void visit_children(visitor::ConstVisitor& v) const override;
293 
294  /**
295  * \brief accept (or visit) the current AST node using provided visitor
296  *
297  * Instead of visiting children of AST node, like Ast::visit_children,
298  * accept allows to visit the current node itself using provided concrete
299  * visitor.
300  *
301  * \param v Concrete visitor that will be used to recursively visit node
302  *
303  * \sa Ast::accept for example.
304  */
305  void accept(visitor::Visitor& v) override;
306 
307  /**
308  * \copydoc accept(visitor::Visitor&)
309  */
310  void accept(visitor::ConstVisitor& v) const override;
311  /// \}
312 
313  private:
314  /**
315  * \brief Set this object as parent for all the children
316  *
317  * This should be called in every object (with children) constructor
318  * to set parents. Since it is called only in the constructors it
319  * should not be virtual to avoid ambiguities (issue #295).
320  */
321  void set_parent_in_children();
322 };
323 
324 /** \} */ // end of ast_class
325 
326 
327 
328 
329 
330 
331 
332 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::Unit
TODO.
Definition: unit.hpp:38
nmodl::ast::FactorDef::get_node_name
std::string get_node_name() const override
Return name of the node.
Definition: ast.cpp:7487
nmodl::ast::FactorDef::gt
std::shared_ptr< Boolean > gt
Todo: Michael : rename variable gt as well.
Definition: factor_def.hpp:47
nmodl::ast::FactorDef
TODO.
Definition: factor_def.hpp:38
nmodl::ast::FactorDef::FactorDef
FactorDef()=default
nmodl::ast::Double
Represents a double variable.
Definition: double.hpp:53
nmodl::ast::FactorDef::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:7503
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::FactorDef::is_factor_def
bool is_factor_def() const noexcept override
Check if the ast node is an instance of ast::FactorDef.
Definition: factor_def.hpp:67
nmodl::ast::FactorDef::~FactorDef
virtual ~FactorDef()=default
nmodl::ast::FactorDef::set_unit2
void set_unit2(std::shared_ptr< Unit > &&unit2)
Setter for member variable FactorDef::unit2 (rvalue reference)
Definition: ast.cpp:7697
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::FactorDef::unit2
std::shared_ptr< Unit > unit2
TODO.
Definition: factor_def.hpp:49
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:166
nmodl::ast::FactorDef::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: factor_def.hpp:115
nmodl::ast::FactorDef::get_gt
std::shared_ptr< Boolean > get_gt() const noexcept
Getter for member variable FactorDef::gt.
Definition: factor_def.hpp:191
nmodl::ast::FactorDef::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: factor_def.hpp:143
nmodl::ast::FactorDef::get_value
std::shared_ptr< Double > get_value() const noexcept
Getter for member variable FactorDef::value.
Definition: factor_def.hpp:173
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::FactorDef::set_gt
void set_gt(std::shared_ptr< Boolean > &&gt)
Setter for member variable FactorDef::gt (rvalue reference)
Definition: ast.cpp:7680
nmodl::ast::FactorDef::token
std::shared_ptr< ModToken > token
token with location information
Definition: factor_def.hpp:51
nmodl::ast::FactorDef::get_unit2
std::shared_ptr< Unit > get_unit2() const noexcept
Getter for member variable FactorDef::unit2.
Definition: factor_def.hpp:200
nmodl::ast::FactorDef::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:7551
nmodl::ast::Boolean
Represents a boolean variable.
Definition: boolean.hpp:42
nmodl::ast::FactorDef::get_name
std::shared_ptr< Name > get_name() const noexcept
Getter for member variable FactorDef::name.
Definition: factor_def.hpp:164
nmodl::ast::FactorDef::value
std::shared_ptr< Double > value
TODO.
Definition: factor_def.hpp:43
nmodl::ast::FactorDef::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: factor_def.hpp:100
nmodl::ast::FactorDef::unit1
std::shared_ptr< Unit > unit1
TODO.
Definition: factor_def.hpp:45
nmodl::ast::FactorDef::get_unit1
std::shared_ptr< Unit > get_unit1() const noexcept
Getter for member variable FactorDef::unit1.
Definition: factor_def.hpp:182
nmodl::ast::FactorDef::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: factor_def.hpp:123
nmodl::ast::AstNodeType::FACTOR_DEF
@ FACTOR_DEF
type of ast::FactorDef
nmodl::ast::FactorDef::clone
FactorDef * clone() const override
Return a copy of the current node.
Definition: factor_def.hpp:82
nmodl::ast::FactorDef::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:7602
nmodl::ast::FactorDef::get_shared_ptr
std::shared_ptr< const Ast > get_shared_ptr() const override
Get std::shared_ptr from this pointer of the current ast node.
Definition: factor_def.hpp:130
nmodl::ast::Name
Represents a name.
Definition: name.hpp:44
expression.hpp
Auto generated AST classes declaration.
nmodl::ast::FactorDef::set_name
void set_name(std::shared_ptr< Name > &&name)
Setter for member variable FactorDef::name (rvalue reference)
Definition: ast.cpp:7629
nmodl::ast::Expression
Base class for all expressions in the NMODL.
Definition: expression.hpp:43
nmodl::ast::FactorDef::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: factor_def.hpp:210
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::FactorDef::set_value
void set_value(std::shared_ptr< Double > &&value)
Setter for member variable FactorDef::value (rvalue reference)
Definition: ast.cpp:7646
nmodl::ast::FactorDef::name
std::shared_ptr< Name > name
TODO.
Definition: factor_def.hpp:41
nmodl::ast::FactorDef::set_unit1
void set_unit1(std::shared_ptr< Unit > &&unit1)
Setter for member variable FactorDef::unit1 (rvalue reference)
Definition: ast.cpp:7663