Salome HOME
updated copyright message
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_Study.cxx
index 7d838bc5d262159bd2071a4b47c4709d2777bd57..cc063bd8f74772be6699aeeb22df66b10e69b93c 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -84,17 +84,17 @@ namespace {
     void suspend()
     {
       if (myLocked) {
-           myStudy->GetProperties()->SetLocked(true);
-           myPrevLocked = myLocked;
-           myLocked = false;
+        myStudy->GetProperties()->SetLocked(true);
+        myPrevLocked = myLocked;
+        myLocked = false;
       }
     }
     void resume()
     {
       if (myPrevLocked) {
-           myStudy->GetProperties()->SetLocked(false);
-           myLocked = myPrevLocked;
-           myPrevLocked = false;
+        myStudy->GetProperties()->SetLocked(false);
+        myLocked = myPrevLocked;
+        myPrevLocked = false;
       }
     }
   private:
@@ -109,7 +109,7 @@ namespace {
  *  Purpose  : SALOMEDSImpl_Study constructor
  */
 //============================================================================
-SALOMEDSImpl_Study::SALOMEDSImpl_Study()
+SALOMEDSImpl_Study::SALOMEDSImpl_Study() : _doc(NULL)
 {
   _appli = new DF_Application();
   _clipboard = _appli->NewDocument("SALOME_STUDY");
@@ -137,12 +137,15 @@ SALOMEDSImpl_Study::~SALOMEDSImpl_Study()
 //============================================================================
 void SALOMEDSImpl_Study::Init()
 {
+  if (_doc)
+    return; // noop: already initialized
+
   static int _id = 0;
   std::stringstream sstrm;
   sstrm << ++_id;
   _name = "Study" + std::string(sstrm.str());
   _doc = _appli->NewDocument("SALOME_STUDY");
-  _Saved = false ;
+  _Saved = false;
   _URL = "";
   _autoFill = false;
   _errorCode = "";
@@ -150,6 +153,7 @@ void SALOMEDSImpl_Study::Init()
   _builder = new SALOMEDSImpl_StudyBuilder(this);
   _cb = new SALOMEDSImpl_Callback(_useCaseBuilder);
   _notifier=0;
+  _genObjRegister=0;
   //Put on the root label a StudyHandle attribute to store the address of this object
   //It will be used to retrieve the study object by DF_Label that belongs to the study
   SALOMEDSImpl_StudyHandle::Set(_doc->Main().Root(), this);
@@ -171,9 +175,13 @@ void SALOMEDSImpl_Study::Init()
 //============================================================================
 void SALOMEDSImpl_Study::Clear()
 {
-  delete _builder;
-  delete _cb;
-  delete _useCaseBuilder;
+  if (_builder) delete _builder;
+  _builder = NULL;
+  if (_cb) delete _cb;
+  _cb = NULL;
+  if (_useCaseBuilder) delete _useCaseBuilder;
+  _useCaseBuilder = NULL;
+  URL("");
   _appli->Close(_doc);
   _doc = NULL;
   _mapOfSO.clear();
@@ -187,8 +195,6 @@ void SALOMEDSImpl_Study::Clear()
 //============================================================================
 bool SALOMEDSImpl_Study::Open(const std::string& aUrl)
 {
-  Clear();
-  Init();
   // Set "C" locale temporarily to avoid possible localization problems
   Kernel_Utils::Localizer loc;
 
@@ -296,24 +302,8 @@ bool SALOMEDSImpl_Study::Open(const std::string& aUrl)
  */
 //============================================================================
 bool SALOMEDSImpl_Study::Save(SALOMEDSImpl_DriverFactory* aFactory,
-                              bool theMultiFile)
-{
-  _errorCode = "";
-
-  std::string url = URL();
-  if (url.empty()) {
-    _errorCode = "No path specified to save the study. Nothing done";
-    return false;
-  }
-  else {
-    return Impl_SaveAs(url, aFactory, theMultiFile, false);
-  }
-
-  return false;
-}
-
-bool SALOMEDSImpl_Study::SaveASCII(SALOMEDSImpl_DriverFactory* aFactory,
-                                   bool theMultiFile)
+                              bool theMultiFile,
+                              bool theASCII)
 {
   _errorCode = "";
 
@@ -323,7 +313,7 @@ bool SALOMEDSImpl_Study::SaveASCII(SALOMEDSImpl_DriverFactory* aFactory,
     return false;
   }
   else {
-    return Impl_SaveAs(url, aFactory, theMultiFile, true);
+    return Impl_SaveAs(url, aFactory, theMultiFile, theASCII);
   }
 
   return false;
@@ -336,18 +326,11 @@ bool SALOMEDSImpl_Study::SaveASCII(SALOMEDSImpl_DriverFactory* aFactory,
 //============================================================================
 bool SALOMEDSImpl_Study::SaveAs(const std::string& aUrl,
                                 SALOMEDSImpl_DriverFactory* aFactory,
-                                bool theMultiFile)
+                                bool theMultiFile,
+                                bool theASCII)
 {
   _errorCode = "";
-  return Impl_SaveAs(aUrl, aFactory, theMultiFile, false);
-}
-
-bool SALOMEDSImpl_Study::SaveAsASCII(const std::string& aUrl,
-                                     SALOMEDSImpl_DriverFactory* aFactory,
-                                     bool theMultiFile)
-{
-  _errorCode = "";
-  return Impl_SaveAs(aUrl, aFactory, theMultiFile, true);
+  return Impl_SaveAs(aUrl, aFactory, theMultiFile, theASCII);
 }
 
 //=============================================================================
@@ -372,7 +355,7 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
   int month=0,day=0,year=0,hh=0,mn=0,ss=0;
   SALOMEDSImpl_Tool::GetSystemDate(year, month, day, hh, mn, ss);
   aProp->SetModification(SALOMEDSImpl_Tool::GetUserName(),
-                                    mn, hh, day, month, year);
+                         mn, hh, day, month, year);
 
   // lock study back if it was locked initially, to write correct value of Locked flag
   unlock.suspend();
@@ -390,8 +373,8 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
 
   int aLength = 0, aLength1 = 0, anIndex, i, unitsSize = 0, commentSize = 0;
 
-  for(i=1; i<=aNames.size(); i++)
-    aLength += aNames[i-1].size() + 1;
+  for(i=1; i<=(int)aNames.size(); i++)
+    aLength += (int)aNames[i-1].size() + 1; //!< TODO: conversion from size_t to int
 
   std::map< std::string, std::vector<std::string> >::const_iterator it;
   for (it = allVersions.begin(); it != allVersions.end(); ++it ) {
@@ -403,11 +386,11 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
       vlist += *vlit;
     }
     versions[ it->first ] = vlist;
-    aLength1 += it->first.size() + vlist.size() + 2;
+    aLength1 += int(it->first.size() + vlist.size() + 2); //!< TODO: conversion from size_t to int
   }
 
-  unitsSize = units.size();
-  commentSize = comment.size();
+  unitsSize = (int)units.size(); //!< TODO: conversion from size_t to int
+  commentSize = (int)comment.size(); //!< TODO: conversion from size_t to int
 
   //string format:
   //locked flag, modified flag,
@@ -423,14 +406,14 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
   //...........................,
   //component=versions, char(1), char(0)
 
-  //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimeter)
+  //string length: 1 byte = locked flag, 1 byte = modified flag, (12 + name length + 1) for each name and date, 1 byte (char(30) section delimiter)
   // unit length + 1, comment length, "zero" byte
 
   char* aProperty = new char[3 + aLength + 12 * aNames.size() + 1 + unitsSize + 1 + commentSize + 1 + aLength1 ];
 
   sprintf(aProperty,"%c%c", (char)aProp->GetCreationMode(),  (aProp->IsLocked())?'l':'u');
 
-  aLength = aNames.size();
+  aLength = (int)aNames.size(); //!< TODO: conversion from size_t to int
   int a = 2;
   for(anIndex = 0; anIndex<aLength; anIndex++) {
     sprintf(&(aProperty[a]),"%2d%2d%2d%2d%4d%s",
@@ -440,17 +423,17 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
             (int)(aMonths[anIndex]),
             (int)(aYears[anIndex]),
             aNames[anIndex].c_str());
-    a = strlen(aProperty);
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
     aProperty[a++] = 1;
   }
 
-  //Write delimeter of the section to define end of the modifications section
+  //Write delimiter of the section to define end of the modifications section
   aProperty[a++] = 30;
 
   //Write units if need
   if(units.size() > 0) {
     sprintf(&(aProperty[a]),"%s",units.c_str());
-    a = strlen(aProperty);
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
   }
 
   aProperty[a++] = 1;
@@ -458,17 +441,17 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
   //Write comments if need
   if(comment.size() > 0) {
     sprintf(&(aProperty[a]),"%s",comment.c_str());
-    a = strlen(aProperty);
+    a = (int)strlen(aProperty); //!< TODO: conversion from size_t to int
   }
 
-  aProperty[a++] = 30; //delimeter of the component versions
+  aProperty[a++] = 30; //delimiter of the component versions
 
   std::map<std::string, std::string>::const_iterator versionsIt;
   for ( versionsIt = versions.begin(); versionsIt != versions.end(); ++versionsIt ) {
     sprintf(&(aProperty[a]),"%s=%s",
             (char*)(versionsIt->first.c_str()),
-           (char*)(versionsIt->second.c_str()));
-    a = a + versionsIt->first.size() + versionsIt->second.size() + 1;
+            (char*)(versionsIt->second.c_str()));
+    a = a + (int)versionsIt->first.size() + (int)versionsIt->second.size() + 1; //!< TODO: conversion from size_t to int
     aProperty[a++] = 1;
   }
 
@@ -500,11 +483,11 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
   // Set "C" locale temporarily to avoid possible localization problems
   Kernel_Utils::Localizer loc;
 
-  // HDF File will be composed of differents part :
+  // HDF File will be composed of different part :
   // * For each ComponentDataType, all data created by the component
-  //   Informations in data group hdf_group_datacomponent
+  //   Information in data group hdf_group_datacomponent
   // * Study Structure -> Exactly what is contained in Document
-  //   Informations in data group hdf_group_study_structure
+  //   Information in data group hdf_group_study_structure
 
   _errorCode = "";
 
@@ -522,7 +505,7 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
   std::string component_name;
 
   // Store previous URL
-  std::string anOldName = Name();
+  std::string anOldName = URL();
 
   // Map to store components' versions
   std::map<std::string, std::string> componentVersions;
@@ -557,10 +540,10 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
             }
           }
         }
-           else {
-             aDriver = aFactory->GetDriverByIOR(IOREngine);
-           }
-           aMapTypeDriver[aCompType] = aDriver;
+        else {
+          aDriver = aFactory->GetDriverByIOR(IOREngine);
+        }
+        aMapTypeDriver[aCompType] = aDriver;
       }
       catch(...) {
         _errorCode = "Can not restore information to resave it";
@@ -573,7 +556,7 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
     URL(aStudyUrl);
 
     // To change for Save
-    // Do not have to do a new file but just a Open??? Rewrite all informations after erasing evrything??
+    // Do not have to do a new file but just a Open??? Rewrite all information after erasing everything??
     hdf_file = new HDFfile((char*)aUrl.c_str());
     hdf_file->CreateOnDisk();
 
@@ -636,7 +619,7 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
           hdf_dataset->WriteOnDisk((void*)(theASCII?"A":"B")); // save: ASCII or BINARY
           hdf_dataset->CloseOnDisk();
           hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
-          // Creation of the persistance reference  attribute
+          // Creation of the persistence reference  attribute
           Translate_IOR_to_persistentID (sco, Engine, theMultiFile, theASCII);
         }
       }
@@ -695,7 +678,7 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
     std::string varType;
     std::string varIndex;
 
-    for (int i=0 ;i < myNoteBookVars.size(); i++ ) {
+    for (int i=0 ;i < (int)myNoteBookVars.size(); i++ ) {
       // For each variable create HDF group
       hdf_notebook_var = new HDFgroup((char*)myNoteBookVars[i]->Name().c_str(),hdf_notebook_vars);
       hdf_notebook_var->CreateOnDisk();
@@ -790,14 +773,24 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
   std::string aStudyTmpDir = SALOMEDSImpl_Tool::GetDirFromPath(aUrl);
 
 #ifdef WIN32
-  aCmd = "dir /B \"" + aStudyTmpDir +"\" > " + aTmpFile;
+  aCmd = "dir /B \"" + aStudyTmpDir +"\" > \"" + aTmpFile + "\"";
 #else
   aCmd ="ls -1 \"" + aStudyTmpDir +"\" > " + aTmpFile;
 #endif
+#if defined(WIN32) && defined(UNICODE)
+  std::wstring awCmd = Kernel_Utils::utf8_decode_s(aCmd);
+  _wsystem( awCmd.c_str() );
+#else  
   system(aCmd.c_str());
+#endif
 
   // Iterate and move files in the temporary directory
+#if defined(WIN32) && defined(UNICODE)
+  std::wstring awTmpFile = Kernel_Utils::utf8_decode_s(aTmpFile);
+  FILE* fp = _wfopen(awTmpFile.c_str(), L"rb");
+#else
   FILE* fp = fopen(aTmpFile.c_str(), "rb");
+#endif
   if (!fp) {
     URL( anOldName ); // VSR: restore previous url if operation is failed
     return false;
@@ -808,12 +801,27 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
     if ((fgets(buffer, 2046, fp)) == NULL) break;
     size_t aLen = strlen(buffer);
     if (buffer[aLen-1] == '\n') buffer[aLen-1] = char(0);
-#ifdef WIN32
-    aCmd = "move /Y \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl) +"\"";
+
+#ifdef WIN32    
+    // Force removing readonly attribute from a file under Windows, because of a but in the HDF
+    std::string aReadOlnyRmCmd = "attrib -r \"" + aStudyTmpDir + std::string(buffer)+ "\" > nul 2>&1";
+#ifdef UNICODE
+    std::wstring awReadOlnyRmCmd = Kernel_Utils::utf8_decode_s(aReadOlnyRmCmd);
+    _wsystem(awReadOlnyRmCmd.c_str());
+#else  
+    system(aReadOlnyRmCmd.c_str());
+#endif
+
+    aCmd = "move /Y \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl) +"\" > nul 2>&1";
 #else
     aCmd = "mv -f \"" + aStudyTmpDir + std::string(buffer) + "\" \"" + SALOMEDSImpl_Tool::GetDirFromPath(aStudyUrl)+"\"";
 #endif
+#if defined(WIN32) && defined(UNICODE)
+    std::wstring awCmd = Kernel_Utils::utf8_decode_s(aCmd);
+    errors = _wsystem(awCmd.c_str());
+#else  
     errors = system(aCmd.c_str());
+#endif
   }
 
   delete []buffer;
@@ -821,14 +829,27 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
 
   // Perform cleanup
 #ifdef WIN32
-  DeleteFileA(aTmpFile.c_str());
+#ifdef UNICODE
+  std::wstring aTmpFileToDelete = Kernel_Utils::utf8_decode_s(aTmpFile);
+#else
+  std::string aTmpFileToDelete = aTmpFile;
+#endif
+  DeleteFile(aTmpFileToDelete.c_str());
 #else
   unlink(aTmpFile.c_str());
 #endif
 
 #ifdef WIN32
-  RemoveDirectoryA(aTmpFileDir.c_str());
-  RemoveDirectoryA(aStudyTmpDir.c_str());
+#ifdef UNICODE
+  std::wstring aTmpFileDirToDelete = Kernel_Utils::utf8_decode_s( aTmpFileDir );
+  std::wstring aStudyTmpDirToDelete = Kernel_Utils::utf8_decode_s( aStudyTmpDir );
+#else
+  std::string aTmpFileDirToDelete = aTmpFileDir;
+  std::string aStudyTmpDirToDelete = aStudyTmpDir;
+#endif  
+  RemoveDirectory( aTmpFileDirToDelete.c_str() );
+  RemoveDirectory( aStudyTmpDirToDelete.c_str() );
 #else
   rmdir(aTmpFileDir.c_str());
   rmdir(aStudyTmpDir.c_str());
@@ -839,6 +860,10 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
     IsSaved(true);
   }
 
+  std::map<std::string, SALOMEDSImpl_Driver*>::iterator n2dr = aMapTypeDriver.begin();
+  for ( ; n2dr != aMapTypeDriver.end(); ++n2dr )
+    delete n2dr->second;
+
   return !errors;
 }
 
@@ -852,7 +877,7 @@ bool SALOMEDSImpl_Study::Impl_SaveObject(const SALOMEDSImpl_SObject& SC,
 {
   _errorCode = "";
 
-  // Write in group hdf_group_datatype all informations of SObject SC
+  // Write in group hdf_group_datatype all information of SObject SC
   // Iterative function to parse all SObjects under a SComponent
 
   HDFgroup *hdf_group_sobject = 0;
@@ -932,7 +957,7 @@ bool SALOMEDSImpl_Study::CopyLabel(SALOMEDSImpl_Driver* theEngine,
   }
   // iterate attributes
   std::vector<DF_Attribute*> attrList = theSource.GetAttributes();
-  for(int i = 0, len = attrList.size(); i<len; i++) {
+  for(int i = 0, len = (int)attrList.size(); i<len; i++) { //!< TODO: conversion from size_t to int
     DF_Attribute* anAttr = attrList[i];
     std::string type = SALOMEDSImpl_GenericAttribute::Impl_GetType(anAttr);
     if (type.substr(0, 17) == std::string("AttributeTreeNode")) continue; // never copy tree node attribute
@@ -990,9 +1015,6 @@ bool SALOMEDSImpl_Study::Copy(const SALOMEDSImpl_SObject& theObject,
   bool aStructureOnly; // copy only SObjects and attributes without component help
   aStructureOnly = !theObject.GetLabel().IsAttribute(SALOMEDSImpl_AttributeIOR::GetID());
 
-  // get component-engine
-  SALOMEDSImpl_Study* aStudy = theObject.GetStudy();
-
   if (!_doc) {
     _errorCode = "Document is null";
     return false;
@@ -1100,7 +1122,7 @@ DF_Label SALOMEDSImpl_Study::PasteLabel(SALOMEDSImpl_Driver* theEngine,
 
     if (theEngine->CanPaste(aCompName, anObjID->Value())) {
       std::string aTMPStr = aNameAttribute->Value();
-      int aLen = aTMPStr.size();
+      int aLen = (int)aTMPStr.size(); //!< TODO: conversion from size_t to int
       unsigned char* aStream = NULL;
       if(aLen > 0) {
         aStream = new unsigned char[aLen+10];
@@ -1127,7 +1149,7 @@ DF_Label SALOMEDSImpl_Study::PasteLabel(SALOMEDSImpl_Driver* theEngine,
 
   // iterate attributes
   std::vector<DF_Attribute*> attrList = theSource.GetAttributes();
-  for(int i = 0, len = attrList.size(); i<len; i++) {
+  for(int i = 0, len = (int)attrList.size(); i<len; i++) { //!< TODO: conversion from size_t to int
     DF_Attribute* anAttr = attrList[i];
     if (aTargetLabel.FindAttribute(anAttr->ID())) {
       aTargetLabel.ForgetAttribute(anAttr->ID());
@@ -1218,41 +1240,6 @@ std::string SALOMEDSImpl_Study::GetPersistentReference()
   _errorCode = "";
   return URL();
 }
-//============================================================================
-/*! Function : GetTransientReference
- *  Purpose  : Get IOR of the Study (registred in Document in doc->Root)
- */
-//============================================================================
-std::string SALOMEDSImpl_Study::GetTransientReference()
-{
-  _errorCode = "";
-  std::string IOR = "";
-
-  SALOMEDSImpl_AttributeIOR* Att;
-  DF_Label _lab = _doc->Root();
-  if ((Att=(SALOMEDSImpl_AttributeIOR*)_lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
-    IOR = Att->Value();
-  }
-  else {
-    _errorCode = "IOR is empty";
-  }
-
-  return IOR;
-}
-
-void SALOMEDSImpl_Study::SetTransientReference(const std::string& theIOR)
-{
-  _errorCode = "";
-
-  SALOMEDSImpl_AttributeStudyProperties* aProp = GetProperties();
-  int aLocked = aProp->IsLocked();
-  if (aLocked) aProp->SetLocked(false);
-
-  // Assign the value of the IOR in the study->root
-  SALOMEDSImpl_AttributeIOR::Set(_doc->Main().Root(), theIOR);
-
-  if (aLocked) aProp->SetLocked(true);
-}
 
 //============================================================================
 /*! Function : IsEmpty
@@ -1489,11 +1476,11 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectByPath(const std::string& the
 
   std::string aPath(thePath), aToken;
   SALOMEDSImpl_SObject aSO;
-  int aLength = aPath.size();
+  int aLength = (int)aPath.size(); //!< TODO: conversion from size_t to int
   bool isRelative = false;
 
   if(aLength == 0) {  //Empty path - return the current context
-    return GetSObject(_current);
+    return aSO;
   }
 
   if(aPath[0] != '/')  //Relative path
@@ -1504,8 +1491,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectByPath(const std::string& the
   SALOMEDSImpl_AttributeName* anAttr;
 
   if(isRelative) {
-    if(_current.IsNull()) return aSO;
-    anIterator.Init(_current, false);
+    return aSO;
   }
   else {
     if(aPath.size() == 1 && aPath[0] == '/') {    //Root
@@ -1515,7 +1501,7 @@ SALOMEDSImpl_SObject SALOMEDSImpl_Study::FindObjectByPath(const std::string& the
   }
 
   std::vector<std::string> vs = SALOMEDSImpl_Tool::splitString(aPath, '/');
-  for(int i = 0, len = vs.size(); i<len; i++) {
+  for(int i = 0, len = (int)vs.size(); i<len; i++) { //!< TODO: conversion from size_t to int
 
     aToken = vs[i];
     if(aToken.size() == 0) break;
@@ -1594,212 +1580,6 @@ std::string SALOMEDSImpl_Study::GetObjectPathByIOR(const std::string& theIOR)
   return GetObjectPath(so);
 }
 
-
-//============================================================================
-/*! Function : SetContext
- *  Purpose  : Sets the current context
- */
-//============================================================================
-bool SALOMEDSImpl_Study::SetContext(const std::string& thePath)
-{
-  _errorCode = "";
-  if(thePath.empty()) {
-    _errorCode = "InvalidPath";
-    return false;
-  }
-
-  std::string aPath(thePath), aContext("");
-  bool isInvalid = false;
-  SALOMEDSImpl_SObject aSO;
-
-  if(aPath[0] != '/') { //Relative path
-    aContext = GetContext();
-    aContext += '/';
-    aContext += aPath;
-  }
-  else
-    aContext = aPath;
-
-  try {
-    aSO = FindObjectByPath(aContext);
-  }
-  catch( ... ) {
-    isInvalid = true;
-  }
-
-  if(isInvalid || !aSO) {
-    _errorCode = "InvalidContext";
-    return false;
-  }
-
-  DF_Label aLabel = aSO.GetLabel();
-  if(aLabel.IsNull()) {
-    _errorCode = "InvalidContext";
-    return false;
-  }
-  else
-    _current = aLabel;  //Set the current context
-
-  return true;
-}
-
-//============================================================================
-/*! Function : GetContext
- *  Purpose  : Gets the current context
- */
-//============================================================================
-std::string SALOMEDSImpl_Study::GetContext()
-{
-  _errorCode = "";
-
-  if(_current.IsNull()) {
-    _errorCode = "InvaidContext";
-    return "";
-  }
-  SALOMEDSImpl_SObject so = GetSObject(_current);
-  return GetObjectPath(so);
-}
-
-//============================================================================
-/*! Function : GetObjectNames
- *  Purpose  : method to get all object names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetObjectNames(const std::string& theContext)
-{
-  _errorCode = "";
-
-  std::vector<std::string> aResultSeq;
-  DF_Label aLabel;
-  if (theContext.empty()) {
-    aLabel = _current;
-  } else {
-    DF_Label aTmp = _current;
-    SetContext(theContext);
-    aLabel = _current;
-    _current = aTmp;
-  }
-  if (aLabel.IsNull()) {
-    _errorCode = "InvalidContext";
-    return aResultSeq;
-  }
-
-  DF_ChildIterator anIter (aLabel, true); // iterate all subchildren at all sublevels
-  for (; anIter.More(); anIter.Next()) {
-    DF_Label aLabel = anIter.Value();
-    SALOMEDSImpl_AttributeName* aName;
-    if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
-      aResultSeq.push_back(aName->Value());
-  }
-
-  return aResultSeq;
-}
-
-//============================================================================
-/*! Function : GetDirectoryNames
- *  Purpose  : method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetDirectoryNames(const std::string& theContext)
-{
-  _errorCode = "";
-
-  std::vector<std::string> aResultSeq;
-  DF_Label aLabel;
-  if (theContext.empty()) {
-    aLabel = _current;
-  } else {
-    DF_Label aTmp = _current;
-    SetContext(theContext);
-    aLabel = _current;
-    _current = aTmp;
-  }
-  if (aLabel.IsNull()) {
-    _errorCode = "InvalidContext";
-    return aResultSeq;
-  }
-
-  DF_ChildIterator anIter (aLabel, true); // iterate first-level children at all sublevels
-  for (; anIter.More(); anIter.Next()) {
-    DF_Label aLabel = anIter.Value();
-    SALOMEDSImpl_AttributeLocalID* anID;
-    if ((anID=(SALOMEDSImpl_AttributeLocalID*)aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID()))) {
-      if (anID->Value() == DIRECTORYID) {
-        SALOMEDSImpl_AttributeName* aName;
-        if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID()))) {
-          aResultSeq.push_back(aName->Value());
-        }
-      }
-    }
-  }
-
-  return aResultSeq;
-}
-
-//============================================================================
-/*! Function : GetFileNames
- *  Purpose  : method to get all file names in the given context (or in the current context, if 'theContext' is empty)
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetFileNames(const std::string& theContext)
-{
-  _errorCode = "";
-
-  std::vector<std::string> aResultSeq;
-  DF_Label aLabel;
-  if (theContext.empty()) {
-    aLabel = _current;
-  } else {
-    DF_Label aTmp = _current;
-    SetContext(theContext);
-    aLabel = _current;
-    _current = aTmp;
-  }
-  if (aLabel.IsNull()) {
-    _errorCode = "InvalidContext";
-    return aResultSeq;
-  }
-
-  DF_ChildIterator anIter (aLabel, true); // iterate all subchildren at all sublevels
-  for (; anIter.More(); anIter.Next()) {
-    DF_Label aLabel = anIter.Value();
-    SALOMEDSImpl_AttributeLocalID* anID;
-    if ((anID=(SALOMEDSImpl_AttributeLocalID*)aLabel.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID()))) {
-      if (anID->Value() == FILELOCALID) {
-        SALOMEDSImpl_AttributePersistentRef* aName;
-        if ((aName=(SALOMEDSImpl_AttributePersistentRef*)aLabel.FindAttribute(SALOMEDSImpl_AttributePersistentRef::GetID()))) {
-          std::string aFileName = aName->Value();
-          if (aFileName.size() > 0)
-            aResultSeq.push_back(aFileName.substr(strlen(FILEID), aFileName.size()));
-        }
-      }
-    }
-  }
-
-  return aResultSeq;
-}
-
-//============================================================================
-/*! Function : GetComponentNames
- *  Purpose  : method to get all components names
- */
-//============================================================================
-std::vector<std::string> SALOMEDSImpl_Study::GetComponentNames(const std::string& theContext)
-{
-  _errorCode = "";
-
-  std::vector<std::string> aResultSeq;
-  DF_ChildIterator anIter(_doc->Main(), false); // iterate all subchildren at first level
-  for(; anIter.More(); anIter.Next()) {
-    DF_Label aLabel = anIter.Value();
-    SALOMEDSImpl_AttributeName* aName;
-    if ((aName=(SALOMEDSImpl_AttributeName*)aLabel.FindAttribute(SALOMEDSImpl_AttributeName::GetID())))
-      aResultSeq.push_back(aName->Value());
-  }
-
-  return aResultSeq;
-}
-
 //============================================================================
 /*! Function : NewChildIterator
  *  Purpose  : Create a ChildIterator from an SObject
@@ -1851,6 +1631,17 @@ std::string SALOMEDSImpl_Study::Name()
   return Kernel_Utils::GetBaseName( _name, false );
 }
 
+//============================================================================
+/*! Function : Name
+ *  Purpose  : set study name
+ */
+//============================================================================
+void SALOMEDSImpl_Study::Name(const std::string& name)
+{
+  _errorCode = "";
+  _name = name;
+}
+
 //============================================================================
 /*! Function : IsSaved
  *  Purpose  : get if study has been saved
@@ -1897,8 +1688,6 @@ bool SALOMEDSImpl_Study::IsModified()
 std::string SALOMEDSImpl_Study::URL()
 {
   _errorCode = "";
-  if ( _URL.empty() )
-    return Kernel_Utils::AddExtension( _name );
   return _URL;
 }
 
@@ -2030,7 +1819,7 @@ std::string SALOMEDSImpl_Study::_GetStudyVariablesScript()
   std::string set_method = _GetNoteBookAccessor()+".set(";
   std::string varName;
   std::string varValue;
-  for(int i = 0 ; i < myNoteBookVars.size();i++ ) {
+  for(int i = 0 ; i < (int)myNoteBookVars.size();i++ ) {
     varName = myNoteBookVars[i]->Name();
     varValue = myNoteBookVars[i]->SaveToScript();
     dump+=set_method+"\""+varName+"\", "+varValue+")\n";
@@ -2048,10 +1837,10 @@ std::string SALOMEDSImpl_Study::_GetStudyVariablesScript()
  *  Purpose  :
  */
 //============================================================================
-std::string SALOMEDSImpl_Study::_GetNoteBookAccess(const std::string& theStudyVar)
+std::string SALOMEDSImpl_Study::_GetNoteBookAccess()
 {
   std::string notebook = "import salome_notebook\n";
-  notebook += _GetNoteBookAccessor() + " = salome_notebook.NoteBook(" + theStudyVar + ")" ;
+  notebook += _GetNoteBookAccessor() + " = salome_notebook.NoteBook()" ;
   return notebook;
 }
 
@@ -2080,7 +1869,7 @@ void SALOMEDSImpl_Study::DeleteIORLabelMapItem(const std::string& anIOR)
     }
 }
 
-SALOMEDSImpl_Study* SALOMEDSImpl_Study::GetStudy(const DF_Label& theLabel)
+SALOMEDSImpl_Study* SALOMEDSImpl_Study::GetStudyImpl(const DF_Label& theLabel)
 {
   SALOMEDSImpl_StudyHandle* Att;
   if ((Att=(SALOMEDSImpl_StudyHandle*)theLabel.Root().FindAttribute(SALOMEDSImpl_StudyHandle::GetID()))) {
@@ -2091,19 +1880,19 @@ SALOMEDSImpl_Study* SALOMEDSImpl_Study::GetStudy(const DF_Label& theLabel)
 
 SALOMEDSImpl_SObject SALOMEDSImpl_Study::SObject(const DF_Label& theLabel)
 {
-  return GetStudy(theLabel)->GetSObject(theLabel);
+  return GetStudyImpl(theLabel)->GetSObject(theLabel);
 }
 
 SALOMEDSImpl_SComponent SALOMEDSImpl_Study::SComponent(const DF_Label& theLabel)
 {
-  return GetStudy(theLabel)->GetSComponent(theLabel);
+  return GetStudyImpl(theLabel)->GetSComponent(theLabel);
 }
 
 
 void SALOMEDSImpl_Study::IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute)
 {
   std::string aString = theAttribute->Label().Entry();
-  GetStudy(theAttribute->Label())->UpdateIORLabelMap(theAttribute->Value(), aString);
+  GetStudyImpl(theAttribute->Label())->UpdateIORLabelMap(theAttribute->Value(), aString);
 }
 
 std::vector<SALOMEDSImpl_SObject> SALOMEDSImpl_Study::FindDependances(const SALOMEDSImpl_SObject& anObject)
@@ -2135,7 +1924,7 @@ std::string SALOMEDSImpl_Study::GetLastModificationDate()
   std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
   aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
 
-  int aLastIndex = aNames.size()-1;
+  int aLastIndex = (int)aNames.size()-1; //!< TODO: conversion from size_t to int
   char aResult[20];
   sprintf(aResult, "%2.2d/%2.2d/%4.4d %2.2d:%2.2d",
           (int)(aDays[aLastIndex]),(int)(aMonths[aLastIndex]), (int)(aYears[aLastIndex]),
@@ -2153,7 +1942,7 @@ std::vector<std::string> SALOMEDSImpl_Study::GetModificationsDate()
   std::vector<int> aMinutes, aHours, aDays, aMonths, aYears;
   aProp->GetModifications(aNames, aMinutes, aHours, aDays, aMonths, aYears);
 
-  int anIndex, aLength = aNames.size();
+  int anIndex, aLength = (int)aNames.size(); //!< TODO: conversion from size_t to int
   std::vector<std::string> aDates;
 
   for (anIndex = 1; anIndex < aLength; anIndex++) {
@@ -2296,25 +2085,30 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
   }
 
   std::vector<std::string> aSeq;
-  std::string aCompType, aFactoryType;
+  std::string aFactoryType;
 
   //Build a list of all components in the Study
   SALOMEDSImpl_SComponentIterator itcomponent = NewComponentIterator();
 
-  for (; itcomponent.More(); itcomponent.Next()) {
-    SALOMEDSImpl_SComponent sco = itcomponent.Value();
-    aCompType = sco.ComponentDataType();
-   if (aCompType == "GEOM")
-      aSeq.insert(aSeq.begin(), aCompType);
-    else
-      aSeq.push_back(aCompType);
+  for (; itcomponent.More(); itcomponent.Next())
+    aSeq.push_back(itcomponent.Value().ComponentDataType());
+
+  std::vector<std::string>::iterator it;
+  if ( (it = std::find( aSeq.begin(), aSeq.end(), "GEOM" )) != aSeq.end() ) {
+    aSeq.erase( it );
+    aSeq.insert(aSeq.begin(), "GEOM" );
   }
+  if ( (it = std::find( aSeq.begin(), aSeq.end(), "SHAPER" )) != aSeq.end() ) {
+    aSeq.erase( it );
+    aSeq.insert(aSeq.begin(), "SHAPER" );
+  }
+
   // re-arrange modules in the sequence, if specific order is given via SALOME_MODULES_ORDER environment variable.
   if ( getenv("SALOME_MODULES_ORDER") != 0 ) {
     std::string order = getenv("SALOME_MODULES_ORDER");
     std::vector<std::string> mlist;
     while ( !order.empty() ) {
-      size_t idx = order.find( "," );
+      size_t idx = order.find( ":" );
       std::string m = order.substr(0, idx);
       order = order.substr( ( idx == std::string::npos ) ? order.size() : idx+1 );
       if ( m.empty() || std::find( mlist.begin(), mlist.end(), m ) != mlist.end() ) continue;
@@ -2340,7 +2134,12 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
 
   //Create a file that will contain a main Study script
   std::fstream fp;
+#if defined(WIN32) && defined(UNICODE)
+  std::wstring aConverterFN = Kernel_Utils::utf8_decode_s(aFileName);
+  fp.open(aConverterFN.c_str(), std::ios::out);
+#else
   fp.open(aFileName.c_str(), std::ios::out);
+#endif
 
 #ifdef WIN32
   bool isOpened = fp.is_open();
@@ -2352,6 +2151,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
     _errorCode = std::string("Can't create a file ")+aFileName;
     return false;
   }
+  _dumpPath = thePath;
 
   std::stringstream sfp;
 
@@ -2367,18 +2167,14 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
   sfp << "import sys" << std::endl;
   sfp << "import " << aBatchModeScript << std::endl << std::endl;
 
-  std::string aStudyVar = "salome.myStudy";
   // initialization function
   sfp << aBatchModeScript << ".salome_init()" << std::endl;
-  if ( !isMultiFile ) {
-    sfp << "theStudy = " << aStudyVar << std::endl << std::endl;
-    aStudyVar = "theStudy";
-  }
+
   // notebook initialization
-  sfp << _GetNoteBookAccess(aStudyVar) << std::endl;
+  sfp << _GetNoteBookAccess() << std::endl;
 
   // extend sys.path with the directory where the script is being dumped to
-  sfp << "sys.path.insert( 0, r\'" << thePath << "\')" << std::endl << std::endl;
+  sfp << "sys.path.insert(0, r\'" << thePath << "\')" << std::endl << std::endl;
 
   // dump NoteBook variables
   sfp << _GetStudyVariablesScript();
@@ -2397,10 +2193,10 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
 
   // dump all components and create the components specific scripts
   bool isOk = true;
-  int aLength = aSeq.size();
+  int aLength = (int)aSeq.size(); //!< TODO: conversion from size_t to int
   for(int i = 1; i <= aLength; i++) {
 
-    aCompType = aSeq[i-1];
+    std::string aCompType = aSeq[i-1];
     SALOMEDSImpl_SComponent sco = FindComponent(aCompType);
     SALOMEDSImpl_Driver* aDriver = NULL;
     // if there is an associated Engine call its method for saving
@@ -2438,14 +2234,14 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
       isOk = false;
 
     std::stringstream sfp2;
-    
+
     //Output the Python script generated by the component in the newly created file.
     if ( isMultiFile )
       sfp2 << GetDumpStudyComment( aCompType.c_str() ) << std::endl;
     else
       sfp2 << GetComponentHeader( aCompType.c_str() ) << std::endl;
     sfp2 << aStream->Data();
-    
+
     if ( isMultiFile ) {
       //Create a file that will contain the component specific script
       std::fstream fp2;
@@ -2458,24 +2254,29 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
       aScriptName += theBaseName;
       aScriptName += "_";
       aScriptName += aCompType;
-      
+
       aFileName += aScriptName+ std::string(".py");
       aSeqOfFileNames.push_back(aFileName);
-      
+
+#if defined(WIN32) && defined(UNICODE)
+      std::wstring aConverterFN2 = Kernel_Utils::utf8_decode_s(aFileName);
+      fp2.open(aConverterFN2.c_str(), std::ios::out);
+#else
       fp2.open(aFileName.c_str(), std::ios::out);
-      
+#endif
+
 #ifdef WIN32
       isOpened = fp2.is_open();
 #else
       isOpened = fp2.rdbuf()->is_open();
 #endif
-      
+
       if(!isOpened) {
         _errorCode = std::string("Can't create a file ")+aFileName;
         SALOMEDSImpl_Tool::RemoveTemporaryFiles(thePath, aSeqOfFileNames, false);
         return false;
       }
-     
+
       // replace '\t' symbols
       fp2 << replace_tabs( sfp2.str() );
 
@@ -2483,7 +2284,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
 
       //Add to the main script a call to RebuildData of the generated by the component the Python script
       sfp << "import " << aScriptName << std::endl;
-      sfp << aScriptName << ".RebuildData(" << aBatchModeScript << ".myStudy)" << std::endl;
+      sfp << aScriptName << ".RebuildData()" << std::endl;
     }
     else
       sfp << sfp2.str();
@@ -2501,12 +2302,21 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
 
   // replace '\t' symbols
   fp << replace_tabs( sfp.str() );
-  
+
   fp.close();
 
+  _dumpPath.clear();
+
   return isOk;
 }
 
+// Returns the folder of the python script which is currently dumped
+std::string SALOMEDSImpl_Study::GetDumpPath()
+{
+  return _dumpPath;
+}
+
+
 //=======================================================================
 //function : GetDumpStudyComment
 //purpose  : return a header comment for a DumpStudy script
@@ -2515,7 +2325,7 @@ bool SALOMEDSImpl_Study::DumpStudy(const std::string& thePath,
 std::string SALOMEDSImpl_Study::GetDumpStudyComment(const char* theComponentName)
 {
   std::stringstream txt;
-  txt << "# -*- coding: utf-8 -*-" << std::endl << std::endl;
+  txt << "#!/usr/bin/env python" << std::endl << std::endl;
   txt << "###" << std::endl;
   txt << "### This file is generated automatically by SALOME v"
       << KERNEL_VERSION_STR
@@ -2575,7 +2385,7 @@ void dumpSO(const SALOMEDSImpl_SObject& theSO,
   std::string aTab(Tab), anID(theSO.GetID());
   fp << aTab << anID << std::endl;
   std::vector<DF_Attribute*> attribs = theSO.GetLabel().GetAttributes();
-  for(int i = 0; i<attribs.size(); i++) {
+  for(int i = 0; i<(int)attribs.size(); i++) {
     SALOMEDSImpl_GenericAttribute* anAttr = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(attribs[i]);
 
     if(!anAttr) {
@@ -2722,7 +2532,7 @@ bool SALOMEDSImpl_Study::IsStudyLocked()
 void SALOMEDSImpl_Study::UnLockStudy(const char* theLockerID)
 {
   std::vector<std::string>::iterator vsI = _lockers.begin();
-  int length = _lockers.size();
+  int length = (int)_lockers.size(); //!< TODO: conversion from size_t to int
   bool isFound = false;
   std::string id(theLockerID);
   for(int i = 0; i<length; i++, vsI++) {
@@ -2811,7 +2621,7 @@ void SALOMEDSImpl_Study::SetStringVariable(const std::string& theVarName,
 //============================================================================
 void SALOMEDSImpl_Study::SetStringVariableAsDouble(const std::string& theVarName,
                                                    const double theValue,
-                                                   const SALOMEDSImpl_GenericVariable::VariableTypes theType)
+                                                   const SALOMEDSImpl_GenericVariable::VariableTypes /*theType*/)
 {
   SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName);
   if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast<SALOMEDSImpl_ScalarVariable*>(aGVar))
@@ -2887,7 +2697,7 @@ std::vector<std::string> SALOMEDSImpl_Study::GetVariableNames() const
 {
   std::vector<std::string> aResult;
 
-  for(int i = 0; i < myNoteBookVars.size(); i++)
+  for(int i = 0; i < (int)myNoteBookVars.size(); i++)
     aResult.push_back(myNoteBookVars[i]->Name());
 
   return aResult;
@@ -2911,7 +2721,7 @@ void SALOMEDSImpl_Study::AddVariable(SALOMEDSImpl_GenericVariable* theVariable)
 SALOMEDSImpl_GenericVariable* SALOMEDSImpl_Study::GetVariable(const std::string& theName) const
 {
   SALOMEDSImpl_GenericVariable* aResult = NULL;
-  for(int i = 0; i < myNoteBookVars.size();i++) {
+  for(int i = 0; i < (int)myNoteBookVars.size();i++) {
     if(theName.compare(myNoteBookVars[i]->Name()) == 0) {
       aResult = myNoteBookVars[i];
       break;
@@ -3009,10 +2819,10 @@ bool SALOMEDSImpl_Study::FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStu
       std::string aString = aStringAttr->Value();
 
       std::vector< std::vector<std::string> > aSections = ParseVariables( aString );
-      for( int i = 0, n = aSections.size(); i < n; i++ )
+      for( int i = 0, n = (int)aSections.size(); i < n; i++ ) //!< TODO: conversion from size_t to int
       {
         std::vector<std::string> aVector = aSections[i];
-        for( int j = 0, m = aVector.size(); j < m; j++ )
+        for( int j = 0, m = (int)aVector.size(); j < m; j++ ) //!< TODO: conversion from size_t to int
         {
           std::string aStr = aVector[j];
           if( aStr.compare( theName ) == 0 )
@@ -3065,10 +2875,10 @@ void SALOMEDSImpl_Study::ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* the
       std::string aNewString, aCurrentString = aStringAttr->Value();
 
       std::vector< std::vector<std::string> > aSections = ParseVariables( aCurrentString );
-      for( int i = 0, n = aSections.size(); i < n; i++ )
+      for( int i = 0, n = (int)aSections.size(); i < n; i++ ) //!< TODO: conversion from size_t to int
       {
         std::vector<std::string> aVector = aSections[i];
-        for( int j = 0, m = aVector.size(); j < m; j++ )
+        for( int j = 0, m = (int)aVector.size(); j < m; j++ ) //!< TODO: conversion from size_t to int
         {
           std::string aStr = aVector[j];
           if( aStr.compare( theSource ) == 0 )
@@ -3182,7 +2992,7 @@ bool SALOMEDSImpl_Study::removeSO_Notification (const SALOMEDSImpl_SObject& theS
                pass the mofification reason
  */
 //============================================================================
-bool SALOMEDSImpl_Study::modifySO_Notification (const SALOMEDSImpl_SObject& theSObject, int reason) 
+bool SALOMEDSImpl_Study::modifySO_Notification (const SALOMEDSImpl_SObject& theSObject, int reason)
 {
   if(_notifier)
     return _notifier->modifySO_Notification(theSObject, reason);
@@ -3195,11 +3005,54 @@ bool SALOMEDSImpl_Study::modifySO_Notification (const SALOMEDSImpl_SObject& theS
  *  Purpose  : register a notifier
  */
 //============================================================================
-void SALOMEDSImpl_Study::setNotifier(SALOMEDSImpl_AbstractCallback* notifier) 
+void SALOMEDSImpl_Study::setNotifier(SALOMEDSImpl_AbstractCallback* notifier)
 {
   _notifier=notifier;
 }
 
+static SALOMEDSImpl_AbstractCallback* & getGenObjRegister( DF_Document* doc )
+{
+  static std::vector< SALOMEDSImpl_AbstractCallback* > _genObjRegVec;
+  if ( doc->GetDocumentID() >= (int)_genObjRegVec.size() )
+    _genObjRegVec.resize( doc->GetDocumentID() + 1, 0 );
+  return _genObjRegVec[ doc->GetDocumentID() ];
+}
+
+//================================================================================
+/*!
+ * \brief Stores theRegister
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::setGenObjRegister(SALOMEDSImpl_AbstractCallback* theRegister)
+{
+  getGenObjRegister( _doc ) = theRegister;
+}
+
+//================================================================================
+/*!
+ * \brief Indirectly invokes GenericObj_i::Register()
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::RegisterGenObj  (const std::string& theIOR, DF_Label label)
+{
+  if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
+    goRegister->RegisterGenObj( theIOR );
+}
+
+//================================================================================
+/*!
+ * \brief Indirectly invokes GenericObj_i::UnRegister()
+ */
+//================================================================================
+
+void SALOMEDSImpl_Study::UnRegisterGenObj(const std::string& theIOR, DF_Label label)
+{
+  if ( SALOMEDSImpl_AbstractCallback* goRegister = getGenObjRegister( label.GetDocument() ))
+    goRegister->UnRegisterGenObj( theIOR );
+}
+
 //#######################################################################################################
 //#                                     STATIC PRIVATE FUNCTIONS
 //#######################################################################################################
@@ -3214,7 +3067,7 @@ static void SaveAttributes(const SALOMEDSImpl_SObject& aSO, HDFgroup *hdf_group_
   hdf_size size[1];
   std::vector<DF_Attribute*> attrList = aSO.GetLabel().GetAttributes();
   DF_Attribute* anAttr = NULL;
-  for(int i = 0, len = attrList.size(); i<len; i++) {
+  for(int i = 0, len = (int)attrList.size(); i<len; i++) { //!< TODO: conversion from size_t to int
     anAttr = attrList[i];
     //The following attributes are not supposed to be written to the file
     std::string type = SALOMEDSImpl_GenericAttribute::Impl_GetType(anAttr);
@@ -3247,7 +3100,7 @@ static void ReadAttributes(SALOMEDSImpl_Study* theStudy,
     anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
   }
   else if (!strcmp(hdf_dataset->GetName(),"AttributeReference") ||
-           !strcmp(hdf_dataset->GetName(),"Reference")) { // Old format maintainance
+           !strcmp(hdf_dataset->GetName(),"Reference")) { // Old format maintenance
     theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
     delete [] (current_string);
     hdf_dataset->CloseOnDisk();
@@ -3408,4 +3261,3 @@ void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup)
 
   theGroup->CloseOnDisk();
 }
-