DCPS_IR_Participant.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_PARTICIPANT_H
00009 #define DCPS_IR_PARTICIPANT_H
00010 
00011 #include  "inforepo_export.h"
00012 #include /**/ "dds/DdsDcpsInfrastructureC.h"
00013 #include /**/ "dds/DCPS/InfoRepoDiscovery/InfoS.h"
00014 
00015 #include "dds/DCPS/RepoIdGenerator.h"
00016 #include "dds/DCPS/GuidUtils.h"
00017 #include "dds/DCPS/RcObject.h"
00018 
00019 #include /**/ "ace/Map_Manager.h"
00020 
00021 #include /**/ "DCPS_IR_Subscription.h"
00022 #include /**/ "DCPS_IR_Publication.h"
00023 #include /**/ "DCPS_IR_Topic.h"
00024 
00025 #include <map>
00026 
00027 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00028 #pragma once
00029 #endif /* ACE_LACKS_PRAGMA_ONCE */
00030 
00031 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 // forward declarations
00034 class DCPS_IR_Domain;
00035 class TAO_DDS_DCPSFederationId;
00036 
00037 namespace Update {
00038 
00039 class Manager;
00040 
00041 } // namespace Update
00042 
00043 typedef std::map<OpenDDS::DCPS::RepoId,
00044                  OpenDDS::DCPS::container_supported_unique_ptr<DCPS_IR_Subscription>,
00045                  OpenDDS::DCPS::GUID_tKeyLessThan> DCPS_IR_Subscription_Map;
00046 typedef std::map<OpenDDS::DCPS::RepoId,
00047                  OpenDDS::DCPS::container_supported_unique_ptr<DCPS_IR_Publication>,
00048                  OpenDDS::DCPS::GUID_tKeyLessThan> DCPS_IR_Publication_Map;
00049 typedef std::map<OpenDDS::DCPS::RepoId,
00050                  DCPS_IR_Topic*,
00051                  OpenDDS::DCPS::GUID_tKeyLessThan> DCPS_IR_Topic_Map;
00052 
00053 typedef ACE_Unbounded_Set<OpenDDS::DCPS::RepoId> TAO_DDS_RepoId_Set;
00054 
00055 /**
00056  * @class DCPS_IR_Participant
00057  *
00058  * @brief Representative of the Domain Participant
00059  *
00060  *
00061  */
00062 class OpenDDS_InfoRepoLib_Export DCPS_IR_Participant
00063   : public OpenDDS::DCPS::RcObject
00064 {
00065 public:
00066   /// Special owner to enforce no callbacks.
00067   enum { OWNER_NONE};
00068 
00069   DCPS_IR_Participant(const TAO_DDS_DCPSFederationId& federationId,
00070                       OpenDDS::DCPS::RepoId id,
00071                       DCPS_IR_Domain* domain,
00072                       DDS::DomainParticipantQos qos,
00073                       Update::Manager* um,
00074                       bool isBit);
00075 
00076   virtual ~DCPS_IR_Participant();
00077 
00078   /// Take local ownership of this participant and publish an update.
00079   void takeOwnership();
00080 
00081   /// Process an incoming update that changes ownership.
00082   void changeOwner(long sender, long owner);
00083 
00084   /// Value of the owner for this participant.
00085   long owner() const;
00086 
00087   /// Indication of whether the current repository is the owner of this participant.
00088   bool isOwner() const;
00089 
00090   ///@{
00091   /// Flag to discriminate the built-in topic publishing participant within a domain.
00092   bool& isBitPublisher();
00093   bool  isBitPublisher() const;
00094   ///@}
00095 
00096   /// Add a publication
00097   /// This takes ownership of the memory pointed to by pub
00098   /// Returns 0 if added, 1 if already exists, -1 other failure
00099   int add_publication(OpenDDS::DCPS::unique_ptr<DCPS_IR_Publication> pub);
00100 
00101   /// Return the publication object.
00102   int find_publication_reference(OpenDDS::DCPS::RepoId pubId,
00103                                  DCPS_IR_Publication*& pub);
00104 
00105   /// Removes the publication with the id
00106   /// Deletes the publication object if returns successful
00107   /// Returns 0 if successful
00108   int remove_publication(OpenDDS::DCPS::RepoId pubId);
00109 
00110   /// Add a subscription
00111   /// This takes ownership of the memory pointed to by aub
00112   /// Returns 0 if added, 1 if already exists, -1 other failure
00113   int add_subscription(OpenDDS::DCPS::unique_ptr<DCPS_IR_Subscription> sub);
00114 
00115   /// Return the subscription object.
00116   int find_subscription_reference(OpenDDS::DCPS::RepoId subId,
00117                                   DCPS_IR_Subscription*& sub);
00118 
00119   /// Removes the subscription with the id
00120   /// Deletes the subscription object if returns successful
00121   /// Returns 0 if successful
00122   int remove_subscription(OpenDDS::DCPS::RepoId subId);
00123 
00124   /// Add a topic
00125   /// Returns 0 if added, 1 if already exists, -1 other failure
00126   int add_topic_reference(DCPS_IR_Topic* topic);
00127 
00128   /// Remove a topic reference
00129   /// Does not change or take ownership of topic
00130   /// Returns 0 if successful
00131   int remove_topic_reference(OpenDDS::DCPS::RepoId topicId,
00132                              DCPS_IR_Topic*& topic);
00133 
00134   /// Find topic reference with id
00135   /// Does NOT give ownership of memory
00136   /// Returns 0 if successful
00137   int find_topic_reference(OpenDDS::DCPS::RepoId topicId,
00138                            DCPS_IR_Topic*& topic);
00139 
00140   /// Removes all topics, publications and
00141   // subscriptions for this participant
00142   void remove_all_dependents(CORBA::Boolean notify_lost);
00143 
00144   // called by publications and subscriptions when the writer
00145   // or reader throws an exception during a remote invocation
00146   //
00147   /// Changes aliveStatus to false then adds itself to the
00148   ///  domain's list of dead participants for removal
00149   void mark_dead();
00150 
00151   OpenDDS::DCPS::RepoId get_id();
00152 
00153   CORBA::Boolean is_alive();
00154   void set_alive(CORBA::Boolean alive);
00155 
00156   /// Ignore the participant with the id
00157   void ignore_participant(OpenDDS::DCPS::RepoId id);
00158   /// Ignore the topic with the id
00159   void ignore_topic(OpenDDS::DCPS::RepoId id);
00160   /// Ignore the publication with the id
00161   void ignore_publication(OpenDDS::DCPS::RepoId id);
00162   /// Ignore the subscription with the id
00163   void ignore_subscription(OpenDDS::DCPS::RepoId id);
00164 
00165   /// Return pointer to the participant qos
00166   /// Participant retains ownership
00167   const DDS::DomainParticipantQos* get_qos();
00168 
00169   /// Update qos and also propagate the qos change to related BITs
00170   /// that has the qos copy.
00171   /// Return false if the provided QoS makes the DataWriter and DataReader
00172   /// QoS incompatible. Currently supported changeable QoS in DomainParticipantQos
00173   /// do not affect.
00174   bool set_qos(const DDS::DomainParticipantQos & qos);
00175 
00176   ///@{
00177   /// Test if an entity is ignored by this participant.
00178   CORBA::Boolean is_participant_ignored(OpenDDS::DCPS::RepoId id);
00179   CORBA::Boolean is_topic_ignored(OpenDDS::DCPS::RepoId id);
00180   CORBA::Boolean is_publication_ignored(OpenDDS::DCPS::RepoId id);
00181   CORBA::Boolean is_subscription_ignored(OpenDDS::DCPS::RepoId id);
00182   ///@}
00183 
00184   DDS::InstanceHandle_t get_handle();
00185   void set_handle(DDS::InstanceHandle_t handle);
00186 
00187   DCPS_IR_Domain* get_domain_reference() const;
00188 
00189   ///@{
00190   /// Next Entity Id value in sequence.
00191   OpenDDS::DCPS::RepoId get_next_topic_id(bool builtin);
00192   OpenDDS::DCPS::RepoId get_next_publication_id(bool builtin);
00193   OpenDDS::DCPS::RepoId get_next_subscription_id(bool builtin);
00194   ///@}
00195 
00196   ///@{
00197   /// Ensure no conflicts with sequence values from persistent storage.
00198   void last_topic_key(long key);
00199   void last_publication_key(long key);
00200   void last_subscription_key(long key);
00201   ///@}
00202 
00203   /// Expose a readable reference to the publication map.
00204   const DCPS_IR_Publication_Map& publications() const;
00205 
00206   /// Expose a readable reference to the subscription map.
00207   const DCPS_IR_Subscription_Map& subscriptions() const;
00208 
00209   /// Expose a readable reference to the topic map.
00210   const DCPS_IR_Topic_Map& topics() const;
00211 
00212   std::string dump_to_string(const std::string& prefix, int depth) const;
00213 
00214 private:
00215   OpenDDS::DCPS::RepoId id_;
00216   DCPS_IR_Domain* domain_;
00217   DDS::DomainParticipantQos qos_;
00218   CORBA::Boolean aliveStatus_;
00219   DDS::InstanceHandle_t handle_;
00220 
00221   const TAO_DDS_DCPSFederationId& federationId_;
00222   long owner_;
00223 
00224   /// Lock portions ownership processing.
00225   ACE_SYNCH_MUTEX ownerLock_;
00226 
00227   ///@{
00228   /// Entity GUID Id generators.
00229   OpenDDS::DCPS::RepoIdGenerator topicIdGenerator_;
00230   OpenDDS::DCPS::RepoIdGenerator publicationIdGenerator_;
00231   OpenDDS::DCPS::RepoIdGenerator subscriptionIdGenerator_;
00232   ///@}
00233 
00234   ///@{
00235   /// Entities in the Participant
00236   DCPS_IR_Subscription_Map subscriptions_;
00237   DCPS_IR_Publication_Map publications_;
00238   DCPS_IR_Topic_Map topicRefs_;
00239   ///@}
00240 
00241   ///@{
00242   /// Lists of Ignored Entities
00243   TAO_DDS_RepoId_Set ignoredParticipants_;
00244   TAO_DDS_RepoId_Set ignoredTopics_;
00245   TAO_DDS_RepoId_Set ignoredPublications_;
00246   TAO_DDS_RepoId_Set ignoredSubscriptions_;
00247   ///@}
00248 
00249   /**
00250    * The participant is the only entity that has and deals with
00251    * dependencies (topics, actors). In handling dependencies it
00252    * encompasses a bigger role. Therefore it needs to update
00253    * other entities (specifically the Update::Manager) the
00254    * changes it makes.
00255    */
00256   Update::Manager* um_;
00257 
00258   /// Flag indicating this participant publishes built-in topics.
00259   bool isBitPublisher_;
00260 };
00261 
00262 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00263 
00264 #endif /* DCPS_IR_PARTICIPANT_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1