The regression was caused by last refactoring of SALOMEDS concerning improving memory menagement.
Bug PAL7023 - Problem loading MED file with a large number of families (same as VISU6154))
void SALOMEDS_AttributeIOR_i::SetValue(const char* value)
{
CheckLocked();
- const CORBA::ORB_var& anORB = _mySObject->GetORB();
- SALOMEDS::Study_var aStudy = SALOMEDS_Study_i::GetStudy(_myAttr->Label(),anORB);
+ SALOMEDS_Study_i* aStudy = _mySObject->GetStudyServant();
aStudy->AddCreatedPostponed(value);
aStudy->AddPostponed(Value());
CORBA::String_var Str = CORBA::string_dup(value);
Handle(TDataStd_Comment)::DownCast(_myAttr)->Set(TCollection_ExtendedString(Str));
- SALOMEDS_Study_i::IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr),anORB);
+ aStudy->IORUpdated(Handle(SALOMEDS_IORAttribute)::DownCast(_myAttr));
}
_lab(theLabel),
_study(theStudy)
{
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(theLabel,anEntry);
}
//============================================================================
//============================================================================
void SALOMEDS_ChildIterator_i::Init()
{
- _it.Initialize (_lab);
+ _it.Initialize(_lab);
}
//============================================================================
*
*/
//============================================================================
-void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean allLevels)
+void SALOMEDS_ChildIterator_i::InitEx(CORBA::Boolean theIsAllLevels)
{
- _it.Initialize (_lab, allLevels);
+ _it.Initialize(_lab,theIsAllLevels);
}
//============================================================================
void SALOMEDS_ChildIterator_i::Next()
{
_it.Next();
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(_it.Value(),anEntry);
}
return SALOMEDS_SObject_i::NewRef(_study,_it.Value())._retn();
}
+SALOMEDS_SObject_i* SALOMEDS_ChildIterator_i::GetValue()
+{
+ return SALOMEDS_SObject_i::NewPtr(_study,_it.Value());
+}
#include <TDF_Label.hxx>
class SALOMEDS_Study_i;
+class SALOMEDS_SObject_i;
class SALOMEDS_ChildIterator_i: public POA_SALOMEDS::ChildIterator,
public PortableServer::RefCountServantBase
~SALOMEDS_ChildIterator_i();
- TDF_Label GetValue() { return _it.Value();}
+ SALOMEDS_SObject_i* GetValue();
virtual void Init();
virtual void InitEx(CORBA::Boolean);
// Module : SALOME
// $Header$
-#include "SALOMEDS_IORAttribute.ixx"
#include <TDataStd_Comment.hxx>
#include <TCollection_ExtendedString.hxx>
+
+#include "SALOMEDS_IORAttribute.ixx"
#include "SALOMEDS_Study_i.hxx"
+
using namespace std;
//=======================================================================
Handle(SALOMEDS_IORAttribute) SALOMEDS_IORAttribute::Set (const TDF_Label& L,
const TCollection_ExtendedString& S,
- CORBA::ORB_ptr orb)
+ SALOMEDS_Study_i* theStudy)
{
Handle(SALOMEDS_IORAttribute) A;
if (!L.FindAttribute(SALOMEDS_IORAttribute::GetID(),A)) {
}
(Handle(TDataStd_Comment)::DownCast(A))->Set (S);
- SALOMEDS_Study_i::IORUpdated(A,orb);
+ theStudy->IORUpdated(A);
return A;
}
class TCollection_ExtendedString;
class TDF_Attribute;
class TDF_RelocationTable;
-
+class SALOMEDS_Study_i;
class SALOMEDS_IORAttribute : public TDataStd_Comment {
// Methods PUBLIC
//
Standard_EXPORT static const Standard_GUID& GetID() ;
-Standard_EXPORT static Handle_SALOMEDS_IORAttribute Set(const TDF_Label& label,const TCollection_ExtendedString& string, CORBA::ORB_ptr orb) ;
+Standard_EXPORT static Handle_SALOMEDS_IORAttribute Set(const TDF_Label& label,
+ const TCollection_ExtendedString& string,
+ SALOMEDS_Study_i* theStudy) ;
Standard_EXPORT SALOMEDS_IORAttribute();
Standard_EXPORT const Standard_GUID& ID() const;
Standard_EXPORT void Restore(const Handle(TDF_Attribute)& with) ;
if(anIter != anSObjectMap.end())
aSObjectHolder = anIter->second;
else{
- TCollection_AsciiString anEntry;
- TDF_Tool::Entry(theLabel,anEntry);
SALOMEDS_SObject_i* aSObject = new SALOMEDS_SObject_i(theStudy,theLabel);
aSObjectHolder.first = aSObject;
aSObjectHolder.second = aSObject->_this();
anSObjectMap[theLabel] = aSObjectHolder;
+
+ //TCollection_AsciiString anEntry;
+ //TDF_Tool::Entry(theLabel,anEntry);
+ //cout<<"APO - SALOMEDS_SObject_i::New - anEntry = "<<anEntry.ToCString()<<endl;
}
return aSObjectHolder;
}
* Purpose : Returns list of all attributes for this sobject
*/
//============================================================================
-SALOMEDS_GenericAttribute_i*
+SALOMEDS_SObject_i::TAttrHolder
SALOMEDS_SObject_i::_FindGenAttribute(const Handle(TDF_Attribute)& theAttr)
{
- SALOMEDS_GenericAttribute_i* anGenAttr = NULL;
+ TAttrHolder anGenAttr;
Standard_GUID aGUID = theAttr->ID();
if(anIter != myAttrMap.end())
anGenAttr = anIter->second;
- if(anGenAttr != NULL){
- if(anGenAttr->GetAttribute() != theAttr)
- anGenAttr->SetAttribute(theAttr);
+ SALOMEDS_GenericAttribute_i* anAttr = anGenAttr.first;
+ if(anAttr != NULL){
+ if(anAttr->GetAttribute() != theAttr)
+ anAttr->SetAttribute(theAttr);
}else{
anGenAttr = _CreateGenAttribute(theAttr,anAttributeID.c_str());
}
Standard_Integer i = 0;
for(TDF_AttributeIterator iter(_lab); iter.More(); iter.Next()) {
Handle(TDF_Attribute) anAttr = iter.Value();
- if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(anAttr))
+ TAttrHolder anAttrHolder = _FindGenAttribute(anAttr);
+ SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second;
+ if(!anGenAttr->_is_nil())
{
aSeqOfAttr->length(++i);
- aSeqOfAttr[i-1] = anGenAttr->_this();
+ aSeqOfAttr[i-1] = anGenAttr._retn();
}
}
}
* Purpose : Find attribute of given type on this SObject
*/
//============================================================================
-SALOMEDS_GenericAttribute_i*
+SALOMEDS_SObject_i::TAttrHolder
SALOMEDS_SObject_i::_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
const char* theType)
{
-
+ SALOMEDS_GenericAttribute_i* anAttr;
TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
if(anIter != __AttrID2FunMap__.end()){
const TAttrID2FunMap::data_type& aValue = anIter->second;
if(aValue.myIsCheckLockedStudy())
_study->CheckLocked();
- return aValue.myNewInstance(theAttr,this);
+ anAttr = aValue.myNewInstance(theAttr,this);
+ return TAttrHolder(anAttr,anAttr->_this());
}
if(strncmp(theType,"AttributeTreeNode",17) == 0){
- return new SALOMEDS_AttributeTreeNode_i(theAttr,this);
+ anAttr = new SALOMEDS_AttributeTreeNode_i(theAttr,this);
+ return TAttrHolder(anAttr,anAttr->_this());
}
if(strncmp(theType,"AttributeUserID",15) == 0){
- return new SALOMEDS_AttributeUserID_i(theAttr,this);
+ anAttr = new SALOMEDS_AttributeUserID_i(theAttr,this);
+ return TAttrHolder(anAttr,anAttr->_this());
}
- return NULL;
+ return TAttrHolder();
}
-SALOMEDS_GenericAttribute_i*
+SALOMEDS_SObject_i::TAttrHolder
SALOMEDS_SObject_i::_FindGenAttribute(const char* theType)
{
- SALOMEDS_GenericAttribute_i* anGenAttr = NULL;
+ TAttrHolder anAttrHolder;
TAttrMap::const_iterator anIter = myAttrMap.find(theType);
if(anIter != myAttrMap.end())
- anGenAttr = anIter->second;
+ anAttrHolder = anIter->second;
Standard_GUID aGUID = ::GetGUID(theType);
Handle(TDF_Attribute) anAttr;
if(_lab.FindAttribute(aGUID,anAttr)){
- if(anGenAttr != NULL){
- if(anGenAttr->GetAttribute() != anAttr)
- anGenAttr->SetAttribute(anAttr);
+ SALOMEDS_GenericAttribute_i* aGenAttr = anAttrHolder.first;
+ if(aGenAttr != NULL){
+ if(aGenAttr->GetAttribute() != anAttr)
+ aGenAttr->SetAttribute(anAttr);
}else{
- anGenAttr = _CreateGenAttribute(anAttr,theType);
+ anAttrHolder = _CreateGenAttribute(anAttr,theType);
}
- if(anGenAttr != NULL)
- myAttrMap[theType] = anGenAttr;
+ aGenAttr = anAttrHolder.first;
+ if(aGenAttr != NULL)
+ myAttrMap[theType] = anAttrHolder;
}else{
myAttrMap.erase(theType);
//if(anGenAttr != NULL)
// anGenAttr->Destroy();
+ return TAttrHolder();
}
- return anGenAttr;
+ return anAttrHolder;
}
SALOMEDS::GenericAttribute_ptr
SALOMEDS_SObject_i::_FindCORBAAttribute(const char* theType)
{
- if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(theType))
- return anGenAttr->_this();
+ TAttrHolder anAttr = _FindGenAttribute(theType);
+ SALOMEDS::GenericAttribute_var anGenAttr = anAttr.second;
+ if(!CORBA::is_nil(anGenAttr)){
+ return anGenAttr._retn();
+ }
+
return SALOMEDS::GenericAttribute::_nil();
}
SALOMEDS::GenericAttribute_ptr
SALOMEDS_SObject_i::FindOrCreateAttribute(const char* theType)
{
- if(SALOMEDS_GenericAttribute_i* anGenAttr = _FindGenAttribute(theType))
- return anGenAttr->_this();
+ TAttrHolder anAttrHolder = _FindGenAttribute(theType);
+ SALOMEDS::GenericAttribute_var anGenAttr = anAttrHolder.second;
+ if(!anGenAttr->_is_nil())
+ return anGenAttr._retn();
+
Handle(TDF_Attribute) anAttr = _AddAttribute(theType);
if(!anAttr.IsNull()){
- if(SALOMEDS_GenericAttribute_i* anGenAttr = _CreateGenAttribute(anAttr,theType)){
- return anGenAttr->_this();
- }
+ anAttrHolder = _CreateGenAttribute(anAttr,theType);
+ anGenAttr = anAttrHolder.second;
+ if(!anGenAttr->_is_nil())
+ return anGenAttr._retn();
}
+
return SALOMEDS::GenericAttribute::_nil();
}
_lab.ForgetAttribute(::GetGUID(theType));
}
+
+void SALOMEDS_SObject_i::OnRemove()
+{
+ Handle(TDF_Reference) aReference;
+ if(_lab.FindAttribute(TDF_Reference::GetID(),aReference)){
+ Handle(SALOMEDS_TargetAttribute) aTarget;
+ if(aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
+ aTarget->Remove(_lab);
+ }
+
+ Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
+ if(_lab.FindAttribute(SALOMEDS_IORAttribute::GetID(),anAttr)){
+ _study->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+ }
+
+ myAttrMap.clear();
+
+ SALOMEDS_Study_i::TSObjectMap& anSObjectMap = _study->GetSObjectMap();
+ anSObjectMap.erase(_lab);
+}
FindOrCreateAttribute(const char* theTypeOfAttribute);
void RemoveAttribute(const char* theTypeOfAttribute);
+ void OnRemove();
SALOMEDS_Study_i* GetStudyServant(){ return _study;}
+ TDF_Label GetLabel(){ return _lab;}
+
CORBA::ORB_var GetORB() const;
PortableServer::POA_var GetPOA() const;
protected:
friend class SALOMEDS_GenericAttribute_i;
- SALOMEDS_GenericAttribute_i*
+ typedef std::string TAttributeID;
+ typedef std::pair<SALOMEDS_GenericAttribute_i*,SALOMEDS::GenericAttribute_var> TAttrHolder;
+ typedef std::map<TAttributeID,TAttrHolder> TAttrMap;
+ TAttrMap myAttrMap;
+
+ TAttrHolder
_FindGenAttribute(const Handle(TDF_Attribute)& theAttr);
- SALOMEDS_GenericAttribute_i*
+ TAttrHolder
_CreateGenAttribute(const Handle(TDF_Attribute)& theAttr,
const char* theTypeOfAttribute);
- SALOMEDS_GenericAttribute_i*
+ TAttrHolder
_FindGenAttribute(const char* theTypeOfAttribute);
SALOMEDS::GenericAttribute_ptr
std::string _name;
TDF_Label _lab;
- typedef std::string TAttributeID;
- typedef SALOMEDS_GenericAttribute_i* TAttrHolder;
- typedef std::map<TAttributeID,TAttrHolder> TAttrMap;
- TAttrMap myAttrMap;
-
SALOMEDS_SObject_i(SALOMEDS_Study_i* theStudy,
const TDF_Label& theLabel);
#include "SALOMEDS_SObject_i.hxx"
#include "SALOMEDS_SComponent_i.hxx"
+#include "SALOMEDS_ChildIterator_i.hxx"
#include "SALOMEDS_TargetAttribute.hxx"
#include "SALOMEDS_IORAttribute.hxx"
//add theObject definition
aString = GetORB()->object_to_string(theObject);
- SALOMEDS_IORAttribute::Set(Lab,const_cast<char*>(aString.in()),GetORB());
+ SALOMEDS_IORAttribute::Set(Lab,const_cast<char*>(aString.in()),_study);
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::RemoveObject(SALOMEDS::SObject_ptr theSObject)
{
- CheckLocked();
-
- if(CORBA::is_nil(theSObject))
- return;
-
- OnRemoveSObject(theSObject);
-
- TDF_Label Lab;
- CORBA::String_var aString(theSObject->GetID());
- TDF_Tool::Label(_doc->GetData(),const_cast<char*>(aString.in()),Lab);
+ RemoveSObject(theSObject);
+}
- Handle(TDF_Reference) aReference;
- if(Lab.FindAttribute(TDF_Reference::GetID(),aReference)){
- Handle(SALOMEDS_TargetAttribute) aTarget;
- if(aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
- aTarget->Remove(Lab);
- }
+SALOMEDS_SObject_i*
+SALOMEDS_StudyBuilder_i::RemoveSObject(SALOMEDS::SObject_ptr theSObject,
+ bool theIsForgetAllAttributes)
+{
+ CheckLocked();
- Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
- if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){
- SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB());
- aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+ if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theSObject)){
+ OnRemoveSObject(theSObject);
+ aSObject->OnRemove();
+ if(theIsForgetAllAttributes){
+ TDF_Label aLabel = aSObject->GetLabel();
+ aLabel.ForgetAllAttributes();
+ }
+ return aSObject;
}
- Lab.ForgetAllAttributes();
+ return NULL;
}
//============================================================================
//============================================================================
void SALOMEDS_StudyBuilder_i::RemoveObjectWithChildren(SALOMEDS::SObject_ptr theSObject)
{
- CheckLocked();
-
- if(CORBA::is_nil(theSObject))
- return;
-
- OnRemoveSObject(theSObject);
-
- TDF_Label Lab;
- CORBA::String_var aString(theSObject->GetID());
- TDF_Tool::Label(_doc->GetData(),aString,Lab);
-
- Handle(TDF_Reference) aReference;
- if (Lab.FindAttribute(TDF_Reference::GetID(), aReference)) {
- Handle(SALOMEDS_TargetAttribute) aTarget;
- if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
- aTarget->Remove(Lab);
- }
-
- Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
- if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){
- SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB());
- aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
- }
-
- TDF_ChildIterator it(Lab, Standard_True);
- for(;it.More();it.Next()) {
- TDF_Label aLabel = it.Value();
-
- if (aLabel.FindAttribute(TDF_Reference::GetID(), aReference)) {
- Handle(SALOMEDS_TargetAttribute) aTarget;
- if (aReference->Get().FindAttribute(SALOMEDS_TargetAttribute::GetID(),aTarget))
- aTarget->Remove(aLabel);
- }
-
- Handle(SALOMEDS_IORAttribute) anAttr; // postponed removing of CORBA objects
- if (aLabel.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr)){
- SALOMEDS::Study_ptr aStudy = SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB());
- aStudy->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+ if(SALOMEDS_SObject_i* aSObject = RemoveSObject(theSObject,false)){
+ SALOMEDS_ChildIterator_i aChildIter(_study,aSObject->GetLabel(),true);
+ for(; aChildIter.More(); aChildIter.Next()){
+ if(SALOMEDS_SObject_i* aSObj = aChildIter.GetValue())
+ aSObj->OnRemove();
}
+ TDF_Label aLabel = aSObject->GetLabel();
+ aLabel.ForgetAllAttributes(Standard_True);
}
-
- Lab.ForgetAllAttributes(Standard_True);
}
//============================================================================
//============================================================================
static void Translate_persistentID_to_IOR(TDF_Label theLabel,
SALOMEDS::Driver_ptr theDriver,
- CORBA::ORB_ptr theORB,
SALOMEDS_Study_i* theStudy,
CORBA::Boolean theIsMultiFile,
CORBA::Boolean theIsASCII)
CORBA::String_var anIOR =
theDriver->LocalPersistentIDToIOR(aSObject,ch.ToCString(),theIsMultiFile,theIsASCII);
- SALOMEDS_IORAttribute::Set (aCurrentLabel,const_cast<char*>(anIOR.in()),theORB);
+ SALOMEDS_IORAttribute::Set(aCurrentLabel,const_cast<char*>(anIOR.in()),theStudy);
}
- Translate_persistentID_to_IOR(aCurrentLabel,theDriver,theORB,theStudy,theIsMultiFile,theIsASCII);
+ Translate_persistentID_to_IOR(aCurrentLabel,theDriver,theStudy,theIsMultiFile,theIsASCII);
}
}
if(CORBA::is_nil(theDriver))
return;
- int aLocked = theSComponent->GetStudy()->GetProperties()->IsLocked();
+ int aLocked = _study->GetProperties()->IsLocked();
if(aLocked)
- theSComponent->GetStudy()->GetProperties()->SetLocked(false);
+ _study->GetProperties()->SetLocked(false);
// mpv 06.03.2003: SAL1927 - if component data if already loaded, it is not necessary to do it again
if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), Att)) {
if(aLocked)
- theSComponent->GetStudy()->GetProperties()->SetLocked(true);
+ _study->GetProperties()->SetLocked(true);
return;
}
DefineComponentInstance (theSComponent,theDriver);
SALOMEDS_Tool::RemoveTemporaryFiles(aDir,aFilesToRemove,true);
}
if(aLocked)
- theSComponent->GetStudy()->GetProperties()->SetLocked(true);
+ _study->GetProperties()->SetLocked(true);
THROW_SALOME_CORBA_EXCEPTION("No persistent file Name found",SALOME::BAD_PARAM);
}
try {
- Translate_persistentID_to_IOR(Lab,theDriver,GetORB(),_study, aMultifileState[0]=='M', ASCIIfileState[0] == 'A');
+ Translate_persistentID_to_IOR(Lab,theDriver,_study,aMultifileState[0]=='M',ASCIIfileState[0] == 'A');
} catch (SALOME::SALOME_Exception) {
INFOS("Can't translate PersRef to IOR");
if (aLocked)
- theSComponent->GetStudy()->GetProperties()->SetLocked(true);
+ _study->GetProperties()->SetLocked(true);
THROW_SALOME_CORBA_EXCEPTION("Unable to convert component persistent data to the transient",SALOME::BAD_PARAM);
// throw HDFexception("Unable to load component data");
}
if(aLocked)
- theSComponent->GetStudy()->GetProperties()->SetLocked(true);
+ _study->GetProperties()->SetLocked(true);
} else
MESSAGE("No persistent file Name");
}
SALOMEDS_StudyBuilder_i::FindOrCreateAttribute(SALOMEDS::SObject_ptr theObject,
const char* theTypeOfAttribute)
{
- if(!CORBA::is_nil(theObject)){
- PortableServer::POA_var aPOA = GetPOA();
- PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theObject,aPOA);
- if(aServant.in() != NULL){
- if(SALOMEDS_SObject_i* anSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in())){
- return anSObject->FindOrCreateAttribute(theTypeOfAttribute);
- }
- }
- }
+ if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject))
+ return aSObject->FindOrCreateAttribute(theTypeOfAttribute);
+
return SALOMEDS::GenericAttribute::_nil();
}
SALOMEDS::GenericAttribute_out theAttr,
const char* theTypeOfAttribute)
{
- if(!CORBA::is_nil(theObject)){
- PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theObject,GetPOA());
- if(aServant.in() != NULL){
- if(SALOMEDS_SObject_i* anSObject = dynamic_cast<SALOMEDS_SObject_i*>(aServant.in())){
- return anSObject->FindAttribute(theAttr,theTypeOfAttribute);
- }
- }
- }
+ if(SALOMEDS_SObject_i* aSObject = _study->DownCast(theObject))
+ return aSObject->FindAttribute(theAttr,theTypeOfAttribute);
+
return Standard_False;
}
if (strcmp(aTypeOfAttribute, "AttributeIOR") == 0) { // postponed removing of CORBA objects
Handle(SALOMEDS_IORAttribute) anAttr;
if (Lab.FindAttribute(SALOMEDS_IORAttribute::GetID(), anAttr))
- SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
- else return;
+ _study->AddPostponed(TCollection_AsciiString(anAttr->Get()).ToCString());
+ else
+ return;
}
Lab.ForgetAttribute(SALOMEDS::GetGUID(aTypeOfAttribute));
Handle(TDataStd_Name) aName;
TDF_Label aLabel;
SALOMEDS::SObject_var anObject = SALOMEDS_SObject_i::NewRef(_study,_doc->Main());
- SALOMEDS::Study_var aStudy = anObject->GetStudy();
try {
- anObject = aStudy->FindObjectByPath(thePath); //Check if the directory already exists
+ anObject = _study->FindObjectByPath(thePath); //Check if the directory already exists
}
catch(...) { }
if(aPath.Value(1) != '/') { //Relative path
aPath.Prepend('/');
- aPath = TCollection_AsciiString(aStudy->GetContext()) + aPath;
+ aPath = TCollection_AsciiString(_study->GetContext()) + aPath;
}
TCollection_AsciiString aToken = aPath.Token("/", 1);
anObject = SALOMEDS::SObject::_nil();
try {
- anObject = aStudy->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists
+ anObject = _study->FindObjectByPath(aFatherPath.ToCString()); //Check if the father directory exists
}
catch(...) { ; }
if(anObject->_is_nil())
AbortCommand();
throw SALOMEDS::StudyBuilder::LockProtection();
} else {
- SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->RemovePostponed(_doc->GetUndoLimit());
+ _study->RemovePostponed(_doc->GetUndoLimit());
int aModif = anAttr->GetModified();
if (aModif < 0) aModif = 1000; // if user make undo and then - new transaction "modify" will never be zero
//============================================================================
void SALOMEDS_StudyBuilder_i::AbortCommand()
{
- SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(0);
+ _study->UndoPostponed(0);
_doc->AbortCommand();
}
MESSAGE("Locked document modification !!!");
throw SALOMEDS::StudyBuilder::LockProtection();
} else {
- SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(1);
+ _study->UndoPostponed(1);
_doc->Undo();
anAttr->SetModified(anAttr->GetModified()-1);
}
throw SALOMEDS::StudyBuilder::LockProtection();
} else {
_doc->Redo();
- SALOMEDS_Study_i::GetStudy(_doc->Main(),GetORB())->UndoPostponed(-1);
+ _study->UndoPostponed(-1);
anAttr->SetModified(anAttr->GetModified()+1);
}
}
TDF_Label aLabel;
CORBA::String_var aSOID = theSO->GetID();
TDF_Tool::Label(_doc->GetData(), aSOID, aLabel);
- SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue),GetORB());
+ SALOMEDS_IORAttribute::Set(aLabel, TCollection_ExtendedString((char*)theValue),_study);
}
#include <TDocStd_Document.hxx>
class SALOMEDS_Study_i;
+class SALOMEDS_SObject_i;
class SALOMEDS_Callback_i;
class SALOMEDS_StudyBuilder_i: public virtual POA_SALOMEDS::StudyBuilder,
throw(SALOME::SALOME_Exception);
virtual void Load(SALOMEDS::SObject_ptr sco);
+ SALOMEDS_SObject_i* RemoveSObject(SALOMEDS::SObject_ptr theSObject,
+ bool theIsForgetAllAttributes = true);
virtual void RemoveObject(SALOMEDS::SObject_ptr anObject);
virtual void RemoveObjectWithChildren(SALOMEDS::SObject_ptr anObject);
#include "SALOMEDS_StudyManager_i.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
-#include "SALOMEDS_SObject_i.hxx"
+
#include "SALOMEDS_Study_i.hxx"
+#include "SALOMEDS_SObject_i.hxx"
+#include "SALOMEDS_StudyBuilder_i.hxx"
#include "SALOMEDS_IORAttribute.hxx"
#include "SALOMEDS_PersRefAttribute.hxx"
//===========================================================================
//Function : LoadAttributes
//===========================================================================
-static void ReadAttributes(SALOMEDS::Study_ptr theStudy,
- SALOMEDS::SObject_ptr aSO,
- HDFdataset* hdf_dataset)
+static
+void
+ReadAttributes(SALOMEDS_Study_i* theStudy,
+ SALOMEDS::SObject_ptr aSO,
+ HDFdataset* hdf_dataset)
{
hdf_dataset->OpenOnDisk();
hdf_dataset->ReadFromDisk(current_string);
if (!strcmp(hdf_dataset->GetName(),"COMPONENTDATATYPE")) {
- anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
+ anAttr = theStudy->GetBuilder()->FindOrCreateAttribute(aSO, "AttributeComment");
} else if (!strcmp(hdf_dataset->GetName(),"Reference")) {
- theStudy->NewBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
+ theStudy->GetBuilder()->Addreference(aSO, theStudy->CreateObjectID(current_string));
delete(current_string);
hdf_dataset->CloseOnDisk();
return;
} else {
MESSAGE("Read attribute "<<hdf_dataset->GetName())
- anAttr = theStudy->NewBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
+ anAttr = theStudy->GetBuilder()->FindOrCreateAttribute(aSO, hdf_dataset->GetName());
}
if (!CORBA::is_nil(anAttr)) {
//============================================================================
//Function : Translate_IOR_to_persistentID
//============================================================================
-static void Translate_IOR_to_persistentID (SALOMEDS::Study_ptr theStudy,
- SALOMEDS::StudyBuilder_ptr theBuilder,
- SALOMEDS::SObject_ptr theSObject,
- SALOMEDS::Driver_ptr theEngine,
- CORBA::Boolean theIsMultiFile,
- CORBA::Boolean theIsASCII)
+static void Translate_IOR_to_persistentID(SALOMEDS_Study_i* theStudy,
+ SALOMEDS_StudyBuilder_i* theBuilder,
+ SALOMEDS::SObject_ptr theSObject,
+ SALOMEDS::Driver_ptr theEngine,
+ CORBA::Boolean theIsMultiFile,
+ CORBA::Boolean theIsASCII)
{
MESSAGE("In Translate_IOR_to_persistentID");
- SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator(theSObject);
- for (; anIter->More(); anIter->Next()){
+ SALOMEDS_ChildIterator_i anIter = theStudy->GetChildIterator(theSObject);
+ for(; anIter.More(); anIter.Next()){
SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::SObject_var aSObject = anIter->Value();
+ SALOMEDS::SObject_var aSObject = anIter.Value();
if(aSObject->FindAttribute(anAttr,"AttributeIOR")){
SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
CORBA::String_var aString = anIOR->Value();
//============================================================================
//Function : BuildlTree
//============================================================================
-static void BuildTree (SALOMEDS::Study_ptr theStudy,HDFgroup* hdf_current_group)
+static
+void
+BuildTree(SALOMEDS_Study_i* theStudy, HDFgroup* hdf_current_group)
{
hdf_current_group->OpenOnDisk();
else if (type == HDF_GROUP) {
MESSAGE( "--> Group: Internal Object Name : " << name);
HDFgroup* new_group = new HDFgroup(name,hdf_current_group);
- BuildTree (theStudy, new_group);
+ BuildTree(theStudy, new_group);
new_group = 0; // will be deleted by father destructor
}
}
_name_service.Destroy_Directory("/Study");
}
+SALOMEDS_Study_i*
+SALOMEDS_StudyManager_i::DownCast(SALOMEDS::Study_ptr theStudy) const
+{
+ if(!CORBA::is_nil(theStudy)){
+ PortableServer::POA_var aPOA = GetPOA();
+ PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theStudy,aPOA);
+ if(aServant.in())
+ return dynamic_cast<SALOMEDS_Study_i*>(aServant.in());
+ }
+ return NULL;
+}
+
//============================================================================
/*! Function : register_name
* Purpose : Register the study Manager in the naming service under the
// Assign the value of the IOR in the study->root
CORBA::String_var anIOR = _orb->object_to_string(aStudy);
- SALOMEDS_IORAttribute::Set(aDocument->Main().Root(),const_cast<char*>(anIOR.in()),_orb);
+ SALOMEDS_IORAttribute::Set(aDocument->Main().Root(),
+ const_cast<char*>(anIOR.in()),
+ aStudyServant);
// set Study properties
SALOMEDS::AttributeStudyProperties_var aProp = aStudyServant->GetProperties();
aStudy->StudyId( _IDcounter );
// Assign the value of the URL in the study object
- aStudy->URL(theURL);
+ aStudyServant->URL(theURL);
SCRUTE(theURL);
// Assign the value of the IOR in the study->root
CORBA::String_var anIOR = _orb->object_to_string(aStudy);
- SALOMEDS_IORAttribute::Set(Doc->Main().Root(),const_cast<char*>(anIOR.in()),_orb);
+ SALOMEDS_IORAttribute::Set(Doc->Main().Root(),
+ const_cast<char*>(anIOR.in()),
+ aStudyServant);
SALOMEDS_PersRefAttribute::Set(Doc->Main(),const_cast<char*>(theURL));
Handle(TDF_Data) DF = Doc->GetData();
try{
- BuildTree (aStudy,hdf_group_study_structure);
+ BuildTree(aStudyServant,hdf_group_study_structure);
}catch(HDFexception){
std::ostringstream aStream;
aStream<<"Can't open file "<<theURL;
if(!_name_service.Change_Directory("/Study")){
MESSAGE( "Unable to access the study directory" );
}else{
- CORBA::String_var aString(aStudy->Name());
+ CORBA::String_var aString(aStudyServant->Name());
_name_service.Register(aStudy,aString.in());
}
* Purpose : save the study properties in HDF file
*/
//============================================================================
-void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group)
+void SALOMEDS_StudyManager_i::_SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group)
{
// add modifications list (user and date of save)
- SALOMEDS::AttributeStudyProperties_ptr aProp = aStudy->GetProperties();
- SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder();
-// SB->NewCommand();
+ SALOMEDS::AttributeStudyProperties_ptr aProp = theStudy->GetProperties();
int aLocked = aProp->IsLocked();
if (aLocked)
aProp->SetLocked(Standard_False);
CORBA::Long(aDate.Year()));
if(aLocked)
aProp->SetLocked(Standard_True);
-// SB->CommitCommand();
SALOMEDS::StringSeq_var aNames;
SALOMEDS::LongSeq_var aMinutes, aHours, aDays, aMonths, aYears;
*/
//============================================================================
void SALOMEDS_StudyManager_i::_SaveAs(const char* aUrl,
- SALOMEDS::Study_ptr aStudy,
+ SALOMEDS::Study_ptr theStudy,
CORBA::Boolean theMultiFile,
CORBA::Boolean theASCII)
{
// * Study Structure -> Exactly what is contained in OCAF document
// Informations in data group hdf_group_study_structure
- HDFfile *hdf_file=0;
- HDFgroup *hdf_group_study_structure =0;
- HDFgroup *hdf_sco_group =0;
- HDFgroup *hdf_sco_group2 =0;
+ if(SALOMEDS_Study_i* aStudy = DownCast(theStudy)){
+ HDFfile *hdf_file=0;
+ HDFgroup *hdf_group_study_structure =0;
+ HDFgroup *hdf_sco_group =0;
+ HDFgroup *hdf_sco_group2 =0;
- HDFgroup *hdf_group_datacomponent =0;
- HDFdataset *hdf_dataset =0;
- hdf_size size[1];
- hdf_int32 name_len = 0;
-
- int aLocked = aStudy->GetProperties()->IsLocked();
- if (aLocked) aStudy->GetProperties()->SetLocked(false);
-
- SALOMEDS::StudyBuilder_var SB= aStudy->NewBuilder();
+ HDFgroup *hdf_group_datacomponent =0;
+ HDFdataset *hdf_dataset =0;
+ hdf_size size[1];
+ hdf_int32 name_len = 0;
+
+ int aLocked = aStudy->GetProperties()->IsLocked();
+ if(aLocked)
+ aStudy->GetProperties()->SetLocked(false);
- ASSERT(!CORBA::is_nil(aStudy));
- try
- {
+ SALOMEDS_StudyBuilder_i* SB= aStudy->GetBuilder();
+ try{
// mpv 15.12.2003: for saving components we have to load all data from all modules
-
- SALOMEDS::SComponentIterator_var itcomponent1 = aStudy->NewComponentIterator();
- for (; itcomponent1->More(); itcomponent1->Next())
- {
- SALOMEDS::SComponent_var sco = itcomponent1->Value();
- // if there is an associated Engine call its method for saving
- CORBA::String_var IOREngine;
- try {
+ SALOMEDS_SComponentIterator_i aComponentIter = aStudy->GetComponentIterator();
+ for(; aComponentIter.More(); aComponentIter.Next()){
+ SALOMEDS::SComponent_var sco = aComponentIter.Value();
+ // if there is an associated Engine call its method for saving
+ CORBA::String_var IOREngine;
+ try{
+ if(!sco->ComponentIOR(IOREngine)){
+ SALOMEDS::GenericAttribute_var aGeneric;
+ SALOMEDS::AttributeName_var aName;
+ if(sco->FindAttribute(aGeneric, "AttributeName"))
+ aName = SALOMEDS::AttributeName::_narrow(aGeneric);
- if (!sco->ComponentIOR(IOREngine)) {
- SALOMEDS::GenericAttribute_var aGeneric;
- SALOMEDS::AttributeName_var aName;
- if(sco->FindAttribute(aGeneric, "AttributeName"))
- aName = SALOMEDS::AttributeName::_narrow(aGeneric);
-
- if (!aName->_is_nil()) {
-
- CORBA::String_var aCompType = aName->Value();
-
-
- CORBA::String_var aFactoryType;
- if (strcmp(aCompType, "SUPERV") == 0) aFactoryType = "SuperVisionContainer";
- else aFactoryType = "FactoryServer";
+ if(!aName->_is_nil()){
+ CORBA::String_var aCompType = aName->Value();
+
+ CORBA::String_var aFactoryType;
+ if(strcmp(aCompType, "SUPERV") == 0)
+ aFactoryType = "SuperVisionContainer";
+ else
+ aFactoryType = "FactoryServer";
+
+ Engines::Component_var aComp =
+ SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component(aFactoryType, aCompType);
+ if(aComp->_is_nil()){
Engines::Component_var aComp =
- SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component(aFactoryType, aCompType);
-
- if (aComp->_is_nil()) {
- Engines::Component_var aComp =
- SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component("FactoryServerPy", aCompType);
- }
+ SALOME_LifeCycleCORBA(&_name_service).FindOrLoad_Component("FactoryServerPy", aCompType);
+ }
- if (!aComp->_is_nil()) {
- SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp);
- if (!CORBA::is_nil(aDriver)) {
- SB->LoadWith(sco, aDriver);
- }
+ if(!aComp->_is_nil()){
+ SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aComp);
+ if (!CORBA::is_nil(aDriver)) {
+ SB->LoadWith(sco, aDriver);
}
}
}
- } catch(...) {
- MESSAGE("Can not restore information to resave it");
- return;
}
+ }catch(...){
+ MESSAGE("Can not restore information to resave it");
+ return;
}
-
-
+ }
CORBA::String_var anOldName = aStudy->Name();
aStudy->URL(aUrl);
hdf_group_datacomponent = new HDFgroup("DATACOMPONENT",hdf_file);
hdf_group_datacomponent->CreateOnDisk();
- SALOMEDS::SComponentIterator_var itcomponent = aStudy->NewComponentIterator();
-
//SRN: Added 17 Nov, 2003
SALOMEDS::SObject_var anAutoSaveSO = aStudy->FindObjectID(AUTO_SAVE_TAG);
//SRN: End
- for (; itcomponent->More(); itcomponent->Next())
- {
- SALOMEDS::SComponent_var sco = itcomponent->Value();
+ aComponentIter.Init();
+ for(; aComponentIter.More(); aComponentIter.Next()){
+ SALOMEDS::SComponent_var sco = aComponentIter.Value();
- CORBA::String_var scoid = sco->GetID();
- hdf_sco_group = new HDFgroup(scoid,hdf_group_datacomponent);
- hdf_sco_group->CreateOnDisk();
-
- CORBA::String_var componentDataType = sco->ComponentDataType();
- MESSAGE ( "Look for an engine for data type :"<< componentDataType);
-
- //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save
- if(!CORBA::is_nil(anAutoSaveSO) && SB->IsGUID(sco, AUTO_SAVE_GUID)) {
-
- SALOMEDS::GenericAttribute_var aGeneric;
- SALOMEDS::AttributeTableOfString_var aTable;
- if(anAutoSaveSO->FindAttribute(aGeneric, "AttributeTableOfString")) {
- aTable = SALOMEDS::AttributeTableOfString::_narrow(aGeneric);
- Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0;
- if(nbRows > 0 && aTable->GetNbColumns() > 1) {
-
- SALOMEDS::StringSeq_var aRow;
- for(k=1; k<=nbRows; k++) {
- aRow = aTable->GetRow(k);
- if (strcmp(aRow[0], componentDataType) == 0) {
- CORBA::String_var anEntry = CORBA::string_dup(aRow[1]);
- SALOMEDS::SObject_var aCompSpecificSO = aStudy->FindObjectID(anEntry);
- if(!CORBA::is_nil(aCompSpecificSO)) {
- SALOMEDS::AttributeInteger_var anInteger;
- if(aCompSpecificSO->FindAttribute(aGeneric, "AttributeInteger")) {
- anInteger = SALOMEDS::AttributeInteger::_narrow(aGeneric);
- anInteger->SetValue(-1);
- while(anInteger->Value() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; }
- } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger"))
- } // if(!CORBA::is_nil(aCompSpecificSO))
- } // if (strcmp(aRow[0], componentDataType) == 0)
- } // for
-
- } // if(nbRows > 0 && aTable->GetNbColumns() > 1)
-
- } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString")
-
- } // if(SB->IsGUID(AUTO_SAVE_GUID)
-
- //SRN: End
-
- CORBA::String_var IOREngine;
- if (sco->ComponentIOR(IOREngine))
- {
- // we have found the associated engine to write the data
- MESSAGE ( "We have found an engine for data type :"<< componentDataType);
- CORBA::Object_var obj = _orb->string_to_object(IOREngine);
- SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
+ CORBA::String_var scoid = sco->GetID();
+ hdf_sco_group = new HDFgroup(scoid,hdf_group_datacomponent);
+ hdf_sco_group->CreateOnDisk();
+
+ CORBA::String_var componentDataType = sco->ComponentDataType();
+ MESSAGE ( "Look for an engine for data type :"<< componentDataType);
+
+ //SRN: Added 17 Nov 2003: If there is a specified attribute, the component peforms a special save
+ if(!CORBA::is_nil(anAutoSaveSO) && SB->IsGUID(sco, AUTO_SAVE_GUID)){
+ SALOMEDS::GenericAttribute_var aGeneric;
+ SALOMEDS::AttributeTableOfString_var aTable;
+ if(anAutoSaveSO->FindAttribute(aGeneric, "AttributeTableOfString")){
+ aTable = SALOMEDS::AttributeTableOfString::_narrow(aGeneric);
+ Standard_Integer nbRows = aTable->GetNbRows(), k, aTimeOut = 0;
+ if(nbRows > 0 && aTable->GetNbColumns() > 1) {
+ SALOMEDS::StringSeq_var aRow;
+ for(k=1; k<=nbRows; k++){
+ aRow = aTable->GetRow(k);
+ if(strcmp(aRow[0], componentDataType) == 0){
+ CORBA::String_var anEntry = CORBA::string_dup(aRow[1]);
+ SALOMEDS::SObject_var aCompSpecificSO = aStudy->FindObjectID(anEntry);
+ if(!CORBA::is_nil(aCompSpecificSO)) {
+ SALOMEDS::AttributeInteger_var anInteger;
+ if(aCompSpecificSO->FindAttribute(aGeneric, "AttributeInteger")) {
+ anInteger = SALOMEDS::AttributeInteger::_narrow(aGeneric);
+ anInteger->SetValue(-1);
+ while(anInteger->Value() < 0) { sleep(2); if(++aTimeOut > AUTO_SAVE_TIME_OUT_IN_SECONDS) break; }
+ } // if(aCompSpecificSO->FindAttribute(anInteger, "AttributeInteger"))
+ } // if(!CORBA::is_nil(aCompSpecificSO))
+ } // if (strcmp(aRow[0], componentDataType) == 0)
+ } // for
- if (!CORBA::is_nil(Engine))
- {
- MESSAGE ( "Save the data of type:"<< componentDataType);
- MESSAGE("Engine :"<<Engine->ComponentDataType());
-
- SALOMEDS::TMPFile_var aStream;
-
- if (theASCII) aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
- else aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
-
- HDFdataset *hdf_dataset;
- hdf_size aHDFSize[1];
- if(aStream->length() > 0) { //The component saved some auxiliary files, then put them into HDF file
-
- aHDFSize[0] = aStream->length();
-
- HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file
- hdf_dataset->CloseOnDisk();
- }
- // store multifile state
- aHDFSize[0] = 2;
- hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
-
- // store ASCII state
- aHDFSize[0] = 2;
- hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
- hdf_dataset->CreateOnDisk();
- 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
-
- Translate_IOR_to_persistentID (aStudy,SB,sco,Engine,theMultiFile, theASCII);
- MESSAGE("After Translate_IOR_to_persistentID");
-
- // Creation of the persistance reference attribute
- }
+ } // if(nbRows > 0 && aTable->GetNbColumns() > 1)
+
+ } // if(anAutoSaveSO->FindAttribute(aTable, "AttributeTableOfString")
+
+ } // if(SB->IsGUID(AUTO_SAVE_GUID)
+
+ //SRN: End
+
+ CORBA::String_var IOREngine;
+ if(sco->ComponentIOR(IOREngine)){
+ // we have found the associated engine to write the data
+ MESSAGE ( "We have found an engine for data type :"<< componentDataType);
+ CORBA::Object_var obj = _orb->string_to_object(IOREngine);
+ SALOMEDS::Driver_var Engine = SALOMEDS::Driver::_narrow(obj) ;
+
+ if(!CORBA::is_nil(Engine)){
+ MESSAGE ( "Save the data of type:"<< componentDataType);
+ MESSAGE("Engine :"<<Engine->ComponentDataType());
+
+ SALOMEDS::TMPFile_var aStream;
+
+ if(theASCII)
+ aStream = Engine->SaveASCII(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
+ else
+ aStream = Engine->Save(sco,SALOMEDS_Tool::GetDirFromPath(aUrl).c_str(),theMultiFile);
+
+ HDFdataset *hdf_dataset;
+ hdf_size aHDFSize[1];
+ if(aStream->length() > 0){ //The component saved some auxiliary files, then put them into HDF file
+
+ aHDFSize[0] = aStream->length();
+
+ HDFdataset *hdf_dataset = new HDFdataset("FILE_STREAM", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((unsigned char*) &aStream[0]); //Save the stream in the HDF file
+ hdf_dataset->CloseOnDisk();
}
- hdf_sco_group->CloseOnDisk();
- hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor
+ // store multifile state
+ aHDFSize[0] = 2;
+ hdf_dataset = new HDFdataset("MULTIFILE_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk((void*)(theMultiFile?"M":"S")); // save: multi or single
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_AuxFiles destructor
+
+ // store ASCII state
+ aHDFSize[0] = 2;
+ hdf_dataset = new HDFdataset("ASCII_STATE", hdf_sco_group, HDF_STRING, aHDFSize, 1);
+ hdf_dataset->CreateOnDisk();
+ 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
+
+ Translate_IOR_to_persistentID(aStudy,SB,sco,Engine,theMultiFile, theASCII);
+ MESSAGE("After Translate_IOR_to_persistentID");
+
+ // Creation of the persistance reference attribute
+ }
}
+ hdf_sco_group->CloseOnDisk();
+ hdf_sco_group=0; // will be deleted by hdf_group_datacomponent destructor
+ }
hdf_group_datacomponent->CloseOnDisk();
hdf_group_datacomponent =0; // will be deleted by hdf_file destructor
-
-
+
+
//-----------------------------------------------------------------------
//3 - Write the Study Structure
//-----------------------------------------------------------------------
hdf_group_study_structure->CreateOnDisk();
// save component attributes
- SALOMEDS::SComponentIterator_var itcomp = aStudy->NewComponentIterator();
- for (; itcomp->More(); itcomp->Next())
- {
- SALOMEDS::SComponent_var SC = itcomp->Value();
-
- CORBA::String_var scid = SC->GetID();
- hdf_sco_group2 = new HDFgroup(scid,hdf_group_study_structure);
- hdf_sco_group2->CreateOnDisk();
- SaveAttributes(SC, hdf_sco_group2);
- // ComponentDataType treatment
- CORBA::String_var component_name = SC->ComponentDataType();
- MESSAGE("Component data type " << component_name << " treated");
-
- name_len = (hdf_int32) strlen(component_name.in());
- size[0] = name_len +1 ;
- hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1);
- hdf_dataset->CreateOnDisk();
- hdf_dataset->WriteOnDisk(const_cast<char*>(component_name.in()));
- MESSAGE("component name " << component_name << " wrote on file");
- hdf_dataset->CloseOnDisk();
- hdf_dataset=0; //will be deleted by hdf_sco_group destructor
- _SaveObject(aStudy, SC, hdf_sco_group2);
- hdf_sco_group2->CloseOnDisk();
- hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor
- }
+ aComponentIter.Init();
+ for(; aComponentIter.More(); aComponentIter.Next()){
+ SALOMEDS::SComponent_var SC = aComponentIter.Value();
+
+ CORBA::String_var scid = SC->GetID();
+ hdf_sco_group2 = new HDFgroup(scid,hdf_group_study_structure);
+ hdf_sco_group2->CreateOnDisk();
+ SaveAttributes(SC, hdf_sco_group2);
+ // ComponentDataType treatment
+ CORBA::String_var component_name = SC->ComponentDataType();
+ MESSAGE("Component data type " << component_name << " treated");
+
+ name_len = (hdf_int32) strlen(component_name.in());
+ size[0] = name_len +1 ;
+ hdf_dataset = new HDFdataset("COMPONENTDATATYPE",hdf_sco_group2,HDF_STRING,size,1);
+ hdf_dataset->CreateOnDisk();
+ hdf_dataset->WriteOnDisk(const_cast<char*>(component_name.in()));
+ MESSAGE("component name " << component_name << " wrote on file");
+ hdf_dataset->CloseOnDisk();
+ hdf_dataset=0; //will be deleted by hdf_sco_group destructor
+ _SaveObject(aStudy, SC, hdf_sco_group2);
+ hdf_sco_group2->CloseOnDisk();
+ hdf_sco_group2=0; // will be deleted by hdf_group_study_structure destructor
+ }
//-----------------------------------------------------------------------
//4 - Write the Study UseCases Structure
//-----------------------------------------------------------------------
SALOMEDS::SObject_var aSO = aStudy->FindObjectID(USE_CASE_LABEL_ID);
- if (!aSO->_is_nil()) {
+ if(!aSO->_is_nil()){
HDFgroup *hdf_soo_group = new HDFgroup(USE_CASE_LABEL_ID,hdf_group_study_structure);
hdf_soo_group->CreateOnDisk();
SaveAttributes(aSO, hdf_soo_group);
hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor
}
- if (aLocked) aStudy->GetProperties()->SetLocked(true);
+ if (aLocked)
+ aStudy->GetProperties()->SetLocked(true);
//-----------------------------------------------------------------------
//5 - Write the Study Properties
//-----------------------------------------------------------------------
_name_service.Change_Directory("/Study");
_name_service.Destroy_Name(anOldName);
- _name_service.Register(aStudy, aStudy->Name());
+ _name_service.Register(theStudy, aStudy->Name());
aStudy->IsSaved(true);
hdf_group_study_structure =0; // will be deleted by hdf_file destructor
delete hdf_file; // recursively deletes all hdf objects...
+ }catch(HDFexception){
+ MESSAGE( "HDFexception ! " );
}
- catch (HDFexception)
- {
- MESSAGE( "HDFexception ! " )
+ if(theASCII){ // save file in ASCII format
+ HDFascii::ConvertFromHDFToASCII(aUrl, true);
}
- if (theASCII) { // save file in ASCII format
- HDFascii::ConvertFromHDFToASCII(aUrl, true);
}
}
* Purpose :
*/
//============================================================================
-void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS::Study_ptr aStudy,
- SALOMEDS::SObject_ptr SC,
+void SALOMEDS_StudyManager_i::_SaveObject(SALOMEDS_Study_i* theStudy,
+ SALOMEDS::SObject_ptr theSObject,
HDFgroup *hdf_group_datatype)
{
// Write in group hdf_group_datatype all informations of SObject SC
SALOMEDS::SObject_var RefSO;
HDFgroup *hdf_group_sobject = 0;
- SALOMEDS::ChildIterator_var itchild = aStudy->NewChildIterator(SC);
- for (; itchild->More(); itchild->Next())
- {
- SALOMEDS::SObject_var SO = itchild->Value();
-
- // mpv: don't save empty labels
- if (SO->GetAllAttributes()->length() == 0 && !SO->ReferencedObject(RefSO)) {
- SALOMEDS::ChildIterator_var subchild = aStudy->NewChildIterator(SC);
- if (!subchild->More()) {
- continue;
- }
- subchild->InitEx(true);
- bool anEmpty = true;
- for (; subchild->More() && anEmpty; subchild->Next())
- if (subchild->Value()->GetAllAttributes()->length() != 0 ||
- subchild->Value()->ReferencedObject(RefSO)) anEmpty = false;
- if (anEmpty) {
- continue;
- }
+ SALOMEDS_ChildIterator_i aChildIter = theStudy->GetChildIterator(theSObject);
+ for(; aChildIter.More(); aChildIter.Next()){
+ SALOMEDS::SObject_var aSObject = aChildIter.Value();
+ SALOMEDS::ListOfAttributes_var anAllAttributes = aSObject->GetAllAttributes();
+
+ // mpv: don't save empty labels
+ if(anAllAttributes->length() == 0 && !aSObject->ReferencedObject(RefSO)){
+ SALOMEDS_ChildIterator_i aSubChildIter = theStudy->GetChildIterator(theSObject);
+ if(!aSubChildIter.More())
+ continue;
+
+ aSubChildIter.InitEx(true);
+ bool anEmpty = true;
+ for(; aSubChildIter.More() && anEmpty; aSubChildIter.Next()){
+ SALOMEDS::SObject_var aSObj = aSubChildIter.Value();
+ SALOMEDS::ListOfAttributes_var anAllAttr = aSObj->GetAllAttributes();
+ if(anAllAttr->length() != 0 || aSObj->ReferencedObject(RefSO))
+ anEmpty = false;
}
-
- CORBA::String_var scoid(SO->GetID());
- hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype);
- hdf_group_sobject->CreateOnDisk();
- SaveAttributes(SO, hdf_group_sobject);
- _SaveObject(aStudy,SO, hdf_group_sobject);
- hdf_group_sobject->CloseOnDisk();
- hdf_group_sobject =0; // will be deleted by father hdf object destructor
-
+ if(anEmpty)
+ continue;
}
+
+ CORBA::String_var scoid(aSObject->GetID());
+ hdf_group_sobject = new HDFgroup(scoid,hdf_group_datatype);
+ hdf_group_sobject->CreateOnDisk();
+ SaveAttributes(aSObject, hdf_group_sobject);
+ _SaveObject(theStudy,aSObject, hdf_group_sobject);
+ hdf_group_sobject->CloseOnDisk();
+ hdf_group_sobject =0; // will be deleted by father hdf object destructor
+ }
}
//============================================================================
CORBA::Boolean theMultiFile,
CORBA::Boolean theASCII);
// _SaveObject private function called by _SaveAs
- virtual void _SaveObject(SALOMEDS::Study_ptr aStudy,
- SALOMEDS::SObject_ptr SC,
- HDFgroup *hdf_group_datatype);
+ void _SaveObject(SALOMEDS_Study_i* theStudy,
+ SALOMEDS::SObject_ptr SC,
+ HDFgroup *hdf_group_datatype);
// _SubstituteSlash function called by Open and GetStudyByName
virtual std::string _SubstituteSlash(const char *aUrl);
- virtual void _SaveProperties(SALOMEDS::Study_ptr aStudy, HDFgroup *hdf_group);
+ void _SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group);
public:
//! standard constructor
PortableServer::POA_var GetPOA() const { return _poa; }
+ SALOMEDS_Study_i* DownCast(SALOMEDS::Study_ptr theStudy) const;
+
//! method to Register study Manager in the naming service
/*!
\param char* arguments, the context to register the study manager in the NS
return _StudyManager->GetPOA();
}
+
+SALOMEDS_SObject_i*
+SALOMEDS_Study_i::DownCast(SALOMEDS::SObject_ptr theSObject) const
+{
+ if(!CORBA::is_nil(theSObject)){
+ PortableServer::POA_var aPOA = GetPOA();
+ PortableServer::ServantBase_var aServant = SALOMEDS::GetServant(theSObject,aPOA);
+ if(aServant.in())
+ return dynamic_cast<SALOMEDS_SObject_i*>(aServant.in());
+ }
+ return NULL;
+}
+
//============================================================================
/*! Function : SetOnAddSObject
* Purpose :
{
// firstly searching in the datamap for optimization
char* anIOR = const_cast<char*>(theObjectIOR);
- if (myIORLabels.IsBound(anIOR)) {
- SALOMEDS::SObject_var aResult = SALOMEDS_SObject_i::NewRef(this,myIORLabels.Find(anIOR));
+ if(myIORLabels.IsBound(anIOR)){
+ TDF_Label aLabel = myIORLabels.Find(anIOR);
+ TSObjectHolder aSObjectHolder = SALOMEDS_SObject_i::New(this,aLabel);
+ SALOMEDS_SObject_i* aSObjectPtr = aSObjectHolder.first;
+ SALOMEDS::SObject_var aSObject = aSObjectHolder.second;
// 11 oct 2002: forbidden attributes must be checked here
SALOMEDS::GenericAttribute_var anAttr;
- if (!aResult->FindAttribute(anAttr,"AttributeIOR")) {
+ if(!aSObjectPtr->FindAttribute(anAttr,"AttributeIOR")){
myIORLabels.UnBind(anIOR);
- } else
- return aResult._retn();
+ }else{
+ return aSObject._retn();
+ }
}
// Iterate to all components defined in the study
* Purpose : Create a ChildIterator from an SObject
*/
//============================================================================
-SALOMEDS::ChildIterator_ptr SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr aSO)
+SALOMEDS::ChildIterator_ptr
+SALOMEDS_Study_i::NewChildIterator(SALOMEDS::SObject_ptr theSObject)
{
- //Convert aSO->GetID in TDF_Label.
- TDF_Label Lab;
- TDF_Tool::Label(_doc->GetData(), aSO->GetID(), Lab);
+ SALOMEDS_ChildIterator_i* aServant =
+ new SALOMEDS_ChildIterator_i(GetChildIterator(theSObject));
- //Create iterator
- SALOMEDS_ChildIterator_i* aServant = new SALOMEDS_ChildIterator_i(this,Lab);
return aServant->_this();
}
+SALOMEDS_ChildIterator_i
+SALOMEDS_Study_i::GetChildIterator(SALOMEDS::SObject_ptr theSObject)
+{
+ TDF_Label aLab;
+ TDF_Tool::Label(_doc->GetData(),theSObject->GetID(),aLab);
+ return SALOMEDS_ChildIterator_i(this,aLab);
+}
//============================================================================
/*! Function : NewComponentIterator
* Purpose : Create a SComponentIterator
*/
//============================================================================
-SALOMEDS::SComponentIterator_ptr SALOMEDS_Study_i::NewComponentIterator()
+SALOMEDS::SComponentIterator_ptr
+SALOMEDS_Study_i::NewComponentIterator()
{
- SALOMEDS_SComponentIterator_i* aServant = new SALOMEDS_SComponentIterator_i(this,_doc);
+ SALOMEDS_SComponentIterator_i* aServant =
+ new SALOMEDS_SComponentIterator_i(GetComponentIterator());
+
return aServant->_this();
}
+SALOMEDS_SComponentIterator_i
+SALOMEDS_Study_i::GetComponentIterator()
+{
+ return SALOMEDS_SComponentIterator_i(this,_doc);
+}
+
//============================================================================
/*! Function : GetUseCaseBuilder
* Purpose : Returns a UseCase builder
* Purpose : Create a StudyBuilder
*/
//============================================================================
+SALOMEDS_StudyBuilder_i* SALOMEDS_Study_i::GetBuilder()
+{
+ return _Builder;
+}
+
SALOMEDS::StudyBuilder_ptr SALOMEDS_Study_i::NewBuilder()
{
- return _Builder->_this();
+ return GetBuilder()->_this();
}
//============================================================================
myIORLabels.Bind(TCollection_ExtendedString(IOR), aLabel);
}
-SALOMEDS::Study_ptr SALOMEDS_Study_i::GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb) {
- Handle(SALOMEDS_IORAttribute) Att;
- if (theLabel.Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){
- char* IOR = CORBA::string_dup(TCollection_AsciiString(Att->Get()).ToCString());
- CORBA::Object_var obj = orb->string_to_object(IOR);
- SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj) ;
- ASSERT(!CORBA::is_nil(aStudy));
- return SALOMEDS::Study::_duplicate(aStudy);
- } else {
- MESSAGE("GetStudy: Problem to get study");
- }
- return SALOMEDS::Study::_nil();
-}
-
-void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb) {
+void SALOMEDS_Study_i::IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute) {
TCollection_AsciiString aString;
- TDF_Tool::Entry(theAttribute->Label(), aString);
- GetStudy(theAttribute->Label(), orb)->UpdateIORLabelMap(TCollection_AsciiString(theAttribute->Get()).ToCString(),
- aString.ToCString());
+ TDF_Tool::Entry(theAttribute->Label(),aString);
+ TCollection_AsciiString aValue(theAttribute->Get());
+ UpdateIORLabelMap(aValue.ToCString(),aString.ToCString());
}
SALOMEDS::Study::ListOfSObject* SALOMEDS_Study_i::FindDependances(SALOMEDS::SObject_ptr anObject) {
}
-SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties() {
- SALOMEDS::GenericAttribute_ptr anAttr = NewBuilder()->FindOrCreateAttribute(FindObjectID("0:1"),
- "AttributeStudyProperties");
+SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties(){
+ SALOMEDS::SObject_var aSObject = FindObjectID("0:1");
+
+ SALOMEDS::GenericAttribute_var anAttr =
+ GetBuilder()->FindOrCreateAttribute(aSObject,"AttributeStudyProperties");
+
return SALOMEDS::AttributeStudyProperties::_narrow(anAttr);
}
*/
//============================================================================
void SALOMEDS_Study_i::AddPostponed(const char* theIOR) {
- if (!NewBuilder()->HasOpenCommand()) return;
+ if (!GetBuilder()->HasOpenCommand()) return;
try {
CORBA::Object_var obj = GetORB()->string_to_object(theIOR);
if (!CORBA::is_nil(obj)) {
}
void SALOMEDS_Study_i::AddCreatedPostponed(const char* theIOR) {
- if (!NewBuilder()->HasOpenCommand()) return;
+ if (!GetBuilder()->HasOpenCommand()) return;
try {
CORBA::Object_var obj = GetORB()->string_to_object(theIOR);
if (!CORBA::is_nil(obj)) {
#include "SALOMEDS_DataMapStringLabel.hxx"
#include "SALOMEDS_IORAttribute.hxx"
+#include "SALOMEDS_SComponentIterator_i.hxx"
+#include "SALOMEDS_ChildIterator_i.hxx"
+
class SALOMEDS_StudyManager_i;
class SALOMEDS_UseCaseBuilder_i;
class SALOMEDS_StudyBuilder_i;
CORBA::ORB_var GetORB() const;
PortableServer::POA_var GetPOA() const;
-
+
+ SALOMEDS_SObject_i* DownCast(SALOMEDS::SObject_ptr theSObject) const;
+
SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback);
SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback);
\return ChildIterator_ptr arguments, the created ChildIterator
*/
virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO);
+ SALOMEDS_ChildIterator_i GetChildIterator(SALOMEDS::SObject_ptr theSObject);
//! method to Create a SComponentIterator
/*!
\return SComponentIterator_ptr arguments, the created SComponentIterator
*/
virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator();
+ SALOMEDS_SComponentIterator_i GetComponentIterator();
//! method to Create a StudyBuilder
/*!
\return StudyBuilder_ptr arguments, the created StudyBuilder
*/
+ SALOMEDS_StudyBuilder_i* GetBuilder();
virtual SALOMEDS::StudyBuilder_ptr NewBuilder();
//! method to get study name
virtual CORBA::Short StudyId();
virtual void StudyId(CORBA::Short id);
- static SALOMEDS::Study_ptr GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb);
-
- static void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb);
+ void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute);
virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel);