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