| 174 | typedef map<string, vector<int> > mapvectorint; |
| 175 | |
| 176 | PyObject* paramToPython(const Parameter& p) { |
| 177 | if (!p.isConfigured()) return NULL; |
| 178 | |
| 179 | Parameter::ParamType pType = p.type(); |
| 180 | |
| 181 | #define PARAM_CASE(e, t, fname) case Parameter::e: { t temp = p.to##fname(); return toPython(&temp, paramTypeToEdt(pType)); } |
| 182 | |
| 183 | |
| 184 | switch (pType) { |
| 185 | PARAM_CASE(REAL, Real, Real); |
| 186 | PARAM_CASE(STRING, string, String); |
| 187 | PARAM_CASE(INT, int, Int); |
| 188 | PARAM_CASE(BOOL, bool, Bool); |
| 189 | |
| 190 | PARAM_CASE(STEREOSAMPLE, StereoSample, StereoSample); |
| 191 | case Parameter::VECTOR_REAL: { |
| 192 | // we have to do the vectors in a special way since they need to not be deleted (i.e. toPython |
| 193 | // won't make a copy of them: toPythonRef) |
| 194 | vector<Real> v = p.toVectorReal(); |
| 195 | RogueVector<Real>* r = new RogueVector<Real>(v.size(), 0); |
| 196 | for (int i=0; i<int(v.size()); ++i) (*r)[i] = v[i]; |
| 197 | return toPython(r, paramTypeToEdt(pType)); |
| 198 | } |
| 199 | PARAM_CASE(VECTOR_STRING, vector<string>, VectorString); |
| 200 | PARAM_CASE(VECTOR_BOOL, vector<bool>, VectorBool); |
| 201 | case Parameter::VECTOR_INT: { |
| 202 | vector<int> v = p.toVectorInt(); |
| 203 | RogueVector<int>* r = new RogueVector<int>(v.size(), 0); |
| 204 | for (int i=0; i<int(v.size()); ++i) (*r)[i] = v[i]; |
| 205 | return toPython(r, paramTypeToEdt(pType)); |
| 206 | } |
| 207 | PARAM_CASE(VECTOR_STEREOSAMPLE, vector<StereoSample>, VectorStereoSample); |
| 208 | PARAM_CASE(VECTOR_VECTOR_REAL, vector<vector<Real> >, VectorVectorReal); |
| 209 | PARAM_CASE(VECTOR_VECTOR_STRING, vector<vector<string> >, VectorVectorString); |
| 210 | PARAM_CASE(VECTOR_VECTOR_STEREOSAMPLE, vector<vector<StereoSample> >, VectorVectorStereoSample); |
| 211 | PARAM_CASE(MATRIX_REAL, TNT::Array2D<Real>, MatrixReal); |
| 212 | PARAM_CASE(VECTOR_MATRIX_REAL, vector<TNT::Array2D<Real> >, VectorMatrixReal); |
| 213 | PARAM_CASE(MAP_VECTOR_REAL, mapvectorreal, MapVectorReal); |
| 214 | PARAM_CASE(MAP_VECTOR_STRING, mapvectorstring, MapVectorString); |
| 215 | PARAM_CASE(MAP_VECTOR_INT, mapvectorint, MapVectorInt); |
| 216 | PARAM_CASE(MAP_REAL, mapreal, MapReal); |
| 217 | |
| 218 | default: return NULL; |
| 219 | } |
| 220 | |
| 221 | #undef PARAM_CASE |
| 222 | } |
no test coverage detected