WriterInfo.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef OPENDDS_DCPS_WRITERINFO_H
00010 #define OPENDDS_DCPS_WRITERINFO_H
00011
00012 #include "dds/DdsDcpsInfoUtilsC.h"
00013 #include "dds/DdsDcpsCoreC.h"
00014 #include "dds/DCPS/PoolAllocator.h"
00015 #include "RcObject.h"
00016 #include "Definitions.h"
00017 #include "CoherentChangeControl.h"
00018 #include "DisjointSequence.h"
00019 #include "transport/framework/ReceivedDataSample.h"
00020
00021 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00022
00023 namespace OpenDDS {
00024 namespace DCPS {
00025
00026 class WriterInfo;
00027
00028 class OpenDDS_Dcps_Export WriterInfoListener
00029 {
00030 public:
00031 WriterInfoListener();
00032 virtual ~WriterInfoListener();
00033
00034 RepoId subscription_id_;
00035
00036
00037
00038
00039
00040
00041
00042 ACE_Time_Value liveliness_lease_duration_;
00043
00044
00045
00046
00047 virtual void writer_became_alive(WriterInfo& info,
00048 const ACE_Time_Value& when);
00049
00050
00051
00052
00053 virtual void writer_became_dead(WriterInfo& info,
00054 const ACE_Time_Value& when);
00055
00056
00057
00058 virtual void writer_removed(WriterInfo& info);
00059 };
00060
00061
00062 #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE
00063 enum Coherent_State {
00064 NOT_COMPLETED_YET,
00065 COMPLETED,
00066 REJECTED
00067 };
00068 #endif
00069
00070
00071
00072
00073 class OpenDDS_Dcps_Export WriterInfo : public RcObject {
00074 friend class WriteInfoListner;
00075
00076 public:
00077 enum WriterState { NOT_SET, ALIVE, DEAD };
00078 enum HistoricSamplesState { NO_TIMER = -1 };
00079
00080 WriterInfo(WriterInfoListener* reader,
00081 const PublicationId& writer_id,
00082 const DDS::DataWriterQos& writer_qos);
00083
00084
00085
00086
00087
00088
00089 ACE_Time_Value check_activity(const ACE_Time_Value& now);
00090
00091
00092 int received_activity(const ACE_Time_Value& when);
00093
00094
00095 WriterState get_state() {
00096 return state_;
00097 };
00098
00099 OPENDDS_STRING get_state_str() const;
00100
00101
00102 void removed();
00103
00104 ACE_Time_Value activity_wait_period() const;
00105
00106
00107
00108
00109 bool active() const;
00110
00111 #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE
00112 Coherent_State coherent_change_received ();
00113 void reset_coherent_info ();
00114 void set_group_info (const CoherentChangeControl& info);
00115 #endif
00116
00117 void clear_owner_evaluated ();
00118 void set_owner_evaluated (DDS::InstanceHandle_t instance, bool flag);
00119 bool is_owner_evaluated (DDS::InstanceHandle_t instance);
00120
00121
00122
00123
00124 ACE_Time_Value last_liveliness_activity_time_;
00125
00126
00127 long historic_samples_timer_;
00128 long remove_association_timer_;
00129 ACE_Time_Value removal_deadline_;
00130
00131
00132
00133 OPENDDS_MAP(SequenceNumber, ReceivedDataSample) historic_samples_;
00134
00135
00136 SequenceNumber last_historic_seq_;
00137
00138 bool waiting_for_end_historic_samples_;
00139
00140 bool scheduled_for_removal_;
00141 bool notify_lost_;
00142
00143
00144 WriterState state_;
00145
00146
00147 WriterInfoListener* reader_;
00148
00149
00150 PublicationId writer_id_;
00151
00152
00153 DDS::DataWriterQos writer_qos_;
00154
00155
00156 DDS::InstanceHandle_t handle_;
00157
00158
00159 ACE_Atomic_Op<ACE_Thread_Mutex, ACE_UINT32> coherent_samples_;
00160
00161
00162 typedef OPENDDS_MAP(DDS::InstanceHandle_t, bool) OwnerEvaluateFlags;
00163 OwnerEvaluateFlags owner_evaluated_;
00164
00165
00166 #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE
00167 bool group_coherent_;
00168 RepoId publisher_id_;
00169 DisjointSequence coherent_sample_sequence_;
00170 WriterCoherentSample writer_coherent_samples_;
00171 GroupCoherentSamples group_coherent_samples_;
00172 #endif
00173
00174 };
00175
00176 inline
00177 int
00178 OpenDDS::DCPS::WriterInfo::received_activity(const ACE_Time_Value& when)
00179 {
00180 last_liveliness_activity_time_ = when;
00181
00182 if (state_ != ALIVE) {
00183 reader_->writer_became_alive(*this, when);
00184 return 0;
00185 }
00186
00187
00188 return 1;
00189 }
00190
00191 }
00192 }
00193
00194 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00195
00196 #endif