SpectraPac 2.0(r200)
Evaluates PAC Measurements

PacFileSlicer.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008-2010 by Matthias Nagl                              *
00003  *   mnagl@uni-goettingen.de                                               *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef PACFILESLICER_H
00022 #define PACFILESLICER_H
00023 
00024 #include <QIODevice>
00025 #include <QFile>
00026 
00032 class PacFileSlicer : public QIODevice
00033 {
00034 Q_OBJECT
00035 public:
00036   explicit PacFileSlicer(QFile *input, quint64 beginning, quint64 end, QObject *parent = 0) : QIODevice(parent), input(input), slicebeginning(beginning), sliceend(end) { input->seek(beginning); };
00037     virtual ~PacFileSlicer() {};
00038 
00039     virtual void selectSlice(quint64 beginning, quint64 end) {
00040       Q_ASSERT(beginning <= end);
00041       slicebeginning = beginning;
00042       sliceend = end;
00043       input->seek(slicebeginning);
00044     };
00045     virtual bool isSequential() const { return true; };
00046     virtual qint64 bytesAvailable() const { return sliceend-input->pos() + QIODevice::bytesAvailable(); };
00047 
00048 signals:
00049 
00050 public slots:
00051 
00052 protected:
00053     virtual qint64 readData(char * data, qint64 maxSize) { return input->read(data, qMin(qint64(sliceend)-input->pos(), maxSize)); };
00054     virtual qint64 writeData(const char *, qint64) { return -1; };
00055 
00056 private:
00057     QFile *input;
00058     quint64 slicebeginning, sliceend;
00059 };
00060 
00061 #endif // PACFILESLICER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines