Fast RTPS  Version 2.14.1
Fast RTPS
Loading...
Searching...
No Matches
XMLProfileManager.h
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#ifndef XML_PROFILE_MANAGER_H_
16#define XML_PROFILE_MANAGER_H_
17
18#include <cstdio>
19#include <map>
20#include <string>
21
22#include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
23#include <fastrtps/attributes/ParticipantAttributes.h>
24#include <fastrtps/attributes/PublisherAttributes.h>
25#include <fastrtps/attributes/SubscriberAttributes.h>
26#include <fastrtps/types/DynamicPubSubType.h>
27#include <fastrtps/types/DynamicTypeBuilder.h>
28#include <fastrtps/types/DynamicTypeBuilderFactory.h>
29#include <fastrtps/xmlparser/XMLParser.h>
30#include <fastrtps/xmlparser/XMLParserCommon.h>
31
32namespace eprosima {
33namespace fastrtps {
34namespace xmlparser {
35
36using participant_factory_map_t = std::map<std::string, up_participantfactory_t>;
37using part_factory_map_iterator_t = participant_factory_map_t::iterator;
38using participant_map_t = std::map<std::string, up_participant_t>;
39using part_map_iterator_t = participant_map_t::iterator;
40using publisher_map_t = std::map<std::string, up_publisher_t>;
41using publ_map_iterator_t = publisher_map_t::iterator;
42using subscriber_map_t = std::map<std::string, up_subscriber_t>;
43using subs_map_iterator_t = subscriber_map_t::iterator;
44using topic_map_t = std::map<std::string, up_topic_t>;
45using topic_map_iterator_t = topic_map_t::iterator;
46using requester_map_t = std::map<std::string, up_requester_t>;
47using requester_map_iterator_t = requester_map_t::iterator;
48using replier_map_t = std::map<std::string, up_replier_t>;
49using replier_map_iterator_t = replier_map_t::iterator;
50using xmlfiles_map_t = std::map<std::string, XMLP_ret>;
51using xmlfile_map_iterator_t = xmlfiles_map_t::iterator;
52
58{
59public:
60
64 RTPS_DllAPI static void loadDefaultXMLFile();
65
72 RTPS_DllAPI static XMLP_ret loadXMLFile(
73 const std::string& filename);
74
82 RTPS_DllAPI static XMLP_ret loadXMLString(
83 const char* data,
84 size_t length);
85
92 RTPS_DllAPI static XMLP_ret loadXMLNode(
93 tinyxml2::XMLDocument& doc);
94
101 RTPS_DllAPI static XMLP_ret loadXMLProfiles(
102 tinyxml2::XMLElement& profiles);
103
109 RTPS_DllAPI static XMLP_ret loadXMLDynamicTypes(
110 tinyxml2::XMLElement& types);
111
116 RTPS_DllAPI static void library_settings(
118
123 RTPS_DllAPI static const LibrarySettingsAttributes& library_settings();
124
133 const std::string& profile_name,
135 bool log_error = true);
136
138 RTPS_DllAPI static void getDefaultParticipantAttributes(
139 ParticipantAttributes& participant_attributes);
140
149 const std::string& profile_name,
150 fastdds::dds::DomainParticipantFactoryQos& qos,
151 bool log_error = true);
152
158 fastdds::dds::DomainParticipantFactoryQos& qos);
159
168 const std::string& profile_name,
170 bool log_error = true);
171
173 RTPS_DllAPI static void getDefaultPublisherAttributes(
174 PublisherAttributes& publisher_attributes);
175
184 const std::string& profile_name,
186 bool log_error = true);
187
189 RTPS_DllAPI static void getDefaultSubscriberAttributes(
190 SubscriberAttributes& subscriber_attributes);
191
193 RTPS_DllAPI static bool insertTransportById(
194 const std::string& transport_id,
195 sp_transport_t transport);
196
199 const std::string& transport_id);
200
207 RTPS_DllAPI static XMLP_ret fillTopicAttributes(
208 const std::string& profile_name,
209 TopicAttributes& atts);
210
212 RTPS_DllAPI static void getDefaultTopicAttributes(
213 TopicAttributes& topic_attributes);
214
216 RTPS_DllAPI static bool insertDynamicTypeByName(
217 const std::string& type_name,
219
222 const std::string& type_name);
223
224
232 const std::string& profile_name,
233 RequesterAttributes& atts);
234
241 RTPS_DllAPI static XMLP_ret fillReplierAttributes(
242 const std::string& profile_name,
243 ReplierAttributes& atts);
244
250 RTPS_DllAPI static void DeleteInstance();
251
258 const std::string& type_name);
259
264 RTPS_DllAPI static void DeleteDynamicPubSubType(
266
267private:
268
269 RTPS_DllAPI static XMLP_ret extractProfiles(
270 up_base_node_t properties,
271 const std::string& filename);
272
273 RTPS_DllAPI static XMLP_ret extractDomainParticipantFactoryProfile(
274 up_base_node_t& profile,
275 const std::string& filename);
276
277 RTPS_DllAPI static XMLP_ret extractParticipantProfile(
278 up_base_node_t& profile,
279 const std::string& filename);
280
281 RTPS_DllAPI static XMLP_ret extractPublisherProfile(
282 up_base_node_t& profile,
283 const std::string& filename);
284
285 RTPS_DllAPI static XMLP_ret extractSubscriberProfile(
286 up_base_node_t& profile,
287 const std::string& filename);
288
289 RTPS_DllAPI static XMLP_ret extractTopicProfile(
290 up_base_node_t& profile,
291 const std::string& filename);
292
293 RTPS_DllAPI static XMLP_ret extractRequesterProfile(
294 up_base_node_t& profile,
295 const std::string& filename);
296
297 RTPS_DllAPI static XMLP_ret extractReplierProfile(
298 up_base_node_t& profile,
299 const std::string& filename);
300
301 static BaseNode* root;
302
303 static LibrarySettingsAttributes library_settings_;
304
305 static participant_factory_map_t participant_factory_profiles_;
306
307 static participant_map_t participant_profiles_;
308
309 static publisher_map_t publisher_profiles_;
310
311 static subscriber_map_t subscriber_profiles_;
312
313 static topic_map_t topic_profiles_;
314
315 static requester_map_t requester_profiles_;
316
317 static replier_map_t replier_profiles_;
318
319 static xmlfiles_map_t xml_files_;
320
321 static sp_transport_map_t transport_profiles_;
322
323 static p_dynamictype_map_t dynamic_types_;
324};
325
326} /* xmlparser */
327} /* namespace */
328} /* namespace eprosima */
329
330#endif // ifndef XML_PROFILE_MANAGER_H_
Class LibraySettingsAttributes, used by the user to define the FastRTPS library behaviour.
Definition LibrarySettingsAttributes.h:38
Class ParticipantAttributes, used by the user to define the attributes of a Participant.
Definition ParticipantAttributes.h:35
Class PublisherAttributes, used by the user to define the attributes of a Publisher.
Definition PublisherAttributes.h:41
Definition ReplierAttributes.hpp:29
Definition RequesterAttributes.hpp:29
Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
Definition SubscriberAttributes.h:39
Class TopicAttributes, used by the user to define the attributes of the topic associated with a Publi...
Definition TopicAttributes.h:36
Definition DynamicPubSubType.h:29
Definition DynamicTypeBuilder.h:32
Class XMLProfileManager, used to make available profiles from XML file.
Definition XMLProfileManager.h:58
static RTPS_DllAPI XMLP_ret fillParticipantAttributes(const std::string &profile_name, ParticipantAttributes &atts, bool log_error=true)
Search for the profile specified and fill the structure.
static RTPS_DllAPI void library_settings(const LibrarySettingsAttributes &library_settings)
Library settings setter.
static RTPS_DllAPI void getDefaultTopicAttributes(TopicAttributes &topic_attributes)
Fills topic_attributes with the default values.
static RTPS_DllAPI XMLP_ret fillTopicAttributes(const std::string &profile_name, TopicAttributes &atts)
Search for the profile specified and fill the structure.
static RTPS_DllAPI void getDefaultParticipantAttributes(ParticipantAttributes &participant_attributes)
Fills participant_attributes with the default values.
static RTPS_DllAPI XMLP_ret loadXMLNode(tinyxml2::XMLDocument &doc)
Load a profiles XML node.
static RTPS_DllAPI types::DynamicPubSubType * CreateDynamicPubSubType(const std::string &type_name)
Retrieves a DynamicPubSubType for the given dynamic type name.
static RTPS_DllAPI XMLP_ret fillReplierAttributes(const std::string &profile_name, ReplierAttributes &atts)
Search for the profile specified and fill the structure.
static RTPS_DllAPI bool insertTransportById(const std::string &transport_id, sp_transport_t transport)
Add a new transport instance along with its id.
static RTPS_DllAPI bool insertDynamicTypeByName(const std::string &type_name, p_dynamictypebuilder_t type)
Add a new dynamic type instance along with its name.
static RTPS_DllAPI void loadDefaultXMLFile()
Load the default profiles XML file.
static RTPS_DllAPI void getDefaultPublisherAttributes(PublisherAttributes &publisher_attributes)
Fills publisher_attributes with the default values.
static RTPS_DllAPI XMLP_ret loadXMLDynamicTypes(tinyxml2::XMLElement &types)
Load a dynamic types XML node.
static RTPS_DllAPI void getDefaultSubscriberAttributes(SubscriberAttributes &subscriber_attributes)
Fills subscriber_attributes with the default values.
static RTPS_DllAPI XMLP_ret fillPublisherAttributes(const std::string &profile_name, PublisherAttributes &atts, bool log_error=true)
Search for the profile specified and fill the structure.
static RTPS_DllAPI const LibrarySettingsAttributes & library_settings()
Library settings getter.
static RTPS_DllAPI void DeleteDynamicPubSubType(types::DynamicPubSubType *type)
Deletes the given DynamicPubSubType previously created by calling XMLProfileManager::CreateDynamicPub...
static RTPS_DllAPI XMLP_ret fillDomainParticipantFactoryQos(const std::string &profile_name, fastdds::dds::DomainParticipantFactoryQos &qos, bool log_error=true)
Search for the profile specified and fill the structure.
static RTPS_DllAPI XMLP_ret fillRequesterAttributes(const std::string &profile_name, RequesterAttributes &atts)
Search for the profile specified and fill the structure.
static RTPS_DllAPI XMLP_ret loadXMLString(const char *data, size_t length)
Load a profiles XML string.
static RTPS_DllAPI XMLP_ret loadXMLFile(const std::string &filename)
Load a profiles XML file.
static RTPS_DllAPI void DeleteInstance()
Deletes the XMLProfileManager instance.
static RTPS_DllAPI XMLP_ret fillSubscriberAttributes(const std::string &profile_name, SubscriberAttributes &atts, bool log_error=true)
Search for the profile specified and fill the structure.
static RTPS_DllAPI sp_transport_t getTransportById(const std::string &transport_id)
Retrieves a transport instance by its id.
static RTPS_DllAPI void getDefaultDomainParticipantFactoryQos(fastdds::dds::DomainParticipantFactoryQos &qos)
Fills input domain participant factory qos with the default values.
static RTPS_DllAPI XMLP_ret loadXMLProfiles(tinyxml2::XMLElement &profiles)
Load a profiles XML node.
static RTPS_DllAPI p_dynamictypebuilder_t getDynamicTypeByName(const std::string &type_name)
Retrieves a transport instance by its name.
XMLP_ret
Enum class XMLP_ret, used to provide a strongly typed result from the operations within this module.
Definition XMLParserCommon.h:27
topic_map_t::iterator topic_map_iterator_t
Definition XMLProfileManager.h:45
std::map< std::string, up_participantfactory_t > participant_factory_map_t
Definition XMLProfileManager.h:36
replier_map_t::iterator replier_map_iterator_t
Definition XMLProfileManager.h:49
std::map< std::string, up_participant_t > participant_map_t
Definition XMLProfileManager.h:38
participant_factory_map_t::iterator part_factory_map_iterator_t
Definition XMLProfileManager.h:37
std::map< std::string, sp_transport_t > sp_transport_map_t
Definition XMLParser.h:58
std::shared_ptr< fastdds::rtps::TransportDescriptorInterface > sp_transport_t
Definition XMLParser.h:57
std::map< std::string, up_publisher_t > publisher_map_t
Definition XMLProfileManager.h:40
std::map< std::string, up_subscriber_t > subscriber_map_t
Definition XMLProfileManager.h:42
std::map< std::string, XMLP_ret > xmlfiles_map_t
Definition XMLProfileManager.h:50
std::map< std::string, up_topic_t > topic_map_t
Definition XMLProfileManager.h:44
xmlfiles_map_t::iterator xmlfile_map_iterator_t
Definition XMLProfileManager.h:51
std::map< std::string, up_requester_t > requester_map_t
Definition XMLProfileManager.h:46
std::map< std::string, p_dynamictypebuilder_t > p_dynamictype_map_t
Definition XMLParser.h:60
requester_map_t::iterator requester_map_iterator_t
Definition XMLProfileManager.h:47
std::map< std::string, up_replier_t > replier_map_t
Definition XMLProfileManager.h:48
std::unique_ptr< BaseNode > up_base_node_t
Definition XMLParser.h:51
participant_map_t::iterator part_map_iterator_t
Definition XMLProfileManager.h:39
publisher_map_t::iterator publ_map_iterator_t
Definition XMLProfileManager.h:41
subscriber_map_t::iterator subs_map_iterator_t
Definition XMLProfileManager.h:43
eProsima namespace.
Definition LibrarySettingsAttributes.h:23