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