GNU Radio 3.7.1 C++ API
file_meta_source.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_FILE_META_SOURCE_H
00024 #define INCLUDED_BLOCKS_FILE_META_SOURCE_H
00025 
00026 #include <gnuradio/blocks/api.h>
00027 #include <gnuradio/sync_block.h>
00028 
00029 namespace gr {
00030   namespace blocks {
00031 
00032     /*!
00033      * \brief Reads stream from file with meta-data headers. Headers
00034      * are parsed into tags.
00035      * \ingroup file_operators_blk
00036      *
00037      * \details
00038      * The information in the metadata headers includes:
00039      *
00040      *   rx_rate (double): sample rate of data.
00041      *   rx_time (uint64_t, double): time stamp of first sample in segment.
00042      *   size (uint32_t): item size in bytes.
00043      *   type (gr_file_types as int32_t): data type.
00044      *   cplx (bool): Is data complex?
00045      *   strt (uint64_t): Starting byte of data in this segment.
00046      *   bytes (uint64_t): Size in bytes of data in this segment.
00047      *
00048      * Any item inside of the extra header dictionary is ready out and
00049      * made into a stream tag.
00050      */
00051     class BLOCKS_API file_meta_source : virtual public sync_block
00052     {
00053     public:
00054       // gr::blocks::file_meta_source::sptr
00055       typedef boost::shared_ptr<file_meta_source> sptr;
00056 
00057       /*!
00058        * \brief Create a meta-data file source.
00059        *
00060        * \param filename (string): Name of file to write data to.
00061        * \param repeat (bool): Repeats file when EOF is found.
00062        * \param detached_header (bool): Set to true if header
00063        *    info is stored in a separate file (usually named filename.hdr)
00064        * \param hdr_filename (string): Name of detached header file if used.
00065        *    Defaults to 'filename.hdr' if detached_header is true but this
00066        *    field is an empty string.
00067        */
00068       static sptr make(const std::string &filename,
00069                        bool repeat=false,
00070                        bool detached_header=false,
00071                        const std::string &hdr_filename="");
00072 
00073       virtual bool open(const std::string &filename,
00074                         const std::string &hdr_filename="") = 0;
00075       virtual void close() = 0;
00076       virtual void do_update() = 0;
00077     };
00078 
00079   } /* namespace blocks */
00080 } /* namespace gr */
00081 
00082 #endif /* INCLUDED_BLOCKS_FILE_META_SOURCE_H */