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