Salome HOME
New implementation of SALOMEDSImpl package based on DF data structure instead of...
[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/ or email : webmaster.salome@opencascade.com
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 // std C++ headers
28 #include <strstream>
29 #include <string>
30 #include <vector>
31
32 #include "DF_Application.hxx"
33 #include "SALOMEDSImpl_Study.hxx"
34 #include "SALOMEDSImpl_SObject.hxx"
35 #include "SALOMEDSImpl_Driver.hxx"
36 #include "DF_Attribute.hxx"
37 #include "DF_Label.hxx"
38 #include "DF_Document.hxx"
39
40 class HDFgroup;
41
42 class SALOMEDSImpl_StudyManager
43 {
44
45 private:
46
47   DF_Application*   _appli;  
48   int               _IDcounter;
49   DF_Document*      _clipboard;
50   std::string       _errorCode;
51
52 public:
53
54   //! standard constructor
55   Standard_EXPORT SALOMEDSImpl_StudyManager();
56
57   //! standard destructor
58   Standard_EXPORT virtual  ~SALOMEDSImpl_StudyManager(); 
59
60   //! method to Create a New Study of name study_name
61   Standard_EXPORT virtual SALOMEDSImpl_Study* NewStudy(const std::string& study_name);
62
63   //! method to Open a Study from it's persistent reference
64   Standard_EXPORT virtual SALOMEDSImpl_Study* Open(const std::string& aStudyUrl);
65
66   //! method to close a Study 
67   Standard_EXPORT virtual void Close(SALOMEDSImpl_Study* aStudy);
68
69   //! method to save a Study 
70   Standard_EXPORT virtual bool Save(SALOMEDSImpl_Study* aStudy, SALOMEDSImpl_DriverFactory* aFactory, bool theMultiFile);
71
72   Standard_EXPORT virtual bool SaveASCII(SALOMEDSImpl_Study* aStudy, 
73                                          SALOMEDSImpl_DriverFactory* aFactory, 
74                                          bool theMultiFile);
75
76   //! method to save a Study to the persistent reference aUrl
77   Standard_EXPORT virtual bool SaveAs(const std::string& aUrl,  
78                                       SALOMEDSImpl_Study* aStudy, 
79                                       SALOMEDSImpl_DriverFactory* aFactory,
80                                       bool theMultiFile);
81
82   Standard_EXPORT virtual bool SaveAsASCII(const std::string& aUrl, 
83                                            SALOMEDSImpl_Study* aStudy, 
84                                            SALOMEDSImpl_DriverFactory* aFactory,
85                                            bool theMultiFile);
86
87   //! method to Get name list of open studies in the session
88   Standard_EXPORT virtual std::vector<SALOMEDSImpl_Study*> GetOpenStudies();
89
90   //! method to get a Study from it's name
91   Standard_EXPORT virtual SALOMEDSImpl_Study* GetStudyByName(const std::string& aStudyName) ;
92
93   //! method to get a Study from it's ID
94   Standard_EXPORT virtual SALOMEDSImpl_Study* GetStudyByID(int aStudyID) ;
95
96
97   Standard_EXPORT DF_Document* GetDocumentOfStudy(SALOMEDSImpl_Study* theStudy);
98
99   Standard_EXPORT DF_Document* GetClipboard() { return _clipboard; }
100   
101   Standard_EXPORT bool CopyLabel(SALOMEDSImpl_Study* theSourceStudy, 
102                                  SALOMEDSImpl_Driver* theEngine,
103                                  const int theSourceStartDepth,
104                                  const DF_Label& theSource,
105                                  const DF_Label& theDestinationMain);
106
107   Standard_EXPORT DF_Label PasteLabel(SALOMEDSImpl_Study* theDestinationStudy,
108                                        SALOMEDSImpl_Driver* theEngine,
109                                        const DF_Label& theSource,
110                                        const DF_Label& theDestinationStart,
111                                        const int theCopiedStudyID,
112                                        const bool isFirstElement);
113   
114   Standard_EXPORT virtual bool CanCopy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
115   Standard_EXPORT virtual bool Copy(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
116   Standard_EXPORT virtual bool CanPaste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
117   Standard_EXPORT virtual SALOMEDSImpl_SObject Paste(const SALOMEDSImpl_SObject& theObject, SALOMEDSImpl_Driver* Engine);
118
119   // _SaveAs private function called by Save and SaveAs
120   Standard_EXPORT virtual bool Impl_SaveAs(const std::string& aUrl,
121                                            SALOMEDSImpl_Study* aStudy,
122                                            SALOMEDSImpl_DriverFactory* aFactory,
123                                            bool theMultiFile,
124                                            bool theASCII);
125
126   // _SaveObject private function called by _SaveAs
127   Standard_EXPORT virtual bool Impl_SaveObject(const SALOMEDSImpl_SObject& SC, HDFgroup *hdf_group_datatype);
128
129   // _SubstituteSlash function called by Open and GetStudyByName
130   Standard_EXPORT virtual std::string Impl_SubstituteSlash(const std::string& aUrl);
131
132   Standard_EXPORT virtual bool Impl_SaveProperties(SALOMEDSImpl_Study* aStudy, HDFgroup *hdf_group);
133
134   Standard_EXPORT std::string GetErrorCode() { return _errorCode; }
135   Standard_EXPORT virtual bool IsError() { return _errorCode != ""; }
136
137 };
138
139 #endif