Salome HOME
Merge from V5_1_main branch 24/11/2010
[modules/smesh.git] / src / SMESH_I / SMESH_PythonDump.hxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef _SMESH_PYTHONDUMP_HXX_
24 #define _SMESH_PYTHONDUMP_HXX_
25
26 #include "SMESH.hxx"
27
28 #include <SALOMEconfig.h>
29 #include CORBA_SERVER_HEADER(SMESH_Mesh)
30 #include CORBA_SERVER_HEADER(SALOMEDS)
31
32 #include <sstream>
33
34 class SMESH_Gen_i;
35 class SMESH_MeshEditor_i;
36 class TCollection_AsciiString;
37 class Resource_DataMapOfAsciiStringAsciiString;
38
39 // ===========================================================================================
40 /*!
41  * \brief Tool converting SMESH engine calls into commands defined in smesh.py
42  *
43  * Implementation is in SMESH_2smeshpy.cxx
44  */
45 // ===========================================================================================
46
47 class SMESH_2smeshpy
48 {
49 public:
50   /*!
51    * \brief Convert a python script using commands of smesh.py
52    * \param theScript - Input script
53    * \param theEntry2AccessorMethod - The returning method names to access to
54    *        objects wrapped with python class
55    * \retval TCollection_AsciiString - Convertion result
56    */
57   static TCollection_AsciiString
58   ConvertScript(const TCollection_AsciiString& theScript,
59                 Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod,
60                 Resource_DataMapOfAsciiStringAsciiString& theObjectNames);
61
62   /*!
63    * \brief Return the name of the python file wrapping IDL API
64     * \retval TCollection_AsciiString - The file name
65    */
66   static const char* SmeshpyName() { return "smesh"; }
67   static const char* GenName() { return "smesh"; }
68 };
69
70 namespace SMESH
71 {
72   class FilterLibrary_i;
73   class FilterManager_i;
74   class Filter_i;
75   class Functor_i;
76   class Measurements_i;
77
78 // ===========================================================================================
79 /*!
80  * \brief Utility helping in storing SMESH engine calls as python commands
81  */
82 // ===========================================================================================
83
84   class SMESH_I_EXPORT TPythonDump
85   {
86     std::ostringstream myStream;
87     static size_t myCounter;
88   public:
89     TPythonDump();
90     virtual ~TPythonDump();
91     
92     TPythonDump& 
93     operator<<(long int theArg);
94
95     TPythonDump& 
96     operator<<(int theArg);
97
98     TPythonDump& 
99     operator<<(double theArg);
100
101     TPythonDump& 
102     operator<<(float theArg);
103
104     TPythonDump& 
105     operator<<(const void* theArg);
106
107     TPythonDump& 
108     operator<<(const char* theArg);
109
110     TPythonDump& 
111     operator<<(const SMESH::ElementType& theArg);
112
113     TPythonDump&
114     operator<<(const SMESH::GeometryType& theArg);
115
116     TPythonDump& 
117     operator<<(const SMESH::long_array& theArg);
118
119     TPythonDump& 
120     operator<<(const SMESH::double_array& theArg);
121
122     TPythonDump& 
123     operator<<(SMESH::SMESH_Hypothesis_ptr theArg);
124
125     TPythonDump& 
126     operator<<(SMESH::SMESH_IDSource_ptr theArg);
127
128     TPythonDump& 
129     operator<<(SALOMEDS::SObject_ptr theArg);
130
131     TPythonDump& 
132     operator<<(CORBA::Object_ptr theArg);
133
134     TPythonDump& 
135     operator<<(SMESH::FilterLibrary_i* theArg);
136
137     TPythonDump& 
138     operator<<(SMESH::FilterManager_i* theArg);
139
140     TPythonDump& 
141     operator<<(SMESH::Filter_i* theArg);
142
143     TPythonDump& 
144     operator<<(SMESH::Functor_i* theArg);
145
146     TPythonDump& 
147     operator<<(SMESH::Measurements_i* theArg);
148
149     TPythonDump& 
150     operator<<(SMESH_Gen_i* theArg);
151
152     TPythonDump& 
153     operator<<(SMESH_MeshEditor_i* theArg);
154
155     TPythonDump& 
156     operator<<(SMESH::MED_VERSION theArg);
157
158     TPythonDump&
159     operator<<(const SMESH::AxisStruct & theAxis);
160
161     TPythonDump&
162     operator<<(const SMESH::DirStruct & theDir);
163
164     TPythonDump&
165     operator<<(const TCollection_AsciiString & theArg);
166
167     TPythonDump&
168     operator<<(const SMESH::ListOfGroups& theList);
169
170     TPythonDump&
171     operator<<(const SMESH::ListOfIDSources& theList);
172
173     static const char* SMESHGenName() { return "smeshgen"; }
174     static const char* MeshEditorName() { return "mesh_editor"; }
175
176     /*!
177      * \brief Return marker of long string literal beginning
178       * \param type - a name of functionality producing the string literal 
179       * \retval TCollection_AsciiString - the marker string to be written into
180       * a raw python script
181      */
182     static TCollection_AsciiString LongStringStart(const char* type);
183     /*!
184      * \brief Return marker of long string literal end
185       * \retval TCollection_AsciiString - the marker string to be written into
186       * a raw python script
187      */
188     static TCollection_AsciiString LongStringEnd();
189     /*!
190      * \brief Cut out a long string literal from a string
191       * \param theText - text possibly containing string literals
192       * \param theFrom - position in the text to search from
193       * \param theLongString - the retrieved literal
194       * \param theStringType - a name of functionality produced the literal
195       * \retval bool - true if a string literal found
196      * 
197      * The literal is removed from theText; theFrom points position right after
198      * the removed literal
199      */
200     static bool  CutoutLongString( TCollection_AsciiString & theText,
201                                    int                     & theFrom,
202                                    TCollection_AsciiString & theLongString,
203                                    TCollection_AsciiString & theStringType);
204   };
205 }
206
207 #endif