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

Generated on Fri Feb 12 20:05:20 2016 for OpenDDS by  doxygen 1.4.7