Commit 73796538 authored by florent's avatar florent
Browse files

Use factory to create entities.

    * src/dynamic_graph/entity.py,
    * src/entity-py.cc: the name of the entity class to be created is now given
      as input to the constructor of Entity python class.
parent 9a3f57de
......@@ -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) :
......
......@@ -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;
......
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