TopoShapeCompSolidPy.cpp

Go to the documentation of this file.
00001 
00002 // This file is generated by src/Tools/generateTemaplates/templateClassPyExport.py out of the .XML file
00003 // Every change you make here get lost at the next full rebuild!
00004 // This File is normaly build as an include in TopoShapeCompSolidPyImp.cpp! Its not intended to be in a project!
00005 
00006 #include <boost/filesystem/path.hpp>
00007 #include <boost/filesystem/operations.hpp>
00008 #include <boost/filesystem/exception.hpp>
00009 #include <Base/PyObjectBase.h>
00010 #include <Base/Console.h>
00011 #include <Base/Exception.h>
00012 #include <CXX/Objects.hxx>
00013 
00014 #define new DEBUG_CLIENTBLOCK
00015 
00016 using Base::streq;
00017 using namespace Part;
00018 
00020 PyTypeObject TopoShapeCompSolidPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Part.TopoShape",     /*tp_name*/
00024     sizeof(TopoShapeCompSolidPy),                       /*tp_basicsize*/
00025     0,                                                /*tp_itemsize*/
00026     /* methods */
00027     PyDestructor,                                     /*tp_dealloc*/
00028     0,                                                /*tp_print*/
00029     __getattr,                                        /*tp_getattr*/
00030     __setattr,                                        /*tp_setattr*/
00031     0,                                                /*tp_compare*/
00032     __repr,                                           /*tp_repr*/
00033     0,                                                /*tp_as_number*/
00034     0,                                                /*tp_as_sequence*/
00035     0,                                                /*tp_as_mapping*/
00036     0,                                                /*tp_hash*/
00037     0,                                                /*tp_call */
00038     0,                                                /*tp_str  */
00039     0,                                                /*tp_getattro*/
00040     0,                                                /*tp_setattro*/
00041     /* --- Functions to access object as input/output buffer ---------*/
00042     0,                                                /* tp_as_buffer */
00043     /* --- Flags to define presence of optional/expanded features */
00044     Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS,        /*tp_flags */
00045     "TopoShapeCompSolid is the OpenCasCade topological compound solid wrapper",           /*tp_doc */
00046     0,                                                /*tp_traverse */
00047     0,                                                /*tp_clear */
00048     0,                                                /*tp_richcompare */
00049     0,                                                /*tp_weaklistoffset */
00050     0,                                                /*tp_iter */
00051     0,                                                /*tp_iternext */
00052     Part::TopoShapeCompSolidPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Part::TopoShapeCompSolidPy::GetterSetter,                     /*tp_getset */
00055     &Part::TopoShapePy::Type,                        /*tp_base */
00056     0,                                                /*tp_dict */
00057     0,                                                /*tp_descr_get */
00058     0,                                                /*tp_descr_set */
00059     0,                                                /*tp_dictoffset */
00060     __PyInit,                                         /*tp_init */
00061     0,                                                /*tp_alloc */
00062     Part::TopoShapeCompSolidPy::PyMake,/*tp_new */
00063     0,                                                /*tp_free   Low-level free-memory routine */
00064     0,                                                /*tp_is_gc  For PyObject_IS_GC */
00065     0,                                                /*tp_bases */
00066     0,                                                /*tp_mro    method resolution order */
00067     0,                                                /*tp_cache */
00068     0,                                                /*tp_subclasses */
00069     0,                                                /*tp_weaklist */
00070     0                                                 /*tp_del */
00071 };
00072 
00074 PyMethodDef TopoShapeCompSolidPy::Methods[] = {
00075     {"add",
00076         (PyCFunction) staticCallback_add,
00077         METH_VARARGS,
00078         "Add a solid to the compound."
00079     },
00080     {NULL, NULL, 0, NULL}               /* Sentinel */
00081 };
00082 
00083 
00084 
00086 PyGetSetDef TopoShapeCompSolidPy::GetterSetter[] = {
00087     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00088 };
00089 
00090 // add() callback and implementer
00091 // PyObject*  TopoShapeCompSolidPy::add(PyObject *args){};
00092 // has to be implemented in TopoShapeCompSolidPyImp.cpp
00093 PyObject * TopoShapeCompSolidPy::staticCallback_add (PyObject *self, PyObject *args)
00094 {
00095     // test if twin object not allready deleted
00096     if (!((PyObjectBase*) self)->isValid()){
00097         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00098         return NULL;
00099     }
00100 
00101     // test if object is set Const
00102     if (((PyObjectBase*) self)->isConst()){
00103         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00104         return NULL;
00105     }
00106 
00107     try { // catches all exceptions coming up from c++ and generate a python exception
00108         PyObject* ret = ((TopoShapeCompSolidPy*)self)->add(args);
00109         if (ret != 0)
00110             ((TopoShapeCompSolidPy*)self)->startNotify();
00111         return ret;
00112     }
00113     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00114     {
00115         std::string str;
00116         str += "FreeCAD exception thrown (";
00117         str += e.what();
00118         str += ")";
00119         e.ReportException();
00120         PyErr_SetString(PyExc_Exception,str.c_str());
00121         return NULL;
00122     }
00123     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00124     {
00125         std::string str;
00126         str += "File system exception thrown (";
00127         //str += e.who();
00128         //str += ", ";
00129         str += e.what();
00130         str += ")\n";
00131         Base::Console().Error(str.c_str());
00132         PyErr_SetString(PyExc_Exception,str.c_str());
00133         return NULL;
00134     }
00135     catch(const Py::Exception&)
00136     {
00137         // The exception text is already set
00138         return NULL;
00139     }
00140     catch(const char* e) // catch simple string exceptions
00141     {
00142         Base::Console().Error(e);
00143         PyErr_SetString(PyExc_Exception,e);
00144         return NULL;
00145     }
00146     // in debug not all exceptions will be catched to get the attention of the developer!
00147 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00148     catch(const std::exception& e) // catch other c++ exceptions
00149     {
00150         std::string str;
00151         str += "FC++ exception thrown (";
00152         str += e.what();
00153         str += ")";
00154         Base::Console().Error(str.c_str());
00155         PyErr_SetString(PyExc_Exception,str.c_str());
00156         return NULL;
00157     }
00158     catch(...)  // catch the rest!
00159     {
00160         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00161         return NULL;
00162     }
00163 #endif
00164 }
00165 
00166 
00167 
00168 //--------------------------------------------------------------------------
00169 // Parents structure
00170 //--------------------------------------------------------------------------
00171 PyParentObject TopoShapeCompSolidPy::Parents[] = { PARENTSPartTopoShapeCompSolidPy };
00172 
00173 //--------------------------------------------------------------------------
00174 // Constructor
00175 //--------------------------------------------------------------------------
00176 TopoShapeCompSolidPy::TopoShapeCompSolidPy(TopoShape *pcObject, PyTypeObject *T)
00177     : TopoShapePy(reinterpret_cast<TopoShapePy::PointerType>(pcObject), T)
00178 {
00179 }
00180 
00181 
00182 //--------------------------------------------------------------------------
00183 // destructor
00184 //--------------------------------------------------------------------------
00185 TopoShapeCompSolidPy::~TopoShapeCompSolidPy()                                // Everything handled in parent
00186 {
00187 }
00188 
00189 //--------------------------------------------------------------------------
00190 // TopoShapeCompSolidPy representation
00191 //--------------------------------------------------------------------------
00192 PyObject *TopoShapeCompSolidPy::_repr(void)
00193 {
00194     return Py_BuildValue("s", representation().c_str());
00195 }
00196 
00197 //--------------------------------------------------------------------------
00198 // TopoShapeCompSolidPy Attributes
00199 //--------------------------------------------------------------------------
00200 PyObject *TopoShapeCompSolidPy::_getattr(char *attr)                            // __getattr__ function: note only need to handle new state
00201 {
00202     try {
00203         // getter method for special Attributes (e.g. dynamic ones)
00204         PyObject *r = getCustomAttributes(attr);
00205         if(r) return r;
00206     }
00207 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00208     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00209     {
00210         std::string str;
00211         str += "FreeCAD exception thrown (";
00212         str += e.what();
00213         str += ")";
00214         e.ReportException();
00215         PyErr_SetString(PyExc_Exception,str.c_str());
00216         return NULL;
00217     }
00218     catch(const std::exception& e) // catch other c++ exceptions
00219     {
00220         std::string str;
00221         str += "FC++ exception thrown (";
00222         str += e.what();
00223         str += ")";
00224         Base::Console().Error(str.c_str());
00225         PyErr_SetString(PyExc_Exception,str.c_str());
00226         return NULL;
00227     }
00228     catch(const Py::Exception&)
00229     {
00230         // The exception text is already set
00231         return NULL;
00232     }
00233     catch(...)  // catch the rest!
00234     {
00235         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00236         return NULL;
00237     }
00238 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00239     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00240     {
00241         std::string str;
00242         str += "FreeCAD exception thrown (";
00243         str += e.what();
00244         str += ")";
00245         e.ReportException();
00246         PyErr_SetString(PyExc_Exception,str.c_str());
00247         return NULL;
00248     }
00249     catch(const Py::Exception&)
00250     {
00251         // The exception text is already set
00252         return NULL;
00253     }
00254 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00255 
00256     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00257     if (rvalue == NULL)
00258     {
00259         PyErr_Clear();
00260         return TopoShapePy::_getattr(attr);
00261     }
00262     else
00263     {
00264         return rvalue;
00265     }
00266 }
00267 
00268 int TopoShapeCompSolidPy::_setattr(char *attr, PyObject *value)         // __setattr__ function: note only need to handle new state
00269 {
00270     try {
00271         // setter for  special Attributes (e.g. dynamic ones)
00272         int r = setCustomAttributes(attr, value);
00273         if(r==1) return 0;
00274     }
00275 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00276     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00277     {
00278         std::string str;
00279         str += "FreeCAD exception thrown (";
00280         str += e.what();
00281         str += ")";
00282         e.ReportException();
00283         PyErr_SetString(PyExc_Exception,str.c_str());
00284         return -1;
00285     }
00286     catch(const std::exception& e) // catch other c++ exceptions
00287     {
00288         std::string str;
00289         str += "FC++ exception thrown (";
00290         str += e.what();
00291         str += ")";
00292         Base::Console().Error(str.c_str());
00293         PyErr_SetString(PyExc_Exception,str.c_str());
00294         return -1;
00295     }
00296     catch(const Py::Exception&)
00297     {
00298         // The exception text is already set
00299         return -1;
00300     }
00301     catch(...)  // catch the rest!
00302     {
00303         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00304         return -1;
00305     }
00306 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00307     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00308     {
00309         std::string str;
00310         str += "FreeCAD exception thrown (";
00311         str += e.what();
00312         str += ")";
00313         e.ReportException();
00314         PyErr_SetString(PyExc_Exception,str.c_str());
00315         return -1;
00316     }
00317     catch(const Py::Exception&)
00318     {
00319         // The exception text is already set
00320         return -1;
00321     }
00322 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00323 
00324     return TopoShapePy::_setattr(attr, value);
00325 }
00326 
00327 TopoShape *TopoShapeCompSolidPy::getTopoShapePtr(void) const
00328 {
00329     return static_cast<TopoShape *>(_pcTwinPointer);
00330 }
00331 
00332 #if 0
00333 /* From here on come the methods you have to implement, but NOT in this module. Implement in TopoShapeCompSolidPyImp.cpp! This prototypes 
00334  * are just for convenience when you add a new method.
00335  */
00336 
00337 PyObject *TopoShapeCompSolidPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00338 {
00339     // create a new instance of TopoShapeCompSolidPy and the Twin object 
00340     return new TopoShapeCompSolidPy(new TopoShape);
00341 }
00342 
00343 // constructor method
00344 int TopoShapeCompSolidPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00345 {
00346     return 0;
00347 }
00348 
00349 // returns a string which represents the object e.g. when printed in python
00350 std::string TopoShapeCompSolidPy::representation(void) const
00351 {
00352     return std::string("<TopoShape object>");
00353 }
00354 
00355 PyObject* TopoShapeCompSolidPy::add(PyObject *args)
00356 {
00357     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00358     return 0;
00359 }
00360 
00361 
00362 
00363 PyObject *TopoShapeCompSolidPy::getCustomAttributes(const char* attr) const
00364 {
00365     return 0;
00366 }
00367 
00368 int TopoShapeCompSolidPy::setCustomAttributes(const char* attr, PyObject *obj)
00369 {
00370     return 0; 
00371 }
00372 #endif
00373 
00374 
00375 

Generated on Wed Nov 23 19:00:46 2011 for FreeCAD by  doxygen 1.6.1