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