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

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1