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

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