QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
workoutsessionmessage.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 WorkoutSessionMessage, and WorkoutSessionMessagePrivate classes.
28  */
29 
30 #include "workoutsessionmessage.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class WorkoutSessionMessage
40  *
41  * The WorkoutSessionMessage class represents a FIT WorkoutSessionMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a WorkoutSessionMessage 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 WorkoutSessionMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the WorkoutSessionMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const WorkoutSessionMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the WorkoutSessionMessage data message's \c sport field's current value.
82  *
83  * \return the \c sport field value.
84  */
86 {
87  Q_D(const WorkoutSessionMessage);
88  return d->sport;
89 }
90 
91 /*!
92  * Returns the WorkoutSessionMessage data message's \c subSport field's current value.
93  *
94  * \return the \c subSport field value.
95  */
97 {
98  Q_D(const WorkoutSessionMessage);
99  return d->subSport;
100 }
101 
102 /*!
103  * Returns the WorkoutSessionMessage data message's \c numValidSteps field's current value.
104  *
105  * \return the \c numValidSteps field value.
106  */
108 {
109  Q_D(const WorkoutSessionMessage);
110  return d->numValidSteps;
111 }
112 
113 /*!
114  * Returns the WorkoutSessionMessage data message's \c firstStepIndex field's current value.
115  *
116  * \return the \c firstStepIndex field value.
117  */
119 {
120  Q_D(const WorkoutSessionMessage);
121  return d->firstStepIndex;
122 }
123 
124 /*!
125  * Returns the WorkoutSessionMessage data message's \c poolLength field's current value.
126  *
127  * \return the \c poolLength field value.
128  */
130 {
131  Q_D(const WorkoutSessionMessage);
132  return d->poolLength;
133 }
134 
135 /*!
136  * Returns the WorkoutSessionMessage data message's \c poolLengthUnit field's current value.
137  *
138  * \return the \c poolLengthUnit field value.
139  */
141 {
142  Q_D(const WorkoutSessionMessage);
143  return d->poolLengthUnit;
144 }
145 
146 /*!
147  * Sets the \c messageIndex field to \a messageIndex.
148  *
149  * \param messageIndex The field value to set.
150  */
152 {
154  d->messageIndex = messageIndex;
155 }
156 /*!
157  * Sets the \c sport field to \a sport.
158  *
159  * \param sport The field value to set.
160  */
162 {
164  d->sport = sport;
165 }
166 /*!
167  * Sets the \c subSport field to \a subSport.
168  *
169  * \param subSport The field value to set.
170  */
172 {
174  d->subSport = subSport;
175 }
176 /*!
177  * Sets the \c numValidSteps field to \a numValidSteps.
178  *
179  * \param numValidSteps The field value to set.
180  */
181 void WorkoutSessionMessage::setNumValidSteps(const quint16 numValidSteps)
182 {
184  d->numValidSteps = numValidSteps;
185 }
186 /*!
187  * Sets the \c firstStepIndex field to \a firstStepIndex.
188  *
189  * \param firstStepIndex The field value to set.
190  */
191 void WorkoutSessionMessage::setFirstStepIndex(const quint16 firstStepIndex)
192 {
194  d->firstStepIndex = firstStepIndex;
195 }
196 /*!
197  * Sets the \c poolLength field to \a poolLength.
198  *
199  * \param poolLength The field value to set.
200  */
201 void WorkoutSessionMessage::setPoolLength(const quint16 poolLength)
202 {
204  d->poolLength = poolLength;
205 }
206 /*!
207  * Sets the \c poolLengthUnit field to \a poolLengthUnit.
208  *
209  * \param poolLengthUnit The field value to set.
210  */
212 {
214  d->poolLengthUnit = poolLengthUnit;
215 }
216 
217 /// \cond internal
218 
219 /*!
220  * \internal
221  *
222  * \class WorkoutSessionMessagePrivate
223  *
224  * The WorkoutSessionMessagePrivate class provides private implementation for the WorkoutSessionMessage.
225  *
226  * \sa WorkoutSessionMessage
227  */
228 
229 /*!
230  * \internal
231  *
232  * Constructs a WorkoutSessionMessagePrivate object with public implementation \a q.
233  *
234  * \param q Pointer to public implementaton.
235  */
236 WorkoutSessionMessagePrivate::WorkoutSessionMessagePrivate(WorkoutSessionMessage * const q)
238  , messageIndex(static_cast<MessageIndex>(-1))
239  , sport(static_cast<Sport>(-1))
240  , subSport(static_cast<SubSport>(-1))
241  , numValidSteps(0xFFFF)
242  , firstStepIndex(0xFFFF)
243  , poolLength(0xFFFF)
244  , poolLengthUnit(static_cast<DisplayMeasure>(-1))
245 {
246  globalMessageNumber = MesgNum::WorkoutSession;
247 }
248 
249 /*!
250  * \internal
251  *
252  * Destroys the WorkoutSessionMessagePrivate object.
253  */
255 {
256 
257 }
258 
260  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
261 {
262  switch (fieldId) {
263  case 254: // See Profile.xlsx::Messages:workout_session.messageIndex
264  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_session.messageIndex")) return false;
265  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
266  break;
267  case 0: // See Profile.xlsx::Messages:workout_session.sport
268  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_session.sport")) return false;
269  this->sport = static_cast<Sport>(data.at(0));
270  break;
271  case 1: // See Profile.xlsx::Messages:workout_session.subSport
272  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_session.subSport")) return false;
273  this->subSport = static_cast<SubSport>(data.at(0));
274  break;
275  case 2: // See Profile.xlsx::Messages:workout_session.numValidSteps
276  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_session.numValidSteps")) return false;
277  this->numValidSteps = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
278  break;
279  case 3: // See Profile.xlsx::Messages:workout_session.firstStepIndex
280  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_session.firstStepIndex")) return false;
281  this->firstStepIndex = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
282  break;
283  case 4: // See Profile.xlsx::Messages:workout_session.poolLength
284  if (!verify(data, baseType, 2, FitBaseType::Uint16, "workout_session.poolLength")) return false;
285  this->poolLength = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
286  break;
287  case 5: // See Profile.xlsx::Messages:workout_session.poolLengthUnit
288  if (!verify(data, baseType, 1, FitBaseType::Enum, "workout_session.poolLengthUnit")) return false;
289  this->poolLengthUnit = static_cast<DisplayMeasure>(data.at(0));
290  break;
291  default:
292  qWarning() << "ignoring unknown workout_session message field number" << fieldId << bigEndian;
293  // Fall through to return true, as its still 'safe' to continue parsing data messages.
294  }
295  return true;
296 }
297 
298 /// \endcond
299 
#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.
MessageIndex messageIndex
The WorkoutSessionMessage FIT message's messageIndex field.
SubSport subSport
The WorkoutSessionMessage FIT message's subSport field.
quint16 firstStepIndex
The WorkoutSessionMessage FIT message's firstStepIndex field.
quint16 poolLength
The WorkoutSessionMessage FIT message's poolLength field.
Sport sport
The WorkoutSessionMessage FIT message's sport field.
quint16 numValidSteps
The WorkoutSessionMessage FIT message's numValidSteps field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
DisplayMeasure poolLengthUnit
The WorkoutSessionMessage FIT message's poolLengthUnit field.
The WorkoutSessionMessage class represents a FIT WorkoutSessionMessage data message.
void setPoolLength(const quint16 poolLength)
Sets the poolLength field to poolLength.
void setFirstStepIndex(const quint16 firstStepIndex)
Sets the firstStepIndex field to firstStepIndex.
Sport sport() const
Returns the WorkoutSessionMessage data message's sport field's current value.
SubSport subSport() const
Returns the WorkoutSessionMessage data message's subSport field's current value.
quint16 firstStepIndex() const
Returns the WorkoutSessionMessage data message's firstStepIndex field's current value.
WorkoutSessionMessage()
Constructs a WorkoutSessionMessage object.
void setSport(const Sport sport)
Sets the sport field to sport.
void setSubSport(const SubSport subSport)
Sets the subSport field to subSport.
MessageIndex messageIndex() const
Returns the WorkoutSessionMessage data message's messageIndex field's current value.
DisplayMeasure poolLengthUnit() const
Returns the WorkoutSessionMessage data message's poolLengthUnit field's current value.
void setPoolLengthUnit(const DisplayMeasure poolLengthUnit)
Sets the poolLengthUnit field to poolLengthUnit.
quint16 poolLength() const
Returns the WorkoutSessionMessage data message's poolLength field's current value.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
quint16 numValidSteps() const
Returns the WorkoutSessionMessage data message's numValidSteps field's current value.
void setNumValidSteps(const quint16 numValidSteps)
Sets the numValidSteps field to numValidSteps.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Sport
Garmin FIT Sport type.
Definition: types.h:685
DisplayMeasure
Garmin FIT DisplayMeasure type.
Definition: types.h:572
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
SubSport
Garmin FIT SubSport type.
Definition: types.h:881
Declares the WorkoutSessionMessage class.
Declares the WorkoutSessionMessagePrivate class.