/src/Fast-DDS/src/cpp/xmlparser/XMLProfileManager.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright 2017 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 | | #include <xmlparser/XMLProfileManager.h> |
16 | | |
17 | | #include <cstdlib> |
18 | | #include <functional> |
19 | | #ifdef _WIN32 |
20 | | #include <windows.h> |
21 | | #else |
22 | | #include <unistd.h> |
23 | | #endif // _WIN32 |
24 | | |
25 | | #include <tinyxml2.h> |
26 | | |
27 | | #include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp> |
28 | | #include <fastdds/dds/log/Log.hpp> |
29 | | |
30 | | #include <xmlparser/XMLTree.h> |
31 | | |
32 | | using namespace eprosima::fastdds; |
33 | | using namespace ::xmlparser; |
34 | | |
35 | | LibrarySettings XMLProfileManager::library_settings_; |
36 | | std::map<std::string, up_participantfactory_t> XMLProfileManager::participant_factory_profiles_; |
37 | | dds::DomainParticipantFactoryQos default_participant_factory_qos; |
38 | | std::map<std::string, up_participant_t> XMLProfileManager::participant_profiles_; |
39 | | ParticipantAttributes default_participant_attributes; |
40 | | std::map<std::string, up_publisher_t> XMLProfileManager::publisher_profiles_; |
41 | | PublisherAttributes default_publisher_attributes; |
42 | | std::map<std::string, up_subscriber_t> XMLProfileManager::subscriber_profiles_; |
43 | | SubscriberAttributes default_subscriber_attributes; |
44 | | std::map<std::string, up_topic_t> XMLProfileManager::topic_profiles_; |
45 | | TopicAttributes default_topic_attributes; |
46 | | std::map<std::string, up_requester_t> XMLProfileManager::requester_profiles_; |
47 | | std::map<std::string, up_replier_t> XMLProfileManager::replier_profiles_; |
48 | | std::map<std::string, XMLP_ret> XMLProfileManager::xml_files_; |
49 | | sp_transport_map_t XMLProfileManager::transport_profiles_; |
50 | | p_dynamictype_map_t XMLProfileManager::dynamic_types_; |
51 | | BaseNode* XMLProfileManager::root = nullptr; |
52 | | |
53 | | template<typename T> |
54 | | struct AttributesTraits; |
55 | | |
56 | | template<> |
57 | | struct AttributesTraits<ParticipantAttributes> |
58 | | { |
59 | | static constexpr NodeType node_type = NodeType::PARTICIPANT; |
60 | | using NodePtrType = p_node_participant_t; |
61 | | using NodeUniquePtrType = up_participant_t; |
62 | | |
63 | | static std::string name() |
64 | 0 | { |
65 | 0 | return "Participant"; |
66 | 0 | } |
67 | | |
68 | | }; |
69 | | |
70 | | template<> |
71 | | struct AttributesTraits<PublisherAttributes> |
72 | | { |
73 | | static constexpr NodeType node_type = NodeType::PUBLISHER; |
74 | | using NodePtrType = p_node_publisher_t; |
75 | | using NodeUniquePtrType = up_publisher_t; |
76 | | |
77 | | static std::string name() |
78 | 0 | { |
79 | 0 | return "Publisher"; |
80 | 0 | } |
81 | | |
82 | | }; |
83 | | |
84 | | template<> |
85 | | struct AttributesTraits<SubscriberAttributes> |
86 | | { |
87 | | static constexpr NodeType node_type = NodeType::SUBSCRIBER; |
88 | | using NodePtrType = p_node_subscriber_t; |
89 | | using NodeUniquePtrType = up_subscriber_t; |
90 | | |
91 | | static std::string name() |
92 | 0 | { |
93 | 0 | return "Subscriber"; |
94 | 0 | } |
95 | | |
96 | | }; |
97 | | |
98 | | template<> |
99 | | struct AttributesTraits<TopicAttributes> |
100 | | { |
101 | | static constexpr NodeType node_type = NodeType::TOPIC; |
102 | | using NodePtrType = p_node_topic_t; |
103 | | using NodeUniquePtrType = up_topic_t; |
104 | | |
105 | | static std::string name() |
106 | 0 | { |
107 | 0 | return "Topic"; |
108 | 0 | } |
109 | | |
110 | | }; |
111 | | |
112 | | template<> |
113 | | struct AttributesTraits<RequesterAttributes> |
114 | | { |
115 | | static constexpr NodeType node_type = NodeType::REQUESTER; |
116 | | using NodePtrType = p_node_requester_t; |
117 | | using NodeUniquePtrType = up_requester_t; |
118 | | |
119 | | static std::string name() |
120 | 0 | { |
121 | 0 | return "Requester"; |
122 | 0 | } |
123 | | |
124 | | }; |
125 | | |
126 | | template<> |
127 | | struct AttributesTraits<ReplierAttributes> |
128 | | { |
129 | | static constexpr NodeType node_type = NodeType::REPLIER; |
130 | | using NodePtrType = p_node_replier_t; |
131 | | using NodeUniquePtrType = up_replier_t; |
132 | | |
133 | | static std::string name() |
134 | 0 | { |
135 | 0 | return "Replier"; |
136 | 0 | } |
137 | | |
138 | | }; |
139 | | |
140 | | template <typename AttributesType> |
141 | | XMLP_ret fill_attributes_from_xml( |
142 | | const std::string& xml, |
143 | | AttributesType& atts, |
144 | | const std::function<bool(typename AttributesTraits<AttributesType>::NodePtrType)>& node_filter, |
145 | | bool fulfill_xsd) |
146 | 0 | { |
147 | 0 | using Traits = AttributesTraits<AttributesType>; |
148 | |
|
149 | 0 | up_base_node_t root_node; |
150 | 0 | XMLP_ret loaded_ret = XMLParser::loadXML(xml.c_str(), xml.size(), root_node); |
151 | |
|
152 | 0 | if (!root_node || loaded_ret != XMLP_ret::XML_OK) |
153 | 0 | { |
154 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing string"); |
155 | 0 | return XMLP_ret::XML_ERROR; |
156 | 0 | } |
157 | | |
158 | | // Process node function |
159 | 0 | auto process_node = [&](const up_base_node_t& node_to_process, AttributesType& atts) |
160 | 0 | { |
161 | | // If node type doesn't match, skip |
162 | 0 | if (Traits::node_type != node_to_process->getType()) |
163 | 0 | { |
164 | 0 | return XMLP_ret::XML_NOK; |
165 | 0 | } |
166 | | |
167 | | // Cast the node to the expected type |
168 | 0 | typename Traits::NodePtrType node = dynamic_cast<typename Traits::NodePtrType>(node_to_process.get()); |
169 | 0 | if (!node) |
170 | 0 | { |
171 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error casting node"); |
172 | 0 | return XMLP_ret::XML_ERROR; |
173 | 0 | } |
174 | | |
175 | | // If node doesn't match the filter, skip |
176 | 0 | if (!node_filter(node)) |
177 | 0 | { |
178 | 0 | return XMLP_ret::XML_NOK; |
179 | 0 | } |
180 | | |
181 | | // Retrieve node data |
182 | 0 | typename Traits::NodeUniquePtrType node_data = node->getData(); |
183 | 0 | if (!node_data) |
184 | 0 | { |
185 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error retrieving node data"); |
186 | 0 | return XMLP_ret::XML_ERROR; |
187 | 0 | } |
188 | | |
189 | | // Fill attributes |
190 | 0 | atts = *node_data; |
191 | 0 | return XMLP_ret::XML_OK; |
192 | 0 | }; Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::ParticipantAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&)#1}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::PublisherAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&)#1}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::SubscriberAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&)#1}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::TopicAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::TopicAttributes&)#1}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::TopicAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::RequesterAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&)#1}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::ReplierAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&)#1}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&) const |
193 | | |
194 | | // Recursive function to process the root node and its children |
195 | 0 | std::function<XMLP_ret(const up_base_node_t&, AttributesType&)> process_node_recursive; |
196 | 0 | process_node_recursive = |
197 | 0 | [&process_node, &process_node_recursive](const up_base_node_t& node_to_process, AttributesType& atts) |
198 | 0 | { |
199 | 0 | XMLP_ret ret = process_node(node_to_process, atts); |
200 | 0 | if (XMLP_ret::XML_OK == ret || XMLP_ret::XML_ERROR == ret) |
201 | 0 | { |
202 | 0 | return ret; |
203 | 0 | } |
204 | | |
205 | 0 | for (auto&& child: node_to_process->getChildren()) |
206 | 0 | { |
207 | 0 | ret = process_node_recursive(child, atts); |
208 | 0 | if (XMLP_ret::XML_OK == ret || XMLP_ret::XML_ERROR == ret) |
209 | 0 | { |
210 | 0 | return ret; |
211 | 0 | } |
212 | 0 | } |
213 | 0 | return XMLP_ret::XML_NOK; |
214 | 0 | }; Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::ParticipantAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&)#2}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::PublisherAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&)#2}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::SubscriberAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&)#2}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::TopicAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::TopicAttributes&)#2}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::TopicAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::RequesterAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&)#2}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::ReplierAttributes>::NodePtrType)> const&, bool)::{lambda(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&)#2}::operator()(std::__1::unique_ptr<eprosima::fastdds::xmlparser::BaseNode, std::__1::default_delete<eprosima::fastdds::xmlparser::BaseNode> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&) const |
215 | |
|
216 | 0 | std::reference_wrapper<up_base_node_t> node_to_process = root_node; |
217 | 0 | if (fulfill_xsd) |
218 | 0 | { |
219 | 0 | if (NodeType::ROOT == root_node->getType()) |
220 | 0 | { |
221 | 0 | for (auto&& child: root_node->getChildren()) |
222 | 0 | { |
223 | 0 | if (NodeType::PROFILES == child->getType()) |
224 | 0 | { |
225 | 0 | node_to_process = child; |
226 | 0 | break; |
227 | 0 | } |
228 | 0 | } |
229 | 0 | } |
230 | | |
231 | | // Abort if profiles tag is not found according to XSD |
232 | 0 | if (NodeType::PROFILES != node_to_process.get()->getType()) |
233 | 0 | { |
234 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Provided XML literal does not contain profiles"); |
235 | 0 | return XMLP_ret::XML_ERROR; |
236 | 0 | } |
237 | 0 | } |
238 | | |
239 | 0 | if (XMLP_ret::XML_OK == process_node_recursive(node_to_process, atts)) |
240 | 0 | { |
241 | 0 | return XMLP_ret::XML_OK; |
242 | 0 | } |
243 | | |
244 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, Traits::name() << " profile not found"); |
245 | 0 | return XMLP_ret::XML_ERROR; |
246 | 0 | } Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::ParticipantAttributes>::NodePtrType)> const&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::PublisherAttributes>::NodePtrType)> const&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::SubscriberAttributes>::NodePtrType)> const&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::TopicAttributes>::NodePtrType)> const&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::RequesterAttributes>::NodePtrType)> const&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, std::__1::function<bool (AttributesTraits<eprosima::fastdds::xmlparser::ReplierAttributes>::NodePtrType)> const&, bool) |
247 | | |
248 | | template <typename AttributesType> |
249 | | XMLP_ret fill_attributes_from_xml( |
250 | | const std::string& xml, |
251 | | AttributesType& atts, |
252 | | bool fulfill_xsd, |
253 | | const std::string& profile_name) |
254 | 0 | { |
255 | 0 | auto node_filter = [&profile_name](typename AttributesTraits<AttributesType>::NodePtrType node) -> bool |
256 | 0 | { |
257 | 0 | if (!profile_name.empty()) |
258 | 0 | { |
259 | 0 | auto it = node->getAttributes().find(PROFILE_NAME); |
260 | 0 | return (it != node->getAttributes().end() && it->second == profile_name); |
261 | 0 | } |
262 | 0 | return true; |
263 | 0 | }; Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ParticipantAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ParticipantAttributes>*) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::PublisherAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::PublisherAttributes>*) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::SubscriberAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::SubscriberAttributes>*) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::TopicAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::TopicAttributes>*) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::RequesterAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::RequesterAttributes>*) const Unexecuted instantiation: fill_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ReplierAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ReplierAttributes>*) const |
264 | 0 | return fill_attributes_from_xml(xml, atts, node_filter, fulfill_xsd); |
265 | 0 | } Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, bool, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) |
266 | | |
267 | | template <typename AttributesType> |
268 | | XMLP_ret fill_default_attributes_from_xml( |
269 | | const std::string& xml, |
270 | | AttributesType& atts, |
271 | | bool fulfill_xsd) |
272 | 0 | { |
273 | 0 | auto node_filter = [](typename AttributesTraits<AttributesType>::NodePtrType node) -> bool |
274 | 0 | { |
275 | 0 | auto it = node->getAttributes().find(DEFAULT_PROF); |
276 | 0 | return (it != node->getAttributes().end() && it->second == "true"); |
277 | 0 | }; Unexecuted instantiation: fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, bool)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ParticipantAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ParticipantAttributes>*) const Unexecuted instantiation: fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, bool)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::PublisherAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::PublisherAttributes>*) const Unexecuted instantiation: fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, bool)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::SubscriberAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::SubscriberAttributes>*) const Unexecuted instantiation: fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, bool)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::TopicAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::TopicAttributes>*) const Unexecuted instantiation: fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, bool)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::RequesterAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::RequesterAttributes>*) const Unexecuted instantiation: fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, bool)::{lambda(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ReplierAttributes>*)#1}::operator()(eprosima::fastdds::xmlparser::DataNode<eprosima::fastdds::xmlparser::ReplierAttributes>*) const |
278 | 0 | return fill_attributes_from_xml(xml, atts, node_filter, fulfill_xsd); |
279 | 0 | } Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::ParticipantAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ParticipantAttributes&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::PublisherAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::PublisherAttributes&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::SubscriberAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::SubscriberAttributes&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::TopicAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::TopicAttributes&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::RequesterAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::RequesterAttributes&, bool) Unexecuted instantiation: eprosima::fastdds::xmlparser::XMLP_ret fill_default_attributes_from_xml<eprosima::fastdds::xmlparser::ReplierAttributes>(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, eprosima::fastdds::xmlparser::ReplierAttributes&, bool) |
280 | | |
281 | | XMLP_ret XMLProfileManager::fillParticipantAttributes( |
282 | | const std::string& profile_name, |
283 | | ParticipantAttributes& atts, |
284 | | bool log_error) |
285 | 0 | { |
286 | 0 | part_map_iterator_t it = participant_profiles_.find(profile_name); |
287 | 0 | if (it == participant_profiles_.end()) |
288 | 0 | { |
289 | 0 | if (log_error) |
290 | 0 | { |
291 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
292 | 0 | } |
293 | 0 | return XMLP_ret::XML_ERROR; |
294 | 0 | } |
295 | 0 | atts = *(it->second); |
296 | 0 | return XMLP_ret::XML_OK; |
297 | 0 | } |
298 | | |
299 | | XMLP_ret XMLProfileManager::fill_participant_attributes_from_xml( |
300 | | const std::string& xml, |
301 | | ParticipantAttributes& atts, |
302 | | bool fulfill_xsd, |
303 | | const std::string& profile_name) |
304 | 0 | { |
305 | 0 | return fill_attributes_from_xml<ParticipantAttributes>(xml, atts, fulfill_xsd, profile_name); |
306 | 0 | } |
307 | | |
308 | | XMLP_ret XMLProfileManager::fill_default_participant_attributes_from_xml( |
309 | | const std::string& xml, |
310 | | ParticipantAttributes& atts, |
311 | | bool fulfill_xsd) |
312 | 0 | { |
313 | 0 | return fill_default_attributes_from_xml<ParticipantAttributes>(xml, atts, fulfill_xsd); |
314 | 0 | } |
315 | | |
316 | | XMLP_ret XMLProfileManager::fillPublisherAttributes( |
317 | | const std::string& profile_name, |
318 | | PublisherAttributes& atts, |
319 | | bool log_error) |
320 | 0 | { |
321 | 0 | publ_map_iterator_t it = publisher_profiles_.find(profile_name); |
322 | 0 | if (it == publisher_profiles_.end()) |
323 | 0 | { |
324 | 0 | if (log_error) |
325 | 0 | { |
326 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
327 | 0 | } |
328 | 0 | return XMLP_ret::XML_ERROR; |
329 | 0 | } |
330 | 0 | atts = *(it->second); |
331 | 0 | return XMLP_ret::XML_OK; |
332 | 0 | } |
333 | | |
334 | | XMLP_ret XMLProfileManager::fill_publisher_attributes_from_xml( |
335 | | const std::string& xml, |
336 | | PublisherAttributes& atts, |
337 | | bool fulfill_xsd, |
338 | | const std::string& profile_name) |
339 | 0 | { |
340 | 0 | return fill_attributes_from_xml<PublisherAttributes>(xml, atts, fulfill_xsd, profile_name); |
341 | 0 | } |
342 | | |
343 | | XMLP_ret XMLProfileManager::fill_default_publisher_attributes_from_xml( |
344 | | const std::string& xml, |
345 | | PublisherAttributes& atts, |
346 | | bool fulfill_xsd) |
347 | 0 | { |
348 | 0 | return fill_default_attributes_from_xml<PublisherAttributes>(xml, atts, fulfill_xsd); |
349 | 0 | } |
350 | | |
351 | | XMLP_ret XMLProfileManager::fillSubscriberAttributes( |
352 | | const std::string& profile_name, |
353 | | SubscriberAttributes& atts, |
354 | | bool log_error) |
355 | 0 | { |
356 | 0 | subs_map_iterator_t it = subscriber_profiles_.find(profile_name); |
357 | 0 | if (it == subscriber_profiles_.end()) |
358 | 0 | { |
359 | 0 | if (log_error) |
360 | 0 | { |
361 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
362 | 0 | } |
363 | 0 | return XMLP_ret::XML_ERROR; |
364 | 0 | } |
365 | 0 | atts = *(it->second); |
366 | 0 | return XMLP_ret::XML_OK; |
367 | 0 | } |
368 | | |
369 | | XMLP_ret XMLProfileManager::fill_subscriber_attributes_from_xml( |
370 | | const std::string& xml, |
371 | | SubscriberAttributes& atts, |
372 | | bool fulfill_xsd, |
373 | | const std::string& profile_name) |
374 | 0 | { |
375 | 0 | return fill_attributes_from_xml<SubscriberAttributes>(xml, atts, fulfill_xsd, profile_name); |
376 | 0 | } |
377 | | |
378 | | XMLP_ret XMLProfileManager::fill_default_subscriber_attributes_from_xml( |
379 | | const std::string& xml, |
380 | | SubscriberAttributes& atts, |
381 | | bool fulfill_xsd) |
382 | 0 | { |
383 | 0 | return fill_default_attributes_from_xml<SubscriberAttributes>(xml, atts, fulfill_xsd); |
384 | 0 | } |
385 | | |
386 | | XMLP_ret XMLProfileManager::fillTopicAttributes( |
387 | | const std::string& profile_name, |
388 | | TopicAttributes& atts) |
389 | 0 | { |
390 | 0 | topic_map_iterator_t it = topic_profiles_.find(profile_name); |
391 | 0 | if (it == topic_profiles_.end()) |
392 | 0 | { |
393 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
394 | 0 | return XMLP_ret::XML_ERROR; |
395 | 0 | } |
396 | 0 | atts = *(it->second); |
397 | 0 | return XMLP_ret::XML_OK; |
398 | 0 | } |
399 | | |
400 | | XMLP_ret XMLProfileManager::fill_topic_attributes_from_xml( |
401 | | const std::string& xml, |
402 | | TopicAttributes& atts, |
403 | | bool fulfill_xsd, |
404 | | const std::string& profile_name) |
405 | 0 | { |
406 | 0 | return fill_attributes_from_xml<TopicAttributes>(xml, atts, fulfill_xsd, profile_name); |
407 | 0 | } |
408 | | |
409 | | XMLP_ret XMLProfileManager::fill_default_topic_attributes_from_xml( |
410 | | const std::string& xml, |
411 | | TopicAttributes& atts, |
412 | | bool fulfill_xsd) |
413 | 0 | { |
414 | 0 | return fill_default_attributes_from_xml<TopicAttributes>(xml, atts, fulfill_xsd); |
415 | 0 | } |
416 | | |
417 | | XMLP_ret XMLProfileManager::fillRequesterAttributes( |
418 | | const std::string& profile_name, |
419 | | RequesterAttributes& atts) |
420 | 0 | { |
421 | 0 | requester_map_iterator_t it = requester_profiles_.find(profile_name); |
422 | 0 | if (it == requester_profiles_.end()) |
423 | 0 | { |
424 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
425 | 0 | return XMLP_ret::XML_ERROR; |
426 | 0 | } |
427 | 0 | atts = *(it->second); |
428 | 0 | return XMLP_ret::XML_OK; |
429 | 0 | } |
430 | | |
431 | | XMLP_ret XMLProfileManager::fill_requester_attributes_from_xml( |
432 | | const std::string& xml, |
433 | | RequesterAttributes& atts, |
434 | | bool fulfill_xsd, |
435 | | const std::string& profile_name) |
436 | 0 | { |
437 | 0 | return fill_attributes_from_xml<RequesterAttributes>(xml, atts, fulfill_xsd, profile_name); |
438 | 0 | } |
439 | | |
440 | | XMLP_ret XMLProfileManager::fill_default_requester_attributes_from_xml( |
441 | | const std::string& xml, |
442 | | RequesterAttributes& atts, |
443 | | bool fulfill_xsd) |
444 | 0 | { |
445 | 0 | return fill_default_attributes_from_xml<RequesterAttributes>(xml, atts, fulfill_xsd); |
446 | 0 | } |
447 | | |
448 | | XMLP_ret XMLProfileManager::fillReplierAttributes( |
449 | | const std::string& profile_name, |
450 | | ReplierAttributes& atts) |
451 | 0 | { |
452 | 0 | replier_map_iterator_t it = replier_profiles_.find(profile_name); |
453 | 0 | if (it == replier_profiles_.end()) |
454 | 0 | { |
455 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
456 | 0 | return XMLP_ret::XML_ERROR; |
457 | 0 | } |
458 | 0 | atts = *(it->second); |
459 | 0 | return XMLP_ret::XML_OK; |
460 | 0 | } |
461 | | |
462 | | XMLP_ret XMLProfileManager::fill_replier_attributes_from_xml( |
463 | | const std::string& xml, |
464 | | ReplierAttributes& atts, |
465 | | bool fulfill_xsd, |
466 | | const std::string& profile_name) |
467 | 0 | { |
468 | 0 | return fill_attributes_from_xml<ReplierAttributes>(xml, atts, fulfill_xsd, profile_name); |
469 | 0 | } |
470 | | |
471 | | XMLP_ret XMLProfileManager::fill_default_replier_attributes_from_xml( |
472 | | const std::string& xml, |
473 | | ReplierAttributes& atts, |
474 | | bool fulfill_xsd) |
475 | 0 | { |
476 | 0 | return fill_default_attributes_from_xml<ReplierAttributes>(xml, atts, fulfill_xsd); |
477 | 0 | } |
478 | | |
479 | | void XMLProfileManager::getDefaultParticipantAttributes( |
480 | | ParticipantAttributes& participant_attributes) |
481 | 0 | { |
482 | 0 | participant_attributes = default_participant_attributes; |
483 | 0 | } |
484 | | |
485 | | void XMLProfileManager::getDefaultPublisherAttributes( |
486 | | PublisherAttributes& publisher_attributes) |
487 | 0 | { |
488 | 0 | publisher_attributes = default_publisher_attributes; |
489 | 0 | } |
490 | | |
491 | | XMLP_ret XMLProfileManager::fillDomainParticipantFactoryQos( |
492 | | const std::string& profile_name, |
493 | | dds::DomainParticipantFactoryQos& qos, |
494 | | bool log_error) |
495 | 0 | { |
496 | 0 | part_factory_map_iterator_t it = participant_factory_profiles_.find(profile_name); |
497 | 0 | if (it == participant_factory_profiles_.end()) |
498 | 0 | { |
499 | 0 | if (log_error) |
500 | 0 | { |
501 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Profile '" << profile_name << "' not found"); |
502 | 0 | } |
503 | 0 | return XMLP_ret::XML_ERROR; |
504 | 0 | } |
505 | 0 | qos = *(it->second); |
506 | 0 | return XMLP_ret::XML_OK; |
507 | 0 | } |
508 | | |
509 | | void XMLProfileManager::getDefaultDomainParticipantFactoryQos( |
510 | | dds::DomainParticipantFactoryQos& qos) |
511 | 0 | { |
512 | 0 | qos = default_participant_factory_qos; |
513 | 0 | } |
514 | | |
515 | | void XMLProfileManager::getDefaultSubscriberAttributes( |
516 | | SubscriberAttributes& subscriber_attributes) |
517 | 0 | { |
518 | 0 | subscriber_attributes = default_subscriber_attributes; |
519 | 0 | } |
520 | | |
521 | | void XMLProfileManager::getDefaultTopicAttributes( |
522 | | TopicAttributes& topic_attributes) |
523 | 0 | { |
524 | 0 | topic_attributes = default_topic_attributes; |
525 | 0 | } |
526 | | |
527 | | void XMLProfileManager::loadDefaultXMLFile() |
528 | 0 | { |
529 | | // Try to load the default XML file set with an environment variable. |
530 | | #ifdef _WIN32 |
531 | | char file_path[MAX_PATH]; |
532 | | char absolute_path[MAX_PATH]; |
533 | | char current_directory[MAX_PATH]; |
534 | | char** filename = {nullptr}; |
535 | | size_t size = MAX_PATH; |
536 | | if (getenv_s(&size, file_path, size, DEFAULT_FASTDDS_ENV_VARIABLE) == 0 && size > 0) |
537 | | { |
538 | | // Use absolute path to ensure the file is loaded only once |
539 | | if (GetFullPathName(file_path, MAX_PATH, absolute_path, filename) == 0) |
540 | | { |
541 | | EPROSIMA_LOG_ERROR(XMLPARSER, "GetFullPathName failed " << GetLastError()); |
542 | | } |
543 | | else |
544 | | { |
545 | | loadXMLFile(absolute_path); |
546 | | } |
547 | | } |
548 | | |
549 | | // Should take into account '\0' |
550 | | char skip_xml[2]; |
551 | | size = 2; |
552 | | |
553 | | // Try to load the default XML file if variable does not exist or is not set to '1' |
554 | | if (!(getenv_s(&size, skip_xml, size, SKIP_DEFAULT_XML_FILE) == 0 && skip_xml[0] == '1')) |
555 | | { |
556 | | // Try to load the default XML file. |
557 | | if (GetCurrentDirectory(MAX_PATH, current_directory) == 0) |
558 | | { |
559 | | EPROSIMA_LOG_ERROR(XMLPARSER, "GetCurrentDirectory failed " << GetLastError()); |
560 | | } |
561 | | else |
562 | | { |
563 | | strcat_s(current_directory, MAX_PATH, "\\"); |
564 | | strcat_s(current_directory, MAX_PATH, DEFAULT_FASTDDS_PROFILES); |
565 | | loadXMLFile(current_directory, true); |
566 | | } |
567 | | } |
568 | | #else |
569 | 0 | char absolute_path[PATH_MAX]; |
570 | |
|
571 | 0 | if (const char* file_path = std::getenv(DEFAULT_FASTDDS_ENV_VARIABLE)) |
572 | 0 | { |
573 | 0 | char* res = realpath(file_path, absolute_path); |
574 | 0 | if (res) |
575 | 0 | { |
576 | 0 | loadXMLFile(absolute_path); |
577 | 0 | } |
578 | 0 | else |
579 | 0 | { |
580 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "realpath failed " << std::strerror(errno)); |
581 | 0 | } |
582 | 0 | } |
583 | |
|
584 | 0 | const char* skip_xml = std::getenv(SKIP_DEFAULT_XML_FILE); |
585 | | |
586 | | // Try to load the default XML file if variable does not exist or is not set to '1' |
587 | 0 | if (!(skip_xml != nullptr && skip_xml[0] == '1')) |
588 | 0 | { |
589 | 0 | if (getcwd(absolute_path, PATH_MAX) == NULL) |
590 | 0 | { |
591 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "getcwd failed " << std::strerror(errno)); |
592 | 0 | } |
593 | 0 | else |
594 | 0 | { |
595 | 0 | strcat(absolute_path, "/"); |
596 | 0 | strcat(absolute_path, DEFAULT_FASTDDS_PROFILES); |
597 | 0 | loadXMLFile(absolute_path, true); |
598 | 0 | } |
599 | 0 | } |
600 | |
|
601 | 0 | #endif // ifdef _WIN32 |
602 | 0 | } |
603 | | |
604 | | XMLP_ret XMLProfileManager::loadXMLProfiles( |
605 | | tinyxml2::XMLElement& profiles) |
606 | 0 | { |
607 | 0 | up_base_node_t root_node; |
608 | 0 | if (strcmp(profiles.Name(), PROFILES) != 0) |
609 | 0 | { |
610 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "<profiles> element not found"); |
611 | 0 | return XMLP_ret::XML_ERROR; |
612 | 0 | } |
613 | | |
614 | 0 | if (XMLParser::loadXMLProfiles(profiles, root_node) == XMLP_ret::XML_OK) |
615 | 0 | { |
616 | 0 | EPROSIMA_LOG_INFO(XMLPARSER, "Node parsed successfully"); |
617 | 0 | return XMLProfileManager::extractProfiles(std::move(root_node), "-XML Node-"); |
618 | 0 | } |
619 | 0 | else |
620 | 0 | { |
621 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing profiles"); |
622 | 0 | return XMLP_ret::XML_ERROR; |
623 | 0 | } |
624 | 0 | } |
625 | | |
626 | | XMLP_ret XMLProfileManager::loadXMLDynamicTypes( |
627 | | tinyxml2::XMLElement& types) |
628 | 0 | { |
629 | 0 | return XMLParser::loadXMLDynamicTypes(types); |
630 | 0 | } |
631 | | |
632 | | XMLP_ret XMLProfileManager::loadXMLNode( |
633 | | tinyxml2::XMLDocument& doc) |
634 | 0 | { |
635 | 0 | up_base_node_t root_node; |
636 | 0 | XMLP_ret parse_ret; |
637 | 0 | XMLP_ret loaded_ret = XMLParser::loadXML(doc, root_node); |
638 | |
|
639 | 0 | if (!root_node) |
640 | 0 | { |
641 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing node"); |
642 | 0 | return XMLP_ret::XML_ERROR; |
643 | 0 | } |
644 | | |
645 | 0 | EPROSIMA_LOG_INFO(XMLPARSER, "Node parsed successfully"); |
646 | |
|
647 | 0 | if (NodeType::PROFILES == root_node->getType()) |
648 | 0 | { |
649 | 0 | parse_ret = XMLProfileManager::extractProfiles(std::move(root_node), "-XML Node-"); |
650 | 0 | if (parse_ret == XMLP_ret::XML_OK && loaded_ret != XMLP_ret::XML_OK) |
651 | 0 | { |
652 | 0 | return XMLP_ret::XML_NOK; |
653 | 0 | } |
654 | 0 | else |
655 | 0 | { |
656 | 0 | return parse_ret; |
657 | 0 | } |
658 | 0 | } |
659 | | |
660 | 0 | if (NodeType::ROOT == root_node->getType()) |
661 | 0 | { |
662 | 0 | for (auto&& child: root_node->getChildren()) |
663 | 0 | { |
664 | 0 | if (NodeType::PROFILES == child.get()->getType()) |
665 | 0 | { |
666 | 0 | parse_ret = XMLProfileManager::extractProfiles(std::move(child), "-XML Node-"); |
667 | 0 | if (parse_ret == XMLP_ret::XML_OK && loaded_ret != XMLP_ret::XML_OK) |
668 | 0 | { |
669 | 0 | return XMLP_ret::XML_NOK; |
670 | 0 | } |
671 | 0 | else |
672 | 0 | { |
673 | 0 | return parse_ret; |
674 | 0 | } |
675 | 0 | } |
676 | 0 | } |
677 | 0 | } |
678 | | |
679 | 0 | return XMLP_ret::XML_ERROR; |
680 | 0 | } |
681 | | |
682 | | XMLP_ret XMLProfileManager::loadXMLFile( |
683 | | const std::string& filename) |
684 | 0 | { |
685 | 0 | return loadXMLFile(filename, false); |
686 | 0 | } |
687 | | |
688 | | XMLP_ret XMLProfileManager::loadXMLFile( |
689 | | const std::string& filename, |
690 | | bool is_default) |
691 | 0 | { |
692 | 0 | if (filename.empty()) |
693 | 0 | { |
694 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error loading XML file, filename empty"); |
695 | 0 | return XMLP_ret::XML_ERROR; |
696 | 0 | } |
697 | | |
698 | 0 | xmlfile_map_iterator_t it = xml_files_.find(filename); |
699 | 0 | if (it != xml_files_.end() && XMLP_ret::XML_OK == it->second) |
700 | 0 | { |
701 | 0 | EPROSIMA_LOG_INFO(XMLPARSER, "XML file '" << filename << "' already parsed"); |
702 | 0 | return XMLP_ret::XML_OK; |
703 | 0 | } |
704 | | |
705 | 0 | up_base_node_t root_node; |
706 | 0 | XMLP_ret loaded_ret = XMLParser::loadXML(filename, root_node, is_default); |
707 | 0 | if (!root_node || loaded_ret != XMLP_ret::XML_OK) |
708 | 0 | { |
709 | 0 | if (!is_default) |
710 | 0 | { |
711 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing '" << filename << "'"); |
712 | 0 | } |
713 | 0 | xml_files_.emplace(filename, XMLP_ret::XML_ERROR); |
714 | 0 | return XMLP_ret::XML_ERROR; |
715 | 0 | } |
716 | | |
717 | 0 | EPROSIMA_LOG_INFO(XMLPARSER, "File '" << filename << "' parsed successfully"); |
718 | |
|
719 | 0 | if (NodeType::ROOT == root_node->getType()) |
720 | 0 | { |
721 | 0 | for (auto&& child: root_node->getChildren()) |
722 | 0 | { |
723 | 0 | if (NodeType::PROFILES == child.get()->getType()) |
724 | 0 | { |
725 | 0 | return XMLProfileManager::extractProfiles(std::move(child), filename); |
726 | 0 | } |
727 | 0 | } |
728 | 0 | return loaded_ret; |
729 | 0 | } |
730 | 0 | else if (NodeType::PROFILES == root_node->getType()) |
731 | 0 | { |
732 | 0 | return XMLProfileManager::extractProfiles(std::move(root_node), filename); |
733 | 0 | } |
734 | | |
735 | 0 | return loaded_ret; |
736 | 0 | } |
737 | | |
738 | | XMLP_ret XMLProfileManager::loadXMLString( |
739 | | const char* data, |
740 | | size_t length) |
741 | 20.0k | { |
742 | 20.0k | up_base_node_t root_node; |
743 | 20.0k | XMLP_ret loaded_ret = XMLParser::loadXML(data, length, root_node); |
744 | 20.0k | if (!root_node || loaded_ret != XMLP_ret::XML_OK) |
745 | 16.8k | { |
746 | 16.8k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error parsing string"); |
747 | 16.8k | return XMLP_ret::XML_ERROR; |
748 | 16.8k | } |
749 | | |
750 | 3.14k | if (NodeType::ROOT == root_node->getType()) |
751 | 699 | { |
752 | 699 | for (auto&& child: root_node->getChildren()) |
753 | 3.52k | { |
754 | 3.52k | if (NodeType::PROFILES == child.get()->getType()) |
755 | 42 | { |
756 | 42 | return XMLProfileManager::extractProfiles(std::move(child), "inmem"); |
757 | 42 | } |
758 | 3.52k | } |
759 | 657 | return loaded_ret; |
760 | 699 | } |
761 | 2.44k | else if (NodeType::PROFILES == root_node->getType()) |
762 | 2.21k | { |
763 | 2.21k | return XMLProfileManager::extractProfiles(std::move(root_node), "inmem"); |
764 | 2.21k | } |
765 | | |
766 | 235 | return loaded_ret; |
767 | 3.14k | } |
768 | | |
769 | | XMLP_ret XMLProfileManager::extractProfiles( |
770 | | up_base_node_t profiles, |
771 | | const std::string& filename) |
772 | 2.25k | { |
773 | 2.25k | assert(profiles != nullptr); |
774 | | |
775 | 2.25k | unsigned int profile_count = 0u; |
776 | | |
777 | 2.25k | XMLP_ret ret = XMLP_ret::XML_OK; |
778 | 2.25k | for (auto&& profile: profiles->getChildren()) |
779 | 72.3k | { |
780 | 72.3k | if (NodeType::DOMAINPARTICIPANT_FACTORY == profile->getType()) |
781 | 6.19k | { |
782 | 6.19k | if (XMLP_ret::XML_OK == extractDomainParticipantFactoryProfile(profile, filename)) |
783 | 870 | { |
784 | 870 | ++profile_count; |
785 | 870 | } |
786 | 5.32k | else |
787 | 5.32k | { |
788 | 5.32k | ret = XMLP_ret::XML_NOK; |
789 | 5.32k | } |
790 | 6.19k | } |
791 | 66.1k | else if (NodeType::PARTICIPANT == profile->getType()) |
792 | 10.8k | { |
793 | 10.8k | if (XMLP_ret::XML_OK == extractParticipantProfile(profile, filename)) |
794 | 1.18k | { |
795 | 1.18k | ++profile_count; |
796 | 1.18k | } |
797 | 9.62k | else |
798 | 9.62k | { |
799 | 9.62k | ret = XMLP_ret::XML_NOK; |
800 | 9.62k | } |
801 | 10.8k | } |
802 | 55.3k | else if (NodeType::PUBLISHER == profile.get()->getType()) |
803 | 9.77k | { |
804 | 9.77k | if (XMLP_ret::XML_OK == extractPublisherProfile(profile, filename)) |
805 | 1.16k | { |
806 | 1.16k | ++profile_count; |
807 | 1.16k | } |
808 | 8.60k | else |
809 | 8.60k | { |
810 | 8.60k | ret = XMLP_ret::XML_NOK; |
811 | 8.60k | } |
812 | 9.77k | } |
813 | 45.5k | else if (NodeType::SUBSCRIBER == profile.get()->getType()) |
814 | 18.1k | { |
815 | 18.1k | if (XMLP_ret::XML_OK == extractSubscriberProfile(profile, filename)) |
816 | 1.21k | { |
817 | 1.21k | ++profile_count; |
818 | 1.21k | } |
819 | 16.9k | else |
820 | 16.9k | { |
821 | 16.9k | ret = XMLP_ret::XML_NOK; |
822 | 16.9k | } |
823 | 18.1k | } |
824 | 27.4k | else if (NodeType::TOPIC == profile.get()->getType()) |
825 | 15.6k | { |
826 | 15.6k | if (XMLP_ret::XML_OK == extractTopicProfile(profile, filename)) |
827 | 1.00k | { |
828 | 1.00k | ++profile_count; |
829 | 1.00k | } |
830 | 14.6k | else |
831 | 14.6k | { |
832 | 14.6k | ret = XMLP_ret::XML_NOK; |
833 | 14.6k | } |
834 | 15.6k | } |
835 | 11.8k | else if (NodeType::REQUESTER == profile.get()->getType()) |
836 | 6.48k | { |
837 | 6.48k | if (XMLP_ret::XML_OK == extractRequesterProfile(profile, filename)) |
838 | 402 | { |
839 | 402 | ++profile_count; |
840 | 402 | } |
841 | 6.07k | else |
842 | 6.07k | { |
843 | 6.07k | ret = XMLP_ret::XML_NOK; |
844 | 6.07k | } |
845 | 6.48k | } |
846 | 5.38k | else if (NodeType::REPLIER == profile.get()->getType()) |
847 | 5.38k | { |
848 | 5.38k | if (XMLP_ret::XML_OK == extractReplierProfile(profile, filename)) |
849 | 421 | { |
850 | 421 | ++profile_count; |
851 | 421 | } |
852 | 4.96k | else |
853 | 4.96k | { |
854 | 4.96k | ret = XMLP_ret::XML_NOK; |
855 | 4.96k | } |
856 | 5.38k | } |
857 | 72.3k | } |
858 | | |
859 | 2.25k | profile_count += static_cast<unsigned int>(transport_profiles_.size()); // Count transport profiles |
860 | | |
861 | 2.25k | if (profile_count == 0) |
862 | 889 | { |
863 | 889 | EPROSIMA_LOG_ERROR(XMLProfileManager, "Could not extract any profile"); |
864 | 889 | ret = XMLP_ret::XML_ERROR; |
865 | 889 | } |
866 | | |
867 | 2.25k | xml_files_.emplace(filename, ret); |
868 | | |
869 | 2.25k | return ret; |
870 | 2.25k | } |
871 | | |
872 | | XMLP_ret XMLProfileManager::extractDomainParticipantFactoryProfile( |
873 | | up_base_node_t& profile, |
874 | | const std::string& filename) |
875 | 6.19k | { |
876 | 6.19k | static_cast<void>(filename); |
877 | 6.19k | std::string profile_name = ""; |
878 | | |
879 | 6.19k | p_node_participantfactory_t node_factory = dynamic_cast<p_node_participantfactory_t>(profile.get()); |
880 | 6.19k | node_att_map_cit_t it = node_factory->getAttributes().find(PROFILE_NAME); |
881 | 6.19k | if (it == node_factory->getAttributes().end() || it->second.empty()) |
882 | 1.39k | { |
883 | 1.39k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
884 | 1.39k | return XMLP_ret::XML_ERROR; |
885 | 1.39k | } |
886 | | |
887 | 4.79k | profile_name = it->second; |
888 | | |
889 | 4.79k | std::pair<part_factory_map_iterator_t, bool> emplace = participant_factory_profiles_.emplace(profile_name, |
890 | 4.79k | node_factory->getData()); |
891 | 4.79k | if (false == emplace.second) |
892 | 3.92k | { |
893 | 3.92k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
894 | 3.92k | return XMLP_ret::XML_ERROR; |
895 | 3.92k | } |
896 | | |
897 | 870 | it = node_factory->getAttributes().find(DEFAULT_PROF); |
898 | 870 | if (it != node_factory->getAttributes().end() && it->second == "true") // Set as default profile |
899 | 59 | { |
900 | 59 | default_participant_factory_qos = *(emplace.first->second.get()); |
901 | 59 | } |
902 | 870 | return XMLP_ret::XML_OK; |
903 | 4.79k | } |
904 | | |
905 | | XMLP_ret XMLProfileManager::extractParticipantProfile( |
906 | | up_base_node_t& profile, |
907 | | const std::string& filename) |
908 | 10.8k | { |
909 | 10.8k | (void)(filename); |
910 | 10.8k | std::string profile_name = ""; |
911 | | |
912 | 10.8k | p_node_participant_t node_part = dynamic_cast<p_node_participant_t>(profile.get()); |
913 | 10.8k | node_att_map_cit_t it = node_part->getAttributes().find(PROFILE_NAME); |
914 | 10.8k | if (it == node_part->getAttributes().end() || it->second.empty()) |
915 | 2.32k | { |
916 | 2.32k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
917 | 2.32k | return XMLP_ret::XML_ERROR; |
918 | 2.32k | } |
919 | | |
920 | 8.48k | profile_name = it->second; |
921 | | |
922 | 8.48k | std::pair<part_map_iterator_t, bool> emplace = participant_profiles_.emplace(profile_name, node_part->getData()); |
923 | 8.48k | if (false == emplace.second) |
924 | 7.30k | { |
925 | 7.30k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
926 | 7.30k | return XMLP_ret::XML_ERROR; |
927 | 7.30k | } |
928 | | |
929 | 1.18k | it = node_part->getAttributes().find(DEFAULT_PROF); |
930 | 1.18k | if (it != node_part->getAttributes().end() && it->second == "true") // Set as default profile |
931 | 237 | { |
932 | | // +V+ TODO: LOG ERROR IN SECOND ATTEMPT |
933 | 237 | default_participant_attributes = *(emplace.first->second.get()); |
934 | 237 | } |
935 | 1.18k | return XMLP_ret::XML_OK; |
936 | 8.48k | } |
937 | | |
938 | | XMLP_ret XMLProfileManager::extractPublisherProfile( |
939 | | up_base_node_t& profile, |
940 | | const std::string& filename) |
941 | 9.77k | { |
942 | 9.77k | (void)(filename); |
943 | 9.77k | std::string profile_name = ""; |
944 | | |
945 | 9.77k | p_node_publisher_t node_part = dynamic_cast<p_node_publisher_t>(profile.get()); |
946 | 9.77k | node_att_map_cit_t it = node_part->getAttributes().find(PROFILE_NAME); |
947 | 9.77k | if (it == node_part->getAttributes().end() || it->second.empty()) |
948 | 1.80k | { |
949 | 1.80k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
950 | 1.80k | return XMLP_ret::XML_ERROR; |
951 | 1.80k | } |
952 | | |
953 | 7.96k | profile_name = it->second; |
954 | | |
955 | 7.96k | std::pair<publ_map_iterator_t, bool> emplace = publisher_profiles_.emplace(profile_name, node_part->getData()); |
956 | 7.96k | if (false == emplace.second) |
957 | 6.79k | { |
958 | 6.79k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
959 | 6.79k | return XMLP_ret::XML_ERROR; |
960 | 6.79k | } |
961 | | |
962 | 1.16k | it = node_part->getAttributes().find(DEFAULT_PROF); |
963 | 1.16k | if (it != node_part->getAttributes().end() && it->second == "true") // Set as default profile |
964 | 230 | { |
965 | | // +V+ TODO: LOG ERROR IN SECOND ATTEMPT |
966 | 230 | default_publisher_attributes = *(emplace.first->second.get()); |
967 | 230 | } |
968 | 1.16k | return XMLP_ret::XML_OK; |
969 | 7.96k | } |
970 | | |
971 | | XMLP_ret XMLProfileManager::extractSubscriberProfile( |
972 | | up_base_node_t& profile, |
973 | | const std::string& filename) |
974 | 18.1k | { |
975 | 18.1k | (void)(filename); |
976 | 18.1k | std::string profile_name = ""; |
977 | | |
978 | 18.1k | p_node_subscriber_t node_part = dynamic_cast<p_node_subscriber_t>(profile.get()); |
979 | 18.1k | node_att_map_cit_t it = node_part->getAttributes().find(PROFILE_NAME); |
980 | 18.1k | if (it == node_part->getAttributes().end() || it->second.empty()) |
981 | 1.71k | { |
982 | 1.71k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
983 | 1.71k | return XMLP_ret::XML_ERROR; |
984 | 1.71k | } |
985 | | |
986 | 16.3k | profile_name = it->second; |
987 | | |
988 | 16.3k | std::pair<subs_map_iterator_t, bool> emplace = subscriber_profiles_.emplace(profile_name, node_part->getData()); |
989 | 16.3k | if (false == emplace.second) |
990 | 15.1k | { |
991 | 15.1k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
992 | 15.1k | return XMLP_ret::XML_ERROR; |
993 | 15.1k | } |
994 | | |
995 | 1.21k | it = node_part->getAttributes().find(DEFAULT_PROF); |
996 | 1.21k | if (it != node_part->getAttributes().end() && it->second == "true") // Set as default profile |
997 | 242 | { |
998 | | // +V+ TODO: LOG ERROR IN SECOND ATTEMPT |
999 | 242 | default_subscriber_attributes = *(emplace.first->second.get()); |
1000 | 242 | } |
1001 | 1.21k | return XMLP_ret::XML_OK; |
1002 | 16.3k | } |
1003 | | |
1004 | | bool XMLProfileManager::insertTransportById( |
1005 | | const std::string& transport_id, |
1006 | | sp_transport_t transport) |
1007 | 0 | { |
1008 | 0 | if (transport_profiles_.find(transport_id) == transport_profiles_.end()) |
1009 | 0 | { |
1010 | 0 | transport_profiles_[transport_id] = transport; |
1011 | 0 | return true; |
1012 | 0 | } |
1013 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, |
1014 | 0 | "Error adding the transport " << transport_id << ". There is other transport with the same id"); |
1015 | 0 | return false; |
1016 | 0 | } |
1017 | | |
1018 | | const LibrarySettings& XMLProfileManager::library_settings() |
1019 | 0 | { |
1020 | 0 | return library_settings_; |
1021 | 0 | } |
1022 | | |
1023 | | void XMLProfileManager::library_settings( |
1024 | | const LibrarySettings& library_settings) |
1025 | 0 | { |
1026 | 0 | library_settings_ = library_settings; |
1027 | 0 | } |
1028 | | |
1029 | | sp_transport_t XMLProfileManager::getTransportById( |
1030 | | const std::string& transport_id) |
1031 | 0 | { |
1032 | 0 | if (transport_profiles_.find(transport_id) != transport_profiles_.end()) |
1033 | 0 | { |
1034 | 0 | return transport_profiles_[transport_id]; |
1035 | 0 | } |
1036 | 0 | return nullptr; |
1037 | 0 | } |
1038 | | |
1039 | | bool XMLProfileManager::insertDynamicTypeBuilderByName( |
1040 | | const std::string& type_name, |
1041 | | const eprosima::fastdds::dds::DynamicTypeBuilder::_ref_type& type) |
1042 | 1.30k | { |
1043 | 1.30k | if (dynamic_types_.find(type_name) == dynamic_types_.end()) |
1044 | 1.30k | { |
1045 | 1.30k | dynamic_types_.emplace(std::make_pair(type_name, type)); |
1046 | 1.30k | return true; |
1047 | 1.30k | } |
1048 | 0 | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding the type " << type_name << ". There is other type with the same name."); |
1049 | 0 | return false; |
1050 | 1.30k | } |
1051 | | |
1052 | | XMLP_ret XMLProfileManager::getDynamicTypeBuilderByName( |
1053 | | eprosima::fastdds::dds::DynamicTypeBuilder::_ref_type& dynamic_type, |
1054 | | const std::string& type_name) |
1055 | 85.7k | { |
1056 | 85.7k | if (dynamic_types_.find(type_name) != dynamic_types_.end()) |
1057 | 18.6k | { |
1058 | 18.6k | dynamic_type = dynamic_types_[type_name]; |
1059 | 18.6k | return XMLP_ret::XML_OK; |
1060 | 18.6k | } |
1061 | | |
1062 | 67.0k | return XMLP_ret::XML_ERROR; |
1063 | 85.7k | } |
1064 | | |
1065 | | XMLP_ret XMLProfileManager::extractTopicProfile( |
1066 | | up_base_node_t& profile, |
1067 | | const std::string& filename) |
1068 | 15.6k | { |
1069 | 15.6k | (void)(filename); |
1070 | 15.6k | std::string profile_name = ""; |
1071 | | |
1072 | 15.6k | p_node_topic_t node_topic = dynamic_cast<p_node_topic_t>(profile.get()); |
1073 | 15.6k | node_att_map_cit_t it = node_topic->getAttributes().find(PROFILE_NAME); |
1074 | 15.6k | if (it == node_topic->getAttributes().end() || it->second.empty()) |
1075 | 3.77k | { |
1076 | 3.77k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
1077 | 3.77k | return XMLP_ret::XML_ERROR; |
1078 | 3.77k | } |
1079 | | |
1080 | 11.8k | profile_name = it->second; |
1081 | | |
1082 | 11.8k | std::pair<topic_map_iterator_t, bool> emplace = topic_profiles_.emplace(profile_name, node_topic->getData()); |
1083 | 11.8k | if (false == emplace.second) |
1084 | 10.8k | { |
1085 | 10.8k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
1086 | 10.8k | return XMLP_ret::XML_ERROR; |
1087 | 10.8k | } |
1088 | | |
1089 | 1.00k | it = node_topic->getAttributes().find(DEFAULT_PROF); |
1090 | 1.00k | if (it != node_topic->getAttributes().end() && it->second == "true") |
1091 | 88 | { |
1092 | | // +V+ TODO: LOG ERROR IN SECOND ATTEMPT |
1093 | 88 | default_topic_attributes = *(emplace.first->second.get()); |
1094 | 88 | } |
1095 | 1.00k | return XMLP_ret::XML_OK; |
1096 | 11.8k | } |
1097 | | |
1098 | | XMLP_ret XMLProfileManager::extractRequesterProfile( |
1099 | | up_base_node_t& profile, |
1100 | | const std::string& filename) |
1101 | 6.48k | { |
1102 | 6.48k | (void)(filename); |
1103 | 6.48k | std::string profile_name = ""; |
1104 | | |
1105 | 6.48k | p_node_requester_t node_requester = dynamic_cast<p_node_requester_t>(profile.get()); |
1106 | 6.48k | node_att_map_cit_t it = node_requester->getAttributes().find(PROFILE_NAME); |
1107 | 6.48k | if (it == node_requester->getAttributes().end() || it->second.empty()) |
1108 | 1.50k | { |
1109 | 1.50k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
1110 | 1.50k | return XMLP_ret::XML_ERROR; |
1111 | 1.50k | } |
1112 | | |
1113 | 4.97k | profile_name = it->second; |
1114 | | |
1115 | 4.97k | std::pair<requester_map_iterator_t, bool> emplace = requester_profiles_.emplace(profile_name, |
1116 | 4.97k | node_requester->getData()); |
1117 | 4.97k | if (false == emplace.second) |
1118 | 4.57k | { |
1119 | 4.57k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
1120 | 4.57k | return XMLP_ret::XML_ERROR; |
1121 | 4.57k | } |
1122 | | |
1123 | 402 | return XMLP_ret::XML_OK; |
1124 | 4.97k | } |
1125 | | |
1126 | | XMLP_ret XMLProfileManager::extractReplierProfile( |
1127 | | up_base_node_t& profile, |
1128 | | const std::string& filename) |
1129 | 5.38k | { |
1130 | 5.38k | (void)(filename); |
1131 | 5.38k | std::string profile_name = ""; |
1132 | | |
1133 | 5.38k | p_node_replier_t node_replier = dynamic_cast<p_node_replier_t>(profile.get()); |
1134 | 5.38k | node_att_map_cit_t it = node_replier->getAttributes().find(PROFILE_NAME); |
1135 | 5.38k | if (it == node_replier->getAttributes().end() || it->second.empty()) |
1136 | 1.23k | { |
1137 | 1.23k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile from file '" << filename << "': no name found"); |
1138 | 1.23k | return XMLP_ret::XML_ERROR; |
1139 | 1.23k | } |
1140 | | |
1141 | 4.14k | profile_name = it->second; |
1142 | | |
1143 | 4.14k | std::pair<replier_map_iterator_t, bool> emplace = replier_profiles_.emplace(profile_name, node_replier->getData()); |
1144 | 4.14k | if (false == emplace.second) |
1145 | 3.72k | { |
1146 | 3.72k | EPROSIMA_LOG_ERROR(XMLPARSER, "Error adding profile '" << profile_name << "' from file '" << filename << "'"); |
1147 | 3.72k | return XMLP_ret::XML_ERROR; |
1148 | 3.72k | } |
1149 | | |
1150 | 421 | return XMLP_ret::XML_OK; |
1151 | 4.14k | } |
1152 | | |
1153 | | void XMLProfileManager::DeleteInstance() |
1154 | 0 | { |
1155 | 0 | participant_factory_profiles_.clear(); |
1156 | 0 | participant_profiles_.clear(); |
1157 | 0 | publisher_profiles_.clear(); |
1158 | 0 | subscriber_profiles_.clear(); |
1159 | 0 | requester_profiles_.clear(); |
1160 | 0 | replier_profiles_.clear(); |
1161 | 0 | topic_profiles_.clear(); |
1162 | 0 | xml_files_.clear(); |
1163 | 0 | transport_profiles_.clear(); |
1164 | 0 | dynamic_types_.clear(); |
1165 | 0 | } |