Coverage Report

Created: 2022-08-24 06:19

/src/Fast-DDS/include/fastdds/rtps/messages/RTPSMessageCreator.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2016 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 RTPSMessageCreator.h
17
 */
18
#ifndef _FASTDDS_RTPS_CDRMESSAGECREATOR_H_
19
#define _FASTDDS_RTPS_CDRMESSAGECREATOR_H_
20
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
21
22
#include <fastdds/rtps/common/CDRMessage_t.h>
23
#include <fastdds/rtps/common/Guid.h>
24
#include <fastdds/rtps/common/SequenceNumber.h>
25
#include <fastdds/rtps/common/FragmentNumber.h>
26
#include <fastdds/rtps/common/CacheChange.h>
27
28
namespace eprosima {
29
namespace fastrtps {
30
namespace rtps {
31
32
//!An interface to add inline qos parameters to a CDRMessage
33
class InlineQosWriter
34
{
35
public:
36
37
0
    virtual ~InlineQosWriter() = default;
38
39
    /**
40
     * Writes inline QOS parameters to a CDRMessage.
41
     * @param msg Pointer to the message.
42
     * @return true if writing was successful, false otherwise.
43
     */
44
    virtual bool writeQosToCDRMessage(
45
            CDRMessage_t* msg) = 0;
46
};
47
48
/**
49
 * @brief Class RTPSMessageCreator, allows the generation of serialized CDR RTPS Messages.
50
 * @ingroup MANAGEMENT_MODULE
51
 */
52
class RTPSMessageCreator
53
{
54
public:
55
56
    RTPSMessageCreator() = delete;
57
    ~RTPSMessageCreator() = delete;
58
59
    /**
60
     * Create a Header to the serialized message.
61
     * @param msg Pointer to the Message.
62
     * @param Prefix RTPSParticipant prefix of the message.
63
     * @param version Protocol version.
64
     * @param vendorId Vendor Id.
65
     * @return True if correct.
66
     */
67
    static bool addHeader(
68
            CDRMessage_t* msg,
69
            const GuidPrefix_t& Prefix,
70
            const ProtocolVersion_t& version,
71
            const VendorId_t& vendorId);
72
73
    /**
74
     * Create a Header to the serialized message.
75
     * @param msg Pointer to the Message.
76
     * @param Prefix RTPSParticipant prefix of the message.
77
     * @return True if correct.
78
     */
79
    static bool addHeader(
80
            CDRMessage_t* msg,
81
            const GuidPrefix_t& Prefix);
82
83
    /**
84
     * Add a custom content to the serialized message.
85
     * @param msg Pointer to the Message.
86
     * @param content content to create.
87
     * @param contentSize size of the content.
88
     * @return True if correct.
89
     */
90
    static bool addCustomContent(
91
            CDRMessage_t* msg,
92
            const octet* content,
93
            const size_t contentSize);
94
    /**
95
     * Create SubmessageHeader.
96
     * @param msg Pointer to the CDRMessage.
97
     * @param id SubMessage Id.
98
     * @param flags Submessage flags.
99
     * @param size Submessage size.
100
     * @return True if correct.
101
     */
102
    static bool addSubmessageHeader(
103
            CDRMessage_t* msg,
104
            octet id,
105
            octet flags,
106
            uint16_t size);
107
108
109
    /** @name CDR messages creation methods.
110
     * These methods create a CDR message for different types
111
     * Depending on the function a complete message (with RTPS Header is created) or only the submessage.
112
     * @param[out] msg Pointer to where the message is going to be created and stored.
113
     * @param[in] guidPrefix Guid Prefix of the RTPSParticipant.
114
     * @param[in] param Different parameters depending on the message.
115
     * @return True if correct.
116
     */
117
118
    /// @{
119
120
    static bool addMessageData(
121
            CDRMessage_t* msg,
122
            GuidPrefix_t& guidprefix,
123
            const CacheChange_t* change,
124
            TopicKind_t topicKind,
125
            const EntityId_t& readerId,
126
            bool expectsInlineQos,
127
            InlineQosWriter* inlineQos);
128
129
    static bool addSubmessageData(
130
            CDRMessage_t* msg,
131
            const CacheChange_t* change,
132
            TopicKind_t topicKind,
133
            const EntityId_t& readerId,
134
            bool expectsInlineQos,
135
            InlineQosWriter* inlineQos,
136
            bool* is_big_submessage);
137
138
    static bool addMessageDataFrag(
139
            CDRMessage_t* msg,
140
            GuidPrefix_t& guidprefix,
141
            const CacheChange_t* change,
142
            uint32_t fragment_number,
143
            TopicKind_t topicKind,
144
            const EntityId_t& readerId,
145
            bool expectsInlineQos,
146
            InlineQosWriter* inlineQos);
147
    static bool addSubmessageDataFrag(
148
            CDRMessage_t* msg,
149
            const CacheChange_t* change,
150
            uint32_t fragment_number,
151
            const SerializedPayload_t& data,
152
            TopicKind_t topicKind,
153
            const EntityId_t& readerId,
154
            bool expectsInlineQos,
155
            InlineQosWriter* inlineQos);
156
157
    static bool addMessageGap(
158
            CDRMessage_t* msg,
159
            const GuidPrefix_t& guidprefix,
160
            const GuidPrefix_t& remoteGuidPrefix,
161
            const SequenceNumber_t& seqNumFirst,
162
            const SequenceNumberSet_t& seqNumList,
163
            const EntityId_t& readerId,
164
            const EntityId_t& writerId);
165
    static bool addSubmessageGap(
166
            CDRMessage_t* msg,
167
            const SequenceNumber_t& seqNumFirst,
168
            const SequenceNumberSet_t& seqNumList,
169
            const EntityId_t& readerId,
170
            const EntityId_t& writerId);
171
172
    static bool addMessageHeartbeat(
173
            CDRMessage_t* msg,
174
            const GuidPrefix_t& guidprefix,
175
            const EntityId_t& readerId,
176
            const EntityId_t& writerId,
177
            const SequenceNumber_t& firstSN,
178
            const SequenceNumber_t& lastSN,
179
            Count_t count,
180
            bool isFinal,
181
            bool livelinessFlag);
182
    static bool addMessageHeartbeat(
183
            CDRMessage_t* msg,
184
            const GuidPrefix_t& guidprefix,
185
            const GuidPrefix_t& remoteGuidprefix,
186
            const EntityId_t& readerId,
187
            const EntityId_t& writerId,
188
            const SequenceNumber_t& firstSN,
189
            const SequenceNumber_t& lastSN,
190
            Count_t count,
191
            bool isFinal,
192
            bool livelinessFlag);
193
    static bool addSubmessageHeartbeat(
194
            CDRMessage_t* msg,
195
            const EntityId_t& readerId,
196
            const EntityId_t& writerId,
197
            const SequenceNumber_t& firstSN,
198
            const SequenceNumber_t& lastSN,
199
            Count_t count,
200
            bool isFinal,
201
            bool livelinessFlag);
202
203
    static bool addMessageHeartbeatFrag(
204
            CDRMessage_t* msg,
205
            const GuidPrefix_t& guidprefix,
206
            const EntityId_t& readerId,
207
            const EntityId_t& writerId,
208
            SequenceNumber_t& firstSN,
209
            FragmentNumber_t& lastFN,
210
            Count_t count);
211
    static bool addSubmessageHeartbeatFrag(
212
            CDRMessage_t* msg,
213
            const EntityId_t& readerId,
214
            const EntityId_t& writerId,
215
            SequenceNumber_t& firstSN,
216
            FragmentNumber_t& lastFN,
217
            Count_t count);
218
219
    static bool addMessageAcknack(
220
            CDRMessage_t* msg,
221
            const GuidPrefix_t& guidprefix,
222
            const GuidPrefix_t& remoteGuidPrefix,
223
            const EntityId_t& readerId,
224
            const EntityId_t& writerId,
225
            const SequenceNumberSet_t& SNSet,
226
            int32_t count,
227
            bool finalFlag);
228
    static bool addSubmessageAcknack(
229
            CDRMessage_t* msg,
230
            const EntityId_t& readerId,
231
            const EntityId_t& writerId,
232
            const SequenceNumberSet_t& SNSet,
233
            int32_t count,
234
            bool finalFlag);
235
236
    static bool addMessageNackFrag(
237
            CDRMessage_t* msg,
238
            const GuidPrefix_t& guidprefix,
239
            const GuidPrefix_t& remoteGuidPrefix,
240
            const EntityId_t& readerId,
241
            const EntityId_t& writerId,
242
            SequenceNumber_t& writerSN,
243
            FragmentNumberSet_t fnState,
244
            int32_t count);
245
    static bool addSubmessageNackFrag(
246
            CDRMessage_t* msg,
247
            const EntityId_t& readerId,
248
            const EntityId_t& writerId,
249
            const SequenceNumber_t& writerSN,
250
            FragmentNumberSet_t fnState,
251
            int32_t count);
252
253
    static bool addSubmessageInfoTS(
254
            CDRMessage_t* msg,
255
            const Time_t& time,
256
            bool invalidateFlag);
257
    static bool addSubmessageInfoTS_Now(
258
            CDRMessage_t* msg,
259
            bool invalidateFlag);
260
261
    static bool addSubmessageInfoSRC(
262
            CDRMessage_t* msg,
263
            const ProtocolVersion_t& version,
264
            const VendorId_t& vendorId,
265
            const GuidPrefix_t& guidP);
266
    static bool addSubmessageInfoDST(
267
            CDRMessage_t* msg,
268
            const GuidPrefix_t& guidP);
269
};
270
} // namespace rtps
271
} /* namespace rtps */
272
} /* namespace eprosima */
273
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
274
#endif /* _FASTDDS_RTPS_CDRMESSAGECREATOR_H_ */