NEST main@caf0ae8
 
Loading...
Searching...
No Matches
nest::NodeCollectionPrimitive Class Reference

Subclass for the primitive NodeCollection type. More...

#include <node_collection.h>

Inheritance diagram for nest::NodeCollectionPrimitive:
[legend]
Collaboration diagram for nest::NodeCollectionPrimitive:
[legend]

Public Member Functions

 NodeCollectionPrimitive (size_t first, size_t last, size_t model_id, NodeCollectionMetadataPTR)
 Create a primitive from a range of node IDs, with provided model ID and metadata pointer.
 
 NodeCollectionPrimitive (size_t first, size_t last, size_t model_id)
 Create a primitive from a range of node IDs, with provided model ID.
 
 NodeCollectionPrimitive (size_t first, size_t last)
 Create a primitive from a range of node IDs.
 
 NodeCollectionPrimitive (const NodeCollectionPrimitive &)=default
 Primitive copy constructor.
 
NodeCollectionPrimitive & operator= (const NodeCollectionPrimitive &)=default
 Primitive assignment operator.
 
 NodeCollectionPrimitive ()
 Create empty NodeCollection.
 
std::ostream & print_me (std::ostream &) const override
 Print out the contents of the NodeCollection in a pretty and informative way.
 
void print_primitive (std::ostream &) const
 
size_t operator[] (const size_t) const override
 Get the node ID in the specified index in the NodeCollection.
 
NodeCollectionPTR operator+ (NodeCollectionPTR rhs) const override
 Join two NodeCollections.
 
bool operator== (const NodeCollectionPTR rhs) const override
 
bool operator== (const NodeCollectionPrimitive &rhs) const
 
const_iterator begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override
 Method to get an iterator representing the beginning of the NodeCollection.
 
const_iterator thread_local_begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override
 Return iterator stepping from first node on the thread it is called on over nodes on that thread.
 
const_iterator rank_local_begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override
 Method to get an iterator representing the beginning of the NodeCollection.
 
const_iterator end (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override
 Method to get an iterator representing the end of the NodeCollection.
 
size_t size () const override
 Returns total number of node IDs in the primitive.
 
size_t stride () const override
 Returns the stride between node IDs in the primitive (always 1).
 
bool contains (const size_t node_id) const override
 Check if the NodeCollection contains a specified node ID.
 
NodeCollectionPTR slice (size_t start, size_t end, size_t stride=1) const override
 Slices the NodeCollection to the boundaries, with an optional step parameter.
 
void set_metadata (NodeCollectionMetadataPTR) override
 Sets the metadata of the NodeCollection.
 
NodeCollectionMetadataPTR get_metadata () const override
 Gets the metadata of the NodeCollection.
 
bool is_range () const override
 
bool empty () const override
 Checks if the NodeCollection has no elements.
 
long get_nc_index (const size_t) const override
 Returns index of node with given node ID in NodeCollection.
 
bool has_proxies () const override
 Returns whether the NodeCollection contains any nodes with proxies or not.
 
bool is_contiguous_ascending (const NodeCollectionPrimitive &other) const
 Checks if node IDs in another primitive is a continuation of node IDs in this primitive.
 
bool overlapping (const NodeCollectionPrimitive &rhs) const
 Checks if node IDs of another primitive is overlapping node IDs of this primitive.
 
- Public Member Functions inherited from nest::NodeCollection
 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 bool operator!= (NodeCollectionPTR) const
 Check if two NodeCollections are equal.
 
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.
 
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
 

Private Member Functions

void assert_consistent_model_ids_ (const size_t) const
 Raise an error if the model IDs of all nodes in the primitive are not the same as the expected model id.
 

Private Attributes

size_t first_
 The first node ID in the primitive.
 
size_t last_
 The last node ID in the primitive.
 
size_t model_id_
 Model ID of the node IDs.
 
NodeCollectionMetadataPTR metadata_
 Pointer to the metadata of the node IDs.
 
bool nodes_have_no_proxies_
 Whether the primitive contains devices or not.
 

Friends

class nc_const_iterator
 

Additional Inherited Members

- Public Types inherited from nest::NodeCollection
using const_iterator = nc_const_iterator
 
- Static Public Member Functions inherited from nest::NodeCollection
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.
 

Detailed Description

Subclass for the primitive NodeCollection type.

The primitive type contains only homogeneous and contiguous node IDs. It also contains model ID and metadata of the node IDs.

Constructor & Destructor Documentation

◆ NodeCollectionPrimitive() [1/5]

nest::NodeCollectionPrimitive::NodeCollectionPrimitive ( size_t  first,
size_t  last,
size_t  model_id,
NodeCollectionMetadataPTR  meta 
)

Create a primitive from a range of node IDs, with provided model ID and metadata pointer.

Parameters
firstThe first node ID in the primitive
lastThe last node ID in the primitive
model_idModel ID of the node IDs
metaMetadata pointer of the node IDs

References assert_consistent_model_ids_(), first_, last_, and model_id_.

Here is the call graph for this function:

◆ NodeCollectionPrimitive() [2/5]

nest::NodeCollectionPrimitive::NodeCollectionPrimitive ( size_t  first,
size_t  last,
size_t  model_id 
)

Create a primitive from a range of node IDs, with provided model ID.

Parameters
firstThe first node ID in the primitive
lastThe last node ID in the primitive
model_idModel ID of the node IDs

References first_, and last_.

◆ NodeCollectionPrimitive() [3/5]

nest::NodeCollectionPrimitive::NodeCollectionPrimitive ( size_t  first,
size_t  last 
)

Create a primitive from a range of node IDs.

The model ID has to be found by the constructor.

Parameters
firstThe first node ID in the primitive
lastThe last node ID in the primitive

References first_, nest::ModelRangeManager::get_model_id(), nest::ModelManager::get_node_model(), nest::Model::has_proxies(), nest::kernel(), last_, model_id_, nest::KernelManager::model_manager, nest::KernelManager::modelrange_manager, and nodes_have_no_proxies_.

Here is the call graph for this function:

◆ NodeCollectionPrimitive() [4/5]

nest::NodeCollectionPrimitive::NodeCollectionPrimitive ( const NodeCollectionPrimitive &  )
default

Primitive copy constructor.

Parameters
rhsPrimitive to copy

◆ NodeCollectionPrimitive() [5/5]

nest::NodeCollectionPrimitive::NodeCollectionPrimitive ( )

Create empty NodeCollection.

Note
This is only for use by SPBuilder.

Member Function Documentation

◆ assert_consistent_model_ids_()

void nest::NodeCollectionPrimitive::assert_consistent_model_ids_ ( const size_t  expected_model_id) const
private

Raise an error if the model IDs of all nodes in the primitive are not the same as the expected model id.

Note
For use in the constructor only.
Parameters
model_idExpected model id.

References first_, nest::ModelRangeManager::get_model_id(), nest::ModelRangeManager::get_model_of_node_id(), nest::Model::get_name(), nest::kernel(), last_, nest::message(), and nest::KernelManager::modelrange_manager.

Referenced by NodeCollectionPrimitive().

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

◆ begin()

NodeCollection::const_iterator nest::NodeCollectionPrimitive::begin ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
inlineoverridevirtual

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

Returns
an iterator representing the beginning of the NodeCollection

Implements nest::NodeCollection.

References nc_const_iterator.

◆ contains()

bool nest::NodeCollectionPrimitive::contains ( const size_t  node_id) const
inlineoverridevirtual

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

Implements nest::NodeCollection.

References first_, and last_.

◆ empty()

bool nest::NodeCollectionPrimitive::empty ( ) const
inlineoverridevirtual

Checks if the NodeCollection has no elements.

Returns
true if the NodeCollection is empty, false otherwise

Implements nest::NodeCollection.

References last_.

Referenced by operator+(), and print_me().

Here is the caller graph for this function:

◆ end()

NodeCollection::const_iterator nest::NodeCollectionPrimitive::end ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
inlineoverridevirtual

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

Implements nest::NodeCollection.

References nest::nc_const_iterator::END, nc_const_iterator, and size().

Referenced by slice().

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

◆ get_metadata()

NodeCollectionMetadataPTR nest::NodeCollectionPrimitive::get_metadata ( ) const
inlineoverridevirtual

Gets the metadata of the NodeCollection.

Returns
A Metadata pointer

Implements nest::NodeCollection.

References metadata_.

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

Here is the caller graph for this function:

◆ get_nc_index()

long nest::NodeCollectionPrimitive::get_nc_index ( const size_t  ) const
inlineoverridevirtual

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.

Implements nest::NodeCollection.

References first_, and last_.

◆ has_proxies()

bool nest::NodeCollectionPrimitive::has_proxies ( ) const
inlineoverridevirtual

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

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

Implements nest::NodeCollection.

References nodes_have_no_proxies_.

◆ is_contiguous_ascending()

bool nest::NodeCollectionPrimitive::is_contiguous_ascending ( const NodeCollectionPrimitive &  other) const

Checks if node IDs in another primitive is a continuation of node IDs in this primitive.

Parameters
otherPrimitive to check for continuity
Returns
True if the first element in the other primitive is the next after the last element in this primitive, and they both have the same model ID. Otherwise false.

References last_, and model_id_.

◆ is_range()

bool nest::NodeCollectionPrimitive::is_range ( ) const
inlineoverridevirtual

Implements nest::NodeCollection.

◆ operator+()

NodeCollectionPTR nest::NodeCollectionPrimitive::operator+ ( NodeCollectionPTR  ) const
overridevirtual

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

Implements nest::NodeCollection.

References empty(), first_, get_metadata(), last_, metadata_, model_id_, overlapping(), and nest::NodeCollection::valid().

Here is the call graph for this function:

◆ operator=()

NodeCollectionPrimitive & nest::NodeCollectionPrimitive::operator= ( const NodeCollectionPrimitive &  )
default

Primitive assignment operator.

Parameters
rhsPrimitive to assign

◆ operator==() [1/2]

bool nest::NodeCollectionPrimitive::operator== ( const NodeCollectionPrimitive &  rhs) const
inline

References first_, last_, metadata_, and model_id_.

◆ operator==() [2/2]

bool nest::NodeCollectionPrimitive::operator== ( const NodeCollectionPTR  rhs) const
inlineoverridevirtual

Implements nest::NodeCollection.

◆ operator[]()

size_t nest::NodeCollectionPrimitive::operator[] ( const size_t  ) const
inlineoverridevirtual

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

Parameters
idxIndex in the NodeCollection
Returns
a node ID

Implements nest::NodeCollection.

References first_, and last_.

◆ overlapping()

bool nest::NodeCollectionPrimitive::overlapping ( const NodeCollectionPrimitive &  rhs) const

Checks if node IDs of another primitive is overlapping node IDs of this primitive.

Parameters
rhsPrimitive to be checked.
Returns
True if the other primitive overlaps, false otherwise.

References first_, and last_.

Referenced by operator+().

Here is the caller graph for this function:

◆ print_me()

std::ostream & nest::NodeCollectionPrimitive::print_me ( std::ostream &  ) const
overridevirtual

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

Note
Important for resolution from NodeCollectionPTR to subclasses.

Implements nest::NodeCollection.

References empty(), metadata_, and print_primitive().

Here is the call graph for this function:

◆ print_primitive()

void nest::NodeCollectionPrimitive::print_primitive ( std::ostream &  out) const

References first_, nest::Model::get_name(), nest::ModelManager::get_node_model(), nest::kernel(), last_, model_id_, nest::KernelManager::model_manager, and size().

Referenced by print_me().

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

◆ rank_local_begin()

NodeCollection::const_iterator nest::NodeCollectionPrimitive::rank_local_begin ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
overridevirtual

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.

Implements nest::NodeCollection.

References nest::nc_const_iterator::END, first_, nest::MPIManager::get_num_processes(), nest::MPIManager::get_process_id_of_vp(), nest::MPIManager::get_rank(), nest::kernel(), nest::KernelManager::mpi_manager, nest::nc_const_iterator::RANK_LOCAL, and size().

Here is the call graph for this function:

◆ set_metadata()

void nest::NodeCollectionPrimitive::set_metadata ( NodeCollectionMetadataPTR  )
inlineoverridevirtual

Sets the metadata of the NodeCollection.

Parameters
metaA Metadata pointer

Implements nest::NodeCollection.

References metadata_.

◆ size()

size_t nest::NodeCollectionPrimitive::size ( ) const
inlineoverridevirtual

Returns total number of node IDs in the primitive.

Implements nest::NodeCollection.

References first_, and last_.

Referenced by end(), nest::nc_const_iterator::find_next_within_part_(), nest::nc_const_iterator::nc_const_iterator(), print_primitive(), rank_local_begin(), slice(), and thread_local_begin().

Here is the caller graph for this function:

◆ slice()

NodeCollectionPTR nest::NodeCollectionPrimitive::slice ( size_t  start,
size_t  end,
size_t  stride = 1 
) const
overridevirtual

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.

Implements nest::NodeCollection.

References end(), first_, metadata_, model_id_, size(), stride(), and nest::NodeCollection::valid().

Here is the call graph for this function:

◆ stride()

size_t nest::NodeCollectionPrimitive::stride ( ) const
inlineoverridevirtual

Returns the stride between node IDs in the primitive (always 1).

Implements nest::NodeCollection.

Referenced by slice().

Here is the caller graph for this function:

◆ thread_local_begin()

NodeCollection::const_iterator nest::NodeCollectionPrimitive::thread_local_begin ( NodeCollectionPTR  = NodeCollectionPTR(nullptr)) const
overridevirtual

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.

Implements nest::NodeCollection.

References nest::nc_const_iterator::END, first_, nest::VPManager::get_num_virtual_processes(), nest::kernel(), nc_const_iterator, nest::VPManager::node_id_to_vp(), size(), nest::nc_const_iterator::THREAD_LOCAL, nest::VPManager::thread_to_vp(), and nest::KernelManager::vp_manager.

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ nc_const_iterator

friend class nc_const_iterator
friend

Referenced by begin(), end(), and thread_local_begin().

Member Data Documentation

◆ first_

◆ last_

◆ metadata_

NodeCollectionMetadataPTR nest::NodeCollectionPrimitive::metadata_
private

Pointer to the metadata of the node IDs.

Referenced by get_metadata(), operator+(), operator==(), print_me(), set_metadata(), and slice().

◆ model_id_

size_t nest::NodeCollectionPrimitive::model_id_
private

◆ nodes_have_no_proxies_

bool nest::NodeCollectionPrimitive::nodes_have_no_proxies_
private

Whether the primitive contains devices or not.

Referenced by has_proxies(), and NodeCollectionPrimitive().


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