1 // SALOME SALOMEDS : data structure of SALOME and sources of Salome data server
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOMEDS_Study_i.hxx
25 // Author : Yves FRICAUD
29 #ifndef __SALOMEDS_STUDY_I_H__
30 #define __SALOMEDS_STUDY_I_H__
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SALOMEDS)
41 #include <TDF_Tool.hxx>
42 #include <TDF_Data.hxx>
43 #include <TDF_Label.hxx>
44 #include <TDocStd_Document.hxx>
45 #include <TColStd_SequenceOfInteger.hxx>
46 #include <TColStd_SequenceOfAsciiString.hxx>
49 #include "SALOMEDS_DataMapStringLabel.hxx"
50 #include "SALOMEDS_IORAttribute.hxx"
52 class SALOMEDS_StudyManager_i;
53 class SALOMEDS_UseCaseBuilder_i;
54 class SALOMEDS_StudyBuilder_i;
55 class SALOMEDS_SObject_i;
58 bool operator<(const TDF_Label& theLeft, const TDF_Label& theRight);
61 class SALOMEDS_Study_i: public virtual POA_SALOMEDS::Study,
62 public virtual PortableServer::RefCountServantBase
65 typedef TDF_Label TSObjectID;
66 typedef std::pair<SALOMEDS_SObject_i*,SALOMEDS::SObject_var> TSObjectHolder;
67 typedef std::map<TSObjectID,TSObjectHolder> TSObjectMap;
69 SALOMEDS_Study_i(SALOMEDS_StudyManager_i* theStudyManager,
70 const Handle(TDocStd_Document)& theDoc,
71 const char* theStudyName);
73 virtual ~SALOMEDS_Study_i();
76 SALOMEDS_StudyManager_i* GetStudyManager(){ return _StudyManager; }
78 Handle(TDocStd_Document) GetDocument(){ return _doc; }
80 TSObjectMap& GetSObjectMap(){ return mySObjectMap;}
82 CORBA::ORB_var GetORB() const;
84 PortableServer::POA_var GetPOA() const;
86 SALOMEDS::Callback_ptr SetOnAddSObject(SALOMEDS::Callback_ptr theCallback);
88 SALOMEDS::Callback_ptr SetOnRemoveSObject(SALOMEDS::Callback_ptr theCallback);
90 void OnAddSObject(SALOMEDS::SObject_ptr theObject);
92 void OnRemoveSObject(SALOMEDS::SObject_ptr theObject);
97 virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject);
99 virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR);
101 //! method to Get persistent reference of study (idem URL())
104 \return char* arguments, the persistent reference of the study
106 virtual char* GetPersistentReference();
109 //! method to Get transient reference of study
111 \return char* arguments, the transient reference of the study
113 virtual char* GetTransientReference();
115 //! method to detect if a study is empty
117 \return bool arguments, true if study is empty
119 virtual CORBA::Boolean IsEmpty();
121 //! method to Find a Component with ComponentDataType = aComponentName
123 \param aComponentName char* arguments
124 \return SComponent_ptr arguments, the component found
126 virtual SALOMEDS::SComponent_ptr FindComponent (const char* aComponentName);
128 //! method to Find a Component Find a Component from it's ID
130 \param aComponentID char* arguments
131 \return SComponent_ptr arguments, the component found
133 virtual SALOMEDS::SComponent_ptr FindComponentID(const char* aComponentID);
135 //! method to Find an Object with SALOMEDS::Name = anObjectName
137 \param anObjectName char* arguments
138 \return SObject_ptr arguments, the object found
140 virtual SALOMEDS::SObject_ptr FindObject(const char* anObjectName);
143 //! method to Find Object(s) with SALOMEDS::Name = anObjectName in a component with ComponentDataType = aComponentName
145 \param anObjectName char* arguments
146 \param aComponentName char* arguments
147 \return ListOfSObject_ptr arguments, a list of objects found
150 virtual SALOMEDS::Study::ListOfSObject* FindObjectByName( const char* anObjectName, const char* aComponentName ) ;
152 //! method to Find an Object with ID = anObjectID
154 \param anObjectID char* arguments
155 \return SObject_ptr arguments, the object found
157 virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID);
159 //! method to Create an Object with ID = anObjectID
161 \param anObjectID char* arguments
162 \return SObject_ptr arguments, the object found
164 virtual SALOMEDS::SObject_ptr CreateObjectID(const char* anObjectID);
166 //! method to Find an Object with ID = anObjectIOR
168 \param anObjectIOR char* arguments
169 \return SObject_ptr arguments, the object found
171 virtual SALOMEDS::SObject_ptr FindObjectIOR(const char* anObjectIOR);
173 //! method to Find an Object by its path
175 \param thePath char* arguments
176 \return SObject_ptr arguments, the object found
178 virtual SALOMEDS::SObject_ptr FindObjectByPath(const char* thePath);
180 //! method to get a path of SObject
182 \param aSO SObject_ptr arguments
183 \return char* arguments, the path of the SObject
185 virtual char* GetObjectPath(CORBA::Object_ptr theObject);
187 //! method to set a context: root ('/') is UserData component
190 virtual void SetContext(const char* thePath);
192 //! method to get a context
195 virtual char* GetContext();
197 //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
200 virtual SALOMEDS::ListOfStrings* GetObjectNames(const char* theContext);
202 //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
205 virtual SALOMEDS::ListOfStrings* GetDirectoryNames(const char* theContext);
207 //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
210 virtual SALOMEDS::ListOfStrings* GetFileNames(const char* theContext);
212 //! method to get all components names
215 virtual SALOMEDS::ListOfStrings* GetComponentNames(const char* theContext);
217 //! method to Create a ChildIterator from an SObject
219 \param aSO SObject_ptr arguments
220 \return ChildIterator_ptr arguments, the created ChildIterator
222 virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO);
224 //! method to Create a SComponentIterator
226 \return SComponentIterator_ptr arguments, the created SComponentIterator
228 virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator();
230 //! method to Create a StudyBuilder
232 \return StudyBuilder_ptr arguments, the created StudyBuilder
234 virtual SALOMEDS::StudyBuilder_ptr NewBuilder();
236 //! method to get study name
238 \return char* arguments, the study name
240 virtual char* Name();
242 //! method to set study name
244 \param name char* arguments, the study name
246 virtual void Name(const char* name);
248 //! method to get if study has been saved
250 \return bool arguments
252 virtual CORBA::Boolean IsSaved();
254 //! method to set if study has been saved
256 \param save bool arguments
258 virtual void IsSaved(CORBA::Boolean save);
260 //! method to Detect if a Study has been modified since it has been saved
262 \return bool arguments
264 virtual CORBA::Boolean IsModified();
266 //! method to get URL of the study (idem GetPersistentReference)
268 \return char* arguments, the study URL
272 //! method to set URL of the study
274 \param url char* arguments, the study URL
276 virtual void URL(const char* url);
278 virtual CORBA::Short StudyId();
279 virtual void StudyId(CORBA::Short id);
281 static SALOMEDS::Study_ptr GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb);
283 static void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb);
285 virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel);
287 virtual SALOMEDS::Study::ListOfSObject* FindDependances(SALOMEDS::SObject_ptr anObject);
289 virtual SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties();
291 virtual char* GetLastModificationDate();
293 virtual SALOMEDS::ListOfDates* GetModificationsDate();
295 virtual SALOMEDS::UseCaseBuilder_ptr GetUseCaseBuilder();
297 virtual void Close();
299 void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _autoFill = isEnabled; }
301 // postponed destroying of CORBA object functionality
302 virtual void AddPostponed(const char* theIOR);
304 virtual void AddCreatedPostponed(const char* theIOR);
306 virtual void RemovePostponed(const CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
307 // if theUndoLimit==0, removes all
308 virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects,
309 // theWay = -1: get back to the list of postponed
311 friend class SALOMEDS_StudyBuilder_i;
312 friend class SALOMEDS_SObject_i;
314 SALOMEDS_StudyManager_i* _StudyManager;
316 TSObjectMap mySObjectMap;
318 SALOMEDS_UseCaseBuilder_i* _UseCaseBuilder;
319 SALOMEDS_StudyBuilder_i* _Builder;
320 SALOMEDS::Callback_var _callbackOnAdd;
321 SALOMEDS::Callback_var _callbackOnRemove;
324 Handle(TDocStd_Document) _doc; // OCAF Document
325 CORBA::Boolean _isSaved; // True if the Study is saved
326 char* _URL; //URL of the persistent reference of the study
327 CORBA::Short _StudyId;
329 SALOMEDS_DataMapStringLabel myIORLabels;
331 // data structures for postponed destroying of CORBA object functionality
332 TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs
333 TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction
334 int myNbUndos; // number of current Undos, made by user
339 SALOMEDS::SObject_ptr _FindObject(TDF_Label theLabel,
340 const char* theObjectIOR,
342 SALOMEDS::SObject_ptr _FindObjectIOR(TDF_Label theLabel,
343 const char* theObjectIOR,
346 SALOMEDS_Study_i(); // Not implemented
347 void operator=(const SALOMEDS_Study_i&); // Not implemented