SelectionObjectPy.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 SelectionObjectPyImp.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 Gui;
00018 
00020 PyTypeObject SelectionObjectPy::Type = {
00021     PyObject_HEAD_INIT(&PyType_Type)
00022     0,                                                /*ob_size*/
00023     "Gui.SelectionObject",     /*tp_name*/
00024     sizeof(SelectionObjectPy),                       /*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     "This class represents selections made by the user. It holds information about the object, document and sub-element of the selection.",           /*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     Gui::SelectionObjectPy::Methods,                     /*tp_methods */
00053     0,                                                /*tp_members */
00054     Gui::SelectionObjectPy::GetterSetter,                     /*tp_getset */
00055     &Base::BaseClassPy::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     Gui::SelectionObjectPy::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 SelectionObjectPy::Methods[] = {
00075     {"remove",
00076         (PyCFunction) staticCallback_remove,
00077         METH_VARARGS,
00078         "Remove this selection item from the selection. This object becomes invalid."
00079     },
00080     {"isA",
00081         (PyCFunction) staticCallback_isA,
00082         METH_VARARGS,
00083         "Test for a certain father class."
00084     },
00085     {NULL, NULL, 0, NULL}               /* Sentinel */
00086 };
00087 
00088 
00089 
00091 PyGetSetDef SelectionObjectPy::GetterSetter[] = {
00092     {"ObjectName",
00093         (getter) staticCallback_getObjectName,
00094         (setter) staticCallback_setObjectName, 
00095         "Name of the selected object",
00096         NULL
00097     },
00098     {"SubElementNames",
00099         (getter) staticCallback_getSubElementNames,
00100         (setter) staticCallback_setSubElementNames, 
00101         "Name of the selected sub-element if any",
00102         NULL
00103     },
00104     {"FullName",
00105         (getter) staticCallback_getFullName,
00106         (setter) staticCallback_setFullName, 
00107         "Name of the selected object",
00108         NULL
00109     },
00110     {"DocumentName",
00111         (getter) staticCallback_getDocumentName,
00112         (setter) staticCallback_setDocumentName, 
00113         "Name of the document of the selected object",
00114         NULL
00115     },
00116     {"Document",
00117         (getter) staticCallback_getDocument,
00118         (setter) staticCallback_setDocument, 
00119         "Selected document",
00120         NULL
00121     },
00122     {"Object",
00123         (getter) staticCallback_getObject,
00124         (setter) staticCallback_setObject, 
00125         "Selected object",
00126         NULL
00127     },
00128     {"SubObjects",
00129         (getter) staticCallback_getSubObjects,
00130         (setter) staticCallback_setSubObjects, 
00131         "Selected sub-element, if any",
00132         NULL
00133     },
00134     {"HasSubObjects",
00135         (getter) staticCallback_getHasSubObjects,
00136         (setter) staticCallback_setHasSubObjects, 
00137         "Selected sub-element, if any",
00138         NULL
00139     },
00140     {NULL, NULL, NULL, NULL, NULL}              /* Sentinel */
00141 };
00142 
00143 // remove() callback and implementer
00144 // PyObject*  SelectionObjectPy::remove(PyObject *args){};
00145 // has to be implemented in SelectionObjectPyImp.cpp
00146 PyObject * SelectionObjectPy::staticCallback_remove (PyObject *self, PyObject *args)
00147 {
00148     // test if twin object not allready deleted
00149     if (!((PyObjectBase*) self)->isValid()){
00150         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00151         return NULL;
00152     }
00153 
00154     // test if object is set Const
00155     if (((PyObjectBase*) self)->isConst()){
00156         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00157         return NULL;
00158     }
00159 
00160     try { // catches all exceptions coming up from c++ and generate a python exception
00161         PyObject* ret = ((SelectionObjectPy*)self)->remove(args);
00162         if (ret != 0)
00163             ((SelectionObjectPy*)self)->startNotify();
00164         return ret;
00165     }
00166     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00167     {
00168         std::string str;
00169         str += "FreeCAD exception thrown (";
00170         str += e.what();
00171         str += ")";
00172         e.ReportException();
00173         PyErr_SetString(PyExc_Exception,str.c_str());
00174         return NULL;
00175     }
00176     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00177     {
00178         std::string str;
00179         str += "File system exception thrown (";
00180         //str += e.who();
00181         //str += ", ";
00182         str += e.what();
00183         str += ")\n";
00184         Base::Console().Error(str.c_str());
00185         PyErr_SetString(PyExc_Exception,str.c_str());
00186         return NULL;
00187     }
00188     catch(const Py::Exception&)
00189     {
00190         // The exception text is already set
00191         return NULL;
00192     }
00193     catch(const char* e) // catch simple string exceptions
00194     {
00195         Base::Console().Error(e);
00196         PyErr_SetString(PyExc_Exception,e);
00197         return NULL;
00198     }
00199     // in debug not all exceptions will be catched to get the attention of the developer!
00200 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00201     catch(const std::exception& e) // catch other c++ exceptions
00202     {
00203         std::string str;
00204         str += "FC++ exception thrown (";
00205         str += e.what();
00206         str += ")";
00207         Base::Console().Error(str.c_str());
00208         PyErr_SetString(PyExc_Exception,str.c_str());
00209         return NULL;
00210     }
00211     catch(...)  // catch the rest!
00212     {
00213         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00214         return NULL;
00215     }
00216 #endif
00217 }
00218 
00219 // isA() callback and implementer
00220 // PyObject*  SelectionObjectPy::isA(PyObject *args){};
00221 // has to be implemented in SelectionObjectPyImp.cpp
00222 PyObject * SelectionObjectPy::staticCallback_isA (PyObject *self, PyObject *args)
00223 {
00224     // test if twin object not allready deleted
00225     if (!((PyObjectBase*) self)->isValid()){
00226         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00227         return NULL;
00228     }
00229 
00230     // test if object is set Const
00231     if (((PyObjectBase*) self)->isConst()){
00232         PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method");
00233         return NULL;
00234     }
00235 
00236     try { // catches all exceptions coming up from c++ and generate a python exception
00237         PyObject* ret = ((SelectionObjectPy*)self)->isA(args);
00238         if (ret != 0)
00239             ((SelectionObjectPy*)self)->startNotify();
00240         return ret;
00241     }
00242     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00243     {
00244         std::string str;
00245         str += "FreeCAD exception thrown (";
00246         str += e.what();
00247         str += ")";
00248         e.ReportException();
00249         PyErr_SetString(PyExc_Exception,str.c_str());
00250         return NULL;
00251     }
00252     catch(const boost::filesystem::filesystem_error& e) // catch boost filesystem exception
00253     {
00254         std::string str;
00255         str += "File system exception thrown (";
00256         //str += e.who();
00257         //str += ", ";
00258         str += e.what();
00259         str += ")\n";
00260         Base::Console().Error(str.c_str());
00261         PyErr_SetString(PyExc_Exception,str.c_str());
00262         return NULL;
00263     }
00264     catch(const Py::Exception&)
00265     {
00266         // The exception text is already set
00267         return NULL;
00268     }
00269     catch(const char* e) // catch simple string exceptions
00270     {
00271         Base::Console().Error(e);
00272         PyErr_SetString(PyExc_Exception,e);
00273         return NULL;
00274     }
00275     // in debug not all exceptions will be catched to get the attention of the developer!
00276 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00277     catch(const std::exception& e) // catch other c++ exceptions
00278     {
00279         std::string str;
00280         str += "FC++ exception thrown (";
00281         str += e.what();
00282         str += ")";
00283         Base::Console().Error(str.c_str());
00284         PyErr_SetString(PyExc_Exception,str.c_str());
00285         return NULL;
00286     }
00287     catch(...)  // catch the rest!
00288     {
00289         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00290         return NULL;
00291     }
00292 #endif
00293 }
00294 
00295 // ObjectName() callback and implementer
00296 // PyObject*  SelectionObjectPy::ObjectName(PyObject *args){};
00297 // has to be implemented in SelectionObjectPyImp.cpp
00298 PyObject * SelectionObjectPy::staticCallback_getObjectName (PyObject *self, void * /*closure*/)
00299 {
00300     if (!((PyObjectBase*) self)->isValid()){
00301         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00302         return NULL;
00303     }
00304 
00305     try {
00306         return Py::new_reference_to(((SelectionObjectPy*)self)->getObjectName());
00307     } catch (const Py::Exception&) {
00308         // The exception text is already set
00309         return NULL;
00310     } catch (...) {
00311         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'ObjectName' of object 'SelectionObject'");
00312         return NULL;
00313     }
00314 }
00315 
00316 int SelectionObjectPy::staticCallback_setObjectName (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00317 {
00318     if (!((PyObjectBase*) self)->isValid()){
00319         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00320         return -1;
00321     }
00322 
00323     PyErr_SetString(PyExc_AttributeError, "Attribute 'ObjectName' of object 'SelectionObject' is read-only");
00324     return -1;
00325 }
00326 
00327 // SubElementNames() callback and implementer
00328 // PyObject*  SelectionObjectPy::SubElementNames(PyObject *args){};
00329 // has to be implemented in SelectionObjectPyImp.cpp
00330 PyObject * SelectionObjectPy::staticCallback_getSubElementNames (PyObject *self, void * /*closure*/)
00331 {
00332     if (!((PyObjectBase*) self)->isValid()){
00333         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00334         return NULL;
00335     }
00336 
00337     try {
00338         return Py::new_reference_to(((SelectionObjectPy*)self)->getSubElementNames());
00339     } catch (const Py::Exception&) {
00340         // The exception text is already set
00341         return NULL;
00342     } catch (...) {
00343         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'SubElementNames' of object 'SelectionObject'");
00344         return NULL;
00345     }
00346 }
00347 
00348 int SelectionObjectPy::staticCallback_setSubElementNames (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00349 {
00350     if (!((PyObjectBase*) self)->isValid()){
00351         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00352         return -1;
00353     }
00354 
00355     PyErr_SetString(PyExc_AttributeError, "Attribute 'SubElementNames' of object 'SelectionObject' is read-only");
00356     return -1;
00357 }
00358 
00359 // FullName() callback and implementer
00360 // PyObject*  SelectionObjectPy::FullName(PyObject *args){};
00361 // has to be implemented in SelectionObjectPyImp.cpp
00362 PyObject * SelectionObjectPy::staticCallback_getFullName (PyObject *self, void * /*closure*/)
00363 {
00364     if (!((PyObjectBase*) self)->isValid()){
00365         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00366         return NULL;
00367     }
00368 
00369     try {
00370         return Py::new_reference_to(((SelectionObjectPy*)self)->getFullName());
00371     } catch (const Py::Exception&) {
00372         // The exception text is already set
00373         return NULL;
00374     } catch (...) {
00375         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'FullName' of object 'SelectionObject'");
00376         return NULL;
00377     }
00378 }
00379 
00380 int SelectionObjectPy::staticCallback_setFullName (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00381 {
00382     if (!((PyObjectBase*) self)->isValid()){
00383         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00384         return -1;
00385     }
00386 
00387     PyErr_SetString(PyExc_AttributeError, "Attribute 'FullName' of object 'SelectionObject' is read-only");
00388     return -1;
00389 }
00390 
00391 // DocumentName() callback and implementer
00392 // PyObject*  SelectionObjectPy::DocumentName(PyObject *args){};
00393 // has to be implemented in SelectionObjectPyImp.cpp
00394 PyObject * SelectionObjectPy::staticCallback_getDocumentName (PyObject *self, void * /*closure*/)
00395 {
00396     if (!((PyObjectBase*) self)->isValid()){
00397         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00398         return NULL;
00399     }
00400 
00401     try {
00402         return Py::new_reference_to(((SelectionObjectPy*)self)->getDocumentName());
00403     } catch (const Py::Exception&) {
00404         // The exception text is already set
00405         return NULL;
00406     } catch (...) {
00407         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'DocumentName' of object 'SelectionObject'");
00408         return NULL;
00409     }
00410 }
00411 
00412 int SelectionObjectPy::staticCallback_setDocumentName (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00413 {
00414     if (!((PyObjectBase*) self)->isValid()){
00415         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00416         return -1;
00417     }
00418 
00419     PyErr_SetString(PyExc_AttributeError, "Attribute 'DocumentName' of object 'SelectionObject' is read-only");
00420     return -1;
00421 }
00422 
00423 // Document() callback and implementer
00424 // PyObject*  SelectionObjectPy::Document(PyObject *args){};
00425 // has to be implemented in SelectionObjectPyImp.cpp
00426 PyObject * SelectionObjectPy::staticCallback_getDocument (PyObject *self, void * /*closure*/)
00427 {
00428     if (!((PyObjectBase*) self)->isValid()){
00429         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00430         return NULL;
00431     }
00432 
00433     try {
00434         return Py::new_reference_to(((SelectionObjectPy*)self)->getDocument());
00435     } catch (const Py::Exception&) {
00436         // The exception text is already set
00437         return NULL;
00438     } catch (...) {
00439         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Document' of object 'SelectionObject'");
00440         return NULL;
00441     }
00442 }
00443 
00444 int SelectionObjectPy::staticCallback_setDocument (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00445 {
00446     if (!((PyObjectBase*) self)->isValid()){
00447         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00448         return -1;
00449     }
00450 
00451     PyErr_SetString(PyExc_AttributeError, "Attribute 'Document' of object 'SelectionObject' is read-only");
00452     return -1;
00453 }
00454 
00455 // Object() callback and implementer
00456 // PyObject*  SelectionObjectPy::Object(PyObject *args){};
00457 // has to be implemented in SelectionObjectPyImp.cpp
00458 PyObject * SelectionObjectPy::staticCallback_getObject (PyObject *self, void * /*closure*/)
00459 {
00460     if (!((PyObjectBase*) self)->isValid()){
00461         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00462         return NULL;
00463     }
00464 
00465     try {
00466         return Py::new_reference_to(((SelectionObjectPy*)self)->getObject());
00467     } catch (const Py::Exception&) {
00468         // The exception text is already set
00469         return NULL;
00470     } catch (...) {
00471         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'Object' of object 'SelectionObject'");
00472         return NULL;
00473     }
00474 }
00475 
00476 int SelectionObjectPy::staticCallback_setObject (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00477 {
00478     if (!((PyObjectBase*) self)->isValid()){
00479         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00480         return -1;
00481     }
00482 
00483     PyErr_SetString(PyExc_AttributeError, "Attribute 'Object' of object 'SelectionObject' is read-only");
00484     return -1;
00485 }
00486 
00487 // SubObjects() callback and implementer
00488 // PyObject*  SelectionObjectPy::SubObjects(PyObject *args){};
00489 // has to be implemented in SelectionObjectPyImp.cpp
00490 PyObject * SelectionObjectPy::staticCallback_getSubObjects (PyObject *self, void * /*closure*/)
00491 {
00492     if (!((PyObjectBase*) self)->isValid()){
00493         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00494         return NULL;
00495     }
00496 
00497     try {
00498         return Py::new_reference_to(((SelectionObjectPy*)self)->getSubObjects());
00499     } catch (const Py::Exception&) {
00500         // The exception text is already set
00501         return NULL;
00502     } catch (...) {
00503         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'SubObjects' of object 'SelectionObject'");
00504         return NULL;
00505     }
00506 }
00507 
00508 int SelectionObjectPy::staticCallback_setSubObjects (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00509 {
00510     if (!((PyObjectBase*) self)->isValid()){
00511         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00512         return -1;
00513     }
00514 
00515     PyErr_SetString(PyExc_AttributeError, "Attribute 'SubObjects' of object 'SelectionObject' is read-only");
00516     return -1;
00517 }
00518 
00519 // HasSubObjects() callback and implementer
00520 // PyObject*  SelectionObjectPy::HasSubObjects(PyObject *args){};
00521 // has to be implemented in SelectionObjectPyImp.cpp
00522 PyObject * SelectionObjectPy::staticCallback_getHasSubObjects (PyObject *self, void * /*closure*/)
00523 {
00524     if (!((PyObjectBase*) self)->isValid()){
00525         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00526         return NULL;
00527     }
00528 
00529     try {
00530         return Py::new_reference_to(((SelectionObjectPy*)self)->getHasSubObjects());
00531     } catch (const Py::Exception&) {
00532         // The exception text is already set
00533         return NULL;
00534     } catch (...) {
00535         PyErr_SetString(PyExc_Exception, "Unknown exception while reading attribute 'HasSubObjects' of object 'SelectionObject'");
00536         return NULL;
00537     }
00538 }
00539 
00540 int SelectionObjectPy::staticCallback_setHasSubObjects (PyObject *self, PyObject * /*value*/, void * /*closure*/)
00541 {
00542     if (!((PyObjectBase*) self)->isValid()){
00543         PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!");
00544         return -1;
00545     }
00546 
00547     PyErr_SetString(PyExc_AttributeError, "Attribute 'HasSubObjects' of object 'SelectionObject' is read-only");
00548     return -1;
00549 }
00550 
00551 
00552 
00553 //--------------------------------------------------------------------------
00554 // Parents structure
00555 //--------------------------------------------------------------------------
00556 PyParentObject SelectionObjectPy::Parents[] = { PARENTSGuiSelectionObjectPy };
00557 
00558 //--------------------------------------------------------------------------
00559 // Constructor
00560 //--------------------------------------------------------------------------
00561 SelectionObjectPy::SelectionObjectPy(SelectionObject *pcObject, PyTypeObject *T)
00562     : BaseClassPy(reinterpret_cast<BaseClassPy::PointerType>(pcObject), T)
00563 {
00564 }
00565 
00566 PyObject *SelectionObjectPy::PyMake(struct _typeobject *, PyObject *, PyObject *)  // Python wrapper
00567 {
00568     // never create such objects with the constructor
00569     PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of 'SelectionObjectPy'.");
00570  
00571     return 0;
00572 }
00573 
00574 int SelectionObjectPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/)
00575 {
00576     return 0;
00577 }
00578 
00579 //--------------------------------------------------------------------------
00580 // destructor
00581 //--------------------------------------------------------------------------
00582 SelectionObjectPy::~SelectionObjectPy()                                // Everything handled in parent
00583 {
00584     // delete the handled object when the PyObject dies
00585     SelectionObjectPy::PointerType ptr = reinterpret_cast<SelectionObjectPy::PointerType>(_pcTwinPointer);
00586     delete ptr;
00587 }
00588 
00589 //--------------------------------------------------------------------------
00590 // SelectionObjectPy representation
00591 //--------------------------------------------------------------------------
00592 PyObject *SelectionObjectPy::_repr(void)
00593 {
00594     return Py_BuildValue("s", representation().c_str());
00595 }
00596 
00597 //--------------------------------------------------------------------------
00598 // SelectionObjectPy Attributes
00599 //--------------------------------------------------------------------------
00600 PyObject *SelectionObjectPy::_getattr(char *attr)                               // __getattr__ function: note only need to handle new state
00601 {
00602     try {
00603         // getter method for special Attributes (e.g. dynamic ones)
00604         PyObject *r = getCustomAttributes(attr);
00605         if(r) return r;
00606     }
00607 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00608     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00609     {
00610         std::string str;
00611         str += "FreeCAD exception thrown (";
00612         str += e.what();
00613         str += ")";
00614         e.ReportException();
00615         PyErr_SetString(PyExc_Exception,str.c_str());
00616         return NULL;
00617     }
00618     catch(const std::exception& e) // catch other c++ exceptions
00619     {
00620         std::string str;
00621         str += "FC++ exception thrown (";
00622         str += e.what();
00623         str += ")";
00624         Base::Console().Error(str.c_str());
00625         PyErr_SetString(PyExc_Exception,str.c_str());
00626         return NULL;
00627     }
00628     catch(const Py::Exception&)
00629     {
00630         // The exception text is already set
00631         return NULL;
00632     }
00633     catch(...)  // catch the rest!
00634     {
00635         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00636         return NULL;
00637     }
00638 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00639     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00640     {
00641         std::string str;
00642         str += "FreeCAD exception thrown (";
00643         str += e.what();
00644         str += ")";
00645         e.ReportException();
00646         PyErr_SetString(PyExc_Exception,str.c_str());
00647         return NULL;
00648     }
00649     catch(const Py::Exception&)
00650     {
00651         // The exception text is already set
00652         return NULL;
00653     }
00654 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00655 
00656     PyObject *rvalue = Py_FindMethod(Methods, this, attr);
00657     if (rvalue == NULL)
00658     {
00659         PyErr_Clear();
00660         return BaseClassPy::_getattr(attr);
00661     }
00662     else
00663     {
00664         return rvalue;
00665     }
00666 }
00667 
00668 int SelectionObjectPy::_setattr(char *attr, PyObject *value)    // __setattr__ function: note only need to handle new state
00669 {
00670     try {
00671         // setter for  special Attributes (e.g. dynamic ones)
00672         int r = setCustomAttributes(attr, value);
00673         if(r==1) return 0;
00674     }
00675 #ifndef DONT_CATCH_CXX_EXCEPTIONS 
00676     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00677     {
00678         std::string str;
00679         str += "FreeCAD exception thrown (";
00680         str += e.what();
00681         str += ")";
00682         e.ReportException();
00683         PyErr_SetString(PyExc_Exception,str.c_str());
00684         return -1;
00685     }
00686     catch(const std::exception& e) // catch other c++ exceptions
00687     {
00688         std::string str;
00689         str += "FC++ exception thrown (";
00690         str += e.what();
00691         str += ")";
00692         Base::Console().Error(str.c_str());
00693         PyErr_SetString(PyExc_Exception,str.c_str());
00694         return -1;
00695     }
00696     catch(const Py::Exception&)
00697     {
00698         // The exception text is already set
00699         return -1;
00700     }
00701     catch(...)  // catch the rest!
00702     {
00703         PyErr_SetString(PyExc_Exception,"Unknown C++ exception");
00704         return -1;
00705     }
00706 #else  // DONT_CATCH_CXX_EXCEPTIONS  
00707     catch(const Base::Exception& e) // catch the FreeCAD exceptions
00708     {
00709         std::string str;
00710         str += "FreeCAD exception thrown (";
00711         str += e.what();
00712         str += ")";
00713         e.ReportException();
00714         PyErr_SetString(PyExc_Exception,str.c_str());
00715         return -1;
00716     }
00717     catch(const Py::Exception&)
00718     {
00719         // The exception text is already set
00720         return -1;
00721     }
00722 #endif  // DONT_CATCH_CXX_EXCEPTIONS
00723 
00724     return BaseClassPy::_setattr(attr, value);
00725 }
00726 
00727 SelectionObject *SelectionObjectPy::getSelectionObjectPtr(void) const
00728 {
00729     return static_cast<SelectionObject *>(_pcTwinPointer);
00730 }
00731 
00732 #if 0
00733 /* From here on come the methods you have to implement, but NOT in this module. Implement in SelectionObjectPyImp.cpp! This prototypes 
00734  * are just for convenience when you add a new method.
00735  */
00736 
00737 
00738 // returns a string which represents the object e.g. when printed in python
00739 std::string SelectionObjectPy::representation(void) const
00740 {
00741     return std::string("<SelectionObject object>");
00742 }
00743 
00744 PyObject* SelectionObjectPy::remove(PyObject *args)
00745 {
00746     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00747     return 0;
00748 }
00749 
00750 PyObject* SelectionObjectPy::isA(PyObject *args)
00751 {
00752     PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented");
00753     return 0;
00754 }
00755 
00756 
00757 
00758 Py::String SelectionObjectPy::getObjectName(void) const
00759 {
00760     //return Py::String();
00761     throw Py::AttributeError("Not yet implemented");
00762 }
00763 
00764 Py::List SelectionObjectPy::getSubElementNames(void) const
00765 {
00766     //return Py::List();
00767     throw Py::AttributeError("Not yet implemented");
00768 }
00769 
00770 Py::String SelectionObjectPy::getFullName(void) const
00771 {
00772     //return Py::String();
00773     throw Py::AttributeError("Not yet implemented");
00774 }
00775 
00776 Py::String SelectionObjectPy::getDocumentName(void) const
00777 {
00778     //return Py::String();
00779     throw Py::AttributeError("Not yet implemented");
00780 }
00781 
00782 Py::Object SelectionObjectPy::getDocument(void) const
00783 {
00784     //return Py::Object();
00785     throw Py::AttributeError("Not yet implemented");
00786 }
00787 
00788 Py::Object SelectionObjectPy::getObject(void) const
00789 {
00790     //return Py::Object();
00791     throw Py::AttributeError("Not yet implemented");
00792 }
00793 
00794 Py::List SelectionObjectPy::getSubObjects(void) const
00795 {
00796     //return Py::List();
00797     throw Py::AttributeError("Not yet implemented");
00798 }
00799 
00800 Py::Boolean SelectionObjectPy::getHasSubObjects(void) const
00801 {
00802     //return Py::Boolean();
00803     throw Py::AttributeError("Not yet implemented");
00804 }
00805 
00806 PyObject *SelectionObjectPy::getCustomAttributes(const char* attr) const
00807 {
00808     return 0;
00809 }
00810 
00811 int SelectionObjectPy::setCustomAttributes(const char* attr, PyObject *obj)
00812 {
00813     return 0; 
00814 }
00815 #endif
00816 
00817 
00818 

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