Salome HOME
merge from branch DEV tag mergeto_trunk_04apr08
[modules/yacs.git] / src / engine / ComponentInstance.cxx
index 374c0cb3768b9555ab1d7960f85b1dd3a35bff3e..9e5d4925f00df3184ba82860b3ea8fbbde998448 100644 (file)
@@ -2,6 +2,7 @@
 #include "Container.hxx"
 
 #include <iostream>
+#include <sstream>
 
 //#define _DEVDEBUG_
 #include "YacsTrace.hxx"
@@ -10,6 +11,8 @@ using namespace YACS::ENGINE;
 using namespace std;
 
 const char ComponentInstance::KIND[]="";
+int ComponentInstance::_total = 0;
+
 
 const char ComponentInstance::NULL_FILE_REPR[]="No repr specified for ComponentInstance";
 
@@ -26,14 +29,22 @@ void ComponentInstance::setContainer(Container *cont)
     _container->incrRef();
 }
 
-ComponentInstance::ComponentInstance(const std::string& name):_name(name),_isAttachedOnCloning(false),_container(0)
+ComponentInstance::ComponentInstance(const std::string& name):_compoName(name),_isAttachedOnCloning(false),_container(0)
 {
+  _numId = _total++;
+  stringstream instName;
+  instName << _compoName << "_" << _numId;
+  _instanceName = instName.str();
 }
 
-ComponentInstance::ComponentInstance(const ComponentInstance& other):_name(other._name),
+ComponentInstance::ComponentInstance(const ComponentInstance& other):_compoName(other._compoName),
                                                                      _container(0),
                                                                      _isAttachedOnCloning(other._isAttachedOnCloning)
 {
+  _numId = _total++;
+  stringstream instName;
+  instName << _compoName << "_" << _numId;
+  _instanceName = instName.str();
   if(other._container)
     _container=other._container->clone();
 }