User Guide
useion.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/read_ion_var.hpp"
24 #include "ast/statement.hpp"
25 #include "ast/write_ion_var.hpp"
26 
27 namespace nmodl::ast {
28 
29 /**
30  * \addtogroup ast_class
31  * \ingroup ast
32  * \{
33  */
34 
35 /**
36  * \brief Represents USEION statement in NMODL
37  *
38  *
39 */
40 class Useion : public Statement {
41  private:
42  /// Name of ion
43  std::shared_ptr<Name> name;
44  /// Variables being read
46  /// Variables being written
48  /// (TODO)
49  std::shared_ptr<Valence> valence;
50  /// Ontology to indicate the chemical ion
51  std::shared_ptr<String> ontology_id;
52  /// token with location information
53  std::shared_ptr<ModToken> token;
54 
55  public:
56  /// \name Ctor & dtor
57  /// \{
59  explicit Useion(std::shared_ptr<Name> name, const ReadIonVarVector& readlist, const WriteIonVarVector& writelist, std::shared_ptr<Valence> valence, std::shared_ptr<String> ontology_id);
60  Useion(const Useion& obj);
61  virtual ~Useion() = default;
62  /// \}
63 
64  /**
65  * \brief Check if the ast node is an instance of ast::Useion
66  * \return true as object is of type ast::Useion
67  */
68  bool is_useion () const noexcept override {
69  return true;
70  }
71 
72  /**
73  * \brief Return a copy of the current node
74  *
75  * Recursively make a new copy/clone of the current node including
76  * all members and return a pointer to the node. This is used for
77  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
78  * ast.
79  *
80  * \return pointer to the clone/copy of the current node
81  */
82  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
83  Useion* clone() const override {
84  return new Useion(*this);
85  }
86  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
87 
88  /// \name Getters
89  /// \{
90 
91  /**
92  * \brief Return type (ast::AstNodeType) of ast node
93  *
94  * Every node in the ast has a type defined in ast::AstNodeType and this
95  * function is used to retrieve the same.
96  *
97  * \return ast node type i.e. ast::AstNodeType::USEION
98  *
99  * \sa Ast::get_node_type_name
100  */
101  AstNodeType get_node_type() const noexcept override {
102  return AstNodeType::USEION;
103  }
104 
105  /**
106  * \brief Return type (ast::AstNodeType) of ast node as std::string
107  *
108  * Every node in the ast has a type defined in ast::AstNodeType.
109  * This type name can be returned as a std::string for printing
110  * node to text/json form.
111  *
112  * \return name of the node type as a string i.e. "Useion"
113  *
114  * \sa Ast::get_node_name
115  */
116  std::string get_node_type_name() const noexcept override {
117  return "Useion";
118  }
119 
120  /**
121  * \brief Return NMODL statement of ast node as std::string
122  *
123  * Every node is related to a special statement in the NMODL. This
124  * statement can be returned as a std::string for printing to
125  * text/json form.
126  *
127  * \return name of the statement as a string i.e. "USEION "
128  *
129  * \sa Ast::get_nmodl_name
130  */
131  std::string get_nmodl_name() const noexcept override {
132  return "USEION ";
133  }
134 
135  /**
136  * \brief Get std::shared_ptr from `this` pointer of the current ast node
137  */
138  std::shared_ptr<Ast> get_shared_ptr() override {
139  return std::static_pointer_cast<Useion>(shared_from_this());
140  }
141 
142  /**
143  * \brief Get std::shared_ptr from `this` pointer of the current ast node
144  */
145  std::shared_ptr<const Ast> get_shared_ptr() const override {
146  return std::static_pointer_cast<const Useion>(shared_from_this());
147  }
148 
149  /**
150  * \brief Return associated token for the current ast node
151  *
152  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
153  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
154  * nullptr to store in the nmodl::symtab::SymbolTable.
155  *
156  * \return pointer to token if exist otherwise nullptr
157  */
158  const ModToken* get_token() const noexcept override {
159  return token.get();
160  }
161 
162 
163  /**
164  * \brief Return name of the node
165  *
166  * Some ast nodes have a member marked designated as node name. For example,
167  * in case of this ast::Name has name designated as a
168  * node name.
169  *
170  * \return name of the node as std::string
171  *
172  * \sa Ast::get_node_type_name
173  */
174  std::string get_node_name() const override;
175 
176  /**
177  * \brief Getter for member variable \ref Useion.name
178  */
179  std::shared_ptr<Name> get_name() const noexcept {
180  return name;
181  }
182 
183 
184 
185  /**
186  * \brief Getter for member variable \ref Useion.readlist
187  */
188  const ReadIonVarVector& get_readlist() const noexcept {
189  return readlist;
190  }
191 
192 
193 
194  /**
195  * \brief Getter for member variable \ref Useion.writelist
196  */
197  const WriteIonVarVector& get_writelist() const noexcept {
198  return writelist;
199  }
200 
201 
202 
203  /**
204  * \brief Getter for member variable \ref Useion.valence
205  */
206  std::shared_ptr<Valence> get_valence() const noexcept {
207  return valence;
208  }
209 
210 
211 
212  /**
213  * \brief Getter for member variable \ref Useion.ontology_id
214  */
215  std::shared_ptr<String> get_ontology_id() const noexcept {
216  return ontology_id;
217  }
218  /// \}
219 
220  /// \name Setters
221  /// \{
222  /**
223  * \brief Set token for the current ast node
224  */
225  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
226 
227  /**
228  * \brief Setter for member variable \ref Useion.name (rvalue reference)
229  */
230  void set_name(std::shared_ptr<Name>&& name);
231 
232  /**
233  * \brief Setter for member variable \ref Useion.name
234  */
235  void set_name(const std::shared_ptr<Name>& name);
236 
237 
238  /**
239  * \brief Setter for member variable \ref Useion.readlist (rvalue reference)
240  */
242 
243  /**
244  * \brief Setter for member variable \ref Useion.readlist
245  */
247 
248 
249  /**
250  * \brief Setter for member variable \ref Useion.writelist (rvalue reference)
251  */
253 
254  /**
255  * \brief Setter for member variable \ref Useion.writelist
256  */
258 
259 
260  /**
261  * \brief Setter for member variable \ref Useion.valence (rvalue reference)
262  */
263  void set_valence(std::shared_ptr<Valence>&& valence);
264 
265  /**
266  * \brief Setter for member variable \ref Useion.valence
267  */
268  void set_valence(const std::shared_ptr<Valence>& valence);
269 
270 
271  /**
272  * \brief Setter for member variable \ref Useion.ontology_id (rvalue reference)
273  */
274  void set_ontology_id(std::shared_ptr<String>&& ontology_id);
275 
276  /**
277  * \brief Setter for member variable \ref Useion.ontology_id
278  */
279  void set_ontology_id(const std::shared_ptr<String>& ontology_id);
280 
281  /// \}
282 
283  /// \name Visitor
284  /// \{
285  /**
286  * \brief visit children i.e. member variables of current node using provided visitor
287  *
288  * Different nodes in the AST have different members (i.e. children). This method
289  * recursively visits children using provided visitor.
290  *
291  * \param v Concrete visitor that will be used to recursively visit children
292  *
293  * \sa Ast::visit_children for example.
294  */
295  void visit_children(visitor::Visitor& v) override;
296 
297  /**
298  * \brief visit children i.e. member variables of current node using provided visitor
299  *
300  * Different nodes in the AST have different members (i.e. children). This method
301  * recursively visits children using provided visitor.
302  *
303  * \param v Concrete constant visitor that will be used to recursively visit children
304  *
305  * \sa Ast::visit_children for example.
306  */
307  void visit_children(visitor::ConstVisitor& v) const override;
308 
309  /**
310  * \brief accept (or visit) the current AST node using provided visitor
311  *
312  * Instead of visiting children of AST node, like Ast::visit_children,
313  * accept allows to visit the current node itself using provided concrete
314  * visitor.
315  *
316  * \param v Concrete visitor that will be used to recursively visit node
317  *
318  * \sa Ast::accept for example.
319  */
320  void accept(visitor::Visitor& v) override;
321 
322  /**
323  * \copydoc accept(visitor::Visitor&)
324  */
325  void accept(visitor::ConstVisitor& v) const override;
326  /// \}
327 
328  private:
329  /**
330  * \brief Set this object as parent for all the children
331  *
332  * This should be called in every object (with children) constructor
333  * to set parents. Since it is called only in the constructors it
334  * should not be virtual to avoid ambiguities (issue #295).
335  */
336  void set_parent_in_children();
337 };
338 
339 /** \} */ // end of ast_class
340 
341 
342 
343 
344 
345 
346 
347 } // namespace nmodl::ast
nmodl::ast::Useion::ontology_id
std::shared_ptr< String > ontology_id
Ontology to indicate the chemical ion.
Definition: useion.hpp:51
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::Useion::Useion
Useion(Name *name, const ReadIonVarVector &readlist, const WriteIonVarVector &writelist, Valence *valence, String *ontology_id)
Definition: ast.cpp:11440
nmodl::ast::Useion::valence
std::shared_ptr< Valence > valence
(TODO)
Definition: useion.hpp:49
nmodl::ast::Useion::readlist
ReadIonVarVector readlist
Variables being read.
Definition: useion.hpp:45
nmodl::ast::Useion::get_ontology_id
std::shared_ptr< String > get_ontology_id() const noexcept
Getter for member variable Useion::ontology_id.
Definition: useion.hpp:215
read_ion_var.hpp
Auto generated AST classes declaration.
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::Useion::get_writelist
const WriteIonVarVector & get_writelist() const noexcept
Getter for member variable Useion::writelist.
Definition: useion.hpp:197
nmodl::ast::Valence
TODO.
Definition: valence.hpp:38
nmodl::ast::Useion::set_writelist
void set_writelist(WriteIonVarVector &&writelist)
Setter for member variable Useion::writelist (rvalue reference)
Definition: ast.cpp:11545
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:166
statement.hpp
Auto generated AST classes declaration.
nmodl::ast::Useion::get_valence
std::shared_ptr< Valence > get_valence() const noexcept
Getter for member variable Useion::valence.
Definition: useion.hpp:206
nmodl::ast::ReadIonVarVector
std::vector< std::shared_ptr< ReadIonVar > > ReadIonVarVector
Definition: ast_decl.hpp:318
nmodl::ast::Useion::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: useion.hpp:101
nmodl::ast::Useion::set_readlist
void set_readlist(ReadIonVarVector &&readlist)
Setter for member variable Useion::readlist (rvalue reference)
Definition: ast.cpp:11528
nmodl::ast::Useion::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: useion.hpp:225
nmodl::ast::Useion::token
std::shared_ptr< ModToken > token
token with location information
Definition: useion.hpp:53
nmodl::ast::Useion::get_readlist
const ReadIonVarVector & get_readlist() const noexcept
Getter for member variable Useion::readlist.
Definition: useion.hpp:188
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::Useion
Represents USEION statement in NMODL.
Definition: useion.hpp:40
nmodl::ast::Useion::name
std::shared_ptr< Name > name
Name of ion.
Definition: useion.hpp:43
nmodl::ast::Useion::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: useion.hpp:145
nmodl::ast::Useion::writelist
WriteIonVarVector writelist
Variables being written.
Definition: useion.hpp:47
nmodl::ast::Useion::set_ontology_id
void set_ontology_id(std::shared_ptr< String > &&ontology_id)
Setter for member variable Useion::ontology_id (rvalue reference)
Definition: ast.cpp:11579
nmodl::ast::Useion::get_node_name
std::string get_node_name() const override
Return name of the node.
Definition: ast.cpp:11363
nmodl::ast::Useion::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: useion.hpp:158
nmodl::ast::Useion::get_name
std::shared_ptr< Name > get_name() const noexcept
Getter for member variable Useion::name.
Definition: useion.hpp:179
nmodl::ast::Statement
TODO.
Definition: statement.hpp:38
nmodl::ast::Useion::set_valence
void set_valence(std::shared_ptr< Valence > &&valence)
Setter for member variable Useion::valence (rvalue reference)
Definition: ast.cpp:11562
nmodl::ast::AstNodeType::USEION
@ USEION
type of ast::Useion
write_ion_var.hpp
Auto generated AST classes declaration.
nmodl::ast::Useion::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:11482
nmodl::ast::Useion::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:11379
nmodl::ast::Useion::clone
Useion * clone() const override
Return a copy of the current node.
Definition: useion.hpp:83
nmodl::ast::Useion::~Useion
virtual ~Useion()=default
nmodl::ast::Useion::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:11431
nmodl::ast::Name
Represents a name.
Definition: name.hpp:44
nmodl::ast::Useion::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: useion.hpp:116
nmodl::ast::WriteIonVarVector
std::vector< std::shared_ptr< WriteIonVar > > WriteIonVarVector
Definition: ast_decl.hpp:319
nmodl::ast::Useion::set_name
void set_name(std::shared_ptr< Name > &&name)
Setter for member variable Useion::name (rvalue reference)
Definition: ast.cpp:11511
nmodl::ast::Useion::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: useion.hpp:131
nmodl::ast::Useion::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: useion.hpp:138
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::String
Represents a string.
Definition: string.hpp:52
nmodl::ast::Useion::is_useion
bool is_useion() const noexcept override
Check if the ast node is an instance of ast::Useion.
Definition: useion.hpp:68