Class NetworkInterface
Defined in File network_interface_base.hpp
Inheritance Relationships
Derived Types
public network_bridge::TcpInterface
(Class TcpInterface)public network_bridge::UdpInterface
(Class UdpInterface)
Class Documentation
-
class NetworkInterface
Abstract base class for network interfaces.
This class defines the interface for network communication. It provides methods for opening and closing the connection, writing data, and setting a receive callback function.
Subclassed by network_bridge::TcpInterface, network_bridge::UdpInterface
Public Functions
-
inline NetworkInterface()
Constructor for NetworkInterface.
-
virtual ~NetworkInterface() = default
Virtual destructor for NetworkInterface.
Initializes the network interface.
This function sets the node and receive callback for the network interface, and then calls the protected
initialize_
function to perform any additional initialization steps for a specific implementation.- Parameters:
node – A shared pointer to the ROS 2 node.
recv_cb – The callback function to be called when data is received.
-
virtual void open() = 0
Opens the network connection.
This method should be implemented by derived classes to establish the network connection. Should handle all network setup, including sockets, starting threads, etc
-
virtual void close() = 0
Closes the network connection.
This method should be implemented by derived classes to close the network connection. Cleanly stop threads, close sockets, etc.
-
virtual void write(const std::vector<uint8_t> &data) = 0
Writes data to the network.
This method should be implemented by derived classes to send data over the network.
- Parameters:
data – The data to be written.
Protected Functions
-
virtual void initialize_() = 0
Initializes the network interface.
This function is pure virtual and must be implemented by derived classes. Should declare and load all parameters, such as IP addresses, ports, etc.
-
inline NetworkInterface()