NEST  2.6.0,not_revisioned_source_dir@0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
nest::Model Class Referenceabstract

Base class for all Models. More...

#include <model.h>

Inheritance diagram for nest::Model:
nest::GenericModel< ElementT >

Public Member Functions

 Model (const std::string &name)
 
 Model (const Model &m)
 
virtual ~Model ()
 
virtual Modelclone (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...
 
Nodeallocate (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 Nodeallocate_ (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::poolmemory_
 Memory for all nodes sorted by threads. More...
 

Detailed Description

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.

See also
Node

Constructor & Destructor Documentation

nest::Model::Model ( const std::string &  name)
nest::Model::Model ( const Model m)
inline
virtual nest::Model::~Model ( )
inlinevirtual

Member Function Documentation

Node * nest::Model::allocate ( thread  t)
inline

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().

virtual Node* nest::Model::allocate_ ( void *  )
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_().

virtual Model* nest::Model::clone ( const std::string &  ) const
pure virtual

Create clone with new name.

Implemented in nest::GenericModel< ElementT >.

Referenced by nest::Network::copy_model(), and nest::Network::register_model().

void nest::Model::free ( thread  t,
Node n 
)
inline

References assert(), and memory_.

virtual size_t nest::Model::get_element_size ( ) const
pure virtual

Return the size of the prototype.

Implemented in nest::GenericModel< ElementT >.

Referenced by nest::Network::memory_info().

std::string nest::Model::get_name ( ) const
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();

See also
Model::Model()
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().

virtual Node const& nest::Model::get_prototype ( void  ) const
pure virtual

Return const reference to the prototype.

Implemented in nest::GenericModel< ElementT >.

Referenced by nest::Node::init_state().

virtual DictionaryDatum nest::Model::get_status_ ( )
privatepure virtual

Implemented in nest::GenericModel< ElementT >.

Referenced by get_status().

index nest::Model::get_type_id ( ) const
inline
virtual bool nest::Model::has_proxies ( )
pure virtual
virtual void nest::Model::init_memory_ ( sli::pool )
privatepure virtual

Initialize the pool allocator with the Node specific values.

Implemented in nest::GenericModel< ElementT >.

Referenced by set_threads_().

virtual bool nest::Model::is_off_grid ( )
pure virtual
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().

virtual bool nest::Model::one_node_per_process ( )
pure virtual
virtual bool nest::Model::potential_global_receiver ( )
pure virtual
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.

Parameters
tThread for which the Nodes are reserved.
nNumber of Nodes to be allocated.

References assert(), and memory_.

Referenced by nest::Network::add_node().

virtual port nest::Model::send_test_event ( Node ,
rport  ,
synindex  ,
bool   
)
pure virtual
virtual void nest::Model::set_model_id ( int  )
pure virtual

Set the model id on the prototype.

Implemented in nest::GenericModel< ElementT >.

Referenced by nest::Network::register_model().

virtual void nest::Model::set_status_ ( DictionaryDatum  )
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.

Note
Requires that network pointer in NestModule is initialized.

References nest::NestModule::get_num_threads(), and set_threads_().

Referenced by nest::GenericModel< ElementT >::GenericModel().

void nest::Model::set_threads_ ( thread  t)
private

Set the number of threads.

See also
set_threads()

References init_memory_(), and memory_.

Referenced by clear(), and set_threads().

void nest::Model::set_type_id ( index  id)
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().

Member Data Documentation

std::vector<sli::pool> nest::Model::memory_
private

Memory for all nodes sorted by threads.

Referenced by allocate(), clear(), free(), get_status(), mem_available(), mem_capacity(), reserve_additional(), and set_threads_().

std::string nest::Model::name_
private

Name of the Model.

This name will be used to identify all Nodes which are created by this model object.

Referenced by get_name().

index nest::Model::type_id_
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().


The documentation for this class was generated from the following files: