DCPS_IR_Domain.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_DOMAIN_H
00009 #define DCPS_IR_DOMAIN_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 
00017 #include /**/ "dds/DdsDcpsDomainC.h"
00018 #include /**/ "dds/DdsDcpsInfoUtilsC.h"
00019 
00020 #if !defined (DDS_HAS_MINIMUM_BIT)
00021 #include /**/ "dds/DdsDcpsCoreTypeSupportImpl.h"
00022 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00023 
00024 #include "dds/DCPS/transport/framework/TransportConfig.h"
00025 #include "dds/DCPS/transport/tcp/TcpTransport.h"
00026 
00027 #include /**/ "ace/Unbounded_Set.h"
00028 
00029 #include <set>
00030 #include <map>
00031 
00032 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00033 #pragma once
00034 #endif /* ACE_LACKS_PRAGMA_ONCE */
00035 
00036 // forward declarations
00037 class DCPS_IR_Topic_Description;
00038 typedef std::set<DCPS_IR_Topic_Description*> DCPS_IR_Topic_Description_Set;
00039 
00040 class DCPS_IR_Participant;
00041 typedef ACE_Unbounded_Set<DCPS_IR_Participant*> DCPS_IR_Participant_Set;
00042 
00043 typedef std::map<OpenDDS::DCPS::RepoId, DCPS_IR_Participant*,
00044   OpenDDS::DCPS::GUID_tKeyLessThan> DCPS_IR_Participant_Map;
00045 
00046 class DCPS_IR_Topic;
00047 class DCPS_IR_Subscription;
00048 class DCPS_IR_Publication;
00049 
00050 /**
00051  * @class DCPS_IR_Domain
00052  *
00053  * @brief Representation of a Domain in the system.
00054  *
00055  * This represents a Domain in the system.  It contains the
00056  * representatives of the entities that are in the corresponding
00057  * system's domain.
00058  */
00059 class OpenDDS_InfoRepoLib_Export DCPS_IR_Domain {
00060 public:
00061   DCPS_IR_Domain(DDS::DomainId_t id, RepoIdGenerator& generator);
00062 
00063   ~DCPS_IR_Domain();
00064 
00065   /// Add the participant
00066   /// This takes ownership of the memory if the particpant is added.
00067   /// Returns 0 if added, 1 if already exists, -1 other failure
00068   int add_participant(DCPS_IR_Participant* participant);
00069 
00070   /// Remove the particpant
00071   /// The participant has been deleted if returns successful.
00072   /// Returns 0 if successful.
00073   /// The notify_lost parameter is passed to the remove_associations()
00074   /// See the comments of remove_associations() in DataWriterRemote.idl
00075   /// or DataReaderRemote.idl.
00076   int remove_participant(const OpenDDS::DCPS::RepoId& particpantId,
00077                          CORBA::Boolean    notify_lost);
00078 
00079   /// Find the participant with the id.
00080   DCPS_IR_Participant* participant(const OpenDDS::DCPS::RepoId& id) const;
00081 
00082   /// Add a topic to the domain
00083   /// Returns OpenDDS::DCPS::CREATED if successfull
00084   OpenDDS::DCPS::TopicStatus add_topic(OpenDDS::DCPS::RepoId_out topicId,
00085                                        const char * topicName,
00086                                        const char * dataTypeName,
00087                                        const DDS::TopicQos & qos,
00088                                        DCPS_IR_Participant* participantPtr);
00089 
00090   OpenDDS::DCPS::TopicStatus force_add_topic(const OpenDDS::DCPS::RepoId& topicId,
00091                                              const char* topicName,
00092                                              const char* dataTypeName,
00093                                              const DDS::TopicQos & qos,
00094                                              DCPS_IR_Participant* participantPtr);
00095 
00096   /// Find the topic with the topic name
00097   /// Does NOT take ownership of any initial memory pointed to by topic
00098   /// Returns OpenDDS::DCPS::FOUND if exists and topic is changed, -1 otherwise
00099   OpenDDS::DCPS::TopicStatus find_topic(const char * topicName,
00100                                         DCPS_IR_Topic*& topic);
00101 
00102   /// Find a topic object reference using the topic Id value.
00103   DCPS_IR_Topic* find_topic(const OpenDDS::DCPS::RepoId& id);
00104 
00105   /// Remove the topic
00106   /// The topic has been deleted if returns successful
00107   /// Returns OpenDDS::DCPS::REMOVED if successful
00108   OpenDDS::DCPS::TopicStatus remove_topic(DCPS_IR_Participant* part,
00109                                           DCPS_IR_Topic*& topic);
00110 
00111   /// Remove the topic from the id to topic map.
00112   /// This method should only be called by the DCPS_IR_Topic
00113   /// when deleting the topic.
00114   void remove_topic_id_mapping(const OpenDDS::DCPS::RepoId& topicId);
00115 
00116   /// Mark a participant as being unresponsive (dead) and
00117   ///  schedule it to be removed next time
00118   ///  remove_dead_participants is called.
00119   void add_dead_participant(DCPS_IR_Participant* participant);
00120 
00121   /// Remove any participants currently marked as dead
00122   void remove_dead_participants();
00123 
00124   DDS::DomainId_t get_id();
00125 
00126   // Next Entity Id value in sequence.
00127   OpenDDS::DCPS::RepoId get_next_participant_id();
00128 
00129   // Ensure no conflicts with sequence values from persistent storage.
00130   void last_participant_key(long key);
00131 
00132   /// Initialize the Built-In Topic structures
00133   /// This needs to be called before the run begins
00134   /// Returns 0 (zero) if successful
00135   int init_built_in_topics(bool federated = false);
00136 
00137   /// Cleans up the Built-In Topic structures
00138   int cleanup_built_in_topics();
00139 
00140   /// Reassociate the Built-In Topic datawriters
00141   /// This needs to be called after reincarnating from persistence and
00142   /// before the run begins
00143   /// Returns 0 (zero) if successful
00144   int reassociate_built_in_topic_pubs();
00145 
00146   /// Publish the Built-In Topic information
00147   void publish_participant_bit(DCPS_IR_Participant* participant);
00148   void publish_topic_bit(DCPS_IR_Topic* topic);
00149   void publish_subscription_bit(DCPS_IR_Subscription* subscription);
00150   void publish_publication_bit(DCPS_IR_Publication* publication);
00151 
00152   /// Remove the Built-In Topic information
00153   void dispose_participant_bit(DCPS_IR_Participant* participant);
00154   void dispose_topic_bit(DCPS_IR_Topic* topic);
00155   void dispose_subscription_bit(DCPS_IR_Subscription* subscription);
00156   void dispose_publication_bit(DCPS_IR_Publication* publication);
00157 
00158   /// Expose a readable reference to the participant map.
00159   const DCPS_IR_Participant_Map& participants() const;
00160 
00161   std::string dump_to_string(const std::string& prefix, int depth) const;
00162 
00163 private:
00164   OpenDDS::DCPS::TopicStatus add_topic_i(OpenDDS::DCPS::RepoId& topicId,
00165                                          const char * topicName,
00166                                          const char * dataTypeName,
00167                                          const DDS::TopicQos & qos,
00168                                          DCPS_IR_Participant* participantPtr);
00169 
00170   /// Takes ownership of the memory pointed to by desc if successful
00171   /// returns 0 if successful,
00172   /// 1 if description already exists
00173   /// -1 unknown error
00174   /// 2 if confliciting dataTypeName
00175   int add_topic_description(DCPS_IR_Topic_Description*& desc);
00176 
00177   /// Find the topic description with the name and data type name
00178   /// Does NOT take ownership of any initial memory pointed to by desc
00179   /// Returns 0 if found and desc is changed,
00180   ///  -1 if not found and 1 if conflicting dataTypeName
00181   int find_topic_description(const char* name,
00182                              const char* dataTypeName,
00183                              DCPS_IR_Topic_Description*& desc);
00184 
00185   /// Caller is given ownership of the topic description and any memory
00186   ///  that it has ownership of if returns successful
00187   // Returns 0 if successful
00188   int remove_topic_description(DCPS_IR_Topic_Description*& desc);
00189 
00190   /// work of initializing the built in topics is
00191   /// done in these private methods.  They were
00192   /// broken up for readability.
00193   int init_built_in_topics_topics();
00194   int init_built_in_topics_datawriters(bool federated);
00195   int init_built_in_topics_transport();
00196 
00197   DDS::DomainId_t id_;
00198 
00199   // Participant GUID Id generator.  The remaining Entities have their
00200   // values generated within the containing Participant.
00201   RepoIdGenerator& participantIdGenerator_;
00202 
00203   /// all the participants
00204   DCPS_IR_Participant_Map participants_;
00205 
00206   /// the dead participants
00207   /// dead participants exist in both this and participants_
00208   DCPS_IR_Participant_Set deadParticipants_;
00209 
00210   /// all the topics
00211   DCPS_IR_Topic_Description_Set topicDescriptions_;
00212 
00213   /// Mapping from RepoId values to Topic object references.
00214   typedef std::map<OpenDDS::DCPS::RepoId, DCPS_IR_Topic*,
00215     OpenDDS::DCPS::GUID_tKeyLessThan> IdToTopicMap;
00216 
00217   /// Actual mapping of Id values to Topic object references.
00218   IdToTopicMap idToTopicMap_;
00219 
00220   /// indicates if the BuiltIn Topics are enabled
00221   bool useBIT_;
00222 
00223   /// Built-in Topic variables
00224   DDS::DomainParticipantFactory_var                bitParticipantFactory_;
00225   DDS::DomainParticipant_var                       bitParticipant_;
00226   DDS::DomainParticipantListener_var               bitParticipantListener_;
00227   DDS::Publisher_var                               bitPublisher_;
00228 
00229 #if !defined (DDS_HAS_MINIMUM_BIT)
00230   OpenDDS::DCPS::TransportConfig_rch               transportConfig_;
00231 
00232   DDS::Topic_var                                   bitParticipantTopic_;
00233   DDS::ParticipantBuiltinTopicDataDataWriter_var   bitParticipantDataWriter_;
00234 
00235   DDS::Topic_var                                   bitTopicTopic_;
00236   DDS::TopicBuiltinTopicDataDataWriter_var         bitTopicDataWriter_;
00237 
00238   DDS::Topic_var                                   bitSubscriptionTopic_;
00239   DDS::SubscriptionBuiltinTopicDataDataWriter_var  bitSubscriptionDataWriter_;
00240 
00241   DDS::Topic_var                                   bitPublicationTopic_;
00242   DDS::PublicationBuiltinTopicDataDataWriter_var   bitPublicationDataWriter_;
00243 #endif // !defined (DDS_HAS_MINIMUM_BIT)
00244 };
00245 
00246 #endif /* DCPS_IR_DOMAIN_H */

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