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