messageserializer.h
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #ifndef MESSAGESERIALIZER_H
66 #define MESSAGESERIALIZER_H
67 
68 #include <xstypes/xsmessage.h>
72 
73 struct XsDeviceId;
78 
80 {
81 public:
82  MessageSerializer(XsMessage& message, XsSize offset = 0);
83  virtual ~MessageSerializer();
84 
89  MessageSerializer& operator<<(uint8_t value);
90  MessageSerializer& operator<<(uint16_t value);
92  MessageSerializer& operator<<(uint64_t value);
93 
98  inline MessageSerializer& operator<<(int64_t value)
99  {
100  return (operator<<((uint64_t)value));
101  }
102 
108  {
109  return (operator<<((uint32_t)value));
110  }
111 
116  inline MessageSerializer& operator<<(int16_t value)
117  {
118  return (operator<<((uint16_t)value));
119  }
120 
125  inline MessageSerializer& operator<<(int8_t value)
126  {
127  return (operator<<((uint8_t)value));
128  }
129 
132 
135 
137  inline XsSize index() const
138  {
139  return m_index;
140  }
141 
142  void append(const uint8_t* data, XsSize size);
143  void finalize();
144 private:
147 };
148 
150 {
151 public:
152  MessageDeserializer(const XsMessage& message, XsSize offset = 0);
153  virtual ~MessageDeserializer();
154 
159  MessageDeserializer& operator>>(uint8_t& value);
160  MessageDeserializer& operator>>(int8_t& value);
161  MessageDeserializer& operator>>(uint16_t& value);
163  MessageDeserializer& operator>>(uint64_t& value);
164 
169  inline MessageDeserializer& operator>>(int64_t& value)
170  {
171  return (operator>>((uint64_t&)value));
172  }
173 
179  {
180  return (operator>>((uint32_t&)value));
181  }
182 
187  inline MessageDeserializer& operator>>(int16_t& value)
188  {
189  return (operator>>((uint16_t&)value));
190  }
191 
192  bool atEnd() const;
193 
196 
199 
201  const XsMessage& message() const
202  {
203  return m_message;
204  }
205 
207  inline XsSize index() const
208  {
209  return m_index;
210  }
211 
212 private:
215 };
216 
217 #endif
MessageDeserializer
A class that does the message deserialization.
Definition: messageserializer.h:149
MessageSerializer::MessageSerializer
MessageSerializer(XsMessage &message, XsSize offset=0)
Default constructor.
Definition: messageserializer.cpp:80
MessageDeserializer::operator>>
MessageDeserializer & operator>>(int16_t &value)
Input stream operator that takes a int16_t from the stream.
Definition: messageserializer.h:187
MessageSerializer::append
void append(const uint8_t *data, XsSize size)
Appends the data to the message.
Definition: messageserializer.cpp:234
MessageDeserializer::index
XsSize index() const
Definition: messageserializer.h:207
MessageSerializer::m_message
XsMessage & m_message
Definition: messageserializer.h:145
MessageDeserializer::operator>>
MessageDeserializer & operator>>(int64_t &value)
Input stream operator that takes a int64_t from the stream.
Definition: messageserializer.h:169
MessageDeserializer::message
const XsMessage & message() const
Definition: messageserializer.h:201
MessageDeserializer::operator>>
MessageDeserializer & operator>>(XsDataIdentifier &value)
Input stream operator that takes a XsDataIdentifier from the stream.
Definition: messageserializer.cpp:270
MessageSerializer::m_index
XsSize m_index
Definition: messageserializer.h:146
MessageDeserializer::~MessageDeserializer
virtual ~MessageDeserializer()
Destructor.
Definition: messageserializer.cpp:262
XsCanDataIdentifier
XsCanDataIdentifier
Defines the data identifiers for CAN messages.
Definition: xscandataidentifier.h:82
XsOutputConfigurationArray
A list of XsOutputConfiguration values.
MessageDeserializer::m_index
XsSize m_index
Definition: messageserializer.h:214
MessageSerializer::finalize
void finalize()
Finalizes the message serialization.
Definition: messageserializer.cpp:242
XsDataIdentifier
XsDataIdentifier
Defines the data identifiers.
Definition: xsdataidentifier.h:84
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
MessageSerializer::~MessageSerializer
virtual ~MessageSerializer()
Destructor.
Definition: messageserializer.cpp:89
MessageDeserializer::MessageDeserializer
MessageDeserializer(const XsMessage &message, XsSize offset=0)
Default constructor.
Definition: messageserializer.cpp:254
MessageDeserializer::atEnd
bool atEnd() const
Checks if we are at the end of message.
Definition: messageserializer.cpp:430
MessageSerializer::operator<<
MessageSerializer & operator<<(int32_t value)
Output stream operator that adds a int32_t to the stream.
Definition: messageserializer.h:107
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:74
MessageSerializer::operator<<
MessageSerializer & operator<<(int16_t value)
Output stream operator that adds a int16_t to the stream.
Definition: messageserializer.h:116
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:202
xsdataidentifier.h
MessageSerializer::index
XsSize index() const
Definition: messageserializer.h:137
XsDeviceId
Contains an Xsens device ID and provides operations for determining the type of device.
Definition: xsdeviceid.h:192
XsCanFrameFormat
XsCanFrameFormat
Defines the Frame format for CAN messages.
Definition: xscanframeformat.h:78
MessageDeserializer::operator>>
MessageDeserializer & operator>>(int32_t &value)
Input stream operator that takes a int32_t from the stream.
Definition: messageserializer.h:178
MessageSerializer
A class that does the message serialization.
Definition: messageserializer.h:79
xsmessage.h
xscanframeformat.h
MessageSerializer::operator<<
MessageSerializer & operator<<(int8_t value)
Output stream operator that adds a int8_t to the stream.
Definition: messageserializer.h:125
int32_t
signed int int32_t
Definition: pstdint.h:515
xscandataidentifier.h
XsCanOutputConfiguration
Single data type CAN output configuration.
Definition: xscanoutputconfiguration.h:97
XsCanOutputConfigurationArray
A list of XsCanOutputConfiguration values.
XsOutputConfiguration
Single data type output configuration.
Definition: xsoutputconfiguration.h:96
MessageDeserializer::m_message
const XsMessage & m_message
Definition: messageserializer.h:213
MessageSerializer::operator<<
MessageSerializer & operator<<(XsDataIdentifier value)
Output stream operator that adds a XsDataIdentifier to the stream.
Definition: messageserializer.cpp:104
MessageSerializer::operator<<
MessageSerializer & operator<<(int64_t value)
Output stream operator that adds a int64_t to the stream.
Definition: messageserializer.h:98


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20