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