Salome HOME
Merge changes from 'master' branch.
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_Study.cxx
index 773f16e5fa3354676d9a6a6fa3fac726c5c572c6..e0814bab1cbdba125d84602545e03a093a6d0347 100644 (file)
@@ -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:
@@ -349,7 +349,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();
@@ -400,7 +400,7 @@ 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 ];
@@ -421,7 +421,7 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
     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
@@ -438,13 +438,13 @@ bool SALOMEDSImpl_Study::Impl_SaveProperties(HDFgroup *hdf_group)
     a = strlen(aProperty);
   }
 
-  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()));
+            (char*)(versionsIt->second.c_str()));
     a = a + versionsIt->first.size() + versionsIt->second.size() + 1;
     aProperty[a++] = 1;
   }
@@ -479,9 +479,9 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
 
   // HDF File will be composed of differents 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 = "";
 
@@ -534,10 +534,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";
@@ -550,7 +550,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 evrything??
     hdf_file = new HDFfile((char*)aUrl.c_str());
     hdf_file->CreateOnDisk();
 
@@ -570,8 +570,8 @@ bool SALOMEDSImpl_Study::Impl_SaveAs(const std::string& aStudyUrl,
       std::string componentDataType = sco.ComponentDataType();
       std::string IOREngine;
       if (sco.ComponentIOR(IOREngine)) {
-        // Engine should be already in the map as it was to added before
-        SALOMEDSImpl_Driver* Engine = aMapTypeDriver[componentDataType];
+       // Engine should be already in the map as it was to added before
+       SALOMEDSImpl_Driver* Engine = aMapTypeDriver[componentDataType];
         if (Engine != NULL) {
           SALOMEDSImpl_TMPFile* aStream = NULL;
           long length = 0;
@@ -613,7 +613,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);
         }
       }
@@ -816,6 +816,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;
 }
 
@@ -829,7 +833,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;
@@ -3027,7 +3031,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();