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

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