GNU Radio 3.6.2 C++ API
gr_vector_map.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2012 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_VECTOR_MAP_H
24 #define INCLUDED_GR_VECTOR_MAP_H
25 
26 #include <vector>
27 #include <gr_core_api.h>
28 #include <gr_sync_interpolator.h>
29 #include <gruel/thread.h>
30 
31 class gr_vector_map;
33 
35 gr_make_vector_map (size_t item_size, std::vector<size_t> in_vlens,
36  std::vector< std::vector< std::vector<size_t> > > mapping);
37 
38 /*!
39  * \brief Maps elements from a set of input vectors to a set of output vectors.
40  *
41  * If in[i] is the input vector in the i'th stream then the output
42  * vector in the j'th stream is:
43  *
44  * out[j][k] = in[mapping[j][k][0]][mapping[j][k][1]]
45  *
46  * That is mapping is of the form (out_stream1_mapping,
47  * out_stream2_mapping, ...) and out_stream1_mapping is of the form
48  * (element1_mapping, element2_mapping, ...) and element1_mapping is
49  * of the form (in_stream, in_element).
50  *
51  * \param item_size (integer) size of vector elements
52  *
53  * \param in_vlens (vector of integers) number of elements in each
54  * input vector
55  *
56  * \param mapping (vector of vectors of vectors of integers) how to
57  * map elements from input to output vectors
58  *
59  * \ingroup slicedice_blk
60  */
62 {
64  gr_make_vector_map(size_t item_size, std::vector<size_t> in_vlens,
65  std::vector< std::vector< std::vector<size_t> > > mapping);
66  size_t d_item_size;
67  std::vector<size_t> d_in_vlens;
68  std::vector< std::vector< std::vector<size_t> > > d_mapping;
69  gruel::mutex d_mutex; // mutex to protect set/work access
70 
71  protected:
72  gr_vector_map(size_t item_size, std::vector<size_t> in_vlens,
73  std::vector< std::vector< std::vector<size_t> > > mapping);
74 
75  public:
76  int work(int noutput_items,
77  gr_vector_const_void_star &input_items,
78  gr_vector_void_star &output_items);
79 
80  void set_mapping(std::vector< std::vector< std::vector<size_t> > > mapping);
81 };
82 
83 #endif /* INCLUDED_GR_VECTOR_MAP_H */