21 #ifndef OSPL_DDS_TOPIC_TTOPIC_HPP_ 22 #define OSPL_DDS_TOPIC_TTOPIC_HPP_ 32 #include "org/opensplice/topic/TopicTraits.hpp" 33 #include "org/opensplice/topic/TopicListener.hpp" 53 const std::string& topic_name) :
54 ::
dds::core::Reference(new DELEGATE<T>(
58 dp.is_nil() ?
dds::topic::qos::TopicQos() : dp.default_topic_qos(),
60 dds::core::status::StatusMask::none()))
62 ISOCPP_REPORT_STACK_DDS_BEGIN(dp);
64 this->delegate()->init(this->impl_);
69 const std::string& topic_name,
75 dp.
is_nil() ?
dds::topic::
qos::TopicQos() : dp.default_topic_qos(),
77 dds::core::status::StatusMask::none())),
80 ISOCPP_REPORT_STACK_DDS_BEGIN(dp);
82 this->delegate()->init(this->impl_);
87 const std::string& topic_name,
100 ISOCPP_REPORT_STACK_DDS_BEGIN(dp);
102 this->delegate()->init(this->impl_);
105 template <
typename T>
107 const std::string& topic_name,
121 ISOCPP_REPORT_STACK_DDS_BEGIN(dp);
123 this->delegate()->init(this->impl_);
126 template <
typename T>
129 template <
typename T>
131 const ::dds::core::status::StatusMask& event_mask)
133 ISOCPP_REPORT_STACK_DDS_BEGIN(*
this);
135 this->delegate()->listener(listener, event_mask);
138 template <
typename T>
141 ISOCPP_REPORT_STACK_DDS_BEGIN(*
this);
143 return this->delegate()->listener();
166 #include <org/opensplice/core/ScopedLock.hpp> 168 template <
typename T>
170 const std::string&
name,
175 : org::opensplice::topic::TopicDescriptionDelegate(dp,
name,
type_name),
176 org::opensplice::topic::AnyTopicDelegate(qos, dp,
name,
type_name)
178 ISOCPP_REPORT_STACK_NC_BEGIN();
187 org::opensplice::topic::TopicDescriptionDelegate::myTypeName = org::opensplice::topic::TopicTraits<T>::getTypeName();
190 org::opensplice::topic::qos::TopicQosDelegate tQos = qos.delegate();
192 u_topicQos uTopicQos = tQos.u_qos();
193 u_participant uParticipant = participant->registerType(
194 org::opensplice::topic::TopicTraits<T>::getTypeName(),
195 org::opensplice::topic::TopicTraits<T>::getDescriptor(),
196 org::opensplice::topic::TopicTraits<T>::getDataRepresentationId(),
197 org::opensplice::topic::TopicTraits<T>::getTypeHash(),
198 org::opensplice::topic::TopicTraits<T>::getMetaData(),
199 org::opensplice::topic::TopicTraits<T>::getExtentions());
201 u_topic uTopic = u_topicNew(
204 org::opensplice::topic::TopicDescriptionDelegate::myTypeName.c_str(),
205 org::opensplice::topic::TopicTraits<T>::getKeyList(),
208 u_topicQosFree(uTopicQos);
211 ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR,
"Failed to create Topic");
214 this->userHandle = (u_object)uTopic;
215 this->listener_set((
void*)listener, mask);
218 template <
typename T>
220 const std::string&
name,
224 : org::opensplice::topic::TopicDescriptionDelegate(dp,
name,
type_name),
225 org::opensplice::topic::AnyTopicDelegate(qos, dp,
name,
type_name)
227 ISOCPP_REPORT_STACK_DDS_BEGIN(dp);
228 this->userHandle = (u_object)uTopic;
233 template <
typename T>
234 dds::topic::detail::Topic<T>::~Topic()
245 template <
typename T>
247 dds::topic::detail::Topic<T>::close()
250 this->listener_dispatcher_reset();
252 org::opensplice::core::ScopedObjectLock scopedLock(*
this);
254 if (this->hasDependents()) {
255 ISOCPP_THROW_EXCEPTION(ISOCPP_PRECONDITION_NOT_MET_ERROR,
"Topic still has unclosed dependencies (e.g. Readers/Writers/ContentFilteredTopics)");
258 this->myParticipant.delegate()->remove_topic(*
this);
260 org::opensplice::core::EntityDelegate::close();
263 template <
typename T>
265 dds::topic::detail::Topic<T>::init(ObjectDelegate::weak_ref_type weak_ref)
268 this->set_weak_ref(weak_ref);
270 this->myParticipant.delegate()->add_topic(*
this);
272 this->listener_dispatcher_set(this->myParticipant.delegate()->listener_dispatcher_get());
274 this->listener_enable();
276 if (this->myParticipant.delegate()->is_auto_enable()) {
281 template <
typename T>
284 const ::dds::core::status::StatusMask& mask)
287 this->listener_set((
void*)listener, mask);
288 this->listener_enable();
291 template <
typename T>
293 dds::topic::detail::Topic<T>::listener()
298 template <
typename T>
300 dds::topic::detail::Topic<T>::wrapper()
303 typename Topic::ref_type ref =
304 OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<
Topic<T> >(this->get_strong_ref());
310 template <
typename T>
312 dds::topic::detail::Topic<T>::listener_notify(
313 ObjectDelegate::ref_type source,
314 uint32_t triggerMask,
325 typename Topic::ref_type ref =
326 OSPL_CXX11_STD_MODULE::dynamic_pointer_cast<
Topic<T> >(source);
329 if (triggerMask & V_EVENT_INCONSISTENT_TOPIC) {
331 status.delegate().v_status(((v_topicStatus)eventData)->inconsistentTopic);
335 if (triggerMask & V_EVENT_ALL_DATA_DISPOSED ) {
340 status.delegate().v_status(((v_topicStatus)eventData)->allDataDisposed);
346 template <
typename T>
348 dds::topic::detail::Topic<T>::discover_topic(
350 const std::string&
name,
353 u_topic uTopic = dp.delegate()->lookup_topic(
name, timeout);
355 if (uTopic == NULL) {
356 return dds::core::null;
359 os_char *uTypename = u_topicTypeName(uTopic);
364 u_result uResult = u_topicGetQos(uTopic, &uQos);
365 ISOCPP_U_RESULT_CHECK_AND_THROW(uResult,
"Failed to get user layer topic qos");
368 qos.delegate().u_qos(uQos);
369 u_topicQosFree(uQos);
377 template <
typename T>
379 dds::topic::detail::Topic<T>::discover_topics(
384 std::vector<u_topic> uTopics;
389 topics.reserve(uTopics.size());
391 for (std::vector<u_topic>::const_iterator it = uTopics.begin(); it != uTopics.end(); ++it) {
392 u_topic uTopic = *it;
393 os_char *topic_name = u_topicName(uTopic);
394 os_char *
type_name = u_topicTypeName(uTopic);
397 u_result uResult = u_topicGetQos(uTopic, &uQos);
398 ISOCPP_U_RESULT_CHECK_AND_THROW(uResult,
"Failed to get user layer topic qos");
401 qos.delegate().u_qos(uQos);
402 u_topicQosFree(uQos);
Typeless base class for the typed Topic.
Reference(dds::core::null_type &)
Topic proprietary events Listener.
Topic is the most basic description of the data to be published and subscribed.
virtual void on_inconsistent_topic(Topic< T > &topic, const dds::core::status::InconsistentTopicStatus &status)=0
virtual void on_all_data_disposed(dds::topic::Topic< T > &topic, const org::opensplice::core::status::AllDataDisposedTopicStatus &status)=0
A DomainParticipant represents the local membership of the application in a Domain.
const std::string & type_name() const
const dds::domain::DomainParticipant & domain_participant() const
Topic(const dds::domain::DomainParticipant &dp, const std::string &topic_name)
StatusMask is a bitmap or bitset field.
This struct provides the basic mechanism for an application to specify Quality of Service attributes ...
Listener * listener() const
dds::topic::qos::TopicQos qos() const
const std::string & name() const
Support functionality to get the default type_name of a Topic type.