QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
ohrsettingsmessage.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 OhrSettingsMessage, and OhrSettingsMessagePrivate classes.
28  */
29 
30 #include "ohrsettingsmessage.h"
31 #include "ohrsettingsmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class OhrSettingsMessage
40  *
41  * The OhrSettingsMessage class represents a FIT OhrSettingsMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a OhrSettingsMessage 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 OhrSettingsMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the OhrSettingsMessage data message's \c timestamp field's current value.
71  *
72  * \return the \c timestamp field value.
73  */
75 {
76  Q_D(const OhrSettingsMessage);
77  return d->timestamp;
78 }
79 
80 /*!
81  * Returns the OhrSettingsMessage data message's \c enabled field's current value.
82  *
83  * \return the \c enabled field value.
84  */
86 {
87  Q_D(const OhrSettingsMessage);
88  return d->enabled;
89 }
90 
91 /*!
92  * Sets the \c timestamp field to \a timestamp.
93  *
94  * \param timestamp The field value to set.
95  */
97 {
98  Q_D(OhrSettingsMessage);
99  d->timestamp = timestamp;
100 }
101 /*!
102  * Sets the \c enabled field to \a enabled.
103  *
104  * \param enabled The field value to set.
105  */
107 {
108  Q_D(OhrSettingsMessage);
109  d->enabled = enabled;
110 }
111 
112 /// \cond internal
113 
114 /*!
115  * \internal
116  *
117  * \class OhrSettingsMessagePrivate
118  *
119  * The OhrSettingsMessagePrivate class provides private implementation for the OhrSettingsMessage.
120  *
121  * \sa OhrSettingsMessage
122  */
123 
124 /*!
125  * \internal
126  *
127  * Constructs a OhrSettingsMessagePrivate object with public implementation \a q.
128  *
129  * \param q Pointer to public implementaton.
130  */
131 OhrSettingsMessagePrivate::OhrSettingsMessagePrivate(OhrSettingsMessage * const q)
133  , timestamp(static_cast<DateTime>(-1))
134  , enabled(static_cast<Switch>(-1))
135 {
136  globalMessageNumber = MesgNum::OhrSettings;
137 }
138 
139 /*!
140  * \internal
141  *
142  * Destroys the OhrSettingsMessagePrivate object.
143  */
145 {
146 
147 }
148 
150  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
151 {
152  switch (fieldId) {
153  case 253: // See Profile.xlsx::Messages:ohr_settings.timestamp
154  if (!verify(data, baseType, 4, FitBaseType::Uint32, "ohr_settings.timestamp")) return false;
155  this->timestamp = static_cast<DateTime>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
156  break;
157  case 0: // See Profile.xlsx::Messages:ohr_settings.enabled
158  if (!verify(data, baseType, 1, FitBaseType::Enum, "ohr_settings.enabled")) return false;
159  this->enabled = static_cast<Switch>(data.at(0));
160  break;
161  default:
162  qWarning() << "ignoring unknown ohr_settings message field number" << fieldId << bigEndian;
163  // Fall through to return true, as its still 'safe' to continue parsing data messages.
164  }
165  return true;
166 }
167 
168 /// \endcond
169 
#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.
DateTime timestamp
The OhrSettingsMessage FIT message's timestamp field.
Switch enabled
The OhrSettingsMessage FIT message's enabled field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
The OhrSettingsMessage class represents a FIT OhrSettingsMessage data message.
void setEnabled(const Switch enabled)
Sets the enabled field to enabled.
void setTimestamp(const DateTime timestamp)
Sets the timestamp field to timestamp.
DateTime timestamp() const
Returns the OhrSettingsMessage data message's timestamp field's current value.
Switch enabled() const
Returns the OhrSettingsMessage data message's enabled field's current value.
OhrSettingsMessage()
Constructs a OhrSettingsMessage object.
Declares the OhrSettingsMessage class.
Declares the OhrSettingsMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Switch
Garmin FIT Switch type.
Definition: types.h:670
DateTime
Seconds since UTC 00:00 Dec 31 1989.
Definition: types.h:237