11 #include <type_traits>
13 #include <unordered_map>
53 #define NULL_CUR (Pfri) 0
54 #define NULL_ALLOC (Pfri) 0
55 #define NULL_STATE (Pfri) 0
56 #define NULL_INITIALIZE (Pfri) 0
116 #define CABLESECTION 1
169 #define NMODLRANDOM 6
171 #define BEFORE_INITIAL 0
172 #define AFTER_INITIAL 1
173 #define BEFORE_BREAKPOINT 2
174 #define AFTER_SOLVE 3
175 #define BEFORE_STEP 4
176 #define BEFORE_AFTER_SIZE 5
197 template <
typename T>
202 field(std::string name_,
int array_size_)
205 field(std::string name_, std::string semantics_)
213 std::vector<std::pair<const char*, int>>
const& param_info,
214 std::vector<std::pair<const char*, const char*>>
const& dparam_size);
216 std::vector<std::pair<std::string, int>>
const& param_info,
217 std::vector<std::pair<std::string, std::string>>
const& dparam_size);
236 template <
typename... Fields>
239 std::vector<std::pair<const char*, int>> param_info{};
240 std::vector<std::pair<const char*, const char*>> dparam_info{};
241 auto const process = [&](
auto const&
field) {
242 using field_t = std::decay_t<decltype(
field)>;
244 if constexpr (std::is_same_v<data_t, double>) {
246 param_info.emplace_back(
field.name.c_str(),
field.array_size);
248 static_assert(std::is_same_v<data_t, int> || std::is_pointer_v<data_t>,
249 "only pointers, doubles and ints are supported");
251 dparam_info.emplace_back(
field.name.c_str(),
field.semantics.c_str());
256 static_cast<void>(std::initializer_list<int>{(
static_cast<void>(process(fields)), 0)...});
274 template <
typename T>
void hoc_register_parm_default(int type, const std::vector< double > *)
void(*)(Prop *, int, neuron::container::data_handle< double > *, neuron::container::data_handle< double > *, double *, int) nrn_ode_map_t
int nrn_dparam_semantics_to_int(const char *)
int _nrn_mechanism_get_nnode(Section *)
neuron::container::data_handle< double > _nrn_mechanism_get_param_handle(Prop *prop, neuron::container::field_index field)
int nrn_nlayer_extracellular
void(*)(Memb_list *, std::size_t, Datum *, Datum *, double *, NrnThread *, int, neuron::model_sorted_token const &) nrn_thread_table_check_t
NrnThread * _nrn_mechanism_get_thread(Node *)
std::vector< Memb_list > memb_list
std::vector< Memb_func > memb_func
void hoc_register_prop_size(int type, int psize, int dpsize)
Legacy way of registering mechanism data/pdata size.
double & _nrn_mechanism_access_rhs(Node *)
double & _nrn_mechanism_access_d(Node *)
int(* nrn_ode_count_t)(int)
void(* Pvmi)(struct NrnThread *, Memb_list *, int)
int _nrn_mechanism_get_type(Prop *)
Extnode *& _nrn_mechanism_access_extnode(Node *)
double & _nrn_mechanism_access_a(Node *)
std::unordered_map< int, NPyDirectMechFuncs > nrn_mech2funcs_map
long & _nrn_mechanism_access_alloc_seq(Prop *)
int * nrn_prop_param_size_
neuron::container::generic_data_handle *& _nrn_mechanism_access_dparam(Prop *)
void hoc_register_npy_direct(int type, NPyDirectMechFunc *)
Support mechanism FUNCTION/PROCEDURE python syntax seg.mech.f()
Node * _nrn_mechanism_get_node(Section *, int)
double & _nrn_mechanism_access_voltage(Node *)
int _nrn_mechanism_get_v_node_index(Node *)
double & _nrn_mechanism_access_param(Prop *, int field, int array_index=0)
std::vector< int > & nrn_mech_random_indices(int type)
dparam indices with random semantics for mechtype
Section * _nrn_mechanism_get_child(Section *)
int * nrn_prop_dparam_size_
double & _nrn_mechanism_access_b(Node *)
void(*)(neuron::model_sorted_token const &, NrnThread *, Memb_list *, int) nrn_cur_t
std::unordered_map< int, void(*)(Prop *)> nrn_mech_inst_destruct
neuron::container::data_handle< double > _nrn_mechanism_get_area_handle(Node *)
Section * _nrn_mechanism_get_sibling(Section *)
Node * _nrn_mechanism_access_node(Prop *prop)
nrn_cur_t nrn_ode_matsol_t
std::unordered_map< std::string, NPyDirectMechFunc * > NPyDirectMechFuncs
int _nrn_mechanism_get_num_vars(Prop *)
void(*)(Node *, Datum *, Datum *, NrnThread *, Memb_list *, std::size_t, neuron::model_sorted_token const &) nrn_bamech_t
void(*)(neuron::model_sorted_token const &, NrnThread &, Memb_list &, int) nrn_ode_synonym_t
void move(Item *q1, Item *q2, Item *q3)
std::vector< double *const * > const & _pdata_ptr_cache_data(neuron::model_sorted_token const &cache_token, int mech_type)
std::size_t _current_row(Prop *prop)
void register_data_fields(int mechtype, std::vector< std::pair< std::string, int >> const ¶m_info, std::vector< std::pair< std::string, std::string >> const &dparam_info)
static void register_data_fields(int mech_type, Fields const &... fields)
Type- and array-aware version of hoc_register_prop_size.
int const * get_array_dims(int mech_type)
Get the array dimensions for fields of the given type.
T *const * get_data_ptrs(int mech_type)
Pointer to a range of pointers to the start of contiguous storage ranges.
int get_field_count(int mech_type)
Get the number of fields (some of which may be arrays) of the given type.
HOC interpreter function declarations (included by hocdec.h)
nrn_ode_synonym_t ode_synonym
void(* setdata_)(struct Prop *)
const std::vector< double > * parm_default
void invoke_initialize(neuron::model_sorted_token const &sorted_token, NrnThread *nt, Memb_list *ml, int type) const
nrn_ode_count_t ode_count
bool has_initialize() const
void set_initialize(nrn_init_t init)
nrn_thread_table_check_t thread_table_check_
void(* thread_mem_init_)(Datum *)
void(* thread_cleanup_)(Datum *)
std::unique_ptr< int[]> dparam_semantics
nrn_ode_matsol_t ode_matsol
A view into a set of mechanism instances.
Represent main neuron object computed by single thread.
Struct used to index SoAoS data, such as array range variables.
Non-template stable handle to a generic value.
field(std::string name_, int array_size_)