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