User Guide
conductance_hint.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/statement.hpp"
24 
25 namespace nmodl::ast {
26 
27 /**
28  * \addtogroup ast_class
29  * \ingroup ast
30  * \{
31  */
32 
33 /**
34  * \brief Represents `CONDUCTANCE` statement in NMODL
35  *
36  * If `I/V` relation in the `BREAKPOINT` block is ohomic then one can
37  * specify `CONDUCTANCE` hint for optimised code generation:
38  *
39  * \code{.mod}
40  * CONDUCTANCE g USEION I
41  * \endcode
42  *
43  * \sa nmodl::visitor::SympyConductanceVisitor
44  *
45 */
46 class ConductanceHint : public Statement {
47  private:
48  /// Conductance variable
49  std::shared_ptr<Name> conductance;
50  /// Ion name
51  std::shared_ptr<Name> ion;
52  /// token with location information
53  std::shared_ptr<ModToken> token;
54 
55  public:
56  /// \name Ctor & dtor
57  /// \{
59  explicit ConductanceHint(std::shared_ptr<Name> conductance, std::shared_ptr<Name> ion);
60  ConductanceHint(const ConductanceHint& obj);
61  virtual ~ConductanceHint() = default;
62  /// \}
63 
64  /**
65  * \brief Check if the ast node is an instance of ast::ConductanceHint
66  * \return true as object is of type ast::ConductanceHint
67  */
68  bool is_conductance_hint () 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  ConductanceHint* clone() const override {
84  return new ConductanceHint(*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::CONDUCTANCE_HINT
98  *
99  * \sa Ast::get_node_type_name
100  */
101  AstNodeType get_node_type() const noexcept override {
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. "ConductanceHint"
113  *
114  * \sa Ast::get_node_name
115  */
116  std::string get_node_type_name() const noexcept override {
117  return "ConductanceHint";
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. "CONDUCTANCE "
128  *
129  * \sa Ast::get_nmodl_name
130  */
131  std::string get_nmodl_name() const noexcept override {
132  return "CONDUCTANCE ";
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<ConductanceHint>(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 ConductanceHint>(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  /**
165  * \brief Getter for member variable \ref ConductanceHint.conductance
166  */
167  std::shared_ptr<Name> get_conductance() const noexcept {
168  return conductance;
169  }
170 
171 
172 
173  /**
174  * \brief Getter for member variable \ref ConductanceHint.ion
175  */
176  std::shared_ptr<Name> get_ion() const noexcept {
177  return ion;
178  }
179  /// \}
180 
181  /// \name Setters
182  /// \{
183  /**
184  * \brief Set token for the current ast node
185  */
186  void set_token(const ModToken& tok) { token = std::make_shared<ModToken>(tok); }
187 
188  /**
189  * \brief Setter for member variable \ref ConductanceHint.conductance (rvalue reference)
190  */
191  void set_conductance(std::shared_ptr<Name>&& conductance);
192 
193  /**
194  * \brief Setter for member variable \ref ConductanceHint.conductance
195  */
196  void set_conductance(const std::shared_ptr<Name>& conductance);
197 
198 
199  /**
200  * \brief Setter for member variable \ref ConductanceHint.ion (rvalue reference)
201  */
202  void set_ion(std::shared_ptr<Name>&& ion);
203 
204  /**
205  * \brief Setter for member variable \ref ConductanceHint.ion
206  */
207  void set_ion(const std::shared_ptr<Name>& ion);
208 
209  /// \}
210 
211  /// \name Visitor
212  /// \{
213  /**
214  * \brief visit children i.e. member variables of current node using provided visitor
215  *
216  * Different nodes in the AST have different members (i.e. children). This method
217  * recursively visits children using provided visitor.
218  *
219  * \param v Concrete visitor that will be used to recursively visit children
220  *
221  * \sa Ast::visit_children for example.
222  */
223  void visit_children(visitor::Visitor& v) override;
224 
225  /**
226  * \brief visit children i.e. member variables of current node using provided visitor
227  *
228  * Different nodes in the AST have different members (i.e. children). This method
229  * recursively visits children using provided visitor.
230  *
231  * \param v Concrete constant visitor that will be used to recursively visit children
232  *
233  * \sa Ast::visit_children for example.
234  */
235  void visit_children(visitor::ConstVisitor& v) const override;
236 
237  /**
238  * \brief accept (or visit) the current AST node using provided visitor
239  *
240  * Instead of visiting children of AST node, like Ast::visit_children,
241  * accept allows to visit the current node itself using provided concrete
242  * visitor.
243  *
244  * \param v Concrete visitor that will be used to recursively visit node
245  *
246  * \sa Ast::accept for example.
247  */
248  void accept(visitor::Visitor& v) override;
249 
250  /**
251  * \copydoc accept(visitor::Visitor&)
252  */
253  void accept(visitor::ConstVisitor& v) const override;
254  /// \}
255 
256  private:
257  /**
258  * \brief Set this object as parent for all the children
259  *
260  * This should be called in every object (with children) constructor
261  * to set parents. Since it is called only in the constructors it
262  * should not be virtual to avoid ambiguities (issue #295).
263  */
264  void set_parent_in_children();
265 };
266 
267 /** \} */ // end of ast_class
268 
269 
270 
271 
272 } // namespace nmodl::ast
nmodl::visitor::ConstVisitor
Abstract base class for all constant visitors implementation.
Definition: visitor.hpp:302
nmodl::ast::ConductanceHint::conductance
std::shared_ptr< Name > conductance
Conductance variable.
Definition: conductance_hint.hpp:49
nmodl::ast::ConductanceHint::get_ion
std::shared_ptr< Name > get_ion() const noexcept
Getter for member variable ConductanceHint::ion.
Definition: conductance_hint.hpp:176
nmodl::ast::ConductanceHint::ConductanceHint
ConductanceHint(Name *conductance, Name *ion)
Definition: ast.cpp:8946
nmodl::ast::ConductanceHint
Represents CONDUCTANCE statement in NMODL.
Definition: conductance_hint.hpp:46
ast_decl.hpp
THIS FILE IS GENERATED AT BUILD TIME AND SHALL NOT BE EDITED.
nmodl::ast::ConductanceHint::get_conductance
std::shared_ptr< Name > get_conductance() const noexcept
Getter for member variable ConductanceHint::conductance.
Definition: conductance_hint.hpp:167
nmodl::ast
Abstract Syntax Tree (AST) related implementations.
Definition: ast_common.hpp:29
nmodl::ast::ConductanceHint::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: conductance_hint.hpp:145
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::ConductanceHint::ion
std::shared_ptr< Name > ion
Ion name.
Definition: conductance_hint.hpp:51
nmodl::ast::ConductanceHint::token
std::shared_ptr< ModToken > token
token with location information
Definition: conductance_hint.hpp:53
nmodl::ast::ConductanceHint::accept
void accept(visitor::Visitor &v) override
accept (or visit) the current AST node using provided visitor
Definition: ast.cpp:8937
nmodl::ast::AstNodeType::CONDUCTANCE_HINT
@ CONDUCTANCE_HINT
type of ast::ConductanceHint
nmodl::visitor::Visitor
Abstract base class for all visitors implementation.
Definition: visitor.hpp:39
nmodl::ast::ConductanceHint::get_shared_ptr
std::shared_ptr< Ast > get_shared_ptr() override
Get std::shared_ptr from this pointer of the current ast node.
Definition: conductance_hint.hpp:138
nmodl::ast::ConductanceHint::get_token
const ModToken * get_token() const noexcept override
Return associated token for the current ast node.
Definition: conductance_hint.hpp:158
nmodl::ast::ConductanceHint::is_conductance_hint
bool is_conductance_hint() const noexcept override
Check if the ast node is an instance of ast::ConductanceHint.
Definition: conductance_hint.hpp:68
nmodl::ast::ConductanceHint::get_node_type_name
std::string get_node_type_name() const noexcept override
Return type (ast::AstNodeType) of ast node as std::string.
Definition: conductance_hint.hpp:116
nmodl::ast::ConductanceHint::clone
ConductanceHint * clone() const override
Return a copy of the current node.
Definition: conductance_hint.hpp:83
nmodl::ast::ConductanceHint::set_conductance
void set_conductance(std::shared_ptr< Name > &&conductance)
Setter for member variable ConductanceHint::conductance (rvalue reference)
Definition: ast.cpp:8991
nmodl::ast::Statement
TODO.
Definition: statement.hpp:38
nmodl::ast::ConductanceHint::set_ion
void set_ion(std::shared_ptr< Name > &&ion)
Setter for member variable ConductanceHint::ion (rvalue reference)
Definition: ast.cpp:9008
nmodl::ast::ConductanceHint::~ConductanceHint
virtual ~ConductanceHint()=default
nmodl::ast::ConductanceHint::set_token
void set_token(const ModToken &tok)
Set token for the current ast node.
Definition: conductance_hint.hpp:186
nmodl::ast::ConductanceHint::get_node_type
AstNodeType get_node_type() const noexcept override
Return type (ast::AstNodeType) of ast node.
Definition: conductance_hint.hpp:101
nmodl::ast::ConductanceHint::visit_children
void visit_children(visitor::Visitor &v) override
visit children i.e.
Definition: ast.cpp:8915
nmodl::ast::Name
Represents a name.
Definition: name.hpp:44
nmodl::ast::ConductanceHint::set_parent_in_children
void set_parent_in_children()
Set this object as parent for all the children.
Definition: ast.cpp:8976
nmodl::ModToken
Represent token returned by scanner.
Definition: modtoken.hpp:50
nmodl::ast::ConductanceHint::get_nmodl_name
std::string get_nmodl_name() const noexcept override
Return NMODL statement of ast node as std::string.
Definition: conductance_hint.hpp:131