Commit 82d05f50 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Guilhem Saurel

Add entity_get_class_name

parent 67cbba71
......@@ -48,6 +48,7 @@ namespace dynamicgraph {
extern PyObject* display(PyObject* self, PyObject* args);
extern PyObject* display(PyObject* self, PyObject* args);
extern PyObject* getName(PyObject* self, PyObject* args);
extern PyObject* getClassName(PyObject* self, PyObject* args);
extern PyObject* hasSignal(PyObject* self, PyObject* args);
extern PyObject* getSignal(PyObject* self, PyObject* args);
extern PyObject* listSignals(PyObject* self, PyObject* args);
......@@ -181,6 +182,8 @@ static PyMethodDef dynamicGraphMethods[] = {
"print an Entity C++ object"},
{"entity_get_name", dynamicgraph::python::entity::getName, METH_VARARGS,
"get the name of an Entity"},
{"entity_get_class_name", dynamicgraph::python::entity::getClassName, METH_VARARGS,
"get the class name of an Entity"},
{"entity_has_signal", dynamicgraph::python::entity::hasSignal, METH_VARARGS,
"return True if the entity has a signal with the given name"},
{"entity_get_signal", dynamicgraph::python::entity::getSignal, METH_VARARGS,
......
......@@ -113,6 +113,32 @@ namespace dynamicgraph {
return Py_BuildValue("s", name.c_str());
}
/**
\brief Get class name of entity
*/
PyObject* getClassName(PyObject* /*self*/, PyObject* args)
{
PyObject* object = NULL;
void* pointer = NULL;
std::string name;
if (!PyArg_ParseTuple(args, "O", &object))
return NULL;
if (!PyCObject_Check(object)) {
PyErr_SetString(PyExc_TypeError,
"function takes a PyCObject as argument");
return NULL;
}
pointer = PyCObject_AsVoidPtr(object);
Entity* entity = (Entity*)pointer;
try {
name = entity->getClassName();
} CATCH_ALL_EXCEPTIONS();
return Py_BuildValue("s", name.c_str());
}
/**
\brief Check if the entity has a signal with the given name
*/
......
Markdown is supported
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