3 * Copyright 2005 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
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 2, or (at your option)
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.
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.
22 #ifndef INCLUDED_TIME_SERIES_H
23 #define INCLUDED_TIME_SERIES_H
28 * \brief Memory mapped input for complex time series data
30 * Inspired by "iqts" by John Sahr, Univ of Washington
34 size_t d_itemsize; // user specified item size
35 std::string d_filename;
36 int d_fd; // file descriptor
37 unsigned long long d_filesize; // in bytes
38 unsigned long long d_start; // in items
39 unsigned long long d_limit; // in items
40 void *d_buffer; // points to base of file
44 * \brief Create read-only mapped file accessor.
45 * \param item_size size of item in bytes
46 * \param filename name of file to open
47 * \param starting_offset offset in file in item_size units at which to start
48 * \param nsamples_to_process maximum number of samples to map in starting at \p start. -1 implies no limit.
50 * \throws string on error opening file, etc.
52 time_series(size_t item_size, const std::string filename,
53 unsigned long long starting_offset=0,
54 long long nsamples_to_process=-1);
58 * \brief Return a pointer to a buffer of data at file offset pos.
60 * \param pos offset from beginning of file in itemsize units.
61 * \param blocksize minimum size of returned buffer in itemsize units.
63 * "Seek" to pos in file and return a pointer to the data at that
64 * location. The returned pointer will have at least blocksize valid
65 * elements. Return 0 if pos is out of bounds, or if there isn't
66 * at least blocksize units available in the file.
68 const void *seek(unsigned long long pos, unsigned long long blocksize) const;
70 long long nsamples_available(unsigned long long pos) const;
73 #endif /* INCLUDED_TIME_SERIES_H */