Main MRPT website > C++ reference for MRPT 1.5.7
iprotocolhandler.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef IPROTOCOLHANDLER_H
10 #define IPROTOCOLHANDLER_H
11 
12 #include "messagelocation.h"
13 #include <xsens/xsmessage.h>
14 #include <xsens/xsbytearray.h>
15 
16 //--------------------------------------------------------------------------------
17 /*! \brief Interface class for protocol handlers
18  \details Describes the interfaces of the protocol handling classes. The protocol handlers are
19  used to convert a binary data stream into XsMessage objects.
20 */
22 {
23 public:
24  //! \brief Destructor
25  virtual ~IProtocolHandler() {}
26 
27  /*! \brief Find the first message in the \a raw byte stream
28  \details This function scans \a raw for a sequence of bytes that it can convert into an
29  %XsMessage object. It returns the location and total byte size of the message so that the
30  caller can remove those bytes from the stream. The return value can also describe that a
31  partial message has been found. Return values:
32  \li \a startpos >= 0 and \a size > 0: A full message with \a size has been found at \a startpos.
33  \li \a startpos >= 0 and \a size == 0: The start of a message has been found at \a startpos, but the size could not yet be determined.
34  \li \a startpos >= 0 and \a size < 0: The start of a message has been found at \a startpos, and the size of the full message is at least \a -size.
35  \li \a startpos < 0: No messages have been found.
36 
37  \param rcv If a message is read, it will be put in this object.
38  \param raw The raw byte stream to analyze.
39  \returns A %MessageLocation object that describes what was found.
40  */
41  virtual MessageLocation findMessage(XsMessage& rcv, const XsByteArray& raw) const = 0;
42  /*! \brief Returns the minimum size of a valid message
43  \details This value may differ for different protocols, but is always at least 1.
44  \returns The minimum size of a valid message for the protocol.
45  */
46  virtual int minimumMessageSize() const = 0;
47  /*! \brief Returns the maximum size of a valid message
48  \details This value may differ for different protocols.
49  \returns The maximum size of a valid message for the protocol.
50  */
51  virtual int maximumMessageSize() const = 0;
52  /*! \brief Returns the type of the protocol handler
53  \details Each protocol handler has a locally unique id that can be used for instantiation of
54  the correct protocol handler.
55  \returns The type id of the protocol handler.
56  */
57  virtual int type() const = 0;
58 };
59 
60 //--------------------------------------------------------------------------------
61 
62 #endif // file guard
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
virtual int minimumMessageSize() const =0
Returns the minimum size of a valid message.
virtual MessageLocation findMessage(XsMessage &rcv, const XsByteArray &raw) const =0
Find the first message in the raw byte stream.
Stores the location of a message in a buffer using a start position and a size.
Structure for storing a single message.
Definition: xsmessage.h:138
virtual int type() const =0
Returns the type of the protocol handler.
virtual int maximumMessageSize() const =0
Returns the maximum size of a valid message.
Interface class for protocol handlers.
virtual ~IProtocolHandler()
Destructor.



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019