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