Fast DDS  Version 3.6.1.0
Fast DDS
DomainParticipantFactory.hpp
1 // Copyright 2019 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 
20 #ifndef FASTDDS_DDS_DOMAIN__DOMAINPARTICIPANTFACTORY_HPP
21 #define FASTDDS_DDS_DOMAIN__DOMAINPARTICIPANTFACTORY_HPP
22 
23 #include <map>
24 #include <memory>
25 #include <mutex>
26 
27 #include <fastdds/dds/core/ReturnCode.hpp>
28 #include <fastdds/dds/core/status/StatusMask.hpp>
29 #include <fastdds/dds/domain/qos/DomainParticipantExtendedQos.hpp>
30 #include <fastdds/dds/domain/qos/DomainParticipantFactoryQos.hpp>
31 #include <fastdds/dds/domain/qos/DomainParticipantQos.hpp>
32 #include <fastdds/dds/xtypes/dynamic_types/DynamicType.hpp>
33 #include <fastdds/dds/xtypes/dynamic_types/DynamicTypeBuilder.hpp>
34 #include <fastdds/dds/xtypes/type_representation/ITypeObjectRegistry.hpp>
35 #include <fastdds/LibrarySettings.hpp>
36 
37 namespace eprosima {
38 
39 namespace fastdds {
40 namespace rtps {
41 
42 class IDomainImpl;
43 
44 namespace detail {
45 class TopicPayloadPoolRegistry;
46 } // namespace detail
47 } // namespace rtps
48 
49 namespace dds {
50 
51 class DomainParticipantListener;
52 class DomainParticipant;
53 class DomainParticipantImpl;
54 
61 {
62 
63 public:
64 
70  FASTDDS_EXPORTED_API static DomainParticipantFactory* get_instance();
71 
77  FASTDDS_EXPORTED_API static std::shared_ptr<DomainParticipantFactory> get_shared_instance();
78 
88  FASTDDS_EXPORTED_API DomainParticipant* create_participant(
89  DomainId_t domain_id,
90  const DomainParticipantQos& qos,
91  DomainParticipantListener* listener = nullptr,
92  const StatusMask& mask = StatusMask::all());
93 
102  FASTDDS_EXPORTED_API DomainParticipant* create_participant(
103  const DomainParticipantExtendedQos& extended_qos,
104  DomainParticipantListener* listener = nullptr,
105  const StatusMask& mask = StatusMask::all());
106 
113 
114 
123  DomainParticipantListener* listener,
124  const StatusMask& mask);
125 
136  DomainId_t domain_id,
137  const std::string& profile_name,
138  DomainParticipantListener* listener = nullptr,
139  const StatusMask& mask = StatusMask::all());
140 
150  const std::string& profile_name,
151  DomainParticipantListener* listener = nullptr,
152  const StatusMask& mask = StatusMask::all());
153 
163  FASTDDS_EXPORTED_API DomainParticipant* lookup_participant(
164  DomainId_t domain_id) const;
165 
172  FASTDDS_EXPORTED_API std::vector<DomainParticipant*> lookup_participants(
173  DomainId_t domain_id) const;
174 
186  DomainParticipantQos& qos) const;
187 
197  FASTDDS_EXPORTED_API const DomainParticipantQos& get_default_participant_qos() const;
198 
215  const DomainParticipantQos& qos);
216 
225  const std::string& profile_name,
226  DomainParticipantQos& qos) const;
227 
236  const std::string& xml,
237  DomainParticipantQos& qos) const;
238 
248  const std::string& xml,
250  const std::string& profile_name) const;
251 
262  const std::string& xml,
263  DomainParticipantQos& qos) const;
264 
273  const std::string& profile_name,
274  DomainParticipantExtendedQos& extended_qos) const;
275 
284  const std::string& xml,
285  DomainParticipantExtendedQos& extended_qos) const;
286 
296  const std::string& xml,
297  DomainParticipantExtendedQos& extended_qos,
298  const std::string& profile_name) const;
299 
310  const std::string& xml,
311  DomainParticipantExtendedQos& extended_qos) const;
312 
320  DomainParticipantExtendedQos& extended_qos) const;
321 
329  FASTDDS_EXPORTED_API ReturnCode_t delete_participant(
330  DomainParticipant* part);
331 
337  FASTDDS_EXPORTED_API ReturnCode_t load_profiles();
338 
345  FASTDDS_EXPORTED_API ReturnCode_t load_XML_profiles_file(
346  const std::string& xml_profile_file);
347 
356  const char* data,
357  size_t length);
358 
366  std::string& xml_file);
367 
374  FASTDDS_EXPORTED_API ReturnCode_t get_qos(
375  DomainParticipantFactoryQos& qos) const;
376 
390  FASTDDS_EXPORTED_API ReturnCode_t set_qos(
391  const DomainParticipantFactoryQos& qos);
392 
399  FASTDDS_EXPORTED_API ReturnCode_t get_library_settings(
400  LibrarySettings& library_settings) const;
401 
412  FASTDDS_EXPORTED_API ReturnCode_t set_library_settings(
413  const LibrarySettings& library_settings);
414 
426  const std::string& type_name,
428 
435 
436 protected:
437 
438  friend class DomainParticipant;
439 
440  std::map<DomainId_t, std::vector<DomainParticipantImpl*>> participants_;
441 
443 
445 
447  const DomainParticipantFactory&) = delete;
448 
450  const DomainParticipantFactory&) = delete;
451 
453 
454  static void set_qos(
456  const DomainParticipantFactoryQos& from,
457  bool first_time);
458 
460  const DomainParticipantFactoryQos& qos);
461 
462  static bool can_qos_be_updated(
463  const DomainParticipantFactoryQos& to,
464  const DomainParticipantFactoryQos& from);
465 
467  DomainParticipantImpl* part);
468 
469  mutable std::mutex mtx_participants_;
470 
472 
474 
476 
478 
479  std::shared_ptr<fastdds::rtps::detail::TopicPayloadPoolRegistry> topic_pool_;
480 
481  std::shared_ptr<fastdds::rtps::IDomainImpl> rtps_domain_;
482 
489 };
490 
491 } // namespace dds
492 } // namespace fastdds
493 } // namespace eprosima
494 
495 #endif // FASTDDS_DDS_DOMAIN__DOMAINPARTICIPANTFACTORY_HPP
Class LibraySettings, used by the user to define the Fast DDS library behaviour.
Definition: LibrarySettings.hpp:38
Definition: DomainParticipantExtendedQos.hpp:32
Class DomainParticipantFactory.
Definition: DomainParticipantFactory.hpp:61
FASTDDS_EXPORTED_API DomainParticipant * create_participant(const DomainParticipantExtendedQos &extended_qos, DomainParticipantListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
Create a Participant.
static void set_qos(DomainParticipantFactoryQos &to, const DomainParticipantFactoryQos &from, bool first_time)
bool default_xml_profiles_loaded
Definition: DomainParticipantFactory.hpp:471
std::shared_ptr< fastdds::rtps::detail::TopicPayloadPoolRegistry > topic_pool_
Definition: DomainParticipantFactory.hpp:479
static FASTDDS_EXPORTED_API std::shared_ptr< DomainParticipantFactory > get_shared_instance()
Returns the DomainParticipantFactory singleton instance.
std::shared_ptr< fastdds::rtps::IDomainImpl > rtps_domain_
Definition: DomainParticipantFactory.hpp:481
FASTDDS_EXPORTED_API DomainParticipant * lookup_participant(DomainId_t domain_id) const
This operation retrieves a previously created DomainParticipant belonging to specified domain_id.
DomainParticipantFactory(const DomainParticipantFactory &)=delete
FASTDDS_EXPORTED_API ReturnCode_t set_library_settings(const LibrarySettings &library_settings)
This operation sets the library settings.
FASTDDS_EXPORTED_API ReturnCode_t set_qos(const DomainParticipantFactoryQos &qos)
This operation sets the value of the DomainParticipantFactory QoS policies.
void operator=(const DomainParticipantFactory &)=delete
FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml(const std::string &xml, DomainParticipantExtendedQos &extended_qos, const std::string &profile_name) const
Fills the DomainParticipantExtendedQos with the DomainParticipant profile with profile_name to be fou...
FASTDDS_EXPORTED_API ReturnCode_t get_library_settings(LibrarySettings &library_settings) const
This operation returns the value of the DomainParticipant library settings.
std::mutex default_xml_profiles_loaded_mtx_
This mutex guards the access to load the profiles.
Definition: DomainParticipantFactory.hpp:488
FASTDDS_EXPORTED_API ReturnCode_t get_qos(DomainParticipantFactoryQos &qos) const
This operation returns the value of the DomainParticipantFactory QoS policies.
FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_qos_from_xml(const std::string &xml, DomainParticipantQos &qos) const
Fills the DomainParticipantQos with the default DomainParticipant profile found in the provided XML (...
static FASTDDS_EXPORTED_API DomainParticipantFactory * get_instance()
Returns the DomainParticipantFactory singleton instance.
FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml(const std::string &xml, DomainParticipantQos &qos) const
Fills the DomainParticipantQos with the first DomainParticipant profile found in the provided XML.
FASTDDS_EXPORTED_API DomainParticipant * create_participant(DomainId_t domain_id, const DomainParticipantQos &qos, DomainParticipantListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
Create a Participant.
FASTDDS_EXPORTED_API ReturnCode_t load_XML_profiles_file(const std::string &xml_profile_file)
Load profiles from XML file.
std::mutex mtx_participants_
Definition: DomainParticipantFactory.hpp:469
std::map< DomainId_t, std::vector< DomainParticipantImpl * > > participants_
Definition: DomainParticipantFactory.hpp:440
FASTDDS_EXPORTED_API std::vector< DomainParticipant * > lookup_participants(DomainId_t domain_id) const
Returns all participants that belongs to the specified domain_id.
DomainParticipantQos default_participant_qos_
Definition: DomainParticipantFactory.hpp:477
FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_xml(const std::string &xml, DomainParticipantQos &qos, const std::string &profile_name) const
Fills the DomainParticipantQos with the DomainParticipant profile with profile_name to be found in th...
FASTDDS_EXPORTED_API ReturnCode_t set_default_participant_qos(const DomainParticipantQos &qos)
This operation sets a default value of the DomainParticipant QoS policies which will be used for newl...
FASTDDS_EXPORTED_API DomainParticipant * create_participant_with_default_profile()
Create a Participant with default domain id and qos.
DomainParticipantFactoryQos factory_qos_
Definition: DomainParticipantFactory.hpp:475
FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_default_profile(DomainParticipantExtendedQos &extended_qos) const
Fills the DomainParticipantExtendedQos with the values of the default XML profile.
FASTDDS_EXPORTED_API ReturnCode_t get_dynamic_type_builder_from_xml_by_name(const std::string &type_name, DynamicTypeBuilder::_ref_type &type)
Get the DynamicType defined in XML file.
FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_qos(DomainParticipantQos &qos) const
This operation retrieves the default value of the DomainParticipant QoS, that is, the QoS policies wh...
FASTDDS_EXPORTED_API ReturnCode_t get_participant_qos_from_profile(const std::string &profile_name, DomainParticipantQos &qos) const
Fills the DomainParticipantQos with the values of the XML profile.
void participant_has_been_deleted(DomainParticipantImpl *part)
FASTDDS_EXPORTED_API ReturnCode_t load_XML_profiles_string(const char *data, size_t length)
Load profiles from XML string.
static bool can_qos_be_updated(const DomainParticipantFactoryQos &to, const DomainParticipantFactoryQos &from)
FASTDDS_EXPORTED_API ReturnCode_t get_default_participant_extended_qos_from_xml(const std::string &xml, DomainParticipantExtendedQos &extended_qos) const
Fills the DomainParticipantExtendedQos with the default DomainParticipant profile found in the provid...
FASTDDS_EXPORTED_API ReturnCode_t delete_participant(DomainParticipant *part)
Remove a Participant and all associated publishers and subscribers.
DomainId_t default_domain_id_
Definition: DomainParticipantFactory.hpp:473
FASTDDS_EXPORTED_API xtypes::ITypeObjectRegistry & type_object_registry()
Return the TypeObjectRegistry member to access the public API.
FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_xml(const std::string &xml, DomainParticipantExtendedQos &extended_qos) const
Fills the DomainParticipantExtendedQos with the first DomainParticipant profile found in the provided...
FASTDDS_EXPORTED_API const DomainParticipantQos & get_default_participant_qos() const
This operation retrieves the default value of the DomainParticipant QoS, that is, the QoS policies wh...
FASTDDS_EXPORTED_API ReturnCode_t load_profiles()
Load profiles from default XML file.
FASTDDS_EXPORTED_API DomainParticipant * create_participant_with_profile(const std::string &profile_name, DomainParticipantListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
Create a Participant.
FASTDDS_EXPORTED_API ReturnCode_t check_xml_static_discovery(std::string &xml_file)
Check the validity of the provided static discovery XML file.
FASTDDS_EXPORTED_API DomainParticipant * create_participant_with_profile(DomainId_t domain_id, const std::string &profile_name, DomainParticipantListener *listener=nullptr, const StatusMask &mask=StatusMask::all())
Create a Participant.
static ReturnCode_t check_qos(const DomainParticipantFactoryQos &qos)
FASTDDS_EXPORTED_API ReturnCode_t get_participant_extended_qos_from_profile(const std::string &profile_name, DomainParticipantExtendedQos &extended_qos) const
Fills the DomainParticipantExtendedQos with the values of the XML profile.
FASTDDS_EXPORTED_API DomainParticipant * create_participant_with_default_profile(DomainParticipantListener *listener, const StatusMask &mask)
Create a Participant with default domain id and qos.
Class DomainParticipantFactoryQos, contains all the possible Qos that can be set for a determined par...
Definition: DomainParticipantFactoryQos.hpp:37
Class DomainParticipant used to group Publishers and Subscribers into a single working unit.
Definition: DomainParticipant.hpp:86
Class DomainParticipantListener, overrides behaviour towards certain events.
Definition: DomainParticipantListener.hpp:49
Class DomainParticipantQos, contains all the possible Qos that can be set for a determined participan...
Definition: DomainParticipantQos.hpp:42
typename traits< DynamicTypeBuilder >::ref_type _ref_type
Definition: DynamicTypeBuilder.hpp:35
StatusMask is a bitmap or bitset field.
Definition: StatusMask.hpp:48
static StatusMask all()
Get all StatusMasks.
Definition: StatusMask.hpp:104
Definition: ITypeObjectRegistry.hpp:45
Definition: DomainParticipant.hpp:46
uint32_t DomainId_t
Definition: Types.hpp:24
int32_t ReturnCode_t
Definition: DDSReturnCode.hpp:59