Added monitors and statistics, also made a module with some
specific python stuff in __init__.py
This commit is contained in:
parent
d953d25f08
commit
ea2e369542
19 changed files with 503 additions and 47 deletions
|
|
@ -18,11 +18,53 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <utils/eoParam.h>
|
||||
#include <utils/eoMonitor.h>
|
||||
#include "PyEO.h"
|
||||
|
||||
class MonitorWrapper : public eoMonitor
|
||||
{
|
||||
public:
|
||||
PyObject* self;
|
||||
list objects;
|
||||
|
||||
MonitorWrapper(PyObject* p) :self(p) {}
|
||||
|
||||
eoMonitor& operator()()
|
||||
{
|
||||
call_method<void>(self, "__call__");
|
||||
return *this;
|
||||
}
|
||||
|
||||
std::string getString(int i)
|
||||
{
|
||||
if (static_cast<unsigned>(i) >= vec.size())
|
||||
{
|
||||
throw index_error("Index out of bounds");
|
||||
}
|
||||
|
||||
return vec[i]->getValue();
|
||||
}
|
||||
|
||||
unsigned size() { return vec.size(); }
|
||||
};
|
||||
|
||||
void monitors()
|
||||
{
|
||||
|
||||
/**
|
||||
* Change of interface: I encountered some difficulties with
|
||||
* transferring eoParams from and to Python, so now we can
|
||||
* only get at the strings contained in the eoParams.
|
||||
* sorry
|
||||
*/
|
||||
|
||||
class_<eoMonitor, MonitorWrapper, boost::noncopyable>("eoMonitor", init<>())
|
||||
.def("lastCall", &eoMonitor::lastCall)
|
||||
.def("add", &eoMonitor::add)
|
||||
.def("__call__", &MonitorWrapper::operator(), return_internal_reference<1>() )
|
||||
.def("__getitem__", &MonitorWrapper::getString,
|
||||
"Returns the string value of the indexed Parameter")
|
||||
.def("__len__", &MonitorWrapper::size)
|
||||
;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue