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