Coverage Report

Created: 2026-05-04 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/Fast-DDS/src/cpp/xmlparser/XMLEndpointParser.h
Line
Count
Source
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 XMLEndpointParser.h
17
 *
18
 */
19
20
#ifndef FASTDDS_XMLPARSER__XMLENDPOINTPARSER_H
21
#define FASTDDS_XMLPARSER__XMLENDPOINTPARSER_H
22
#ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
23
24
#include <cstdint>
25
#include <set>
26
#include <string>
27
#include <vector>
28
29
#include <tinyxml2.h>
30
31
#include <rtps/builtin/data/ReaderProxyData.hpp>
32
#include <rtps/builtin/data/WriterProxyData.hpp>
33
#include <xmlparser/XMLParserCommon.h>
34
#include <xmlparser/XMLParser.h>
35
36
namespace tinyxml2 {
37
class XMLElement;
38
class XMLDocument;
39
} // namespace tinyxml2
40
41
42
43
namespace eprosima {
44
namespace fastdds {
45
namespace rtps {
46
class ReaderProxyData;
47
class WriterProxyData;
48
} // namespace rtps
49
50
namespace xmlparser {
51
52
/**
53
 * Class StaticRTPSParticipantInfo, contains the information of writers and readers loaded from the XML file.
54
 *@ingroup DISCOVERY_MODULE
55
 */
56
class StaticRTPSParticipantInfo
57
{
58
public:
59
60
    StaticRTPSParticipantInfo()
61
0
    {
62
0
    }
63
64
    virtual ~StaticRTPSParticipantInfo()
65
0
    {
66
0
    }
67
68
    //!RTPS PArticipant name
69
    std::string m_RTPSParticipantName;
70
    //!Vector of ReaderProxyData pointer
71
    std::vector<rtps::ReaderProxyData*> m_readers;
72
    //!Vector of ReaderProxyData pointer
73
    std::vector<rtps::WriterProxyData*> m_writers;
74
};
75
76
/**
77
 * Class XMLEndpointParser used to parse the XML file that contains information about remote endpoints.
78
 * @ingroup DISCOVERY_MODULE
79
 */
80
class XMLEndpointParser : XMLParser
81
{
82
public:
83
84
    XMLEndpointParser();
85
    virtual ~XMLEndpointParser();
86
    /**
87
     * Load the XML file
88
     * @param filename Name or data of the file to load and parse.
89
     * The string could contain a filename (file://) or the XML content directly (data://), filename assumed if neither
90
     * @return True if correct.
91
     */
92
    XMLP_ret loadXMLFile(
93
            std::string& filename);
94
    /**
95
     * Load the XML node
96
     * @param doc Node to parse.
97
     * @return True if correct.
98
     */
99
    XMLP_ret loadXMLNode(
100
            tinyxml2::XMLDocument& doc);
101
102
    void loadXMLParticipantEndpoint(
103
            tinyxml2::XMLElement* xml_endpoint,
104
            StaticRTPSParticipantInfo* pdata);
105
106
    /**
107
     * Load a Reader endpoint.
108
     * @param xml_endpoint Reference of a tree child for a reader.
109
     * @param pdata Pointer to the RTPSParticipantInfo where the reader must be added.
110
     * @return True if correctly added.
111
     */
112
    XMLP_ret loadXMLReaderEndpoint(
113
            tinyxml2::XMLElement* xml_endpoint,
114
            StaticRTPSParticipantInfo* pdata);
115
    /**
116
     * Load a Writer endpoint.
117
     * @param xml_endpoint Reference of a tree child for a writer.
118
     * @param pdata Pointer to the RTPSParticipantInfo where the reader must be added.
119
     * @return True if correctly added.
120
     */
121
    XMLP_ret loadXMLWriterEndpoint(
122
            tinyxml2::XMLElement* xml_endpoint,
123
            StaticRTPSParticipantInfo* pdata);
124
    /**
125
     * Look for a reader in the previously loaded endpoints.
126
     * @param [in] partname RTPSParticipant name
127
     * @param [in] id Id of the reader
128
     * @param [out] rdataptr Pointer to pointer to return the information.
129
     * @param [out] position Return the position of the reader in the vector of readers.
130
     * @return True if found.
131
     */
132
    XMLP_ret lookforReader(
133
            const char* partname,
134
            uint16_t id,
135
            rtps::ReaderProxyData** rdataptr,
136
            uint32_t& position);
137
    /**
138
     * Look for a writer in the previously loaded endpoints.
139
     * @param [in] partname RTPSParticipant name
140
     * @param [in] id Id of the writer
141
     * @param [out] wdataptr Pointer to pointer to return the information.
142
     * @param [out] position Return the position of the writer in the vector of writers.
143
     * @return True if found
144
     */
145
    XMLP_ret lookforWriter(
146
            const char* partname,
147
            uint16_t id,
148
            rtps::WriterProxyData** wdataptr,
149
            uint32_t& position);
150
151
    /**
152
     * Get a reader from the position in the vector of readers.
153
     * @param[in] participant_name Name of the participant
154
     * @param[in] pos Position in the vector of readers.
155
     * @param[out] rdataptr Pointer to pointer to return the information.
156
     * @return XMLP_ret::XML_OK if found, XMLP_ret::XML_ERROR otherwise.
157
     */
158
    XMLP_ret get_reader_from_position(
159
            const std::string& participant_name,
160
            size_t pos,
161
            rtps::ReaderProxyData** rdataptr);
162
163
    /**
164
     * Get a writer from the position in the vector of writers.
165
     * @param[in] participant_name Name of the participant
166
     * @param[in] pos Position in the vector of writers.
167
     * @param[out] wdataptr Pointer to pointer to return the information.
168
     * @return XMLP_ret::XML_OK if found, XMLP_ret::XML_ERROR otherwise.
169
     */
170
    XMLP_ret get_writer_from_position(
171
            const std::string& participant_name,
172
            size_t pos,
173
            rtps::WriterProxyData** wdataptr);
174
175
    /**
176
     * Get the number of readers for a participant.
177
     * @param[in] participant_name Name of the participant.
178
     * @return Number of readers for the participant.
179
     */
180
    size_t get_number_of_readers(
181
            const std::string& participant_name);
182
183
    /**
184
     * Get the number of writers for a participant.
185
     * @param[in] participant_name Name of the participant.
186
     * @return Number of writers for the participant.
187
     */
188
    size_t get_number_of_writers(
189
            const std::string& participant_name);
190
191
private:
192
193
    XMLP_ret get_disable_positive_acks_qos(
194
            tinyxml2::XMLElement* elem,
195
            dds::DisablePositiveACKsQosPolicy& disable_positive_acks_qos);
196
197
    std::set<int16_t> m_endpointIds;
198
    std::set<uint32_t> m_entityIds;
199
200
    std::vector<StaticRTPSParticipantInfo*> m_RTPSParticipants;
201
};
202
203
204
} // namespace xmlparser
205
} // namespace fastdds
206
} // namespace eprosima
207
208
#endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC
209
#endif // FASTDDS_XMLPARSER__XMLENDPOINTPARSER_H