00001
00002
00003
00004
00005
00006
00007
00008 #ifndef OPENDDS_DCPS_INSTANCESTATE_H
00009 #define OPENDDS_DCPS_INSTANCESTATE_H
00010
00011 #include "dcps_export.h"
00012 #include "ace/Time_Value.h"
00013 #include "dds/DdsDcpsInfrastructureC.h"
00014 #include "dds/DCPS/Definitions.h"
00015 #include "dds/DCPS/GuidUtils.h"
00016 #include "dds/DCPS/PoolAllocator.h"
00017
00018 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00019 #pragma once
00020 #endif
00021
00022 namespace OpenDDS {
00023 namespace DCPS {
00024
00025 class DataReaderImpl;
00026 class ReceivedDataElement;
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class OpenDDS_Dcps_Export InstanceState : public ACE_Event_Handler {
00040 public:
00041
00042 InstanceState(DataReaderImpl* reader,
00043 ACE_Recursive_Thread_Mutex& lock,
00044 DDS::InstanceHandle_t handle);
00045
00046
00047 virtual ~InstanceState();
00048
00049
00050 void sample_info(DDS::SampleInfo& si,
00051 const ReceivedDataElement* de);
00052
00053
00054 DDS::InstanceStateKind instance_state() const;
00055
00056
00057 DDS::ViewStateKind view_state() const;
00058
00059
00060 size_t disposed_generation_count() const;
00061
00062
00063 size_t no_writers_generation_count() const;
00064
00065
00066
00067
00068
00069
00070 bool dispose_was_received(const PublicationId& writer_id);
00071
00072
00073
00074
00075
00076
00077 bool unregister_was_received(const PublicationId& writer_id);
00078
00079
00080 void data_was_received(const PublicationId& writer_id);
00081
00082
00083 void lively(const PublicationId& writer_id);
00084
00085
00086 void accessed();
00087
00088 bool most_recent_generation(ReceivedDataElement* item) const;
00089
00090
00091 bool empty(bool value);
00092
00093
00094 void schedule_pending();
00095
00096
00097 void schedule_release();
00098
00099
00100 void cancel_release();
00101
00102
00103
00104
00105 bool release_if_empty();
00106
00107
00108 void release();
00109
00110
00111 void writer_became_dead(const PublicationId& writer_id,
00112 int num_alive_writers,
00113 const ACE_Time_Value& when);
00114
00115 DataReaderImpl* data_reader() const;
00116
00117 virtual int handle_timeout(const ACE_Time_Value& current_time,
00118 const void* arg);
00119
00120 void set_owner (const PublicationId& owner);
00121 PublicationId& get_owner ();
00122 bool is_exclusive () const;
00123 bool registered();
00124 void registered (bool flag);
00125 bool is_last (const PublicationId& pub);
00126
00127 bool no_writer () const;
00128
00129 void reset_ownership (::DDS::InstanceHandle_t instance);
00130
00131 DDS::InstanceHandle_t instance_handle() const { return handle_; }
00132
00133 private:
00134 ACE_Recursive_Thread_Mutex& lock_;
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150 DDS::InstanceStateKind instance_state_;
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 DDS::ViewStateKind view_state_;
00165
00166
00167
00168 size_t disposed_generation_count_;
00169
00170
00171
00172 size_t no_writers_generation_count_;
00173
00174
00175
00176
00177 bool empty_;
00178
00179
00180
00181
00182 bool release_pending_;
00183
00184
00185
00186
00187 long release_timer_id_;
00188
00189
00190
00191
00192
00193
00194
00195 DataReaderImpl* reader_;
00196 DDS::InstanceHandle_t handle_;
00197
00198 RepoIdSet writers_;
00199 PublicationId owner_;
00200 bool exclusive_;
00201
00202
00203 bool registered_;
00204 };
00205
00206 }
00207 }
00208
00209 #if defined (__ACE_INLINE__)
00210 # include "InstanceState.inl"
00211 #endif
00212
00213 #endif