-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+// Copyright (C) 2003-2007 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.
+// 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.
//
-// 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 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
+// 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/ or email : webmaster.salome@opencascade.com
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// File : SALOMEDSImpl_StudyBuilder.cxx
// Author : Sergey RUIN
// Module : SALOME
#include <stdlib.h>
#include <string.h>
-using namespace std;
-
#define USE_CASE_LABEL_TAG 2
#define DIRECTORYID 16661
#define FILELOCALID 26662
* Purpose : Create a new component (Scomponent)
*/
//============================================================================
-SALOMEDSImpl_SComponent SALOMEDSImpl_StudyBuilder::NewComponent(const string& DataType)
+SALOMEDSImpl_SComponent SALOMEDSImpl_StudyBuilder::NewComponent(const std::string& DataType)
{
_errorCode = "";
CheckLocked();
SALOMEDSImpl_SComponent so = _study->GetSComponent (NL);
if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so);
+ _study->addSO_Notification(so);
_doc->SetModified(true);
*/
//============================================================================
bool SALOMEDSImpl_StudyBuilder::DefineComponentInstance(const SALOMEDSImpl_SComponent& aComponent,
- const string& IOR)
+ const std::string& IOR)
{
_errorCode = "";
SALOMEDSImpl_SObject so = _study->GetSObject(NewLab);
if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so);
+ _study->addSO_Notification(so);
_doc->SetModified(true);
return so;
SALOMEDSImpl_SObject so = _study->GetSObject(NewLab);
if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so);
+ _study->addSO_Notification(so);
_doc->SetModified(true);
return so;
Lab.ForgetAllAttributes();
_doc->SetModified(true);
+ _study->removeSO_Notification(anObject);
return true;
}
Lab.ForgetAllAttributes(true);
_doc->SetModified(true);
+ _study->removeSO_Notification(anObject);
return true;
}
if (aLocked) _study->GetProperties()->SetLocked(false);
std::string Res(Att->Value());
- string aHDFPath(Res);
+ std::string aHDFPath(Res);
SALOMEDSImpl_AttributeComment* type = NULL;
std::string DataType;
DefineComponentInstance (anSCO, aDriver->GetIOR());
- string aHDFUrl;
+ std::string aHDFUrl;
bool isASCII = false;
if (HDFascii::isASCII(aHDFPath.c_str())) {
isASCII = true;
char aMultifileState[2];
char ASCIIfileState[2];
+ bool hasModuleData = false;
try {
- string scoid = anSCO.GetID();
+ std::string scoid = anSCO.GetID();
hdf_file->OpenOnDisk(HDF_RDONLY);
HDFgroup *hdf_group = new HDFgroup("DATACOMPONENT",hdf_file);
hdf_group->OpenOnDisk();
HDFgroup *hdf_sco_group = new HDFgroup((char*)scoid.c_str(), hdf_group);
hdf_sco_group->OpenOnDisk();
+ hasModuleData = true;
unsigned char* aStreamFile = NULL;
int aStreamSize = 0;
ascii_hdf_dataset->OpenOnDisk();
ascii_hdf_dataset->ReadFromDisk(ASCIIfileState);
- string aDir = SALOMEDSImpl_Tool::GetDirFromPath(Res);
+ std::string aDir = SALOMEDSImpl_Tool::GetDirFromPath(Res);
- bool aResult = (ASCIIfileState[0]=='A')?
+ 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');
+ }
if(aStreamFile != NULL) delete []aStreamFile;
delete hdf_file;
if (isASCII) {
- vector<string> aFilesToRemove;
+ std::vector<std::string> aFilesToRemove;
aFilesToRemove.push_back("hdf_from_ascii.hdf");
SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl),
aFilesToRemove, true);
delete hdf_file;
if (isASCII) {
- vector<string> aFilesToRemove;
+ std::vector<std::string> aFilesToRemove;
aFilesToRemove.push_back(aHDFUrl);
SALOMEDSImpl_Tool::RemoveTemporaryFiles(SALOMEDSImpl_Tool::GetDirFromPath(aHDFUrl), aFilesToRemove, true);
}
if (aLocked) _study->GetProperties()->SetLocked(true);
+
+ if (!hasModuleData)
+ return true;
+
_errorCode = "No persistent file";
return false;
}
*/
//============================================================================
DF_Attribute* SALOMEDSImpl_StudyBuilder::FindOrCreateAttribute(const SALOMEDSImpl_SObject& anObject,
- const string& aTypeOfAttribute)
+ const std::string& aTypeOfAttribute)
{
_errorCode = "";
if(!anObject) {
//Add checks for TreeNode and UserID attributes
if (strncmp(aTypeOfAttribute.c_str(), "AttributeTreeNode",17) == 0 ) {
- string aTreeNodeGUID;
+ std::string aTreeNodeGUID;
if (strcmp(aTypeOfAttribute.c_str(), "AttributeTreeNode") == 0) {
aTreeNodeGUID = SALOMEDSImpl_AttributeTreeNode::GetDefaultTreeID();
} else {
bool SALOMEDSImpl_StudyBuilder::FindAttribute(const SALOMEDSImpl_SObject& anObject,
DF_Attribute*& anAttribute,
- const string& aTypeOfAttribute)
+ const std::string& aTypeOfAttribute)
{
_errorCode = "";
if(!anObject) {
//============================================================================
bool SALOMEDSImpl_StudyBuilder::RemoveAttribute(const SALOMEDSImpl_SObject& anObject,
- const string& aTypeOfAttribute)
+ const std::string& aTypeOfAttribute)
{
_errorCode = "";
CheckLocked();
}
DF_Label Lab = anObject.GetLabel();
- if (aTypeOfAttribute == string("AttributeIOR")) { // Remove from IORLabel map
+ if (aTypeOfAttribute == std::string("AttributeIOR")) { // Remove from IORLabel map
SALOMEDSImpl_AttributeIOR* anAttr = NULL;
if ((anAttr=(SALOMEDSImpl_AttributeIOR*)Lab.FindAttribute(SALOMEDSImpl_AttributeIOR::GetID()))) {
_study->DeleteIORLabelMapItem(anAttr->Value());
Lab.ForgetAttribute (SALOMEDSImpl_SObject::GetGUID(aTypeOfAttribute));
_doc->SetModified(true);
+ _study->modifySO_Notification(anObject,0);
return true;
}
* Purpose : adds a new directory with a path = thePath
*/
//============================================================================
-bool SALOMEDSImpl_StudyBuilder::AddDirectory(const string& thePath)
+bool SALOMEDSImpl_StudyBuilder::AddDirectory(const std::string& thePath)
{
_errorCode = "";
CheckLocked();
return false;
}
- string aPath(thePath), aContext(""), aFatherPath;
+ std::string aPath(thePath), aContext(""), aFatherPath;
DF_Label aLabel;
SALOMEDSImpl_SObject anObject;
aPath = _study->GetContext() + aPath;
}
- vector<string> vs = SALOMEDSImpl_Tool::splitString(aPath, '/');
+ std::vector<std::string> vs = SALOMEDSImpl_Tool::splitString(aPath, '/');
if(vs.size() == 1)
aFatherPath = "/";
else {
*/
//============================================================================
bool SALOMEDSImpl_StudyBuilder::SetGUID(const SALOMEDSImpl_SObject& anObject,
- const string& theGUID)
+ const std::string& theGUID)
{
_errorCode = "";
CheckLocked();
*/
//============================================================================
bool SALOMEDSImpl_StudyBuilder::IsGUID(const SALOMEDSImpl_SObject& anObject,
- const string& theGUID)
+ const std::string& theGUID)
{
_errorCode = "";
if(!anObject) {
*/
//============================================================================
bool SALOMEDSImpl_StudyBuilder::SetName(const SALOMEDSImpl_SObject& theSO,
- const string& theValue)
+ const std::string& theValue)
{
_errorCode = "";
CheckLocked();
*/
//============================================================================
bool SALOMEDSImpl_StudyBuilder::SetComment(const SALOMEDSImpl_SObject& theSO,
- const string& theValue)
+ const std::string& theValue)
{
_errorCode = "";
CheckLocked();
*/
//============================================================================
bool SALOMEDSImpl_StudyBuilder::SetIOR(const SALOMEDSImpl_SObject& theSO,
- const string& theValue)
+ const std::string& theValue)
{
_errorCode = "";
CheckLocked();
if ((anID=(SALOMEDSImpl_AttributeLocalID*)current.FindAttribute(SALOMEDSImpl_AttributeLocalID::GetID())))
if (anID->Value() == FILELOCALID) continue; //SRN: This attribute store a file name, skip it
- string persist_ref = Att->Value();
+ std::string persist_ref = Att->Value();
SALOMEDSImpl_SObject so = SALOMEDSImpl_Study::SObject(current);
- string ior_string = driver->LocalPersistentIDToIOR(so,
+ std::string ior_string = driver->LocalPersistentIDToIOR(so,
persist_ref,
isMultiFile,
isASCII);