ComplexGeoDataPy.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 ComplexGeoDataPyImp.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 Data;
00018 
00020 PyTypeObject ComplexGeoDataPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Data.ComplexGeoData",     /*tp_name*/
00024     sizeof(ComplexGeoDataPy),                       /*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     "Father of all complex geometric data types",           /*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     Data::ComplexGeoDataPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Data::ComplexGeoDataPy::GetterSetter,                     /*tp_getset */
00055     &Base::PersistencePy::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     Data::ComplexGeoDataPy::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 ComplexGeoDataPy::Methods[] = {
00075     {NULL, NULL, 0, NULL}               /* Sentinel */
00076 };
00077 
00078 
00079 
00081 PyGetSetDef ComplexGeoDataPy::GetterSetter[] = {
00082     {"BoundBox",
00083         (getter) staticCallback_getBoundBox,
00084         (setter) staticCallback_setBoundBox, 
00085         "Get the BoundBox of the object",
00086         NULL
00087     },
00088     {"Placement",
00089         (getter) staticCallback_getPlacement,
00090         (setter) staticCallback_setPlacement, 
00091         "Get the current transformation of the object as placement",
00092         NULL
00093     },
00094     {"Matrix",
00095         (getter) staticCallback_getMatrix,
00096         (setter) staticCallback_setMatrix, 
00097         "Get the current transformation of the object as matrix",
00098         NULL
00099     },
00100     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00101 };
00102 
00103 // BoundBox() callback and implementer
00104 // PyObject*  ComplexGeoDataPy::BoundBox(PyObject *args){};
00105 // has to be implemented in ComplexGeoDataPyImp.cpp
00106 PyObject * ComplexGeoDataPy::staticCallback_getBoundBox (PyObject *self, void * /*closure*/)
00107 {
00108     if (!((PyObjectBase*) self)->isValid()){
00109         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00110         return NULL;
00111     }
00112 
00113     try {
00114         return Py::new_reference_to(((ComplexGeoDataPy*)self)->getBoundBox());
00115     } catch (const Py::Exception&) {
00116         // The exception text is already set
00117         return NULL;
00118     } catch (...) {
00119         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'BoundBox' of object 'ComplexGeoData'");
00120         return NULL;
00121     }
00122 }
00123 
00124 int ComplexGeoDataPy::staticCallback_setBoundBox (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00125 {
00126     if (!((PyObjectBase*) self)->isValid()){
00127         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00128         return -1;
00129     }
00130 
00131     PyErr_SetString(PyExc_AttributeError, "Attribute 'BoundBox' of object 'ComplexGeoData' is read-only");
00132     return -1;
00133 }
00134 
00135 // Placement() callback and implementer
00136 // PyObject*  ComplexGeoDataPy::Placement(PyObject *args){};
00137 // has to be implemented in ComplexGeoDataPyImp.cpp
00138 PyObject * ComplexGeoDataPy::staticCallback_getPlacement (PyObject *self, void * /*closure*/)
00139 {
00140     if (!((PyObjectBase*) self)->isValid()){
00141         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00142         return NULL;
00143     }
00144 
00145     try {
00146         return Py::new_reference_to(((ComplexGeoDataPy*)self)->getPlacement());
00147     } catch (const Py::Exception&) {
00148         // The exception text is already set
00149         return NULL;
00150     } catch (...) {
00151         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Placement' of object 'ComplexGeoData'");
00152         return NULL;
00153     }
00154 }
00155 
00156 int ComplexGeoDataPy::staticCallback_setPlacement (PyObject *self, PyObject *value, void * /*closure*/)
00157 {    
00158     if (!((PyObjectBase*) self)->isValid()){
00159         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00160         return -1;
00161     }
00162     if (((PyObjectBase*) self)->isConst()){
00163         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00164         return -1;
00165     }
00166 
00167     try {
00168         ((ComplexGeoDataPy*)self)->setPlacement(Py::Object(value,false));
00169         return 0;
00170     } catch (const Py::Exception&) {
00171         // The exception text is already set
00172         return -1;
00173     } catch (...) {
00174         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Placement' of object 'ComplexGeoData'");
00175         return -1;
00176     }
00177 }
00178 
00179 // Matrix() callback and implementer
00180 // PyObject*  ComplexGeoDataPy::Matrix(PyObject *args){};
00181 // has to be implemented in ComplexGeoDataPyImp.cpp
00182 PyObject * ComplexGeoDataPy::staticCallback_getMatrix (PyObject *self, void * /*closure*/)
00183 {
00184     if (!((PyObjectBase*) self)->isValid()){
00185         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00186         return NULL;
00187     }
00188 
00189     try {
00190         return Py::new_reference_to(((ComplexGeoDataPy*)self)->getMatrix());
00191     } catch (const Py::Exception&) {
00192         // The exception text is already set
00193         return NULL;
00194     } catch (...) {
00195         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Matrix' of object 'ComplexGeoData'");
00196         return NULL;
00197     }
00198 }
00199 
00200 int ComplexGeoDataPy::staticCallback_setMatrix (PyObject *self, PyObject *value, void * /*closure*/)
00201 {    
00202     if (!((PyObjectBase*) self)->isValid()){
00203         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00204         return -1;
00205     }
00206     if (((PyObjectBase*) self)->isConst()){
00207         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a method");
00208         return -1;
00209     }
00210 
00211     try {
00212         ((ComplexGeoDataPy*)self)->setMatrix(Py::Object(value,false));
00213         return 0;
00214     } catch (const Py::Exception&) {
00215         // The exception text is already set
00216         return -1;
00217     } catch (...) {
00218         PyErr_SetString(PyExc_Exception, "Unknown exception while writing attribute 'Matrix' of object 'ComplexGeoData'");
00219         return -1;
00220     }
00221 }
00222 
00223 
00224 
00225 //--------------------------------------------------------------------------
00226 // Parents structure
00227 //--------------------------------------------------------------------------
00228 PyParentObject ComplexGeoDataPy::Parents[] = { PARENTSDataComplexGeoDataPy };
00229 
00230 //--------------------------------------------------------------------------
00231 // Constructor
00232 //--------------------------------------------------------------------------
00233 ComplexGeoDataPy::ComplexGeoDataPy(ComplexGeoData *pcObject, PyTypeObject *T)
00234     : PersistencePy(reinterpret_cast<PersistencePy::PointerType>(pcObject), T)
00235 {
00236     pcObject->ref();
00237 }
00238 
00239 PyObject *ComplexGeoDataPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00240 {
00241     // never create such objects with the constructor
00242     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'ComplexGeoDataPy'.");
00243  
00244     return 0;
00245 }
00246 
00247 int ComplexGeoDataPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00248 {
00249     return 0;
00250 }
00251 
00252 //--------------------------------------------------------------------------
00253 // destructor
00254 //--------------------------------------------------------------------------
00255 ComplexGeoDataPy::~ComplexGeoDataPy()                                // Everything handled in parent
00256 {
00257     getComplexGeoDataPtr()->unref();
00258 }
00259 
00260 //--------------------------------------------------------------------------
00261 // ComplexGeoDataPy representation
00262 //--------------------------------------------------------------------------
00263 PyObject *ComplexGeoDataPy::_repr(void)
00264 {
00265     return Py_BuildValue("s", representation().c_str());
00266 }
00267 
00268 //--------------------------------------------------------------------------
00269 // ComplexGeoDataPy Attributes
00270 //--------------------------------------------------------------------------
00271 PyObject *ComplexGeoDataPy::_getattr(char *attr)                                // __getattr__ function: note only need to handle new state
00272 {
00273     try {
00274         // getter method for special Attributes (e.g. dynamic ones)
00275         PyObject *r = getCustomAttributes(attr);
00276         if(r) return r;
00277     }
00278 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00279     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00280     {
00281         std::string str;
00282         str += "FreeCAD exception thrown (";
00283         str += e.what();
00284         str += ")";
00285         e.ReportException();
00286         PyErr_SetString(PyExc_Exception,str.c_str());
00287         return NULL;
00288     }
00289     catch(const std::exception& e) // catch other c++ exceptions
00290     {
00291         std::string str;
00292         str += "FC++ exception thrown (";
00293         str += e.what();
00294         str += ")";
00295         Base::Console().Error(str.c_str());
00296         PyErr_SetString(PyExc_Exception,str.c_str());
00297         return NULL;
00298     }
00299     catch(const Py::Exception&)
00300     {
00301         // The exception text is already set
00302         return NULL;
00303     }
00304     catch(...)  // catch the rest!
00305     {
00306         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00307         return NULL;
00308     }
00309 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00310     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00311     {
00312         std::string str;
00313         str += "FreeCAD exception thrown (";
00314         str += e.what();
00315         str += ")";
00316         e.ReportException();
00317         PyErr_SetString(PyExc_Exception,str.c_str());
00318         return NULL;
00319     }
00320     catch(const Py::Exception&)
00321     {
00322         // The exception text is already set
00323         return NULL;
00324     }
00325 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00326 
00327     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00328     if (rvalue == NULL)
00329     {
00330         PyErr_Clear();
00331         return PersistencePy::_getattr(attr);
00332     }
00333     else
00334     {
00335         return rvalue;
00336     }
00337 }
00338 
00339 int ComplexGeoDataPy::_setattr(char *attr, PyObject *value)     // __setattr__ function: note only need to handle new state
00340 {
00341     try {
00342         // setter for  special Attributes (e.g. dynamic ones)
00343         int r = setCustomAttributes(attr, value);
00344         if(r==1) return 0;
00345     }
00346 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00347     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00348     {
00349         std::string str;
00350         str += "FreeCAD exception thrown (";
00351         str += e.what();
00352         str += ")";
00353         e.ReportException();
00354         PyErr_SetString(PyExc_Exception,str.c_str());
00355         return -1;
00356     }
00357     catch(const std::exception& e) // catch other c++ exceptions
00358     {
00359         std::string str;
00360         str += "FC++ exception thrown (";
00361         str += e.what();
00362         str += ")";
00363         Base::Console().Error(str.c_str());
00364         PyErr_SetString(PyExc_Exception,str.c_str());
00365         return -1;
00366     }
00367     catch(const Py::Exception&)
00368     {
00369         // The exception text is already set
00370         return -1;
00371     }
00372     catch(...)  // catch the rest!
00373     {
00374         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00375         return -1;
00376     }
00377 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00378     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00379     {
00380         std::string str;
00381         str += "FreeCAD exception thrown (";
00382         str += e.what();
00383         str += ")";
00384         e.ReportException();
00385         PyErr_SetString(PyExc_Exception,str.c_str());
00386         return -1;
00387     }
00388     catch(const Py::Exception&)
00389     {
00390         // The exception text is already set
00391         return -1;
00392     }
00393 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00394 
00395     return PersistencePy::_setattr(attr, value);
00396 }
00397 
00398 ComplexGeoData *ComplexGeoDataPy::getComplexGeoDataPtr(void) const
00399 {
00400     return static_cast<ComplexGeoData *>(_pcTwinPointer);
00401 }
00402 
00403 #if 0
00404 /* From here on come the methods you have to implement, but NOT in this module. Implement in ComplexGeoDataPyImp.cpp! This prototypes 
00405  * are just for convenience when you add a new method.
00406  */
00407 
00408 
00409 // returns a string which represents the object e.g. when printed in python
00410 std::string ComplexGeoDataPy::representation(void) const
00411 {
00412     return std::string("<ComplexGeoData object>");
00413 }
00414 
00415 
00416 
00417 Py::Object ComplexGeoDataPy::getBoundBox(void) const
00418 {
00419     //return Py::Object();
00420     throw Py::AttributeError("Not yet implemented");
00421 }
00422 
00423 Py::Object ComplexGeoDataPy::getPlacement(void) const
00424 {
00425     //return Py::Object();
00426     throw Py::AttributeError("Not yet implemented");
00427 }
00428 
00429 void  ComplexGeoDataPy::setPlacement(Py::Object arg)
00430 {
00431     throw Py::AttributeError("Not yet implemented");
00432 }
00433 
00434 Py::Object ComplexGeoDataPy::getMatrix(void) const
00435 {
00436     //return Py::Object();
00437     throw Py::AttributeError("Not yet implemented");
00438 }
00439 
00440 void  ComplexGeoDataPy::setMatrix(Py::Object arg)
00441 {
00442     throw Py::AttributeError("Not yet implemented");
00443 }
00444 
00445 PyObject *ComplexGeoDataPy::getCustomAttributes(const char* attr) const
00446 {
00447     return 0;
00448 }
00449 
00450 int ComplexGeoDataPy::setCustomAttributes(const char* attr, PyObject *obj)
00451 {
00452     return 0; 
00453 }
00454 #endif
00455 
00456 
00457 

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