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