QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
capabilitiesmessage.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 CapabilitiesMessage, and CapabilitiesMessagePrivate classes.
28  */
29 
30 #include "capabilitiesmessage.h"
31 #include "capabilitiesmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class CapabilitiesMessage
40  *
41  * The CapabilitiesMessage class represents a FIT CapabilitiesMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a CapabilitiesMessage 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 CapabilitiesMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the CapabilitiesMessage data message's \c languages field's current value.
71  *
72  * Use language_bits_x types where x is index of array.
73  *
74  * \return the \c languages field value.
75  */
77 {
78  Q_D(const CapabilitiesMessage);
79  return d->languages;
80 }
81 
82 /*!
83  * Returns the CapabilitiesMessage data message's \c sports field's current value.
84  *
85  * Use sport_bits_x types where x is index of array.
86  *
87  * \return the \c sports field value.
88  */
90 {
91  Q_D(const CapabilitiesMessage);
92  return d->sports;
93 }
94 
95 /*!
96  * Returns the CapabilitiesMessage data message's \c workoutsSupported field's current value.
97  *
98  * \return the \c workoutsSupported field value.
99  */
101 {
102  Q_D(const CapabilitiesMessage);
103  return d->workoutsSupported;
104 }
105 
106 /*!
107  * Returns the CapabilitiesMessage data message's \c connectivitySupported field's current value.
108  *
109  * \return the \c connectivitySupported field value.
110  */
112 {
113  Q_D(const CapabilitiesMessage);
114  return d->connectivitySupported;
115 }
116 
117 /*!
118  * Sets the \c languages field to \a languages.
119  *
120  * \param languages The field value to set.
121  */
123 {
124  Q_D(CapabilitiesMessage);
125  d->languages = languages;
126 }
127 /*!
128  * Sets the \c sports field to \a sports.
129  *
130  * \param sports The field value to set.
131  */
133 {
134  Q_D(CapabilitiesMessage);
135  d->sports = sports;
136 }
137 /*!
138  * Sets the \c workoutsSupported field to \a workoutsSupported.
139  *
140  * \param workoutsSupported The field value to set.
141  */
143 {
144  Q_D(CapabilitiesMessage);
145  d->workoutsSupported = workoutsSupported;
146 }
147 /*!
148  * Sets the \c connectivitySupported field to \a connectivitySupported.
149  *
150  * \param connectivitySupported The field value to set.
151  */
153 {
154  Q_D(CapabilitiesMessage);
155  d->connectivitySupported = connectivitySupported;
156 }
157 
158 /// \cond internal
159 
160 /*!
161  * \internal
162  *
163  * \class CapabilitiesMessagePrivate
164  *
165  * The CapabilitiesMessagePrivate class provides private implementation for the CapabilitiesMessage.
166  *
167  * \sa CapabilitiesMessage
168  */
169 
170 /*!
171  * \internal
172  *
173  * Constructs a CapabilitiesMessagePrivate object with public implementation \a q.
174  *
175  * \param q Pointer to public implementaton.
176  */
177 CapabilitiesMessagePrivate::CapabilitiesMessagePrivate(CapabilitiesMessage * const q)
179  , languages(static_cast<quint8z>(-1))
180  , sports(static_cast<SportBits0>(-1))
181  , workoutsSupported(static_cast<WorkoutCapabilities>(-1))
182  , connectivitySupported(static_cast<ConnectivityCapabilities>(-1))
183 {
184  globalMessageNumber = MesgNum::Capabilities;
185 }
186 
187 /*!
188  * \internal
189  *
190  * Destroys the CapabilitiesMessagePrivate object.
191  */
193 {
194 
195 }
196 
198  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
199 {
200  switch (fieldId) {
201  case 0: // See Profile.xlsx::Messages:capabilities.languages
202  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "capabilities.languages")) return false;
203  this->languages = static_cast<quint8z>(data.at(0));
204  break;
205  case 1: // See Profile.xlsx::Messages:capabilities.sports
206  if (!verify(data, baseType, 1, FitBaseType::Uint8z, "capabilities.sports")) return false;
207  this->sports = static_cast<SportBits0>(data.at(0));
208  break;
209  case 21: // See Profile.xlsx::Messages:capabilities.workoutsSupported
210  if (!verify(data, baseType, 4, FitBaseType::Uint32z, "capabilities.workoutsSupported")) return false;
211  this->workoutsSupported = static_cast<WorkoutCapabilities>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
212  break;
213  case 23: // See Profile.xlsx::Messages:capabilities.connectivitySupported
214  if (!verify(data, baseType, 4, FitBaseType::Uint32z, "capabilities.connectivitySupported")) return false;
215  this->connectivitySupported = static_cast<ConnectivityCapabilities>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
216  break;
217  default:
218  qWarning() << "ignoring unknown capabilities message field number" << fieldId << bigEndian;
219  // Fall through to return true, as its still 'safe' to continue parsing data messages.
220  }
221  return true;
222 }
223 
224 /// \endcond
225 
#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
Declares the CapabilitiesMessage class.
Declares the CapabilitiesMessagePrivate class.
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.
quint8z languages
The CapabilitiesMessage FIT message's languages field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
ConnectivityCapabilities connectivitySupported
The CapabilitiesMessage FIT message's connectivitySupported field.
WorkoutCapabilities workoutsSupported
The CapabilitiesMessage FIT message's workoutsSupported field.
SportBits0 sports
The CapabilitiesMessage FIT message's sports field.
The CapabilitiesMessage class represents a FIT CapabilitiesMessage data message.
void setLanguages(const quint8z languages)
Sets the languages field to languages.
void setWorkoutsSupported(const WorkoutCapabilities workoutsSupported)
Sets the workoutsSupported field to workoutsSupported.
quint8z languages() const
Returns the CapabilitiesMessage data message's languages field's current value.
SportBits0 sports() const
Returns the CapabilitiesMessage data message's sports field's current value.
void setSports(const SportBits0 sports)
Sets the sports field to sports.
WorkoutCapabilities workoutsSupported() const
Returns the CapabilitiesMessage data message's workoutsSupported field's current value.
ConnectivityCapabilities connectivitySupported() const
Returns the CapabilitiesMessage data message's connectivitySupported field's current value.
CapabilitiesMessage()
Constructs a CapabilitiesMessage object.
void setConnectivitySupported(const ConnectivityCapabilities connectivitySupported)
Sets the connectivitySupported field to connectivitySupported.
ConnectivityCapabilities
Garmin FIT ConnectivityCapabilities type.
Definition: types.h:2424
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
SportBits0
Bit field corresponding to sport enum type (1 << sport).
Definition: types.h:748
WorkoutCapabilities
Garmin FIT WorkoutCapabilities type.
Definition: types.h:2106
QTFIT_BEGIN_NAMESPACE typedef quint8 quint8z
8-bit unsigned integer, with 0-is-invalid semantics.
Definition: types.h:45