NEURON
classreg.cpp
Go to the documentation of this file.
1
#include <../../nrnconf.h>
2
// interface c++ class to oc
3
#if defined(__GO32__)
4
#define HAVE_IV 0
5
#define OC_CLASSES "nrnclass.h"
6
#endif
7
8
#include <
InterViews/resource.h
>
9
#include <stdio.h>
10
#include <nrnpython_config.h>
11
#include "
classreg.h
"
12
#ifndef OC_CLASSES
13
#define OC_CLASSES "occlass.h"
14
#endif
15
16
#define EXTERNS 1
17
extern
void
18
#include OC_CLASSES
19
;
20
21
#undef EXTERNS
22
static
void
(*
register_classes
[])() = {
23
#include OC_CLASSES
24
,
25
0};
26
27
void
hoc_class_registration
(
void
) {
28
for
(
int
i
= 0;
register_classes
[
i
];
i
++) {
29
(*
register_classes
[
i
])();
30
}
31
}
32
33
/*-----------------------------------------------------*/
34
#if 0
35
//example
36
37
//the class
38
39
/*static*/
class
A
{
40
public
:
41
A
();
42
~
A
();
43
void
f1(
char
* s);
44
double
f2(
double
x);
45
private
:
46
double
x_
;
47
};
48
49
A::A
() {
printf
(
"A::A\n"
);
x_
=1; }
50
A::~A() {
printf
(
"A::~A\n"
); }
51
void
A::f1(
char
* s) {
printf
(
"A::f1(\"%s\")\n"
, s);}
52
double
A::f2(
double
x) {
double
a =
x_
;
x_
=x;
return
a; }
53
54
//the interface
55
56
static
void
* A_constructor(
Object
*) {
57
printf
(
"A::constructor\n"
);
58
return
(
void
*)
new
A
;
59
}
60
61
static
void
A_destructor(
void
*
v
) {
62
delete
(
A
*)
v
;
63
}
64
65
static
double
A_f1(
void
*
v
) {
66
((
A
*)
v
)->f1(
gargstr
(1));
67
return
(0.);
68
}
69
70
static
double
A_f2(
void
*
v
) {
71
double
x = ((
A
*)
v
)->f2(*
getarg
(1));
72
return
(x);
73
}
74
75
// class registration to oc
76
77
static
Member_func
A_member_func[] = {
78
"f1"
, A_f1,
79
"f2"
, A_f2,
80
0, 0
81
};
82
83
void
A_reg() {
84
class2oc
(
"A"
, A_constructor, A_destructor, A_member_func);
85
}
86
87
#endif
classreg.h
hoc_class_registration
void hoc_class_registration(void)
Definition:
classreg.cpp:27
getarg
#define getarg
Definition:
hocdec.h:15
gargstr
#define gargstr
Definition:
hocdec.h:14
void
void
register_classes
static void(* register_classes[])()
Definition:
classreg.cpp:22
v
#define v
Definition:
md1redef.h:4
i
#define i
Definition:
md1redef.h:12
A
#define A(i)
Definition:
multisplit.cpp:63
printf
#define printf
Definition:
mwprefix.h:26
class2oc
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
Definition:
hoc_oop.cpp:1560
x_
static N_Vector x_
Definition:
nvector_nrnthread.cpp:54
resource.h
Member_func
Definition:
hoc_membf.h:6
Object
Definition:
hocdec.h:227
src
ivoc
classreg.cpp