Skip to content

Commit e25f691

Browse files
committed
Review changes. Added descriptions to classes. MInor fixes
1 parent 49489ea commit e25f691

File tree

6 files changed

+57
-9
lines changed

6 files changed

+57
-9
lines changed

examples/routing_service/udp_socket_adapter_dynamic/RsSocketAdapter.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414
<routing_service name="SocketAdapterToDDS">
1515
<domain_route name="SocketBridge">
1616
<connection name="SocketConnection" plugin_name="AdapterLib::SocketAdapter">
17-
<register_type name="PingType" type_ref="PingType" />
1817
</connection>
1918
<participant name="DDSConnection">
2019
<domain_id>1</domain_id>
2120
<domain_participant_qos base_name="BuiltinQosLib::Generic.Common" />
22-
<register_type name="PingType" type_ref="PingType" />
2321
</participant>
2422
<session name="session">
2523
<route>

examples/routing_service/udp_socket_adapter_dynamic/src/SocketStreamReader.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void SocketStreamReader::take(
9999
std::vector<dds::core::xtypes::DynamicData *> &samples,
100100
std::vector<dds::sub::SampleInfo *> &infos)
101101
{
102-
std::vector<char> buffer;
102+
take_buffer_.clear();
103103
{
104104
std::unique_lock<std::mutex> lock(buffer_mutex_);
105105
if (received_buffers_.empty()) {
@@ -108,12 +108,12 @@ void SocketStreamReader::take(
108108
infos.clear();
109109
return;
110110
}
111-
buffer = std::move(received_buffers_.front());
111+
take_buffer_ = std::move(received_buffers_.front());
112112
received_buffers_.pop();
113113
}
114114

115115
dds::core::xtypes::DynamicData deserialized_sample(*adapter_type_);
116-
rti::core::xtypes::from_cdr_buffer(deserialized_sample, buffer);
116+
rti::core::xtypes::from_cdr_buffer(deserialized_sample, take_buffer_);
117117

118118
samples.resize(1);
119119
infos.resize(1);

examples/routing_service/udp_socket_adapter_dynamic/src/SocketStreamReader.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@
2828
#define RECEIVE_ADDRESS_STRING "receive_address"
2929
#define RECEIVE_PORT_STRING "receive_port"
3030

31+
/**
32+
* @brief StreamReader implementation for UDP socket input in RTI Routing Service.
33+
*
34+
* SocketStreamReader is a specific implementation of rti::routing::adapter::DynamicDataStreamReader
35+
* that receives data from a UDP socket and makes it available to RTI Routing Service as DynamicData samples.
36+
*
37+
* This class manages a background thread to continuously read UDP packets from a specified address and port,
38+
* buffering received data for consumption by the Routing Service. It supports thread-safe queuing of incoming
39+
* data, loaning and returning DynamicData samples, and clean shutdown of the reading thread.
40+
*
41+
*/
42+
3143
class SocketStreamReader : public rti::routing::adapter::DynamicDataStreamReader {
3244
public:
3345
SocketStreamReader(
@@ -69,6 +81,7 @@ class SocketStreamReader : public rti::routing::adapter::DynamicDataStreamReader
6981
char received_buffer_[BUFFER_MAX_SIZE];
7082
std::queue<std::vector<char>> received_buffers_;
7183
std::mutex buffer_mutex_;
84+
std::vector<char> take_buffer_;
7285

7386
rti::routing::StreamInfo stream_info_;
7487
dds::core::xtypes::DynamicType *adapter_type_;

examples/routing_service/udp_socket_adapter_dynamic/src/SocketStreamWriter.hpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
#define DEST_ADDRESS_STRING "dest_address"
3131
#define DEST_PORT_STRING "dest_port"
3232

33+
/**
34+
* @brief StreamWriter implementation for UDP socket output in RTI Routing Service.
35+
*
36+
* SocketStreamWriter is a specific implementation of rti::routing::adapter::DynamicDataStreamWriter
37+
* that sends data to a UDP socket, making it available for external consumers outside DDS.
38+
*
39+
* This class is responsible for serializing DynamicData samples received from Routing Service
40+
* and transmitting them as UDP packets to a specified destination address and port.
41+
* It manages socket creation, serialization buffers, and the configuration of destination
42+
* parameters via properties.
43+
*
44+
*/
45+
3346
class SocketStreamWriter : public rti::routing::adapter::DynamicDataStreamWriter {
3447
public:
3548
explicit SocketStreamWriter(
@@ -46,10 +59,6 @@ class SocketStreamWriter : public rti::routing::adapter::DynamicDataStreamWriter
4659

4760

4861
private:
49-
/**
50-
* @brief Function used by socketreader_thread_ to read samples from the
51-
* socket.
52-
*/
5362

5463
SocketConnection *socket_connection_;
5564
std::vector<char> serialization_buffer_;

examples/routing_service/udp_socket_adapter_dynamic/src/UdpSocket.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@
3131
#pragma comment(lib, "ws2_32.lib")
3232
#endif
3333

34+
/**
35+
* @brief Utility class for UDP socket communication in the RTI Routing Service UDP Socket Adapter.
36+
*
37+
* UdpSocket provides a lightweight abstraction for UDP socket communication,
38+
* supporting both Windows and POSIX systems. It is designed to be used by the Routing Service
39+
* UDP socket adapter to send and receive raw UDP packets as part of data bridging between
40+
* external UDP sources and DDS.
41+
*
42+
* The class handles socket creation, binding to a specified IP address and port, and
43+
* ensures non-blocking operation for efficient integration with multi-threaded applications.
44+
* It provides methods for receiving data from any UDP client and for sending data to a
45+
* specified destination address and port.
46+
*/
47+
3448
class UdpSocket {
3549
public:
3650
UdpSocket(const char* ip, int port);

examples/routing_service/udp_socket_adapter_typed/src/UdpSocket.hpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,20 @@
3131
#pragma comment(lib, "ws2_32.lib")
3232
#endif
3333

34+
/**
35+
* @brief Utility class for UDP socket communication in the RTI Routing Service UDP Socket Adapter.
36+
*
37+
* UdpSocket provides a lightweight abstraction for UDP socket communication,
38+
* supporting both Windows and POSIX systems. It is designed to be used by the Routing Service
39+
* UDP socket adapter to send and receive raw UDP packets as part of data bridging between
40+
* external UDP sources and DDS.
41+
*
42+
* The class handles socket creation, binding to a specified IP address and port, and
43+
* ensures non-blocking operation for efficient integration with multi-threaded applications.
44+
* It provides methods for receiving data from any UDP client and for sending data to a
45+
* specified destination address and port.
46+
*/
47+
3448
class UdpSocket {
3549
public:
3650
UdpSocket(const char* ip, int port);

0 commit comments

Comments
 (0)