NEST
2.6.0,not_revisioned_source_dir@0
|
Base class for all Models. More...
#include <model.h>
Public Member Functions | |
Model (const std::string &name) | |
Model (const Model &m) | |
virtual | ~Model () |
virtual Model * | clone (const std::string &) const =0 |
Create clone with new name. More... | |
void | set_threads () |
Set number of threads based on number set in network. More... | |
Node * | allocate (thread t) |
Allocate new Node and return its pointer. More... | |
void | free (thread t, Node *) |
void | clear () |
Deletes all nodes which belong to this model. More... | |
void | reserve_additional (thread t, size_t n) |
Reserve memory for at least n additional Nodes. More... | |
std::string | get_name () const |
Return name of the Model. More... | |
size_t | mem_available () |
Return the available memory. More... | |
size_t | mem_capacity () |
Return the memory capacity. More... | |
virtual bool | has_proxies ()=0 |
virtual bool | potential_global_receiver ()=0 |
virtual bool | one_node_per_process ()=0 |
virtual bool | is_off_grid ()=0 |
void | set_status (DictionaryDatum) |
Change properties of the prototype node according to the entries in the dictionary. More... | |
DictionaryDatum | get_status (void) |
Export properties of the prototype node by setting entries in the status dictionary. More... | |
virtual port | send_test_event (Node &, rport, synindex, bool)=0 |
virtual size_t | get_element_size () const =0 |
Return the size of the prototype. More... | |
virtual Node const & | get_prototype (void) const =0 |
Return const reference to the prototype. More... | |
virtual void | set_model_id (int)=0 |
Set the model id on the prototype. More... | |
void | set_type_id (index id) |
Set the model id on the prototype. More... | |
index | get_type_id () const |
Private Member Functions | |
virtual void | set_status_ (DictionaryDatum)=0 |
virtual DictionaryDatum | get_status_ ()=0 |
void | set_threads_ (thread t) |
Set the number of threads. More... | |
virtual void | init_memory_ (sli::pool &)=0 |
Initialize the pool allocator with the Node specific values. More... | |
virtual Node * | allocate_ (void *)=0 |
Allocate a new object at the specified memory position. More... | |
Private Attributes | |
std::string | name_ |
Name of the Model. More... | |
index | type_id_ |
Identifier of the model C++ type. More... | |
std::vector< sli::pool > | memory_ |
Memory for all nodes sorted by threads. More... | |
Base class for all Models.
Each Node class is associated with a corresponding Model class. The Model class is responsible for the creation and class wide parametrisation of its associated Node objects.
class Model manages the thread-sorted memory pool of the model. The default constructor uses one thread as default. Use set_threads() to use more than one thread.
nest::Model::Model | ( | const std::string & | name | ) |
|
inline |
|
inlinevirtual |
Allocate new Node and return its pointer.
allocate() is not const, because it is allowed to modify the Model object for 'administrative' purposes.
References allocate_(), assert(), and memory_.
Referenced by nest::Network::add_node(), nest::Network::copy_model(), nest::Network::init_(), and nest::Network::register_model().
|
privatepure virtual |
Allocate a new object at the specified memory position.
Implemented in nest::GenericModel< ElementT >.
Referenced by allocate().
void nest::Model::clear | ( | ) |
Deletes all nodes which belong to this model.
References memory_, and set_threads_().
|
pure virtual |
Create clone with new name.
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::copy_model(), and nest::Network::register_model().
|
pure virtual |
Return the size of the prototype.
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::memory_info().
|
inline |
Return name of the Model.
This function returns the name of the Model as C++ string. The name is defined by the constructor. The result is identical to the value of Node::get_name();
References name_.
Referenced by nest::Node::get_name(), get_status(), nest::Network::memory_info(), nest::Network::register_basis_model(), nest::Network::register_model(), set_status(), nest::Network::try_unregister_model(), and nest::Network::unregister_model().
|
pure virtual |
Return const reference to the prototype.
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Node::init_state().
|
privatepure virtual |
Implemented in nest::GenericModel< ElementT >.
Referenced by get_status().
|
inline |
References type_id_.
Referenced by nest::GenericModel< ElementT >::GenericModel().
|
pure virtual |
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::add_node().
|
privatepure virtual |
Initialize the pool allocator with the Node specific values.
Implemented in nest::GenericModel< ElementT >.
Referenced by set_threads_().
|
pure virtual |
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::add_node().
size_t nest::Model::mem_available | ( | ) |
Return the available memory.
The result is given in number of elements, not in bytes. Note that this function reports a sum over all threads.
References memory_.
Referenced by nest::Network::memory_info().
size_t nest::Model::mem_capacity | ( | ) |
Return the memory capacity.
The result is given in number of elements, not in bytes. Note that this function reports a sum over all threads.
References memory_.
Referenced by nest::Network::memory_info().
|
pure virtual |
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::add_node().
|
pure virtual |
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::add_node().
void nest::Model::reserve_additional | ( | thread | t, |
size_t | n | ||
) |
Reserve memory for at least n additional Nodes.
A number of memory managers work more efficently if they have an idea about the number of Nodes to be allocated. This function prepares the memory manager for the subsequent allocation of n additional Nodes.
t | Thread for which the Nodes are reserved. |
n | Number of Nodes to be allocated. |
References assert(), and memory_.
Referenced by nest::Network::add_node().
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::proxynode::send_test_event().
|
pure virtual |
Set the model id on the prototype.
Implemented in nest::GenericModel< ElementT >.
Referenced by nest::Network::register_model().
|
privatepure virtual |
Implemented in nest::GenericModel< ElementT >.
Referenced by set_status().
void nest::Model::set_threads | ( | ) |
Set number of threads based on number set in network.
As long as no nodes of the model have been allocated, the number of threads may be changed.
References nest::NestModule::get_num_threads(), and set_threads_().
Referenced by nest::GenericModel< ElementT >::GenericModel().
|
private |
Set the number of threads.
References init_memory_(), and memory_.
Referenced by clear(), and set_threads().
|
inline |
Set the model id on the prototype.
References type_id_.
Referenced by nest::GenericModel< ElementT >::GenericModel(), nest::Network::Network(), and nest::Network::register_model().
|
private |
Memory for all nodes sorted by threads.
Referenced by allocate(), clear(), free(), get_status(), mem_available(), mem_capacity(), reserve_additional(), and set_threads_().
|
private |
This name will be used to identify all Nodes which are created by this model object.
Referenced by get_name().
|
private |
Identifier of the model C++ type.
For pristine models, the type_id equals the model_id. For copied models, the type_id equals the type_id of the base model. This number is needed to automatically save and restore copied models.
Referenced by get_status(), get_type_id(), and set_type_id().