QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
coursepointmessage.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 CoursePointMessage, and CoursePointMessagePrivate classes.
28  */
29 
30 #include "coursepointmessage.h"
31 #include "coursepointmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class CoursePointMessage
40  *
41  * The CoursePointMessage class represents a FIT CoursePointMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a CoursePointMessage 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 CoursePointMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the CoursePointMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const CoursePointMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the CoursePointMessage data message's \c timestamp field's current value.
82  *
83  * \return the \c timestamp field value.
84  */
86 {
87  Q_D(const CoursePointMessage);
88  return d->timestamp;
89 }
90 
91 /*!
92  * Returns the CoursePointMessage data message's \c positionLat field's current value.
93  *
94  * \return the \c positionLat field value.
95  */
97 {
98  Q_D(const CoursePointMessage);
99  return d->positionLat;
100 }
101 
102 /*!
103  * Returns the CoursePointMessage data message's \c positionLong field's current value.
104  *
105  * \return the \c positionLong field value.
106  */
108 {
109  Q_D(const CoursePointMessage);
110  return d->positionLong;
111 }
112 
113 /*!
114  * Returns the CoursePointMessage data message's \c distance field's current value.
115  *
116  * \return the \c distance field value.
117  */
119 {
120  Q_D(const CoursePointMessage);
121  return d->distance;
122 }
123 
124 /*!
125  * Returns the CoursePointMessage data message's \c type field's current value.
126  *
127  * \return the \c type field value.
128  */
130 {
131  Q_D(const CoursePointMessage);
132  return d->type;
133 }
134 
135 /*!
136  * Returns the CoursePointMessage data message's \c name field's current value.
137  *
138  * \return the \c name field value.
139  */
141 {
142  Q_D(const CoursePointMessage);
143  return d->name;
144 }
145 
146 /*!
147  * Returns the CoursePointMessage data message's \c favorite field's current value.
148  *
149  * \return the \c favorite field value.
150  */
152 {
153  Q_D(const CoursePointMessage);
154  return d->favorite;
155 }
156 
157 /*!
158  * Sets the \c messageIndex field to \a messageIndex.
159  *
160  * \param messageIndex The field value to set.
161  */
163 {
164  Q_D(CoursePointMessage);
165  d->messageIndex = messageIndex;
166 }
167 /*!
168  * Sets the \c timestamp field to \a timestamp.
169  *
170  * \param timestamp The field value to set.
171  */
173 {
174  Q_D(CoursePointMessage);
175  d->timestamp = timestamp;
176 }
177 /*!
178  * Sets the \c positionLat field to \a positionLat.
179  *
180  * \param positionLat The field value to set.
181  */
182 void CoursePointMessage::setPositionLat(const qint32 positionLat)
183 {
184  Q_D(CoursePointMessage);
185  d->positionLat = positionLat;
186 }
187 /*!
188  * Sets the \c positionLong field to \a positionLong.
189  *
190  * \param positionLong The field value to set.
191  */
192 void CoursePointMessage::setPositionLong(const qint32 positionLong)
193 {
194  Q_D(CoursePointMessage);
195  d->positionLong = positionLong;
196 }
197 /*!
198  * Sets the \c distance field to \a distance.
199  *
200  * \param distance The field value to set.
201  */
202 void CoursePointMessage::setDistance(const quint32 distance)
203 {
204  Q_D(CoursePointMessage);
205  d->distance = distance;
206 }
207 /*!
208  * Sets the \c type field to \a type.
209  *
210  * \param type The field value to set.
211  */
213 {
214  Q_D(CoursePointMessage);
215  d->type = type;
216 }
217 /*!
218  * Sets the \c name field to \a name.
219  *
220  * \param name The field value to set.
221  */
222 void CoursePointMessage::setName(const QString name)
223 {
224  Q_D(CoursePointMessage);
225  d->name = name;
226 }
227 /*!
228  * Sets the \c favorite field to \a favorite.
229  *
230  * \param favorite The field value to set.
231  */
232 void CoursePointMessage::setFavorite(const bool favorite)
233 {
234  Q_D(CoursePointMessage);
235  d->favorite = favorite;
236 }
237 
238 /// \cond internal
239 
240 /*!
241  * \internal
242  *
243  * \class CoursePointMessagePrivate
244  *
245  * The CoursePointMessagePrivate class provides private implementation for the CoursePointMessage.
246  *
247  * \sa CoursePointMessage
248  */
249 
250 /*!
251  * \internal
252  *
253  * Constructs a CoursePointMessagePrivate object with public implementation \a q.
254  *
255  * \param q Pointer to public implementaton.
256  */
257 CoursePointMessagePrivate::CoursePointMessagePrivate(CoursePointMessage * const q)
259  , messageIndex(static_cast<MessageIndex>(-1))
260  , timestamp(static_cast<DateTime>(-1))
261  , positionLat(0x7FFFFFFF)
262  , positionLong(0x7FFFFFFF)
263  , distance(0xFFFFFFFF)
264  , type(static_cast<CoursePoint>(-1))
265  , favorite(static_cast<bool>(-1))
266 {
267  globalMessageNumber = MesgNum::CoursePoint;
268 }
269 
270 /*!
271  * \internal
272  *
273  * Destroys the CoursePointMessagePrivate object.
274  */
276 {
277 
278 }
279 
281  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
282 {
283  switch (fieldId) {
284  case 254: // See Profile.xlsx::Messages:course_point.messageIndex
285  if (!verify(data, baseType, 2, FitBaseType::Uint16, "course_point.messageIndex")) return false;
286  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
287  break;
288  case 1: // See Profile.xlsx::Messages:course_point.timestamp
289  if (!verify(data, baseType, 4, FitBaseType::Uint32, "course_point.timestamp")) return false;
290  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
291  break;
292  case 2: // See Profile.xlsx::Messages:course_point.positionLat
293  if (!verify(data, baseType, 4, FitBaseType::Sint32, "course_point.positionLat")) return false;
294  this->positionLat = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
295  break;
296  case 3: // See Profile.xlsx::Messages:course_point.positionLong
297  if (!verify(data, baseType, 4, FitBaseType::Sint32, "course_point.positionLong")) return false;
298  this->positionLong = static_cast<qint32>(bigEndian ? qFromBigEndian< qint32>(data) : qFromLittleEndian< qint32>(data));
299  break;
300  case 4: // See Profile.xlsx::Messages:course_point.distance
301  if (!verify(data, baseType, 4, FitBaseType::Uint32, "course_point.distance")) return false;
302  this->distance = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
303  break;
304  case 5: // See Profile.xlsx::Messages:course_point.type
305  if (!verify(data, baseType, 1, FitBaseType::Enum, "course_point.type")) return false;
306  this->type = static_cast<CoursePoint>(data.at(0));
307  break;
308  case 6: // See Profile.xlsx::Messages:course_point.name
309  if (!verify(data, baseType, 1, FitBaseType::String, "course_point.name")) return false;
310  this->name = QString::fromUtf8(data);
311  break;
312  case 8: // See Profile.xlsx::Messages:course_point.favorite
313  if (!verify(data, baseType, 0, FitBaseType::Byte, "course_point.favorite")) return false;
314  this->favorite = static_cast<bool>(data.at(0));
315  break;
316  default:
317  qWarning() << "ignoring unknown course_point message field number" << fieldId << bigEndian;
318  // Fall through to return true, as its still 'safe' to continue parsing data messages.
319  }
320  return true;
321 }
322 
323 /// \endcond
324 
#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 CoursePointMessage FIT message's messageIndex field.
bool favorite
The CoursePointMessage FIT message's favorite field.
quint32 distance
The CoursePointMessage FIT message's distance field.
qint32 positionLat
The CoursePointMessage FIT message's positionLat field.
QString name
The CoursePointMessage FIT message's name field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
CoursePoint type
The CoursePointMessage FIT message's type field.
qint32 positionLong
The CoursePointMessage FIT message's positionLong field.
DateTime timestamp
The CoursePointMessage FIT message's timestamp field.
The CoursePointMessage class represents a FIT CoursePointMessage data message.
qint32 positionLat() const
Returns the CoursePointMessage data message's positionLat field's current value.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
void setDistance(const quint32 distance)
Sets the distance field to distance.
quint32 distance() const
Returns the CoursePointMessage data message's distance field's current value.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
QString name() const
Returns the CoursePointMessage data message's name field's current value.
void setPositionLong(const qint32 positionLong)
Sets the positionLong field to positionLong.
void setType(const CoursePoint type)
Sets the type field to type.
CoursePointMessage()
Constructs a CoursePointMessage object.
CoursePoint type() const
Returns the CoursePointMessage data message's type field's current value.
MessageIndex messageIndex() const
Returns the CoursePointMessage data message's messageIndex field's current value.
bool favorite() const
Returns the CoursePointMessage data message's favorite field's current value.
qint32 positionLong() const
Returns the CoursePointMessage data message's positionLong field's current value.
void setFavorite(const bool favorite)
Sets the favorite field to favorite.
void setPositionLat(const qint32 positionLat)
Sets the positionLat field to positionLat.
DateTime timestamp() const
Returns the CoursePointMessage data message's timestamp field's current value.
void setName(const QString name)
Sets the name field to name.
Declares the CoursePointMessage class.
Declares the CoursePointMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
CoursePoint
Garmin FIT CoursePoint type.
Definition: types.h:1446
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237