gnuradio_swig_python.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  * This file was automatically generated by SWIG (http://www.swig.org).
00003  * Version 1.3.28
00004  * 
00005  * This file is not intended to be easily readable and contains a number of 
00006  * coding conventions designed to improve portability and efficiency. Do not make
00007  * changes to this file unless you know what you are doing--modify the SWIG 
00008  * interface file instead. 
00009  * ----------------------------------------------------------------------------- */
00010 
00011 #ifndef SWIG_gnuradio_swig_python_WRAP_H_
00012 #define SWIG_gnuradio_swig_python_WRAP_H_
00013 
00014 #ifndef SWIG_DIRECTOR_PYTHON_HEADER_
00015 #define SWIG_DIRECTOR_PYTHON_HEADER_
00016 /***********************************************************************
00017  * director_h.swg
00018  *
00019  *     This file contains support for director classes that proxy
00020  *     method calls from C++ to Python extensions.
00021  *
00022  * Author : Mark Rose (mrose@stm.lbl.gov)
00023  ************************************************************************/
00024 
00025 #ifdef __cplusplus
00026 
00027 #include <string>
00028 #include <iostream>
00029 #include <exception>
00030 #include <vector>
00031 #include <map>
00032 
00033 
00034 /*
00035   Use -DSWIG_PYTHON_DIRECTOR_NO_VTABLE if you don't want to generate a 'virtual
00036   table', and avoid multiple GetAttr calls to retreive the python
00037   methods.
00038 */
00039 
00040 #ifndef SWIG_PYTHON_DIRECTOR_NO_VTABLE
00041 #ifndef SWIG_PYTHON_DIRECTOR_VTABLE
00042 #define SWIG_PYTHON_DIRECTOR_VTABLE
00043 #endif
00044 #endif
00045 
00046 
00047 
00048 /*
00049   Use -DSWIG_DIRECTOR_NO_UEH if you prefer to avoid the use of the
00050   Undefined Exception Handler provided by swift
00051 */
00052 #ifndef SWIG_DIRECTOR_NO_UEH
00053 #ifndef SWIG_DIRECTOR_UEH
00054 #define SWIG_DIRECTOR_UEH
00055 #endif
00056 #endif
00057 
00058 
00059 /*
00060   Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the
00061   'Swig' namespace. This could be usefull for multi-modules projects.
00062 */
00063 #ifdef SWIG_DIRECTOR_STATIC
00064 /* Force anonymous (static) namespace */
00065 #define Swig
00066 #endif
00067 
00068 
00069 /*
00070   Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the
00071   native C++ RTTI and dynamic_cast<>. But be aware that directors
00072   could stop working when using this option.
00073 */
00074 #ifdef SWIG_DIRECTOR_NORTTI
00075 /* 
00076    When we don't use the native C++ RTTI, we implement a minimal one
00077    only for Directors.
00078 */
00079 # ifndef SWIG_DIRECTOR_RTDIR
00080 # define SWIG_DIRECTOR_RTDIR
00081 #include <map>
00082 
00083 namespace Swig {
00084   class Director;
00085   SWIGINTERN std::map<void*,Director*>& get_rtdir_map() {
00086     static std::map<void*,Director*> rtdir_map;
00087     return rtdir_map;
00088   }
00089 
00090   SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) {
00091     get_rtdir_map()[vptr] = rtdir;
00092   }
00093 
00094   SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
00095     std::map<void*,Director*>::const_iterator pos = get_rtdir_map().find(vptr);
00096     Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0;
00097     return rtdir;
00098   }
00099 }
00100 # endif /* SWIG_DIRECTOR_RTDIR */
00101 
00102 # define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg))
00103 # define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2)
00104 
00105 #else
00106 
00107 # define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg)
00108 # define SWIG_DIRECTOR_RGTR(Arg1, Arg2)
00109 
00110 #endif /* SWIG_DIRECTOR_NORTTI */
00111 
00112 extern "C" {
00113   struct swig_type_info;
00114 }
00115 
00116 namespace Swig {  
00117 
00118   /* memory handler */
00119   struct GCItem 
00120   {
00121     virtual ~GCItem() = 0;
00122 
00123     virtual int get_own() const
00124     {
00125       return 0;
00126     }
00127   };
00128   
00129   struct GCItem_var
00130   {
00131     GCItem_var(GCItem *item = 0) : _item(item)
00132     {
00133     }
00134 
00135     GCItem_var& operator=(GCItem *item)
00136     {
00137       GCItem *tmp = _item;
00138       _item = item;
00139       delete tmp;
00140       return *this;
00141     }
00142 
00143     ~GCItem_var() 
00144     {
00145       delete _item;
00146     }
00147     
00148     GCItem * operator->() const
00149     {
00150       return _item;
00151     }
00152     
00153   private:
00154     GCItem *_item;
00155   };
00156   
00157   struct GCItem_Object : GCItem
00158   {
00159     GCItem_Object(int own) : _own(own)
00160     {
00161     }
00162     
00163     virtual ~GCItem_Object() 
00164     {
00165     }
00166 
00167     int get_own() const
00168     {
00169       return _own;
00170     }
00171     
00172   private:
00173     int _own;
00174   };
00175 
00176   template <typename Type>
00177   struct GCItem_T : GCItem
00178   {
00179     GCItem_T(Type *ptr) : _ptr(ptr)
00180     {
00181     }
00182     
00183     virtual ~GCItem_T() 
00184     {
00185       delete _ptr;
00186     }
00187     
00188   private:
00189     Type *_ptr;
00190   };
00191 
00192   template <typename Type>
00193   struct GCArray_T : GCItem
00194   {
00195     GCArray_T(Type *ptr) : _ptr(ptr)
00196     {
00197     }
00198     
00199     virtual ~GCArray_T() 
00200     {
00201       delete[] _ptr;
00202     }
00203     
00204   private:
00205     Type *_ptr;
00206   };
00207 
00208 
00209   /* unknown exception handler  */
00210   class UnknownExceptionHandler 
00211   {
00212     static void handler();    
00213   public:
00214     
00215 #ifdef SWIG_DIRECTOR_UEH
00216     std::unexpected_handler old;
00217     UnknownExceptionHandler(std::unexpected_handler nh = handler)
00218     {
00219       old = std::set_unexpected(nh);
00220     }
00221 
00222     ~UnknownExceptionHandler()
00223     {
00224       std::set_unexpected(old);
00225     }
00226 #endif
00227   };
00228 
00229   /* base class for director exceptions */
00230   class DirectorException {
00231   protected:
00232     std::string swig_msg;
00233   public:
00234     DirectorException(PyObject *error, const char* hdr ="", const char* msg ="") 
00235       : swig_msg(hdr)
00236     {
00237       SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
00238       if (strlen(msg)) {
00239         swig_msg += " ";
00240         swig_msg += msg;
00241       }
00242       if (!PyErr_Occurred()) {
00243         PyErr_SetString(error, getMessage());
00244       } else {
00245         SWIG_Python_AddErrorMsg(getMessage());
00246       }
00247       SWIG_PYTHON_THREAD_END_BLOCK; 
00248     }
00249 
00250     const char *getMessage() const
00251     { 
00252       return swig_msg.c_str(); 
00253     }
00254 
00255     static void raise(PyObject *error, const char *msg) 
00256     {
00257       throw DirectorException(error, msg);
00258     }
00259 
00260     static void raise(const char *msg) 
00261     {
00262       raise(PyExc_RuntimeError, msg);
00263     }
00264   };
00265 
00266 
00267   /* type mismatch in the return value from a python method call */
00268   class DirectorTypeMismatchException : public Swig::DirectorException {
00269   public:
00270     DirectorTypeMismatchException(PyObject *error, const char* msg="") 
00271       : Swig::DirectorException(error, "Swig director type mismatch", msg)
00272     {
00273     }
00274 
00275     DirectorTypeMismatchException(const char* msg="") 
00276       : Swig::DirectorException(PyExc_TypeError, "Swig director type mismatch", msg)
00277     {
00278     }
00279 
00280     static void raise(PyObject *error, const char *msg)
00281     {
00282       throw DirectorTypeMismatchException(error, msg);
00283     }
00284 
00285     static void raise(const char *msg)
00286     {
00287       throw DirectorTypeMismatchException(msg);
00288     }
00289   };
00290 
00291   /* any python exception that occurs during a director method call */
00292   class DirectorMethodException : public Swig::DirectorException {
00293   public:
00294     DirectorMethodException(const char* msg = "") 
00295       : DirectorException(PyExc_RuntimeError, "Swig director method error", msg)
00296     {
00297     }    
00298 
00299     static void raise(const char *msg)
00300     {
00301       throw DirectorMethodException(msg);
00302     }
00303   };
00304 
00305   /* attempt to call a pure virtual method via a director method */
00306   class DirectorPureVirtualException : public Swig::DirectorException
00307   {
00308   public:
00309     DirectorPureVirtualException(const char* msg = "") 
00310       : DirectorException(PyExc_RuntimeError, "Swig director pure virtal method called", msg)
00311     { 
00312     }
00313 
00314     static void raise(const char *msg) 
00315     {
00316       throw DirectorPureVirtualException(msg);
00317     }
00318   };
00319 
00320 
00321 #if defined(SWIG_PYTHON_THREADS)
00322 /*  __THREAD__ is the old macro to activate some thread support */
00323 # if !defined(__THREAD__)
00324 #   define __THREAD__ 1
00325 # endif
00326 #endif
00327 
00328 /* simple thread abstraction for pthreads on win32 */
00329 #ifdef __THREAD__
00330 # define __PTHREAD__
00331 # if defined(_WIN32) || defined(__WIN32__)
00332 #  define pthread_mutex_lock EnterCriticalSection
00333 #  define pthread_mutex_unlock LeaveCriticalSection
00334 #  define pthread_mutex_t CRITICAL_SECTION
00335 #  define SWIG_MUTEX_INIT(var) var
00336 # else
00337 #  include <pthread.h>
00338 #  define SWIG_MUTEX_INIT(var) var = PTHREAD_MUTEX_INITIALIZER 
00339 # endif
00340 #endif
00341 
00342 #ifdef  __PTHREAD__
00343   struct Guard
00344   {
00345     pthread_mutex_t *_mutex;
00346     
00347     Guard(pthread_mutex_t &mutex) : _mutex(&mutex)
00348     {
00349       pthread_mutex_lock(_mutex);
00350     }
00351     
00352     ~Guard()
00353     {
00354       pthread_mutex_unlock(_mutex);
00355     }
00356   };
00357 # define SWIG_GUARD(mutex) Guard _guard(mutex)
00358 #else
00359 # define SWIG_GUARD(mutex) 
00360 #endif
00361 
00362   /* director base class */
00363   class Director {
00364   private:
00365     /* pointer to the wrapped python object */
00366     PyObject* swig_self;
00367     /* flag indicating whether the object is owned by python or c++ */
00368     mutable bool swig_disown_flag;
00369     /* shared flag for breaking recursive director calls */
00370     static bool swig_up;
00371 
00372 #ifdef __PTHREAD__
00373     /* locks for sharing the swig_up flag in a threaded environment */
00374     static pthread_mutex_t swig_mutex_up;
00375     static bool swig_mutex_active;
00376     static pthread_t swig_mutex_thread;
00377 #endif
00378 
00379     /* decrement the reference count of the wrapped python object */
00380     void swig_decref() const { 
00381       if (swig_disown_flag) {
00382         SWIG_PYTHON_THREAD_BEGIN_BLOCK; 
00383         Py_DECREF(swig_self); 
00384         SWIG_PYTHON_THREAD_END_BLOCK; 
00385       }
00386     }
00387 
00388     /* reset the swig_up flag once the routing direction has been determined */
00389 #ifdef __PTHREAD__
00390     void swig_clear_up() const { 
00391       Swig::Director::swig_up = false; 
00392       Swig::Director::swig_mutex_active = false;
00393       pthread_mutex_unlock(&swig_mutex_up);
00394     }
00395 #else
00396     void swig_clear_up() const { 
00397       Swig::Director::swig_up = false; 
00398     }
00399 #endif
00400 
00401   public:
00402     /* wrap a python object, optionally taking ownership */
00403     Director(PyObject* self);
00404 
00405     /* discard our reference at destruction */
00406     virtual ~Director();
00407 
00408     /* return a pointer to the wrapped python object */
00409     PyObject *swig_get_self() const { 
00410       return swig_self; 
00411     }
00412 
00413     /* get the swig_up flag to determine if the method call should be routed
00414      * to the c++ base class or through the wrapped python object
00415      */
00416 #ifdef __PTHREAD__
00417     bool swig_get_up() const { 
00418       if (Swig::Director::swig_mutex_active) {
00419         if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
00420           bool up = swig_up;
00421           swig_clear_up();
00422           return up;
00423         }
00424       }
00425       return 0;
00426     }
00427 #else 
00428     bool swig_get_up() const { 
00429       bool up = swig_up;
00430       swig_up = false;
00431       return up;
00432     }
00433 #endif
00434 
00435     /* set the swig_up flag if the next method call should be directed to
00436      * the c++ base class rather than the wrapped python object
00437      */
00438 #ifdef __PTHREAD__
00439     void swig_set_up() const { 
00440       pthread_mutex_lock(&Swig::Director::swig_mutex_up);
00441       Swig::Director::swig_mutex_thread = pthread_self();
00442       Swig::Director::swig_mutex_active = true;
00443       Swig::Director::swig_up = true; 
00444     }
00445 #else 
00446     void swig_set_up() const { 
00447       Swig::Director::swig_up = true; 
00448     }
00449 #endif
00450 
00451     /* acquire ownership of the wrapped python object (the sense of "disown"
00452      * is from python) */
00453     void swig_disown() const { 
00454       if (!swig_disown_flag) { 
00455         swig_disown_flag=true;
00456         swig_incref(); 
00457       } 
00458     }
00459 
00460     /* increase the reference count of the wrapped python object */
00461     void swig_incref() const { 
00462       if (swig_disown_flag) {
00463         Py_INCREF(swig_self); 
00464       }
00465     }
00466 
00467     /* methods to implement pseudo protected director members */
00468     virtual bool swig_get_inner(const char* /* name */) const {
00469       return true;
00470     }
00471     
00472     virtual void swig_set_inner(const char* /* name */, bool /* val */) const {
00473     }
00474 
00475     /* ownership managing */
00476   private:
00477     typedef std::map<void*, GCItem_var> ownership_map;
00478     mutable ownership_map owner;
00479 #ifdef __PTHREAD__
00480     static pthread_mutex_t swig_mutex_own;
00481 #endif
00482 
00483   public:
00484     template <typename Type>
00485     void swig_acquire_ownership_array(Type *vptr)  const
00486     {
00487       if (vptr) {
00488         SWIG_GUARD(swig_mutex_own);
00489         owner[vptr] = new GCArray_T<Type>(vptr);
00490       }
00491     }
00492     
00493     template <typename Type>
00494     void swig_acquire_ownership(Type *vptr)  const
00495     {
00496       if (vptr) {       
00497         SWIG_GUARD(swig_mutex_own);
00498         owner[vptr] = new GCItem_T<Type>(vptr);
00499       }
00500     }
00501 
00502     void swig_acquire_ownership_obj(void *vptr, int own) const
00503     {
00504       if (vptr && own) {
00505         SWIG_GUARD(swig_mutex_own);
00506         owner[vptr] = new GCItem_Object(own);
00507       }
00508     }
00509     
00510     int swig_release_ownership(void *vptr) const
00511     {
00512       int own = 0;
00513       if (vptr) {
00514         SWIG_GUARD(swig_mutex_own);
00515         ownership_map::iterator iter = owner.find(vptr);
00516         if (iter != owner.end()) {
00517           own = iter->second->get_own();
00518           owner.erase(iter);
00519         }
00520       }
00521       return own;
00522     }
00523   };
00524 
00525 }
00526 
00527 #endif /* __cplusplus */
00528 
00529 
00530 #endif
00531 
00532 class SwigDirector_gr_prefs : public gr_prefs, public Swig::Director {
00533 
00534 public:
00535     SwigDirector_gr_prefs(PyObject *self);
00536     virtual bool has_option(std::string const section, std::string const option);
00537     virtual std::string const get_string(std::string const section, std::string const option, std::string const default_val);
00538     virtual double get_double(std::string const section, std::string const option, double default_val);
00539     virtual ~SwigDirector_gr_prefs();
00540     virtual bool has_section(std::string const section);
00541     virtual bool get_bool(std::string const section, std::string const option, bool default_val);
00542     virtual long get_long(std::string const section, std::string const option, long default_val);
00543 
00544 
00545 #if defined(SWIG_PYTHON_DIRECTOR_VTABLE)
00546 /* VTable implementation */
00547     PyObject *swig_get_method(size_t method_index, const char *method_name) const {
00548       PyObject *method = vtable[method_index];
00549       if (!method) {
00550         swig::PyObject_var name = PyString_FromString(method_name);
00551         method = PyObject_GetAttr(swig_get_self(), name);
00552         if (method == NULL) {
00553           std::string msg = "Method in class gr_prefs doesn't exist, undefined ";
00554           msg += method_name;
00555           Swig::DirectorMethodException::raise(msg.c_str());
00556         }
00557         vtable[method_index] = method;
00558       };
00559       return method;
00560     }
00561 private:
00562     mutable swig::PyObject_var vtable[6];
00563 #endif
00564 
00565 };
00566 
00567 
00568 #endif

Generated on Mon Sep 18 14:57:46 2006 for GNU Radio 2.x by  doxygen 1.4.7