20 if (node_count == 0) {
39 free(std::exchange(
nodelist,
nullptr));
41 delete[] std::exchange(
prop,
nullptr);
42 free(std::exchange(
pdata,
nullptr));
49 other.m_owns_nodes =
false;
54 rhs.m_owns_nodes =
false;
69 std::vector<double*> ret(num_fields,
nullptr);
70 for (
auto i = 0;
i < num_fields; ++
i) {
88 [[nodiscard]]
double&
Memb_list::data(std::size_t instance,
int variable,
int array_index) {
97 int array_index)
const {
151 auto const sum_of_array_dims = std::accumulate(array_dims, array_dims + num_fields, 0);
152 int sum_of_array_dims_of_previous_fields{};
154 auto const array_dim = array_dims[
field];
160 auto const instance_offset =
index / array_dim;
161 auto const array_index =
index % array_dim;
164 sum_of_array_dims_of_previous_fields + array_index;
166 sum_of_array_dims_of_previous_fields += array_dim;
168 assert(sum_of_array_dims_of_previous_fields == sum_of_array_dims);
174 return pdata[instance][variable].
get<
double*>();
std::optional< Model > model
size_t get_num_variables(T const &t)
constexpr std::size_t invalid_row
In mechanism libraries, cannot use auto const token = nrn_ensure_model_data_are_sorted(); because the...
#define nrn_assert(x)
assert()-like macro, independent of NDEBUG status
A view into a set of mechanism instances.
Memb_list & operator=(Memb_list &&) noexcept
int const * get_array_prefix_sums() const
Get the array_dims of field variable.
neuron::container::data_handle< double > data_handle(std::size_t instance, neuron::container::field_index field) const
Memb_list()=default
Construct a null Memb_list that does not refer to any thread/type.
bool m_owns_nodes
Whether this memlist owns its nodes memory or whether we are a view Has implications on memory manage...
void nodes_free()
Free memory allocated for nodes (with nodes_alloc)
int type() const
Get the mechanism type.
~Memb_list() noexcept
Uninitialize, freeing any allocated mem for nodes.
neuron::container::Mechanism::storage * m_storage
Pointer to the global mechanism data structure for this mech type.
std::ptrdiff_t legacy_index(double const *ptr) const
Calculate a legacy index of the given pointer in this mechanism data.
std::vector< double * > data()
Get a vector of double* representing the model data.
int const * get_array_dims() const
Get the array_dims of field variable.
std::size_t m_storage_offset
Offset of this thread+mechanism into the global mechanism data.
double * dptr_field(std::size_t instance)
void nodes_alloc(int node_count, bool also_pdata)
Allocate memory for node_count nodes.
Catch-all for floating point per-instance variables in the MOD file.
short type() const
The type of this mechanism.
Struct used to index SoAoS data, such as array range variables.
Non-template stable handle to a generic value.
T get() const
Explicit conversion to any T.
int const * get_array_dims() const
Get a pointer to an array holding the array dimensions of the fields associated with this tag.
int const * get_array_dim_prefix_sums() const
Get a pointer to an array holding the prefix sum of array dimensions for this tag.
Tag::type & get_field_instance(std::size_t offset, int field_index, int array_index=0)
Get the offset-th element of the field_index-th instance of the column named by Tag.
std::size_t size() const
Get the size of the container.
constexpr Tag const & get_tag() const
Get the instance of the given tag type.
non_owning_identifier_without_container get_identifier(std::size_t offset) const
Get the offset-th identifier.
size_t get_num_variables() const
data_handle< typename Tag::type > get_field_instance_handle(non_owning_identifier_without_container id, int field_index, int array_index=0) const
Get a handle to the given element of the field_index-th column named by Tag.