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

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