/src/Fast-DDS/include/fastrtps/xmlparser/XMLEndpointParser.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 XMLEndpointParser.h |
17 | | * |
18 | | */ |
19 | | |
20 | | #ifndef XMLENDPOINTPARSER_H_ |
21 | | #define 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 <fastdds/rtps/builtin/data/ReaderProxyData.h> |
32 | | #include <fastdds/rtps/builtin/data/WriterProxyData.h> |
33 | | #include <fastrtps/xmlparser/XMLParserCommon.h> |
34 | | #include <fastrtps/xmlparser/XMLParser.h> |
35 | | |
36 | | namespace tinyxml2 { |
37 | | class XMLElement; |
38 | | class XMLDocument; |
39 | | } // namespace tinyxml2 |
40 | | |
41 | | |
42 | | |
43 | | namespace eprosima { |
44 | | namespace fastrtps { |
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 DISCVOERYMODULE |
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 | | * @return True if found. |
130 | | */ |
131 | | XMLP_ret lookforReader( |
132 | | const char* partname, |
133 | | uint16_t id, |
134 | | rtps::ReaderProxyData** rdataptr); |
135 | | /** |
136 | | * Look for a writer in the previously loaded endpoints. |
137 | | * @param[in] partname RTPSParticipant name |
138 | | * @param[in] id Id of the writer |
139 | | * @param[out] wdataptr Pointer to pointer to return the information. |
140 | | * @return True if found |
141 | | */ |
142 | | XMLP_ret lookforWriter( |
143 | | const char* partname, |
144 | | uint16_t id, |
145 | | rtps::WriterProxyData** wdataptr); |
146 | | |
147 | | private: |
148 | | |
149 | | XMLP_ret get_disable_positive_acks_qos( |
150 | | tinyxml2::XMLElement* elem, |
151 | | DisablePositiveACKsQosPolicy& disable_positive_acks_qos); |
152 | | |
153 | | std::set<int16_t> m_endpointIds; |
154 | | std::set<uint32_t> m_entityIds; |
155 | | |
156 | | std::vector<StaticRTPSParticipantInfo*> m_RTPSParticipants; |
157 | | }; |
158 | | |
159 | | |
160 | | } /* xmlparser */ |
161 | | } /* namespace */ |
162 | | } /* namespace eprosima */ |
163 | | |
164 | | #endif // ifndef DOXYGEN_SHOULD_SKIP_THIS_PUBLIC |
165 | | #endif /* XMLENDPOINTPARSER_H_ */ |