User Guide
random_var_list.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/random_var.hpp"
24 #include "ast/statement.hpp"
25 
26 namespace nmodl::ast {
27 
28 /**
29  * \addtogroup ast_class
30  * \ingroup ast
31  * \{
32  */
33 
34 /**
35  * \brief Represents RANDOM statement in NMODL
36  *
37  * Here is an example of RANDOM statement
38  *
39  * \code{.mod}
40  * NEURON {
41  * THREADSAFE
42  * POINT_PROCESS NetStim
43  * RANDOM ranvar
44  * \endcode
45  *
46 */
47 class RandomVarList : public Statement {
48  private:
49  /// Vector of random variables
51  /// token with location information
52  std::shared_ptr<ModToken> token;
53 
54  public:
55  /// \name Ctor & dtor
56  /// \{
57  explicit RandomVarList(const RandomVarVector& variables);
58  RandomVarList(const RandomVarList& obj);
59  virtual ~RandomVarList() = default;
60  /// \}
61 
62  /**
63  * \brief Check if the ast node is an instance of ast::RandomVarList
64  * \return true as object is of type ast::RandomVarList
65  */
66  bool is_random_var_list () const noexcept override {
67  return true;
68  }
69 
70  /**
71  * \brief Return a copy of the current node
72  *
73  * Recursively make a new copy/clone of the current node including
74  * all members and return a pointer to the node. This is used for
75  * passes like nmodl::visitor::InlineVisitor where nodes are cloned in the
76  * ast.
77  *
78  * \return pointer to the clone/copy of the current node
79  */
80  // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks)
81  RandomVarList* clone() const override {
82  return new RandomVarList(*this);
83  }
84  // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
85 
86  /// \name Getters
87  /// \{
88 
89  /**
90  * \brief Return type (ast::AstNodeType) of ast node
91  *
92  * Every node in the ast has a type defined in ast::AstNodeType and this
93  * function is used to retrieve the same.
94  *
95  * \return ast node type i.e. ast::AstNodeType::RANDOM_VAR_LIST
96  *
97  * \sa Ast::get_node_type_name
98  */
99  AstNodeType get_node_type() const noexcept override {
101  }
102 
103  /**
104  * \brief Return type (ast::AstNodeType) of ast node as std::string
105  *
106  * Every node in the ast has a type defined in ast::AstNodeType.
107  * This type name can be returned as a std::string for printing
108  * node to text/json form.
109  *
110  * \return name of the node type as a string i.e. "RandomVarList"
111  *
112  * \sa Ast::get_node_name
113  */
114  std::string get_node_type_name() const noexcept override {
115  return "RandomVarList";
116  }
117 
118  /**
119  * \brief Return NMODL statement of ast node as std::string
120  *
121  * Every node is related to a special statement in the NMODL. This
122  * statement can be returned as a std::string for printing to
123  * text/json form.
124  *
125  * \return name of the statement as a string i.e. "RANDOM "
126  *
127  * \sa Ast::get_nmodl_name
128  */
129  std::string get_nmodl_name() const noexcept override {
130  return "RANDOM ";
131  }
132 
133  /**
134  * \brief Get std::shared_ptr from `this` pointer of the current ast node
135  */
136  std::shared_ptr<Ast> get_shared_ptr() override {
137  return std::static_pointer_cast<RandomVarList>(shared_from_this());
138  }
139 
140  /**
141  * \brief Get std::shared_ptr from `this` pointer of the current ast node
142  */
143  std::shared_ptr<const Ast> get_shared_ptr() const override {
144  return std::static_pointer_cast<const RandomVarList>(shared_from_this());
145  }
146 
147  /**
148  * \brief Return associated token for the current ast node
149  *
150  * Not all ast nodes have token information. For example, nmodl::visitor::NeuronSolveVisitor
151  * can insert new nodes in the ast as a solution of ODEs. In this case, we return
152  * nullptr to store in the nmodl::symtab::SymbolTable.
153  *
154  * \return pointer to token if exist otherwise nullptr
155  */
156  const ModToken* get_token() const noexcept override {
157  return token.get();
158  }
159 
160 
161 
162  /**
163  * \brief Getter for member variable \ref RandomVarList.variables
164  */
165  const RandomVarVector& get_variables() const noexcept {
166  return variables;
167  }
168  /// \}
169 
170  /// \name Setters
171  /// \{
172  /**
173  * \brief Set token for the current ast node
174  */
175  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
176 
177  /**
178  * \brief Setter for member variable \ref RandomVarList.variables (rvalue reference)
179  */
181 
182  /**
183  * \brief Setter for member variable \ref RandomVarList.variables
184  */
186 
187  /// \}
188 
189  /// \name Visitor
190  /// \{
191  /**
192  * \brief visit children i.e. member variables of current node using provided visitor
193  *
194  * Different nodes in the AST have different members (i.e. children). This method
195  * recursively visits children using provided visitor.
196  *
197  * \param v Concrete visitor that will be used to recursively visit children
198  *
199  * \sa Ast::visit_children for example.
200  */
201  void visit_children(visitor::Visitor& v) override;
202 
203  /**
204  * \brief visit children i.e. member variables of current node using provided visitor
205  *
206  * Different nodes in the AST have different members (i.e. children). This method
207  * recursively visits children using provided visitor.
208  *
209  * \param v Concrete constant visitor that will be used to recursively visit children
210  *
211  * \sa Ast::visit_children for example.
212  */
213  void visit_children(visitor::ConstVisitor& v) const override;
214 
215  /**
216  * \brief accept (or visit) the current AST node using provided visitor
217  *
218  * Instead of visiting children of AST node, like Ast::visit_children,
219  * accept allows to visit the current node itself using provided concrete
220  * visitor.
221  *
222  * \param v Concrete visitor that will be used to recursively visit node
223  *
224  * \sa Ast::accept for example.
225  */
226  void accept(visitor::Visitor& v) override;
227 
228  /**
229  * \copydoc accept(visitor::Visitor&)
230  */
231  void accept(visitor::ConstVisitor& v) const override;
232  /// \}
233 
234  private:
235  /**
236  * \brief Set this object as parent for all the children
237  *
238  * This should be called in every object (with children) constructor
239  * to set parents. Since it is called only in the constructors it
240  * should not be virtual to avoid ambiguities (issue #295).
241  */
242  void set_parent_in_children();
243 };
244 
245 /** \} */ // end of ast_class
246 
247 
248 
249 } // namespace nmodl::ast
nmodl::ast::AstNodeType::RANDOM_VAR_LIST
@ RANDOM_VAR_LIST
type of ast::RandomVarList
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:298
nmodl::ast::RandomVarList::token
std::shared_ptr< ModToken > token
token with location information
Definition: random_var_list.hpp:52
nmodl::ast::RandomVarList::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: random_var_list.hpp:99
nmodl::ast::RandomVarList
Represents RANDOM statement in NMODL.
Definition: random_var_list.hpp:47
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::RandomVarList::variables
RandomVarVector variables
Vector of random variables.
Definition: random_var_list.hpp:50
nmodl::ast::RandomVarVector
std::vector< std::shared_ptr< RandomVar > > RandomVarVector
Definition: ast_decl.hpp:321
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::RandomVarList::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:12078
nmodl::ast::RandomVarList::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:12030
nmodl::ast::RandomVarList::~RandomVarList
virtual ~RandomVarList()=default
nmodl::ast::RandomVarList::RandomVarList
RandomVarList(const RandomVarVector &variables)
Definition: ast.cpp:12055
nmodl::ast::AstNodeType
AstNodeType
Enum type for every AST node type.
Definition: ast_decl.hpp:164
nmodl::ast::RandomVarList::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: random_var_list.hpp:175
statement.hpp
Auto generated AST classes declaration.
nmodl::ast::RandomVarList::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:12046
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::RandomVarList::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: random_var_list.hpp:114
nmodl::ast::RandomVarList::set_variables
void set_variables(RandomVarVector &&variables)
Setter for member variable RandomVarList::variables (rvalue reference)
Definition: ast.cpp:12090
nmodl::ast::Statement
TODO.
Definition: statement.hpp:38
nmodl::ast::RandomVarList::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: random_var_list.hpp:136
nmodl::ast::RandomVarList::get_variables
const RandomVarVector & get_variables() const noexcept
Getter for member variable RandomVarList::variables.
Definition: random_var_list.hpp:165
nmodl::ast::RandomVarList::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: random_var_list.hpp:156
nmodl::ast::RandomVarList::clone
RandomVarList * clone() const override
Return a copy of the current node.
Definition: random_var_list.hpp:81
nmodl::ast::RandomVarList::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: random_var_list.hpp:129
nmodl::ast::RandomVarList::is_random_var_list
bool is_random_var_list() const noexcept override
Check if the ast node is an instance of ast::RandomVarList.
Definition: random_var_list.hpp:66
nmodl::ast::RandomVarList::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: random_var_list.hpp:143
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
random_var.hpp
Auto generated AST classes declaration.