GNU Radio's IIO Package
iio_math_impl.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2016 Analog Devices Inc.
4 * Author: Paul Cercueil <paul.cercueil@analog.com>
5 *
6 * This is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3, or (at your option)
9 * any later version.
10 *
11 * This software is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this software; see the file COPYING. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street,
19 * Boston, MA 02110-1301, USA.
20 */
21
22#ifndef INCLUDED_GR_IIO_MATH_IMPL_H
23#define INCLUDED_GR_IIO_MATH_IMPL_H
24
25#include <vector>
26
27#include <gnuradio/basic_block.h>
28#include <iio/math.h>
29
30extern "C" {
31#include "parser.h"
32
33int yyparse(yyscan_t scanner);
34void *yy_scan_string(const char *str, yyscan_t scanner);
35void yy_delete_buffer(void *buf, yyscan_t scanner);
36}
37
38namespace gr {
39 namespace iio {
40 class iio_math_impl : public iio_math
41 {
42 public:
43 iio_math_impl(const std::string &function, int ninputs);
45
46 struct block;
47
48 void register_block(struct block *block);
49 void set_port_used(unsigned int port);
50 virtual gr::basic_block_sptr get_src_block();
51 virtual void connect_to_output(gr::basic_block_sptr block, unsigned int port = 0);
52
53 private:
54 std::vector<struct block *> blocks;
55 std::vector<bool> connected_ports;
56
57 void connect_null_sinks();
58
59 protected:
61
62 int parse_function(const std::string &function);
63 void cleanup();
64 };
65
67 public iio_math_gen
68 {
69 public:
70 iio_math_gen_impl(double sampling_freq, double wav_freq,
71 const std::string &function);
72
73 virtual gr::basic_block_sptr get_src_block();
74 virtual void connect_to_output(gr::basic_block_sptr block, unsigned int port = 0);
75
76 private:
77 gr::basic_block_sptr src_block;
78 };
79 }
80}
81
82#endif /* INCLUDED_GR_IIO_MATH_IMPL_H */
iio_math_gen_impl(double sampling_freq, double wav_freq, const std::string &function)
virtual void connect_to_output(gr::basic_block_sptr block, unsigned int port=0)
virtual gr::basic_block_sptr get_src_block()
Definition math.h:41
void register_block(struct block *block)
iio_math_impl(const std::string &function, int ninputs)
virtual void connect_to_output(gr::basic_block_sptr block, unsigned int port=0)
iio_math_impl()
Definition iio_math_impl.h:60
void set_port_used(unsigned int port)
virtual gr::basic_block_sptr get_src_block()
Definition math.h:32
void yy_delete_buffer(void *buf, yyscan_t scanner)
void * yy_scan_string(const char *str, yyscan_t scanner)
Definition attr_sink.h:30
Definition attr_sink.h:29
void * yyscan_t
Definition parser.h:52