Salome HOME
Fix on [Bug PAL7750] Regression of UNDO in GEOM
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_StudyManager_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_StudyManager_i.hxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef __SALOMEDS_STUDYMANAGER_I_H__
30 #define __SALOMEDS_STUDYMANAGER_I_H__
31
32 // std C++ headers
33 #include <iostream.h>
34 #include <stdlib.h>
35
36 // IDL headers
37 #include <SALOMEconfig.h>
38 #include CORBA_SERVER_HEADER(SALOMEDS)
39
40 // Cascade headers
41 #include <TDocStd_Document.hxx>
42 #include <TDF_Attribute.hxx>
43 #include <TDataStd_Name.hxx>
44 #include <TDF_Label.hxx>
45 #include <TDocStd_Document.hxx>
46 #include <Standard_NotImplemented.hxx>
47
48 #include "SALOMEDS_OCAFApplication.hxx"
49 #include "SALOME_NamingService.hxx"
50
51 // HDF
52 #include "HDFOI.hxx"
53
54 class SALOMEDS_Study_i;
55
56 namespace SALOMEDS{
57
58   // To convert IOR from SALOMEDS_IORAttribute to CORBA::Object
59   CORBA::Object_var 
60   GetObject(const TDF_Label&, CORBA::ORB_ptr);
61   
62   // To convert CORBA::Object to  PortableServer::ServantBase
63   PortableServer::ServantBase_var 
64   GetServant(CORBA::Object_ptr, PortableServer::POA_ptr);
65   
66 }
67
68
69 class SALOMEDS_StudyManager_i: 
70   public virtual POA_SALOMEDS::StudyManager,
71   public virtual PortableServer::RefCountServantBase 
72 {
73   SALOMEDS_StudyManager_i(); // Not implemented
74   void operator=(const SALOMEDS_StudyManager_i&); // Not implemented
75
76 private:
77   CORBA::ORB_var _orb;
78   PortableServer::POA_var _poa;
79   SALOME_NamingService _name_service;
80   Handle (SALOMEDS_OCAFApplication) _OCAFApp;  
81   Handle(TDocStd_Document) _clipboard;
82   int _IDcounter;
83
84   // _SaveAs private function called by Save and SaveAs
85   virtual void _SaveAs(const char* aUrl,
86                        SALOMEDS::Study_ptr aStudy,
87                        CORBA::Boolean theMultiFile,
88                        CORBA::Boolean theASCII);
89   // _SaveObject private function called by _SaveAs
90   void _SaveObject(SALOMEDS_Study_i* theStudy, 
91                    SALOMEDS::SObject_ptr SC, 
92                    HDFgroup *hdf_group_datatype);
93   // _SubstituteSlash function called by Open and GetStudyByName
94   virtual std::string _SubstituteSlash(const char *aUrl);
95
96   void _SaveProperties(SALOMEDS_Study_i* theStudy, HDFgroup *hdf_group);
97
98 public:
99   //! standard constructor
100   SALOMEDS_StudyManager_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA);
101
102   //! standard destructor
103   virtual  ~SALOMEDS_StudyManager_i(); 
104
105   CORBA::ORB_var GetORB() const { return _orb; }
106
107   PortableServer::POA_var GetPOA() const { return _poa; }
108
109   SALOMEDS_Study_i* DownCast(SALOMEDS::Study_ptr theStudy) const;
110
111  //! method to Register study Manager in the naming service
112   /*!
113     \param char* arguments, the context to register the study manager in the NS
114   */  
115   void register_name(char * name);
116   
117  //! method to Create a New Study of name study_name
118   /*!
119     \param char* arguments, the new study name
120     \return Study_ptr arguments
121   */  
122   virtual SALOMEDS::Study_ptr NewStudy(const char* study_name);
123
124   //! method to Open a Study from it's persistent reference
125   /*!
126     \param char* arguments, the study URL
127     \return Study_ptr arguments
128   */ 
129   virtual SALOMEDS::Study_ptr Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception);
130
131
132   //! method to close a Study 
133   /*!
134     \param Study_ptr arguments
135   */ 
136   virtual void Close( SALOMEDS::Study_ptr aStudy);
137
138   //! method to save a Study 
139   /*!
140     \param Study_ptr arguments
141   */
142   virtual void Save( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
143
144   virtual void SaveASCII( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
145
146   //! method to save a Study to the persistent reference aUrl
147   /*!
148     \param char* arguments, the new URL of the study
149     \param Study_ptr arguments
150   */
151   virtual void SaveAs(const char* aUrl,  SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
152   virtual void SaveAsASCII(const char* aUrl,  SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
153
154  //! method to Get name list of open studies in the session
155   /*!
156     \return ListOfOpenStudies* arguments
157   */
158   virtual SALOMEDS::ListOfOpenStudies* GetOpenStudies();
159
160   //! method to get a Study from it's name
161   /*!
162     \param char* arguments, the study name
163     \return Study_ptr arguments
164   */ 
165   virtual SALOMEDS::Study_ptr GetStudyByName(const char* aStudyName) ;
166
167   //! method to get a Study from it's ID
168   /*!
169     \param char* arguments, the study ID
170     \return Study_ptr arguments
171   */ 
172   virtual SALOMEDS::Study_ptr GetStudyByID(CORBA::Short aStudyID) ;
173
174   void CopyLabel(SALOMEDS_Study_i* theSourceStudy, 
175                  const SALOMEDS::Driver_ptr theEngine,
176                  const Standard_Integer theSourceStartDepth,
177                  const TDF_Label& theSource,
178                  const TDF_Label& theDestinationMain);
179
180   TDF_Label PasteLabel(SALOMEDS_Study_i* theDestinationStudy,
181                        const SALOMEDS::Driver_ptr theEngine,
182                        const TDF_Label& theSource,
183                        const TDF_Label& theDestinationStart,
184                        const int theCopiedStudyID,
185                        const bool isFirstElement);
186   
187   virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
188   virtual CORBA::Boolean Copy(SALOMEDS::SObject_ptr theObject);
189   virtual CORBA::Boolean CanPaste(SALOMEDS::SObject_ptr theObject);
190   virtual SALOMEDS::SObject_ptr Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection);
191   
192   void ping(){};
193 };
194
195 #endif