QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
coursemessage.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 CourseMessage, and CourseMessagePrivate classes.
28  */
29 
30 #include "coursemessage.h"
31 #include "coursemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class CourseMessage
40  *
41  * The CourseMessage class represents a FIT CourseMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a CourseMessage 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 CourseMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the CourseMessage data message's \c sport field's current value.
71  *
72  * \return the \c sport field value.
73  */
75 {
76  Q_D(const CourseMessage);
77  return d->sport;
78 }
79 
80 /*!
81  * Returns the CourseMessage data message's \c name field's current value.
82  *
83  * \return the \c name field value.
84  */
85 QString CourseMessage::name() const
86 {
87  Q_D(const CourseMessage);
88  return d->name;
89 }
90 
91 /*!
92  * Returns the CourseMessage data message's \c capabilities field's current value.
93  *
94  * \return the \c capabilities field value.
95  */
97 {
98  Q_D(const CourseMessage);
99  return d->capabilities;
100 }
101 
102 /*!
103  * Returns the CourseMessage data message's \c subSport field's current value.
104  *
105  * \return the \c subSport field value.
106  */
108 {
109  Q_D(const CourseMessage);
110  return d->subSport;
111 }
112 
113 /*!
114  * Sets the \c sport field to \a sport.
115  *
116  * \param sport The field value to set.
117  */
119 {
120  Q_D(CourseMessage);
121  d->sport = sport;
122 }
123 /*!
124  * Sets the \c name field to \a name.
125  *
126  * \param name The field value to set.
127  */
128 void CourseMessage::setName(const QString name)
129 {
130  Q_D(CourseMessage);
131  d->name = name;
132 }
133 /*!
134  * Sets the \c capabilities field to \a capabilities.
135  *
136  * \param capabilities The field value to set.
137  */
139 {
140  Q_D(CourseMessage);
141  d->capabilities = capabilities;
142 }
143 /*!
144  * Sets the \c subSport field to \a subSport.
145  *
146  * \param subSport The field value to set.
147  */
149 {
150  Q_D(CourseMessage);
151  d->subSport = subSport;
152 }
153 
154 /// \cond internal
155 
156 /*!
157  * \internal
158  *
159  * \class CourseMessagePrivate
160  *
161  * The CourseMessagePrivate class provides private implementation for the CourseMessage.
162  *
163  * \sa CourseMessage
164  */
165 
166 /*!
167  * \internal
168  *
169  * Constructs a CourseMessagePrivate object with public implementation \a q.
170  *
171  * \param q Pointer to public implementaton.
172  */
173 CourseMessagePrivate::CourseMessagePrivate(CourseMessage * const q)
175  , sport(static_cast<Sport>(-1))
176  , capabilities(static_cast<CourseCapabilities>(-1))
177  , subSport(static_cast<SubSport>(-1))
178 {
179  globalMessageNumber = MesgNum::Course;
180 }
181 
182 /*!
183  * \internal
184  *
185  * Destroys the CourseMessagePrivate object.
186  */
188 {
189 
190 }
191 
193  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
194 {
195  switch (fieldId) {
196  case 4: // See Profile.xlsx::Messages:course.sport
197  if (!verify(data, baseType, 1, FitBaseType::Enum, "course.sport")) return false;
198  this->sport = static_cast<Sport>(data.at(0));
199  break;
200  case 5: // See Profile.xlsx::Messages:course.name
201  if (!verify(data, baseType, 1, FitBaseType::String, "course.name")) return false;
202  this->name = QString::fromUtf8(data);
203  break;
204  case 6: // See Profile.xlsx::Messages:course.capabilities
205  if (!verify(data, baseType, 4, FitBaseType::Uint32z, "course.capabilities")) return false;
206  this->capabilities = static_cast<CourseCapabilities>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
207  break;
208  case 7: // See Profile.xlsx::Messages:course.subSport
209  if (!verify(data, baseType, 1, FitBaseType::Enum, "course.subSport")) return false;
210  this->subSport = static_cast<SubSport>(data.at(0));
211  break;
212  default:
213  qWarning() << "ignoring unknown course message field number" << fieldId << bigEndian;
214  // Fall through to return true, as its still 'safe' to continue parsing data messages.
215  }
216  return true;
217 }
218 
219 /// \endcond
220 
#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.
CourseCapabilities capabilities
The CourseMessage FIT message's capabilities field.
virtual ~CourseMessagePrivate()
QString name
The CourseMessage FIT message's name field.
Sport sport
The CourseMessage FIT message's sport field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
SubSport subSport
The CourseMessage FIT message's subSport field.
The CourseMessage class represents a FIT CourseMessage data message.
Definition: coursemessage.h:39
SubSport subSport() const
Returns the CourseMessage data message's subSport field's current value.
void setSubSport(const SubSport subSport)
Sets the subSport field to subSport.
CourseMessage()
Constructs a CourseMessage object.
void setCapabilities(const CourseCapabilities capabilities)
Sets the capabilities field to capabilities.
Sport sport() const
Returns the CourseMessage data message's sport field's current value.
void setName(const QString name)
Sets the name field to name.
CourseCapabilities capabilities() const
Returns the CourseMessage data message's capabilities field's current value.
QString name() const
Returns the CourseMessage data message's name field's current value.
void setSport(const Sport sport)
Sets the sport field to sport.
Declares the CourseMessage class.
Declares the CourseMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Sport
Garmin FIT Sport type.
Definition: types.h:685
CourseCapabilities
Garmin FIT CourseCapabilities type.
Definition: types.h:2165
SubSport
Garmin FIT SubSport type.
Definition: types.h:881