diff --git a/src/dynamic_graph/entity.py b/src/dynamic_graph/entity.py index 57629e6f9d9538205fe312e4e68fb058280ccd83..42edb39df789d9983f0241b85df7944bab1452ca 100644 --- a/src/dynamic_graph/entity.py +++ b/src/dynamic_graph/entity.py @@ -12,13 +12,12 @@ class Entity (object) : object = None - def __init__(self, name): + def __init__(self, className, instanceName): """ Constructor: if not called by a child class, create and store a pointer to a C++ Entity object. """ - if not self.object : - self.object = wrap.create_entity(self, name) + self.object = wrap.create_entity(className, instanceName) @property def name(self) : diff --git a/src/entity-py.cc b/src/entity-py.cc index 7971b884efafd66221f7cdb3b74e713eaf271490..cae0da245d125c0b7ff868b1515ed2f4e6c64c27 100644 --- a/src/entity-py.cc +++ b/src/entity-py.cc @@ -9,6 +9,7 @@ //#include <string> #include <dynamic-graph/entity.h> +#include <dynamic-graph/factory.h> using dynamicgraph::Entity; using dynamicgraph::SignalBase; @@ -27,14 +28,16 @@ namespace dynamicgraph { */ PyObject* create(PyObject* self, PyObject* args) { - char *name = NULL; + char *className = NULL; + char *instanceName = NULL; - if (!PyArg_ParseTuple(args, "s", &name)) + if (!PyArg_ParseTuple(args, "ss", &className, &instanceName)) return NULL; Entity* obj = NULL; try { - obj = new Entity(name); + obj = dynamicgraph::g_factory.newEntity(std::string(className), + std::string(instanceName)); } catch (dynamicgraph::ExceptionFactory& exc) { PyErr_SetString(error, exc.getStringMessage().c_str()); return NULL;