Fast RTPS  Version 2.1.0
Fast RTPS
Domain.h
1 // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
20 #ifndef DOMAIN_H_
21 #define DOMAIN_H_
22 
23 #include <fastdds/dds/topic/TopicDataType.hpp>
24 #include <fastrtps/attributes/ParticipantAttributes.h>
25 #include <mutex>
26 
27 #ifdef USE_DEPRECATION
28 #if defined(__GNUC__) || defined(__clang__)
29 #define DEPRECATED __attribute__ ((deprecated))
30 #elif defined(_MSC_VER)
31 #define DEPRECATED __declspec(deprecated)
32 #else
33 #define DEPRECATED
34 #endif
35 #else
36 #define DEPRECATED
37 #endif
38 
39 namespace eprosima{
40 namespace fastrtps{
41 
42 class ParticipantListener;
43 class Participant;
44 class ParticipantImpl;
45 class Publisher;
46 class PublisherAttributes;
47 class PublisherListener;
48 class Subscriber;
49 class SubscriberAttributes;
50 class SubscriberListener;
51 
52 namespace types{
53 class DynamicPubSubType;
54 }
55 
60 class Domain
61 {
62  public:
69  RTPS_DllAPI DEPRECATED static Participant* createParticipant(
70  const std::string& participant_profile,
71  ParticipantListener* listen = nullptr);
72 
79  RTPS_DllAPI DEPRECATED static Participant* createParticipant(
80  const ParticipantAttributes& att,
81  ParticipantListener* listen = nullptr);
82 
84  RTPS_DllAPI static void getDefaultParticipantAttributes(ParticipantAttributes& participant_attributes);
85 
93  RTPS_DllAPI static Publisher* createPublisher(
94  Participant* part,
95  const std::string& publisher_profile,
96  PublisherListener* listen = nullptr);
97 
105  RTPS_DllAPI static Publisher* createPublisher(
106  Participant* part,
107  const PublisherAttributes& att,
108  PublisherListener* listen = nullptr);
109 
111  RTPS_DllAPI static void getDefaultPublisherAttributes(PublisherAttributes& publisher_attributes);
112 
120  RTPS_DllAPI static Subscriber* createSubscriber(
121  Participant* part,
122  const std::string& subscriber_profile,
123  SubscriberListener* listen = nullptr);
124 
132  RTPS_DllAPI static Subscriber* createSubscriber(
133  Participant* part,
134  const SubscriberAttributes& att,
135  SubscriberListener* listen = nullptr);
136 
138  RTPS_DllAPI static void getDefaultSubscriberAttributes(SubscriberAttributes& subscriber_attributes);
139 
145  RTPS_DllAPI static bool removeParticipant(Participant* part);
146 
152  RTPS_DllAPI static bool removePublisher(Publisher* pub);
153 
159  RTPS_DllAPI static bool removeSubscriber(Subscriber* sub);
160 
168  RTPS_DllAPI static bool getRegisteredType(
169  Participant* part,
170  const char* typeName,
171  fastdds::dds::TopicDataType** type);
172 
179  RTPS_DllAPI static bool registerType(
180  Participant* part,
181  fastdds::dds::TopicDataType * type);
182 
189  RTPS_DllAPI static bool registerDynamicType(
190  Participant* part,
192 
199  RTPS_DllAPI static bool unregisterType(
200  Participant* part,
201  const char* typeName);
202 
206  RTPS_DllAPI static void stopAll();
207 
213  RTPS_DllAPI static bool loadXMLProfilesFile(const std::string& xml_profile_file);
214 
215  private:
216 
217  typedef std::pair<Participant*,ParticipantImpl*> t_p_Participant;
218 
219  Domain();
220 
221  virtual ~Domain();
222 
223  static std::mutex m_mutex;
224 
225  static std::vector<t_p_Participant> m_participants;
226 
227  static bool default_xml_profiles_loaded;
228 };
229 
230 } /* namespace */
231 } /* namespace eprosima */
232 
233 #endif /* DOMAIN_H_ */
eprosima::fastrtps::Domain::createSubscriber
static RTPS_DllAPI Subscriber * createSubscriber(Participant *part, const std::string &subscriber_profile, SubscriberListener *listen=nullptr)
Create a Subscriber in a Participant from a profile name.
eprosima::fastrtps::Domain::getRegisteredType
static RTPS_DllAPI bool getRegisteredType(Participant *part, const char *typeName, fastdds::dds::TopicDataType **type)
Return a registered type.
eprosima::fastrtps::Publisher
Class Publisher, used to send data to associated subscribers.
Definition: Publisher.h:47
eprosima::fastrtps::Domain::createParticipant
RTPS_DllAPI static DEPRECATED Participant * createParticipant(const std::string &participant_profile, ParticipantListener *listen=nullptr)
Create a Participant from a profile name.
eprosima::fastrtps::ParticipantAttributes
Class ParticipantAttributes, used by the user to define the attributes of a Participant.
Definition: ParticipantAttributes.h:35
eprosima::fastrtps::Domain::loadXMLProfilesFile
static RTPS_DllAPI bool loadXMLProfilesFile(const std::string &xml_profile_file)
Load profiles from XML file.
eprosima::fastrtps::Domain::createSubscriber
static RTPS_DllAPI Subscriber * createSubscriber(Participant *part, const SubscriberAttributes &att, SubscriberListener *listen=nullptr)
Create a Subscriber in a Participant.
eprosima::fastrtps::Domain::getDefaultPublisherAttributes
static RTPS_DllAPI void getDefaultPublisherAttributes(PublisherAttributes &publisher_attributes)
Fills publisher_attributes with the default values.
eprosima::fastrtps::ParticipantListener
Class ParticipantListener, overrides behaviour towards certain events.
Definition: ParticipantListener.h:37
eprosima::fastrtps::Domain::removeSubscriber
static RTPS_DllAPI bool removeSubscriber(Subscriber *sub)
Remove a Subscriber.
eprosima::fastrtps::PublisherAttributes
Class PublisherAttributes, used by the user to define the attributes of a Publisher.
Definition: PublisherAttributes.h:40
eprosima::fastrtps::Domain::createPublisher
static RTPS_DllAPI Publisher * createPublisher(Participant *part, const PublisherAttributes &att, PublisherListener *listen=nullptr)
Create a Publisher in a Participant.
eprosima::fastrtps::types::DynamicPubSubType
Definition: DynamicPubSubType.h:29
eprosima::fastrtps::Domain::getDefaultSubscriberAttributes
static RTPS_DllAPI void getDefaultSubscriberAttributes(SubscriberAttributes &subscriber_attributes)
Fills subscriber_attributes with the default values.
eprosima::fastrtps::Domain::unregisterType
static RTPS_DllAPI bool unregisterType(Participant *part, const char *typeName)
Unregister a type in a participant.
eprosima::fastrtps::SubscriberListener
Class SubscriberListener, it should be used by the end user to implement specific callbacks to certai...
Definition: SubscriberListener.h:41
eprosima::fastrtps::Subscriber
Class Subscriber, contains the public API that allows the user to control the reception of messages.
Definition: Subscriber.h:43
eprosima::fastrtps::Domain
Class Domain, use to interact with the Publisher Subscriber API of the Fast RTPS implementation.
Definition: Domain.h:61
eprosima::fastrtps::Domain::createParticipant
RTPS_DllAPI static DEPRECATED Participant * createParticipant(const ParticipantAttributes &att, ParticipantListener *listen=nullptr)
Create a Participant.
eprosima::fastrtps::PublisherListener
Class PublisherListener, allows the end user to implement callbacks triggered by certain events.
Definition: PublisherListener.h:37
eprosima::fastrtps::Participant
Class Participant used to group Publishers and Subscribers into a single working unit.
Definition: Participant.h:47
eprosima::fastrtps::Domain::removeParticipant
static RTPS_DllAPI bool removeParticipant(Participant *part)
Remove a Participant and all associated publishers and subscribers.
eprosima::fastrtps::Domain::removePublisher
static RTPS_DllAPI bool removePublisher(Publisher *pub)
Remove a Publisher.
eprosima::fastrtps::Domain::getDefaultParticipantAttributes
static RTPS_DllAPI void getDefaultParticipantAttributes(ParticipantAttributes &participant_attributes)
Fills participant_attributes with the default values.
eprosima::fastrtps::Domain::stopAll
static RTPS_DllAPI void stopAll()
Stop and remove all participants, publishers and subscribers in this Domain.
eprosima::fastrtps::Domain::registerType
static RTPS_DllAPI bool registerType(Participant *part, fastdds::dds::TopicDataType *type)
Register a type in a participant.
eprosima::fastrtps::Domain::createPublisher
static RTPS_DllAPI Publisher * createPublisher(Participant *part, const std::string &publisher_profile, PublisherListener *listen=nullptr)
Create a Publisher in a Participant from a profile name.
eprosima
eProsima namespace.
Definition: LibrarySettingsAttributes.h:23
eprosima::fastrtps::SubscriberAttributes
Class SubscriberAttributes, used by the user to define the attributes of a Subscriber.
Definition: SubscriberAttributes.h:41
eprosima::fastrtps::Domain::registerDynamicType
static RTPS_DllAPI bool registerDynamicType(Participant *part, types::DynamicPubSubType *type)
Register a type in a participant.