gr_vmcircbuf.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2003 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 
00023 #ifndef _GR_VMCIRCBUF_H_
00024 #define _GR_VMCIRCBUF_H_
00025 
00026 #include <vector>
00027 
00032 class gr_vmcircbuf {
00033  protected:
00034   int    d_size;
00035   char  *d_base;
00036 
00037   // CREATORS
00038   gr_vmcircbuf (int size) : d_size (size), d_base (0) {};
00039 
00040  public:
00041   virtual ~gr_vmcircbuf ();
00042 
00043   // ACCESSORS
00044   void *pointer_to_first_copy ()  const { return d_base; }
00045   void *pointer_to_second_copy () const { return d_base + d_size; }
00046 };
00047 
00051 class gr_vmcircbuf_factory {
00052  protected:
00053   gr_vmcircbuf_factory () {};
00054   virtual ~gr_vmcircbuf_factory ();
00055 
00056  public:
00057 
00061   virtual const char *name () const = 0;
00062 
00066   virtual int granularity () = 0;
00067 
00073   virtual gr_vmcircbuf *make (int size) = 0;
00074 };
00075 
00076 /*
00077  * \brief pulls together all implementations of gr_vmcircbuf
00078  */
00079 class gr_vmcircbuf_sysconfig {
00080  public:
00081 
00082   /*
00083    * \brief return the single instance of the default factory.
00084    *
00085    * returns the default factory to use if it's already defined,
00086    * else find the first working factory and use it.
00087    */
00088   static gr_vmcircbuf_factory *get_default_factory ();
00089 
00090     
00091   static int granularity ()            { return get_default_factory()->granularity(); }
00092   static gr_vmcircbuf *make (int size) { return get_default_factory()->make(size);    }
00093   
00094 
00095   // N.B. not all factories are guaranteed to work.
00096   // It's too hard to check everything at config time, so we check at runtime
00097   static std::vector<gr_vmcircbuf_factory *> all_factories ();
00098 
00099   // make this factory the default
00100   static void set_default_factory (gr_vmcircbuf_factory *f);
00101 
00109   static bool test_factory (gr_vmcircbuf_factory *f, int verbose);
00110 
00117   static bool test_all_factories (int verbose);
00118 };
00119 
00120 
00121 #endif /* _GR_VMCIRCBUF_H_ */

Generated on Thu Mar 5 09:01:12 2009 for GNU Radio 3.1.3 by  doxygen 1.5.8