Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

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 2, 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., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  */
00022 
00023 #ifndef _GR_VMCIRCBUF_H_
00024 #define _GR_VMCIRCBUF_H_
00025 
00026 #include <vector>
00027 
00031 class gr_vmcircbuf {
00032  protected:
00033   int    d_size;
00034   char  *d_base;
00035 
00036   // CREATORS
00037   gr_vmcircbuf (int size) : d_size (size), d_base (0) {};
00038 
00039  public:
00040   virtual ~gr_vmcircbuf ();
00041 
00042   // ACCESSORS
00043   void *pointer_to_first_copy ()  const { return d_base; }
00044   void *pointer_to_second_copy () const { return d_base + d_size; }
00045 };
00046 
00050 class gr_vmcircbuf_factory {
00051  protected:
00052   gr_vmcircbuf_factory () {};
00053   virtual ~gr_vmcircbuf_factory ();
00054 
00055  public:
00056 
00060   virtual const char *name () const = 0;
00061 
00065   virtual int granularity () = 0;
00066 
00072   virtual gr_vmcircbuf *make (int size) = 0;
00073 };
00074 
00075 /*
00076  * \brief pulls together all implementations of gr_vmcircbuf
00077  */
00078 class gr_vmcircbuf_sysconfig {
00079  public:
00080 
00081   /*
00082    * \brief return the single instance of the default factory.
00083    *
00084    * returns the default factory to use if it's already defined,
00085    * else find the first working factory and use it.
00086    */
00087   static gr_vmcircbuf_factory *get_default_factory ();
00088 
00089     
00090   static int granularity ()            { return get_default_factory()->granularity(); }
00091   static gr_vmcircbuf *make (int size) { return get_default_factory()->make(size);    }
00092   
00093 
00094   // N.B. not all factories are guaranteed to work.
00095   // It's too hard to check everything at config time, so we check at runtime
00096   static std::vector<gr_vmcircbuf_factory *> all_factories ();
00097 
00098   // make this factory the default
00099   static void set_default_factory (gr_vmcircbuf_factory *f);
00100 
00108   static bool test_factory (gr_vmcircbuf_factory *f, int verbose);
00109 
00116   static bool test_all_factories (int verbose);
00117 };
00118 
00119 
00120 #endif /* _GR_VMCIRCBUF_H_ */

Generated on Sat Jul 8 17:04:52 2006 for GNU Radio 2.x by  doxygen 1.4.1