Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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
19  protocol handlers are
20  used to convert a binary data stream into XsMessage objects.
21 */
23 {
24  public:
25  //! \brief Destructor
26  virtual ~IProtocolHandler() {}
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
29  convert into an
30  %XsMessage object. It returns the location and total byte size of the
31  message so that the
32  caller can remove those bytes from the stream. The return value can also
33  describe that a
34  partial message has been found. Return values:
35  \li \a startpos >= 0 and \a size > 0: A full message with \a size has
36  been found at \a startpos.
37  \li \a startpos >= 0 and \a size == 0: The start of a message has been
38  found at \a startpos, but the size could not yet be determined.
39  \li \a startpos >= 0 and \a size < 0: The start of a message has been
40  found at \a startpos, and the size of the full message is at least \a
41  -size.
42  \li \a startpos < 0: No messages have been found.
43 
44  \param rcv If a message is read, it will be put in this object.
45  \param raw The raw byte stream to analyze.
46  \returns A %MessageLocation object that describes what was found.
47  */
49  XsMessage& rcv, const XsByteArray& raw) const = 0;
50  /*! \brief Returns the minimum size of a valid message
51  \details This value may differ for different protocols, but is always at
52  least 1.
53  \returns The minimum size of a valid message for the protocol.
54  */
55  virtual int minimumMessageSize() const = 0;
56  /*! \brief Returns the maximum size of a valid message
57  \details This value may differ for different protocols.
58  \returns The maximum size of a valid message for the protocol.
59  */
60  virtual int maximumMessageSize() const = 0;
61  /*! \brief Returns the type of the protocol handler
62  \details Each protocol handler has a locally unique id that can be used
63  for instantiation of
64  the correct protocol handler.
65  \returns The type id of the protocol handler.
66  */
67  virtual int type() const = 0;
68 };
69 
70 //--------------------------------------------------------------------------------
71 
72 #endif // file guard
XsByteArray
struct XsByteArray XsByteArray
Definition: xsbytearray.h:25
IProtocolHandler::maximumMessageSize
virtual int maximumMessageSize() const =0
Returns the maximum size of a valid message.
messagelocation.h
IProtocolHandler
Interface class for protocol handlers.
Definition: iprotocolhandler.h:22
IProtocolHandler::type
virtual int type() const =0
Returns the type of the protocol handler.
IProtocolHandler::~IProtocolHandler
virtual ~IProtocolHandler()
Destructor.
Definition: iprotocolhandler.h:26
MessageLocation
Stores the location of a message in a buffer using a start position and a size.
Definition: messagelocation.h:15
IProtocolHandler::findMessage
virtual MessageLocation findMessage(XsMessage &rcv, const XsByteArray &raw) const =0
Find the first message in the raw byte stream.
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:198
xsmessage.h
xsbytearray.h
IProtocolHandler::minimumMessageSize
virtual int minimumMessageSize() const =0
Returns the minimum size of a valid message.



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST