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