GNU Radio 3.6.5 C++ API

repack_bits_bb.h

Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2012 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 INCLUDED_BLOCKS_REPACK_BITS_BB_H
00024 #define INCLUDED_BLOCKS_REPACK_BITS_BB_H
00025 
00026 #include <blocks/api.h>
00027 #include <gr_tagged_stream_block.h>
00028 
00029 namespace gr {
00030   namespace blocks {
00031 
00032     /*!
00033      * \brief Pack \p k bits from the input stream onto \p l bits of the output stream.
00034      * \ingroup byte_operators_blk
00035      *
00036      * \details
00037      * No bits are lost here; any value for k and l (within [1, 8]) is allowed.
00038      * On every fresh input byte, it starts reading on the LSB, and starts copying
00039      * to the LSB as well.
00040      *
00041      * If a packet length tag is given, this block assumes a tagged stream.
00042      * In this case, the tag with the packet length is updated accordingly.
00043      * Also, the number of input bits is padded with zeros if the number of input
00044      * bits is not an integer multiple of \p l, or bits are truncated from the input
00045      * if \p align_output is set to true.
00046      */
00047     class BLOCKS_API repack_bits_bb : virtual public gr_tagged_stream_block
00048     {
00049      public:
00050       typedef boost::shared_ptr<repack_bits_bb> sptr;
00051 
00052       /*!
00053        * \param k Number of relevant bits on the input stream
00054        * \param l Number of relevant bits on the output stream
00055        * \param len_tag_key If not empty, this is the key for the length tag.
00056        * \param align_output If len_tag_key is given, this controls if the input
00057        *                     or the output is aligned.
00058        */
00059       static sptr make(int k, int l=8, const std::string &len_tag_key="", bool align_output=false);
00060     };
00061 
00062   } // namespace blocks
00063 } // namespace gr
00064 
00065 #endif /* INCLUDED_BLOCKS_REPACK_BITS_BB_H */
00066