Salome HOME
Remove trailing space.
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyBuilder.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 69e7cc7..911bb63
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024  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
@@ -52,11 +52,11 @@ static void Translate_persistentID_to_IOR(DF_Label& Lab, SALOMEDSImpl_Driver* dr
 //============================================================================
 SALOMEDSImpl_StudyBuilder::SALOMEDSImpl_StudyBuilder(const SALOMEDSImpl_Study* theOwner)
 {
-   _errorCode = "";
+  _errorCode = "";
   _callbackOnAdd=NULL;
   _callbackOnRemove = NULL;
-   _study = (SALOMEDSImpl_Study*)theOwner;
-   _doc = _study->GetDocument();
+  _study = (SALOMEDSImpl_Study*)theOwner;
+  _doc = _study->GetDocument();
 }
 
 //============================================================================
@@ -323,8 +323,8 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO,
     //Open the Study HDF file 
     HDFfile *hdf_file = new HDFfile((char*)aHDFUrl.c_str()); 
 
-    char aMultifileState[2];
-    char ASCIIfileState[2];
+    char aMultifileState[2] = { '0','0' };
+    char ASCIIfileState[2] = { '0','0' };
     bool hasModuleData = false;
     try {
       std::string scoid = anSCO.GetID();
@@ -336,7 +336,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO,
       hasModuleData = true;
 
       unsigned char* aStreamFile = NULL;
-      int aStreamSize = 0;
+      long aStreamSize = 0;
 
       if (hdf_sco_group->ExistInternalObject("FILE_STREAM")) {
         HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group);
@@ -350,21 +350,29 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO,
       } else
         aStreamFile = NULL;
 
-      HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
-      multifile_hdf_dataset->OpenOnDisk();
-      multifile_hdf_dataset->ReadFromDisk(aMultifileState);
+      if (hdf_sco_group->ExistInternalObject("MULTIFILE_STATE")) {
+        HDFdataset *multifile_hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group);
+        multifile_hdf_dataset->OpenOnDisk();
+        multifile_hdf_dataset->ReadFromDisk(aMultifileState);
+        multifile_hdf_dataset->CloseOnDisk();
+        multifile_hdf_dataset = 0;
+      }
 
-      HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
-      ascii_hdf_dataset->OpenOnDisk();
-      ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
+      if (hdf_sco_group->ExistInternalObject("ASCII_STATE")) {
+        HDFdataset *ascii_hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group);
+        ascii_hdf_dataset->OpenOnDisk();
+        ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
+        ascii_hdf_dataset->CloseOnDisk();
+        ascii_hdf_dataset = 0;
+      }
 
       std::string aDir = SALOMEDSImpl_Tool::GetDirFromPath(Res);
 
       bool aResult = true;
       if(aStreamFile && aStreamSize > 0 ) {
         aResult = (ASCIIfileState[0]=='A')?
-        aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir.c_str(), aMultifileState[0]=='M'):
-        aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir.c_str(), aMultifileState[0]=='M');
+        aDriver->LoadASCII(anSCO, aStreamFile, aStreamSize, aDir.c_str(), aMultifileState[0]=='M'): //!< TODO: conversion from size_t to const long
+        aDriver->Load(anSCO, aStreamFile, aStreamSize, aDir.c_str(), aMultifileState[0]=='M'); //!< TODO: conversion from size_t to const long
       }
 
       if(aStreamFile != NULL) delete []aStreamFile; 
@@ -378,11 +386,6 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO,
 
       //if(aDir != NULL) delete []aDir;
 
-      multifile_hdf_dataset->CloseOnDisk();
-      multifile_hdf_dataset = 0;
-      ascii_hdf_dataset->CloseOnDisk();
-      ascii_hdf_dataset = 0;
-
       hdf_sco_group->CloseOnDisk();
       hdf_sco_group = 0;
       hdf_group->CloseOnDisk();
@@ -436,7 +439,7 @@ bool SALOMEDSImpl_StudyBuilder::LoadWith(const SALOMEDSImpl_SComponent& anSCO,
  *  Purpose  : 
  */
 //============================================================================
-bool SALOMEDSImpl_StudyBuilder::Load(const SALOMEDSImpl_SObject& sco)
+bool SALOMEDSImpl_StudyBuilder::Load(const SALOMEDSImpl_SObject& /*sco*/)
 {
   _errorCode = "Not implemented";
   return false;
@@ -617,78 +620,6 @@ bool SALOMEDSImpl_StudyBuilder::RemoveReference(const SALOMEDSImpl_SObject& me)
   return true;
 }
 
-
-
-//============================================================================
-/*! Function : AddDirectory
- *  Purpose  : adds a new directory with a path = thePath
- */
-//============================================================================
-bool SALOMEDSImpl_StudyBuilder::AddDirectory(const std::string& thePath) 
-{
-  _errorCode = "";
-  CheckLocked();
-  if(thePath.empty()) {
-    _errorCode = "Invalid path";
-    return false;
-  }
-
-  std::string aPath(thePath), aContext(""), aFatherPath;
-  DF_Label aLabel;
-  SALOMEDSImpl_SObject anObject;
-
-  try { 
-    anObject = _study->FindObjectByPath(thePath); //Check if the directory already exists
-  }
-  catch(...) { }
-
-  if(anObject) {
-    _errorCode = "StudyNameAlreadyUsed";
-    return false; 
-  }
-
-  if(aPath[0] != '/') { //Relative path 
-    aPath.insert(aPath.begin(), '/');
-    aPath = _study->GetContext() + aPath;
-  }
-
-  std::vector<std::string> vs = SALOMEDSImpl_Tool::splitString(aPath, '/');
-  if(vs.size() == 1) 
-    aFatherPath = "/";
-  else {
-    for(int i = 0, len = vs.size()-1; i<len; i++) { 
-      aFatherPath += "/";
-      aFatherPath += vs[i];
-    }
-  }
-
-  try { 
-    anObject = _study->FindObjectByPath(aFatherPath); //Check if the father directory exists
-  }
-  catch(...) { ; }
-  if(!anObject) {
-    _errorCode = "StudyInvalidDirectory";
-    return false; 
-  }
-
-  SALOMEDSImpl_SObject aNewObject = NewObject(anObject);
-  aLabel = aNewObject.GetLabel();
-  if(aLabel.IsNull()) {
-    _errorCode = "StudyInvalidComponent";
-    return false;
-  }
-
-  SALOMEDSImpl_AttributeName::Set(aLabel, vs.back());
-
-  //Set LocalID attribute to identify the directory object
-  SALOMEDSImpl_AttributeLocalID::Set(aLabel, DIRECTORYID);
-  
-  _doc->SetModified(true); 
-  
-  return true;
-}
-
-
 //============================================================================
 /*! Function : SetGUID
  *  Purpose  : 
@@ -871,7 +802,7 @@ int  SALOMEDSImpl_StudyBuilder::UndoLimit()
  *  Purpose  : 
  */
 //============================================================================
-void SALOMEDSImpl_StudyBuilder::UndoLimit(int n)
+void SALOMEDSImpl_StudyBuilder::UndoLimit(int /*n*/)
 {
   _errorCode = "";
   CheckLocked();