NEURON
cachevec.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 
3 // some functions needed by CACHEVEC. mostly to steer to the various update_ptrs
4 // methods.
5 
6 #if HAVE_IV
7 #include <shapeplt.h>
8 #include <graph.h>
9 #include <ivoc.h>
10 #include <xmenu.h>
11 #endif
12 
13 #include <ocnotify.h>
14 #include <mymath.h>
15 #include <nrnoc2iv.h>
16 #include <parse.hpp>
17 #include <cvodeobj.h>
18 #include <netcvode.h>
19 #include <hoclist.h>
20 #include <ocpointer.h>
21 #include <ocptrvector.h>
22 
23 void nrniv_recalc_ptrs();
24 extern "C" double* nrn_recalc_ptr(double*);
26 
27 extern void nrn_linmod_update_ptrs(void*);
28 
29 static Symbol* grsym_;
30 static Symbol* ptrsym_;
31 static Symbol* lmsym_;
32 static Symbol* pshpsym_;
34 
36  // PlayRecord and PreSyn pointers
37  net_cvode_instance->recalc_ptrs();
38  hoc_List* hl;
39  hoc_Item* q;
40 #if HAVE_IV
41  // update pointers used by Graph
42  if (!grsym_) {
43  grsym_ = hoc_lookup("Graph");
44  assert(grsym_->type == TEMPLATE);
45  }
46  hl = grsym_->u.ctemplate->olist;
47  ITERATE(q, hl) {
48  Object* obj = OBJ(q);
49  Graph* g = (Graph*)obj->u.this_pointer;
50  if (g) {g->update_ptrs();}
51  }
52  // update pointers used by PlotShape
53  if (!pshpsym_) {
54  pshpsym_ = hoc_lookup("PlotShape");
55  assert(pshpsym_->type == TEMPLATE);
56  }
57  hl = pshpsym_->u.ctemplate->olist;
58  ITERATE(q, hl) {
59  Object* obj = OBJ(q);
60  ShapePlot* ps = (ShapePlot*)obj->u.this_pointer;
61  if (ps) {ps->update_ptrs();}
62  }
63  // update pointers used by xpanel
64  HocPanel::update_ptrs();
65 #endif
66  // update pointers used by Pointer
67  if (!ptrsym_) {
68  ptrsym_ = hoc_lookup("Pointer");
69  assert(ptrsym_->type == TEMPLATE);
70  }
71  hl = ptrsym_->u.ctemplate->olist;
72  ITERATE(q, hl) {
73  Object* obj = OBJ(q);
74  OcPointer* op = (OcPointer*)obj->u.this_pointer;
75  if (op && op->p_) {
76  double* pd = nrn_recalc_ptr(op->p_);
77  if (op->p_ != pd ) {
79  op->p_ = pd;
80  op->valid_ = true;
82  }
83  }
84  }
85  // update what LinearMechanisms are observing
86  if (!lmsym_) {
87  lmsym_ = hoc_lookup("LinearMechanism");
88  assert(lmsym_->type == TEMPLATE);
89  }
90  hl = lmsym_->u.ctemplate->olist;
91  ITERATE(q, hl) {
92  Object* obj = OBJ(q);
93  void* pt = (void*)obj->u.this_pointer;
94  if (pt) {nrn_linmod_update_ptrs(pt);}
95  }
96 }
97 
99  // update pointers used by PtrVector
100  hoc_List* hl;
101  hoc_Item* q;
102  if (!ptrvecsym_) {
103  ptrvecsym_ = hoc_lookup("PtrVector");
104  assert(ptrvecsym_->type == TEMPLATE);
105  }
106  hl = ptrvecsym_->u.ctemplate->olist;
107  ITERATE(q, hl) {
108  Object* obj = OBJ(q);
109  OcPtrVector* op = (OcPtrVector*)obj->u.this_pointer;
110  op->ptr_update();
111  }
112 }
NetCvode * net_cvode_instance
Definition: cvodestb.cpp:27
#define assert(ex)
Definition: hocassrt.h:26
if(status)
short type
Definition: model.h:58
#define ITERATE(itm, lst)
Definition: model.h:25
#define g
Definition: passive0.cpp:23
Symbol * hoc_lookup(const char *)
double * p_
Definition: ocpointer.h:15
void * this_pointer
Definition: hocdec.h:231
void nrn_linmod_update_ptrs(void *)
Definition: linmod1.cpp:47
static Symbol * ptrsym_
Definition: cachevec.cpp:30
hoc_List * olist
Definition: hocdec.h:203
void nrniv_recalc_ptrs()
Definition: cachevec.cpp:35
Definition: graph.h:48
void update_ptrs()
static Symbol * lmsym_
Definition: cachevec.cpp:31
void nrn_recalc_ptrvector()
Definition: cachevec.cpp:98
Definition: model.h:57
void ptr_update()
Definition: ocptrvector.cpp:65
static Symbol * pshpsym_
Definition: cachevec.cpp:32
#define OBJ(q)
Definition: hoclist.h:67
void nrn_notify_when_double_freed(double *p, Observer *ob)
Definition: ivoc.cpp:63
Definition: hocdec.h:226
HocStruct cTemplate * ctemplate
Definition: hocdec.h:151
void nrn_notify_pointer_disconnect(Observer *ob)
Definition: ivoc.cpp:72
static Symbol * grsym_
Definition: cachevec.cpp:29
void recalc_ptrs()
Definition: netcvode.cpp:6558
union Symbol::@18 u
double * nrn_recalc_ptr(double *)
Definition: treeset.cpp:2158
union Object::@54 u
size_t q
static Symbol * ptrvecsym_
Definition: cachevec.cpp:33
bool valid_
Definition: ocpointer.h:18