diff --git a/eo/src/pyeo/PyEO/__init__.py b/eo/src/pyeo/PyEO/__init__.py index 4e5e7d0e..cc679542 100644 --- a/eo/src/pyeo/PyEO/__init__.py +++ b/eo/src/pyeo/PyEO/__init__.py @@ -62,15 +62,15 @@ def SeperatedVolumeMonitor(eoMonitor): def __call__(self): pass -class eoStat(eoStatBase, eoValueParamPy): +class eoStat(eoStatBase, eoValueParam): def __init__(self): eoStatBase.__init__(self) - eoValueParamPy.__init__(self) + eoValueParam.__init__(self) -class eoSortedStat(eoSortedStatBase, eoValueParamPy): +class eoSortedStat(eoSortedStatBase, eoValueParam): def __init__(self): eoSortedStatBase.__init__(self) - eoValueParamPy.__init__(self) + eoValueParam.__init__(self) class eoAverageStat(eoStat): def __call__(self, pop): diff --git a/eo/src/pyeo/valueParam.cpp b/eo/src/pyeo/valueParam.cpp index a9f5f310..ce8e4f80 100644 --- a/eo/src/pyeo/valueParam.cpp +++ b/eo/src/pyeo/valueParam.cpp @@ -52,6 +52,21 @@ public: }; +template +struct ValueParam_pickle_suite : boost::python::pickle_suite +{ + static + boost::python::tuple getstate(const eoValueParam& _param) + { + return make_tuple(boost::python::str(_param.getValue())); + } + static + void setstate(eoValueParam& _param, boost::python::tuple pickled) + { + std::string s = extract(pickled[0]); + _param.setValue(s); + } +}; template U getv(const eoValueParam& v) { return v.value(); } @@ -127,7 +142,8 @@ void define_valueParam(std::string prefix) .def("setValueAsString", &eoValueParam::setValue) .def("getValue", getv) .def("setValue", setv) - //.add_property("value", getv, setv) + .add_property("value", getv, setv) + .def_pickle(ValueParam_pickle_suite()) ; } @@ -149,11 +165,11 @@ void valueParam() define_valueParam, numeric::array >("Vec"); define_valueParam< std::pair, tuple >("Pair"); - class_ >("eoValueParamPy", init<>()) + class_ >("eoValueParam", init<>()) //.def(init()) //.def(init()) //.def(init()) - //.def(init()) + .def(init()) .def("getValueAsString", &ValueParam::getValue) .def("__str__", &ValueParam::getValue) .def("setValueAsString", &ValueParam::setValue)