OpenDDS::DCPS::TopicImpl Class Reference

Implements the DDS::Topic interface. More...

#include <TopicImpl.h>

Inheritance diagram for OpenDDS::DCPS::TopicImpl:

Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::TopicImpl:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TopicImpl (const RepoId topic_id, const char *topic_name, const char *type_name, OpenDDS::DCPS::TypeSupport_ptr type_support, const DDS::TopicQos &qos, DDS::TopicListener_ptr a_listener, const DDS::StatusMask &mask, DomainParticipantImpl *participant)
virtual ~TopicImpl ()
virtual DDS::InstanceHandle_t get_instance_handle ()
virtual DDS::ReturnCode_t set_qos (const DDS::TopicQos &qos)
virtual DDS::ReturnCode_t get_qos (DDS::TopicQos &qos)
virtual DDS::ReturnCode_t set_listener (DDS::TopicListener_ptr a_listener, DDS::StatusMask mask)
virtual DDS::TopicListener_ptr get_listener ()
virtual DDS::ReturnCode_t get_inconsistent_topic_status (DDS::InconsistentTopicStatus &a_status)
virtual DDS::ReturnCode_t enable ()
RepoId get_id () const
CORBA::Long entity_refs () const
void add_entity_ref ()
void remove_entity_ref ()
const char * type_name () const
virtual void transport_config (const TransportConfig_rch &cfg)
void inconsistent_topic ()

Private Attributes

DDS::TopicQos qos_
 The topic qos.
DDS::StatusMask listener_mask_
DDS::TopicListener_var listener_
 The topic listener.
RepoId id_
 The id given by discovery.
CORBA::Long entity_refs_
 The number of DataReaders and DataWriters using this Topic.
DDS::InconsistentTopicStatus inconsistent_topic_status_
Monitormonitor_
 Pointer to the monitor object for this entity.

Detailed Description

Implements the DDS::Topic interface.

See the DDS specification, OMG formal/04-12-02, for a description of the interface this class is implementing.

Definition at line 34 of file TopicImpl.h.


Constructor & Destructor Documentation

OpenDDS::DCPS::TopicImpl::TopicImpl ( const RepoId  topic_id,
const char *  topic_name,
const char *  type_name,
OpenDDS::DCPS::TypeSupport_ptr  type_support,
const DDS::TopicQos qos,
DDS::TopicListener_ptr  a_listener,
const DDS::StatusMask mask,
DomainParticipantImpl participant 
)

Definition at line 21 of file TopicImpl.cpp.

References inconsistent_topic_status_, monitor_, TheServiceParticipant, DDS::InconsistentTopicStatus::total_count, and DDS::InconsistentTopicStatus::total_count_change.

00029   : TopicDescriptionImpl(topic_name,
00030                          type_name,
00031                          type_support,
00032                          participant),
00033     qos_(qos),
00034     listener_mask_(mask),
00035     listener_(DDS::TopicListener::_duplicate(a_listener)),
00036     id_(topic_id),
00037     entity_refs_(0),
00038     monitor_(0)
00039 {
00040   inconsistent_topic_status_.total_count = 0;
00041   inconsistent_topic_status_.total_count_change = 0;
00042   monitor_ =
00043     TheServiceParticipant->monitor_factory_->create_topic_monitor(this);
00044 }

OpenDDS::DCPS::TopicImpl::~TopicImpl (  )  [virtual]

Definition at line 46 of file TopicImpl.cpp.

00047 {
00048 }


Member Function Documentation

void OpenDDS::DCPS::TopicImpl::add_entity_ref (  )  [inline]

Definition at line 77 of file TopicImpl.h.

Referenced by OpenDDS::DCPS::ReplayerImpl::init(), OpenDDS::DCPS::RecorderImpl::init(), OpenDDS::DCPS::DataWriterImpl::init(), and OpenDDS::DCPS::DataReaderImpl::init().

00077                         {
00078     entity_refs_++;
00079   }

DDS::ReturnCode_t OpenDDS::DCPS::TopicImpl::enable (  )  [virtual]

Implements DDS::Entity.

Definition at line 125 of file TopicImpl.cpp.

References OpenDDS::DCPS::EntityImpl::is_enabled(), monitor_, OpenDDS::DCPS::TopicDescriptionImpl::participant_, OpenDDS::DCPS::Monitor::report(), DDS::RETCODE_OK, DDS::RETCODE_PRECONDITION_NOT_MET, and OpenDDS::DCPS::EntityImpl::set_enabled().

Referenced by OpenDDS::DCPS::DomainParticipantImpl::create_new_topic().

00126 {
00127   //According spec:
00128   // - Calling enable on an already enabled Entity returns OK and has no
00129   // effect.
00130   // - Calling enable on an Entity whose factory is not enabled will fail
00131   // and return PRECONDITION_NOT_MET.
00132 
00133   if (this->is_enabled()) {
00134     return DDS::RETCODE_OK;
00135   }
00136 
00137   DomainParticipantImpl* part =
00138     dynamic_cast<DomainParticipantImpl*>(this->participant_);
00139 
00140   if (part->is_enabled() == false) {
00141     return DDS::RETCODE_PRECONDITION_NOT_MET;
00142   }
00143 
00144   if (this->monitor_) {
00145     monitor_->report();
00146   }
00147   return this->set_enabled();
00148 }

CORBA::Long OpenDDS::DCPS::TopicImpl::entity_refs (  )  const [inline]

Definition at line 73 of file TopicImpl.h.

Referenced by OpenDDS::DCPS::DomainParticipantImpl::delete_topic_i().

00073                                 {
00074     return entity_refs_;
00075   }

RepoId OpenDDS::DCPS::TopicImpl::get_id (  )  const

This method is not defined in the IDL and is defined for internal use. Return the id given by discovery.

Definition at line 151 of file TopicImpl.cpp.

References id_.

Referenced by OpenDDS::DCPS::DomainParticipantImpl::delete_topic_i(), OpenDDS::DCPS::ReplayerImpl::enable(), OpenDDS::DCPS::RecorderImpl::enable(), OpenDDS::DCPS::DataWriterImpl::enable(), OpenDDS::DCPS::DataReaderImpl::enable(), OpenDDS::DCPS::DataReaderImpl::get_topic_id(), OpenDDS::DCPS::ReplayerImpl::init(), OpenDDS::DCPS::DataWriterImpl::init(), and OpenDDS::DCPS::TopicMonitorImpl::report().

00152 {
00153   return id_;
00154 }

DDS::ReturnCode_t OpenDDS::DCPS::TopicImpl::get_inconsistent_topic_status ( DDS::InconsistentTopicStatus a_status  )  [virtual]

Definition at line 116 of file TopicImpl.cpp.

References DDS::INCONSISTENT_TOPIC_STATUS, inconsistent_topic_status_, DDS::RETCODE_OK, OpenDDS::DCPS::EntityImpl::set_status_changed_flag(), and DDS::InconsistentTopicStatus::total_count_change.

DDS::InstanceHandle_t OpenDDS::DCPS::TopicImpl::get_instance_handle (  )  [virtual]

Implements OpenDDS::DCPS::EntityImpl.

Definition at line 157 of file TopicImpl.cpp.

References OpenDDS::DCPS::DomainParticipantImpl::id_to_handle(), and OpenDDS::DCPS::TopicDescriptionImpl::participant_.

00158 {
00159   return this->participant_->id_to_handle(this->id_);
00160 }

DDS::TopicListener_ptr OpenDDS::DCPS::TopicImpl::get_listener (  )  [virtual]

Implements DDS::Topic.

Definition at line 110 of file TopicImpl.cpp.

References listener_.

00111 {
00112   return DDS::TopicListener::_duplicate(listener_.in());
00113 }

DDS::ReturnCode_t OpenDDS::DCPS::TopicImpl::get_qos ( DDS::TopicQos qos  )  [virtual]

Definition at line 94 of file TopicImpl.cpp.

References qos_, and DDS::RETCODE_OK.

00095 {
00096   qos = qos_;
00097   return DDS::RETCODE_OK;
00098 }

void OpenDDS::DCPS::TopicImpl::inconsistent_topic (  ) 

Definition at line 175 of file TopicImpl.cpp.

References DDS::INCONSISTENT_TOPIC_STATUS, inconsistent_topic_status_, listener_, OpenDDS::DCPS::DomainParticipantImpl::listener_for(), listener_mask_, OpenDDS::DCPS::EntityImpl::notify_status_condition(), OpenDDS::DCPS::TopicDescriptionImpl::participant_, OpenDDS::DCPS::EntityImpl::set_status_changed_flag(), DDS::InconsistentTopicStatus::total_count, and DDS::InconsistentTopicStatus::total_count_change.

Referenced by OpenDDS::DCPS::ReplayerImpl::inconsistent_topic(), OpenDDS::DCPS::RecorderImpl::inconsistent_topic(), OpenDDS::DCPS::DataWriterImpl::inconsistent_topic(), and OpenDDS::DCPS::DataReaderImpl::inconsistent_topic().

00176 {
00177   ++inconsistent_topic_status_.total_count;
00178   ++inconsistent_topic_status_.total_count_change;
00179   set_status_changed_flag(DDS::INCONSISTENT_TOPIC_STATUS, true);
00180 
00181   DDS::TopicListener_var listener = listener_;
00182   if (!listener || !(listener_mask_ & DDS::INCONSISTENT_TOPIC_STATUS)) {
00183     listener = participant_->listener_for(DDS::INCONSISTENT_TOPIC_STATUS);
00184   }
00185 
00186   if (listener) {
00187     listener->on_inconsistent_topic(this, inconsistent_topic_status_);
00188     inconsistent_topic_status_.total_count_change = 0;
00189   }
00190 
00191   notify_status_condition();
00192 }

void OpenDDS::DCPS::TopicImpl::remove_entity_ref (  )  [inline]

Definition at line 81 of file TopicImpl.h.

Referenced by OpenDDS::DCPS::ReplayerImpl::cleanup(), OpenDDS::DCPS::RecorderImpl::cleanup(), OpenDDS::DCPS::DataWriterImpl::cleanup(), and OpenDDS::DCPS::DataReaderImpl::cleanup().

00081                            {
00082     entity_refs_--;
00083   }

DDS::ReturnCode_t OpenDDS::DCPS::TopicImpl::set_listener ( DDS::TopicListener_ptr  a_listener,
DDS::StatusMask  mask 
) [virtual]

Definition at line 101 of file TopicImpl.cpp.

References listener_, listener_mask_, and DDS::RETCODE_OK.

00102 {
00103   listener_mask_ = mask;
00104   //note: OK to duplicate  a nil object ref
00105   listener_ = DDS::TopicListener::_duplicate(a_listener);
00106   return DDS::RETCODE_OK;
00107 }

DDS::ReturnCode_t OpenDDS::DCPS::TopicImpl::set_qos ( const DDS::TopicQos qos  )  [virtual]

Definition at line 51 of file TopicImpl.cpp.

References OpenDDS::DCPS::Qos_Helper::changeable(), OpenDDS::DCPS::Qos_Helper::consistent(), OpenDDS::DCPS::EntityImpl::enabled_, OpenDDS::DCPS::DomainParticipantImpl::get_domain_id(), OpenDDS::DCPS::DomainParticipantImpl::get_id(), OPENDDS_NO_DURABILITY_KIND_TRANSIENT_PERSISTENT_COMPATIBILITY_CHECK, OPENDDS_NO_DURABILITY_SERVICE_COMPATIBILITY_CHECK, OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE_COMPATIBILITY_CHECK, OPENDDS_NO_OWNERSHIP_PROFILE_COMPATIBILITY_CHECK, OpenDDS::DCPS::TopicDescriptionImpl::participant_, qos_, DDS::RETCODE_ERROR, DDS::RETCODE_IMMUTABLE_POLICY, DDS::RETCODE_INCONSISTENT_POLICY, DDS::RETCODE_OK, DDS::RETCODE_UNSUPPORTED, TheServiceParticipant, and OpenDDS::DCPS::Qos_Helper::valid().

00052 {
00053 
00054   OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED);
00055   OPENDDS_NO_OWNERSHIP_PROFILE_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED);
00056   OPENDDS_NO_DURABILITY_SERVICE_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED);
00057   OPENDDS_NO_DURABILITY_KIND_TRANSIENT_PERSISTENT_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED);
00058 
00059   if (Qos_Helper::valid(qos) && Qos_Helper::consistent(qos)) {
00060     if (qos_ == qos)
00061       return DDS::RETCODE_OK;
00062 
00063     // for the not changeable qos, it can be changed before enable
00064     if (!Qos_Helper::changeable(qos_, qos) && enabled_ == true) {
00065       return DDS::RETCODE_IMMUTABLE_POLICY;
00066 
00067     } else {
00068       qos_ = qos;
00069       DomainParticipantImpl* part =
00070         dynamic_cast<DomainParticipantImpl*>(this->participant_);
00071 
00072       Discovery_rch disco =
00073         TheServiceParticipant->get_discovery(part->get_domain_id());
00074       const bool status =
00075         disco->update_topic_qos(this->id_, part->get_domain_id(),
00076                                part->get_id(), qos_);
00077 
00078       if (!status) {
00079         ACE_ERROR_RETURN((LM_ERROR,
00080                           ACE_TEXT("(%P|%t) TopicImpl::set_qos, ")
00081                           ACE_TEXT("failed on compatiblity check. \n")),
00082                          DDS::RETCODE_ERROR);
00083       }
00084     }
00085 
00086     return DDS::RETCODE_OK;
00087 
00088   } else {
00089     return DDS::RETCODE_INCONSISTENT_POLICY;
00090   }
00091 }

void OpenDDS::DCPS::TopicImpl::transport_config ( const TransportConfig_rch cfg  )  [virtual]

Reimplemented from OpenDDS::DCPS::EntityImpl.

Definition at line 169 of file TopicImpl.cpp.

00170 {
00171   throw Transport::MiscProblem();
00172 }

const char * OpenDDS::DCPS::TopicImpl::type_name (  )  const

Definition at line 163 of file TopicImpl.cpp.

References OpenDDS::DCPS::TopicDescriptionImpl::type_name_.

Referenced by OpenDDS::DCPS::DataReaderImpl::cleanup().

00164 {
00165   return this->type_name_.c_str();
00166 }


Member Data Documentation

CORBA::Long OpenDDS::DCPS::TopicImpl::entity_refs_ [private]

The number of DataReaders and DataWriters using this Topic.

Definition at line 105 of file TopicImpl.h.

RepoId OpenDDS::DCPS::TopicImpl::id_ [private]

The id given by discovery.

Definition at line 102 of file TopicImpl.h.

Referenced by get_id().

DDS::InconsistentTopicStatus OpenDDS::DCPS::TopicImpl::inconsistent_topic_status_ [private]

count of discovered (readers/writers using) topics with the same topic name but different characteristics (typename)

Definition at line 109 of file TopicImpl.h.

Referenced by get_inconsistent_topic_status(), inconsistent_topic(), and TopicImpl().

DDS::TopicListener_var OpenDDS::DCPS::TopicImpl::listener_ [private]

The topic listener.

Definition at line 99 of file TopicImpl.h.

Referenced by get_listener(), inconsistent_topic(), and set_listener().

DDS::StatusMask OpenDDS::DCPS::TopicImpl::listener_mask_ [private]

The mask for which kind of events the listener will be notified about.

Definition at line 97 of file TopicImpl.h.

Referenced by inconsistent_topic(), and set_listener().

Monitor* OpenDDS::DCPS::TopicImpl::monitor_ [private]

Pointer to the monitor object for this entity.

Definition at line 112 of file TopicImpl.h.

Referenced by enable(), and TopicImpl().

DDS::TopicQos OpenDDS::DCPS::TopicImpl::qos_ [private]

The topic qos.

Definition at line 93 of file TopicImpl.h.

Referenced by get_qos(), and set_qos().


The documentation for this class was generated from the following files:
Generated on Fri Feb 12 20:06:25 2016 for OpenDDS by  doxygen 1.4.7