1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_Study.hxx
21 // Author : Sergey RUIN
24 #ifndef __SALOMEDSIMPL_STUDY_I_H__
25 #define __SALOMEDSIMPL_STUDY_I_H__
34 #include "DF_Document.hxx"
35 #include "DF_Label.hxx"
38 //SALOMEDSImpl headers
39 #include "SALOMEDSImpl_SComponentIterator.hxx"
40 #include "SALOMEDSImpl_SObject.hxx"
41 #include "SALOMEDSImpl_StudyBuilder.hxx"
42 #include "SALOMEDSImpl_UseCaseBuilder.hxx"
43 #include "SALOMEDSImpl_AttributeStudyProperties.hxx"
44 #include "SALOMEDSImpl_AttributeIOR.hxx"
45 #include "SALOMEDSImpl_AttributeParameter.hxx"
46 #include "SALOMEDSImpl_Callback.hxx"
47 #include "SALOMEDSImpl_Driver.hxx"
48 #include "SALOMEDSImpl_ChildIterator.hxx"
50 class SALOMEDSImpl_StudyManager;
51 class SALOMEDSImpl_GenericAttribute;
54 class SALOMEDSImpl_Study
58 DF_Document* _doc; // Document
59 bool _Saved; // True if the Study is saved
60 std::string _URL; //URL of the persistent reference of the study
64 std::string _errorCode;
65 std::vector<std::string> _lockers;
66 SALOMEDSImpl_Callback* _cb;
67 SALOMEDSImpl_StudyBuilder* _builder;
68 SALOMEDSImpl_UseCaseBuilder* _useCaseBuilder;
70 std::map<std::string, SALOMEDSImpl_SObject> _mapOfSO;
71 std::map<std::string, SALOMEDSImpl_SComponent> _mapOfSCO;
72 std::map<std::string, DF_Label> myIORLabels;
75 SALOMEDSImpl_SObject _FindObject(const SALOMEDSImpl_SObject& SO,
76 const std::string& anObjectName,
79 SALOMEDSImpl_SObject _FindObjectIOR(const SALOMEDSImpl_SObject& SO,
80 const std::string& anObjectIOR,
85 Standard_EXPORT static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel);
86 Standard_EXPORT static SALOMEDSImpl_SObject SObject(const DF_Label& theLabel);
87 Standard_EXPORT static SALOMEDSImpl_SComponent SComponent(const DF_Label& theLabel);
88 Standard_EXPORT static void IORUpdated(const SALOMEDSImpl_AttributeIOR* theAttribute);
90 //! standard constructor
91 Standard_EXPORT SALOMEDSImpl_Study(const DF_Document*, const std::string& study_name);
93 //! standard destructor
94 Standard_EXPORT virtual ~SALOMEDSImpl_Study();
96 //! method to Get persistent reference of study (idem URL())
97 Standard_EXPORT virtual std::string GetPersistentReference();
99 //! method to Get transient reference of study
100 Standard_EXPORT virtual std::string GetTransientReference();
102 Standard_EXPORT virtual void SetTransientReference(const std::string& theIOR);
104 //! method to detect if a study is empty
105 Standard_EXPORT virtual bool IsEmpty();
107 //! method to Find a Component with ComponentDataType = aComponentName
108 Standard_EXPORT virtual SALOMEDSImpl_SComponent FindComponent (const std::string& aComponentName);
110 //! method to Find a Component Find a Component from it's ID
111 Standard_EXPORT virtual SALOMEDSImpl_SComponent FindComponentID(const std::string& aComponentID);
113 //! method to Find an Object with SALOMEDSImpl::Name = anObjectName
114 Standard_EXPORT virtual SALOMEDSImpl_SObject FindObject(const std::string& anObjectName);
117 //! method to Find Object(s) with SALOMEDSImpl::Name=anObjectName in a component with ComponentDataType = aComponentName
118 Standard_EXPORT virtual std::vector<SALOMEDSImpl_SObject> FindObjectByName( const std::string& anObjectName,
119 const std::string& aComponentName ) ;
121 //! method to Find an Object with ID = anObjectID
122 Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectID(const std::string& anObjectID);
124 //! method to Create an Object with ID = anObjectID
125 Standard_EXPORT virtual SALOMEDSImpl_SObject CreateObjectID(const std::string& anObjectID);
127 //! method to Find an Object with ID = anObjectIOR
128 Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectIOR(const std::string& anObjectIOR);
130 //! method to Find an Object by its path
131 Standard_EXPORT virtual SALOMEDSImpl_SObject FindObjectByPath(const std::string& thePath);
133 //! method to get a path of SObject
134 Standard_EXPORT virtual std::string GetObjectPath(const SALOMEDSImpl_SObject& theObject);
136 Standard_EXPORT std::string GetObjectPathByIOR(const std::string& theIOR);
138 //! method to set a context: root ('/') is UserData component
139 Standard_EXPORT virtual bool SetContext(const std::string& thePath);
141 //! method to get a context
142 Standard_EXPORT virtual std::string GetContext();
144 //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
145 Standard_EXPORT virtual std::vector<std::string> GetObjectNames(const std::string& theContext);
147 //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
148 Standard_EXPORT virtual std::vector<std::string> GetDirectoryNames(const std::string& theContext);
150 //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
151 Standard_EXPORT virtual std::vector<std::string> GetFileNames(const std::string& theContext);
153 //! method to get all components names
154 Standard_EXPORT virtual std::vector<std::string> GetComponentNames(const std::string& theContext);
156 //! method to Create a ChildIterator from an SObject
157 Standard_EXPORT virtual SALOMEDSImpl_ChildIterator NewChildIterator(const SALOMEDSImpl_SObject& aSO);
159 //! method to Create a SComponentIterator
160 Standard_EXPORT virtual SALOMEDSImpl_SComponentIterator NewComponentIterator();
162 //! method to Create a StudyBuilder
163 Standard_EXPORT virtual SALOMEDSImpl_StudyBuilder* NewBuilder();
165 //! method to get study name
166 Standard_EXPORT virtual std::string Name();
168 //! method to set study name
169 Standard_EXPORT virtual void Name(const std::string& name);
171 //! method to get if study has been saved
172 Standard_EXPORT virtual bool IsSaved();
174 //! method to set if study has been saved
175 Standard_EXPORT virtual void IsSaved(bool save);
177 //! method to Detect if a Study has been modified since it has been saved
178 Standard_EXPORT virtual bool IsModified();
180 //! method to get URL of the study (idem GetPersistentReference)
181 Standard_EXPORT virtual std::string URL();
183 //! method to set URL of the study
184 Standard_EXPORT virtual void URL(const std::string& url);
186 Standard_EXPORT virtual bool IsLocked();
188 Standard_EXPORT virtual int StudyId();
190 Standard_EXPORT virtual void StudyId(int id);
192 Standard_EXPORT virtual void UpdateIORLabelMap(const std::string& anIOR, const std::string& aLabel);
194 Standard_EXPORT virtual std::vector<SALOMEDSImpl_SObject> FindDependances(const SALOMEDSImpl_SObject& anObject);
196 Standard_EXPORT virtual SALOMEDSImpl_AttributeStudyProperties* GetProperties();
198 Standard_EXPORT virtual std::string GetLastModificationDate();
200 Standard_EXPORT virtual std::vector<std::string> GetModificationsDate();
202 Standard_EXPORT virtual SALOMEDSImpl_UseCaseBuilder* GetUseCaseBuilder();
204 Standard_EXPORT virtual void Close();
206 Standard_EXPORT void EnableUseCaseAutoFilling(bool isEnabled);
208 Standard_EXPORT virtual std::string GetErrorCode() { return _errorCode; }
209 Standard_EXPORT virtual bool IsError() { return _errorCode != ""; }
211 Standard_EXPORT virtual SALOMEDSImpl_SComponent GetSComponent(const std::string& theEntry);
212 Standard_EXPORT virtual SALOMEDSImpl_SComponent GetSComponent(const DF_Label& theLabel);
213 Standard_EXPORT virtual SALOMEDSImpl_SObject GetSObject(const std::string& theEntry);
214 Standard_EXPORT virtual SALOMEDSImpl_SObject GetSObject(const DF_Label& theEntryLabel);
215 Standard_EXPORT virtual DF_Attribute* GetAttribute(const std::string& theEntry,
216 const std::string& theType);
218 Standard_EXPORT virtual bool HasCurrentContext() { return !_current.IsNull(); }
220 Standard_EXPORT virtual bool DumpStudy(const std::string& thePath,
221 const std::string& theBaseName,
223 SALOMEDSImpl_DriverFactory* theFactory);
225 Standard_EXPORT static std::string GetDumpStudyComment(const char* theComponentName = 0);
227 Standard_EXPORT virtual DF_Document* GetDocument() { return _doc; }
229 //The method dump creates a txt file that contain a dump of the study, for debug use
230 Standard_EXPORT void dump(const std::string& theFileName);
232 //This method marks the study as being modified
233 Standard_EXPORT void Modify();
235 Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetCommonParameters(const char* theID, int theSavePoint);
237 Standard_EXPORT SALOMEDSImpl_AttributeParameter* GetModuleParameters(const char* theID,
238 const char* theModuleName,
241 //Locks the study, theLockerID is identificator of the of the one who locked the study for ex. IOR
242 Standard_EXPORT void SetStudyLock(const char* theLockerID);
244 //Returns True if the study is locked
245 Standard_EXPORT bool IsStudyLocked();
248 Standard_EXPORT void UnLockStudy(const char* theLockerID);
250 //Returns an ID of the study locker
251 Standard_EXPORT std::vector<std::string> GetLockerID();
254 Standard_EXPORT SALOMEDSImpl_Callback* GetCallback() { return _cb; }
256 //Returns a list of IOR's stored in the study
257 Standard_EXPORT std::vector<std::string> GetIORs();
260 friend class SALOMEDSImpl_StudyManager;
261 friend class SALOMEDSImpl_GenericAttribute;