QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fileidmessage.cpp
Go to the documentation of this file.
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 /*!
21  * \file
22  * \note This file is automatcially generated. Any changes here are likely to be overwritten.
23  */
24 
25 /*!
26  * \file
27  * Defines the FileIdMessage, and FileIdMessagePrivate classes.
28  */
29 
30 #include "fileidmessage.h"
31 #include "fileidmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class FileIdMessage
40  *
41  * The FileIdMessage class represents a FIT FileIdMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a FileIdMessage object.
48  *
49  * Typically, instances of this class will be returned by FitStreamReader::readNext, but this
50  * constructor may be used, along with the relevant setter methods, to create a valid message.
51  */
53 {
54 
55 }
56 
57 /*!
58  * \internal
59  *
60  * Constructs a FileIdMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the FileIdMessage data message's \c type field's current value.
71  *
72  * \return the \c type field value.
73  */
75 {
76  Q_D(const FileIdMessage);
77  return d->type;
78 }
79 
80 /*!
81  * Returns the FileIdMessage data message's \c manufacturer field's current value.
82  *
83  * \return the \c manufacturer field value.
84  */
86 {
87  Q_D(const FileIdMessage);
88  return d->manufacturer;
89 }
90 
91 /*!
92  * Returns the FileIdMessage data message's \c product field's current value.
93  *
94  * \return the \c product field value.
95  */
96 quint16 FileIdMessage::product() const
97 {
98  Q_D(const FileIdMessage);
99  return d->product;
100 }
101 
102 /*!
103  * Returns the FileIdMessage data message's \c serialNumber field's current value.
104  *
105  * \return the \c serialNumber field value.
106  */
108 {
109  Q_D(const FileIdMessage);
110  return d->serialNumber;
111 }
112 
113 /*!
114  * Returns the FileIdMessage data message's \c timeCreated field's current value.
115  *
116  * Only set for files that are can be created/erased.
117  *
118  * \return the \c timeCreated field value.
119  */
121 {
122  Q_D(const FileIdMessage);
123  return d->timeCreated;
124 }
125 
126 /*!
127  * Returns the FileIdMessage data message's \c number field's current value.
128  *
129  * Only set for files that are not created/erased.
130  *
131  * \return the \c number field value.
132  */
133 quint16 FileIdMessage::number() const
134 {
135  Q_D(const FileIdMessage);
136  return d->number;
137 }
138 
139 /*!
140  * Returns the FileIdMessage data message's \c productName field's current value.
141  *
142  * Optional free form string to indicate the devices name or model
143  *
144  * \return the \c productName field value.
145  */
147 {
148  Q_D(const FileIdMessage);
149  return d->productName;
150 }
151 
152 /*!
153  * Sets the \c type field to \a type.
154  *
155  * \param type The field value to set.
156  */
157 void FileIdMessage::setType(const File type)
158 {
159  Q_D(FileIdMessage);
160  d->type = type;
161 }
162 /*!
163  * Sets the \c manufacturer field to \a manufacturer.
164  *
165  * \param manufacturer The field value to set.
166  */
168 {
169  Q_D(FileIdMessage);
170  d->manufacturer = manufacturer;
171 }
172 /*!
173  * Sets the \c product field to \a product.
174  *
175  * \param product The field value to set.
176  */
177 void FileIdMessage::setProduct(const quint16 product)
178 {
179  Q_D(FileIdMessage);
180  d->product = product;
181 }
182 /*!
183  * Sets the \c serialNumber field to \a serialNumber.
184  *
185  * \param serialNumber The field value to set.
186  */
187 void FileIdMessage::setSerialNumber(const quint32z serialNumber)
188 {
189  Q_D(FileIdMessage);
190  d->serialNumber = serialNumber;
191 }
192 /*!
193  * Sets the \c timeCreated field to \a timeCreated.
194  *
195  * \param timeCreated The field value to set.
196  */
198 {
199  Q_D(FileIdMessage);
200  d->timeCreated = timeCreated;
201 }
202 /*!
203  * Sets the \c number field to \a number.
204  *
205  * \param number The field value to set.
206  */
207 void FileIdMessage::setNumber(const quint16 number)
208 {
209  Q_D(FileIdMessage);
210  d->number = number;
211 }
212 /*!
213  * Sets the \c productName field to \a productName.
214  *
215  * \param productName The field value to set.
216  */
217 void FileIdMessage::setProductName(const QString productName)
218 {
219  Q_D(FileIdMessage);
220  d->productName = productName;
221 }
222 
223 /// \cond internal
224 
225 /*!
226  * \internal
227  *
228  * \class FileIdMessagePrivate
229  *
230  * The FileIdMessagePrivate class provides private implementation for the FileIdMessage.
231  *
232  * \sa FileIdMessage
233  */
234 
235 /*!
236  * \internal
237  *
238  * Constructs a FileIdMessagePrivate object with public implementation \a q.
239  *
240  * \param q Pointer to public implementaton.
241  */
242 FileIdMessagePrivate::FileIdMessagePrivate(FileIdMessage * const q)
244  , type(static_cast<File>(-1))
245  , manufacturer(static_cast<Manufacturer>(-1))
246  , product(0xFFFF)
247  , serialNumber(0)
248  , timeCreated(static_cast<DateTime>(-1))
249  , number(0xFFFF)
250 {
251  globalMessageNumber = MesgNum::FileId;
252 }
253 
254 /*!
255  * \internal
256  *
257  * Destroys the FileIdMessagePrivate object.
258  */
260 {
261 
262 }
263 
265  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
266 {
267  switch (fieldId) {
268  case 0: // See Profile.xlsx::Messages:file_id.type
269  if (!verify(data, baseType, 1, FitBaseType::Enum, "file_id.type")) return false;
270  this->type = static_cast<File>(data.at(0));
271  break;
272  case 1: // See Profile.xlsx::Messages:file_id.manufacturer
273  if (!verify(data, baseType, 2, FitBaseType::Uint16, "file_id.manufacturer")) return false;
274  this->manufacturer = static_cast<Manufacturer>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
275  break;
276  case 2: // See Profile.xlsx::Messages:file_id.product
277  if (!verify(data, baseType, 2, FitBaseType::Uint16, "file_id.product")) return false;
278  this->product = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
279  break;
280  case 3: // See Profile.xlsx::Messages:file_id.serialNumber
281  if (!verify(data, baseType, 4, FitBaseType::Uint32z, "file_id.serialNumber")) return false;
282  this->serialNumber = static_cast<quint32z>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
283  break;
284  case 4: // See Profile.xlsx::Messages:file_id.timeCreated
285  if (!verify(data, baseType, 4, FitBaseType::Uint32, "file_id.timeCreated")) return false;
286  this->timeCreated = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
287  break;
288  case 5: // See Profile.xlsx::Messages:file_id.number
289  if (!verify(data, baseType, 2, FitBaseType::Uint16, "file_id.number")) return false;
290  this->number = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
291  break;
292  case 8: // See Profile.xlsx::Messages:file_id.productName
293  if (!verify(data, baseType, 1, FitBaseType::String, "file_id.productName")) return false;
294  this->productName = QString::fromUtf8(data);
295  break;
296  default:
297  qWarning() << "ignoring unknown file_id message field number" << fieldId << bigEndian;
298  // Fall through to return true, as its still 'safe' to continue parsing data messages.
299  }
300  return true;
301 }
302 
303 /// \endcond
304 
#define QTFIT_END_NAMESPACE
Macro for ending the QtFit library's top-most namespace (if one is defined).
Definition: QtFit_global.h:78
#define QTFIT_BEGIN_NAMESPACE
Macro for starting the QtFit library's top-most namespace (if one is defined).
Definition: QtFit_global.h:77
MesgNum globalMessageNumber
FIT Globla Message Number for this FIT Data Message.
bool verify(const QByteArray &data, const FitBaseType actualType, const int expectedSize, const FitBaseType expectedType, const char *messageFieldName)
The AbstractDataMessage class is the polymorphic base class for all FIT Data Message classes.
Manufacturer manufacturer
The FileIdMessage FIT message's manufacturer field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
DateTime timeCreated
The FileIdMessage FIT message's timeCreated field.
quint32z serialNumber
The FileIdMessage FIT message's serialNumber field.
QString productName
The FileIdMessage FIT message's productName field.
quint16 number
The FileIdMessage FIT message's number field.
virtual ~FileIdMessagePrivate()
quint16 product
The FileIdMessage FIT message's product field.
File type
The FileIdMessage FIT message's type field.
The FileIdMessage class represents a FIT FileIdMessage data message.
Definition: fileidmessage.h:39
FileIdMessage()
Constructs a FileIdMessage object.
QString productName() const
Returns the FileIdMessage data message's productName field's current value.
File type() const
Returns the FileIdMessage data message's type field's current value.
void setNumber(const quint16 number)
Sets the number field to number.
void setTimeCreated(const DateTime timeCreated)
Sets the timeCreated field to timeCreated.
Manufacturer manufacturer() const
Returns the FileIdMessage data message's manufacturer field's current value.
void setType(const File type)
Sets the type field to type.
void setProductName(const QString productName)
Sets the productName field to productName.
void setManufacturer(const Manufacturer manufacturer)
Sets the manufacturer field to manufacturer.
void setProduct(const quint16 product)
Sets the product field to product.
quint16 number() const
Returns the FileIdMessage data message's number field's current value.
quint32z serialNumber() const
Returns the FileIdMessage data message's serialNumber field's current value.
DateTime timeCreated() const
Returns the FileIdMessage data message's timeCreated field's current value.
void setSerialNumber(const quint32z serialNumber)
Sets the serialNumber field to serialNumber.
quint16 product() const
Returns the FileIdMessage data message's product field's current value.
Declares the FileIdMessage class.
Declares the FileIdMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Manufacturer
Garmin FIT Manufacturer type.
Definition: types.h:1484
File
Garmin FIT File type.
Definition: types.h:59
quint32 quint32z
32-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:47
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237