Line data Source code
1 : /* 2 : * Distributed under the OpenDDS License. 3 : * See: http://www.opendds.org/license.html 4 : */ 5 : 6 : #ifndef OPENDDS_DCPS_ENTITY_IMPL_H 7 : #define OPENDDS_DCPS_ENTITY_IMPL_H 8 : 9 : #include "Observer.h" 10 : #include "LocalObject.h" 11 : #include "Definitions.h" 12 : #include "AtomicBool.h" 13 : #include "transport/framework/TransportConfig_rch.h" 14 : 15 : #include <dds/DdsDcpsInfrastructureC.h> 16 : 17 : #ifndef ACE_LACKS_PRAGMA_ONCE 18 : # pragma once 19 : #endif 20 : 21 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 22 : 23 : namespace OpenDDS { 24 : namespace DCPS { 25 : 26 : class DomainParticipantImpl; 27 : 28 : /** 29 : * @class EntityImpl 30 : * 31 : * @brief Implements the OpenDDS::DCPS::Entity 32 : * interfaces. 33 : * 34 : * This class is the base class of other servant classes. 35 : * e.g. DomainParticipantImpl, PublisherImpl ... 36 : */ 37 : class OpenDDS_Dcps_Export EntityImpl 38 : : public virtual LocalObject<DDS::Entity> { 39 : public: 40 : EntityImpl(); 41 : 42 : virtual ~EntityImpl(); 43 : 44 : bool is_enabled() const; 45 : 46 : virtual DDS::StatusCondition_ptr get_statuscondition(); 47 : 48 : virtual DDS::StatusMask get_status_changes(); 49 : 50 : virtual DDS::InstanceHandle_t get_instance_handle() = 0; 51 : 52 0 : virtual DDS::DomainId_t get_domain_id() { return DOMAIN_UNKNOWN; } 53 : 54 0 : virtual GUID_t get_id() const { return GUID_UNKNOWN; } 55 : 56 : void set_status_changed_flag(DDS::StatusKind status, 57 : bool status_changed_flag); 58 : 59 : /// Call this *after* dispatching to listeners when the "changed status 60 : /// flag" is enabled so that any waiting waitsets can be unblocked. 61 : void notify_status_condition(); 62 : 63 : virtual void transport_config(const TransportConfig_rch& cfg); 64 : TransportConfig_rch transport_config() const; 65 : 66 0 : virtual RcHandle<EntityImpl> parent() const { return RcHandle<EntityImpl>(); } 67 : 68 : void set_observer(Observer_rch observer, Observer::Event e); 69 : 70 : Observer_rch get_observer(Observer::Event e); 71 : 72 : protected: 73 : DDS::ReturnCode_t set_enabled(); 74 : 75 : void set_deleted(bool state); 76 : 77 : bool get_deleted() const; 78 : 79 : DDS::InstanceHandle_t get_entity_instance_handle(const GUID_t& id, const RcHandle<DomainParticipantImpl>& participant); 80 : 81 : /// The flag indicates the entity is enabled. 82 : AtomicBool enabled_; 83 : 84 : /// The flag indicates the entity is being deleted. 85 : AtomicBool entity_deleted_; 86 : 87 : private: 88 : /// The status_changes_ variable lists all status changed flag. 89 : /// The StatusChangedFlag becomes TRUE whenever the plain communication 90 : /// status changes and it is reset to FALSE each time the application 91 : /// accesses the plain communication status via the proper 92 : /// get_<plain communication status> operation on the Entity. 93 : DDS::StatusMask status_changes_; 94 : DDS::StatusCondition_var status_condition_; 95 : 96 : TransportConfig_rch transport_config_; 97 : 98 : Observer_rch observer_; 99 : Observer::Event events_; 100 : 101 : mutable ACE_Thread_Mutex lock_; 102 : 103 : DDS::InstanceHandle_t instance_handle_; 104 : WeakRcHandle<DomainParticipantImpl> participant_for_instance_handle_; 105 : }; 106 : 107 : } // namespace DCPS 108 : } // namespace OpenDDS 109 : 110 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 111 : 112 : #endif /* OPENDDS_DCPS_ENTITY_IMPL_H */