Commit 4faf7044 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

Add a method getName in python class SignalBase

    * src/dynamic-graph-py.cc,
    * src/dynamic_graph/signal_base.py,
    * src/signal-base-py.cc.
parent b7485abe
......@@ -19,6 +19,7 @@ namespace dynamicgraph {
namespace signalBase {
extern PyObject* create(PyObject* self, PyObject* args);
extern PyObject* getTime(PyObject* self, PyObject* args);
extern PyObject* getName(PyObject* self, PyObject* args);
extern PyObject* getValue(PyObject* self, PyObject* args);
extern PyObject* setValue(PyObject* self, PyObject* args);
extern PyObject* recompute(PyObject* self, PyObject* args);
......@@ -133,6 +134,8 @@ static PyMethodDef dynamicGraphMethods[] = {
"create a SignalBase C++ object"},
{"signal_base_get_time", dynamicgraph::python::signalBase::getTime,
METH_VARARGS, "Get time of a SignalBase"},
{"signal_base_get_name", dynamicgraph::python::signalBase::getName,
METH_VARARGS, "Get the name of a signal"},
{"signal_base_get_value", dynamicgraph::python::signalBase::getValue,
METH_VARARGS, "Read the value of a signal"},
{"signal_base_set_value", dynamicgraph::python::signalBase::setValue,
......
......@@ -200,6 +200,12 @@ class SignalBase (object) :
string = objectToString(val)
return wrap.signal_base_set_value(self.obj, string)
def getName(self):
"""
Get name of signal
"""
return wrap.signal_base_get_name(self.obj)
def recompute(self, time):
"""
Force signal to recompute the value at given time.
......
......@@ -91,6 +91,33 @@ namespace dynamicgraph {
return Py_BuildValue("s", valueString.c_str());
}
PyObject* getName(PyObject* self, PyObject* args)
{
void* pointer = NULL;
PyObject* object = NULL;
if (!PyArg_ParseTuple(args,"O", &object))
return NULL;
if (!PyCObject_Check(object))
return NULL;
pointer = PyCObject_AsVoidPtr(object);
SignalBase<int>* signal = (SignalBase<int>*)pointer;
std::string name;
try {
name = signal->getName();
} catch (const dynamicgraph::ExceptionAbstract& exc) {
PyErr_SetString(error, exc.getStringMessage().c_str());
return NULL;
} catch (const std::exception& exc) {
PyErr_SetString(error, exc.what());
} catch (...) {
PyErr_SetString(error, "Unknown exception");
return NULL;
}
return Py_BuildValue("s", name.c_str());
}
PyObject* setValue(PyObject* self, PyObject* args)
{
void * pointer = NULL;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment