Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #ifndef OPENDDS_DCPS_OBSERVER_H 9 : #define OPENDDS_DCPS_OBSERVER_H 10 : 11 : #include "RcObject.h" 12 : #include "Definitions.h" 13 : #include "SequenceNumber.h" 14 : #include "ValueDispatcher.h" 15 : #include "ReceivedDataElementList.h" 16 : 17 : #include <dds/DdsDcpsCoreTypeSupportImpl.h> 18 : #include <dds/DdsDcpsPublicationC.h> 19 : #include <dds/DdsDcpsSubscriptionC.h> 20 : #include <dds/DdsDcpsInfoUtilsC.h> 21 : 22 : #if !defined (ACE_LACKS_PRAGMA_ONCE) 23 : #pragma once 24 : #endif /* ACE_LACKS_PRAGMA_ONCE */ 25 : 26 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 27 : 28 : namespace OpenDDS { 29 : namespace DCPS { 30 : 31 : class DataSampleElement; 32 : class ReceivedDataSample; 33 : class ReceivedDataElement; 34 : 35 : class OpenDDS_Dcps_Export Observer 36 : : public virtual RcObject 37 : { 38 : public: 39 : typedef unsigned long Event; 40 : enum { 41 : e_ENABLED = 0x0001 << 0, 42 : e_DELETED = 0x0001 << 1, 43 : e_QOS_CHANGED = 0x0001 << 2, 44 : e_ASSOCIATED = 0x0001 << 3, 45 : e_DISASSOCIATED = 0x0001 << 4, 46 : e_SAMPLE_SENT = 0x0001 << 5, 47 : e_SAMPLE_RECEIVED = 0x0001 << 6, 48 : e_SAMPLE_READ = 0x0001 << 7, 49 : e_SAMPLE_TAKEN = 0x0001 << 8, 50 : e_NONE = 0x0000, 51 : e_ALL = 0xffff 52 : }; 53 : 54 : struct OpenDDS_Dcps_Export Sample 55 : { 56 : DDS::InstanceHandle_t instance; 57 : DDS::InstanceStateKind instance_state; 58 : DDS::Time_t timestamp; 59 : SequenceNumber sequence_number; 60 : const void* data; 61 : const ValueDispatcher& data_dispatcher; 62 : 63 : Sample(DDS::InstanceHandle_t instance, 64 : DDS::InstanceStateKind instance_state, 65 : const DDS::Time_t& timestamp, 66 : const SequenceNumber& sequence_number, 67 : const void* data, 68 : const ValueDispatcher& data_dispatcher); 69 : 70 : Sample(DDS::InstanceHandle_t instance, 71 : DDS::InstanceStateKind instance_state, 72 : const ReceivedDataElement& rde, 73 : const ValueDispatcher& data_dispatcher); 74 : }; 75 : 76 : // Group 1: Reader/Writer enabled, deleted, QoS changed 77 0 : virtual void on_enabled(DDS::DataWriter_ptr) {} 78 0 : virtual void on_enabled(DDS::DataReader_ptr) {} 79 0 : virtual void on_deleted(DDS::DataWriter_ptr) {} 80 0 : virtual void on_deleted(DDS::DataReader_ptr) {} 81 0 : virtual void on_qos_changed(DDS::DataWriter_ptr) {} 82 0 : virtual void on_qos_changed(DDS::DataReader_ptr) {} 83 : 84 : // Group 2: Peer associated, disassociated 85 0 : virtual void on_associated(DDS::DataWriter_ptr, const GUID_t& /* readerId */) {} 86 0 : virtual void on_associated(DDS::DataReader_ptr, const GUID_t& /* writerId */) {} 87 0 : virtual void on_disassociated(DDS::DataWriter_ptr, const GUID_t& /* readerId */) {} 88 0 : virtual void on_disassociated(DDS::DataReader_ptr, const GUID_t& /* writerId */) {} 89 : 90 : // Group 3: Sample sent, received, read, taken 91 0 : virtual void on_sample_sent(DDS::DataWriter_ptr, const Sample&) {} 92 0 : virtual void on_sample_received(DDS::DataReader_ptr, const Sample&) {} 93 0 : virtual void on_sample_read(DDS::DataReader_ptr, const Sample&) {} 94 0 : virtual void on_sample_taken(DDS::DataReader_ptr, const Sample&) {} 95 : 96 : virtual ~Observer(); 97 : protected: 98 : Observer() {} 99 : }; 100 : 101 : typedef RcHandle<Observer> Observer_rch; 102 : 103 : OpenDDS_Dcps_Export void 104 : vwrite(ValueWriter& vw, const Observer::Sample& sample); 105 : 106 : } // namespace DCPS 107 : } // namespace OpenDDS 108 : 109 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 110 : 111 : #endif // OPENDDS_DCPS_OBSERVER_H