Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MED / Med_Gen_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 //  MED MED : implemetation of MED idl descriptions
23 //  File   : Med_Gen_i.hxx
24 //  Author : Paul RASCLE, EDF
25 //  Module : MED
26 //
27 #ifndef _MED_GEN_I_HXX_
28 #define _MED_GEN_I_HXX_
29
30 #include <SALOMEconfig.h>
31 #include <map>
32 #include CORBA_SERVER_HEADER(MED_Gen)
33 #include CORBA_SERVER_HEADER(MED)
34 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
35
36 #include "SALOME_Component_i.hxx"
37 #include "SALOME_NamingService.hxx"
38
39 #include CORBA_SERVER_HEADER(SALOMEDS_Attributes)
40
41 #include "Med_Gen_Driver_i.hxx"
42
43 namespace MEDMEM {
44   class MED_i;
45 }
46
47 #ifdef WNT
48  #if defined MED_EXPORTS
49   #if defined WIN32
50    #define MED_EXPORT __declspec( dllexport )
51   #else
52    #define MED_EXPORT
53   #endif
54  #else
55   #if defined WIN32
56    #define MED_EXPORT __declspec( dllimport )
57   #else
58    #define MED_EXPORT
59   #endif
60  #endif
61 #else
62  #define MED_EXPORT
63 #endif
64
65 class MED_EXPORT Med_Gen_i:
66   public POA_SALOME_MED::MED_Gen,
67   public Engines_Component_i,
68   public Med_Gen_Driver_i
69 {
70 private:
71   SALOMEDS::Study_var studyName2Study(const char* studyName)
72     throw(SALOME::SALOME_Exception);
73   void addInStudy(SALOMEDS::Study_var myStudy)
74     throw(SALOME::SALOME_Exception);
75
76 public:
77   //Med_Gen_i();
78   Med_Gen_i(CORBA::ORB_ptr orb,
79             PortableServer::POA_ptr poa,
80             PortableServer::ObjectId * contId,
81             const char *instanceName,
82             const char *interfaceName);
83   virtual ~Med_Gen_i();
84
85   //
86   SALOME_MED::MESH_ptr readMeshInFile(const char* fileName,
87                                       const char* studyName,
88                                       const char* meshName)
89     throw(SALOME::SALOME_Exception);
90
91   SALOME_MED::FIELD_ptr readFieldInFile(const char* fileName,
92                                         const char* studyName,
93                                         const char* fieldName,
94                                         CORBA::Long ordre,
95                                         CORBA::Long iter)
96     throw(SALOME::SALOME_Exception);
97
98   SALOME_MED::MED_ptr   readStructFile(const char* fileName,
99                                        const char* studyName)
100     throw(SALOME::SALOME_Exception);
101
102   void    readStructFileWithFieldType(const char* fileName,
103                                       const char* studyName)
104     throw(SALOME::SALOME_Exception);
105
106   // Get last created instance of the class
107   static Med_Gen_i* GetMEDGen() { return _MEDGen; }
108
109   // Get Med of the study (for persistance)
110   static SALOME_MED::MED_ptr GetMED(SALOMEDS::SComponent_ptr theStudy);
111
112   // Get object of the CORBA reference
113   static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
114
115   template<class T>
116   static T DownCast(CORBA::Object_ptr theArg)
117   {
118     return dynamic_cast<T>(GetServant(theArg).in());
119   }
120
121   // (re)defined methods of Driver
122   char* ComponentDataType();
123   virtual Engines::Component_ptr GetComponentInstance();
124
125 private:
126   //static std::string _myFileName;
127   //static std::string _saveFileName;
128   static Med_Gen_i*  _MEDGen;    // Point to last created instance of the class
129
130 private:
131   bool   _duringLoad;
132   //int    _myStudyID;
133   //std::string _myStudyName;
134
135   //int myCounter;
136 };
137
138 #endif