NEURON
neuron::container::handle_base< Identifier > Struct Template Reference

Base class for neuron::container::soa<...> handles. More...

#include <view_utils.hpp>

Inheritance diagram for neuron::container::handle_base< Identifier >:
neuron::container::Node::handle_interface< owning_identifier< storage > > neuron::container::Mechanism::handle_interface< Identifier > neuron::container::Node::handle_interface< Identifier > neuron::container::Node::owning_handle

Public Member Functions

 handle_base (Identifier identifier)
 Construct a handle from an identifier. More...
 
std::size_t current_row () const
 Return current offset in the underlying storage where this object lives. More...
 
non_owning_identifier_without_container id () const
 Obtain a lightweight identifier of the current entry. More...
 
auto id_hack () const
 This is a workaround for id sometimes being a macro. More...
 
auto & underlying_storage ()
 Obtain a reference to the storage this handle refers to. More...
 
auto const & underlying_storage () const
 Obtain a const reference to the storage this handle refers to. More...
 

Protected Member Functions

template<typename Tag >
auto get_handle ()
 Get a data_handle<T> referring to the given field inside this handle. More...
 
template<typename Tag >
auto get_handle (int field_index, int array_offset=0)
 Get a data_handle<T> referring to the (runtime) field_index-th copy of a given (static) field. More...
 
template<typename Tag >
auto & get ()
 
template<typename Tag >
auto const & get () const
 
template<typename Tag >
constexpr Tag const & get_tag () const
 Get the instance of the given tag type from underlying storage. More...
 
template<typename Tag >
auto & get (int field_index, int array_offset=0)
 
template<typename Tag >
auto const & get (int field_index, int array_offset=0) const
 

Private Attributes

Identifier m_identifier
 

Detailed Description

template<typename Identifier>
struct neuron::container::handle_base< Identifier >

Base class for neuron::container::soa<...> handles.

Template Parameters
IdentifierIdentifier type used for this handle. This encodes both the referred-to type (Node, Mechanism, ...) and the ownership semantics (owning, non-owning). The instance of this type manages both the pointer-to-row and pointer-to-storage members of the handle.

This provides some common methods that are neither specific to a particular data structure (Node, Mechanism, ...) nor specific to whether or not the handle has owning semantics or not. Methods that are specific to the data type (e.g. Node) belong in the interface template for that type (e.g. Node::interface). Methods that are specific to the owning/non-owning semantics belong in the generic templates non_owning_identifier<T> and owning_identifier<T>.

The typical way these components fit together is:

Node::identifier = non_owning_identifier<Node::storage> Node::owning_identifier = owning_identifier<Node::storage> Node::handle = Node::interface<Node::identifier> inherits from: handle_base<Node::identifier> Node::owning_handle = Node::interface<Node::owning_identifier> inherits from handle_base<Node::owning_identifier>

Where the "identifier" types should be viewed as an implementation detail and the handle types as user-facing.

Definition at line 34 of file view_utils.hpp.

Constructor & Destructor Documentation

◆ handle_base()

template<typename Identifier >
neuron::container::handle_base< Identifier >::handle_base ( Identifier  identifier)
inline

Construct a handle from an identifier.

Definition at line 38 of file view_utils.hpp.

Member Function Documentation

◆ current_row()

template<typename Identifier >
std::size_t neuron::container::handle_base< Identifier >::current_row ( ) const
inline

Return current offset in the underlying storage where this object lives.

Definition at line 44 of file view_utils.hpp.

◆ get() [1/4]

template<typename Identifier >
template<typename Tag >
auto& neuron::container::handle_base< Identifier >::get ( )
inlineprotected

Definition at line 111 of file view_utils.hpp.

◆ get() [2/4]

template<typename Identifier >
template<typename Tag >
auto const& neuron::container::handle_base< Identifier >::get ( ) const
inlineprotected

Definition at line 115 of file view_utils.hpp.

◆ get() [3/4]

template<typename Identifier >
template<typename Tag >
auto& neuron::container::handle_base< Identifier >::get ( int  field_index,
int  array_offset = 0 
)
inlineprotected

Definition at line 132 of file view_utils.hpp.

◆ get() [4/4]

template<typename Identifier >
template<typename Tag >
auto const& neuron::container::handle_base< Identifier >::get ( int  field_index,
int  array_offset = 0 
) const
inlineprotected

Definition at line 138 of file view_utils.hpp.

◆ get_handle() [1/2]

template<typename Identifier >
template<typename Tag >
auto neuron::container::handle_base< Identifier >::get_handle ( )
inlineprotected

Get a data_handle<T> referring to the given field inside this handle.

Template Parameters
TagTag type of the field we want a data_handle to.

This is used to implement methods like area_handle() and v_handle() in the interface templates.

Todo:
const cleanup – should there be a const version returning data_handle<T const>?

Definition at line 92 of file view_utils.hpp.

◆ get_handle() [2/2]

template<typename Identifier >
template<typename Tag >
auto neuron::container::handle_base< Identifier >::get_handle ( int  field_index,
int  array_offset = 0 
)
inlineprotected

Get a data_handle<T> referring to the (runtime) field_index-th copy of a given (static) field.

Template Parameters
TagTag type of the set of fields the from which the field_index-th one is being requested.
Todo:
Const cleanup as above for the zero-argument version.

Definition at line 105 of file view_utils.hpp.

◆ get_tag()

template<typename Identifier >
template<typename Tag >
constexpr Tag const& neuron::container::handle_base< Identifier >::get_tag ( ) const
inlineconstexprprotected

Get the instance of the given tag type from underlying storage.

Template Parameters
TagThe tag type.
Returns
Const reference to the given tag type instance inside the ~global storage struct.

This is a thin wrapper that calls soa::get_tag<Tag> on the storage container (currently an instance of Node::storage or Mechanism::storage) that this handle refers to an instance inside.

Definition at line 128 of file view_utils.hpp.

◆ id()

template<typename Identifier >
non_owning_identifier_without_container neuron::container::handle_base< Identifier >::id ( ) const
inline

Obtain a lightweight identifier of the current entry.

The return type is essentially std::size_t* – it does not contain a pointer/reference to the actual storage container.

Definition at line 54 of file view_utils.hpp.

◆ id_hack()

template<typename Identifier >
auto neuron::container::handle_base< Identifier >::id_hack ( ) const
inline

This is a workaround for id sometimes being a macro.

Todo:
Remove those macros once and for all.

Definition at line 62 of file view_utils.hpp.

◆ underlying_storage() [1/2]

template<typename Identifier >
auto& neuron::container::handle_base< Identifier >::underlying_storage ( )
inline

Obtain a reference to the storage this handle refers to.

Definition at line 69 of file view_utils.hpp.

◆ underlying_storage() [2/2]

template<typename Identifier >
auto const& neuron::container::handle_base< Identifier >::underlying_storage ( ) const
inline

Obtain a const reference to the storage this handle refers to.

Definition at line 76 of file view_utils.hpp.

Member Data Documentation

◆ m_identifier

template<typename Identifier >
Identifier neuron::container::handle_base< Identifier >::m_identifier
private

Definition at line 145 of file view_utils.hpp.


The documentation for this struct was generated from the following file: