Salome HOME
f0e6a547a53a0869561217e0e92f9092a1c34fd3
[modules/hexablock.git] / src / HEXABLOCK / HexDumpStudy.hxx
1
2 // Class : Ecriture d'un dump python
3
4 // Copyright (C) 2009-2013  CEA/DEN, EDF R&D
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ 
21 // or email : webmaster.salome@opencascade.com
22
23 #ifndef __DUMP_STUDY_H_
24 #define __DUMP_STUDY_H_
25
26 #include "Hex_defines.hxx"
27 #include "hexa_base.hxx"
28 #include <map>
29
30 #if defined WIN32
31 #pragma warning ( disable: 4251 )
32 #endif
33
34
35 BEGIN_NAMESPACE_HEXA
36
37
38 #define DumpStart0(p) bool actif=el_root->glob->dump.start(this, p)
39 #define DumpStart(p,args) bool actif=el_root->glob->dump.start(this, p); if (actif)  el_root->glob->dump << args
40 #define DumpEnd       el_root->glob->dump.close (actif)
41 #define DumpReturn(v) el_root->glob->dump.close (actif,v)
42
43 #define DumpLock    bool actif=el_root->glob->dump.lock ()
44 #define DumpRestore            el_root->glob->dump.restore (actif)
45
46 class Witness;
47 class HEXABLOCKENGINE_EXPORT DumpStudy
48 {
49 public :
50     DumpStudy ();
51     void setWitness (Witness* temoin)       { witness = temoin ; }
52
53     DumpStudy& operator << (int      val);
54     DumpStudy& operator << (double   val);
55     DumpStudy& operator << (cpchar   val);
56     DumpStudy& operator << (EltBase* elt);
57     DumpStudy& operator << (Edges&   elt);
58     DumpStudy& operator << (Quads&   elt);
59     DumpStudy& operator << (Hexas&   elt);
60     DumpStudy& operator << (RealVector& elt);
61
62     bool start (EltBase* obj, cpchar method);
63     bool start (cpchar   obj, cpchar method, bool razmess=true);
64     void close (bool reactive);
65     void close (bool reactive, EltBase* retour);
66     void close (bool reactive, int      retour);
67     void close (bool reactive, double   retour);
68
69     bool lock ();
70     void restore  (bool reactive);
71     void getBegin (string& begin);
72
73 private :
74    cpchar findName   (EltBase* elt);
75    void addArgVector (EnumElt type, TabElts& table);
76    void addArgument  (cpchar  arg);
77    void addArgument  (string& arg) { addArgument (arg.c_str()) ; }
78    void declareVectors ();
79    void addVector (cpchar name);
80    void majVector (cpchar value);
81    void closeVector ();
82
83 private :
84    std::map    <EltBase*, std::string> map_name;
85    std::vector <std::string>           tab_declar;
86
87    int    tab_count [EL_MAXI];
88    string curr_vector;
89    int    nbr_values;
90
91    FILE*    fic_dump;
92    string   this_name;
93    string   right_part;
94    bool     is_open;
95    int      nbr_nulls;
96    int      nbr_args;
97    Witness* witness;
98 };
99 END_NAMESPACE_HEXA
100 #endif