NEST main@caf0ae8
 
Loading...
Searching...
No Matches
nest::NodeCollection Class Referenceabstract

Superclass for NodeCollections. More...

#include <node_collection.h>

Inheritance diagram for nest::NodeCollection:
[legend]

Public Types

using const_iterator = nc_const_iterator
 

Public Member Functions

 NodeCollection ()
 Initializer gets current fingerprint from the kernel.
 
virtual ~NodeCollection ()=default
 
bool valid () const
 Check to see if the fingerprint of the NodeCollection matches that of the kernel.
 
virtual std::ostream & print_me (std::ostream &) const =0
 Print out the contents of the NodeCollection in a pretty and informative way.
 
virtual size_t operator[] (size_t) const =0
 Get the node ID in the specified index in the NodeCollection.
 
virtual NodeCollectionPTR operator+ (NodeCollectionPTR) const =0
 Join two NodeCollections.
 
virtual bool operator== (NodeCollectionPTR) const =0
 
virtual bool operator!= (NodeCollectionPTR) const
 Check if two NodeCollections are equal.
 
virtual const_iterator begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const =0
 Method to get an iterator representing the beginning of the NodeCollection.
 
virtual const_iterator thread_local_begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const =0
 Return iterator stepping from first node on the thread it is called on over nodes on that thread.
 
virtual const_iterator rank_local_begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const =0
 Method to get an iterator representing the beginning of the NodeCollection.
 
virtual const_iterator end (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const =0
 Method to get an iterator representing the end of the NodeCollection.
 
std::vector< size_t > to_array (const std::string &selection) const
 Method that creates a vector filled with node IDs from the NodeCollection; for debugging.
 
virtual size_t size () const =0
 Get the size of the NodeCollection.
 
virtual size_t stride () const =0
 Get the step of the NodeCollection.
 
virtual bool contains (const size_t node_id) const =0
 Check if the NodeCollection contains a specified node ID.
 
virtual NodeCollectionPTR slice (size_t start, size_t end, size_t stride) const =0
 Slices the NodeCollection to the boundaries, with an optional step parameter.
 
virtual void set_metadata (NodeCollectionMetadataPTR)=0
 Sets the metadata of the NodeCollection.
 
virtual NodeCollectionMetadataPTR get_metadata () const =0
 Gets the metadata of the NodeCollection.
 
virtual bool is_range () const =0
 
virtual bool empty () const =0
 Checks if the NodeCollection has no elements.
 
virtual long get_nc_index (const size_t) const =0
 Returns index of node with given node ID in NodeCollection.
 
virtual bool has_proxies () const =0
 Returns whether the NodeCollection contains any nodes with proxies or not.
 
void get_metadata_status (Dictionary &) const
 Collect metadata into dictionary.
 
size_t get_first () const
 return the first stored ID (i.e, ID at index zero) inside the NodeCollection
 
size_t get_last () const
 return the last stored ID inside the NodeCollection
 

Static Public Member Functions

static NodeCollectionPTR create (const size_t node_id)
 Create a NodeCollection from a single node ID.
 
static NodeCollectionPTR create (const Node *node)
 Create a NodeCollection from a single node pointer.
 
static NodeCollectionPTR create (const std::vector< size_t > &node_ids)
 Create a NodeCollection from an array of node IDs.
 

Static Private Member Functions

static NodeCollectionPTR create_ ()
 
static NodeCollectionPTR create_ (const std::vector< size_t > &)
 

Private Attributes

unsigned long fingerprint_
 Unique identity of the kernel that created the NodeCollection.
 

Friends

class nc_const_iterator
 

Detailed Description

Superclass for NodeCollections.

The superclass acts as an interface to the primitive and composite NodeCollection types. It contains methods, mostly virtual, for the subclasses, and also create()-methods to be interfaced externally.

The superclass also contains handling of the fingerprint, a unique identity the NodeCollection gets from the kernel on creation, which ensures that the NodeCollection is not used after the kernel is reset.

There are two types of NodeCollections

  • Primitive NCs contain a contiguous range of GIDs of the same neuron model and always have stride 1.
    • Slicing a primitive node collection in the form nc[j:k] returns a new primitive node collection, except when nc has (spatial) metadata, in which case a composite node collection is returned. The reason for this is that we otherwise would have to create a copy of the position information.
  • Composite NCs can contain
    • A single primitive node collection with metadata created by nc[j:k] slicing; the composite NC then represents a view on the primitive node collection with window j:k.
    • Any sequence of primitive node collections with the same or different neuron types; if the node collections contain metadata, all must contain the same metadata and all parts of the composite are separate views
    • A striding slice over a NC in the form nc[j:k:s], where j and k are optional. Here, nc must have stride 1. If nc has metadata, it must be a primitive node collection.

For any node collection, three types of iterators can be obtained by different begin() methods:

  • begin() returns an iterator iterating over all elements of the node collection
  • rank_local_begin() returns an iterator iterating over the elements of the node collection which are local to the rank on which it is called
  • thread_local_begin() returns an iterator iterating over the elements of the node collection which are local to the thread (ie VP) on which it is called

There is only a single type of end iterator returned by end().

For more information on composite node collections, see the documentation for the derived class and nc_const_iterator.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ NodeCollection()

nest::NodeCollection::NodeCollection ( )

Initializer gets current fingerprint from the kernel.

◆ ~NodeCollection()

virtual nest::NodeCollection::~NodeCollection ( )
virtualdefault

Member Function Documentation

◆ begin()

virtual const_iterator nest::NodeCollection::begin ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
pure virtual

Method to get an iterator representing the beginning of the NodeCollection.

Returns
an iterator representing the beginning of the NodeCollection

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

Referenced by get_first(), and get_last().

Here is the caller graph for this function:

◆ contains()

virtual bool nest::NodeCollection::contains ( const size_t  node_id) const
pure virtual

Check if the NodeCollection contains a specified node ID.

Parameters
node_idnode ID to see if exists in the NodeCollection
Returns
true if the NodeCollection contains the node ID, false otherwise

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ create() [1/3]

NodeCollectionPTR nest::NodeCollection::create ( const Node *  node)
static

Create a NodeCollection from a single node pointer.

Results in a primitive unconditionally.

Parameters
nodeNode pointer from which to create the NodeCollection
Returns
a NodeCollection pointer to the created NodeCollection

References create(), create_(), and nest::Node::get_node_id().

Here is the call graph for this function:

◆ create() [2/3]

NodeCollectionPTR nest::NodeCollection::create ( const size_t  node_id)
static

Create a NodeCollection from a single node ID.

Results in a primitive unconditionally.

Parameters
node_idNode ID from which to create the NodeCollection
Returns
a NodeCollection pointer to the created NodeCollection

References create_().

Referenced by create(), nest::NodeManager::get_nodes(), nest::STDPDopaCommonProperties::get_status(), nest::CommonSynapseProperties::get_status(), nest::make_nodecollection(), nest::node_collection_array_index(), nest::node_collection_array_index(), nest::select_nodes_by_mask(), and nest::weight_recorder::Parameters_::set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ create() [3/3]

NodeCollectionPTR nest::NodeCollection::create ( const std::vector< size_t > &  node_ids)
static

Create a NodeCollection from an array of node IDs.

Results in a primitive if the node IDs are homogeneous and contiguous, or a composite otherwise.

Parameters
node_idsArray of node IDs from which to create the NodeCollection
Returns
a NodeCollection pointer to the created NodeCollection

References create_().

Here is the call graph for this function:

◆ create_() [1/2]

NodeCollectionPTR nest::NodeCollection::create_ ( )
staticprivate

Referenced by create(), create(), and create().

Here is the caller graph for this function:

◆ create_() [2/2]

NodeCollectionPTR nest::NodeCollection::create_ ( const std::vector< size_t > &  node_ids)
staticprivate

References nest::ModelRangeManager::get_model_id(), nest::kernel(), and nest::KernelManager::modelrange_manager.

Here is the call graph for this function:

◆ empty()

virtual bool nest::NodeCollection::empty ( ) const
pure virtual

Checks if the NodeCollection has no elements.

Returns
true if the NodeCollection is empty, false otherwise

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ end()

virtual const_iterator nest::NodeCollection::end ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
pure virtual

Method to get an iterator representing the end of the NodeCollection.

Parameters
offsetIndex of element NC that iterator points to
Returns
an iterator representing the end of the NodeCollection, taking offset into account

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

Referenced by nest::FreeLayer< D >::get_status(), and to_array().

Here is the caller graph for this function:

◆ get_first()

size_t nest::NodeCollection::get_first ( ) const
inline

return the first stored ID (i.e, ID at index zero) inside the NodeCollection

References begin().

Here is the call graph for this function:

◆ get_last()

size_t nest::NodeCollection::get_last ( ) const
inline

return the last stored ID inside the NodeCollection

References begin(), and size().

Here is the call graph for this function:

◆ get_metadata()

virtual NodeCollectionMetadataPTR nest::NodeCollection::get_metadata ( ) const
pure virtual

Gets the metadata of the NodeCollection.

Returns
A Metadata pointer

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

Referenced by get_metadata_status().

Here is the caller graph for this function:

◆ get_metadata_status()

void nest::NodeCollection::get_metadata_status ( Dictionary &  d) const

Collect metadata into dictionary.

References get_metadata().

Here is the call graph for this function:

◆ get_nc_index()

virtual long nest::NodeCollection::get_nc_index ( const size_t  ) const
pure virtual

Returns index of node with given node ID in NodeCollection.

Index here is into the sliced node collection, so that nc[ nc.get_nc_index( gid )].node_id == gid.

Returns
Index of node with given node ID; -1 if node not in NodeCollection.

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ has_proxies()

virtual bool nest::NodeCollection::has_proxies ( ) const
pure virtual

Returns whether the NodeCollection contains any nodes with proxies or not.

Returns
true if any nodes in the NodeCollection has proxies, false otherwise.

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ is_range()

virtual bool nest::NodeCollection::is_range ( ) const
pure virtual

◆ operator!=()

bool nest::NodeCollection::operator!= ( NodeCollectionPTR  rhs) const
inlinevirtual

Check if two NodeCollections are equal.

Parameters
rhsNodeCollection pointer to the NodeCollection to be checked against
Returns
true if they are equal, false otherwise

◆ operator+()

virtual NodeCollectionPTR nest::NodeCollection::operator+ ( NodeCollectionPTR  ) const
pure virtual

Join two NodeCollections.

May return a primitive or composite, depending on the input.

Parameters
rhsNodeCollection pointer to the NodeCollection to be added
Returns
a NodeCollection pointer

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ operator==()

virtual bool nest::NodeCollection::operator== ( NodeCollectionPTR  ) const
pure virtual

◆ operator[]()

virtual size_t nest::NodeCollection::operator[] ( size_t  ) const
pure virtual

Get the node ID in the specified index in the NodeCollection.

Parameters
idxIndex in the NodeCollection
Returns
a node ID

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ print_me()

virtual std::ostream & nest::NodeCollection::print_me ( std::ostream &  ) const
pure virtual

Print out the contents of the NodeCollection in a pretty and informative way.

Note
Important for resolution from NodeCollectionPTR to subclasses.

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ rank_local_begin()

virtual const_iterator nest::NodeCollection::rank_local_begin ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
pure virtual

Method to get an iterator representing the beginning of the NodeCollection.

Returns
an iterator representing the beginning of the NodeCollection, in an MPI-parallel context.

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

Referenced by nest::FreeLayer< D >::get_status(), and to_array().

Here is the caller graph for this function:

◆ set_metadata()

void nest::NodeCollection::set_metadata ( NodeCollectionMetadataPTR  )
inlinepure virtual

Sets the metadata of the NodeCollection.

Parameters
metaA Metadata pointer

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ size()

virtual size_t nest::NodeCollection::size ( ) const
pure virtual

Get the size of the NodeCollection.

Returns
number of node IDs in the NodeCollection

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

Referenced by get_last(), and nest::Layer< D >::get_status().

Here is the caller graph for this function:

◆ slice()

virtual NodeCollectionPTR nest::NodeCollection::slice ( size_t  start,
size_t  end,
size_t  stride 
) const
pure virtual

Slices the NodeCollection to the boundaries, with an optional step parameter.

Note that the boundaries being specified are inclusive.

Parameters
startIndex of the NodeCollection to start at
endOne past the index of the NodeCollection to stop at
strideNumber of places between node IDs to skip. Defaults to 1
Returns
a NodeCollection pointer to the new, sliced NodeCollection.

Implemented in nest::NodeCollectionComposite, and nest::NodeCollectionPrimitive.

◆ stride()

virtual size_t nest::NodeCollection::stride ( ) const
pure virtual

Get the step of the NodeCollection.

Returns
Stride between node IDs in the NodeCollection

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

◆ thread_local_begin()

virtual const_iterator nest::NodeCollection::thread_local_begin ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
pure virtual

Return iterator stepping from first node on the thread it is called on over nodes on that thread.

Returns
an iterator representing the beginning of the NodeCollection, in a parallel context.

Implemented in nest::NodeCollectionPrimitive, and nest::NodeCollectionComposite.

Referenced by to_array().

Here is the caller graph for this function:

◆ to_array()

std::vector< size_t > nest::NodeCollection::to_array ( const std::string &  selection) const

Method that creates a vector filled with node IDs from the NodeCollection; for debugging.

Parameters
selectionis "all", "rank" or "thread"
Returns
an vector containing node IDs ; if thread, separate thread sections by "0 thread# 0"

References end(), nest::kernel(), rank_local_begin(), and thread_local_begin().

Here is the call graph for this function:

◆ valid()

bool nest::NodeCollection::valid ( ) const

Check to see if the fingerprint of the NodeCollection matches that of the kernel.

Returns
true if the fingerprint matches that of the kernel, false otherwise

References fingerprint_, nest::KernelManager::get_fingerprint(), and nest::kernel().

Referenced by nest::NodeCollectionPrimitive::operator+(), nest::NodeCollectionComposite::operator+(), nest::NodeCollectionComposite::slice(), and nest::NodeCollectionPrimitive::slice().

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ nc_const_iterator

friend class nc_const_iterator
friend

Member Data Documentation

◆ fingerprint_

unsigned long nest::NodeCollection::fingerprint_
private

Unique identity of the kernel that created the NodeCollection.

Referenced by valid().


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