/src/Fast-DDS/src/cpp/fastdds/publisher/Publisher.cpp
Line | Count | Source |
1 | | // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima). |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // http://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | /** |
16 | | * @file Publisher.cpp |
17 | | * |
18 | | */ |
19 | | |
20 | | #include <fastdds/dds/domain/DomainParticipant.hpp> |
21 | | #include <fastdds/dds/publisher/Publisher.hpp> |
22 | | #include <fastdds/publisher/PublisherImpl.hpp> |
23 | | |
24 | | #include <fastdds/dds/log/Log.hpp> |
25 | | |
26 | | namespace eprosima { |
27 | | namespace fastdds { |
28 | | namespace dds { |
29 | | |
30 | | Publisher::Publisher( |
31 | | PublisherImpl* p, |
32 | | const StatusMask& mask) |
33 | 0 | : DomainEntity(mask) |
34 | 0 | , impl_(p) |
35 | 0 | { |
36 | 0 | } |
37 | | |
38 | | Publisher::Publisher( |
39 | | DomainParticipant* dp, |
40 | | const PublisherQos& qos, |
41 | | PublisherListener* listener, |
42 | | const StatusMask& mask) |
43 | 0 | : DomainEntity(mask) |
44 | 0 | , impl_(dp->create_publisher(qos, listener, mask)->impl_) |
45 | 0 | { |
46 | 0 | } |
47 | | |
48 | | Publisher::~Publisher() |
49 | 0 | { |
50 | 0 | } |
51 | | |
52 | | ReturnCode_t Publisher::enable() |
53 | 0 | { |
54 | 0 | if (enable_) |
55 | 0 | { |
56 | 0 | return RETCODE_OK; |
57 | 0 | } |
58 | | |
59 | 0 | if (false == impl_->get_participant()->is_enabled()) |
60 | 0 | { |
61 | 0 | return RETCODE_PRECONDITION_NOT_MET; |
62 | 0 | } |
63 | | |
64 | 0 | enable_ = true; |
65 | 0 | ReturnCode_t ret_code = impl_->enable(); |
66 | 0 | enable_ = RETCODE_OK == ret_code; |
67 | 0 | return ret_code; |
68 | 0 | } |
69 | | |
70 | | const PublisherQos& Publisher::get_qos() const |
71 | 0 | { |
72 | 0 | return impl_->get_qos(); |
73 | 0 | } |
74 | | |
75 | | ReturnCode_t Publisher::get_qos( |
76 | | PublisherQos& qos) const |
77 | 0 | { |
78 | 0 | qos = impl_->get_qos(); |
79 | 0 | return RETCODE_OK; |
80 | 0 | } |
81 | | |
82 | | ReturnCode_t Publisher::set_qos( |
83 | | const PublisherQos& qos) |
84 | 0 | { |
85 | 0 | return impl_->set_qos(qos); |
86 | 0 | } |
87 | | |
88 | | const PublisherListener* Publisher::get_listener() const |
89 | 0 | { |
90 | 0 | return impl_->get_listener(); |
91 | 0 | } |
92 | | |
93 | | ReturnCode_t Publisher::set_listener( |
94 | | PublisherListener* listener) |
95 | 0 | { |
96 | 0 | return set_listener(listener, StatusMask::all()); |
97 | 0 | } |
98 | | |
99 | | ReturnCode_t Publisher::set_listener( |
100 | | PublisherListener* listener, |
101 | | const StatusMask& mask) |
102 | 0 | { |
103 | 0 | ReturnCode_t ret_val = impl_->set_listener(listener); |
104 | 0 | if (ret_val == RETCODE_OK) |
105 | 0 | { |
106 | 0 | status_mask_ = mask; |
107 | 0 | } |
108 | |
|
109 | 0 | return ret_val; |
110 | 0 | } |
111 | | |
112 | | DataWriter* Publisher::create_datawriter( |
113 | | Topic* topic, |
114 | | const DataWriterQos& qos, |
115 | | DataWriterListener* listener, |
116 | | const StatusMask& mask, |
117 | | std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool) |
118 | 0 | { |
119 | 0 | return impl_->create_datawriter(topic, qos, listener, mask, payload_pool); |
120 | 0 | } |
121 | | |
122 | | DataWriter* Publisher::create_datawriter_with_profile( |
123 | | Topic* topic, |
124 | | const std::string& profile_name, |
125 | | DataWriterListener* listener, |
126 | | const StatusMask& mask, |
127 | | std::shared_ptr<fastdds::rtps::IPayloadPool> payload_pool) |
128 | 0 | { |
129 | 0 | return impl_->create_datawriter_with_profile(topic, profile_name, listener, mask, payload_pool); |
130 | 0 | } |
131 | | |
132 | | ReturnCode_t Publisher::delete_datawriter( |
133 | | const DataWriter* writer) |
134 | 0 | { |
135 | 0 | return impl_->delete_datawriter(writer); |
136 | 0 | } |
137 | | |
138 | | DataWriter* Publisher::lookup_datawriter( |
139 | | const std::string& topic_name) const |
140 | 0 | { |
141 | 0 | return impl_->lookup_datawriter(topic_name); |
142 | 0 | } |
143 | | |
144 | | ReturnCode_t Publisher::suspend_publications() |
145 | 0 | { |
146 | 0 | return RETCODE_UNSUPPORTED; |
147 | | /* |
148 | | return impl_->suspend_publications(); |
149 | | */ |
150 | 0 | } |
151 | | |
152 | | ReturnCode_t Publisher::resume_publications() |
153 | 0 | { |
154 | 0 | return RETCODE_UNSUPPORTED; |
155 | | /* |
156 | | return impl_->resume_publications(); |
157 | | */ |
158 | 0 | } |
159 | | |
160 | | ReturnCode_t Publisher::begin_coherent_changes() |
161 | 0 | { |
162 | 0 | return RETCODE_UNSUPPORTED; |
163 | | /* |
164 | | return impl_->begin_coherent_changes(); |
165 | | */ |
166 | 0 | } |
167 | | |
168 | | ReturnCode_t Publisher::end_coherent_changes() |
169 | 0 | { |
170 | 0 | return RETCODE_UNSUPPORTED; |
171 | | /* |
172 | | return impl_->end_coherent_changes(); |
173 | | */ |
174 | 0 | } |
175 | | |
176 | | ReturnCode_t Publisher::wait_for_acknowledgments( |
177 | | const fastdds::dds::Duration_t& max_wait) |
178 | 0 | { |
179 | 0 | return impl_->wait_for_acknowledgments(max_wait); |
180 | 0 | } |
181 | | |
182 | | const DomainParticipant* Publisher::get_participant() const |
183 | 0 | { |
184 | 0 | return impl_->get_participant(); |
185 | 0 | } |
186 | | |
187 | | ReturnCode_t Publisher::delete_contained_entities() |
188 | 0 | { |
189 | 0 | return impl_->delete_contained_entities(); |
190 | 0 | } |
191 | | |
192 | | ReturnCode_t Publisher::set_default_datawriter_qos( |
193 | | const DataWriterQos& qos) |
194 | 0 | { |
195 | 0 | return impl_->set_default_datawriter_qos(qos); |
196 | 0 | } |
197 | | |
198 | | const DataWriterQos& Publisher::get_default_datawriter_qos() const |
199 | 0 | { |
200 | 0 | return impl_->get_default_datawriter_qos(); |
201 | 0 | } |
202 | | |
203 | | ReturnCode_t Publisher::get_default_datawriter_qos( |
204 | | DataWriterQos& qos) const |
205 | 0 | { |
206 | 0 | qos = impl_->get_default_datawriter_qos(); |
207 | 0 | return RETCODE_OK; |
208 | 0 | } |
209 | | |
210 | | ReturnCode_t Publisher::copy_from_topic_qos( |
211 | | fastdds::dds::DataWriterQos& writer_qos, |
212 | | const fastdds::dds::TopicQos& topic_qos) |
213 | 0 | { |
214 | 0 | return PublisherImpl::copy_from_topic_qos(writer_qos, topic_qos); |
215 | 0 | } |
216 | | |
217 | | const fastdds::rtps::InstanceHandle_t& Publisher::get_instance_handle() const |
218 | 0 | { |
219 | 0 | return impl_->get_instance_handle(); |
220 | 0 | } |
221 | | |
222 | | bool Publisher::get_datawriters( |
223 | | std::vector<DataWriter*>& writers) const |
224 | 0 | { |
225 | 0 | return impl_->get_datawriters(writers); |
226 | 0 | } |
227 | | |
228 | | bool Publisher::has_datawriters() const |
229 | 0 | { |
230 | 0 | return impl_->has_datawriters(); |
231 | 0 | } |
232 | | |
233 | | ReturnCode_t Publisher::get_datawriter_qos_from_profile( |
234 | | const std::string& profile_name, |
235 | | DataWriterQos& qos) const |
236 | 0 | { |
237 | 0 | return impl_->get_datawriter_qos_from_profile(profile_name, qos); |
238 | 0 | } |
239 | | |
240 | | ReturnCode_t Publisher::get_datawriter_qos_from_profile( |
241 | | const std::string& profile_name, |
242 | | DataWriterQos& qos, |
243 | | std::string& topic_name) const |
244 | 0 | { |
245 | 0 | return impl_->get_datawriter_qos_from_profile(profile_name, qos, topic_name); |
246 | 0 | } |
247 | | |
248 | | ReturnCode_t Publisher::get_datawriter_qos_from_xml( |
249 | | const std::string& xml, |
250 | | DataWriterQos& qos) const |
251 | 0 | { |
252 | 0 | return impl_->get_datawriter_qos_from_xml(xml, qos); |
253 | 0 | } |
254 | | |
255 | | ReturnCode_t Publisher::get_datawriter_qos_from_xml( |
256 | | const std::string& xml, |
257 | | DataWriterQos& qos, |
258 | | std::string& topic_name) const |
259 | 0 | { |
260 | 0 | return impl_->get_datawriter_qos_from_xml(xml, qos, topic_name); |
261 | 0 | } |
262 | | |
263 | | ReturnCode_t Publisher::get_datawriter_qos_from_xml( |
264 | | const std::string& xml, |
265 | | DataWriterQos& qos, |
266 | | const std::string& profile_name) const |
267 | 0 | { |
268 | 0 | return impl_->get_datawriter_qos_from_xml(xml, qos, profile_name); |
269 | 0 | } |
270 | | |
271 | | ReturnCode_t Publisher::get_datawriter_qos_from_xml( |
272 | | const std::string& xml, |
273 | | DataWriterQos& qos, |
274 | | std::string& topic_name, |
275 | | const std::string& profile_name) const |
276 | 0 | { |
277 | 0 | return impl_->get_datawriter_qos_from_xml(xml, qos, topic_name, profile_name); |
278 | 0 | } |
279 | | |
280 | | ReturnCode_t Publisher::get_default_datawriter_qos_from_xml( |
281 | | const std::string& xml, |
282 | | DataWriterQos& qos) const |
283 | 0 | { |
284 | 0 | return impl_->get_default_datawriter_qos_from_xml(xml, qos); |
285 | 0 | } |
286 | | |
287 | | ReturnCode_t Publisher::get_default_datawriter_qos_from_xml( |
288 | | const std::string& xml, |
289 | | DataWriterQos& qos, |
290 | | std::string& topic_name) const |
291 | 0 | { |
292 | 0 | return impl_->get_default_datawriter_qos_from_xml(xml, qos, topic_name); |
293 | 0 | } |
294 | | |
295 | | } // namespace dds |
296 | | } // namespace fastdds |
297 | | } // namespace eprosima |