QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
goalmessage.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 GoalMessage, and GoalMessagePrivate classes.
28  */
29 
30 #include "goalmessage.h"
31 #include "goalmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class GoalMessage
40  *
41  * The GoalMessage class represents a FIT GoalMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a GoalMessage 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 GoalMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the GoalMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const GoalMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the GoalMessage data message's \c sport field's current value.
82  *
83  * \return the \c sport field value.
84  */
86 {
87  Q_D(const GoalMessage);
88  return d->sport;
89 }
90 
91 /*!
92  * Returns the GoalMessage data message's \c subSport field's current value.
93  *
94  * \return the \c subSport field value.
95  */
97 {
98  Q_D(const GoalMessage);
99  return d->subSport;
100 }
101 
102 /*!
103  * Returns the GoalMessage data message's \c startDate field's current value.
104  *
105  * \return the \c startDate field value.
106  */
108 {
109  Q_D(const GoalMessage);
110  return d->startDate;
111 }
112 
113 /*!
114  * Returns the GoalMessage data message's \c endDate field's current value.
115  *
116  * \return the \c endDate field value.
117  */
119 {
120  Q_D(const GoalMessage);
121  return d->endDate;
122 }
123 
124 /*!
125  * Returns the GoalMessage data message's \c type field's current value.
126  *
127  * \return the \c type field value.
128  */
130 {
131  Q_D(const GoalMessage);
132  return d->type;
133 }
134 
135 /*!
136  * Returns the GoalMessage data message's \c value field's current value.
137  *
138  * \return the \c value field value.
139  */
140 quint32 GoalMessage::value() const
141 {
142  Q_D(const GoalMessage);
143  return d->value;
144 }
145 
146 /*!
147  * Returns the GoalMessage data message's \c repeat field's current value.
148  *
149  * \return the \c repeat field value.
150  */
152 {
153  Q_D(const GoalMessage);
154  return d->repeat;
155 }
156 
157 /*!
158  * Returns the GoalMessage data message's \c targetValue field's current value.
159  *
160  * \return the \c targetValue field value.
161  */
163 {
164  Q_D(const GoalMessage);
165  return d->targetValue;
166 }
167 
168 /*!
169  * Returns the GoalMessage data message's \c recurrence field's current value.
170  *
171  * \return the \c recurrence field value.
172  */
174 {
175  Q_D(const GoalMessage);
176  return d->recurrence;
177 }
178 
179 /*!
180  * Returns the GoalMessage data message's \c recurrenceValue field's current value.
181  *
182  * \return the \c recurrenceValue field value.
183  */
185 {
186  Q_D(const GoalMessage);
187  return d->recurrenceValue;
188 }
189 
190 /*!
191  * Returns the GoalMessage data message's \c enabled field's current value.
192  *
193  * \return the \c enabled field value.
194  */
196 {
197  Q_D(const GoalMessage);
198  return d->enabled;
199 }
200 
201 /*!
202  * Returns the GoalMessage data message's \c source field's current value.
203  *
204  * \return the \c source field value.
205  */
207 {
208  Q_D(const GoalMessage);
209  return d->source;
210 }
211 
212 /*!
213  * Sets the \c messageIndex field to \a messageIndex.
214  *
215  * \param messageIndex The field value to set.
216  */
218 {
219  Q_D(GoalMessage);
220  d->messageIndex = messageIndex;
221 }
222 /*!
223  * Sets the \c sport field to \a sport.
224  *
225  * \param sport The field value to set.
226  */
227 void GoalMessage::setSport(const Sport sport)
228 {
229  Q_D(GoalMessage);
230  d->sport = sport;
231 }
232 /*!
233  * Sets the \c subSport field to \a subSport.
234  *
235  * \param subSport The field value to set.
236  */
237 void GoalMessage::setSubSport(const SubSport subSport)
238 {
239  Q_D(GoalMessage);
240  d->subSport = subSport;
241 }
242 /*!
243  * Sets the \c startDate field to \a startDate.
244  *
245  * \param startDate The field value to set.
246  */
247 void GoalMessage::setStartDate(const DateTime startDate)
248 {
249  Q_D(GoalMessage);
250  d->startDate = startDate;
251 }
252 /*!
253  * Sets the \c endDate field to \a endDate.
254  *
255  * \param endDate The field value to set.
256  */
258 {
259  Q_D(GoalMessage);
260  d->endDate = endDate;
261 }
262 /*!
263  * Sets the \c type field to \a type.
264  *
265  * \param type The field value to set.
266  */
267 void GoalMessage::setType(const Goal type)
268 {
269  Q_D(GoalMessage);
270  d->type = type;
271 }
272 /*!
273  * Sets the \c value field to \a value.
274  *
275  * \param value The field value to set.
276  */
277 void GoalMessage::setValue(const quint32 value)
278 {
279  Q_D(GoalMessage);
280  d->value = value;
281 }
282 /*!
283  * Sets the \c repeat field to \a repeat.
284  *
285  * \param repeat The field value to set.
286  */
287 void GoalMessage::setRepeat(const bool repeat)
288 {
289  Q_D(GoalMessage);
290  d->repeat = repeat;
291 }
292 /*!
293  * Sets the \c targetValue field to \a targetValue.
294  *
295  * \param targetValue The field value to set.
296  */
297 void GoalMessage::setTargetValue(const quint32 targetValue)
298 {
299  Q_D(GoalMessage);
300  d->targetValue = targetValue;
301 }
302 /*!
303  * Sets the \c recurrence field to \a recurrence.
304  *
305  * \param recurrence The field value to set.
306  */
308 {
309  Q_D(GoalMessage);
310  d->recurrence = recurrence;
311 }
312 /*!
313  * Sets the \c recurrenceValue field to \a recurrenceValue.
314  *
315  * \param recurrenceValue The field value to set.
316  */
317 void GoalMessage::setRecurrenceValue(const quint16 recurrenceValue)
318 {
319  Q_D(GoalMessage);
320  d->recurrenceValue = recurrenceValue;
321 }
322 /*!
323  * Sets the \c enabled field to \a enabled.
324  *
325  * \param enabled The field value to set.
326  */
327 void GoalMessage::setEnabled(const bool enabled)
328 {
329  Q_D(GoalMessage);
330  d->enabled = enabled;
331 }
332 /*!
333  * Sets the \c source field to \a source.
334  *
335  * \param source The field value to set.
336  */
338 {
339  Q_D(GoalMessage);
340  d->source = source;
341 }
342 
343 /// \cond internal
344 
345 /*!
346  * \internal
347  *
348  * \class GoalMessagePrivate
349  *
350  * The GoalMessagePrivate class provides private implementation for the GoalMessage.
351  *
352  * \sa GoalMessage
353  */
354 
355 /*!
356  * \internal
357  *
358  * Constructs a GoalMessagePrivate object with public implementation \a q.
359  *
360  * \param q Pointer to public implementaton.
361  */
362 GoalMessagePrivate::GoalMessagePrivate(GoalMessage * const q)
364  , messageIndex(static_cast<MessageIndex>(-1))
365  , sport(static_cast<Sport>(-1))
366  , subSport(static_cast<SubSport>(-1))
367  , startDate(static_cast<DateTime>(-1))
368  , endDate(static_cast<DateTime>(-1))
369  , type(static_cast<Goal>(-1))
370  , value(0xFFFFFFFF)
371  , repeat(static_cast<bool>(-1))
372  , targetValue(0xFFFFFFFF)
373  , recurrence(static_cast<GoalRecurrence>(-1))
374  , recurrenceValue(0xFFFF)
375  , enabled(static_cast<bool>(-1))
376  , source(static_cast<GoalSource>(-1))
377 {
378  globalMessageNumber = MesgNum::Goal;
379 }
380 
381 /*!
382  * \internal
383  *
384  * Destroys the GoalMessagePrivate object.
385  */
387 {
388 
389 }
390 
392  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
393 {
394  switch (fieldId) {
395  case 254: // See Profile.xlsx::Messages:goal.messageIndex
396  if (!verify(data, baseType, 2, FitBaseType::Uint16, "goal.messageIndex")) return false;
397  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
398  break;
399  case 0: // See Profile.xlsx::Messages:goal.sport
400  if (!verify(data, baseType, 1, FitBaseType::Enum, "goal.sport")) return false;
401  this->sport = static_cast<Sport>(data.at(0));
402  break;
403  case 1: // See Profile.xlsx::Messages:goal.subSport
404  if (!verify(data, baseType, 1, FitBaseType::Enum, "goal.subSport")) return false;
405  this->subSport = static_cast<SubSport>(data.at(0));
406  break;
407  case 2: // See Profile.xlsx::Messages:goal.startDate
408  if (!verify(data, baseType, 4, FitBaseType::Uint32, "goal.startDate")) return false;
409  this->startDate = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
410  break;
411  case 3: // See Profile.xlsx::Messages:goal.endDate
412  if (!verify(data, baseType, 4, FitBaseType::Uint32, "goal.endDate")) return false;
413  this->endDate = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
414  break;
415  case 4: // See Profile.xlsx::Messages:goal.type
416  if (!verify(data, baseType, 1, FitBaseType::Enum, "goal.type")) return false;
417  this->type = static_cast<Goal>(data.at(0));
418  break;
419  case 5: // See Profile.xlsx::Messages:goal.value
420  if (!verify(data, baseType, 4, FitBaseType::Uint32, "goal.value")) return false;
421  this->value = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
422  break;
423  case 6: // See Profile.xlsx::Messages:goal.repeat
424  if (!verify(data, baseType, 0, FitBaseType::Byte, "goal.repeat")) return false;
425  this->repeat = static_cast<bool>(data.at(0));
426  break;
427  case 7: // See Profile.xlsx::Messages:goal.targetValue
428  if (!verify(data, baseType, 4, FitBaseType::Uint32, "goal.targetValue")) return false;
429  this->targetValue = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
430  break;
431  case 8: // See Profile.xlsx::Messages:goal.recurrence
432  if (!verify(data, baseType, 1, FitBaseType::Enum, "goal.recurrence")) return false;
433  this->recurrence = static_cast<GoalRecurrence>(data.at(0));
434  break;
435  case 9: // See Profile.xlsx::Messages:goal.recurrenceValue
436  if (!verify(data, baseType, 2, FitBaseType::Uint16, "goal.recurrenceValue")) return false;
437  this->recurrenceValue = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
438  break;
439  case 10: // See Profile.xlsx::Messages:goal.enabled
440  if (!verify(data, baseType, 0, FitBaseType::Byte, "goal.enabled")) return false;
441  this->enabled = static_cast<bool>(data.at(0));
442  break;
443  case 11: // See Profile.xlsx::Messages:goal.source
444  if (!verify(data, baseType, 1, FitBaseType::Enum, "goal.source")) return false;
445  this->source = static_cast<GoalSource>(data.at(0));
446  break;
447  default:
448  qWarning() << "ignoring unknown goal message field number" << fieldId << bigEndian;
449  // Fall through to return true, as its still 'safe' to continue parsing data messages.
450  }
451  return true;
452 }
453 
454 /// \endcond
455 
#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.
quint32 targetValue
The GoalMessage FIT message's targetValue field.
Definition: goalmessage_p.h:84
SubSport subSport
The GoalMessage FIT message's subSport field.
Definition: goalmessage_p.h:54
DateTime startDate
The GoalMessage FIT message's startDate field.
Definition: goalmessage_p.h:59
MessageIndex messageIndex
The GoalMessage FIT message's messageIndex field.
Definition: goalmessage_p.h:44
quint32 value
The GoalMessage FIT message's value field.
Definition: goalmessage_p.h:74
GoalSource source
The GoalMessage FIT message's source field.
GoalRecurrence recurrence
The GoalMessage FIT message's recurrence field.
Definition: goalmessage_p.h:89
virtual ~GoalMessagePrivate()
Sport sport
The GoalMessage FIT message's sport field.
Definition: goalmessage_p.h:49
DateTime endDate
The GoalMessage FIT message's endDate field.
Definition: goalmessage_p.h:64
quint16 recurrenceValue
The GoalMessage FIT message's recurrenceValue field.
Definition: goalmessage_p.h:94
Goal type
The GoalMessage FIT message's type field.
Definition: goalmessage_p.h:69
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
bool enabled
The GoalMessage FIT message's enabled field.
Definition: goalmessage_p.h:99
bool repeat
The GoalMessage FIT message's repeat field.
Definition: goalmessage_p.h:79
The GoalMessage class represents a FIT GoalMessage data message.
Definition: goalmessage.h:39
GoalRecurrence recurrence() const
Returns the GoalMessage data message's recurrence field's current value.
GoalMessage()
Constructs a GoalMessage object.
Definition: goalmessage.cpp:52
MessageIndex messageIndex() const
Returns the GoalMessage data message's messageIndex field's current value.
Definition: goalmessage.cpp:74
bool enabled() const
Returns the GoalMessage data message's enabled field's current value.
void setEndDate(const DateTime endDate)
Sets the endDate field to endDate.
quint32 targetValue() const
Returns the GoalMessage data message's targetValue field's current value.
DateTime startDate() const
Returns the GoalMessage data message's startDate field's current value.
Sport sport() const
Returns the GoalMessage data message's sport field's current value.
Definition: goalmessage.cpp:85
GoalSource source() const
Returns the GoalMessage data message's source field's current value.
bool repeat() const
Returns the GoalMessage data message's repeat field's current value.
quint32 value() const
Returns the GoalMessage data message's value field's current value.
void setSport(const Sport sport)
Sets the sport field to sport.
void setSource(const GoalSource source)
Sets the source field to source.
Goal type() const
Returns the GoalMessage data message's type field's current value.
quint16 recurrenceValue() const
Returns the GoalMessage data message's recurrenceValue field's current value.
SubSport subSport() const
Returns the GoalMessage data message's subSport field's current value.
Definition: goalmessage.cpp:96
void setRecurrenceValue(const quint16 recurrenceValue)
Sets the recurrenceValue field to recurrenceValue.
void setTargetValue(const quint32 targetValue)
Sets the targetValue field to targetValue.
void setEnabled(const bool enabled)
Sets the enabled field to enabled.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
void setSubSport(const SubSport subSport)
Sets the subSport field to subSport.
void setValue(const quint32 value)
Sets the value field to value.
void setType(const Goal type)
Sets the type field to type.
void setStartDate(const DateTime startDate)
Sets the startDate field to startDate.
DateTime endDate() const
Returns the GoalMessage data message's endDate field's current value.
void setRepeat(const bool repeat)
Sets the repeat field to repeat.
void setRecurrence(const GoalRecurrence recurrence)
Sets the recurrence field to recurrence.
Declares the GoalMessage class.
Declares the GoalMessagePrivate class.
Goal
Garmin FIT Goal type.
Definition: types.h:1380
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
GoalRecurrence
Garmin FIT GoalRecurrence type.
Definition: types.h:1399
Sport
Garmin FIT Sport type.
Definition: types.h:685
GoalSource
Garmin FIT GoalSource type.
Definition: types.h:1417
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
SubSport
Garmin FIT SubSport type.
Definition: types.h:881
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237