From 2caff345c56ada8b5aee232955d149151f43411f Mon Sep 17 00:00:00 2001
From: florent <florent@laas.fr>
Date: Sun, 24 Oct 2010 21:20:39 +0200
Subject: [PATCH] Implement a function that creates a python class for for each
 entity C++ class

	  * src/dynamic_graph/entity.py.
---
 src/dynamic_graph/entity.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/dynamic_graph/entity.py b/src/dynamic_graph/entity.py
index 42edb39..f3e7e12 100644
--- a/src/dynamic_graph/entity.py
+++ b/src/dynamic_graph/entity.py
@@ -5,6 +5,32 @@
 """
 import wrap, signal_base
 
+entityList = []
+
+def initEntity(self, name):
+    """
+    Common constructor of Entity classes
+    """
+    Entity.__init__(self, self.class_name, name)
+
+def updateEntityClasses():
+    entityTypeList = wrap.factory_get_entity_class_list()
+    for e in entityTypeList:
+        class metacls(type):
+            def __new__(mcs, name, bases, dict):
+                return type.__new__(mcs, name, bases, dict)
+
+        # Create new class
+        a = metacls(e, (Entity,), {})
+        # Store class name in class member
+        a.class_name = e
+        print ("new class %s"%e)
+        # set class constructor
+        setattr(a, '__init__', initEntity)
+        # Store new class in dictionary with class name
+        globals()[e] = a
+
+
 class Entity (object) :
     """
     This class binds dynamicgraph::Entity C++ class
-- 
GitLab