DCPS_IR_Publication.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 DCPS_IR_PUBLICATION_H
00009 #define DCPS_IR_PUBLICATION_H
00010 
00011 #include  "inforepo_export.h"
00012 #include /**/ "UpdateDataTypes.h"
00013 #include /**/ "dds/DdsDcpsInfrastructureC.h"
00014 #include /**/ "dds/DdsDcpsPublicationC.h"
00015 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoC.h"
00016 #include /**/ "dds/DCPS/InfoRepoDiscovery/DataWriterRemoteC.h"
00017 #include /**/ "ace/Unbounded_Set.h"
00018 #include "dds/DCPS/unique_ptr.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 #pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 // forward declarations
00027 class DCPS_IR_Participant;
00028 class DCPS_IR_Topic;
00029 class DCPS_IR_Topic_Description;
00030 
00031 class DCPS_IR_Subscription;
00032 typedef ACE_Unbounded_Set<DCPS_IR_Subscription*> DCPS_IR_Subscription_Set;
00033 
00034 /**
00035  * @class DCPS_IR_Publication
00036  *
00037  * @brief Representative of a Publication
00038  *
00039  *
00040  */
00041 class OpenDDS_InfoRepoLib_Export DCPS_IR_Publication
00042 : public OpenDDS::DCPS::EnableContainerSupportedUniquePtr<DCPS_IR_Publication> {
00043 public:
00044   DCPS_IR_Publication(const OpenDDS::DCPS::RepoId& id,
00045                       DCPS_IR_Participant* participant,
00046                       DCPS_IR_Topic* topic,
00047                       OpenDDS::DCPS::DataWriterRemote_ptr writer,
00048                       const DDS::DataWriterQos& qos,
00049                       const OpenDDS::DCPS::TransportLocatorSeq& info,
00050                       const DDS::PublisherQos& publisherQos);
00051 
00052   ~DCPS_IR_Publication();
00053 
00054   /// Associate with the subscription
00055   /// Adds the subscription to the list of associated
00056   ///  subscriptions and notifies datawriter if successfully added
00057   /// This method can mark the participant dead
00058   /// Returns 0 if added, 1 if already exists, -1 other failure
00059   int add_associated_subscription(DCPS_IR_Subscription* sub, bool active);
00060 
00061   /// The service participant that contains this Publication has indicated
00062   /// that the assocation to peer "remote" is complete.  This method will
00063   /// locate the Subscription object for "remote" in order to inform it
00064   /// of the completed association.
00065   void association_complete(const OpenDDS::DCPS::RepoId& remote);
00066 
00067   /// Invoke the DataWriterRemote::association_complete() callback, passing
00068   /// the "remote" parameter (Subscription) to the service participant.
00069   void call_association_complete(const OpenDDS::DCPS::RepoId& remote);
00070 
00071   /// Remove the associated subscription
00072   /// Removes the subscription from the list of associated
00073   ///  subscriptions if return successful
00074   /// sendNotify indicates whether to tell the datawriter about
00075   ///  removing the subscription
00076   /// The notify_lost parameter is passed to the remove_associations()
00077   /// The notify_both_side parameter indicates if it needs call sub to remove
00078   /// association as well.
00079   /// See the comments of remove_associations() in DataWriterRemote.idl
00080   /// or DataReaderRemote.idl.
00081   /// This method can mark the participant dead
00082   /// Returns 0 if successful
00083   int remove_associated_subscription(DCPS_IR_Subscription* sub,
00084                                      CORBA::Boolean sendNotify,
00085                                      CORBA::Boolean notify_lost,
00086                                      bool notify_both_side = false);
00087 
00088   /// Removes all the associated subscriptions
00089   /// This method can mark the participant dead
00090   /// The notify_lost flag true indicates this remove_associations is called
00091   /// when the InfoRepo detects this publication is lost because of the failure
00092   /// of invocation on this publication.
00093   /// Returns 0 if successful
00094   int remove_associations(CORBA::Boolean notify_lost);
00095 
00096   /// Remove any subscriptions whose participant has the id
00097   void disassociate_participant(OpenDDS::DCPS::RepoId id,
00098                                 bool reassociate = false);
00099 
00100   /// Remove any subscriptions whose topic has the id
00101   void disassociate_topic(OpenDDS::DCPS::RepoId id);
00102 
00103   /// Remove any subscriptions with the id
00104   void disassociate_subscription(OpenDDS::DCPS::RepoId id,
00105                                  bool reassociate = false);
00106 
00107   /// Notify the writer of incompatible qos status
00108   ///  and reset the status' count_since_last_send to 0
00109   void update_incompatible_qos();
00110 
00111   /// Check that none of the ids given are ones that
00112   ///  this publication should ignore.
00113   /// returns 1 if one of these ids is an ignored id
00114   CORBA::Boolean is_subscription_ignored(OpenDDS::DCPS::RepoId partId,
00115                                          OpenDDS::DCPS::RepoId topicId,
00116                                          OpenDDS::DCPS::RepoId subId);
00117 
00118   /// Return pointer to the DataWriter qos
00119   /// Publication retains ownership
00120   DDS::DataWriterQos* get_datawriter_qos();
00121 
00122   /// Return pointer to the Publisher qos
00123   /// Publication retains ownership
00124   DDS::PublisherQos* get_publisher_qos();
00125 
00126   /// Update the DataWriter or Publisher qos and also publish the qos changes
00127   /// to datawriter BIT.
00128   bool set_qos(const DDS::DataWriterQos & qos,
00129                const DDS::PublisherQos & publisherQos,
00130                Update::SpecificQos& specificQos);
00131 
00132   /// Update DataWriterQos only.
00133   void set_qos(const DDS::DataWriterQos& qos);
00134 
00135   /// Update PublisherQos only.
00136   void set_qos(const DDS::PublisherQos& qos);
00137 
00138   OpenDDS::DCPS::TransportLocatorSeq get_transportLocatorSeq() const;
00139 
00140   /// Return pointer to the incompatible qos status
00141   /// Publication retains ownership
00142   OpenDDS::DCPS::IncompatibleQosStatus* get_incompatibleQosStatus();
00143 
00144   OpenDDS::DCPS::RepoId get_id();
00145   OpenDDS::DCPS::RepoId get_topic_id();
00146   OpenDDS::DCPS::RepoId get_participant_id();
00147 
00148   DCPS_IR_Topic* get_topic();
00149   DCPS_IR_Topic_Description* get_topic_description();
00150 
00151   DDS::InstanceHandle_t get_handle();
00152   void set_handle(DDS::InstanceHandle_t handle);
00153 
00154   CORBA::Boolean is_bit();
00155   void set_bit_status(CORBA::Boolean isBIT);
00156 
00157   // Expose the datawriter.
00158   OpenDDS::DCPS::DataWriterRemote_ptr writer();
00159 
00160   void reevaluate_defunct_associations();
00161 
00162   // Verify the existing associations. This may result removal of
00163   // associations. The existing associations have to be removed before
00164   // adding new association and may need some delay. Otherwise, if
00165   // two DataReaders uses same Datalink and add an association happens
00166   // before remove an association then the new association will fail to
00167   // connect.
00168   void reevaluate_existing_associations();
00169 
00170   // Re-evaluate the association between this publication and the provided
00171   // subscription. If they are already associated and not compatible then
00172   // they will be dis-associated. If they are not already associated then
00173   // the new association will be added.
00174   bool reevaluate_association(DCPS_IR_Subscription* subscription);
00175 
00176   void update_expr_params(OpenDDS::DCPS::RepoId readerId,
00177                           const DDS::StringSeq& params);
00178 
00179   std::string dump_to_string(const std::string& prefix, int depth) const;
00180 
00181 private:
00182 
00183   OpenDDS::DCPS::RepoId id_;
00184   DCPS_IR_Participant* participant_;
00185   DCPS_IR_Topic* topic_;
00186   DDS::InstanceHandle_t handle_;
00187   CORBA::Boolean isBIT_;
00188 
00189   /// the corresponding DataWriterRemote object
00190   OpenDDS::DCPS::DataWriterRemote_var writer_;
00191   DDS::DataWriterQos qos_;
00192   OpenDDS::DCPS::TransportLocatorSeq info_;
00193   DDS::PublisherQos publisherQos_;
00194 
00195   DCPS_IR_Subscription_Set associations_;
00196   DCPS_IR_Subscription_Set defunct_;
00197 
00198   OpenDDS::DCPS::IncompatibleQosStatus incompatibleQosStatus_;
00199 };
00200 
00201 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00202 
00203 #endif /* DCPS_IR_PUBLICATION_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1