1 | #include "dispersion_visitor.hh" |
---|
2 | #include "parameters.hh" |
---|
3 | |
---|
4 | #ifndef __MODELS_STANDALONE__ |
---|
5 | extern "C" { |
---|
6 | #include <Python.h> |
---|
7 | } |
---|
8 | #endif |
---|
9 | |
---|
10 | void DispersionVisitor:: dispersion_to_dict(void* dispersion, void* dictionary) { |
---|
11 | #ifndef __MODELS_STANDALONE__ |
---|
12 | DispersionModel * disp = (DispersionModel*)dispersion; |
---|
13 | PyObject * dict = (PyObject*)dictionary; |
---|
14 | |
---|
15 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "flat")); |
---|
16 | PyDict_SetItemString(dict, "npts", Py_BuildValue("i", disp->npts)); |
---|
17 | PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width)); |
---|
18 | #endif |
---|
19 | } |
---|
20 | |
---|
21 | void DispersionVisitor:: gaussian_to_dict(void* dispersion, void* dictionary) { |
---|
22 | #ifndef __MODELS_STANDALONE__ |
---|
23 | GaussianDispersion * disp = (GaussianDispersion*)dispersion; |
---|
24 | PyObject * dict = (PyObject*)dictionary; |
---|
25 | |
---|
26 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "gaussian")); |
---|
27 | PyDict_SetItemString(dict, "npts", Py_BuildValue("i", disp->npts)); |
---|
28 | PyDict_SetItemString(dict, "width", Py_BuildValue("d", disp->width)); |
---|
29 | PyDict_SetItemString(dict, "nsigmas", Py_BuildValue("i", disp->nsigmas)); |
---|
30 | #endif |
---|
31 | } |
---|
32 | |
---|
33 | void DispersionVisitor:: array_to_dict(void* dispersion, void* dictionary) { |
---|
34 | #ifndef __MODELS_STANDALONE__ |
---|
35 | ArrayDispersion * disp = (ArrayDispersion*)dispersion; |
---|
36 | PyObject * dict = (PyObject*)dictionary; |
---|
37 | |
---|
38 | PyDict_SetItemString(dict, "type", Py_BuildValue("s", "array")); |
---|
39 | #endif |
---|
40 | } |
---|
41 | |
---|
42 | void DispersionVisitor:: dispersion_from_dict(void* dispersion, void* dictionary) { |
---|
43 | #ifndef __MODELS_STANDALONE__ |
---|
44 | DispersionModel * disp = (DispersionModel*)dispersion; |
---|
45 | PyObject * dict = (PyObject*)dictionary; |
---|
46 | |
---|
47 | disp->npts = PyInt_AsLong( PyDict_GetItemString(dict, "npts") ); |
---|
48 | disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") ); |
---|
49 | #endif |
---|
50 | } |
---|
51 | |
---|
52 | void DispersionVisitor:: gaussian_from_dict(void* dispersion, void* dictionary) { |
---|
53 | #ifndef __MODELS_STANDALONE__ |
---|
54 | GaussianDispersion * disp = (GaussianDispersion*)dispersion; |
---|
55 | PyObject * dict = (PyObject*)dictionary; |
---|
56 | |
---|
57 | disp->npts = PyInt_AsLong( PyDict_GetItemString(dict, "npts") ); |
---|
58 | disp->width = PyFloat_AsDouble( PyDict_GetItemString(dict, "width") ); |
---|
59 | disp->nsigmas = PyFloat_AsDouble( PyDict_GetItemString(dict, "nsigmas") ); |
---|
60 | #endif |
---|
61 | } |
---|
62 | |
---|
63 | void DispersionVisitor:: array_from_dict(void* dispersion, void* dictionary) {} |
---|