gr-baz Package
baz_native_mux.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2004,2013 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 /*
00024  * gr-baz by Balint Seeber (http://spench.net/contact)
00025  * Information, documentation & samples: http://wiki.spench.net/wiki/gr-baz
00026  */
00027 
00028 #ifndef INCLUDED_BAZ_NATIVE_MUX_H
00029 #define INCLUDED_BAZ_NATIVE_MUX_H
00030 
00031 #include <gr_sync_block.h>
00032 #include <baz_native_callback.h>
00033 
00034 class BAZ_API baz_native_mux;
00035 
00036 /*
00037  * We use boost::shared_ptr's instead of raw pointers for all access
00038  * to gr_blocks (and many other data structures).  The shared_ptr gets
00039  * us transparent reference counting, which greatly simplifies storage
00040  * management issues.  This is especially helpful in our hybrid
00041  * C++ / Python system.
00042  *
00043  * See http://www.boost.org/libs/smart_ptr/smart_ptr.htm
00044  *
00045  * As a convention, the _sptr suffix indicates a boost::shared_ptr
00046  */
00047 typedef boost::shared_ptr<baz_native_mux> baz_native_mux_sptr;
00048 
00049 /*!
00050  * \brief Return a shared_ptr to a new instance of baz_native_mux.
00051  *
00052  * To avoid accidental use of raw pointers, baz_native_mux's
00053  * constructor is private.  howto_make_square2_ff is the public
00054  * interface for creating new instances.
00055  */
00056 BAZ_API baz_native_mux_sptr baz_make_native_mux (int item_size, int input_count, int trigger_count = -1);
00057 
00058 /*!
00059  * \brief square2 a stream of floats.
00060  * \ingroup block
00061  *
00062  * This uses the preferred technique: subclassing gr_sync_block.
00063  */
00064 class BAZ_API baz_native_mux : public /*gr_sync_block*/gr_block, public baz_native_callback_target
00065 {
00066 private:
00067   // The friend declaration allows howto_make_square2_ff to
00068   // access the private constructor.
00069 
00070   friend BAZ_API baz_native_mux_sptr baz_make_native_mux (int item_size, int input_count, int trigger_count);
00071 
00072   baz_native_mux (int item_size, int input_count, int trigger_count);   // private constructor
00073 
00074   int d_item_size;
00075   int d_input_count;
00076   int d_selected_input;
00077   int d_trigger_count;
00078   int d_trigger_countdown;
00079   std::vector<float> d_values;
00080   int d_value_index;
00081   int d_last_noutput_items;
00082 
00083   unsigned long d_samples_processed;
00084   std::vector<unsigned long> d_switch_time;
00085 
00086  public:
00087   ~baz_native_mux ();   // public destructor
00088 
00089   int general_work (int noutput_items, gr_vector_int &ninput_items,
00090             gr_vector_const_void_star &input_items,
00091             gr_vector_void_star &output_items);
00092 
00093 public:
00094   void callback(float f, unsigned long samples_processed);
00095 };
00096 
00097 #endif /* INCLUDED_BAZ_NATIVE_MUX_H */