Line data Source code
1 : /* 2 : Copyright 2021 Paul Colby 3 : 4 : This file is part of QtFit. 5 : 6 : QtFit is free software: you can redistribute it and/or modify 7 : it under the terms of the GNU Lesser 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 : QtFit 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 Lesser General Public License for more details. 15 : 16 : You should have received a copy of the GNU Lesser General Public License 17 : along with QtFit. If not, see <http://www.gnu.org/licenses/>. 18 : */ 19 : 20 : #include "fitdatamessage.h" 21 : #include "fitdatamessage_p.h" 22 : 23 : #include <QDebug> 24 : 25 : QTFIT_BEGIN_NAMESPACE 26 : 27 0 : FitDataMessage::FitDataMessage() : d_ptr(new FitDataMessagePrivate(this)) 28 : { 29 : 30 0 : } 31 : 32 0 : FitDataMessage::FitDataMessage(FitDataMessagePrivate * const d) : d_ptr(d) 33 : { 34 : 35 0 : } 36 : 37 0 : FitDataMessage::FitDataMessage(const FitDataMessage &other) : d_ptr(new FitDataMessagePrivate(this)) 38 : { 39 0 : Q_D(FitDataMessage); 40 0 : d->globalMessageNumber = other.globalMessageNumber(); 41 0 : d->isNull = other.isNull(); 42 0 : } 43 : 44 0 : FitDataMessage &FitDataMessage::operator=(const FitDataMessage &other) 45 : { 46 0 : Q_D(FitDataMessage); 47 0 : d->globalMessageNumber = other.globalMessageNumber(); 48 0 : d->isNull = other.isNull(); 49 0 : return *this; 50 : } 51 : 52 0 : FitDataMessage::~FitDataMessage() 53 : { 54 0 : delete d_ptr; 55 0 : } 56 : 57 0 : MesgNum FitDataMessage::globalMessageNumber() const 58 : { 59 0 : Q_D(const FitDataMessage); 60 0 : return d->globalMessageNumber; 61 : } 62 : 63 0 : bool FitDataMessage::isNull() const 64 : { 65 0 : Q_D(const FitDataMessage); 66 0 : return d->isNull; 67 : } 68 : 69 0 : FitDataMessagePrivate::FitDataMessagePrivate(FitDataMessage * const q) 70 0 : : globalMessageNumber(static_cast<MesgNum>(0xFFFF)), isNull(true), q_ptr(q) 71 : { 72 : 73 0 : } 74 : 75 0 : FitDataMessagePrivate::~FitDataMessagePrivate() 76 : { 77 : 78 0 : } 79 : 80 0 : bool FitDataMessagePrivate::setFields(const QByteArray &dataRecord, const DataDefinition &definition) 81 : { 82 : Q_ASSERT(definition.globalMessageNumber == this->globalMessageNumber); 83 0 : int dataOffset=0; // Next field's offset within dataRecord. 84 0 : for (const FieldDefinition &field: definition.fieldDefinitions) { 85 0 : if (!setField(field.number, dataRecord.mid(dataOffset,field.size), field.type)) 86 0 : return false; 87 0 : dataOffset += field.size; 88 : } 89 0 : return true; 90 : } 91 : 92 0 : bool FitDataMessagePrivate::setField(const int fieldId, const QByteArray data, int baseType) 93 : { 94 : Q_UNUSED(fieldId) 95 : Q_UNUSED(data) 96 : Q_UNUSED(baseType) 97 0 : return false; 98 : } 99 : 100 : QTFIT_END_NAMESPACE