QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
speedzonemessage.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 SpeedZoneMessage, and SpeedZoneMessagePrivate classes.
28  */
29 
30 #include "speedzonemessage.h"
31 #include "speedzonemessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class SpeedZoneMessage
40  *
41  * The SpeedZoneMessage class represents a FIT SpeedZoneMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a SpeedZoneMessage 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 SpeedZoneMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the SpeedZoneMessage data message's \c messageIndex field's current value.
71  *
72  * \return the \c messageIndex field value.
73  */
75 {
76  Q_D(const SpeedZoneMessage);
77  return d->messageIndex;
78 }
79 
80 /*!
81  * Returns the SpeedZoneMessage data message's \c highValue field's current value.
82  *
83  * \return the \c highValue field value.
84  */
86 {
87  Q_D(const SpeedZoneMessage);
88  return d->highValue;
89 }
90 
91 /*!
92  * Returns the SpeedZoneMessage data message's \c name field's current value.
93  *
94  * \return the \c name field value.
95  */
96 QString SpeedZoneMessage::name() const
97 {
98  Q_D(const SpeedZoneMessage);
99  return d->name;
100 }
101 
102 /*!
103  * Sets the \c messageIndex field to \a messageIndex.
104  *
105  * \param messageIndex The field value to set.
106  */
108 {
109  Q_D(SpeedZoneMessage);
110  d->messageIndex = messageIndex;
111 }
112 /*!
113  * Sets the \c highValue field to \a highValue.
114  *
115  * \param highValue The field value to set.
116  */
117 void SpeedZoneMessage::setHighValue(const quint16 highValue)
118 {
119  Q_D(SpeedZoneMessage);
120  d->highValue = highValue;
121 }
122 /*!
123  * Sets the \c name field to \a name.
124  *
125  * \param name The field value to set.
126  */
127 void SpeedZoneMessage::setName(const QString name)
128 {
129  Q_D(SpeedZoneMessage);
130  d->name = name;
131 }
132 
133 /// \cond internal
134 
135 /*!
136  * \internal
137  *
138  * \class SpeedZoneMessagePrivate
139  *
140  * The SpeedZoneMessagePrivate class provides private implementation for the SpeedZoneMessage.
141  *
142  * \sa SpeedZoneMessage
143  */
144 
145 /*!
146  * \internal
147  *
148  * Constructs a SpeedZoneMessagePrivate object with public implementation \a q.
149  *
150  * \param q Pointer to public implementaton.
151  */
152 SpeedZoneMessagePrivate::SpeedZoneMessagePrivate(SpeedZoneMessage * const q)
154  , messageIndex(static_cast<MessageIndex>(-1))
155  , highValue(0xFFFF)
156 {
157  globalMessageNumber = MesgNum::SpeedZone;
158 }
159 
160 /*!
161  * \internal
162  *
163  * Destroys the SpeedZoneMessagePrivate object.
164  */
166 {
167 
168 }
169 
171  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
172 {
173  switch (fieldId) {
174  case 254: // See Profile.xlsx::Messages:speed_zone.messageIndex
175  if (!verify(data, baseType, 2, FitBaseType::Uint16, "speed_zone.messageIndex")) return false;
176  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
177  break;
178  case 0: // See Profile.xlsx::Messages:speed_zone.highValue
179  if (!verify(data, baseType, 2, FitBaseType::Uint16, "speed_zone.highValue")) return false;
180  this->highValue = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
181  break;
182  case 1: // See Profile.xlsx::Messages:speed_zone.name
183  if (!verify(data, baseType, 1, FitBaseType::String, "speed_zone.name")) return false;
184  this->name = QString::fromUtf8(data);
185  break;
186  default:
187  qWarning() << "ignoring unknown speed_zone message field number" << fieldId << bigEndian;
188  // Fall through to return true, as its still 'safe' to continue parsing data messages.
189  }
190  return true;
191 }
192 
193 /// \endcond
194 
#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 name
The SpeedZoneMessage FIT message's name field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
MessageIndex messageIndex
The SpeedZoneMessage FIT message's messageIndex field.
quint16 highValue
The SpeedZoneMessage FIT message's highValue field.
The SpeedZoneMessage class represents a FIT SpeedZoneMessage data message.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
void setName(const QString name)
Sets the name field to name.
MessageIndex messageIndex() const
Returns the SpeedZoneMessage data message's messageIndex field's current value.
void setHighValue(const quint16 highValue)
Sets the highValue field to highValue.
QString name() const
Returns the SpeedZoneMessage data message's name field's current value.
SpeedZoneMessage()
Constructs a SpeedZoneMessage object.
quint16 highValue() const
Returns the SpeedZoneMessage data message's highValue field's current value.
Declares the SpeedZoneMessage class.
Declares the SpeedZoneMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263