1 // Copyright (C) 2007-2023 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Authors : Guillaume Boulant (EDF) - 01/06/2011
22 #ifndef _MED_DATAMANAGER_I_HXX_
23 #define _MED_DATAMANAGER_I_HXX_
25 #include <SALOMEconfig.h>
26 #include CORBA_SERVER_HEADER(MEDDataManager)
27 #include "SALOME_GenericObj_i.hh"
29 #include "MEDCouplingRemapper.hxx"
30 #include "MEDCouplingUMesh.hxx"
31 #include "MEDCouplingFieldDouble.hxx"
32 #include "MEDCouplingFieldFloat.hxx"
33 using namespace MEDCoupling;
35 /*! This map is used for lifecycle management of fields used in this operator */
39 typedef std::map<long,MEDCALC::DatasourceHandler*> DatasourceHandlerMap;
40 typedef std::map<long,MEDCALC::DatasourceHandler*>::iterator DatasourceHandlerMapIterator;
42 typedef std::map<long,MEDCALC::MeshHandler*> MeshHandlerMap;
43 typedef std::map<long,MEDCALC::MeshHandler*>::iterator MeshHandlerMapIterator;
45 typedef std::map<long,MEDCALC::FieldseriesHandler*> FieldseriesHandlerMap;
46 typedef std::map<long,MEDCALC::FieldseriesHandler*>::iterator FieldseriesHandlerMapIterator;
48 typedef std::map<long,MEDCALC::FieldHandler*> FieldHandlerMap;
49 typedef std::map<long,MEDCALC::FieldHandler*>::iterator FieldHandlerMapIterator;
50 typedef std::map<long,bool> FieldPersistencyMap;
51 typedef std::map<long,bool>::iterator FieldPersistencyMapIterator;
53 typedef std::map<long,MEDCouplingFieldDouble*> FieldDoubleMap;
54 typedef std::map<long,MEDCouplingFieldDouble*>::iterator FieldDoubleMapIterator;
56 typedef std::map<long,MEDCouplingUMesh*> MeshMap;
57 typedef std::map<long,MEDCouplingUMesh*>::iterator MeshMapIterator;
59 #include "MEDCALC.hxx"
60 class MEDDataManager_i: public POA_MEDCALC::MEDDataManager,
61 public SALOME::GenericObj_i
66 // ===========================================================
67 // Functions specified in the IDL interface
68 // ===========================================================
70 // -----------------------------------------------------------
71 // Datasource management
72 MEDCALC_EXPORT MEDCALC::DatasourceHandler * loadDatasource(const char *filepath);
73 MEDCALC_EXPORT MEDCALC::DatasourceHandler * getDatasourceHandler(const char *filepath);
74 MEDCALC_EXPORT MEDCALC::DatasourceHandler * getDatasourceHandlerFromID(CORBA::Long sourceId);
76 // -----------------------------------------------------------
78 MEDCALC_EXPORT MEDCALC::MeshHandlerList * getMeshHandlerList(CORBA::Long datasourceId);
79 MEDCALC_EXPORT MEDCALC::MeshHandler * getMeshHandler(CORBA::Long meshId);
81 // -----------------------------------------------------------
83 MEDCALC_EXPORT MEDCALC::FieldseriesHandlerList * getFieldseriesListOnMesh(CORBA::Long meshId);
84 MEDCALC_EXPORT MEDCALC::FieldHandlerList * getFieldListInFieldseries(CORBA::Long fieldseriesId);
86 MEDCALC_EXPORT CORBA::Long getFieldIdAtTimestamp(CORBA::Long fieldseriesId, double timestamp);
88 MEDCALC_EXPORT MEDCALC::FieldHandler * getFieldHandler(CORBA::Long fieldHandlerId);
89 MEDCALC_EXPORT char * getFieldRepresentation(CORBA::Long fieldHandlerId);
90 MEDCALC_EXPORT MEDCALC::FieldHandlerList * getFieldHandlerList();
92 MEDCALC_EXPORT void saveFields(const char * filepath,
93 const MEDCALC::FieldIdList & fieldIdList);
94 MEDCALC_EXPORT void markAsPersistent(CORBA::Long fieldHandlerId, bool persistent);
95 MEDCALC_EXPORT void savePersistentFields(const char * filepath);
98 MEDCALC_EXPORT void updateFieldMetadata(CORBA::Long fieldHandlerId,
99 const char * fieldname,
100 CORBA::Long iteration,
102 const char * source);
104 MEDCALC_EXPORT void changeUnderlyingMesh(CORBA::Long fieldHandlerId, CORBA::Long meshHandlerId);
105 MEDCALC_EXPORT MEDCALC::FieldHandler* interpolateField(CORBA::Long fieldHandlerId, CORBA::Long meshHandlerId, const MEDCALC::InterpolationParameters& params);
107 MEDCALC_EXPORT void setEventListenerIOR(const char * ior);
108 MEDCALC_EXPORT char * getEventListenerIOR();
110 MEDCALC_EXPORT void serverlog();
112 MEDCALC_EXPORT void cleanUp();
115 // ===========================================================
116 // Other public functions (non available via CORBA)
117 // ===========================================================
119 static long LONG_UNDEFINED;
120 MEDCALC_EXPORT static MEDDataManager_i * getInstance();
121 MEDCALC_EXPORT MEDCouplingFieldDouble * getFieldDouble(const MEDCALC::FieldHandler * fieldHandler);
122 MEDCALC_EXPORT MEDCALC::FieldHandler * addField(MEDCouplingFieldDouble * fieldDouble,
123 long meshHandlerId=LONG_UNDEFINED);
129 // The MEDDataManager is a singleton, whose instance can be obtained
130 // using the getInstance static method.
131 static MEDDataManager_i * _instance;
135 long _fieldseriesLastId;
137 DatasourceHandlerMap _datasourceHandlerMap;
138 MeshHandlerMap _meshHandlerMap;
139 FieldseriesHandlerMap _fieldseriesHandlerMap;
140 FieldHandlerMap _fieldHandlerMap;
141 FieldDoubleMap _fieldDoubleMap;
143 FieldPersistencyMap _fieldPersistencyMap;
145 std::string _medEventListenerIOR;
147 MEDCALC::FieldHandler * newFieldHandler(const char * fieldname,
148 const char * meshname,
152 const char * source);
154 MEDCALC::FieldHandler * updateFieldHandler(CORBA::Long fieldHandlerId,
155 const char * fieldname,
158 const char * source);
160 std::string file_to_source(const char * filepath);
161 std::string source_to_file(const char * source);
162 bool isSourceInFile(const char * sourceName);
163 long getDatasourceId(const char *filepath);
165 MEDCouplingUMesh * getUMesh(long meshHandlerId);
166 long getUMeshId(const MEDCouplingMesh * mesh);
168 double getFieldTimestamp(CORBA::Long fieldHandlerId);
170 INTERP_KERNEL::IntersectionType _getIntersectionType(const char* intersType);
171 MEDCoupling::NatureOfField _getNatureOfField(const char* fieldNature);
175 #endif // _MED_DATAMANAGER_I_HXX_