NEURON
neuron::container::detail Namespace Reference

Classes

struct  index_of_type_helper
 
struct  index_of_type_helper< T, std::tuple< T, Ts... > >
 
struct  index_of_type_helper< T, std::tuple< U, Ts... > >
 
struct  has_num_variables
 
struct  has_num_variables< T, std::void_t< decltype(std::declval< T >().num_variables())> >
 
struct  optional
 
struct  optional< T, std::void_t< decltype(T::optional)> >
 
struct  index_column_tag
 
struct  field_data
 
struct  field_data< Tag, FieldImplementation::RuntimeVariable >
 Storage manager for a tag type that implements num_variables(). More...
 
struct  storage_info_impl
 
class  AccumulateMemoryUsage
 

Enumerations

enum class  FieldImplementation { AlwaysSingle , OptionalSingle , RuntimeVariable }
 
enum class  may_cause_reallocation { Yes , No }
 

Functions

void notify_handle_dying (non_owning_identifier_without_container p)
 Respond to the news that data_handles relying on p are now dead. More...
 
template<typename T >
std::ostream & print_value_impl (std::ostream &os, T const &,...)
 
template<typename T >
auto print_value_impl (std::ostream &os, T const &val, std::nullptr_t) -> decltype(os<< val)
 
template<typename T >
std::ostream & print_value (std::ostream &os, T const &val)
 
template<typename T >
auto get_array_dimension (T const &t, std::nullptr_t) -> decltype(t.array_dimension(), 0)
 
template<typename T >
auto get_array_dimension (T const &t, int i) -> decltype(t.array_dimension(i), 0)
 
template<typename T >
int get_array_dimension (T const &,...)
 
template<class T >
size_t get_num_variables (T const &t)
 
template<typename Tag >
auto get_name_impl (Tag const &tag, int field_index, std::nullptr_t) -> decltype(static_cast< void >(tag.name(field_index)), std::string())
 
template<typename Tag >
std::string get_name_impl (Tag const &tag, int field_index,...)
 
template<typename Tag >
auto get_name (Tag const &tag, int field_index)
 Get the nicest available name for the field_index-th instance of Tag. More...
 
template<typename Rng >
bool check_permutation_vector (Rng const &range, std::size_t size)
 Check if the given range is a permutation of the first N integers. More...
 
VectorMemoryUsage compute_defer_delete_storage_size ()
 
template<typename T >
void defer_delete (std::unique_ptr< T[]> data)
 Storage for safe deletion of soa<...> containers. More...
 
template<class T >
VectorMemoryUsage compute_defer_delete_storage_size (std::vector< T > const *const v, size_t per_element_size)
 

Variables

template<typename T , typename... Ts>
constexpr bool type_in_pack_v = std::disjunction_v<std::is_same<T, Ts>...>
 
template<typename T , typename... Types>
constexpr bool are_types_unique_v
 
template<typename T >
constexpr bool are_types_unique_v< T > = true
 
template<typename T , typename... Ts>
constexpr std::size_t index_of_type_v
 
template<typename T , typename = void>
constexpr bool has_default_value_v = false
 
template<typename T >
constexpr bool has_num_variables_v = has_num_variables<T>::value
 
template<typename T >
constexpr bool optional_v = optional<T>::value
 
template<typename Tag >
constexpr FieldImplementation field_impl_v
 
std::vector< void * > * defer_delete_storage {}
 Defer deleting pointers to deallocated memory. More...
 

Enumeration Type Documentation

◆ FieldImplementation

Enumerator
AlwaysSingle 
OptionalSingle 
RuntimeVariable 

Definition at line 107 of file soa_container.hpp.

◆ may_cause_reallocation

Enumerator
Yes 
No 

Definition at line 192 of file soa_container.hpp.

Function Documentation

◆ check_permutation_vector()

template<typename Rng >
bool neuron::container::detail::check_permutation_vector ( Rng const &  range,
std::size_t  size 
)

Check if the given range is a permutation of the first N integers.

Returns
true if the permutation is trivial, false otherwise.

A trivial permutation is one where i == range[i] for all i. An empty range is classed as trivial.

Definition at line 171 of file soa_container.hpp.

◆ compute_defer_delete_storage_size() [1/2]

VectorMemoryUsage neuron::container::detail::compute_defer_delete_storage_size ( )

Definition at line 67 of file memory_usage.cpp.

◆ compute_defer_delete_storage_size() [2/2]

template<class T >
VectorMemoryUsage neuron::container::detail::compute_defer_delete_storage_size ( std::vector< T > const *const  v,
size_t  per_element_size 
)

Definition at line 54 of file memory_usage.cpp.

◆ defer_delete()

template<typename T >
void neuron::container::detail::defer_delete ( std::unique_ptr< T[]>  data)

Storage for safe deletion of soa<...> containers.

This is intended to prevent deleting an instance of a soa<...>-based container from invalidating any existing data handles, by keeping certain (small) values alive. Deleting these containers is probably not common (e.g. deleting a mechanism type), and only small bookkeeping-related values have to be kept alive. Generally defer_delete_storage is non-null for the lifetime of the top level Model structure, and the Model destructor deallocates (using delete[]) the pointers that are stored inside defer_delete_storage.

Definition at line 215 of file soa_container.hpp.

◆ get_array_dimension() [1/3]

template<typename T >
int neuron::container::detail::get_array_dimension ( T const &  ,
  ... 
)

Definition at line 75 of file soa_container.hpp.

◆ get_array_dimension() [2/3]

template<typename T >
auto neuron::container::detail::get_array_dimension ( T const &  t,
int  i 
) -> decltype(t.array_dimension(i), 0)

Definition at line 71 of file soa_container.hpp.

◆ get_array_dimension() [3/3]

template<typename T >
auto neuron::container::detail::get_array_dimension ( T const &  t,
std::nullptr_t   
) -> decltype(t.array_dimension(), 0)

Definition at line 66 of file soa_container.hpp.

◆ get_name()

template<typename Tag >
auto neuron::container::detail::get_name ( Tag const &  tag,
int  field_index 
)

Get the nicest available name for the field_index-th instance of Tag.

This should elegantly handle field_index == -1 (=> the tag doesn't get have num_variables()) and field_index being out of range.

Definition at line 148 of file soa_container.hpp.

◆ get_name_impl() [1/2]

template<typename Tag >
auto neuron::container::detail::get_name_impl ( Tag const &  tag,
int  field_index,
std::nullptr_t   
) -> decltype(static_cast<void>(tag.name(field_index)), std::string())

Definition at line 122 of file soa_container.hpp.

◆ get_name_impl() [2/2]

template<typename Tag >
std::string neuron::container::detail::get_name_impl ( Tag const &  tag,
int  field_index,
  ... 
)

Definition at line 128 of file soa_container.hpp.

◆ get_num_variables()

template<class T >
size_t neuron::container::detail::get_num_variables ( T const &  t)

Definition at line 89 of file soa_container.hpp.

◆ notify_handle_dying()

void neuron::container::detail::notify_handle_dying ( non_owning_identifier_without_container  p)

Respond to the news that data_handles relying on p are now dead.

The data_handle<T> and generic_data_handle wrappers ultimately hold something like vector_ptr and p, where p is basically std::size_t*, and yield vector_ptr->at(*p). When the relevant value gets deleted, *p is set to a sentinel value, then this method is called, and then p is transferred to a garbage heap.

Definition at line 114 of file ivoc.cpp.

◆ print_value()

template<typename T >
std::ostream& neuron::container::detail::print_value ( std::ostream &  os,
T const &  val 
)

Definition at line 26 of file data_handle.hpp.

◆ print_value_impl() [1/2]

template<typename T >
std::ostream& neuron::container::detail::print_value_impl ( std::ostream &  os,
T const &  ,
  ... 
)

Definition at line 18 of file data_handle.hpp.

◆ print_value_impl() [2/2]

template<typename T >
auto neuron::container::detail::print_value_impl ( std::ostream &  os,
T const &  val,
std::nullptr_t   
) -> decltype(os << val)

Definition at line 22 of file data_handle.hpp.

Variable Documentation

◆ are_types_unique_v

template<typename T , typename... Types>
constexpr bool neuron::container::detail::are_types_unique_v
inlineconstexpr
Initial value:
=
(!std::is_same_v<T, Types> && ...) && are_types_unique_v<Types...>
constexpr bool are_types_unique_v

Definition at line 24 of file soa_container.hpp.

◆ are_types_unique_v< T >

template<typename T >
constexpr bool neuron::container::detail::are_types_unique_v< T > = true
inlineconstexpr

Definition at line 27 of file soa_container.hpp.

◆ defer_delete_storage

std::vector< void * > * neuron::container::detail::defer_delete_storage {}

Defer deleting pointers to deallocated memory.

The address of a pointer to the underlying storage of field_data can escape the container. When deallocating the container the memory is deallocated but the pointer to the storage location is "leaked" into this vector.

Definition at line 95 of file container.cpp.

◆ field_impl_v

template<typename Tag >
constexpr FieldImplementation neuron::container::detail::field_impl_v
inlineconstexpr
Initial value:
=
(has_num_variables_v<Tag> ? FieldImplementation::RuntimeVariable
: (optional_v<Tag> ? FieldImplementation::OptionalSingle
: FieldImplementation::AlwaysSingle))

Definition at line 115 of file soa_container.hpp.

◆ has_default_value_v

template<typename T , typename = void>
constexpr bool neuron::container::detail::has_default_value_v = false
inlineconstexpr

Definition at line 58 of file soa_container.hpp.

◆ has_num_variables_v

template<typename T >
constexpr bool neuron::container::detail::has_num_variables_v = has_num_variables<T>::value
inlineconstexpr

Definition at line 86 of file soa_container.hpp.

◆ index_of_type_v

template<typename T , typename... Ts>
constexpr std::size_t neuron::container::detail::index_of_type_v
inlineconstexpr
Initial value:
= []() {
constexpr bool Ts_are_unique = are_types_unique_v<Ts...>;
constexpr bool T_is_in_Ts = type_in_pack_v<T, Ts...>;
static_assert(Ts_are_unique,
"index_of_type_v<T, Ts...> assumes there are no duplicates in Ts...");
static_assert(T_is_in_Ts, "index_of_type_v<T, Ts...> assumes that T occurs in Ts...");
if constexpr (Ts_are_unique && T_is_in_Ts) {
return index_of_type_helper<T, std::tuple<Ts...>>::value;
} else {
return std::numeric_limits<std::size_t>::max();
}
}()
constexpr bool type_in_pack_v
static uint32_t value
Definition: scoprand.cpp:25

Definition at line 40 of file soa_container.hpp.

◆ optional_v

template<typename T >
constexpr bool neuron::container::detail::optional_v = optional<T>::value
inlineconstexpr

Definition at line 105 of file soa_container.hpp.

◆ type_in_pack_v

template<typename T , typename... Ts>
constexpr bool neuron::container::detail::type_in_pack_v = std::disjunction_v<std::is_same<T, Ts>...>
inlineconstexpr

Definition at line 21 of file soa_container.hpp.