Salome HOME
Fix pb. with loading of last module (in list).
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_Driver_i.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 #ifndef __SALOMEDS_DRIVER_I_H__
21 #define __SALOMEDS_DRIVER_I_H__
22
23 #include <omniORB4/CORBA.h>
24 #include "SALOMEDSImpl_Driver.hxx"
25 #include "SALOMEDSImpl_SComponent.hxx"
26 #include "SALOMEDSImpl_SObject.hxx"
27
28 #include <SALOMEconfig.h>   
29 #include CORBA_SERVER_HEADER(SALOMEDS) 
30 #include CORBA_SERVER_HEADER(SALOME_Component)
31
32 class Standard_EXPORT SALOMEDS_Driver_i :  public virtual SALOMEDSImpl_Driver 
33 {
34 protected:
35   SALOMEDS::Driver_var _driver;
36   CORBA::ORB_var _orb;
37
38 public:
39
40   SALOMEDS_Driver_i(SALOMEDS::Driver_ptr theDriver, CORBA::ORB_ptr theORB) 
41     {
42       _driver = SALOMEDS::Driver::_duplicate(theDriver);
43       _orb = CORBA::ORB::_duplicate(theORB);        
44     }
45
46   ~SALOMEDS_Driver_i();
47
48   virtual std::string GetIOR() 
49     {
50       CORBA::String_var ior = _orb->object_to_string(_driver);
51       return std::string(ior);
52     }
53
54   virtual SALOMEDSImpl_TMPFile* Save(const SALOMEDSImpl_SComponent& theComponent,
55                                      const std::string& theURL,
56                                      long& theStreamLength,
57                                      bool isMultiFile);
58
59   virtual SALOMEDSImpl_TMPFile* SaveASCII(const SALOMEDSImpl_SComponent& theComponent,
60                                           const std::string& theURL,
61                                           long& theStreamLength,
62                                           bool isMultiFile);
63   
64   virtual bool Load(const SALOMEDSImpl_SComponent& theComponent,
65                     const unsigned char* theStream,
66                     const long theStreamLength,
67                     const std::string& theURL,
68                     bool isMultiFile);
69
70   virtual bool LoadASCII(const SALOMEDSImpl_SComponent& theComponent,
71                          const unsigned char* theStream,
72                          const long theStreamLength,
73                          const std::string& theURL,
74                          bool isMultiFile);
75
76   virtual void Close(const SALOMEDSImpl_SComponent& theComponent);
77  
78   virtual std::string ComponentDataType() 
79     {
80       CORBA::String_var ior = _driver->ComponentDataType();
81       return std::string(ior);
82     }
83
84
85   virtual std::string IORToLocalPersistentID(const SALOMEDSImpl_SObject& theSObject,
86                                              const std::string& IORString,
87                                              bool isMultiFile,
88                                              bool isASCII);
89
90   virtual std::string LocalPersistentIDToIOR(const SALOMEDSImpl_SObject& theSObject,
91                                              const std::string& aLocalPersistentID,
92                                              bool isMultiFile,
93                                              bool isASCII);
94
95   virtual bool CanCopy(const SALOMEDSImpl_SObject& theObject);
96
97   virtual SALOMEDSImpl_TMPFile* CopyFrom(const SALOMEDSImpl_SObject& theObject, 
98                                          int& theObjectID,
99                                          long& theStreamLength);
100   
101   virtual bool CanPaste(const std::string& theComponentName, int theObjectID);
102
103   virtual std::string PasteInto(const unsigned char* theStream,
104                                 const long theStreamLength,
105                                 int theObjectID,
106                                 const SALOMEDSImpl_SObject& theObject);
107
108   virtual SALOMEDSImpl_TMPFile* DumpPython(SALOMEDSImpl_Study* theStudy, 
109                                            bool isPublished, 
110                                            bool& isValidScript,
111                                            long& theStreamLength);
112 };
113
114 #include "SALOME_NamingService.hxx"
115 #include "SALOME_LifeCycleCORBA.hxx"
116
117 class SALOMEDS_DriverFactory_i : public virtual SALOMEDSImpl_DriverFactory 
118 {
119 protected:  
120   CORBA::ORB_ptr        _orb;
121   SALOME_NamingService* _name_service;
122
123 public:
124   
125   SALOMEDS_DriverFactory_i(CORBA::ORB_ptr theORB) 
126     {
127       _orb = CORBA::ORB::_duplicate(theORB);
128       _name_service = new SALOME_NamingService(_orb);
129     }
130
131
132   ~SALOMEDS_DriverFactory_i() 
133   {
134     delete _name_service;
135   }
136    
137   virtual SALOMEDSImpl_Driver* GetDriverByType(const std::string& theComponentType);
138
139   virtual SALOMEDSImpl_Driver* GetDriverByIOR(const std::string& theIOR);
140 };
141
142 #endif