Salome HOME
NPAL18095: Pb. with dump python and mesh group by filter.
[modules/smesh.git] / src / SMESH_I / SMESH_PythonDump.hxx
1 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
3 // 
4 //  This library is free software; you can redistribute it and/or 
5 //  modify it under the terms of the GNU Lesser General Public 
6 //  License as published by the Free Software Foundation; either 
7 //  version 2.1 of the License. 
8 // 
9 //  This library is distributed in the hope that it will be useful, 
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 //  Lesser General Public License for more details. 
13 // 
14 //  You should have received a copy of the GNU Lesser General Public 
15 //  License along with this library; if not, write to the Free Software 
16 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
17 // 
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19
20 #ifndef _SMESH_PYTHONDUMP_HXX_
21 #define _SMESH_PYTHONDUMP_HXX_
22
23 #include <SALOMEconfig.h>
24 #include CORBA_SERVER_HEADER(SMESH_Mesh)
25 #include CORBA_SERVER_HEADER(SALOMEDS)
26
27 #include <sstream>
28
29 class SMESH_Gen_i;
30 class SMESH_MeshEditor_i;
31 class TCollection_AsciiString;
32 class Resource_DataMapOfAsciiStringAsciiString;
33
34 // ===========================================================================================
35 /*!
36  * \brief Tool converting SMESH engine calls into commands defined in smesh.py
37  *
38  * Implementation is in SMESH_2smeshpy.cxx
39  */
40 // ===========================================================================================
41
42 class SMESH_2smeshpy
43 {
44 public:
45   /*!
46    * \brief Convert a python script using commands of smesh.py
47    * \param theScript - Input script
48    * \param theEntry2AccessorMethod - The returning method names to access to
49    *        objects wrapped with python class
50    * \retval TCollection_AsciiString - Convertion result
51    */
52   static TCollection_AsciiString
53   ConvertScript(const TCollection_AsciiString& theScript,
54                 Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod);
55
56   /*!
57    * \brief Return the name of the python file wrapping IDL API
58     * \retval TCollection_AsciiString - The file name
59    */
60   static char* SmeshpyName() { return "smesh"; }
61   static char* GenName() { return "smesh.smesh"; }
62 };
63
64 namespace SMESH
65 {
66   class FilterLibrary_i;
67   class FilterManager_i;
68   class Filter_i;
69   class Functor_i;
70
71 // ===========================================================================================
72 /*!
73  * \brief Utility helping in storing SMESH engine calls as python commands
74  */
75 // ===========================================================================================
76
77   class TPythonDump
78   {
79     std::ostringstream myStream;
80     static size_t myCounter;
81   public:
82     TPythonDump();
83     virtual ~TPythonDump();
84     
85     TPythonDump& 
86     operator<<(long int theArg);
87
88     TPythonDump& 
89     operator<<(int theArg);
90
91     TPythonDump& 
92     operator<<(double theArg);
93
94     TPythonDump& 
95     operator<<(float theArg);
96
97     TPythonDump& 
98     operator<<(const void* theArg);
99
100     TPythonDump& 
101     operator<<(const char* theArg);
102
103     TPythonDump& 
104     operator<<(const SMESH::ElementType& theArg);
105
106     TPythonDump& 
107     operator<<(const SMESH::long_array& theArg);
108
109     TPythonDump& 
110     operator<<(const SMESH::double_array& theArg);
111
112     TPythonDump& 
113     operator<<(SALOMEDS::SObject_ptr theArg);
114
115     TPythonDump& 
116     operator<<(CORBA::Object_ptr theArg);
117
118     TPythonDump& 
119     operator<<(SMESH::FilterLibrary_i* theArg);
120
121     TPythonDump& 
122     operator<<(SMESH::FilterManager_i* theArg);
123
124     TPythonDump& 
125     operator<<(SMESH::Filter_i* theArg);
126
127     TPythonDump& 
128     operator<<(SMESH::Functor_i* theArg);
129
130     TPythonDump& 
131     operator<<(SMESH_Gen_i* theArg);
132
133     TPythonDump& 
134     operator<<(SMESH_MeshEditor_i* theArg);
135
136     TPythonDump& 
137     operator<<(SMESH::MED_VERSION theArg);
138
139     TPythonDump&
140     operator<<(const SMESH::AxisStruct & theAxis);
141
142     TPythonDump&
143     operator<<(const SMESH::DirStruct & theDir);
144
145     TPythonDump&
146     operator<<(const TCollection_AsciiString & theArg);
147
148     static char* SMESHGenName() { return "smeshgen"; }
149     static char* MeshEditorName() { return "mesh_editor"; }
150
151     /*!
152      * \brief Return marker of long string literal beginning
153       * \param type - a name of functionality producing the string literal 
154       * \retval TCollection_AsciiString - the marker string to be written into
155       * a raw python script
156      */
157     static TCollection_AsciiString LongStringStart(const char* type);
158     /*!
159      * \brief Return marker of long string literal end
160       * \retval TCollection_AsciiString - the marker string to be written into
161       * a raw python script
162      */
163     static TCollection_AsciiString LongStringEnd();
164     /*!
165      * \brief Cut out a long string literal from a string
166       * \param theText - text possibly containing string literals
167       * \param theFrom - position in the text to search from
168       * \param theLongString - the retrieved literal
169       * \param theStringType - a name of functionality produced the literal
170       * \retval bool - true if a string literal found
171      * 
172      * The literal is removed from theText; theFrom points position right after
173      * the removed literal
174      */
175     static bool  CutoutLongString( TCollection_AsciiString & theText,
176                                    int                     & theFrom,
177                                    TCollection_AsciiString & theLongString,
178                                    TCollection_AsciiString & theStringType);
179   };
180 }
181
182 #endif