-// 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
//============================================================================
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();
}
//============================================================================
//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();
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);
} 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;
//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();
* Purpose :
*/
//============================================================================
-bool SALOMEDSImpl_StudyBuilder::Load(const SALOMEDSImpl_SObject& sco)
+bool SALOMEDSImpl_StudyBuilder::Load(const SALOMEDSImpl_SObject& /*sco*/)
{
_errorCode = "Not implemented";
return false;
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 :
* Purpose :
*/
//============================================================================
-void SALOMEDSImpl_StudyBuilder::UndoLimit(int n)
+void SALOMEDSImpl_StudyBuilder::UndoLimit(int /*n*/)
{
_errorCode = "";
CheckLocked();