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