NEURON
|
Stable handle to a generic value. More...
#include <data_handle.hpp>
Public Member Functions | |
data_handle ()=default | |
data_handle (T *raw_ptr) | |
Construct a data_handle from a plain pointer. More... | |
data_handle (do_not_search_t, T *raw_ptr) | |
Create a data_handle<T> wrapping the raw T*. More... | |
data_handle | next_array_element (int shift=1) const |
Get a data handle to a different element of the same array variable. More... | |
bool | refers_to_a_modern_data_structure () const |
Query whether this data handle is in "modern" mode. More... | |
data_handle (non_owning_identifier_without_container offset, T *const *container, int array_dim, int array_index) | |
operator bool () const | |
template<typename Tag , typename Container > | |
bool | refers_to (Container const &container) const |
Query whether this generic handle points to a value from the Tag field of the given container. More... | |
std::size_t | current_row () const |
Get the current logical row number. More... | |
T & | operator* () |
T const & | operator* () const |
operator T* () | |
operator T const * () const | |
non_owning_identifier_without_container | identifier () const |
Get the identifier used by this handle. More... | |
Private Member Functions | |
T * | raw_ptr () |
T const * | raw_ptr () const |
T * | container_data () |
T const * | container_data () const |
Static Private Member Functions | |
template<typename This > | |
static auto | get_ptr_helper (This &this_ref) |
Private Attributes | |
non_owning_identifier_without_container | m_offset {} |
void * | m_container_or_raw_ptr {} |
int | m_array_dim {1} |
int | m_array_index {} |
Friends | |
struct | generic_data_handle |
struct | std::hash< data_handle > |
std::ostream & | operator<< (std::ostream &os, data_handle const &dh) |
bool | operator== (data_handle const &lhs, data_handle const &rhs) |
bool | operator!= (data_handle const &lhs, data_handle const &rhs) |
Stable handle to a generic value.
Without this type one can already hold a Node::handle foo
and call something like foo.v()
to get that Node's voltage in a way that is stable against permutations of the underlying data. The data_handle concept is intended to be used if we want to erase the detail that the quantity is a voltage, or that it belongs to a Node, and simply treat it as a floating-point value that we may want to dereference later – essentially a substitute for double*.
Implementation: like Node::handle we can store a std::size_t* that we dereference to find out either:
Assuming nothing has been invalidated, we have an offset, a type, and the fundamental assumption behind all of this that the underlying data are contiguous – we "just" need to know the address of the start of the underlying storage vector without adding specific type information (like Node) to this class. The simplest way of doing this is to assume that the underlying storage is always std::vector<T> (or a custom allocator that is always the same type in neuron::container::*). Note that storing T* or span<T> would not work if the underlying storage is reallocated.
Definition at line 61 of file data_handle.hpp.
|
default |
|
inlineexplicit |
Construct a data_handle from a plain pointer.
Definition at line 66 of file data_handle.hpp.
|
inline |
Create a data_handle<T> wrapping the raw T*.
Unlike the constructor taking T*, this does not attempt to promote raw pointers to modern data_handles.
Definition at line 91 of file data_handle.hpp.
|
inline |
Definition at line 134 of file data_handle.hpp.
|
inlineprivate |
Definition at line 190 of file data_handle.hpp.
|
inlineprivate |
Definition at line 193 of file data_handle.hpp.
|
inline |
Get the current logical row number.
Definition at line 175 of file data_handle.hpp.
|
inlinestaticprivate |
Definition at line 197 of file data_handle.hpp.
|
inline |
Get the identifier used by this handle.
This is likely to only be useful for the (hopefully temporary) method neuron::container::notify_when_handle_dies.
Definition at line 311 of file data_handle.hpp.
|
inline |
Get a data handle to a different element of the same array variable.
Given an array variable a[N], this method allows a handle to a[i] to yield a handle to a[j] within the same logical row. If the handle is wrapping a raw pointer T*, the shift is applied to that raw pointer.
Definition at line 101 of file data_handle.hpp.
|
inlineexplicit |
Definition at line 143 of file data_handle.hpp.
|
inlineexplicit |
Definition at line 247 of file data_handle.hpp.
|
inlineexplicit |
Definition at line 243 of file data_handle.hpp.
|
inline |
Definition at line 221 of file data_handle.hpp.
|
inline |
Definition at line 232 of file data_handle.hpp.
|
inlineprivate |
Definition at line 184 of file data_handle.hpp.
|
inlineprivate |
Definition at line 187 of file data_handle.hpp.
|
inline |
Query whether this generic handle points to a value from the Tag
field of the given container.
Definition at line 160 of file data_handle.hpp.
|
inline |
Query whether this data handle is in "modern" mode.
Note that this does not mean that the handle is still valid. The referred-to row and/or column may have gone away in the meantime.
Definition at line 126 of file data_handle.hpp.
|
friend |
Definition at line 316 of file data_handle.hpp.
|
friend |
Definition at line 301 of file data_handle.hpp.
|
friend |
Definition at line 251 of file data_handle.hpp.
|
friend |
Definition at line 295 of file data_handle.hpp.
|
friend |
Definition at line 316 of file data_handle.hpp.
|
private |
Definition at line 326 of file data_handle.hpp.
|
private |
Definition at line 326 of file data_handle.hpp.
|
private |
Definition at line 322 of file data_handle.hpp.
|
private |
Definition at line 318 of file data_handle.hpp.