Salome HOME
2c9703d65c1fd1253c9e58b8ef46dbf7b439ef9a
[tools/medcoupling.git] / src / MEDLoader / MEDFileData.hxx
1 // Copyright (C) 2007-2016  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 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDFILEDATA_HXX__
22 #define __MEDFILEDATA_HXX__
23
24 #include "MCAuto.hxx"
25 #include "MEDFileParameter.hxx"
26 #include "MEDFileField.hxx"
27 #include "MEDFileMesh.hxx"
28 #include "MEDFileMeshSupport.hxx"
29 #include "MEDFileStructureElement.hxx"
30
31 namespace MEDCoupling
32 {
33   /*!
34    * User class.
35    */
36   class MEDFileData : public RefCountObject, public MEDFileWritableStandAlone
37   {
38   public:
39     MEDLOADER_EXPORT static MEDFileData *New(const std::string& fileName);
40     MEDLOADER_EXPORT static MEDFileData *New(med_idt fid);
41     MEDLOADER_EXPORT static MEDFileData *New();
42     MEDLOADER_EXPORT static MEDFileData *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileData>(db); }
43     MEDLOADER_EXPORT MEDFileData *deepCopy() const;
44     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
45     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
46     MEDLOADER_EXPORT MEDFileFields *getFields() const;
47     MEDLOADER_EXPORT MEDFileMeshes *getMeshes() const;
48     MEDLOADER_EXPORT MEDFileParameters *getParams() const;
49     MEDLOADER_EXPORT void setFields(MEDFileFields *fields);
50     MEDLOADER_EXPORT void setMeshes(MEDFileMeshes *meshes);
51     MEDLOADER_EXPORT void setParams(MEDFileParameters *params);
52     MEDLOADER_EXPORT int getNumberOfFields() const;
53     MEDLOADER_EXPORT int getNumberOfMeshes() const;
54     MEDLOADER_EXPORT int getNumberOfParams() const;
55     MEDLOADER_EXPORT std::string simpleRepr() const;
56     //
57     MEDLOADER_EXPORT std::string getHeader() const;
58     MEDLOADER_EXPORT void setHeader(const std::string& header);
59     //
60     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
61     MEDLOADER_EXPORT bool changeMeshName(const std::string& oldMeshName, const std::string& newMeshName);
62     MEDLOADER_EXPORT bool unPolyzeMeshes();
63     MEDLOADER_EXPORT void dealWithStructureElements();
64     MEDLOADER_EXPORT static MCAuto<MEDFileData> Aggregate(const std::vector<const MEDFileData *>& mfds);
65     //
66     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
67   private:
68     MEDFileData();
69     MEDFileData(med_idt fid);
70     void readHeader(med_idt fid);
71     void writeHeader(med_idt fid) const;
72     void readMeshSupports(med_idt fid);
73   private:
74     MCAuto<MEDFileFields> _fields;
75     MCAuto<MEDFileMeshes> _meshes;
76     MCAuto<MEDFileParameters> _params;
77     MCAuto<MEDFileMeshSupports> _mesh_supports;
78     MCAuto<MEDFileStructureElements> _struct_elems;
79     std::string _header;
80   };
81 }
82
83 #endif