]> SALOME platform Git repositories - modules/med.git/blob - src/MEDCalc/cmp/MEDDataManager_i.hxx
Salome HOME
[Huge] Introducing MEDCalc
[modules/med.git] / src / MEDCalc / cmp / MEDDataManager_i.hxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Authors : Guillaume Boulant (EDF) - 01/06/2011
21
22 #ifndef _MED_DATAMANAGER_I_HXX_
23 #define _MED_DATAMANAGER_I_HXX_
24
25 #include <SALOMEconfig.h>
26 #include CORBA_SERVER_HEADER(MEDDataManager)
27 #include "SALOME_GenericObj_i.hh"
28
29 #include "MEDCouplingRemapper.hxx"
30 #include "MEDCouplingUMesh.hxx"
31 #include "MEDCouplingFieldDouble.hxx"
32 using namespace ParaMEDMEM;
33
34 /*! This map is used for lifecycle management of fields used in this operator */
35 #include <map>
36 #include <string>
37 using namespace std;
38
39 typedef map<long,MEDCALC::DatasourceHandler*> DatasourceHandlerMap;
40 typedef map<long,MEDCALC::DatasourceHandler*>::iterator DatasourceHandlerMapIterator;
41
42 typedef map<long,MEDCALC::MeshHandler*> MeshHandlerMap;
43 typedef map<long,MEDCALC::MeshHandler*>::iterator MeshHandlerMapIterator;
44
45 typedef map<long,MEDCALC::FieldseriesHandler*> FieldseriesHandlerMap;
46 typedef map<long,MEDCALC::FieldseriesHandler*>::iterator FieldseriesHandlerMapIterator;
47
48 typedef map<long,MEDCALC::FieldHandler*> FieldHandlerMap;
49 typedef map<long,MEDCALC::FieldHandler*>::iterator FieldHandlerMapIterator;
50 typedef map<long,bool> FieldPersistencyMap;
51 typedef map<long,bool>::iterator FieldPersistencyMapIterator;
52
53 typedef map<long,MEDCouplingFieldDouble*> FieldDoubleMap;
54 typedef map<long,MEDCouplingFieldDouble*>::iterator FieldDoubleMapIterator;
55
56 typedef map<long,MEDCouplingUMesh*> MeshMap;
57 typedef map<long,MEDCouplingUMesh*>::iterator MeshMapIterator;
58
59 #include "MEDCALC.hxx"
60 class MEDCALC_EXPORT MEDDataManager_i: public POA_MEDCALC::MEDDataManager,
61                                        public SALOME::GenericObj_i
62 {
63 public:
64
65   //
66   // ===========================================================
67   // Functions specified in the IDL interface
68   // ===========================================================
69   //
70   // -----------------------------------------------------------
71   // Datasource management
72   MEDCALC::DatasourceHandler * loadDatasource(const char *filepath);
73   MEDCALC::DatasourceHandler * getDatasourceHandler(const char *filepath);
74
75   // -----------------------------------------------------------
76   // Mesh management
77   MEDCALC::MeshHandlerList * getMeshList(CORBA::Long datasourceId);
78   MEDCALC::MeshHandler * getMesh(CORBA::Long meshId);
79
80   // -----------------------------------------------------------
81   // Field management
82   MEDCALC::FieldseriesHandlerList * getFieldseriesListOnMesh(CORBA::Long meshId);
83   MEDCALC::FieldHandlerList * getFieldListInFieldseries(CORBA::Long fieldseriesId);
84
85   MEDCALC::FieldHandler *     getFieldHandler(CORBA::Long fieldHandlerId);
86   char *                    getFieldRepresentation(CORBA::Long fieldHandlerId);
87   MEDCALC::FieldHandlerList * getFieldHandlerList();
88
89   void                      saveFields(const char * filepath,
90                                        const MEDCALC::FieldIdList & fieldIdList);
91   void                      markAsPersistent(CORBA::Long fieldHandlerId, bool persistent);
92   void                      savePersistentFields(const char * filepath);
93
94
95   void updateFieldMetadata(CORBA::Long  fieldHandlerId,
96                            const char * fieldname,
97                            CORBA::Long  iteration,
98                            CORBA::Long  order,
99                            const char * source);
100
101   void changeUnderlyingMesh(CORBA::Long fieldHandlerId, CORBA::Long meshHandlerId);
102   MEDCALC::FieldHandler* interpolateField(CORBA::Long fieldHandlerId, CORBA::Long meshHandlerId, const MEDCALC::InterpolationParameters& params);
103
104   void   setEventListenerIOR(const char * ior);
105   char * getEventListenerIOR();
106
107   void serverlog();
108
109   //
110   // ===========================================================
111   // Other public functions (non available via CORBA)
112   // ===========================================================
113   //
114   static long LONG_UNDEFINED;
115   static MEDDataManager_i * getInstance();
116   MEDCouplingFieldDouble *  getFieldDouble(const MEDCALC::FieldHandler * fieldHandler);
117   MEDCALC::FieldHandler *     addField(MEDCouplingFieldDouble * fieldDouble,
118                                        long meshHandlerId=LONG_UNDEFINED);
119
120 private:
121   MEDDataManager_i();
122   ~MEDDataManager_i();
123
124   // The MEDDataManager is a singleton, whose instance can be obtained
125   // using the getInstance static method.
126   static MEDDataManager_i * _instance;
127
128   long _sourceLastId;
129   long _meshLastId;
130   long _fieldseriesLastId;
131   long _fieldLastId;
132   DatasourceHandlerMap _datasourceHandlerMap;
133   MeshHandlerMap _meshHandlerMap;
134   FieldseriesHandlerMap _fieldseriesHandlerMap;
135   FieldHandlerMap _fieldHandlerMap;
136   FieldDoubleMap _fieldDoubleMap;
137   MeshMap _meshMap;
138   FieldPersistencyMap _fieldPersistencyMap;
139
140   string _medEventListenerIOR;
141
142   MEDCALC::FieldHandler * newFieldHandler(const char * fieldname,
143                                           const char * meshname,
144                                           TypeOfField  type,
145                                           long         iteration,
146                                           long         order,
147                                           const char * source);
148
149   MEDCALC::FieldHandler * updateFieldHandler(CORBA::Long fieldHandlerId,
150                                              const char * fieldname,
151                                              long         iteration,
152                                              long         order,
153                                              const char * source);
154
155   std::string  file_to_source(const char * filepath);
156   std::string  source_to_file(const char * source);
157   long getDatasourceId(const char *filepath);
158
159   MEDCouplingUMesh * getUMesh(long meshHandlerId);
160   long getUMeshId(const MEDCouplingMesh * mesh);
161
162   INTERP_KERNEL::IntersectionType _getIntersectionType(const char* intersType);
163   ParaMEDMEM::NatureOfField _getNatureOfField(const char* fieldNature);
164
165 };
166
167 #endif // _MED_DATAMANAGER_I_HXX_