QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
segmentidmessage.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 SegmentIdMessage, and SegmentIdMessagePrivate classes.
28  */
29 
30 #include "segmentidmessage.h"
31 #include "segmentidmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class SegmentIdMessage
40  *
41  * The SegmentIdMessage class represents a FIT SegmentIdMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a SegmentIdMessage 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 SegmentIdMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the SegmentIdMessage data message's \c name field's current value.
71  *
72  * Friendly name assigned to segment
73  *
74  * \return the \c name field value.
75  */
76 QString SegmentIdMessage::name() const
77 {
78  Q_D(const SegmentIdMessage);
79  return d->name;
80 }
81 
82 /*!
83  * Returns the SegmentIdMessage data message's \c uuid field's current value.
84  *
85  * UUID of the segment
86  *
87  * \return the \c uuid field value.
88  */
89 QString SegmentIdMessage::uuid() const
90 {
91  Q_D(const SegmentIdMessage);
92  return d->uuid;
93 }
94 
95 /*!
96  * Returns the SegmentIdMessage data message's \c sport field's current value.
97  *
98  * Sport associated with the segment
99  *
100  * \return the \c sport field value.
101  */
103 {
104  Q_D(const SegmentIdMessage);
105  return d->sport;
106 }
107 
108 /*!
109  * Returns the SegmentIdMessage data message's \c enabled field's current value.
110  *
111  * Segment enabled for evaluation
112  *
113  * \return the \c enabled field value.
114  */
116 {
117  Q_D(const SegmentIdMessage);
118  return d->enabled;
119 }
120 
121 /*!
122  * Returns the SegmentIdMessage data message's \c userProfilePrimaryKey field's current value.
123  *
124  * Primary key of the user that created the segment
125  *
126  * \return the \c userProfilePrimaryKey field value.
127  */
129 {
130  Q_D(const SegmentIdMessage);
131  return d->userProfilePrimaryKey;
132 }
133 
134 /*!
135  * Returns the SegmentIdMessage data message's \c deviceId field's current value.
136  *
137  * ID of the device that created the segment
138  *
139  * \return the \c deviceId field value.
140  */
142 {
143  Q_D(const SegmentIdMessage);
144  return d->deviceId;
145 }
146 
147 /*!
148  * Returns the SegmentIdMessage data message's \c defaultRaceLeader field's current value.
149  *
150  * Index for the Leader Board entry selected as the default race participant
151  *
152  * \return the \c defaultRaceLeader field value.
153  */
155 {
156  Q_D(const SegmentIdMessage);
157  return d->defaultRaceLeader;
158 }
159 
160 /*!
161  * Returns the SegmentIdMessage data message's \c deleteStatus field's current value.
162  *
163  * Indicates if any segments should be deleted
164  *
165  * \return the \c deleteStatus field value.
166  */
168 {
169  Q_D(const SegmentIdMessage);
170  return d->deleteStatus;
171 }
172 
173 /*!
174  * Returns the SegmentIdMessage data message's \c selectionType field's current value.
175  *
176  * Indicates how the segment was selected to be sent to the device
177  *
178  * \return the \c selectionType field value.
179  */
181 {
182  Q_D(const SegmentIdMessage);
183  return d->selectionType;
184 }
185 
186 /*!
187  * Sets the \c name field to \a name.
188  *
189  * \param name The field value to set.
190  */
191 void SegmentIdMessage::setName(const QString name)
192 {
193  Q_D(SegmentIdMessage);
194  d->name = name;
195 }
196 /*!
197  * Sets the \c uuid field to \a uuid.
198  *
199  * \param uuid The field value to set.
200  */
201 void SegmentIdMessage::setUuid(const QString uuid)
202 {
203  Q_D(SegmentIdMessage);
204  d->uuid = uuid;
205 }
206 /*!
207  * Sets the \c sport field to \a sport.
208  *
209  * \param sport The field value to set.
210  */
212 {
213  Q_D(SegmentIdMessage);
214  d->sport = sport;
215 }
216 /*!
217  * Sets the \c enabled field to \a enabled.
218  *
219  * \param enabled The field value to set.
220  */
221 void SegmentIdMessage::setEnabled(const bool enabled)
222 {
223  Q_D(SegmentIdMessage);
224  d->enabled = enabled;
225 }
226 /*!
227  * Sets the \c userProfilePrimaryKey field to \a userProfilePrimaryKey.
228  *
229  * \param userProfilePrimaryKey The field value to set.
230  */
231 void SegmentIdMessage::setUserProfilePrimaryKey(const quint32 userProfilePrimaryKey)
232 {
233  Q_D(SegmentIdMessage);
234  d->userProfilePrimaryKey = userProfilePrimaryKey;
235 }
236 /*!
237  * Sets the \c deviceId field to \a deviceId.
238  *
239  * \param deviceId The field value to set.
240  */
241 void SegmentIdMessage::setDeviceId(const quint32 deviceId)
242 {
243  Q_D(SegmentIdMessage);
244  d->deviceId = deviceId;
245 }
246 /*!
247  * Sets the \c defaultRaceLeader field to \a defaultRaceLeader.
248  *
249  * \param defaultRaceLeader The field value to set.
250  */
251 void SegmentIdMessage::setDefaultRaceLeader(const quint8 defaultRaceLeader)
252 {
253  Q_D(SegmentIdMessage);
254  d->defaultRaceLeader = defaultRaceLeader;
255 }
256 /*!
257  * Sets the \c deleteStatus field to \a deleteStatus.
258  *
259  * \param deleteStatus The field value to set.
260  */
262 {
263  Q_D(SegmentIdMessage);
264  d->deleteStatus = deleteStatus;
265 }
266 /*!
267  * Sets the \c selectionType field to \a selectionType.
268  *
269  * \param selectionType The field value to set.
270  */
272 {
273  Q_D(SegmentIdMessage);
274  d->selectionType = selectionType;
275 }
276 
277 /// \cond internal
278 
279 /*!
280  * \internal
281  *
282  * \class SegmentIdMessagePrivate
283  *
284  * The SegmentIdMessagePrivate class provides private implementation for the SegmentIdMessage.
285  *
286  * \sa SegmentIdMessage
287  */
288 
289 /*!
290  * \internal
291  *
292  * Constructs a SegmentIdMessagePrivate object with public implementation \a q.
293  *
294  * \param q Pointer to public implementaton.
295  */
296 SegmentIdMessagePrivate::SegmentIdMessagePrivate(SegmentIdMessage * const q)
298  , sport(static_cast<Sport>(-1))
299  , enabled(static_cast<bool>(-1))
300  , userProfilePrimaryKey(0xFFFFFFFF)
301  , deviceId(0xFFFFFFFF)
302  , defaultRaceLeader(0xFF)
303  , deleteStatus(static_cast<SegmentDeleteStatus>(-1))
304  , selectionType(static_cast<SegmentSelectionType>(-1))
305 {
306  globalMessageNumber = MesgNum::SegmentId;
307 }
308 
309 /*!
310  * \internal
311  *
312  * Destroys the SegmentIdMessagePrivate object.
313  */
315 {
316 
317 }
318 
320  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
321 {
322  switch (fieldId) {
323  case 0: // See Profile.xlsx::Messages:segment_id.name
324  if (!verify(data, baseType, 1, FitBaseType::String, "segment_id.name")) return false;
325  this->name = QString::fromUtf8(data);
326  break;
327  case 1: // See Profile.xlsx::Messages:segment_id.uuid
328  if (!verify(data, baseType, 1, FitBaseType::String, "segment_id.uuid")) return false;
329  this->uuid = QString::fromUtf8(data);
330  break;
331  case 2: // See Profile.xlsx::Messages:segment_id.sport
332  if (!verify(data, baseType, 1, FitBaseType::Enum, "segment_id.sport")) return false;
333  this->sport = static_cast<Sport>(data.at(0));
334  break;
335  case 3: // See Profile.xlsx::Messages:segment_id.enabled
336  if (!verify(data, baseType, 0, FitBaseType::Byte, "segment_id.enabled")) return false;
337  this->enabled = static_cast<bool>(data.at(0));
338  break;
339  case 4: // See Profile.xlsx::Messages:segment_id.userProfilePrimaryKey
340  if (!verify(data, baseType, 4, FitBaseType::Uint32, "segment_id.userProfilePrimaryKey")) return false;
341  this->userProfilePrimaryKey = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
342  break;
343  case 5: // See Profile.xlsx::Messages:segment_id.deviceId
344  if (!verify(data, baseType, 4, FitBaseType::Uint32, "segment_id.deviceId")) return false;
345  this->deviceId = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
346  break;
347  case 6: // See Profile.xlsx::Messages:segment_id.defaultRaceLeader
348  if (!verify(data, baseType, 1, FitBaseType::Uint8, "segment_id.defaultRaceLeader")) return false;
349  this->defaultRaceLeader = static_cast<quint8>(data.at(0));
350  break;
351  case 7: // See Profile.xlsx::Messages:segment_id.deleteStatus
352  if (!verify(data, baseType, 1, FitBaseType::Enum, "segment_id.deleteStatus")) return false;
353  this->deleteStatus = static_cast<SegmentDeleteStatus>(data.at(0));
354  break;
355  case 8: // See Profile.xlsx::Messages:segment_id.selectionType
356  if (!verify(data, baseType, 1, FitBaseType::Enum, "segment_id.selectionType")) return false;
357  this->selectionType = static_cast<SegmentSelectionType>(data.at(0));
358  break;
359  default:
360  qWarning() << "ignoring unknown segment_id message field number" << fieldId << bigEndian;
361  // Fall through to return true, as its still 'safe' to continue parsing data messages.
362  }
363  return true;
364 }
365 
366 /// \endcond
367 
#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.
SegmentSelectionType selectionType
The SegmentIdMessage FIT message's selectionType field.
quint32 userProfilePrimaryKey
The SegmentIdMessage FIT message's userProfilePrimaryKey field.
quint8 defaultRaceLeader
The SegmentIdMessage FIT message's defaultRaceLeader field.
QString uuid
The SegmentIdMessage FIT message's uuid field.
quint32 deviceId
The SegmentIdMessage FIT message's deviceId field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
Sport sport
The SegmentIdMessage FIT message's sport field.
QString name
The SegmentIdMessage FIT message's name field.
bool enabled
The SegmentIdMessage FIT message's enabled field.
SegmentDeleteStatus deleteStatus
The SegmentIdMessage FIT message's deleteStatus field.
The SegmentIdMessage class represents a FIT SegmentIdMessage data message.
void setEnabled(const bool enabled)
Sets the enabled field to enabled.
SegmentDeleteStatus deleteStatus() const
Returns the SegmentIdMessage data message's deleteStatus field's current value.
quint32 userProfilePrimaryKey() const
Returns the SegmentIdMessage data message's userProfilePrimaryKey field's current value.
void setUuid(const QString uuid)
Sets the uuid field to uuid.
void setDeviceId(const quint32 deviceId)
Sets the deviceId field to deviceId.
void setSport(const Sport sport)
Sets the sport field to sport.
quint32 deviceId() const
Returns the SegmentIdMessage data message's deviceId field's current value.
QString name() const
Returns the SegmentIdMessage data message's name field's current value.
void setDefaultRaceLeader(const quint8 defaultRaceLeader)
Sets the defaultRaceLeader field to defaultRaceLeader.
SegmentSelectionType selectionType() const
Returns the SegmentIdMessage data message's selectionType field's current value.
void setUserProfilePrimaryKey(const quint32 userProfilePrimaryKey)
Sets the userProfilePrimaryKey field to userProfilePrimaryKey.
SegmentIdMessage()
Constructs a SegmentIdMessage object.
void setSelectionType(const SegmentSelectionType selectionType)
Sets the selectionType field to selectionType.
Sport sport() const
Returns the SegmentIdMessage data message's sport field's current value.
QString uuid() const
Returns the SegmentIdMessage data message's uuid field's current value.
bool enabled() const
Returns the SegmentIdMessage data message's enabled field's current value.
quint8 defaultRaceLeader() const
Returns the SegmentIdMessage data message's defaultRaceLeader field's current value.
void setDeleteStatus(const SegmentDeleteStatus deleteStatus)
Sets the deleteStatus field to deleteStatus.
void setName(const QString name)
Sets the name field to name.
Declares the SegmentIdMessage class.
Declares the SegmentIdMessagePrivate class.
SegmentDeleteStatus
Garmin FIT SegmentDeleteStatus type.
Definition: types.h:2760
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Sport
Garmin FIT Sport type.
Definition: types.h:685
SegmentSelectionType
Garmin FIT SegmentSelectionType type.
Definition: types.h:2775