QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
fielddescriptionmessage.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 FieldDescriptionMessage, and FieldDescriptionMessagePrivate classes.
28  */
29 
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class FieldDescriptionMessage
40  *
41  * The FieldDescriptionMessage class represents a FIT FieldDescriptionMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a FieldDescriptionMessage 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 FieldDescriptionMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the FieldDescriptionMessage data message's \c developerDataIndex field's current value.
71  *
72  * \return the \c developerDataIndex field value.
73  */
75 {
76  Q_D(const FieldDescriptionMessage);
77  return d->developerDataIndex;
78 }
79 
80 /*!
81  * Returns the FieldDescriptionMessage data message's \c fieldDefinitionNumber field's current value.
82  *
83  * \return the \c fieldDefinitionNumber field value.
84  */
86 {
87  Q_D(const FieldDescriptionMessage);
88  return d->fieldDefinitionNumber;
89 }
90 
91 /*!
92  * Returns the FieldDescriptionMessage data message's \c fitBaseTypeId field's current value.
93  *
94  * \return the \c fitBaseTypeId field value.
95  */
97 {
98  Q_D(const FieldDescriptionMessage);
99  return d->fitBaseTypeId;
100 }
101 
102 /*!
103  * Returns the FieldDescriptionMessage data message's \c fieldName field's current value.
104  *
105  * \return the \c fieldName field value.
106  */
108 {
109  Q_D(const FieldDescriptionMessage);
110  return d->fieldName;
111 }
112 
113 /*!
114  * Returns the FieldDescriptionMessage data message's \c array field's current value.
115  *
116  * \return the \c array field value.
117  */
119 {
120  Q_D(const FieldDescriptionMessage);
121  return d->array;
122 }
123 
124 /*!
125  * Returns the FieldDescriptionMessage data message's \c components field's current value.
126  *
127  * \return the \c components field value.
128  */
130 {
131  Q_D(const FieldDescriptionMessage);
132  return d->components;
133 }
134 
135 /*!
136  * Returns the FieldDescriptionMessage data message's \c scale field's current value.
137  *
138  * \return the \c scale field value.
139  */
141 {
142  Q_D(const FieldDescriptionMessage);
143  return d->scale;
144 }
145 
146 /*!
147  * Returns the FieldDescriptionMessage data message's \c offset field's current value.
148  *
149  * \return the \c offset field value.
150  */
152 {
153  Q_D(const FieldDescriptionMessage);
154  return d->offset;
155 }
156 
157 /*!
158  * Returns the FieldDescriptionMessage data message's \c units field's current value.
159  *
160  * \return the \c units field value.
161  */
163 {
164  Q_D(const FieldDescriptionMessage);
165  return d->units;
166 }
167 
168 /*!
169  * Returns the FieldDescriptionMessage data message's \c bits field's current value.
170  *
171  * \return the \c bits field value.
172  */
174 {
175  Q_D(const FieldDescriptionMessage);
176  return d->bits;
177 }
178 
179 /*!
180  * Returns the FieldDescriptionMessage data message's \c accumulate field's current value.
181  *
182  * \return the \c accumulate field value.
183  */
185 {
186  Q_D(const FieldDescriptionMessage);
187  return d->accumulate;
188 }
189 
190 /*!
191  * Returns the FieldDescriptionMessage data message's \c fitBaseUnitId field's current value.
192  *
193  * \return the \c fitBaseUnitId field value.
194  */
196 {
197  Q_D(const FieldDescriptionMessage);
198  return d->fitBaseUnitId;
199 }
200 
201 /*!
202  * Returns the FieldDescriptionMessage data message's \c nativeMesgNum field's current value.
203  *
204  * \return the \c nativeMesgNum field value.
205  */
207 {
208  Q_D(const FieldDescriptionMessage);
209  return d->nativeMesgNum;
210 }
211 
212 /*!
213  * Returns the FieldDescriptionMessage data message's \c nativeFieldNum field's current value.
214  *
215  * \return the \c nativeFieldNum field value.
216  */
218 {
219  Q_D(const FieldDescriptionMessage);
220  return d->nativeFieldNum;
221 }
222 
223 /*!
224  * Sets the \c developerDataIndex field to \a developerDataIndex.
225  *
226  * \param developerDataIndex The field value to set.
227  */
228 void FieldDescriptionMessage::setDeveloperDataIndex(const quint8 developerDataIndex)
229 {
231  d->developerDataIndex = developerDataIndex;
232 }
233 /*!
234  * Sets the \c fieldDefinitionNumber field to \a fieldDefinitionNumber.
235  *
236  * \param fieldDefinitionNumber The field value to set.
237  */
238 void FieldDescriptionMessage::setFieldDefinitionNumber(const quint8 fieldDefinitionNumber)
239 {
241  d->fieldDefinitionNumber = fieldDefinitionNumber;
242 }
243 /*!
244  * Sets the \c fitBaseTypeId field to \a fitBaseTypeId.
245  *
246  * \param fitBaseTypeId The field value to set.
247  */
249 {
251  d->fitBaseTypeId = fitBaseTypeId;
252 }
253 /*!
254  * Sets the \c fieldName field to \a fieldName.
255  *
256  * \param fieldName The field value to set.
257  */
258 void FieldDescriptionMessage::setFieldName(const QString fieldName)
259 {
261  d->fieldName = fieldName;
262 }
263 /*!
264  * Sets the \c array field to \a array.
265  *
266  * \param array The field value to set.
267  */
268 void FieldDescriptionMessage::setArray(const quint8 array)
269 {
271  d->array = array;
272 }
273 /*!
274  * Sets the \c components field to \a components.
275  *
276  * \param components The field value to set.
277  */
278 void FieldDescriptionMessage::setComponents(const QString components)
279 {
281  d->components = components;
282 }
283 /*!
284  * Sets the \c scale field to \a scale.
285  *
286  * \param scale The field value to set.
287  */
288 void FieldDescriptionMessage::setScale(const quint8 scale)
289 {
291  d->scale = scale;
292 }
293 /*!
294  * Sets the \c offset field to \a offset.
295  *
296  * \param offset The field value to set.
297  */
298 void FieldDescriptionMessage::setOffset(const qint8 offset)
299 {
301  d->offset = offset;
302 }
303 /*!
304  * Sets the \c units field to \a units.
305  *
306  * \param units The field value to set.
307  */
308 void FieldDescriptionMessage::setUnits(const QString units)
309 {
311  d->units = units;
312 }
313 /*!
314  * Sets the \c bits field to \a bits.
315  *
316  * \param bits The field value to set.
317  */
318 void FieldDescriptionMessage::setBits(const QString bits)
319 {
321  d->bits = bits;
322 }
323 /*!
324  * Sets the \c accumulate field to \a accumulate.
325  *
326  * \param accumulate The field value to set.
327  */
328 void FieldDescriptionMessage::setAccumulate(const QString accumulate)
329 {
331  d->accumulate = accumulate;
332 }
333 /*!
334  * Sets the \c fitBaseUnitId field to \a fitBaseUnitId.
335  *
336  * \param fitBaseUnitId The field value to set.
337  */
339 {
341  d->fitBaseUnitId = fitBaseUnitId;
342 }
343 /*!
344  * Sets the \c nativeMesgNum field to \a nativeMesgNum.
345  *
346  * \param nativeMesgNum The field value to set.
347  */
349 {
351  d->nativeMesgNum = nativeMesgNum;
352 }
353 /*!
354  * Sets the \c nativeFieldNum field to \a nativeFieldNum.
355  *
356  * \param nativeFieldNum The field value to set.
357  */
358 void FieldDescriptionMessage::setNativeFieldNum(const quint8 nativeFieldNum)
359 {
361  d->nativeFieldNum = nativeFieldNum;
362 }
363 
364 /// \cond internal
365 
366 /*!
367  * \internal
368  *
369  * \class FieldDescriptionMessagePrivate
370  *
371  * The FieldDescriptionMessagePrivate class provides private implementation for the FieldDescriptionMessage.
372  *
373  * \sa FieldDescriptionMessage
374  */
375 
376 /*!
377  * \internal
378  *
379  * Constructs a FieldDescriptionMessagePrivate object with public implementation \a q.
380  *
381  * \param q Pointer to public implementaton.
382  */
383 FieldDescriptionMessagePrivate::FieldDescriptionMessagePrivate(FieldDescriptionMessage * const q)
385  , developerDataIndex(0xFF)
386  , fieldDefinitionNumber(0xFF)
387  , fitBaseTypeId(static_cast<FitBaseType>(-1))
388  , array(0xFF)
389  , scale(0xFF)
390  , offset(0x7F)
391  , fitBaseUnitId(static_cast<FitBaseUnit>(-1))
392  , nativeMesgNum(static_cast<MesgNum>(-1))
393  , nativeFieldNum(0xFF)
394 {
395  globalMessageNumber = MesgNum::FieldDescription;
396 }
397 
398 /*!
399  * \internal
400  *
401  * Destroys the FieldDescriptionMessagePrivate object.
402  */
404 {
405 
406 }
407 
409  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
410 {
411  switch (fieldId) {
412  case 0: // See Profile.xlsx::Messages:field_description.developerDataIndex
413  if (!verify(data, baseType, 1, FitBaseType::Uint8, "field_description.developerDataIndex")) return false;
414  this->developerDataIndex = static_cast<quint8>(data.at(0));
415  break;
416  case 1: // See Profile.xlsx::Messages:field_description.fieldDefinitionNumber
417  if (!verify(data, baseType, 1, FitBaseType::Uint8, "field_description.fieldDefinitionNumber")) return false;
418  this->fieldDefinitionNumber = static_cast<quint8>(data.at(0));
419  break;
420  case 2: // See Profile.xlsx::Messages:field_description.fitBaseTypeId
421  if (!verify(data, baseType, 1, FitBaseType::Uint8, "field_description.fitBaseTypeId")) return false;
422  this->fitBaseTypeId = static_cast<FitBaseType>(data.at(0));
423  break;
424  case 3: // See Profile.xlsx::Messages:field_description.fieldName
425  if (!verify(data, baseType, 1, FitBaseType::String, "field_description.fieldName")) return false;
426  this->fieldName = QString::fromUtf8(data);
427  break;
428  case 4: // See Profile.xlsx::Messages:field_description.array
429  if (!verify(data, baseType, 1, FitBaseType::Uint8, "field_description.array")) return false;
430  this->array = static_cast<quint8>(data.at(0));
431  break;
432  case 5: // See Profile.xlsx::Messages:field_description.components
433  if (!verify(data, baseType, 1, FitBaseType::String, "field_description.components")) return false;
434  this->components = QString::fromUtf8(data);
435  break;
436  case 6: // See Profile.xlsx::Messages:field_description.scale
437  if (!verify(data, baseType, 1, FitBaseType::Uint8, "field_description.scale")) return false;
438  this->scale = static_cast<quint8>(data.at(0));
439  break;
440  case 7: // See Profile.xlsx::Messages:field_description.offset
441  if (!verify(data, baseType, 1, FitBaseType::Sint8, "field_description.offset")) return false;
442  this->offset = static_cast<qint8>(data.at(0));
443  break;
444  case 8: // See Profile.xlsx::Messages:field_description.units
445  if (!verify(data, baseType, 1, FitBaseType::String, "field_description.units")) return false;
446  this->units = QString::fromUtf8(data);
447  break;
448  case 9: // See Profile.xlsx::Messages:field_description.bits
449  if (!verify(data, baseType, 1, FitBaseType::String, "field_description.bits")) return false;
450  this->bits = QString::fromUtf8(data);
451  break;
452  case 10: // See Profile.xlsx::Messages:field_description.accumulate
453  if (!verify(data, baseType, 1, FitBaseType::String, "field_description.accumulate")) return false;
454  this->accumulate = QString::fromUtf8(data);
455  break;
456  case 13: // See Profile.xlsx::Messages:field_description.fitBaseUnitId
457  if (!verify(data, baseType, 2, FitBaseType::Uint16, "field_description.fitBaseUnitId")) return false;
458  this->fitBaseUnitId = static_cast<FitBaseUnit>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
459  break;
460  case 14: // See Profile.xlsx::Messages:field_description.nativeMesgNum
461  if (!verify(data, baseType, 2, FitBaseType::Uint16, "field_description.nativeMesgNum")) return false;
462  this->nativeMesgNum = static_cast<MesgNum>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
463  break;
464  case 15: // See Profile.xlsx::Messages:field_description.nativeFieldNum
465  if (!verify(data, baseType, 1, FitBaseType::Uint8, "field_description.nativeFieldNum")) return false;
466  this->nativeFieldNum = static_cast<quint8>(data.at(0));
467  break;
468  default:
469  qWarning() << "ignoring unknown field_description message field number" << fieldId << bigEndian;
470  // Fall through to return true, as its still 'safe' to continue parsing data messages.
471  }
472  return true;
473 }
474 
475 /// \endcond
476 
#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.
quint8 developerDataIndex
The FieldDescriptionMessage FIT message's developerDataIndex field.
QString accumulate
The FieldDescriptionMessage FIT message's accumulate field.
quint8 nativeFieldNum
The FieldDescriptionMessage FIT message's nativeFieldNum field.
FitBaseUnit fitBaseUnitId
The FieldDescriptionMessage FIT message's fitBaseUnitId field.
FitBaseType fitBaseTypeId
The FieldDescriptionMessage FIT message's fitBaseTypeId field.
qint8 offset
The FieldDescriptionMessage FIT message's offset field.
QString units
The FieldDescriptionMessage FIT message's units field.
quint8 fieldDefinitionNumber
The FieldDescriptionMessage FIT message's fieldDefinitionNumber field.
QString fieldName
The FieldDescriptionMessage FIT message's fieldName field.
QString components
The FieldDescriptionMessage FIT message's components field.
MesgNum nativeMesgNum
The FieldDescriptionMessage FIT message's nativeMesgNum field.
QString bits
The FieldDescriptionMessage FIT message's bits field.
quint8 scale
The FieldDescriptionMessage FIT message's scale field.
quint8 array
The FieldDescriptionMessage FIT message's array field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
The FieldDescriptionMessage class represents a FIT FieldDescriptionMessage data message.
void setUnits(const QString units)
Sets the units field to units.
quint8 nativeFieldNum() const
Returns the FieldDescriptionMessage data message's nativeFieldNum field's current value.
quint8 fieldDefinitionNumber() const
Returns the FieldDescriptionMessage data message's fieldDefinitionNumber field's current value.
FieldDescriptionMessage()
Constructs a FieldDescriptionMessage object.
void setFieldDefinitionNumber(const quint8 fieldDefinitionNumber)
Sets the fieldDefinitionNumber field to fieldDefinitionNumber.
void setFitBaseUnitId(const FitBaseUnit fitBaseUnitId)
Sets the fitBaseUnitId field to fitBaseUnitId.
void setNativeFieldNum(const quint8 nativeFieldNum)
Sets the nativeFieldNum field to nativeFieldNum.
QString accumulate() const
Returns the FieldDescriptionMessage data message's accumulate field's current value.
quint8 scale() const
Returns the FieldDescriptionMessage data message's scale field's current value.
void setOffset(const qint8 offset)
Sets the offset field to offset.
void setComponents(const QString components)
Sets the components field to components.
void setDeveloperDataIndex(const quint8 developerDataIndex)
Sets the developerDataIndex field to developerDataIndex.
FitBaseUnit fitBaseUnitId() const
Returns the FieldDescriptionMessage data message's fitBaseUnitId field's current value.
quint8 array() const
Returns the FieldDescriptionMessage data message's array field's current value.
void setArray(const quint8 array)
Sets the array field to array.
qint8 offset() const
Returns the FieldDescriptionMessage data message's offset field's current value.
void setNativeMesgNum(const MesgNum nativeMesgNum)
Sets the nativeMesgNum field to nativeMesgNum.
void setBits(const QString bits)
Sets the bits field to bits.
void setFieldName(const QString fieldName)
Sets the fieldName field to fieldName.
void setScale(const quint8 scale)
Sets the scale field to scale.
FitBaseType fitBaseTypeId() const
Returns the FieldDescriptionMessage data message's fitBaseTypeId field's current value.
void setFitBaseTypeId(const FitBaseType fitBaseTypeId)
Sets the fitBaseTypeId field to fitBaseTypeId.
MesgNum nativeMesgNum() const
Returns the FieldDescriptionMessage data message's nativeMesgNum field's current value.
void setAccumulate(const QString accumulate)
Sets the accumulate field to accumulate.
quint8 developerDataIndex() const
Returns the FieldDescriptionMessage data message's developerDataIndex field's current value.
QString fieldName() const
Returns the FieldDescriptionMessage data message's fieldName field's current value.
QString components() const
Returns the FieldDescriptionMessage data message's components field's current value.
QString units() const
Returns the FieldDescriptionMessage data message's units field's current value.
QString bits() const
Returns the FieldDescriptionMessage data message's bits field's current value.
Declares the FieldDescriptionMessage class.
Declares the FieldDescriptionMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
FitBaseUnit
Garmin FIT FitBaseUnit type.
Definition: types.h:3481
MesgNum
Garmin FIT MesgNum type.
Definition: types.h:91