Salome HOME
Copyrights update
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyManager.hxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/
19 //
20 //  File   : SALOMEDSImpl_StudyManager.hxx
21 //  Author : Sergey RUIN
22 //  Module : SALOME
23
24 #ifndef __SALOMEDSImpl_STUDYMANAGER_I_H__
25 #define __SALOMEDSImpl_STUDYMANAGER_I_H__
26
27 //Handle definition
28 #include <Handle_MMgt_TShared.hxx>
29 #include <Standard_DefineHandle.hxx>
30 DEFINE_STANDARD_HANDLE( SALOMEDSImpl_StudyManager, MMgt_TShared )
31
32 // std C++ headers
33 #include <strstream>
34
35 // Cascade headers
36 #include "SALOMEDSImpl_OCAFApplication.hxx"
37 #include "SALOMEDSImpl_Study.hxx"
38 #include "SALOMEDSImpl_SObject.hxx"
39 #include "SALOMEDSImpl_Driver.hxx"
40 #include <TCollection_AsciiString.hxx>
41 #include <TDF_Attribute.hxx>
42 #include <TDF_Label.hxx>
43 #include <TDocStd_Document.hxx>
44 #include <TColStd_HSequenceOfTransient.hxx>
45
46 class HDFgroup;
47
48 class SALOMEDSImpl_StudyManager : public MMgt_TShared 
49 {
50
51 private:
52
53   Handle (SALOMEDSImpl_OCAFApplication) _OCAFApp;  
54   int _IDcounter;
55   Handle(TDocStd_Document) _clipboard;
56   TCollection_AsciiString  _errorCode;
57
58 public:
59
60   //! standard constructor
61   Standard_EXPORT SALOMEDSImpl_StudyManager();
62
63   //! standard destructor
64   Standard_EXPORT virtual  ~SALOMEDSImpl_StudyManager(); 
65
66   //! method to Create a New Study of name study_name
67   Standard_EXPORT virtual Handle(SALOMEDSImpl_Study) NewStudy(const TCollection_AsciiString& study_name);
68
69   //! method to Open a Study from it's persistent reference
70   Standard_EXPORT virtual Handle(SALOMEDSImpl_Study) Open(const TCollection_AsciiString& aStudyUrl);
71
72   //! method to close a Study 
73   Standard_EXPORT virtual void Close(const Handle(SALOMEDSImpl_Study)& aStudy);
74
75   //! method to save a Study 
76   Standard_EXPORT virtual bool Save(const Handle(SALOMEDSImpl_Study)& aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile);
77
78   Standard_EXPORT virtual bool SaveASCII(const Handle(SALOMEDSImpl_Study)& aStudy, 
79                          SALOMEDSImpl_DriverFactory* aFactory, 
80                          bool theMultiFile);
81
82   //! method to save a Study to the persistent reference aUrl
83   Standard_EXPORT virtual bool SaveAs(const TCollection_AsciiString& aUrl,  
84                       const Handle(SALOMEDSImpl_Study)& aStudy, 
85                       SALOMEDSImpl_DriverFactory* aFactory,
86                       bool theMultiFile);
87
88   Standard_EXPORT virtual bool SaveAsASCII(const TCollection_AsciiString& aUrl, 
89                            const Handle(SALOMEDSImpl_Study)& aStudy, 
90                            SALOMEDSImpl_DriverFactory* aFactory,
91                            bool theMultiFile);
92
93   //! method to Get name list of open studies in the session
94   Standard_EXPORT virtual Handle(TColStd_HSequenceOfTransient) GetOpenStudies();
95
96   //! method to get a Study from it's name
97   Standard_EXPORT virtual Handle(SALOMEDSImpl_Study) GetStudyByName(const TCollection_AsciiString& aStudyName) ;
98
99   //! method to get a Study from it's ID
100   Standard_EXPORT virtual Handle(SALOMEDSImpl_Study) GetStudyByID(int aStudyID) ;
101
102
103   Standard_EXPORT Handle(TDocStd_Document) GetDocumentOfStudy(const Handle(SALOMEDSImpl_Study)& theStudy);
104
105   Standard_EXPORT Handle(TDocStd_Document) GetClipboard() { return _clipboard; }
106   
107   Standard_EXPORT bool CopyLabel(const Handle(SALOMEDSImpl_Study)& theSourceStudy, 
108                  SALOMEDSImpl_Driver* theEngine,
109                  const int theSourceStartDepth,
110                  const TDF_Label& theSource,
111                  const TDF_Label& theDestinationMain);
112
113   Standard_EXPORT TDF_Label PasteLabel(const Handle(SALOMEDSImpl_Study)& theDestinationStudy,
114                        SALOMEDSImpl_Driver* theEngine,
115                        const TDF_Label& theSource,
116                        const TDF_Label& theDestinationStart,
117                        const int theCopiedStudyID,
118                        const bool isFirstElement);
119   
120   Standard_EXPORT virtual bool CanCopy(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine);
121   Standard_EXPORT virtual bool Copy(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine);
122   Standard_EXPORT virtual bool CanPaste(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine);
123   Standard_EXPORT virtual Handle(SALOMEDSImpl_SObject) Paste(const Handle(SALOMEDSImpl_SObject)& theObject, SALOMEDSImpl_Driver* Engine);
124
125   // _SaveAs private function called by Save and SaveAs
126   Standard_EXPORT virtual bool Impl_SaveAs(const TCollection_AsciiString& aUrl,
127                            const Handle(SALOMEDSImpl_Study)& aStudy,
128                            SALOMEDSImpl_DriverFactory* aFactory,
129                            bool theMultiFile,
130                            bool theASCII);
131
132   // _SaveObject private function called by _SaveAs
133   Standard_EXPORT virtual bool Impl_SaveObject(const Handle(SALOMEDSImpl_SObject)& SC, HDFgroup *hdf_group_datatype);
134
135   // _SubstituteSlash function called by Open and GetStudyByName
136   Standard_EXPORT virtual TCollection_AsciiString Impl_SubstituteSlash(const TCollection_AsciiString& aUrl);
137
138   Standard_EXPORT virtual bool Impl_SaveProperties(const Handle(SALOMEDSImpl_Study)& aStudy, HDFgroup *hdf_group);
139
140   Standard_EXPORT TCollection_AsciiString GetErrorCode() { return _errorCode; }
141   Standard_EXPORT virtual bool IsError() { return _errorCode != ""; }
142
143 public:
144   DEFINE_STANDARD_RTTI( SALOMEDSImpl_StudyManager )
145   
146 };
147
148 #endif