NEURON
model_data_fwd.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <memory>
3 #include <string_view>
4 
5 namespace neuron {
6 struct Model;
7 inline Model& model();
8 namespace container {
9 template <typename>
10 struct data_handle;
11 namespace utils {
12 template <typename T>
13 [[nodiscard]] data_handle<T> find_data_handle(T* ptr);
14 
15 /**
16  * @brief Interface for obtaining information about model data containers.
17  *
18  * This indirection via an abstract interface helps reduce the ABI surface between translated MOD
19  * file code and the rest of the library.
20  */
21 struct storage_info {
22  virtual ~storage_info() = default;
23  virtual std::string_view container() const = 0;
24  virtual std::string_view field() const = 0;
25  virtual std::size_t size() const = 0;
26 };
27 
28 /** @brief Try and find a helpful name for a container.
29  *
30  * In practice this can be expected to be work for the structures that can be
31  * discovered from neuron::model(), and not for anything else. If no
32  * information about the container can be found the returned std::optional will
33  * not contain a value.
34  */
35 [[nodiscard]] std::unique_ptr<storage_info> find_container_info(void const*);
36 } // namespace utils
37 } // namespace container
38 } // namespace neuron
data_handle< T > find_data_handle(T *ptr)
std::unique_ptr< storage_info > find_container_info(void const *)
Try and find a helpful name for a container.
Definition: container.cpp:149
In mechanism libraries, cannot use auto const token = nrn_ensure_model_data_are_sorted(); because the...
Definition: tnode.hpp:17
Model & model()
Access the global Model instance.
Definition: model_data.hpp:206
Interface for obtaining information about model data containers.
virtual std::string_view container() const =0
virtual std::string_view field() const =0
virtual std::size_t size() const =0