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

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