| 1 | /* |
| 2 | * Copyright (C) 2015, Mike Walters <[email protected]> |
| 3 | * |
| 4 | * This file is part of inspectrum. |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include <complex> |
| 23 | #include <memory> |
| 24 | #include "abstractsamplesource.h" |
| 25 | |
| 26 | #include "util.h" |
| 27 | #include <QString> |
| 28 | #include <QObject> |
| 29 | |
| 30 | class Annotation |
| 31 | { |
| 32 | public: |
| 33 | range_t<size_t> sampleRange; |
| 34 | range_t<double> frequencyRange; |
| 35 | QString label; |
| 36 | QString comment; |
| 37 | |
| 38 | Annotation(range_t<size_t> sampleRange, range_t<double>frequencyRange, QString label, |
| 39 | QString comment) |
| 40 | : sampleRange(sampleRange), frequencyRange(frequencyRange), label(label), |
| 41 | comment(comment) {} |
| 42 | }; |
| 43 | |
| 44 | template<typename T> |
| 45 | class SampleSource : public AbstractSampleSource |
| 46 | { |
| 47 | protected: |
| 48 | double frequency; |
| 49 | |
| 50 | public: |
| 51 | virtual ~SampleSource() {}; |
| 52 | |
| 53 | virtual std::unique_ptr<T[]> getSamples(size_t start, size_t length) = 0; |
| 54 | virtual void invalidateEvent() { }; |
| 55 | virtual size_t count() = 0; |
| 56 | virtual double rate() = 0; |
| 57 | virtual float relativeBandwidth() = 0; |
| 58 | std::vector<Annotation> annotationList; |
| 59 | std::type_index sampleType() override; |
| 60 | virtual bool realSignal() { return false; }; |
| 61 | double getFrequency(); |
| 62 | }; |