GNU Radio Manual and C++ API Reference 3.7.14.0
The Free & Open Software Radio Ecosystem
file_source.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_BLOCKS_FILE_SOURCE_H
24#define INCLUDED_BLOCKS_FILE_SOURCE_H
25
26#include <gnuradio/blocks/api.h>
27#include <gnuradio/sync_block.h>
28
29namespace gr {
30namespace blocks {
31
32/*!
33 * \brief Read stream from file
34 * \ingroup file_operators_blk
35 */
36class BLOCKS_API file_source : virtual public sync_block
37{
38public:
39 // gr::blocks::file_source::sptr
40 typedef boost::shared_ptr<file_source> sptr;
41
42 /*!
43 * \brief Create a file source.
44 *
45 * Opens \p filename as a source of items into a flowgraph. The
46 * data is expected to be in binary format, item after item. The
47 * \p itemsize of the block determines the conversion from bits
48 * to items.
49 *
50 * If \p repeat is turned on, the file will repeat the file after
51 * it's reached the end.
52 *
53 * \param itemsize the size of each item in the file, in bytes
54 * \param filename name of the file to source from
55 * \param repeat repeat file from start
56 */
57 static sptr make(size_t itemsize, const char* filename, bool repeat = false);
58
59 /*!
60 * \brief seek file to \p seek_point relative to \p whence
61 *
62 * \param seek_point sample offset in file
63 * \param whence one of SEEK_SET, SEEK_CUR, SEEK_END (man fseek)
64 */
65 virtual bool seek(long seek_point, int whence) = 0;
66
67 /*!
68 * \brief Opens a new file.
69 *
70 * \param filename name of the file to source from
71 * \param repeat repeat file from start
72 */
73 virtual void open(const char* filename, bool repeat) = 0;
74
75 /*!
76 * \brief Close the file handle.
77 */
78 virtual void close() = 0;
79
80 /*!
81 * \brief Add a stream tag to the first sample of the file if true
82 */
83 virtual void set_begin_tag(pmt::pmt_t val) = 0;
84};
85
86} /* namespace blocks */
87} /* namespace gr */
88
89#endif /* INCLUDED_BLOCKS_FILE_SOURCE_H */
Read stream from file.
Definition: file_source.h:37
boost::shared_ptr< file_source > sptr
Definition: file_source.h:40
virtual void close()=0
Close the file handle.
virtual bool seek(long seek_point, int whence)=0
seek file to seek_point relative to whence
static sptr make(size_t itemsize, const char *filename, bool repeat=false)
Create a file source.
virtual void open(const char *filename, bool repeat)=0
Opens a new file.
virtual void set_begin_tag(pmt::pmt_t val)=0
Add a stream tag to the first sample of the file if true.
repeat each input repeat times
Definition: repeat.h:42
synchronous 1:1 input to output with history
Definition: sync_block.h:38
#define BLOCKS_API
Definition: gr-blocks/include/gnuradio/blocks/api.h:30
BLOCKS_API size_t itemsize(vector_type type)
Include this header to use the message passing features.
Definition: basic_block.h:45
boost::intrusive_ptr< pmt_base > pmt_t
typedef for shared pointer (transparent reference counting). See http://www.boost....
Definition: pmt.h:56