Salome HOME
This commit was generated by cvs2git to create tag 'V1_4_0b1'.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Study_i.hxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
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. 
10 // 
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. 
15 // 
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 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_Study_i.hxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef __SALOMEDS_STUDY_I_H__
30 #define __SALOMEDS_STUDY_I_H__
31
32 // std C++ headers
33 #include <iostream.h>
34
35 // IDL headers
36 #include <SALOMEconfig.h>
37 #include CORBA_SERVER_HEADER(SALOMEDS)
38
39 // Cascade headers
40 #include <TDocStd_Document.hxx>
41 #include <TDF_Tool.hxx>
42 #include <TDF_Data.hxx>
43 #include <TDF_Label.hxx>
44 #include <stdio.h>
45 #include <TColStd_SequenceOfInteger.hxx>
46 #include <TColStd_SequenceOfAsciiString.hxx>
47
48 //SALOMEDS headers
49 #include "SALOMEDS_SComponentIterator_i.hxx"
50 #include "SALOMEDS_ChildIterator_i.hxx"
51 #include "SALOMEDS_StudyBuilder_i.hxx"
52 #include "SALOMEDS_SObject_i.hxx"
53 #include "SALOMEDS_DataMapStringLabel.hxx"
54 #include "SALOMEDS_UseCaseBuilder_i.hxx"
55
56 #include "SALOMEDS_Callback_i.hxx"
57
58 class SALOMEDS_Study_i: public POA_SALOMEDS::Study,
59                         public PortableServer::RefCountServantBase {
60 private:
61   CORBA::ORB_ptr           _orb;
62   char*                    _name;  
63   Handle(TDocStd_Document) _doc;  // OCAF Document
64   CORBA::Boolean           _isSaved; // True if the Study is saved
65   char*                    _URL; //URL of the persistent reference of the study
66   SALOMEDS::SObject_ptr    _FindObject(SALOMEDS::SObject_ptr SO,
67                                        const char* anObjectName,
68                                        bool& _find);
69   SALOMEDS::SObject_ptr    _FindObjectIOR(SALOMEDS::SObject_ptr SO,
70                                           const char* anObjectIOR,
71                                           bool& _find);
72   CORBA::Short             _StudyId;
73
74   SALOMEDS_DataMapStringLabel myIORLabels;
75
76   // data structures for postponed destroying of CORBA object functionality
77   TColStd_SequenceOfAsciiString myPostponedIORs; // ordered set of IORs
78   TColStd_SequenceOfInteger myNbPostponed; // number of IOR in the each transaction
79   int myNbUndos; // number of current Undos, made by user
80
81   TDF_Label                _current;
82   bool                     _autoFill;  
83
84 public:
85
86   //! standard constructor
87   SALOMEDS_Study_i(const Handle(TDocStd_Document), 
88                    CORBA::ORB_ptr, 
89                    const char* study_name);
90   
91   //! standard destructor
92   virtual ~SALOMEDS_Study_i(); 
93   
94   //! method to Get persistent reference of study (idem URL())
95   /*!
96     \sa URL()
97     \return char* arguments, the persistent reference of the study
98   */  
99   virtual char* GetPersistentReference();
100
101
102   //! method to Get transient reference of study
103   /*!
104     \return char* arguments, the transient reference of the study
105   */  
106   virtual char* GetTransientReference();
107
108   //! method to detect if a study is empty
109   /*!
110     \return bool arguments, true if study is empty
111   */  
112   virtual CORBA::Boolean IsEmpty();
113
114   //! method to Find a Component with ComponentDataType = aComponentName
115   /*!
116     \param aComponentName char* arguments
117     \return SComponent_ptr arguments, the component found
118   */  
119   virtual SALOMEDS::SComponent_ptr FindComponent (const char* aComponentName);
120
121   //! method to Find a Component Find a Component from it's ID
122   /*!
123     \param aComponentID char* arguments
124     \return SComponent_ptr arguments, the component found
125   */  
126   virtual SALOMEDS::SComponent_ptr FindComponentID(const char* aComponentID);
127
128   //! method to  Find an Object with SALOMEDS::Name = anObjectName 
129   /*!
130     \param anObjectName char* arguments
131     \return SObject_ptr arguments, the object found
132   */  
133   virtual SALOMEDS::SObject_ptr FindObject(const char* anObjectName);
134
135
136   //! method to Find Object(s) with SALOMEDS::Name = anObjectName in a component with ComponentDataType = aComponentName
137   /*!
138     \param anObjectName char* arguments
139     \param aComponentName char* arguments
140     \return ListOfSObject_ptr arguments, a list of objects found
141   */  
142   
143   virtual SALOMEDS::Study::ListOfSObject* FindObjectByName( const char* anObjectName, const char* aComponentName ) ;
144   
145   //! method to Find an Object with ID = anObjectID 
146   /*!
147     \param anObjectID char* arguments
148     \return SObject_ptr arguments, the object found
149   */  
150   virtual SALOMEDS::SObject_ptr FindObjectID(const char* anObjectID);
151
152   //! method to Find an Object with ID = anObjectIOR 
153   /*!
154     \param anObjectIOR char* arguments
155     \return SObject_ptr arguments, the object found
156   */  
157   virtual SALOMEDS::SObject_ptr FindObjectIOR(const char* anObjectIOR);
158
159   //! method to Find an Object by its path
160   /*!
161     \param thePath char* arguments
162     \return SObject_ptr arguments, the object found
163   */
164   virtual SALOMEDS::SObject_ptr FindObjectByPath(const char* thePath);
165
166   //! method to get a path of SObject
167   /*!
168     \param aSO  SObject_ptr arguments
169     \return char* arguments, the path of the SObject
170   */
171   virtual char* GetObjectPath(CORBA::Object_ptr theObject);
172
173   //! method to set a context: root ('/') is UserData component
174   /*!
175   */
176   virtual void SetContext(const char* thePath);
177
178   //! method to get a context
179   /*!
180   */
181   virtual char* GetContext();  
182
183   //! method to get all object names in the given context (or in the current context, if 'theContext' is empty)
184   /*!
185   */
186   virtual SALOMEDS::ListOfStrings* GetObjectNames(const char* theContext);
187
188   //! method to get all directory names in the given context (or in the current context, if 'theContext' is empty)
189   /*!
190   */
191   virtual SALOMEDS::ListOfStrings* GetDirectoryNames(const char* theContext);
192
193   //! method to get all file names in the given context (or in the current context, if 'theContext' is empty)
194   /*!
195   */
196   virtual SALOMEDS::ListOfStrings* GetFileNames(const char* theContext);
197
198   //! method to get all components names
199   /*!
200   */
201   virtual SALOMEDS::ListOfStrings* GetComponentNames(const char* theContext);
202
203   //! method to Create a ChildIterator from an SObject 
204   /*!
205     \param aSO  SObject_ptr arguments
206     \return ChildIterator_ptr arguments, the created ChildIterator
207   */  
208   virtual SALOMEDS::ChildIterator_ptr NewChildIterator(SALOMEDS::SObject_ptr aSO);
209
210   //! method to Create a SComponentIterator 
211   /*!
212     \return SComponentIterator_ptr arguments, the created SComponentIterator
213   */  
214   virtual SALOMEDS::SComponentIterator_ptr NewComponentIterator();
215
216   //! method to Create a StudyBuilder
217   /*!
218     \return StudyBuilder_ptr arguments, the created StudyBuilder
219   */  
220   virtual SALOMEDS::StudyBuilder_ptr NewBuilder();
221  
222   //! method to get study name
223   /*!
224     \return char* arguments, the study name
225   */
226   virtual char* Name();
227
228   //! method to set study name
229   /*!
230     \param name char* arguments, the study name
231   */
232   virtual void  Name(const char* name);
233
234   //! method to get if study has been saved
235   /*!
236     \return bool arguments
237   */
238   virtual CORBA::Boolean IsSaved();
239
240  //! method to set if study has been saved
241   /*!
242     \param save bool arguments
243   */
244   virtual void  IsSaved(CORBA::Boolean save);
245
246  //! method to Detect if a Study has been modified since it has been saved
247   /*!
248     \return bool arguments
249   */
250   virtual CORBA::Boolean IsModified();
251
252   //! method to get URL of the study (idem GetPersistentReference) 
253   /*!
254     \return char* arguments, the study URL 
255   */
256   virtual char* URL();
257
258  //! method to set URL of the study
259   /*!
260     \param url char* arguments, the study URL
261   */
262   virtual void  URL(const char* url);
263
264
265   virtual CORBA::Short StudyId();
266   virtual void  StudyId(CORBA::Short id);
267
268   static SALOMEDS::Study_ptr GetStudy(const TDF_Label theLabel, CORBA::ORB_ptr orb);
269
270   static void IORUpdated(const Handle(SALOMEDS_IORAttribute) theAttribute, CORBA::ORB_ptr orb);
271
272   virtual void UpdateIORLabelMap(const char* anIOR, const char* aLabel);
273   
274   virtual SALOMEDS::Study::ListOfSObject* FindDependances(SALOMEDS::SObject_ptr anObject);
275
276   virtual SALOMEDS::AttributeStudyProperties_ptr SALOMEDS_Study_i::GetProperties();
277
278   virtual char* GetLastModificationDate();
279
280   virtual SALOMEDS::ListOfDates* GetModificationsDate();
281
282   virtual char* ConvertObjectToIOR(CORBA::Object_ptr theObject) {return _orb->object_to_string(theObject); }
283   virtual CORBA::Object_ptr ConvertIORToObject(const char* theIOR) { return _orb->string_to_object(theIOR); };
284
285   virtual SALOMEDS::UseCaseBuilder_ptr GetUseCaseBuilder();
286
287   virtual void Close();
288
289   void EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) { _autoFill = isEnabled; }
290
291   // postponed destroying of CORBA object functionality
292   virtual void AddPostponed(const char* theIOR);
293
294   virtual void AddCreatedPostponed(const char* theIOR);
295
296   virtual void RemovePostponed(const CORBA::Long theUndoLimit); // removes postponed IORs of old transaction
297                                                         // if theUndoLimit==0, removes all
298   virtual void UndoPostponed(const CORBA::Long theWay); // theWay = 1: resurrect objects,
299                                                 // theWay = -1: get back to the list of postponed
300 };
301 #endif