Galaxis Codebase  1.0.0
Team Galaxis software stack for the Carolo Cup 2023 - ROS2 based software
ICommunication.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstddef>
4 
6 protected:
7  bool m_connected;
8 
9 public:
10  /*
11  * important to declare this, or otherwise pointer to base class could
12  * potentially lead to undefined behavior, if we do not declare the
13  * destructor as virtual
14  */
15  virtual ~ICommunication() {}
16 
17  /*
18  * Code that is used to prepare the communication
19  * like setting baud rate, selecting a proper
20  * port etc. is happening in the initialization
21  */
22  virtual void VInitialize(){};
23 
24  /*
25  * Establish connection with peer
26  * using the current communication protocol
27  */
28  virtual void VConnect() = 0;
29 
30  /*
31  * Stops the communication with the current
32  * communication protocol and clears
33  * the used buffers
34  */
35  virtual void VDisconnect() = 0;
36 
37  /*
38  * Transfer the given data using the
39  * current communication protocol
40  */
41  virtual size_t VSendData(void*, const size_t) = 0;
42 
43  /*
44  * Reads from the device and provides the data read
45  */
46  virtual size_t VReceiveData(void*, const size_t) = 0;
47 
48  /*
49  * Returns true when the current communication
50  * has been established successfully
51  */
52  bool IsConnected() const {
53  return m_connected;
54  }
55 };
56 /*vim:set et sw=2 ts=2 tw=80:*/
ICommunication::IsConnected
bool IsConnected() const
Definition: ICommunication.h:52
ICommunication::VDisconnect
virtual void VDisconnect()=0
ICommunication::VInitialize
virtual void VInitialize()
Definition: ICommunication.h:22
ICommunication::~ICommunication
virtual ~ICommunication()
Definition: ICommunication.h:15
ICommunication::VReceiveData
virtual size_t VReceiveData(void *, const size_t)=0
ICommunication
Definition: ICommunication.h:5
ICommunication::m_connected
bool m_connected
Definition: ICommunication.h:7
ICommunication::VSendData
virtual size_t VSendData(void *, const size_t)=0
ICommunication::VConnect
virtual void VConnect()=0