GNU Radio 3.6.5 C++ API

gr_vector_map.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_GR_VECTOR_MAP_H
00024 #define INCLUDED_GR_VECTOR_MAP_H
00025 
00026 #include <vector>
00027 #include <gr_core_api.h>
00028 #include <gr_sync_interpolator.h>
00029 #include <gruel/thread.h>
00030 
00031 class gr_vector_map;
00032 typedef boost::shared_ptr<gr_vector_map> gr_vector_map_sptr;
00033 
00034 GR_CORE_API gr_vector_map_sptr
00035 gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens,
00036                     std::vector< std::vector< std::vector<size_t> > > mapping);
00037 
00038 /*!
00039  * \brief Maps elements from a set of input vectors to a set of output vectors.
00040  *
00041  * If in[i] is the input vector in the i'th stream then the output
00042  * vector in the j'th stream is:
00043  *
00044  * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]]
00045  *
00046  * That is mapping is of the form (out_stream1_mapping,
00047  * out_stream2_mapping, ...)  and out_stream1_mapping is of the form
00048  * (element1_mapping, element2_mapping, ...)  and element1_mapping is
00049  * of the form (in_stream, in_element).
00050  *
00051  * \param item_size (integer) size of vector elements
00052  *
00053  * \param in_vlens (vector of integers) number of elements in each
00054  *                 input vector
00055  *
00056  * \param mapping (vector of vectors of vectors of integers) how to
00057  *                map elements from input to output vectors
00058  */
00059 class GR_CORE_API gr_vector_map : public gr_sync_block
00060 {
00061   friend GR_CORE_API gr_vector_map_sptr
00062     gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens,
00063                        std::vector< std::vector< std::vector<size_t> > > mapping);
00064   size_t d_item_size;
00065   std::vector<size_t> d_in_vlens;
00066   std::vector< std::vector< std::vector<size_t> > > d_mapping;
00067   gruel::mutex d_mutex; // mutex to protect set/work access
00068 
00069  protected:
00070   gr_vector_map(size_t item_size, std::vector<size_t> in_vlens,
00071                 std::vector< std::vector< std::vector<size_t> > > mapping);
00072 
00073  public:
00074   int work(int noutput_items,
00075            gr_vector_const_void_star &input_items,
00076            gr_vector_void_star &output_items);
00077 
00078   void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping);
00079 };
00080 
00081 #endif /* INCLUDED_GR_VECTOR_MAP_H */