1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #ifndef _SMESH_PYTHONDUMP_HXX_
23 #define _SMESH_PYTHONDUMP_HXX_
27 #include <SALOMEconfig.h>
28 #include CORBA_SERVER_HEADER(SMESH_Mesh)
29 #include CORBA_SERVER_HEADER(SALOMEDS)
34 class SMESH_MeshEditor_i;
35 class TCollection_AsciiString;
36 class Resource_DataMapOfAsciiStringAsciiString;
38 // ===========================================================================================
40 * \brief Tool converting SMESH engine calls into commands defined in smesh.py
42 * Implementation is in SMESH_2smeshpy.cxx
44 // ===========================================================================================
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
56 static TCollection_AsciiString
57 ConvertScript(const TCollection_AsciiString& theScript,
58 Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod);
61 * \brief Return the name of the python file wrapping IDL API
62 * \retval TCollection_AsciiString - The file name
64 static char* SmeshpyName() { return "smesh"; }
65 static char* GenName() { return "smesh.smesh"; }
70 class FilterLibrary_i;
71 class FilterManager_i;
75 // ===========================================================================================
77 * \brief Utility helping in storing SMESH engine calls as python commands
79 // ===========================================================================================
81 class SMESH_I_EXPORT TPythonDump
83 std::ostringstream myStream;
84 static size_t myCounter;
87 virtual ~TPythonDump();
90 operator<<(long int theArg);
93 operator<<(int theArg);
96 operator<<(double theArg);
99 operator<<(float theArg);
102 operator<<(const void* theArg);
105 operator<<(const char* theArg);
108 operator<<(const SMESH::ElementType& theArg);
111 operator<<(const SMESH::long_array& theArg);
114 operator<<(const SMESH::double_array& theArg);
117 operator<<(SALOMEDS::SObject_ptr theArg);
120 operator<<(CORBA::Object_ptr theArg);
123 operator<<(SMESH::FilterLibrary_i* theArg);
126 operator<<(SMESH::FilterManager_i* theArg);
129 operator<<(SMESH::Filter_i* theArg);
132 operator<<(SMESH::Functor_i* theArg);
135 operator<<(SMESH_Gen_i* theArg);
138 operator<<(SMESH_MeshEditor_i* theArg);
141 operator<<(SMESH::MED_VERSION theArg);
144 operator<<(const SMESH::AxisStruct & theAxis);
147 operator<<(const SMESH::DirStruct & theDir);
150 operator<<(const TCollection_AsciiString & theArg);
153 operator<<(const SMESH::ListOfGroups * theList);
155 static char* SMESHGenName() { return "smeshgen"; }
156 static char* MeshEditorName() { return "mesh_editor"; }
159 * \brief Return marker of long string literal beginning
160 * \param type - a name of functionality producing the string literal
161 * \retval TCollection_AsciiString - the marker string to be written into
162 * a raw python script
164 static TCollection_AsciiString LongStringStart(const char* type);
166 * \brief Return marker of long string literal end
167 * \retval TCollection_AsciiString - the marker string to be written into
168 * a raw python script
170 static TCollection_AsciiString LongStringEnd();
172 * \brief Cut out a long string literal from a string
173 * \param theText - text possibly containing string literals
174 * \param theFrom - position in the text to search from
175 * \param theLongString - the retrieved literal
176 * \param theStringType - a name of functionality produced the literal
177 * \retval bool - true if a string literal found
179 * The literal is removed from theText; theFrom points position right after
180 * the removed literal
182 static bool CutoutLongString( TCollection_AsciiString & theText,
184 TCollection_AsciiString & theLongString,
185 TCollection_AsciiString & theStringType);