00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <utils/eoParam.h>
00022 #include <utils/eoMonitor.h>
00023 #include "PyEO.h"
00024
00025 using namespace boost::python;
00026
00027 class MonitorWrapper : public eoMonitor
00028 {
00029 public:
00030 PyObject* self;
00031 list objects;
00032
00033 MonitorWrapper(PyObject* p) :self(p) {}
00034
00035 eoMonitor& operator()()
00036 {
00037 call_method<void>(self, "__call__");
00038 return *this;
00039 }
00040
00041 std::string getString(int i)
00042 {
00043 if (static_cast<unsigned>(i) >= vec.size())
00044 {
00045 throw index_error("Index out of bounds");
00046 }
00047
00048 return vec[i]->getValue();
00049 }
00050
00051 unsigned size() { return vec.size(); }
00052 };
00053
00054 void monitors()
00055 {
00063 class_<eoMonitor, MonitorWrapper, boost::noncopyable>("eoMonitor", init<>())
00064 .def("lastCall", &eoMonitor::lastCall)
00065 .def("add", &eoMonitor::add)
00066 .def("__call__", &MonitorWrapper::operator(), return_internal_reference<1>() )
00067 .def("__getitem__", &MonitorWrapper::getString,
00068 "Returns the string value of the indexed Parameter")
00069 .def("__len__", &MonitorWrapper::size)
00070 ;
00071 }
00072