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