DCPS_IR_Topic.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_TOPIC_H
00009 #define DCPS_IR_TOPIC_H
00010 
00011 #include  "inforepo_export.h"
00012 #include /**/ "dds/DdsDcpsInfrastructureC.h"
00013 #include /**/ "dds/DdsDcpsTopicC.h"
00014 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoC.h"
00015 #include /**/ "ace/Unbounded_Set.h"
00016 
00017 #include <string>
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_Subscription;
00028 typedef ACE_Unbounded_Set<DCPS_IR_Subscription*> DCPS_IR_Subscription_Set;
00029 
00030 class DCPS_IR_Domain;
00031 class DCPS_IR_Participant;
00032 class DCPS_IR_Topic_Description;
00033 class DCPS_IR_Subscription;
00034 
00035 /**
00036  * @class DCPS_IR_Topic
00037  *
00038  * @brief Representative of a Topic
00039  *
00040  */
00041 class OpenDDS_InfoRepoLib_Export DCPS_IR_Topic {
00042 public:
00043   DCPS_IR_Topic(const OpenDDS::DCPS::RepoId& id,
00044                 const DDS::TopicQos& qos,
00045                 DCPS_IR_Domain* domain,
00046                 DCPS_IR_Participant* creator,
00047                 DCPS_IR_Topic_Description* description);
00048 
00049   ~DCPS_IR_Topic();
00050 
00051   /// Delete the topic object upon last topic associated sub/pub and topic
00052   /// object deletion. It's kind of reference counting.
00053   /// The removing true indicates it's called upon delete_topic, otherwise
00054   /// it's upon remove_publication/remove_subcription.
00055   void release(bool removing);
00056 
00057   /// Adds the publication to the list of publications
00058   /// Calls the topic description's try associate if successfully added
00059   /// 'associate' switch toggles association attempt.
00060   /// Returns 0 if added, 1 if already exists, -1 other failure
00061   int add_publication_reference(DCPS_IR_Publication* publication
00062                                 , bool associate = true);
00063 
00064   /// Removes the publication from the list of publications
00065   /// Returns 0 if successful
00066   int remove_publication_reference(DCPS_IR_Publication* publication);
00067 
00068   /// Adds the subscription to the list of subscriptions
00069   /// and let description handle the association.
00070   /// Returns 0 if added, 1 if already exists, -1 other failure
00071   int add_subscription_reference(DCPS_IR_Subscription* subscription
00072                                  , bool associate = true);
00073 
00074   /// Removes the subscription from the list of subscriptions
00075   /// Returns 0 if successful
00076   int remove_subscription_reference(DCPS_IR_Subscription* subscription);
00077 
00078   /// Called by the DCPS_IR_Topic_Description
00079   /// Find any compatible publications and associate
00080   ///  them using the DCPS_IR_Topic_Description's
00081   ///  associate method.
00082   /// This method does not check the subscription's incompatible
00083   ///  qos status.
00084   void try_associate(DCPS_IR_Subscription* subscription);
00085 
00086   /// Called by the DCPS_IR_Topic_Description to re-evaluate the
00087   /// association between the publications of this topic and the
00088   /// provided subscription.
00089   void reevaluate_associations(DCPS_IR_Subscription* subscription);
00090 
00091   OpenDDS::DCPS::RepoId get_id() const;
00092   OpenDDS::DCPS::RepoId get_participant_id() const;
00093 
00094   /// Return pointer to the Topic Description
00095   /// Domain retains ownership
00096   DCPS_IR_Topic_Description* get_topic_description();
00097 
00098   /// Return pointer to the Topic qos
00099   /// Topic retains ownership
00100   DDS::TopicQos * get_topic_qos();
00101 
00102   /// Reset topic qos and also propogate the qos change to related BITs
00103   /// that has the qos copy.
00104   /// Return false if the provided QoS makes the DataWriter and DataReader
00105   /// QoS incompatible. Currently supported changeable QoS in TopicQos do
00106   /// not affect.
00107   bool set_topic_qos(const DDS::TopicQos& qos);
00108 
00109   DDS::InstanceHandle_t get_handle();
00110   void set_handle(DDS::InstanceHandle_t handle);
00111 
00112   CORBA::Boolean is_bit();
00113   void set_bit_status(CORBA::Boolean isBIT);
00114 
00115   /// Try to associate all the current publications.
00116   /// This is used to reconnect Built in Topics after a persistent restart.
00117   void reassociate_all_publications();
00118 
00119   std::string dump_to_string(const std::string& prefix, int depth) const;
00120 
00121 private:
00122   OpenDDS::DCPS::RepoId id_;
00123   DDS::TopicQos qos_;
00124   DCPS_IR_Domain* domain_;
00125   DCPS_IR_Participant* participant_;
00126   DCPS_IR_Topic_Description* description_;
00127   DDS::InstanceHandle_t handle_;
00128   CORBA::Boolean isBIT_;
00129 
00130   DCPS_IR_Publication_Set publicationRefs_;
00131   /// Keep track the subscriptions of this topic so the TopicQos
00132   /// change can be published for those subscriptions.
00133   DCPS_IR_Subscription_Set subscriptionRefs_;
00134 
00135   /// True means release() is called upon delete_topic, but topic object is
00136   /// not deleted because there are still pub/sub associated.
00137   bool removed_;
00138 };
00139 
00140 #endif /* DCPS_IR_TOPIC_H */

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