QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
memoglobmessage.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 MemoGlobMessage, and MemoGlobMessagePrivate classes.
28  */
29 
30 #include "memoglobmessage.h"
31 #include "memoglobmessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class MemoGlobMessage
40  *
41  * The MemoGlobMessage class represents a FIT MemoGlobMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a MemoGlobMessage 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 MemoGlobMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the MemoGlobMessage data message's \c partIndex field's current value.
71  *
72  * Sequence number of memo blocks
73  *
74  * \return the \c partIndex field value.
75  */
77 {
78  Q_D(const MemoGlobMessage);
79  return d->partIndex;
80 }
81 
82 /*!
83  * Returns the MemoGlobMessage data message's \c memo field's current value.
84  *
85  * Block of utf8 bytes
86  *
87  * \return the \c memo field value.
88  */
89 quint8 MemoGlobMessage::memo() const
90 {
91  Q_D(const MemoGlobMessage);
92  return d->memo;
93 }
94 
95 /*!
96  * Returns the MemoGlobMessage data message's \c messageNumber field's current value.
97  *
98  * Allows relating glob to another mesg If used only required for first part of each memo_glob
99  *
100  * \return the \c messageNumber field value.
101  */
103 {
104  Q_D(const MemoGlobMessage);
105  return d->messageNumber;
106 }
107 
108 /*!
109  * Returns the MemoGlobMessage data message's \c messageIndex field's current value.
110  *
111  * Index of external mesg
112  *
113  * \return the \c messageIndex field value.
114  */
116 {
117  Q_D(const MemoGlobMessage);
118  return d->messageIndex;
119 }
120 
121 /*!
122  * Sets the \c partIndex field to \a partIndex.
123  *
124  * \param partIndex The field value to set.
125  */
126 void MemoGlobMessage::setPartIndex(const quint32 partIndex)
127 {
128  Q_D(MemoGlobMessage);
129  d->partIndex = partIndex;
130 }
131 /*!
132  * Sets the \c memo field to \a memo.
133  *
134  * \param memo The field value to set.
135  */
136 void MemoGlobMessage::setMemo(const quint8 memo)
137 {
138  Q_D(MemoGlobMessage);
139  d->memo = memo;
140 }
141 /*!
142  * Sets the \c messageNumber field to \a messageNumber.
143  *
144  * \param messageNumber The field value to set.
145  */
146 void MemoGlobMessage::setMessageNumber(const quint16 messageNumber)
147 {
148  Q_D(MemoGlobMessage);
149  d->messageNumber = messageNumber;
150 }
151 /*!
152  * Sets the \c messageIndex field to \a messageIndex.
153  *
154  * \param messageIndex The field value to set.
155  */
157 {
158  Q_D(MemoGlobMessage);
159  d->messageIndex = messageIndex;
160 }
161 
162 /// \cond internal
163 
164 /*!
165  * \internal
166  *
167  * \class MemoGlobMessagePrivate
168  *
169  * The MemoGlobMessagePrivate class provides private implementation for the MemoGlobMessage.
170  *
171  * \sa MemoGlobMessage
172  */
173 
174 /*!
175  * \internal
176  *
177  * Constructs a MemoGlobMessagePrivate object with public implementation \a q.
178  *
179  * \param q Pointer to public implementaton.
180  */
181 MemoGlobMessagePrivate::MemoGlobMessagePrivate(MemoGlobMessage * const q)
183  , partIndex(0xFFFFFFFF)
184  , memo(0xFF)
185  , messageNumber(0xFFFF)
186  , messageIndex(static_cast<MessageIndex>(-1))
187 {
188  globalMessageNumber = MesgNum::MemoGlob;
189 }
190 
191 /*!
192  * \internal
193  *
194  * Destroys the MemoGlobMessagePrivate object.
195  */
197 {
198 
199 }
200 
202  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
203 {
204  switch (fieldId) {
205  case 250: // See Profile.xlsx::Messages:memo_glob.partIndex
206  if (!verify(data, baseType, 4, FitBaseType::Uint32, "memo_glob.partIndex")) return false;
207  this->partIndex = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
208  break;
209  case 0: // See Profile.xlsx::Messages:memo_glob.memo
210  if (!verify(data, baseType, 1, FitBaseType::Byte, "memo_glob.memo")) return false;
211  this->memo = static_cast<quint8>(data.at(0));
212  break;
213  case 1: // See Profile.xlsx::Messages:memo_glob.messageNumber
214  if (!verify(data, baseType, 2, FitBaseType::Uint16, "memo_glob.messageNumber")) return false;
215  this->messageNumber = static_cast<quint16>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
216  break;
217  case 2: // See Profile.xlsx::Messages:memo_glob.messageIndex
218  if (!verify(data, baseType, 2, FitBaseType::Uint16, "memo_glob.messageIndex")) return false;
219  this->messageIndex = static_cast<MessageIndex>(bigEndian ? qFromBigEndian<quint16>(data) : qFromLittleEndian<quint16>(data));
220  break;
221  default:
222  qWarning() << "ignoring unknown memo_glob message field number" << fieldId << bigEndian;
223  // Fall through to return true, as its still 'safe' to continue parsing data messages.
224  }
225  return true;
226 }
227 
228 /// \endcond
229 
#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.
MessageIndex messageIndex
The MemoGlobMessage FIT message's messageIndex field.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
quint16 messageNumber
The MemoGlobMessage FIT message's messageNumber field.
quint8 memo
The MemoGlobMessage FIT message's memo field.
quint32 partIndex
The MemoGlobMessage FIT message's partIndex field.
The MemoGlobMessage class represents a FIT MemoGlobMessage data message.
void setPartIndex(const quint32 partIndex)
Sets the partIndex field to partIndex.
void setMessageNumber(const quint16 messageNumber)
Sets the messageNumber field to messageNumber.
MemoGlobMessage()
Constructs a MemoGlobMessage object.
quint32 partIndex() const
Returns the MemoGlobMessage data message's partIndex field's current value.
quint8 memo() const
Returns the MemoGlobMessage data message's memo field's current value.
quint16 messageNumber() const
Returns the MemoGlobMessage data message's messageNumber field's current value.
MessageIndex messageIndex() const
Returns the MemoGlobMessage data message's messageIndex field's current value.
void setMemo(const quint8 memo)
Sets the memo field to memo.
void setMessageIndex(const MessageIndex messageIndex)
Sets the messageIndex field to messageIndex.
Declares the MemoGlobMessage class.
Declares the MemoGlobMessagePrivate class.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
MessageIndex
Garmin FIT MessageIndex type.
Definition: types.h:263