A class for the data parsing on a separete thread. More...
#include <dataparser.h>
Public Member Functions | |
void | addRawData (const XsByteArray &arr) |
Adds the raw data to an array. More... | |
void | clear () |
Clears the data queue. More... | |
DataParser () | |
Default constructor. More... | |
virtual void | handleMessage (const XsMessage &message)=0 |
Handles a message. More... | |
virtual const char * | parserType () const |
virtual XsResultValue | processBufferedData (const XsByteArray &rawIn, std::deque< XsMessage > &messages)=0 |
Read all messages from the buffered read data after adding new data supplied in rawIn. More... | |
virtual XsResultValue | readDataToBuffer (XsByteArray &raw)=0 |
Read available data from the open IO device. More... | |
void | terminate () |
Terminates the thread. More... | |
~DataParser () override | |
Protected Member Functions | |
void | initFunction () override |
Initializes the thread. More... | |
int32_t | innerFunction () override |
The inner thread function. More... | |
void | signalStopThread (void) override |
Tells the thread to stop but does not wait for it to end. More... | |
![]() | |
virtual void | exitFunction (void) |
Virtual exit function. More... | |
XsThread | threadHandle () const |
Return the thread handle. More... | |
XsThreadId | getThreadId (void) const |
bool | isAlive (void) volatile const noexcept |
bool | isRunning (void) volatile const noexcept |
Returns whether the thread is currently running. More... | |
bool | isTerminating () volatile const noexcept |
Returns whether the thread should (have) terminate(d) More... | |
bool | setPriority (XsThreadPriority pri) |
Sets the priority of the thread. More... | |
StandardThread () | |
bool | startThread (const char *name=NULL) |
Starts the thread. More... | |
void | stopThread (void) noexcept |
Tells the thread to stop and waits for it to end. More... | |
virtual | ~StandardThread () |
Private Attributes | |
std::queue< XsByteArray > | m_incoming |
xsens::Mutex | m_incomingMutex |
xsens::WaitEvent | m_newDataEvent |
char | m_parserType [128] |
Additional Inherited Members | |
![]() | |
pthread_attr_t | m_attr |
Duplicates m_stop functionality for external dependent classes such as Semaphore. More... | |
bool | m_running |
Indicates that the thread is running. More... | |
volatile std::atomic_bool | m_stop |
Indicates that the thread should stop. Derived classes should check isTerminating() instead of directly polling this value when checking if the thread should stop. However, there are some cases (tests, SignallingThread) where direct access from within the class is desired, which is why the vlaue is protected instead of private. More... | |
volatile std::atomic_bool | m_yieldOnZeroSleep |
When true, a sleep value of 0 returned by innerFunction will trigger a thread yield operation. When false, the next cycle is started immediately. More... | |
A class for the data parsing on a separete thread.
Definition at line 76 of file dataparser.h.
DataParser::DataParser | ( | ) |
Default constructor.
Definition at line 76 of file dataparser.cpp.
|
override |
Definition at line 81 of file dataparser.cpp.
void DataParser::addRawData | ( | const XsByteArray & | arr | ) |
Adds the raw data to an array.
arr | The reference to a byte array to which the data will be added |
Definition at line 95 of file dataparser.cpp.
void DataParser::clear | ( | ) |
Clears the data queue.
Definition at line 160 of file dataparser.cpp.
|
pure virtual |
Handles a message.
Implemented in SerialCommunicator, and ProxyCommunicator.
|
overrideprotectedvirtual |
Initializes the thread.
Reimplemented from xsens::StandardThread.
Definition at line 150 of file dataparser.cpp.
|
overrideprotectedvirtual |
The inner thread function.
Reimplemented from xsens::StandardThread.
Definition at line 105 of file dataparser.cpp.
|
inlinevirtual |
Definition at line 103 of file dataparser.h.
|
pure virtual |
Read all messages from the buffered read data after adding new data supplied in rawIn.
rawIn | The byte array with all data |
messages | The message to process |
Implemented in SerialCommunicator, and ProxyCommunicator.
|
pure virtual |
Read available data from the open IO device.
raw | A buffer that will receive the read data. |
Implemented in SerialCommunicator, and ProxyCommunicator.
|
overrideprotectedvirtual |
Tells the thread to stop but does not wait for it to end.
Reimplemented from xsens::StandardThread.
Definition at line 168 of file dataparser.cpp.
void DataParser::terminate | ( | ) |
Terminates the thread.
Definition at line 176 of file dataparser.cpp.
|
private |
Definition at line 115 of file dataparser.h.
|
private |
Definition at line 114 of file dataparser.h.
|
private |
Definition at line 116 of file dataparser.h.
|
private |
Definition at line 117 of file dataparser.h.