Salome HOME
PR: merge from tag mergeto_trunk_17Jan05
[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   virtual void _SaveObject(SALOMEDS::Study_ptr aStudy, 
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   virtual void _SaveProperties(SALOMEDS::Study_ptr aStudy, 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  //! method to Register study Manager in the naming service
110   /*!
111     \param char* arguments, the context to register the study manager in the NS
112   */  
113   void register_name(char * name);
114   
115  //! method to Create a New Study of name study_name
116   /*!
117     \param char* arguments, the new study name
118     \return Study_ptr arguments
119   */  
120   virtual SALOMEDS::Study_ptr NewStudy(const char* study_name);
121
122   //! method to Open a Study from it's persistent reference
123   /*!
124     \param char* arguments, the study URL
125     \return Study_ptr arguments
126   */ 
127   virtual SALOMEDS::Study_ptr Open(const char* aStudyUrl) throw (SALOME::SALOME_Exception);
128
129
130   //! method to close a Study 
131   /*!
132     \param Study_ptr arguments
133   */ 
134   virtual void Close( SALOMEDS::Study_ptr aStudy);
135
136   //! method to save a Study 
137   /*!
138     \param Study_ptr arguments
139   */
140   virtual void Save( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
141
142   virtual void SaveASCII( SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
143
144   //! method to save a Study to the persistent reference aUrl
145   /*!
146     \param char* arguments, the new URL of the study
147     \param Study_ptr arguments
148   */
149   virtual void SaveAs(const char* aUrl,  SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
150   virtual void SaveAsASCII(const char* aUrl,  SALOMEDS::Study_ptr aStudy, CORBA::Boolean theMultiFile);
151
152  //! method to Get name list of open studies in the session
153   /*!
154     \return ListOfOpenStudies* arguments
155   */
156   virtual SALOMEDS::ListOfOpenStudies* GetOpenStudies();
157
158   //! method to get a Study from it's name
159   /*!
160     \param char* arguments, the study name
161     \return Study_ptr arguments
162   */ 
163   virtual SALOMEDS::Study_ptr GetStudyByName(const char* aStudyName) ;
164
165   //! method to get a Study from it's ID
166   /*!
167     \param char* arguments, the study ID
168     \return Study_ptr arguments
169   */ 
170   virtual SALOMEDS::Study_ptr GetStudyByID(CORBA::Short aStudyID) ;
171
172   void CopyLabel(SALOMEDS_Study_i* theSourceStudy, 
173                  const SALOMEDS::Driver_ptr theEngine,
174                  const Standard_Integer theSourceStartDepth,
175                  const TDF_Label& theSource,
176                  const TDF_Label& theDestinationMain);
177
178   TDF_Label PasteLabel(SALOMEDS_Study_i* theDestinationStudy,
179                        const SALOMEDS::Driver_ptr theEngine,
180                        const TDF_Label& theSource,
181                        const TDF_Label& theDestinationStart,
182                        const int theCopiedStudyID,
183                        const bool isFirstElement);
184   
185   virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject);
186   virtual CORBA::Boolean Copy(SALOMEDS::SObject_ptr theObject);
187   virtual CORBA::Boolean CanPaste(SALOMEDS::SObject_ptr theObject);
188   virtual SALOMEDS::SObject_ptr Paste(SALOMEDS::SObject_ptr theObject) throw(SALOMEDS::StudyBuilder::LockProtection);
189   
190   void ping(){};
191 };
192
193 #endif