1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "registry.h"
extern "C"{
#include <ascend/compiler/importhandler.h>
}
#include <stdexcept>
/*void
Registry::setInteger(const char *key, intptr_t val){
importhandler_setsharedpointer(key,(void *)val);
}*/
void
Registry::setPointer(const char *key, void *val){
importhandler_setsharedpointer(key,val);
}
Instanc *
Registry::getInstance(const char *key){
return new Instanc((struct Instance*)importhandler_getsharedpointer(key));
}
Simulation &
Registry::getSimulation(const char *key){
// how dangerous is this!
Simulation *s = (Simulation *)importhandler_getsharedpointer(key);
if(s==NULL){
throw std::runtime_error("Simulation pointer was NULL");
}
CONSOLE_DEBUG("Simulation 'sim' = %p",s);
return (Simulation &)(*s);
}
#ifdef ASCXX_USE_PYTHON
void
Registry::setPyObject(const char *key, PyObject *val){
importhandler_setsharedpointer(key,(void *)val);
}
#endif
|