/src/Fast-DDS/src/cpp/rtps/messages/RTPSMessageGroup_t.hpp
Line | Count | Source |
1 | | // Copyright 2019 Proyectos y Sistemas de Mantenimiento SL (eProsima). |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | /** |
16 | | * @file RTPSMessageGroup_t.hpp |
17 | | */ |
18 | | |
19 | | #ifndef RTPS_MESSAGES_RTPSMESSAGEGROUP_T_HPP |
20 | | #define RTPS_MESSAGES_RTPSMESSAGEGROUP_T_HPP |
21 | | |
22 | | #ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
23 | | |
24 | | #include <fastdds/rtps/common/CDRMessage_t.hpp> |
25 | | #include <rtps/messages/CDRMessage.hpp> |
26 | | #include <rtps/messages/RTPSMessageCreator.hpp> |
27 | | #include <fastdds/rtps/transport/NetworkBuffer.hpp> |
28 | | #include <fastdds/utils/collections/ResourceLimitedVector.hpp> |
29 | | |
30 | | namespace eprosima { |
31 | | namespace fastdds { |
32 | | namespace rtps { |
33 | | |
34 | | /** |
35 | | * Class RTPSMessageGroup_t that contains the messages used to send multiples changes as one message. |
36 | | * @ingroup WRITER_MODULE |
37 | | */ |
38 | | class RTPSMessageGroup_t |
39 | | { |
40 | | public: |
41 | | |
42 | | RTPSMessageGroup_t( |
43 | | #if HAVE_SECURITY |
44 | | bool has_security, |
45 | | #endif // if HAVE_SECURITY |
46 | | uint32_t payload, |
47 | | const GuidPrefix_t& participant_guid) |
48 | 0 | : rtpsmsg_submessage_(0u) |
49 | 0 | , rtpsmsg_fullmsg_(0u) |
50 | | #if HAVE_SECURITY |
51 | | , rtpsmsg_encrypt_(0u) |
52 | | #endif // if HAVE_SECURITY |
53 | 0 | , buffers_(ResourceLimitedContainerConfig(16, std::numeric_limits<size_t>::max dummy_avoid_winmax (), 16)) |
54 | 0 | , payloads_(ResourceLimitedContainerConfig(16, std::numeric_limits<size_t>::max dummy_avoid_winmax (), 16)) |
55 | 0 | { |
56 | 0 | rtpsmsg_fullmsg_.reserve(payload); |
57 | 0 | rtpsmsg_submessage_.reserve(payload); |
58 | |
|
59 | | #if HAVE_SECURITY |
60 | | if (has_security) |
61 | | { |
62 | | rtpsmsg_encrypt_.reserve(payload); |
63 | | } |
64 | | #endif // if HAVE_SECURITY |
65 | |
|
66 | 0 | init(participant_guid); |
67 | 0 | } |
68 | | |
69 | | RTPSMessageGroup_t( |
70 | | octet* buffer_ptr, |
71 | | #if HAVE_SECURITY |
72 | | bool has_security, |
73 | | #endif // if HAVE_SECURITY |
74 | | uint32_t payload, |
75 | | const GuidPrefix_t& participant_guid, |
76 | | ResourceLimitedContainerConfig nb_config) |
77 | 0 | : rtpsmsg_submessage_(0u) |
78 | 0 | , rtpsmsg_fullmsg_(0u) |
79 | | #if HAVE_SECURITY |
80 | | , rtpsmsg_encrypt_(0u) |
81 | | #endif // if HAVE_SECURITY |
82 | 0 | , buffers_(nb_config) |
83 | 0 | , payloads_(nb_config) |
84 | 0 | { |
85 | 0 | rtpsmsg_fullmsg_.init(buffer_ptr, payload); |
86 | 0 | buffer_ptr += payload; |
87 | 0 | rtpsmsg_submessage_.init(buffer_ptr, payload); |
88 | |
|
89 | | #if HAVE_SECURITY |
90 | | if (has_security) |
91 | | { |
92 | | buffer_ptr += payload; |
93 | | rtpsmsg_encrypt_.init(buffer_ptr, payload); |
94 | | } |
95 | | #endif // if HAVE_SECURITY |
96 | |
|
97 | 0 | init(participant_guid); |
98 | 0 | } |
99 | | |
100 | | inline void init( |
101 | | const GuidPrefix_t& participant_guid) |
102 | 0 | { |
103 | 0 | CDRMessage::initCDRMsg(&rtpsmsg_fullmsg_); |
104 | 0 | RTPSMessageCreator::addHeader(&rtpsmsg_fullmsg_, participant_guid); |
105 | 0 | } |
106 | | |
107 | | CDRMessage_t rtpsmsg_submessage_; |
108 | | |
109 | | CDRMessage_t rtpsmsg_fullmsg_; |
110 | | |
111 | | #if HAVE_SECURITY |
112 | | CDRMessage_t rtpsmsg_encrypt_; |
113 | | #endif // if HAVE_SECURITY |
114 | | |
115 | | //! Vector to store the NetworkBuffers that will be used to form the RTPS message. |
116 | | eprosima::fastdds::ResourceLimitedVector<eprosima::fastdds::rtps::NetworkBuffer> buffers_; |
117 | | |
118 | | //! Mirror vector of buffers_ to store the serialized payloads. |
119 | | eprosima::fastdds::ResourceLimitedVector<eprosima::fastdds::rtps::SerializedPayload_t> payloads_; |
120 | | }; |
121 | | |
122 | | } // namespace rtps |
123 | | } // namespace fastdds |
124 | | } // namespace eprosima |
125 | | |
126 | | #endif // DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
127 | | |
128 | | #endif // RTPS_MESSAGES_RTPSMESSAGEGROUP_T_HPP |
129 | | |