Salome HOME
b68fc714dfd6f795832e2b4571b54e1933266f28
[modules/med.git] / src / MEDCalc / cmp / MEDDataManager_i.hxx
1 // Copyright (C) 2007-2020  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 MEDCoupling;
33
34 /*! This map is used for lifecycle management of fields used in this operator */
35 #include <map>
36 #include <string>
37
38 typedef std::map<long,MEDCALC::DatasourceHandler*> DatasourceHandlerMap;
39 typedef std::map<long,MEDCALC::DatasourceHandler*>::iterator DatasourceHandlerMapIterator;
40
41 typedef std::map<long,MEDCALC::MeshHandler*> MeshHandlerMap;
42 typedef std::map<long,MEDCALC::MeshHandler*>::iterator MeshHandlerMapIterator;
43
44 typedef std::map<long,MEDCALC::FieldseriesHandler*> FieldseriesHandlerMap;
45 typedef std::map<long,MEDCALC::FieldseriesHandler*>::iterator FieldseriesHandlerMapIterator;
46
47 typedef std::map<long,MEDCALC::FieldHandler*> FieldHandlerMap;
48 typedef std::map<long,MEDCALC::FieldHandler*>::iterator FieldHandlerMapIterator;
49 typedef std::map<long,bool> FieldPersistencyMap;
50 typedef std::map<long,bool>::iterator FieldPersistencyMapIterator;
51
52 typedef std::map<long,MEDCouplingFieldDouble*> FieldDoubleMap;
53 typedef std::map<long,MEDCouplingFieldDouble*>::iterator FieldDoubleMapIterator;
54
55 typedef std::map<long,MEDCouplingUMesh*> MeshMap;
56 typedef std::map<long,MEDCouplingUMesh*>::iterator MeshMapIterator;
57
58 #include "MEDCALC.hxx"
59 class MEDDataManager_i: public POA_MEDCALC::MEDDataManager,
60                                        public SALOME::GenericObj_i
61 {
62 public:
63
64   //
65   // ===========================================================
66   // Functions specified in the IDL interface
67   // ===========================================================
68   //
69   // -----------------------------------------------------------
70   // Datasource management
71   MEDCALC_EXPORT MEDCALC::DatasourceHandler * loadDatasource(const char *filepath);
72   MEDCALC_EXPORT MEDCALC::DatasourceHandler * getDatasourceHandler(const char *filepath);
73   MEDCALC_EXPORT MEDCALC::DatasourceHandler * getDatasourceHandlerFromID(CORBA::Long sourceId);
74
75   // -----------------------------------------------------------
76   // Mesh management
77   MEDCALC_EXPORT MEDCALC::MeshHandlerList * getMeshHandlerList(CORBA::Long datasourceId);
78   MEDCALC_EXPORT MEDCALC::MeshHandler * getMeshHandler(CORBA::Long meshId);
79
80   // -----------------------------------------------------------
81   // Field management
82   MEDCALC_EXPORT MEDCALC::FieldseriesHandlerList * getFieldseriesListOnMesh(CORBA::Long meshId);
83   MEDCALC_EXPORT MEDCALC::FieldHandlerList * getFieldListInFieldseries(CORBA::Long fieldseriesId);
84
85   MEDCALC_EXPORT MEDCALC::FieldHandler *     getFieldHandler(CORBA::Long fieldHandlerId);
86   MEDCALC_EXPORT char *                    getFieldRepresentation(CORBA::Long fieldHandlerId);
87   MEDCALC_EXPORT MEDCALC::FieldHandlerList * getFieldHandlerList();
88
89   MEDCALC_EXPORT void      saveFields(const char * filepath,
90                                        const MEDCALC::FieldIdList & fieldIdList);
91   MEDCALC_EXPORT void      markAsPersistent(CORBA::Long fieldHandlerId, bool persistent);
92   MEDCALC_EXPORT void      savePersistentFields(const char * filepath);
93
94
95   MEDCALC_EXPORT void updateFieldMetadata(CORBA::Long  fieldHandlerId,
96                            const char * fieldname,
97                            CORBA::Long  iteration,
98                            CORBA::Long  order,
99                            const char * source);
100
101   MEDCALC_EXPORT void changeUnderlyingMesh(CORBA::Long fieldHandlerId, CORBA::Long meshHandlerId);
102   MEDCALC_EXPORT MEDCALC::FieldHandler* interpolateField(CORBA::Long fieldHandlerId, CORBA::Long meshHandlerId, const MEDCALC::InterpolationParameters& params);
103
104   MEDCALC_EXPORT void   setEventListenerIOR(const char * ior);
105   MEDCALC_EXPORT char * getEventListenerIOR();
106
107   MEDCALC_EXPORT void serverlog();
108
109   MEDCALC_EXPORT void cleanUp();
110
111   //
112   // ===========================================================
113   // Other public functions (non available via CORBA)
114   // ===========================================================
115   //
116   static long LONG_UNDEFINED;
117   MEDCALC_EXPORT static MEDDataManager_i * getInstance();
118   MEDCALC_EXPORT MEDCouplingFieldDouble *  getFieldDouble(const MEDCALC::FieldHandler * fieldHandler);
119   MEDCALC_EXPORT MEDCALC::FieldHandler *     addField(MEDCouplingFieldDouble * fieldDouble,
120                                                        long meshHandlerId=LONG_UNDEFINED);
121
122 private:
123   MEDDataManager_i();
124   ~MEDDataManager_i();
125
126   // The MEDDataManager is a singleton, whose instance can be obtained
127   // using the getInstance static method.
128   static MEDDataManager_i * _instance;
129
130   long _sourceLastId;
131   long _meshLastId;
132   long _fieldseriesLastId;
133   long _fieldLastId;
134   DatasourceHandlerMap _datasourceHandlerMap;
135   MeshHandlerMap _meshHandlerMap;
136   FieldseriesHandlerMap _fieldseriesHandlerMap;
137   FieldHandlerMap _fieldHandlerMap;
138   FieldDoubleMap _fieldDoubleMap;
139   MeshMap _meshMap;
140   FieldPersistencyMap _fieldPersistencyMap;
141
142   std::string _medEventListenerIOR;
143
144   MEDCALC::FieldHandler * newFieldHandler(const char * fieldname,
145                                           const char * meshname,
146                                           TypeOfField  type,
147                                           long         iteration,
148                                           long         order,
149                                           const char * source);
150
151   MEDCALC::FieldHandler * updateFieldHandler(CORBA::Long fieldHandlerId,
152                                              const char * fieldname,
153                                              long         iteration,
154                                              long         order,
155                                              const char * source);
156
157   std::string  file_to_source(const char * filepath);
158   std::string  source_to_file(const char * source);
159   long getDatasourceId(const char *filepath);
160
161   MEDCouplingUMesh * getUMesh(long meshHandlerId);
162   long getUMeshId(const MEDCouplingMesh * mesh);
163
164   INTERP_KERNEL::IntersectionType _getIntersectionType(const char* intersType);
165   MEDCoupling::NatureOfField _getNatureOfField(const char* fieldNature);
166
167 };
168
169 #endif // _MED_DATAMANAGER_I_HXX_