replyobject.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 REPLYOBJECT_H
66 #define REPLYOBJECT_H
67 
68 #include <xstypes/xsmessage.h>
69 #include <xstypes/xsdeviceid.h>
70 
71 namespace xsens
72 {
73 class ReplyMonitor;
74 class Mutex;
75 class WaitCondition;
76 }
77 
82 {
83 public:
84  explicit ReplyObject();
85  virtual ~ReplyObject();
86 
87  void setMessage(const XsMessage& msg);
88  XsMessage message(uint32_t timeout);
89 
93  virtual bool isReplyFor(XsMessage const& message) = 0;
94 
96  virtual uint8_t msgId() const = 0;
97 
98 private:
103 };
104 
109 {
110 public:
111  MidReplyObject(uint8_t messageId);
112  ~MidReplyObject(void);
113 
114  virtual bool isReplyFor(XsMessage const& message);
115  virtual uint8_t msgId() const;
116 private:
117  uint8_t m_messageId;
118 };
119 
124 {
125 public:
126  MidAndDataReplyObject(uint8_t messageId, XsSize offset, XsSize size, uint8_t const* data);
128  void setData(uint8_t const* data);
129  virtual bool isReplyFor(XsMessage const& message);
130  virtual uint8_t msgId() const;
131 private:
132  void freeData();
133  uint8_t m_messageId;
136  uint8_t* m_data;
137 };
138 
139 #endif
140 
ReplyObject::m_mutex
xsens::Mutex * m_mutex
Definition: replyobject.h:99
ReplyObject
Abstract reply object. Blocks on a semaphore when requesting the message until the message has been s...
Definition: replyobject.h:81
msg
msg
MidAndDataReplyObject::isReplyFor
virtual bool isReplyFor(XsMessage const &message)
Definition: replyobject.cpp:196
ReplyObject::message
XsMessage message(uint32_t timeout)
Blocks until a message has been set by setMessage() then returns that message.
Definition: replyobject.cpp:105
MidAndDataReplyObject::~MidAndDataReplyObject
~MidAndDataReplyObject()
MidAndDataReplyObject destructor.
Definition: replyobject.cpp:174
ReplyObject::~ReplyObject
virtual ~ReplyObject()
Definition: replyobject.cpp:80
MidAndDataReplyObject::setData
void setData(uint8_t const *data)
Copies data from 'data' into this object. This is the data to wait for.
Definition: replyobject.cpp:219
data
data
MidAndDataReplyObject::freeData
void freeData()
Frees allocated data (if any)
Definition: replyobject.cpp:207
ReplyObject::m_message
XsMessage m_message
Definition: replyobject.h:101
MidReplyObject::MidReplyObject
MidReplyObject(uint8_t messageId)
MidReplyObject constructor.
Definition: replyobject.cpp:120
MidAndDataReplyObject::m_dataOffset
XsSize m_dataOffset
Definition: replyobject.h:134
MidAndDataReplyObject::MidAndDataReplyObject
MidAndDataReplyObject(uint8_t messageId, XsSize offset, XsSize size, uint8_t const *data)
MidAndDataReplyObject constructor.
Definition: replyobject.cpp:161
MidReplyObject::m_messageId
uint8_t m_messageId
Definition: replyobject.h:117
uint32_t
unsigned int uint32_t
Definition: pstdint.h:485
MidAndDataReplyObject::msgId
virtual uint8_t msgId() const
Definition: replyobject.cpp:188
ReplyObject::ReplyObject
ReplyObject()
Default constructor.
Definition: replyobject.cpp:73
xsens::Mutex
A base mutex class.
Definition: xsens_mutex.h:132
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:74
ReplyObject::msgId
virtual uint8_t msgId() const =0
xsdeviceid.h
XsMessage
Structure for storing a single message.
Definition: xsmessage.h:202
ReplyObject::m_delivered
bool m_delivered
Definition: replyobject.h:102
ReplyObject::m_waitCondition
xsens::WaitCondition * m_waitCondition
Definition: replyobject.h:100
MidAndDataReplyObject::m_dataSize
XsSize m_dataSize
Definition: replyobject.h:135
MidAndDataReplyObject
Reply object that checks the message identifier and data in the data field.
Definition: replyobject.h:123
xsmessage.h
MidReplyObject
Reply object that only checks the message identifier.
Definition: replyobject.h:108
MidReplyObject::isReplyFor
virtual bool isReplyFor(XsMessage const &message)
Definition: replyobject.cpp:142
ReplyObject::isReplyFor
virtual bool isReplyFor(XsMessage const &message)=0
MidAndDataReplyObject::m_messageId
uint8_t m_messageId
Definition: replyobject.h:133
ReplyObject::setMessage
void setMessage(const XsMessage &msg)
Sets a message as reply message and trigger the semaphore which will unblock any waiting message() ca...
Definition: replyobject.cpp:94
MidAndDataReplyObject::m_data
uint8_t * m_data
Definition: replyobject.h:136
MidReplyObject::msgId
virtual uint8_t msgId() const
Definition: replyobject.cpp:134
xsens::WaitCondition
A platform independent wait condition implementation.
Definition: xsens_mutex.h:1806
xsens
Definition: threading.cpp:78
MidReplyObject::~MidReplyObject
~MidReplyObject(void)
MidReplyObject destructor.
Definition: replyobject.cpp:128


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