NEST main@caf0ae8
 
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 one_node_per_process() override;
62 bool is_off_grid() override;
63 void calibrate_time( const TimeConverter& tc ) override;
64
72 size_t send_test_event( Node&, size_t, synindex, bool ) override;
73
74 void sends_secondary_event( GapJunctionEvent& ge ) override;
75
76 SignalType sends_signal() const override;
77
79
81
83
85
86 void sends_secondary_event( SICEvent& sic ) override;
87
88 Node const& get_prototype() const override;
89
90 void set_model_id( int ) override;
91
92 int get_model_id() override;
93
94 void deprecation_warning( const std::string& ) override;
95
96private:
97 void set_status_( const Dictionary& ) override;
98 Dictionary get_status_() override;
99
100 size_t get_element_size() const override;
101
105 Node* create_() override;
106
110 ElementT proto_;
111
115 std::string deprecation_info_;
116
119};
120
121template < typename ElementT >
122GenericModel< ElementT >::GenericModel( const std::string& name, const std::string& deprecation_info )
123 : Model( name )
124 , proto_()
125 , deprecation_info_( deprecation_info )
126 , deprecation_warning_issued_( false )
127{
128 set_threads();
129}
130
131template < typename ElementT >
132GenericModel< ElementT >::GenericModel( const GenericModel& oldmod, const std::string& newname )
133 : Model( newname )
134 , proto_( oldmod.proto_ )
135 , deprecation_info_( oldmod.deprecation_info_ )
136 , deprecation_warning_issued_( false )
137{
138 set_type_id( oldmod.get_type_id() );
139 set_threads();
140}
141
142template < typename ElementT >
143Model*
144GenericModel< ElementT >::clone( const std::string& newname ) const
145{
146 return new GenericModel( *this, newname );
147}
148
149template < typename ElementT >
150Node*
152{
153 Node* n = new ElementT( proto_ );
154 return n;
155}
156
157template < typename ElementT >
158inline bool
160{
161 return proto_.has_proxies();
162}
163
164template < typename ElementT >
165inline bool
167{
168 return proto_.one_node_per_process();
169}
170
171template < typename ElementT >
172inline bool
174{
175 return proto_.is_off_grid();
176}
177
178template < typename ElementT >
179inline void
181{
182 proto_.calibrate_time( tc );
183}
184
185template < typename ElementT >
186inline size_t
187GenericModel< ElementT >::send_test_event( Node& target, size_t receptor, synindex syn_id, bool dummy_target )
188{
189 return proto_.send_test_event( target, receptor, syn_id, dummy_target );
190}
191
192template < typename ElementT >
193inline void
195{
196 return proto_.sends_secondary_event( ge );
197}
198
199template < typename ElementT >
200inline void
202{
203 return proto_.sends_secondary_event( re );
204}
205
206template < typename ElementT >
207inline void
209{
210 return proto_.sends_secondary_event( de );
211}
212
213template < typename ElementT >
214inline void
216{
217 return proto_.sends_secondary_event( re );
218}
219
220template < typename ElementT >
221inline void
223{
224 return proto_.sends_secondary_event( re );
225}
226
227template < typename ElementT >
228inline void
230{
231 return proto_.sends_secondary_event( sic );
232}
233
234template < typename ElementT >
235inline SignalType
237{
238 return proto_.sends_signal();
239}
240
241template < typename ElementT >
242void
244{
245 proto_.set_status( d );
246}
247
248template < typename ElementT >
251{
252 Dictionary d = proto_.get_status_base();
253 d[ names::elementsize ] = static_cast< long >( sizeof( ElementT ) );
254 return d;
255}
256
257template < typename ElementT >
258size_t
260{
261 return sizeof( ElementT );
262}
263
264template < typename ElementT >
265Node const&
267{
268 return proto_;
269}
270
271template < typename ElementT >
272void
274{
275 proto_.set_model_id( i );
276}
277
278template < typename ElementT >
279int
281{
282 return proto_.get_model_id();
283}
284}
285
286#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:180
size_t get_element_size() const override
Return the size of the prototype.
Definition genericmodel.h:259
Dictionary get_status_() override
Definition genericmodel.h:250
void set_status_(const Dictionary &) override
Definition genericmodel.h:243
std::string deprecation_info_
String containing deprecation information; empty if model not deprecated.
Definition genericmodel.h:115
void sends_secondary_event(GapJunctionEvent &ge) override
Definition genericmodel.h:194
Node * create_() override
Call placement new on the supplied memory position.
Definition genericmodel.h:151
bool one_node_per_process() override
Definition genericmodel.h:166
ElementT proto_
Prototype node from which all instances are constructed.
Definition genericmodel.h:110
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:118
int get_model_id() override
Get the model id from the prototype.
Definition genericmodel.h:280
Model * clone(const std::string &) const override
Return pointer to cloned model with same name.
Definition genericmodel.h:144
bool is_off_grid() override
Definition genericmodel.h:173
size_t send_test_event(Node &, size_t, synindex, bool) override
Send a test event to a target node.
Definition genericmodel.h:187
SignalType sends_signal() const override
Check what type of signal this model is sending.
Definition genericmodel.h:236
Node const & get_prototype() const override
Return const reference to the prototype.
Definition genericmodel.h:266
GenericModel(const std::string &, const std::string &deprecation_info)
Definition genericmodel.h:122
bool has_proxies() override
Definition genericmodel.h:159
void set_model_id(int) override
Set the model id on the prototype.
Definition genericmodel.h:273
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:206
void set_type_id(size_t id)
Set the model id on the prototype.
Definition model.h:200
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