1 // File : SALOMEDSImpl_Study.hxx
2 // Author : Sergey RUIN
5 #ifndef __SALOMEDSIMPL_STUDY_I_H__
6 #define __SALOMEDSIMPL_STUDY_I_H__
9 #include <Handle_MMgt_TShared.hxx>
10 #include <Standard_DefineHandle.hxx>
11 DEFINE_STANDARD_HANDLE( SALOMEDSImpl_Study, MMgt_TShared )
17 #include <TDocStd_Document.hxx>
18 #include <TDF_Tool.hxx>
19 #include <TDF_Data.hxx>
20 #include <TDF_Label.hxx>
22 #include <TCollection_AsciiString.hxx>
23 #include <TColStd_SequenceOfInteger.hxx>
24 #include <TColStd_SequenceOfAsciiString.hxx>
25 #include <TColStd_HSequenceOfAsciiString.hxx>
26 #include <TColStd_HSequenceOfTransient.hxx>
28 #include <NCollection_DataMap.hxx>
30 #include <NCollection_DataMap1.hxx>
33 //SALOMEDSImpl headers
34 #include "SALOMEDSImpl_SComponentIterator.hxx"
35 #include "SALOMEDSImpl_SObject.hxx"
36 #include "SALOMEDSImpl_StudyBuilder.hxx"
37 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
38 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
39 #include "SALOMEDSImpl_AttributeIOR.hxx"
40 #include "SALOMEDSImpl_Callback.hxx"
41 #include "SALOMEDSImpl_Driver.hxx"
42 #include "SALOMEDSImpl_ChildIterator.hxx"
44 class SALOMEDSImpl_StudyManager;
45 class SALOMEDSImpl_GenericAttribute;
48 typedef NCollection_DataMap <TCollection_AsciiString, Handle_Standard_Transient> DataMapOfAsciiStringTransient;
49 typedef NCollection_DataMap <TCollection_AsciiString, TDF_Label> DataMapAsciiStringLabel;
51 typedef NCollection_DataMap1 <TCollection_AsciiString, Handle_Standard_Transient> DataMapOfAsciiStringTransient;
52 typedef NCollection_DataMap1 <TCollection_AsciiString, TDF_Label> DataMapAsciiStringLabel;
55 class SALOMEDSImpl_Study : public MMgt_TShared
58 TCollection_AsciiString _name;
59 Handle(TDocStd_Document) _doc; // OCAF Document
60 bool _Saved; // True if the Study is saved
61 TCollection_AsciiString _URL; //URL of the persistent reference of the study
65 TCollection_AsciiString _errorCode;
66 Handle(SALOMEDSImpl_Callback) _cb;
67 Handle(SALOMEDSImpl_StudyBuilder) _builder;
68 Handle(SALOMEDSImpl_UseCaseBuilder) _useCaseBuilder;
70 DataMapOfAsciiStringTransient _mapOfSO;
71 DataMapOfAsciiStringTransient _mapOfSCO;
73 // data structures for postponed destroying of object functionality
74 TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs
75 TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction
76 int myNbUndos; // number of current Undos, made by user
77 DataMapAsciiStringLabel myIORLabels;
80 Handle(SALOMEDSImpl_SObject) _FindObject(const Handle(SALOMEDSImpl_SObject)& SO,
81 const TCollection_AsciiString& anObjectName,
84 Handle(SALOMEDSImpl_SObject) _FindObjectIOR(const Handle(SALOMEDSImpl_SObject)& SO,
85 const TCollection_AsciiString& anObjectIOR,
90 Standard_EXPORT static Handle(SALOMEDSImpl_Study) GetStudy(const TDF_Label& theLabel);
91 Standard_EXPORT static Handle(SALOMEDSImpl_SObject) SObject(const TDF_Label& theLabel);
92 Standard_EXPORT static Handle(SALOMEDSImpl_SComponent) SComponent(const TDF_Label& theLabel);
93 Standard_EXPORT static void IORUpdated(const Handle(SALOMEDSImpl_AttributeIOR)& theAttribute);
95 //! standard constructor
96 Standard_EXPORT SALOMEDSImpl_Study(const Handle(TDocStd_Document)&, const TCollection_AsciiString& study_name);
98 //! standard destructor
99 Standard_EXPORT virtual ~SALOMEDSImpl_Study();
101 //! method to Get persistent reference of study (idem URL())
102 Standard_EXPORT virtual TCollection_AsciiString GetPersistentReference();
104 //! method to Get transient reference of study
105 Standard_EXPORT virtual TCollection_AsciiString GetTransientReference();
107 Standard_EXPORT virtual void SetTransientReference(const TCollection_AsciiString& theIOR);
109 //! method to detect if a study is empty
110 Standard_EXPORT virtual bool IsEmpty();
112 //! method to Find a Component with ComponentDataType = aComponentName
113 Standard_EXPORT virtual Handle(SALOMEDSImpl_SComponent) FindComponent (const TCollection_AsciiString& aComponentName);
115 //! method to Find a Component Find a Component from it's ID
116 Standard_EXPORT virtual Handle(SALOMEDSImpl_SComponent) FindComponentID(const TCollection_AsciiString& aComponentID);
118 //! method to Find an Object with SALOMEDSImpl::Name = anObjectName
119 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) FindObject(const TCollection_AsciiString& anObjectName);
122 //! method to Find Object(s) with SALOMEDSImpl::Name=anObjectName in a component with ComponentDataType = aComponentName
123 Standard_EXPORT virtual Handle(TColStd_HSequenceOfTransient) FindObjectByName( const TCollection_AsciiString& anObjectName,
124 const TCollection_AsciiString& aComponentName ) ;
126 //! method to Find an Object with ID = anObjectID
127 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) FindObjectID(const TCollection_AsciiString& anObjectID);
129 //! method to Create an Object with ID = anObjectID
130 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) CreateObjectID(const TCollection_AsciiString& anObjectID);
132 //! method to Find an Object with ID = anObjectIOR
133 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) FindObjectIOR(const TCollection_AsciiString& anObjectIOR);
135 //! method to Find an Object by its path
136 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) FindObjectByPath(const TCollection_AsciiString& thePath);
138 //! method to get a path of SObject
139 Standard_EXPORT virtual TCollection_AsciiString GetObjectPath(const Handle(SALOMEDSImpl_SObject)& theObject);
141 Standard_EXPORT TCollection_AsciiString GetObjectPathByIOR(const TCollection_AsciiString& theIOR);
143 //! method to set a context: root ('/') is UserData component
144 Standard_EXPORT virtual bool SetContext(const TCollection_AsciiString& thePath);
146 //! method to get a context
147 Standard_EXPORT virtual TCollection_AsciiString GetContext();
149 //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
150 Standard_EXPORT virtual Handle(TColStd_HSequenceOfAsciiString) GetObjectNames(const TCollection_AsciiString& theContext);
152 //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
153 Standard_EXPORT virtual Handle(TColStd_HSequenceOfAsciiString) GetDirectoryNames(const TCollection_AsciiString& theContext);
155 //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
156 Standard_EXPORT virtual Handle(TColStd_HSequenceOfAsciiString) GetFileNames(const TCollection_AsciiString& theContext);
158 //! method to get all components names
159 Standard_EXPORT virtual Handle(TColStd_HSequenceOfAsciiString) GetComponentNames(const TCollection_AsciiString& theContext);
161 //! method to Create a ChildIterator from an SObject
162 Standard_EXPORT virtual Handle(SALOMEDSImpl_ChildIterator) NewChildIterator(const Handle(SALOMEDSImpl_SObject)& aSO);
164 //! method to Create a SComponentIterator
165 Standard_EXPORT virtual SALOMEDSImpl_SComponentIterator NewComponentIterator();
167 //! method to Create a StudyBuilder
168 Standard_EXPORT virtual Handle(SALOMEDSImpl_StudyBuilder) NewBuilder();
170 //! method to get study name
171 Standard_EXPORT virtual TCollection_AsciiString Name();
173 //! method to set study name
174 Standard_EXPORT virtual void Name(const TCollection_AsciiString& name);
176 //! method to get if study has been saved
177 Standard_EXPORT virtual bool IsSaved();
179 //! method to set if study has been saved
180 Standard_EXPORT virtual void IsSaved(bool save);
182 //! method to Detect if a Study has been modified since it has been saved
183 Standard_EXPORT virtual bool IsModified();
185 //! method to get URL of the study (idem GetPersistentReference)
186 Standard_EXPORT virtual TCollection_AsciiString URL();
188 //! method to set URL of the study
189 Standard_EXPORT virtual void URL(const TCollection_AsciiString& url);
191 Standard_EXPORT virtual bool IsLocked();
193 Standard_EXPORT virtual int StudyId();
195 Standard_EXPORT virtual void StudyId(int id);
197 Standard_EXPORT virtual void UpdateIORLabelMap(const TCollection_AsciiString& anIOR, const TCollection_AsciiString& aLabel);
199 Standard_EXPORT virtual Handle(TColStd_HSequenceOfTransient) FindDependances(const Handle(SALOMEDSImpl_SObject)& anObject);
201 Standard_EXPORT virtual Handle(SALOMEDSImpl_AttributeStudyProperties) SALOMEDSImpl_Study::GetProperties();
203 Standard_EXPORT virtual TCollection_AsciiString GetLastModificationDate();
205 Standard_EXPORT virtual Handle(TColStd_HSequenceOfAsciiString) GetModificationsDate();
207 Standard_EXPORT virtual Handle(SALOMEDSImpl_UseCaseBuilder) GetUseCaseBuilder();
209 Standard_EXPORT virtual void Close();
211 Standard_EXPORT void EnableUseCaseAutoFilling(bool isEnabled) { _errorCode = ""; _autoFill = isEnabled; }
213 // postponed destroying of object functionality
214 Standard_EXPORT virtual void AddPostponed(const TCollection_AsciiString& theIOR);
216 Standard_EXPORT virtual void AddCreatedPostponed(const TCollection_AsciiString& theIOR);
218 Standard_EXPORT virtual Handle(TColStd_HSequenceOfAsciiString) RemovePostponed(const int theUndoLimit);
219 // removes postponed IORs of old transaction
220 // if theUndoLimit==0, removes all
221 Standard_EXPORT virtual void UndoPostponed(const int theWay); // theWay = 1: resurrect objects,
222 // theWay = -1: get back to the list of postponed
225 Standard_EXPORT virtual TCollection_AsciiString GetErrorCode() { return _errorCode; }
226 Standard_EXPORT virtual bool IsError() { return _errorCode != ""; }
228 Standard_EXPORT virtual Handle(SALOMEDSImpl_SComponent) GetSComponent(const TCollection_AsciiString& theEntry);
229 Standard_EXPORT virtual Handle(SALOMEDSImpl_SComponent) GetSComponent(const TDF_Label& theLabel);
230 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) GetSObject(const TCollection_AsciiString& theEntry);
231 Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) GetSObject(const TDF_Label& theEntryLabel);
232 Standard_EXPORT virtual Handle(TDF_Attribute) GetAttribute(const TCollection_AsciiString& theEntry,
233 const TCollection_AsciiString& theType);
235 Standard_EXPORT virtual bool HasCurrentContext() { return !_current.IsNull(); }
237 Standard_EXPORT virtual bool DumpStudy(const TCollection_AsciiString& thePath,
238 const TCollection_AsciiString& theBaseName,
240 SALOMEDSImpl_DriverFactory* theFactory);
242 Standard_EXPORT static TCollection_AsciiString GetDumpStudyComment(const char* theComponentName = 0);
244 Standard_EXPORT virtual Handle(TDocStd_Document) GetDocument() { return _doc; }
246 //The method dump creates a txt file that contain a dump of the study, for debug use
247 Standard_EXPORT void dump(const TCollection_AsciiString& theFileName);
249 //This method marks the study as being modified
250 Standard_EXPORT void Modify();
253 DEFINE_STANDARD_RTTI( SALOMEDSImpl_Study )
255 friend class SALOMEDSImpl_StudyManager;
256 friend class SALOMEDSImpl_GenericAttribute;