Salome HOME
Copyrights update
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_SObject_i.cxx
index f9c00984eded0c70bf0307679b2198716a5a5cd2..1a8a25c919d1cda6c2f7b66ed7697602d9803a6c 100644 (file)
-//  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
+// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 // 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either 
+// version 2.1 of the License.
 // 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// This library is distributed in the hope that it will be useful 
+// but WITHOUT ANY WARRANTY; without even the implied warranty of 
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public  
+// License along with this library; if not, write to the Free Software 
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/
 //
 //  File   : SALOMEDS_SObject_i.cxx
-//  Author : Yves FRICAUD
+//  Author : Sergey RUIN
 //  Module : SALOME
-//  $Header$
 
-using namespace std;
+
+
 #include "utilities.h"
 #include "SALOMEDS_SObject_i.hxx"
-//SALOMEDS Headers
 #include "SALOMEDS_SComponent_i.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_SequenceOfRealAttribute.hxx"
-#include "SALOMEDS_SequenceOfIntegerAttribute.hxx"
-#include "SALOMEDS_TableOfRealAttribute.hxx"
-#include "SALOMEDS_TableOfIntegerAttribute.hxx"
-#include "SALOMEDS_IORAttribute.hxx"
-#include "SALOMEDS_PersRefAttribute.hxx"
-#include "SALOMEDS_StudyPropertiesAttribute.hxx"
-#include "SALOMEDS_PythonObjectAttribute.hxx"
-#include "SALOMEDS_AttributePersistentRef_i.hxx"
-#include "SALOMEDS_AttributeIOR_i.hxx"
-#include "SALOMEDS_AttributeComment_i.hxx"
-#include "SALOMEDS_AttributeName_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
-#include "SALOMEDS_AttributeInteger_i.hxx"
-#include "SALOMEDS_AttributeReal_i.hxx"
-#include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_AttributeTreeNode_i.hxx"
-#include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_AttributeUserID_i.hxx"
-#include "SALOMEDS_AttributeTarget_i.hxx"
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_AttributeTableOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
-#include "SALOMEDS_AttributePythonObject_i.hxx"
-#include <TDF_AttributeIterator.hxx>
-
-//============================================================================
-/*! Function : ReturnGUIDForAttribute
- *  Purpose  : 
- */
-//============================================================================
+#include "SALOMEDS_GenericAttribute_i.hxx"
+#include "SALOMEDS_StudyManager_i.hxx"
+#include "SALOMEDS.hxx"
+#include "SALOMEDSImpl_GenericAttribute.hxx"
+#include "SALOMEDSImpl_SComponent.hxx"
+#include "SALOMEDSImpl_Study.hxx"
+#include "SALOMEDSImpl_AttributeIOR.hxx"
 
-Standard_GUID  
-SALOMEDS_SObject_i::ReturnGUIDForAttribute(const char* aTypeOfAttribute)
-{
-   Standard_GUID TypeID;
-  
-   if      (strcmp(aTypeOfAttribute, "AttributeReal") == 0 )               return TDataStd_Real::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 )            return TDataStd_Integer::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 )     return SALOMEDS_SequenceOfRealAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 )  return SALOMEDS_SequenceOfIntegerAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 )               return TDataStd_Name::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 )            return TDataStd_Comment::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 )                return SALOMEDS_IORAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 )      return SALOMEDS_PersRefAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 )           return SALOMEDS_DrawableAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 )         return SALOMEDS_SelectableAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 )         return SALOMEDS_ExpandableAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 )             return SALOMEDS_OpenedAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 )          return SALOMEDS_TextColorAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 ) return SALOMEDS_TextHighlightColorAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 )             return SALOMEDS_PixMapAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTreeNode") == 0 )           return TDataStd_TreeNode::GetDefaultTreeID();
-   else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 )            return SALOMEDS_LocalIDAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 )             return SALOMEDS_TargetAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 )     return SALOMEDS_TableOfIntegerAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 )        return SALOMEDS_TableOfRealAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 )      return SALOMEDS_TableOfStringAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 )    return SALOMEDS_StudyPropertiesAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 )       return SALOMEDS_PythonObjectAttribute::GetID();
-   else if (strcmp(aTypeOfAttribute, "AttributeUserID") == 0 )             return SALOMEDS_AttributeUserID_i::DefaultID();
-   else if (strncmp(aTypeOfAttribute,"AttributeTreeNodeGUID",21) == 0) {
-     char* aGUIDString = new char[40];
-     sprintf(aGUIDString, &(aTypeOfAttribute[21]));
-     Standard_GUID aGUID = Standard_GUID(aGUIDString); // create tree node GUID by name
-     delete(aGUIDString);
-     return aGUID;
-   }
-   else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::ReturnGUIDForAttribute");
-}
+// OCC Headers
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+#include <map>
 
-//============================================================================
-/*! Function : AttributeIDToType
- *  Purpose  : 
- */
-//============================================================================
-char* SALOMEDS_SObject_i::AttributeIDToType(Standard_GUID ID)
+#ifdef WIN32
+#include <process.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
+#include "OpUtil.hxx"
+
+using namespace std;
+
+SALOMEDS::SObject_ptr SALOMEDS_SObject_i::New(const Handle(SALOMEDSImpl_SObject)& theImpl, CORBA::ORB_ptr theORB)
 {
-  if      (ID == TDataStd_Name::GetID())                        return "AttributeName";
-  else if (ID == TDataStd_Comment::GetID())                     return "AttributeComment";
-  else if (ID == SALOMEDS_IORAttribute::GetID())                return "AttributeIOR"; 
-  else if (ID == SALOMEDS_PersRefAttribute::GetID())            return "AttributePersistentRef";
-  else if (ID == TDataStd_Real::GetID())                        return "AttributeReal";
-  else if (ID == TDataStd_Integer::GetID())                     return "AttributeInteger";
-  else if (ID == SALOMEDS_SequenceOfRealAttribute::GetID())     return "AttributeSequenceOfReal";
-  else if (ID == SALOMEDS_SequenceOfIntegerAttribute::GetID())  return "AttributeSequenceOfInteger";
-  else if (ID == SALOMEDS_DrawableAttribute::GetID())           return "AttributeDrawable";
-  else if (ID == SALOMEDS_SelectableAttribute::GetID())         return "AttributeSelectable";
-  else if (ID == SALOMEDS_ExpandableAttribute::GetID())         return "AttributeExpandable";
-  else if (ID == SALOMEDS_OpenedAttribute::GetID())             return "AttributeOpened";
-  else if (ID == SALOMEDS_TextColorAttribute::GetID())          return "AttributeTextColor";
-  else if (ID == SALOMEDS_TextHighlightColorAttribute::GetID()) return "AttributeTextHighlightColor";
-  else if (ID == SALOMEDS_PixMapAttribute::GetID())             return "AttributePixMap";
-  else if (ID == TDataStd_TreeNode::GetDefaultTreeID())         return "AttributeTreeNode";
-  else if (ID == SALOMEDS_LocalIDAttribute::GetID())            return "AttributeLocalID";
-  else if (ID == SALOMEDS_TargetAttribute::GetID())             return "AttributeTarget";
-  else if (ID == SALOMEDS_TableOfIntegerAttribute::GetID())     return "AttributeTableOfInteger";
-  else if (ID == SALOMEDS_TableOfRealAttribute::GetID())        return "AttributeTableOfReal";
-  else if (ID == SALOMEDS_TableOfStringAttribute::GetID())      return "AttributeTableOfString";
-  else if (ID == SALOMEDS_StudyPropertiesAttribute::GetID())    return "AttributeStudyProperties";
-  else if (ID == SALOMEDS_PythonObjectAttribute::GetID())       return "AttributePythonObject";
-  else if (ID == SALOMEDS_AttributeUserID_i::DefaultID())       return "AttributeUserID";
-  // 08.01.2003 mpv: this method must be called only for attributes with constant GUID
-  else Standard_NoSuchObject::Raise("SALOMEDS_SObject_i::AttributeIDToType");
+  SALOMEDS_SObject_i* so_servant = new SALOMEDS_SObject_i(theImpl, theORB);
+  SALOMEDS::SObject_var so  = SALOMEDS::SObject::_narrow(so_servant->_this());
+
+  return so._retn();
 }
 
 
 //============================================================================
 /*! Function : constructor
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
-SALOMEDS_SObject_i::SALOMEDS_SObject_i(const TDF_Label lab, CORBA::ORB_ptr orb)
-  :_lab(lab)
+SALOMEDS_SObject_i::SALOMEDS_SObject_i(const Handle(SALOMEDSImpl_SObject)& impl, CORBA::ORB_ptr orb)
+  : _impl(impl)
 {
   _orb = CORBA::ORB::_duplicate(orb);
-  _value = NULL;
-  _type = NULL;
-  _name = NULL;
-  _liste_ba_type.resize(0);
+   //SALOME::GenericObj_i::myPOA = SALOMEDS_StudyManager_i::GetPOA(GetStudy());
 }
-  
+
 
 //============================================================================
 /*! Function : destructor
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDS_SObject_i::~SALOMEDS_SObject_i()
-{
-  CORBA::string_free(_value);
-  CORBA::string_free(_type);
-  CORBA::string_free(_name);
-}
-  
-  
+{}
+
+
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function :GetID
+ *  Purpose  :
  */
 //============================================================================
 char* SALOMEDS_SObject_i::GetID()
 {
-  TCollection_AsciiString anEntry;
-  TDF_Tool::Entry (_lab,anEntry);
-  return CORBA::string_dup(anEntry.ToCString());
+  SALOMEDS::Locker lock;
+  return CORBA::string_dup(_impl->GetID().ToCString());
 }
-  
+
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function : GetFatherComponent
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDS::SComponent_ptr SALOMEDS_SObject_i::GetFatherComponent()
 {
-  TDF_Label LF = _lab;
-  while (!SALOMEDS_SComponent_i::IsA(LF) && !LF.IsRoot()) {
-    LF = LF.Father();
-  }
-  SALOMEDS_SComponent_i *  so_servant = new SALOMEDS_SComponent_i (LF,_orb);
-  SALOMEDS::SComponent_var so;
-  so= SALOMEDS::SComponent::_narrow(so_servant->SComponent::_this()); 
-  return so;
+  SALOMEDS::Locker lock;
+  SALOMEDS::SComponent_var sco = SALOMEDS_SComponent_i::New (_impl->GetFatherComponent(), _orb);
+  return sco._retn();
 }
-  
+
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function : GetFather
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDS::SObject_ptr SALOMEDS_SObject_i::GetFather()
 {
-  TDF_Label LF = _lab.Father();
-
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (LF,_orb);
-  SALOMEDS::SObject_var so = SALOMEDS::SObject::_narrow(so_servant->_this()); 
-  return so;
+  SALOMEDS::Locker lock;
+  SALOMEDS::SObject_var so = SALOMEDS_SObject_i::New (_impl->GetFather(), _orb);
+  return so._retn();
 }
 
 //============================================================================
 /*! Function :
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
 SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy()
 {
-  TDF_Label Root = _lab.Root();
-  Handle(SALOMEDS_IORAttribute) Att;
-  char* IOR;
-  if (Root.FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){
-    TCollection_AsciiString ch(Att->Get());
-    IOR = CORBA::string_dup(ch.ToCString());
-    CORBA::Object_var obj = _orb->string_to_object(IOR);
-    SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(obj) ;
-    ASSERT(!CORBA::is_nil(Study));
-    return SALOMEDS::Study::_duplicate(Study); //return Study = abort...
+  SALOMEDS::Locker lock;
+  Handle(SALOMEDSImpl_Study) aStudy = _impl->GetStudy();
+  if(aStudy.IsNull()) {
+    MESSAGE("Problem GetStudy");
+    return SALOMEDS::Study::_nil();
   }
-  INFOS("Problem GetStudy");
-  return SALOMEDS::Study::_nil();
+
+  TCollection_AsciiString IOR = aStudy->GetTransientReference();
+  CORBA::Object_var obj = _orb->string_to_object(IOR.ToCString());
+  SALOMEDS::Study_var Study = SALOMEDS::Study::_narrow(obj) ;
+  ASSERT(!CORBA::is_nil(Study));
+  return SALOMEDS::Study::_duplicate(Study);
 }
 
 //============================================================================
@@ -247,133 +143,17 @@ SALOMEDS::Study_ptr SALOMEDS_SObject_i::GetStudy()
  *  Purpose  : Find attribute of given type on this SObject
  */
 //============================================================================
-CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute, 
+CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out anAttribute,
                                                  const char* aTypeOfAttribute)
 {
+  SALOMEDS::Locker lock;
   Handle(TDF_Attribute) anAttr;
-  Standard_Boolean found = _lab.FindAttribute(SALOMEDS_SObject_i::ReturnGUIDForAttribute(aTypeOfAttribute), anAttr);
-  if (found) {
-    if (strcmp(aTypeOfAttribute, "AttributeReal") == 0 )  {
-      SALOMEDS_AttributeReal_i* Attr = new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeReal::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeInteger") == 0 )  {
-      SALOMEDS_AttributeInteger_i* Attr = new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeInteger::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfReal") == 0 )  {
-      SALOMEDS_AttributeSequenceOfReal_i* Attr = new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeSequenceOfReal::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeSequenceOfInteger") == 0 )  {
-      SALOMEDS_AttributeSequenceOfInteger_i* Attr = new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeSequenceOfInteger::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeName") == 0 ) {
-      SALOMEDS_AttributeName_i* Attr = new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeName::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeComment") == 0 ) {
-      SALOMEDS_AttributeComment_i* Attr = new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeComment::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0 ) {
-      SALOMEDS_AttributeIOR_i* Attr = new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeIOR::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributePersistentRef") == 0 )  {
-      SALOMEDS_AttributePersistentRef_i* Attr = new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributePersistentRef::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeDrawable") == 0 )  {
-      SALOMEDS_AttributeDrawable_i* Attr = new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeDrawable::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeSelectable") == 0 )  {
-      SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeSelectable::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeExpandable") == 0 )  {
-      SALOMEDS_AttributeExpandable_i* Attr = new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeExpandable::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeOpened") == 0 )  {
-      SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeOpened::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeTextColor") == 0 )  {
-      SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTextColor::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeTextHighlightColor") == 0 )  {
-      SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTextHighlightColor::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributePixMap") == 0 )  {
-      SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributePixMap::_this();
-      return Standard_True;
-    }
-    else if (strncmp(aTypeOfAttribute, "AttributeTreeNode",17) == 0 )  {
-      SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTreeNode::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeLocalID") == 0 )  {
-      SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeLocalID::_this();
-      return Standard_True;
-    }
-    else if (strncmp(aTypeOfAttribute, "AttributeUserID",15) == 0 )  {
-      SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeUserID::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeTarget") == 0 )  {
-      SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTarget::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeTableOfInteger") == 0 )  {
-      SALOMEDS_AttributeTableOfInteger_i* Attr = new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTableOfInteger::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeTableOfReal") == 0 )  {
-      SALOMEDS_AttributeTableOfReal_i* Attr = new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTableOfReal::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeTableOfString") == 0 )  {
-      SALOMEDS_AttributeTableOfString_i* Attr = new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeTableOfString::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributeStudyProperties") == 0 )  {
-      SALOMEDS_AttributeStudyProperties_i* Attr = new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributeStudyProperties::_this();
-      return Standard_True;
-    }
-    else if (strcmp(aTypeOfAttribute, "AttributePythonObject") == 0 )  {
-      SALOMEDS_AttributePythonObject_i* Attr = new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
-      anAttribute = Attr->AttributePythonObject::_this();
-      return Standard_True;
-    }
-  } else return Standard_False;
+  if(_impl->FindAttribute(anAttr, (char*)aTypeOfAttribute)) {
+    anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb));
+    return Standard_True;
+  }
+
+  return Standard_False;
 }
 
 //============================================================================
@@ -384,120 +164,21 @@ CORBA::Boolean SALOMEDS_SObject_i::FindAttribute (SALOMEDS::GenericAttribute_out
 
 SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
 {
-  Standard_Integer NumAttr = _lab.NbAttributes();
+  SALOMEDS::Locker lock;
+  Handle(TColStd_HSequenceOfTransient) aSeq = _impl->GetAllAttributes();
   SALOMEDS::ListOfAttributes_var SeqOfAttr = new SALOMEDS::ListOfAttributes;
-  SeqOfAttr->length(NumAttr);
-  if (NumAttr != 0) {
-    Standard_Integer i = 0;
-    for(TDF_AttributeIterator iter(_lab);iter.More();iter.Next()) {
-      Handle(TDF_Attribute) anAttr = iter.Value();
+  Standard_Integer length = aSeq->Length();
+
+  SeqOfAttr->length(length);
+
+  if (length != 0) {
+    for(int i = 1; i<= length; i++) {
+      Handle(SALOMEDSImpl_GenericAttribute) anAttr = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(aSeq->Value(i));
       SALOMEDS::GenericAttribute_var anAttribute;
-      if (ReturnGUIDForAttribute("AttributeReal") == anAttr->ID()) {
-        SALOMEDS_AttributeReal_i* Attr= new SALOMEDS_AttributeReal_i(Handle(TDataStd_Real)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeReal::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeInteger") == anAttr->ID()) {
-        SALOMEDS_AttributeInteger_i* Attr= new SALOMEDS_AttributeInteger_i(Handle(TDataStd_Integer)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeInteger::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeSequenceOfReal") == anAttr->ID()) {
-        SALOMEDS_AttributeSequenceOfReal_i* Attr= new SALOMEDS_AttributeSequenceOfReal_i(Handle(SALOMEDS_SequenceOfRealAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeSequenceOfReal::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeSequenceOfInteger") == anAttr->ID()) {
-        SALOMEDS_AttributeSequenceOfInteger_i* Attr= new SALOMEDS_AttributeSequenceOfInteger_i(Handle(SALOMEDS_SequenceOfIntegerAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeSequenceOfInteger::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeName") == anAttr->ID()) {
-        SALOMEDS_AttributeName_i* Attr= new SALOMEDS_AttributeName_i(Handle(TDataStd_Name)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeName::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeComment") == anAttr->ID()) {
-        SALOMEDS_AttributeComment_i* Attr= new SALOMEDS_AttributeComment_i(Handle(TDataStd_Comment)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeComment::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeIOR") == anAttr->ID()) {
-        SALOMEDS_AttributeIOR_i* Attr= new SALOMEDS_AttributeIOR_i(Handle(SALOMEDS_IORAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeIOR::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributePersistentRef") == anAttr->ID()) {
-        SALOMEDS_AttributePersistentRef_i* Attr= new SALOMEDS_AttributePersistentRef_i(Handle(SALOMEDS_PersRefAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributePersistentRef::_this();
+      anAttribute = SALOMEDS::GenericAttribute::_duplicate(SALOMEDS_GenericAttribute_i::CreateAttribute(anAttr, _orb));
+      if (!CORBA::is_nil(anAttribute)) {
+       SeqOfAttr[i - 1] = anAttribute;
       }
-      else if (ReturnGUIDForAttribute("AttributeDrawable") == anAttr->ID()) {
-        SALOMEDS_AttributeDrawable_i* Attr= new SALOMEDS_AttributeDrawable_i(Handle(SALOMEDS_DrawableAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeDrawable::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeSelectable") == anAttr->ID()) {
-        SALOMEDS_AttributeSelectable_i* Attr= new SALOMEDS_AttributeSelectable_i(Handle(SALOMEDS_SelectableAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeSelectable::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeExpandable") == anAttr->ID()) {
-        SALOMEDS_AttributeExpandable_i* Attr= new SALOMEDS_AttributeExpandable_i(Handle(SALOMEDS_ExpandableAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeExpandable::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeOpened") == anAttr->ID()) {
-        SALOMEDS_AttributeOpened_i* Attr= new SALOMEDS_AttributeOpened_i(Handle(SALOMEDS_OpenedAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeOpened::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTextColor") == anAttr->ID()) {
-        SALOMEDS_AttributeTextColor_i* Attr= new SALOMEDS_AttributeTextColor_i(Handle(SALOMEDS_TextColorAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTextColor::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTextHighlightColor") == anAttr->ID()) {
-        SALOMEDS_AttributeTextHighlightColor_i* Attr= new SALOMEDS_AttributeTextHighlightColor_i(Handle(SALOMEDS_TextHighlightColorAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTextHighlightColor::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributePixMap") == anAttr->ID()) {
-        SALOMEDS_AttributePixMap_i* Attr= new SALOMEDS_AttributePixMap_i(Handle(SALOMEDS_PixMapAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributePixMap::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTreeNode") == anAttr->ID()) {
-        SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTreeNode::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeLocalID") == anAttr->ID()) {
-        SALOMEDS_AttributeLocalID_i* Attr= new SALOMEDS_AttributeLocalID_i(Handle(SALOMEDS_LocalIDAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeLocalID::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTarget") == anAttr->ID()) {
-        SALOMEDS_AttributeTarget_i* Attr= new SALOMEDS_AttributeTarget_i(Handle(SALOMEDS_TargetAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTarget::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTableOfInteger") == anAttr->ID()) {
-        SALOMEDS_AttributeTableOfInteger_i* Attr= new SALOMEDS_AttributeTableOfInteger_i(Handle(SALOMEDS_TableOfIntegerAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTableOfInteger::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTableOfReal") == anAttr->ID()) {
-        SALOMEDS_AttributeTableOfReal_i* Attr= new SALOMEDS_AttributeTableOfReal_i(Handle(SALOMEDS_TableOfRealAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTableOfReal::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeTableOfString") == anAttr->ID()) {
-        SALOMEDS_AttributeTableOfString_i* Attr= new SALOMEDS_AttributeTableOfString_i(Handle(SALOMEDS_TableOfStringAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTableOfString::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributeStudyProperties") == anAttr->ID()) {
-        SALOMEDS_AttributeStudyProperties_i* Attr= new SALOMEDS_AttributeStudyProperties_i(Handle(SALOMEDS_StudyPropertiesAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeStudyProperties::_this();
-      } 
-      else if (ReturnGUIDForAttribute("AttributePythonObject") == anAttr->ID()) {
-        SALOMEDS_AttributePythonObject_i* Attr= new SALOMEDS_AttributePythonObject_i(Handle(SALOMEDS_PythonObjectAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributePythonObject::_this();
-      } 
-      else if (!Handle(TDataStd_UAttribute)::DownCast(anAttr).IsNull()) {
-        SALOMEDS_AttributeUserID_i* Attr= new SALOMEDS_AttributeUserID_i(Handle(TDataStd_UAttribute)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeUserID::_this();
-      } 
-      else if (!Handle(TDataStd_TreeNode)::DownCast(anAttr).IsNull()) {
-        SALOMEDS_AttributeTreeNode_i* Attr= new SALOMEDS_AttributeTreeNode_i(Handle(TDataStd_TreeNode)::DownCast(anAttr), _orb);
-        anAttribute = Attr->AttributeTreeNode::_this();
-      } else {
-       // references attributes, for an example, never returns
-       continue;
-      }
-
-      SeqOfAttr[i] =  anAttribute;
-      i++;
     }
   }
   return SeqOfAttr._retn();
@@ -506,62 +187,145 @@ SALOMEDS::ListOfAttributes* SALOMEDS_SObject_i::GetAllAttributes()
 
 //============================================================================
 /*! Function : ReferencedObject
- *  Purpose  : 
+ *  Purpose  :
  */
 //============================================================================
 CORBA::Boolean SALOMEDS_SObject_i::ReferencedObject(SALOMEDS::SObject_out obj)
 {
-  Handle(TDF_Reference) Ref;
-  if (!_lab.FindAttribute(TDF_Reference::GetID(),Ref))
-    return false;
-  
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (Ref->Get(),_orb);
-  obj  = SALOMEDS::SObject::_narrow(so_servant->_this()); 
+  SALOMEDS::Locker lock;
+  Handle(SALOMEDSImpl_SObject) aRefObj;
+  if(!_impl->ReferencedObject(aRefObj)) return false;
+
+  obj = SALOMEDS_SObject_i::New (aRefObj, _orb);
   return true;
 }
 
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function : FindSubObject
+ *  Purpose  :
  */
 //============================================================================
 CORBA::Boolean SALOMEDS_SObject_i::FindSubObject(long atag, SALOMEDS::SObject_out obj)
 {
-  TDF_Label L = _lab.FindChild(atag,false);
-  if (L.IsNull()) return false;
-  
-  SALOMEDS_SObject_i *  so_servant = new SALOMEDS_SObject_i (L,_orb);
-  obj  = SALOMEDS::SObject::_narrow(so_servant->_this()); 
+  SALOMEDS::Locker lock;
+  Handle(SALOMEDSImpl_SObject) aSubObj;
+  if(!_impl->FindSubObject(atag, aSubObj)) return false;
+
+  obj = SALOMEDS_SObject_i::New (aSubObj, _orb);
   return true;
-    
-}  
+
+}
 
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function : Name
+ *  Purpose  : gets a name
  */
 //============================================================================
 char* SALOMEDS_SObject_i::Name()
 {
-  return CORBA::string_dup(_name);
+  SALOMEDS::Locker lock;
+  return CORBA::string_dup(_impl->Name().ToCString());
 }
-  
+
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function : Name
+ *  Purpose  : sets a name
  */
 //============================================================================
 void  SALOMEDS_SObject_i::Name(const char* name)
 {
-  _name = CORBA::string_dup(name);
+  SALOMEDS::Locker lock;
+  TCollection_AsciiString aName((char*)name);
+  _impl->Name(aName);
 }
-  
+
 //============================================================================
-/*! Function :
- *  Purpose  : 
+/*! Function : Tag
+ *  Purpose  :
  */
 //============================================================================
 CORBA::Short SALOMEDS_SObject_i::Tag()
 {
-  return _lab.Tag();
+  SALOMEDS::Locker lock;
+  return _impl->Tag();
+}
+
+//============================================================================
+/*! Function : Depth
+ *  Purpose  :
+ */
+//============================================================================
+CORBA::Short SALOMEDS_SObject_i::Depth()
+{
+  SALOMEDS::Locker lock;
+  return _impl->Depth();
+}
+
+//============================================================================
+/*! Function : GetObject
+ *  Purpose  :
+ */
+//============================================================================
+CORBA::Object_ptr SALOMEDS_SObject_i::GetObject()
+{
+  SALOMEDS::Locker lock;
+  CORBA::Object_ptr obj = CORBA::Object::_nil();
+  try {
+    TCollection_AsciiString IOR = _impl->GetIOR();
+    char* c_ior = CORBA::string_dup(IOR.ToCString());
+    obj = _orb->string_to_object(c_ior);
+    CORBA::string_free(c_ior);
+  } catch(...) {}
+  return obj;
+}
+
+//============================================================================
+/*! Function : GetName
+ *  Purpose  :
+ */
+//============================================================================
+char* SALOMEDS_SObject_i::GetName()
+{
+  SALOMEDS::Locker lock;
+  CORBA::String_var aStr = CORBA::string_dup(_impl->GetName().ToCString());
+  return aStr._retn();
+}
+
+//============================================================================
+/*! Function : GetComment
+ *  Purpose  :
+ */
+//============================================================================
+char* SALOMEDS_SObject_i::GetComment()
+{
+  SALOMEDS::Locker lock;
+  CORBA::String_var aStr = CORBA::string_dup(_impl->GetComment().ToCString());
+  return aStr._retn();
+}
+
+//============================================================================
+/*! Function : GetIOR
+ *  Purpose  :
+ */
+//============================================================================
+char* SALOMEDS_SObject_i::GetIOR()
+{
+  SALOMEDS::Locker lock;
+  CORBA::String_var aStr = CORBA::string_dup(_impl->GetIOR().ToCString());
+  return aStr._retn();
+}
+
+//===========================================================================
+//   PRIVATE FUNCTIONS
+//===========================================================================
+long SALOMEDS_SObject_i::GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal)
+{
+#ifdef WIN32
+  long pid = (long)_getpid();
+#else
+  long pid = (long)getpid();
+#endif
+  isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0;
+  SALOMEDSImpl_SObject* local_impl = _impl.operator->();
+  return ((long)local_impl);
 }