OpenDDS  Snapshot(2023/04/28-20:55)
InstanceState.inl
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
9 #include "ace/OS_NS_sys_time.h"
10 
12 
16 {
17  return reader_;
18 }
19 
21 void
23 {
25  //
26  // Manage the view state due to data access here.
27  //
29  const bool updated = (view_state_ != DDS::NOT_NEW_VIEW_STATE);
31  if (updated) {
32  state_updated();
33  }
34  }
35 }
36 
40 {
41  return instance_state_;
42 }
43 
47 {
48  return view_state_;
49 }
50 
53 {
54  return (view_state_ & view) && (instance_state_ & inst);
55 }
56 
59 {
61 }
62 
65 {
67 }
68 
70 void
72 {
75 
76  //
77  // Update the view state here, since only sample data received affects
78  // this state value. Then manage the data sample only transitions
79  // here. Let the lively() method manage the other transitions.
80  //
81  writers_.insert(writer_id);
82 
83  const CORBA::ULong old_view_state = view_state_;
84  const CORBA::ULong old_instance_state = instance_state_;
85 
86  switch (view_state_) {
88  break;
89 
93  }
94  break;
95 
96  default:
98  break;
99  }
100 
101  switch (instance_state_) {
104  break;
105 
108  break;
109 
110  default:
111  break;
112  }
113 
115 
116  if (view_state_ != old_view_state || instance_state_ != old_instance_state) {
117  state_updated();
118  }
119 }
120 
122 void
124 {
126 
127  //
128  // Manage transisitions in the instance state that do not require a
129  // data sample, but merely the notion of liveliness.
130  //
131  writers_.insert(writer_id);
132 
134  cancel_release(); // cancel unregister
135 
137  const bool updated = (instance_state_ != DDS::ALIVE_INSTANCE_STATE);
139  if (updated) {
140  state_updated();
141  }
142  }
143 }
144 
146 bool
148 {
149  //
150  // Manage the instance state due to the DataReader becoming empty
151  // here.
152  //
153  if ((empty_ = value) && release_pending_) {
154  return release_if_empty();
155  } else {
156  return false;
157  }
158 }
159 
160 
162 bool
164 {
166 
167  return writers_.size() == 1 && *writers_.begin() == pub;
168 }
169 
171 bool
173 {
175 
176  return writers_.empty();
177 }
178 
181 {
183 }
184 
bool is_last(const GUID_t &pub)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
WeakRcHandle< DataReaderImpl > data_reader() const
const LogLevel::Value value
Definition: debug.cpp:61
bool empty(bool value)
DataReader has become empty. Returns true if the instance was released.
void lively(const GUID_t &writer_id)
LIVELINESS message received for this DataWriter.
DDS::ViewStateKind view_state_
unsigned long InstanceStateMask
void accessed()
A read or take operation has been performed on this instance.
const ViewStateKind NOT_NEW_VIEW_STATE
const char * instance_state_string() const
Return string of the name of the current instance state.
ACE_CDR::ULong ULong
void data_was_received(const GUID_t &writer_id)
Data sample received for this instance.
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
unsigned long InstanceStateKind
const ViewStateKind NEW_VIEW_STATE
const ViewStateMask ANY_VIEW_STATE
DDS::InstanceStateKind instance_state_
ACE_Recursive_Thread_Mutex & lock_
DDS::InstanceStateKind instance_state() const
Access instance state.
bool match(DDS::ViewStateMask view, DDS::InstanceStateMask inst) const
const InstanceStateKind NOT_ALIVE_DISPOSED_INSTANCE_STATE
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
#define ACE_INLINE
const InstanceStateMask NOT_ALIVE_INSTANCE_STATE
DDS::ViewStateKind view_state() const
Access view state.
size_t disposed_generation_count() const
Access disposed generation count.
unsigned long ViewStateKind
void cancel_release()
Cancel a scheduled or pending release of resources.
const InstanceStateKind NOT_ALIVE_NO_WRITERS_INSTANCE_STATE
unsigned long ViewStateMask
const InstanceStateKind ALIVE_INSTANCE_STATE
WeakRcHandle< DataReaderImpl > reader_
size_t no_writers_generation_count() const
Access no writers generation count.