QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
trainingfilemessage.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 TrainingFileMessage, and TrainingFileMessagePrivate classes.
28  */
29 
30 #include "trainingfilemessage.h"
31 #include "trainingfilemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class TrainingFileMessage
40  *
41  * The TrainingFileMessage class represents a FIT TrainingFileMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a TrainingFileMessage 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 TrainingFileMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the TrainingFileMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const TrainingFileMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the TrainingFileMessage data message's \c type field's current value.
82  *
83  * \return the \c type field value.
84  */
86 {
87  Q_D(const TrainingFileMessage);
88  return d->type;
89 }
90 
91 /*!
92  * Returns the TrainingFileMessage data message's \c manufacturer field's current value.
93  *
94  * \return the \c manufacturer field value.
95  */
97 {
98  Q_D(const TrainingFileMessage);
99  return d->manufacturer;
100 }
101 
102 /*!
103  * Returns the TrainingFileMessage data message's \c product field's current value.
104  *
105  * \return the \c product field value.
106  */
108 {
109  Q_D(const TrainingFileMessage);
110  return d->product;
111 }
112 
113 /*!
114  * Returns the TrainingFileMessage data message's \c serialNumber field's current value.
115  *
116  * \return the \c serialNumber field value.
117  */
119 {
120  Q_D(const TrainingFileMessage);
121  return d->serialNumber;
122 }
123 
124 /*!
125  * Returns the TrainingFileMessage data message's \c timeCreated field's current value.
126  *
127  * \return the \c timeCreated field value.
128  */
130 {
131  Q_D(const TrainingFileMessage);
132  return d->timeCreated;
133 }
134 
135 /*!
136  * Sets the \c timestamp field to \a timestamp.
137  *
138  * \param timestamp The field value to set.
139  */
141 {
142  Q_D(TrainingFileMessage);
143  d->timestamp = timestamp;
144 }
145 /*!
146  * Sets the \c type field to \a type.
147  *
148  * \param type The field value to set.
149  */
151 {
152  Q_D(TrainingFileMessage);
153  d->type = type;
154 }
155 /*!
156  * Sets the \c manufacturer field to \a manufacturer.
157  *
158  * \param manufacturer The field value to set.
159  */
161 {
162  Q_D(TrainingFileMessage);
163  d->manufacturer = manufacturer;
164 }
165 /*!
166  * Sets the \c product field to \a product.
167  *
168  * \param product The field value to set.
169  */
170 void TrainingFileMessage::setProduct(const quint16 product)
171 {
172  Q_D(TrainingFileMessage);
173  d->product = product;
174 }
175 /*!
176  * Sets the \c serialNumber field to \a serialNumber.
177  *
178  * \param serialNumber The field value to set.
179  */
181 {
182  Q_D(TrainingFileMessage);
183  d->serialNumber = serialNumber;
184 }
185 /*!
186  * Sets the \c timeCreated field to \a timeCreated.
187  *
188  * \param timeCreated The field value to set.
189  */
191 {
192  Q_D(TrainingFileMessage);
193  d->timeCreated = timeCreated;
194 }
195 
196 /// \cond internal
197 
198 /*!
199  * \internal
200  *
201  * \class TrainingFileMessagePrivate
202  *
203  * The TrainingFileMessagePrivate class provides private implementation for the TrainingFileMessage.
204  *
205  * \sa TrainingFileMessage
206  */
207 
208 /*!
209  * \internal
210  *
211  * Constructs a TrainingFileMessagePrivate object with public implementation \a q.
212  *
213  * \param q Pointer to public implementaton.
214  */
215 TrainingFileMessagePrivate::TrainingFileMessagePrivate(TrainingFileMessage * const q)
217  , timestamp(static_cast<DateTime>(-1))
218  , type(static_cast<File>(-1))
219  , manufacturer(static_cast<Manufacturer>(-1))
220  , product(0xFFFF)
221  , serialNumber(0)
222  , timeCreated(static_cast<DateTime>(-1))
223 {
224  globalMessageNumber = MesgNum::TrainingFile;
225 }
226 
227 /*!
228  * \internal
229  *
230  * Destroys the TrainingFileMessagePrivate object.
231  */
233 {
234 
235 }
236 
238  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
239 {
240  switch (fieldId) {
241  case 253: // See Profile.xlsx::Messages:training_file.timestamp
242  if (!verify(data, baseType, 4, FitBaseType::Uint32, "training_file.timestamp")) return false;
243  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
244  break;
245  case 0: // See Profile.xlsx::Messages:training_file.type
246  if (!verify(data, baseType, 1, FitBaseType::Enum, "training_file.type")) return false;
247  this->type = static_cast<File>(data.at(0));
248  break;
249  case 1: // See Profile.xlsx::Messages:training_file.manufacturer
250  if (!verify(data, baseType, 2, FitBaseType::Uint16, "training_file.manufacturer")) return false;
251  this->manufacturer = static_cast<Manufacturer>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
252  break;
253  case 2: // See Profile.xlsx::Messages:training_file.product
254  if (!verify(data, baseType, 2, FitBaseType::Uint16, "training_file.product")) return false;
255  this->product = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
256  break;
257  case 3: // See Profile.xlsx::Messages:training_file.serialNumber
258  if (!verify(data, baseType, 4, FitBaseType::Uint32z, "training_file.serialNumber")) return false;
259  this->serialNumber = static_cast<quint32z>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
260  break;
261  case 4: // See Profile.xlsx::Messages:training_file.timeCreated
262  if (!verify(data, baseType, 4, FitBaseType::Uint32, "training_file.timeCreated")) return false;
263  this->timeCreated = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
264  break;
265  default:
266  qWarning() << "ignoring unknown training_file message field number" << fieldId << bigEndian;
267  // Fall through to return true, as its still 'safe' to continue parsing data messages.
268  }
269  return true;
270 }
271 
272 /// \endcond
273 
#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.
File type
The TrainingFileMessage FIT message's type field.
quint16 product
The TrainingFileMessage FIT message's product field.
DateTime timeCreated
The TrainingFileMessage FIT message's timeCreated field.
DateTime timestamp
The TrainingFileMessage FIT message's timestamp field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
Manufacturer manufacturer
The TrainingFileMessage FIT message's manufacturer field.
quint32z serialNumber
The TrainingFileMessage FIT message's serialNumber field.
The TrainingFileMessage class represents a FIT TrainingFileMessage data message.
Manufacturer manufacturer() const
Returns the TrainingFileMessage data message's manufacturer field's current value.
void setTimeCreated(const DateTime timeCreated)
Sets the timeCreated field to timeCreated.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
void setManufacturer(const Manufacturer manufacturer)
Sets the manufacturer field to manufacturer.
DateTime timeCreated() const
Returns the TrainingFileMessage data message's timeCreated field's current value.
quint32z serialNumber() const
Returns the TrainingFileMessage data message's serialNumber field's current value.
quint16 product() const
Returns the TrainingFileMessage data message's product field's current value.
void setType(const File type)
Sets the type field to type.
File type() const
Returns the TrainingFileMessage data message's type field's current value.
void setSerialNumber(const quint32z serialNumber)
Sets the serialNumber field to serialNumber.
DateTime timestamp() const
Returns the TrainingFileMessage data message's timestamp field's current value.
TrainingFileMessage()
Constructs a TrainingFileMessage object.
void setProduct(const quint16 product)
Sets the product field to product.
Declares the TrainingFileMessage class.
Declares the TrainingFileMessagePrivate 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