NEST main@caf0ae8
 
Loading...
Searching...
No Matches
model_manager.h
Go to the documentation of this file.
1/*
2 * model_manager.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 MODEL_MANAGER_H
24#define MODEL_MANAGER_H
25
26// C++ includes:
27#include <string>
28
29// Includes from nestkernel:
30#include "connector_model.h"
31#include "genericmodel.h"
32#include "manager_interface.h"
33#include "model.h"
34#include "nest.h"
35#include "nest_time.h"
36#include "nest_timeconverter.h"
37#include "nest_types.h"
38#include "node.h"
39
40
41namespace nest
42{
43
45{
46public:
48 ~ModelManager() override;
49
50 void initialize( const bool ) override;
51 void finalize( const bool ) override;
52 void set_status( const Dictionary& ) override;
53 void get_status( Dictionary& ) override;
54
64 void calibrate( const TimeConverter& );
65
68 Node* get_proxy_node( size_t tid, size_t node_id );
69
79 ConnectorModel& get_connection_model( synindex syn_id, size_t thread_id );
80
81 const std::vector< ConnectorModel* >& get_connection_models( size_t tid );
82
95 template < class ModelT >
96 size_t register_node_model( const std::string& name, std::string deprecation_info = std::string() );
97
112 template < template < typename targetidentifierT > class ConnectionT >
113 void register_connection_model( const std::string& name );
114
124 void copy_model( const std::string& old_name, const std::string& new_name, const Dictionary& params );
125
134 bool set_model_defaults( const std::string& name, const Dictionary& params );
135
140 size_t get_node_model_id( const std::string ) const;
141
145 Model* get_node_model( size_t ) const;
146
151 size_t get_synapse_model_id( std::string model_name );
152
154
156
161 void assert_valid_syn_id( synindex syn_id, size_t t ) const;
162
163 bool are_model_defaults_modified() const;
164
165 size_t get_num_connection_models() const;
166
170 void memory_info() const;
171
172 std::unique_ptr< SecondaryEvent > get_secondary_event_prototype( const synindex syn_id, const size_t tid );
173
174private:
182 void clear_node_models_();
183
185
186 size_t register_node_model_( Model* model );
187
188 template < typename CompleteConnecionT >
189 void register_specific_connection_model_( const std::string& name );
190
198 void copy_node_model_( const size_t old_id, const std::string& new_name, const Dictionary& params );
199
207 void copy_connection_model_( const size_t old_id, const std::string& new_name, const Dictionary& params );
208
216 void set_node_defaults_( size_t model_id, const Dictionary& params );
217
225 void set_synapse_defaults_( size_t model_id, const Dictionary& params );
226
228 static bool compare_model_by_id_( const int a, const int b );
229
244 std::vector< Model* > node_models_;
245
265 std::vector< std::vector< ConnectorModel* > > connection_models_;
266
269
271
272 Node* create_proxynode_( size_t t, int model_id );
273
275 std::vector< std::vector< Node* > > proxy_nodes_;
278};
279
280
281inline Model*
283{
284 assert( m < node_models_.size() );
285 return node_models_[ m ];
286}
287
288inline bool
293
294inline ConnectorModel&
296{
297 assert_valid_syn_id( syn_id, thread_id );
298 return *( connection_models_[ thread_id ][ syn_id ] );
299}
300
301inline const std::vector< ConnectorModel* >&
303{
304 return connection_models_[ tid ];
305}
306
307inline void
309{
310 if ( syn_id >= connection_models_[ t ].size() or not connection_models_[ t ][ syn_id ] )
311 {
312 throw UnknownSynapseType( syn_id );
313 }
314}
315
316inline std::unique_ptr< SecondaryEvent >
318{
319 assert_valid_syn_id( syn_id, tid );
320 return get_connection_model( syn_id, tid ).get_secondary_event();
321}
322
323} // namespace nest
324
325#endif /* MODEL_MANAGER_H */
Dictionary class for interface to Python and C++ API.
Definition dictionary.h:213
Definition connector_model.h:69
virtual std::unique_ptr< SecondaryEvent > get_secondary_event()=0
Interface for kernel manager classes.
Definition manager_interface.h:46
Definition model_manager.h:45
void clear_connection_models_()
Definition model_manager.cpp:383
std::vector< std::vector< ConnectorModel * > > connection_models_
The list of connection models.
Definition model_manager.h:265
void set_node_defaults_(size_t model_id, const Dictionary &params)
Set the default parameters of a model.
Definition model_manager.cpp:260
void finalize(const bool) override
Take down manager after operation.
Definition model_manager.cpp:90
void clear_node_models_()
Delete all models and clear the modeldict.
Definition model_manager.cpp:352
void memory_info() const
Print out the memory information for each node model.
Definition model_manager.cpp:434
void initialize(const bool) override
Prepare manager for operation.
Definition model_manager.cpp:68
~ModelManager() override
Definition model_manager.cpp:61
Dictionary get_connector_defaults(synindex syn_id) const
Definition model_manager.cpp:333
void assert_valid_syn_id(synindex syn_id, size_t t) const
Asserts validity of synapse index, otherwise throws exception.
Definition model_manager.h:308
Model * proxynode_model_
Definition model_manager.h:270
ConnectorModel & get_connection_model(synindex syn_id, size_t thread_id)
Return pointer to protoype for given synapse id.
Definition model_manager.h:295
bool are_model_defaults_modified() const
Definition model_manager.h:289
const std::vector< ConnectorModel * > & get_connection_models(size_t tid)
Definition model_manager.h:302
size_t get_num_connection_models() const
Definition model_manager.cpp:99
void register_connection_model(const std::string &name)
Register a synape model with a custom Connector model and without any common properties.
Definition model_manager_impl.h:59
bool set_model_defaults(const std::string &name, const Dictionary &params)
Set the default parameters of a model.
Definition model_manager.cpp:237
void set_status(const Dictionary &) override
Set the status of the manager.
Definition model_manager.cpp:111
void set_synapse_defaults_(size_t model_id, const Dictionary &params)
Set the default parameters of a model.
Definition model_manager.cpp:271
std::vector< Model * > node_models_
List of node models.
Definition model_manager.h:244
std::vector< std::vector< Node * > > proxy_nodes_
Placeholders for remote nodes, one per thread.
Definition model_manager.h:275
static bool compare_model_by_id_(const int a, const int b)
Compares model ids for sorting in memory_info.
Definition model_manager.cpp:427
Model * get_node_model(size_t) const
Definition model_manager.h:282
bool model_defaults_modified_
True if any model defaults have been modified.
Definition model_manager.h:277
void register_specific_connection_model_(const std::string &name)
Definition model_manager_impl.h:80
Node * create_proxynode_(size_t t, int model_id)
Definition model_manager.cpp:470
void copy_node_model_(const size_t old_id, const std::string &new_name, const Dictionary &params)
Copy an existing node model and register it as a new model.
Definition model_manager.cpp:186
void copy_model(const std::string &old_name, const std::string &new_name, const Dictionary &params)
Copy an existing model and register it as a new model.
Definition model_manager.cpp:138
size_t get_node_model_id(const std::string) const
Definition model_manager.cpp:310
Dictionary synapsedict_
Dictionary of all synapse models.
Definition model_manager.h:268
size_t register_node_model_(Model *model)
Definition model_manager.cpp:162
ModelManager()
Definition model_manager.cpp:50
Dictionary modeldict_
Dictionary of all node models.
Definition model_manager.h:267
void set_connector_defaults(synindex syn_id, const Dictionary &d)
size_t register_node_model(const std::string &name, std::string deprecation_info=std::string())
Register a node-model prototype.
Definition model_manager_impl.h:44
size_t get_synapse_model_id(std::string model_name)
Definition model_manager.cpp:321
void get_status(Dictionary &) override
Retrieve the status of the manager.
Definition model_manager.cpp:116
void calibrate(const TimeConverter &)
Resize the structures for the Connector objects if necessary.
Definition model_manager.cpp:407
std::unique_ptr< SecondaryEvent > get_secondary_event_prototype(const synindex syn_id, const size_t tid)
Definition model_manager.h:317
Node * get_proxy_node(size_t tid, size_t node_id)
Definition model_manager_impl.h:116
void copy_connection_model_(const size_t old_id, const std::string &new_name, const Dictionary &params)
Copy an existing synapse model and register it as a new model.
Definition model_manager.cpp:208
Base class for all Models.
Definition model.h:53
Base class for all NEST network objects.
Definition node.h:99
Class to convert times from one representation to another.
Definition nest_timeconverter.h:42
Exception to be thrown if the specified Synapse type does not exist.
Definition exceptions.h:275
Namespace for the NEST simulation kernel.
Definition beta_normalization_factor.h:33
size_t synindex
For enumerations of synapse types.
Definition nest_types.h:115
Declarations for base class Node.