NEST main@a355080
 
Loading...
Searching...
No Matches
genericmodel.h
Go to the documentation of this file.
1/*
2 * genericmodel.h
3 *
4 * This file is part of NEST.
5 *
6 * Copyright (C) 2004 The NEST Initiative
7 *
8 * NEST is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * NEST 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 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef GENERICMODEL_H
24#define GENERICMODEL_H
25
26// C++ includes:
27#include <new>
28
29// Includes from nestkernel:
30#include "model.h"
31
32namespace nest
33{
44template < typename ElementT >
45class GenericModel : public Model
46{
47public:
48 GenericModel( const std::string&, const std::string& deprecation_info );
49
53 GenericModel( const GenericModel&, const std::string& );
54
58 Model* clone( const std::string& ) const override;
59
60 bool has_proxies() override;
61 bool local_receiver() override;
62 bool one_node_per_process() override;
63 bool is_off_grid() override;
64 void calibrate_time( const TimeConverter& tc ) override;
65
73 size_t send_test_event( Node&, size_t, synindex, bool ) override;
74
75 void sends_secondary_event( GapJunctionEvent& ge ) override;
76
77 SignalType sends_signal() const override;
78
80
82
84
86
87 void sends_secondary_event( SICEvent& sic ) override;
88
89 Node const& get_prototype() const override;
90
91 void set_model_id( int ) override;
92
93 int get_model_id() override;
94
95 void deprecation_warning( const std::string& ) override;
96
97private:
98 void set_status_( const Dictionary& ) override;
99 Dictionary get_status_() override;
100
101 size_t get_element_size() const override;
102
106 Node* create_() override;
107
111 ElementT proto_;
112
116 std::string deprecation_info_;
117
120};
121
122template < typename ElementT >
123GenericModel< ElementT >::GenericModel( const std::string& name, const std::string& deprecation_info )
124 : Model( name )
125 , proto_()
126 , deprecation_info_( deprecation_info )
127 , deprecation_warning_issued_( false )
128{
129 set_threads();
130}
131
132template < typename ElementT >
133GenericModel< ElementT >::GenericModel( const GenericModel& oldmod, const std::string& newname )
134 : Model( newname )
135 , proto_( oldmod.proto_ )
136 , deprecation_info_( oldmod.deprecation_info_ )
137 , deprecation_warning_issued_( false )
138{
139 set_type_id( oldmod.get_type_id() );
140 set_threads();
141}
142
143template < typename ElementT >
144Model*
145GenericModel< ElementT >::clone( const std::string& newname ) const
146{
147 return new GenericModel( *this, newname );
148}
149
150template < typename ElementT >
151Node*
153{
154 Node* n = new ElementT( proto_ );
155 return n;
156}
157
158template < typename ElementT >
159inline bool
161{
162 return proto_.has_proxies();
163}
164
165template < typename ElementT >
166inline bool
168{
169 return proto_.local_receiver();
170}
171
172template < typename ElementT >
173inline bool
175{
176 return proto_.one_node_per_process();
177}
178
179template < typename ElementT >
180inline bool
182{
183 return proto_.is_off_grid();
184}
185
186template < typename ElementT >
187inline void
189{
190 proto_.calibrate_time( tc );
191}
192
193template < typename ElementT >
194inline size_t
195GenericModel< ElementT >::send_test_event( Node& target, size_t receptor, synindex syn_id, bool dummy_target )
196{
197 return proto_.send_test_event( target, receptor, syn_id, dummy_target );
198}
199
200template < typename ElementT >
201inline void
203{
204 return proto_.sends_secondary_event( ge );
205}
206
207template < typename ElementT >
208inline void
210{
211 return proto_.sends_secondary_event( re );
212}
213
214template < typename ElementT >
215inline void
217{
218 return proto_.sends_secondary_event( de );
219}
220
221template < typename ElementT >
222inline void
224{
225 return proto_.sends_secondary_event( re );
226}
227
228template < typename ElementT >
229inline void
231{
232 return proto_.sends_secondary_event( re );
233}
234
235template < typename ElementT >
236inline void
238{
239 return proto_.sends_secondary_event( sic );
240}
241
242template < typename ElementT >
243inline SignalType
245{
246 return proto_.sends_signal();
247}
248
249template < typename ElementT >
250void
252{
253 proto_.set_status( d );
254}
255
256template < typename ElementT >
259{
260 Dictionary d = proto_.get_status_base();
261 d[ names::elementsize ] = static_cast< long >( sizeof( ElementT ) );
262 return d;
263}
264
265template < typename ElementT >
266size_t
268{
269 return sizeof( ElementT );
270}
271
272template < typename ElementT >
273Node const&
275{
276 return proto_;
277}
278
279template < typename ElementT >
280void
282{
283 proto_.set_model_id( i );
284}
285
286template < typename ElementT >
287int
289{
290 return proto_.get_model_id();
291}
292}
293
294#endif
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Event for rate model connections with delay.
Definition secondary_event.h:331
Event for diffusion connections (rate model connections for the siegert_neuron).
Definition secondary_event.h:348
Event for gap-junction information.
Definition secondary_event.h:299
Generic Model template.
Definition genericmodel.h:46
void calibrate_time(const TimeConverter &tc) override
Definition genericmodel.h:188
size_t get_element_size() const override
Return the size of the prototype.
Definition genericmodel.h:267
bool local_receiver() override
Definition genericmodel.h:167
Dictionary get_status_() override
Definition genericmodel.h:258
void set_status_(const Dictionary &) override
Definition genericmodel.h:251
std::string deprecation_info_
String containing deprecation information; empty if model not deprecated.
Definition genericmodel.h:116
void sends_secondary_event(GapJunctionEvent &ge) override
Definition genericmodel.h:202
Node * create_() override
Call placement new on the supplied memory position.
Definition genericmodel.h:152
bool one_node_per_process() override
Definition genericmodel.h:174
ElementT proto_
Prototype node from which all instances are constructed.
Definition genericmodel.h:111
void deprecation_warning(const std::string &) override
Issue deprecation warning on first call if model is deprecated.
Definition genericmodel_impl.h:37
bool deprecation_warning_issued_
False until deprecation warning has been issued once.
Definition genericmodel.h:119
int get_model_id() override
Get the model id from the prototype.
Definition genericmodel.h:288
Model * clone(const std::string &) const override
Return pointer to cloned model with same name.
Definition genericmodel.h:145
bool is_off_grid() override
Definition genericmodel.h:181
size_t send_test_event(Node &, size_t, synindex, bool) override
Send a test event to a target node.
Definition genericmodel.h:195
SignalType sends_signal() const override
Check what type of signal this model is sending.
Definition genericmodel.h:244
Node const & get_prototype() const override
Return const reference to the prototype.
Definition genericmodel.h:274
GenericModel(const std::string &, const std::string &deprecation_info)
Definition genericmodel.h:123
bool has_proxies() override
Definition genericmodel.h:160
void set_model_id(int) override
Set the model id on the prototype.
Definition genericmodel.h:281
Event for rate model connections without delay.
Definition secondary_event.h:315
Event for learning signal connections.
Definition secondary_event.h:384
Base class for all Models.
Definition model.h:53
void set_threads()
Set number of threads based on number set in network.
Definition model.cpp:47
size_t get_type_id() const
Definition model.h:207
void set_type_id(size_t id)
Set the model id on the prototype.
Definition model.h:201
Base class for all NEST network objects.
Definition node.h:99
void set_model_id(int)
Set the model id.
Definition node.h:1220
Event for slow inward current (SIC) connections between astrocytes and neurons.
Definition secondary_event.h:458
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
const std::string elementsize("elementsize")
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
SignalType
enum type of signal conveyed by spike events of a node.
Definition nest_types.h:165
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115