PublisherImpl.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_PUBLISHER_IMPL_H
00009 #define OPENDDS_DCPS_PUBLISHER_IMPL_H
00010 
00011 #include "dds/DdsDcpsInfoUtilsC.h"
00012 #include "EntityImpl.h"
00013 #include "DataWriterImpl.h"
00014 #include "ace/Reverse_Lock_T.h"
00015 
00016 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00017 #pragma once
00018 #endif /* ACE_LACKS_PRAGMA_ONCE */
00019 
00020 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 namespace OpenDDS {
00023 namespace DCPS {
00024 
00025 class DomainParticipantImpl;
00026 class Monitor;
00027 
00028 /**
00029 * @class PublisherImpl
00030 *
00031 * @brief Implements the OpenDDS::DCPS::Publisher interfaces.
00032 *
00033 * This class acts as a factory and container of the datawriter.
00034 *
00035 * See the DDS specification, OMG formal/04-12-02, for a description of
00036 * the interface this class is implementing.
00037 */
00038 class OpenDDS_Dcps_Export PublisherImpl
00039   : public virtual LocalObject<DDS::Publisher>
00040   , public virtual EntityImpl {
00041 public:
00042 
00043   friend class DataWriterImpl;
00044 
00045   PublisherImpl(DDS::InstanceHandle_t handle,
00046                 RepoId id,
00047                 const DDS::PublisherQos& qos,
00048                 DDS::PublisherListener_ptr a_listener,
00049                 const DDS::StatusMask& mask,
00050                 DomainParticipantImpl* participant);
00051 
00052   virtual ~PublisherImpl();
00053 
00054   virtual DDS::InstanceHandle_t get_instance_handle();
00055 
00056   bool contains_writer(DDS::InstanceHandle_t a_handle);
00057 
00058   virtual DDS::DataWriter_ptr create_datawriter(
00059     DDS::Topic_ptr a_topic,
00060     const DDS::DataWriterQos& qos,
00061     DDS::DataWriterListener_ptr a_listener,
00062     DDS::StatusMask mask);
00063 
00064   virtual DDS::ReturnCode_t delete_datawriter(
00065     DDS::DataWriter_ptr a_datawriter);
00066 
00067   virtual DDS::DataWriter_ptr lookup_datawriter(
00068     const char* topic_name);
00069 
00070   virtual DDS::ReturnCode_t delete_contained_entities();
00071 
00072   virtual DDS::ReturnCode_t set_qos(
00073     const DDS::PublisherQos& qos);
00074 
00075   virtual DDS::ReturnCode_t get_qos(
00076     DDS::PublisherQos& qos);
00077 
00078   virtual DDS::ReturnCode_t set_listener(
00079     DDS::PublisherListener_ptr a_listener,
00080     DDS::StatusMask mask);
00081 
00082   virtual DDS::PublisherListener_ptr get_listener();
00083 
00084   virtual DDS::ReturnCode_t suspend_publications();
00085 
00086   virtual DDS::ReturnCode_t resume_publications();
00087 
00088 #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE
00089 
00090   virtual DDS::ReturnCode_t begin_coherent_changes();
00091 
00092   virtual DDS::ReturnCode_t end_coherent_changes();
00093 
00094 #endif
00095 
00096   virtual DDS::ReturnCode_t wait_for_acknowledgments(
00097     const DDS::Duration_t& max_wait);
00098 
00099   virtual DDS::DomainParticipant_ptr get_participant();
00100 
00101   virtual DDS::ReturnCode_t set_default_datawriter_qos(
00102     const DDS::DataWriterQos& qos);
00103 
00104   virtual DDS::ReturnCode_t get_default_datawriter_qos(
00105     DDS::DataWriterQos& qos);
00106 
00107   virtual DDS::ReturnCode_t copy_from_topic_qos(
00108     DDS::DataWriterQos& a_datawriter_qos,
00109     const DDS::TopicQos& a_topic_qos);
00110 
00111   virtual DDS::ReturnCode_t enable();
00112 
00113   ACE_Recursive_Thread_Mutex& get_pi_lock() { return pi_lock_; }
00114 
00115   /** This method is not defined in the IDL and is defined for
00116   *  internal use.
00117   *  Check if there is any datawriter associated with this publisher.
00118   */
00119   bool is_clean() const;
00120 
00121   /** This method is called when the datawriter created by this
00122   * publisher was enabled.
00123   */
00124   DDS::ReturnCode_t writer_enabled(const char* topic_name,
00125                                    DataWriterImpl* impl);
00126 
00127   /**
00128   * This is used to retrieve the listener for a certain status change.
00129   * If this publisher has a registered listener and the status kind
00130   * is in the listener mask then the listener is returned.
00131   * Otherwise, the query for listener is propagated up to the
00132   * factory/DomainParticipant.
00133   */
00134   DDS::PublisherListener_ptr listener_for(::DDS::StatusKind kind);
00135 
00136   DDS::ReturnCode_t assert_liveliness_by_participant();
00137   ACE_Time_Value liveliness_check_interval(DDS::LivelinessQosPolicyKind kind);
00138   bool participant_liveliness_activity_after(const ACE_Time_Value& tv);
00139 
00140   typedef OPENDDS_VECTOR(PublicationId) PublicationIdVec;
00141   /// Populates a std::vector with the PublicationIds (GUIDs)
00142   /// of this Publisher's Data Writers
00143   void get_publication_ids(PublicationIdVec& pubs);
00144 
00145   bool is_suspended() const;
00146 
00147   virtual RcHandle<EntityImpl> parent() const;
00148   static bool validate_datawriter_qos(const DDS::DataWriterQos& qos,
00149                                          const DDS::DataWriterQos& default_qos,
00150                                          DDS::Topic_ptr a_topic,
00151                                          DDS::DataWriterQos& dw_qos);
00152 private:
00153   typedef OPENDDS_MULTIMAP(OPENDDS_STRING, DataWriterImpl_rch) DataWriterMap;
00154 
00155   typedef OPENDDS_MAP_CMP(PublicationId, DataWriterImpl_rch, GUID_tKeyLessThan)
00156     PublicationMap;
00157 
00158   // DataWriter id to qos map.
00159   typedef OPENDDS_MAP_CMP(RepoId, DDS::DataWriterQos, GUID_tKeyLessThan) DwIdToQosMap;
00160 
00161   DDS::InstanceHandle_t        handle_;
00162 
00163   /// Publisher QoS policy list.
00164   DDS::PublisherQos            qos_;
00165   /// Default datawriter Qos policy list.
00166   DDS::DataWriterQos           default_datawriter_qos_;
00167 
00168   /// The StatusKind bit mask indicates which status condition change
00169   /// can be notified by the listener of this entity.
00170   DDS::StatusMask              listener_mask_;
00171   /// Used to notify the entity for relevant events.
00172   DDS::PublisherListener_var   listener_;
00173 
00174   typedef OPENDDS_SET(DataWriterImpl_rch) DataWriterSet;
00175   DataWriterSet writers_not_enabled_;
00176 
00177   /// This map is used to support datawriter lookup by topic name.
00178   DataWriterMap                datawriter_map_;
00179   /// This map is used to support datawriter lookup by datawriter
00180   /// repository id.
00181   PublicationMap               publication_map_;
00182 #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE
00183   /// The number of times begin_coherent_changes as been called.
00184   std::size_t                  change_depth_;
00185 #endif
00186   /// Domain in which we are contained.
00187   DDS::DomainId_t              domain_id_;
00188   /// The DomainParticipant servant that owns this Publisher.
00189   WeakRcHandle<DomainParticipantImpl>       participant_;
00190   /// The suspend depth count.
00191   CORBA::Short                 suspend_depth_count_;
00192   /// Unique sequence number used when the scope_access = GROUP.
00193   /// -  NOT USED IN FIRST IMPL - not supporting GROUP scope
00194   SequenceNumber               sequence_number_;
00195   /// Start of current aggregation period. - NOT USED IN FIRST IMPL
00196   ACE_Time_Value               aggregation_period_start_;
00197 
00198   typedef ACE_Recursive_Thread_Mutex  lock_type;
00199   typedef ACE_Reverse_Lock<lock_type> reverse_lock_type;
00200   /// The recursive lock to protect datawriter map and suspend count.
00201   mutable lock_type                   pi_lock_;
00202   reverse_lock_type                   reverse_pi_lock_;
00203 
00204   /// Monitor object for this entity
00205   Monitor* monitor_;
00206 
00207   /// @note The publisher_id_ is not generated by repository, it's unique
00208   ///       in DomainParticipant scope.
00209   RepoId                        publisher_id_;
00210 };
00211 
00212 } // namespace  DDS
00213 } // namespace OpenDDS
00214 
00215 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00216 
00217 #endif /* OPENDDS_DCPS_PUBLISHER_IMPL_H  */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1