OpenDDS  Snapshot(2023/04/07-19:43)
Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::InternalDataReader< T > Class Template Reference

#include <InternalDataReader.h>

Inheritance diagram for OpenDDS::DCPS::InternalDataReader< T >:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::InternalDataReader< T >:
Collaboration graph
[legend]

Classes

struct  Instance
 

Public Types

typedef RcHandle< InternalDataReaderListener< T > > Listener_rch
 
typedef WeakRcHandle< InternalDataReaderListener< T > > Listener_wrch
 

Public Member Functions

typedef OPENDDS_VECTOR (T) SampleSequence
 
 InternalDataReader (bool durable=false, Listener_rch listener=Listener_rch())
 
InternalTopic and InternalWriter Interface
bool durable () const
 
void remove_publication (InternalEntity_wrch publication_handle)
 
void register_instance (InternalEntity_wrch publication_handle, const T &sample)
 
void write (InternalEntity_wrch publication_handle, const T &sample)
 
void unregister_instance (InternalEntity_wrch publication_handle, const T &sample)
 
void dispose (InternalEntity_wrch publication_handle, const T &sample)
 
User Interface
void set_listener (Listener_rch listener)
 
Listener_rch get_listener () const
 
void take (SampleSequence &samples, InternalSampleInfoSequence &infos)
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Private Member Functions

typedef OPENDDS_SET (InternalEntity_wrch) PublicationSet
 
typedef OPENDDS_MAP_T (T, Instance) InstanceMap
 

Private Attributes

const bool durable_
 
Listener_wrch listener_
 
InstanceMap instance_map_
 
ACE_Thread_Mutex mutex_
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Detailed Description

template<typename T>
class OpenDDS::DCPS::InternalDataReader< T >

Definition at line 58 of file InternalDataReader.h.

Member Typedef Documentation

◆ Listener_rch

Definition at line 61 of file InternalDataReader.h.

◆ Listener_wrch

Definition at line 62 of file InternalDataReader.h.

Constructor & Destructor Documentation

◆ InternalDataReader()

template<typename T>
OpenDDS::DCPS::InternalDataReader< T >::InternalDataReader ( bool  durable = false,
Listener_rch  listener = Listener_rch() 
)
inlineexplicit

Definition at line 64 of file InternalDataReader.h.

Member Function Documentation

◆ dispose()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::dispose ( InternalEntity_wrch  publication_handle,
const T &  sample 
)
inline

Definition at line 153 of file InternalDataReader.h.

154  {
156 
157  typename InstanceMap::iterator pos = instance_map_.find(sample);
158  if (pos == instance_map_.end()) {
159  return;
160  }
161 
162  pos->second.samples.push_back(sample);
163  pos->second.infos.push_back(InternalSampleInfo(ISIK_DISPOSE, publication_handle));
164  pos->second.instance_state = DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE;
165 
166  const Listener_rch listener = listener_.lock();
167  if (listener) {
168  listener->schedule(rchandle_from(this));
169  }
170  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< T > lock() const
Definition: RcObject.h:188
RcHandle< InternalDataReaderListener< T > > Listener_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
const InstanceStateKind NOT_ALIVE_DISPOSED_INSTANCE_STATE

◆ durable()

template<typename T>
bool OpenDDS::DCPS::InternalDataReader< T >::durable ( ) const
inline

Definition at line 72 of file InternalDataReader.h.

◆ get_listener()

template<typename T>
Listener_rch OpenDDS::DCPS::InternalDataReader< T >::get_listener ( ) const
inline

Definition at line 181 of file InternalDataReader.h.

182  {
184  return listener_.lock();
185  }
RcHandle< T > lock() const
Definition: RcObject.h:188
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
RcHandle< InternalDataReaderListener< T > > Listener_rch

◆ OPENDDS_MAP_T()

template<typename T>
typedef OpenDDS::DCPS::InternalDataReader< T >::OPENDDS_MAP_T ( ,
Instance   
)
private

◆ OPENDDS_SET()

template<typename T>
typedef OpenDDS::DCPS::InternalDataReader< T >::OPENDDS_SET ( InternalEntity_wrch  )
private

◆ OPENDDS_VECTOR()

template<typename T>
typedef OpenDDS::DCPS::InternalDataReader< T >::OPENDDS_VECTOR ( )

◆ register_instance()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::register_instance ( InternalEntity_wrch  publication_handle,
const T &  sample 
)
inline

Definition at line 92 of file InternalDataReader.h.

93  {
95 
96  const std::pair<typename InstanceMap::iterator, bool> p = instance_map_.insert(std::make_pair(sample, Instance()));
97  const std::pair<PublicationSet::iterator, bool> q = p.first->second.publication_set.insert(publication_handle);
98  if (q.second) {
99  // New publication.
100  p.first->second.samples.push_back(sample);
101  p.first->second.infos.push_back(InternalSampleInfo(ISIK_REGISTER, publication_handle));
102 
103  const Listener_rch listener = listener_.lock();
104  if (listener) {
105  listener->schedule(rchandle_from(this));
106  }
107  }
108 
109  if (p.second) {
110  p.first->second.view_state = DDS::NEW_VIEW_STATE;
111  }
112  p.first->second.instance_state = DDS::ALIVE_INSTANCE_STATE;
113  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
const ViewStateKind NEW_VIEW_STATE
const InstanceStateKind ALIVE_INSTANCE_STATE
RcHandle< T > lock() const
Definition: RcObject.h:188
RcHandle< InternalDataReaderListener< T > > Listener_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ remove_publication()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::remove_publication ( InternalEntity_wrch  publication_handle)
inline

Definition at line 74 of file InternalDataReader.h.

75  {
77 
78  // FUTURE: Index by publication_handle to avoid the loop.
79  bool schedule = false;
80  for (typename InstanceMap::iterator pos = instance_map_.begin(), limit = instance_map_.end(); pos != limit; ++pos) {
81  if (pos->second.unregister_instance(pos->first, publication_handle)) {
82  schedule = true;
83  }
84  }
85 
86  const Listener_rch listener = listener_.lock();
87  if (schedule && listener) {
88  listener->schedule(rchandle_from(this));
89  }
90  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< T > lock() const
Definition: RcObject.h:188
RcHandle< InternalDataReaderListener< T > > Listener_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ set_listener()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::set_listener ( Listener_rch  listener)
inline

Definition at line 175 of file InternalDataReader.h.

176  {
178  listener_ = listener;
179  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)

◆ take()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::take ( SampleSequence &  samples,
InternalSampleInfoSequence &  infos 
)
inline

Definition at line 187 of file InternalDataReader.h.

188  {
189  samples.clear();
190  infos.clear();
191 
193  for (typename InstanceMap::iterator pos = instance_map_.begin(), limit = instance_map_.end(); pos != limit; ) {
194  samples.insert(samples.end(), pos->second.samples.begin(), pos->second.samples.end());
195  pos->second.samples.clear();
196  infos.insert(infos.end(), pos->second.infos.begin(), pos->second.infos.end());
197  pos->second.infos.clear();
198 
199  pos->second.view_state = DDS::NOT_NEW_VIEW_STATE;
200 
201  if (pos->second.instance_state != DDS::ALIVE_INSTANCE_STATE) {
202  instance_map_.erase(pos++);
203  } else {
204  ++pos;
205  }
206  }
207  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
const InstanceStateKind ALIVE_INSTANCE_STATE
const ViewStateKind NOT_NEW_VIEW_STATE

◆ unregister_instance()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::unregister_instance ( InternalEntity_wrch  publication_handle,
const T &  sample 
)
inline

Definition at line 138 of file InternalDataReader.h.

139  {
141 
142  typename InstanceMap::iterator pos = instance_map_.find(sample);
143  if (pos == instance_map_.end()) {
144  return;
145  }
146 
147  const Listener_rch listener = listener_.lock();
148  if (pos->second.unregister_instance(sample, publication_handle) && listener) {
149  listener->schedule(rchandle_from(this));
150  }
151  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< T > lock() const
Definition: RcObject.h:188
RcHandle< InternalDataReaderListener< T > > Listener_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ write()

template<typename T>
void OpenDDS::DCPS::InternalDataReader< T >::write ( InternalEntity_wrch  publication_handle,
const T &  sample 
)
inline

Definition at line 115 of file InternalDataReader.h.

116  {
118 
119  const std::pair<typename InstanceMap::iterator, bool> p = instance_map_.insert(std::make_pair(sample, Instance()));
120  p.first->second.publication_set.insert(publication_handle);
121  p.first->second.samples.push_back(sample);
122  p.first->second.infos.push_back(InternalSampleInfo(ISIK_SAMPLE, publication_handle));
123 
124  const Listener_rch listener = listener_.lock();
125  if (listener) {
126  listener->schedule(rchandle_from(this));
127  }
128 
129  if (p.second ||
130  (p.first->second.view_state == DDS::NOT_NEW_VIEW_STATE &&
131  p.first->second.instance_state != DDS::ALIVE_INSTANCE_STATE)) {
132  p.first->second.view_state = DDS::NEW_VIEW_STATE;
133  }
134 
135  p.first->second.instance_state = DDS::ALIVE_INSTANCE_STATE;
136  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
const ViewStateKind NEW_VIEW_STATE
const InstanceStateKind ALIVE_INSTANCE_STATE
RcHandle< T > lock() const
Definition: RcObject.h:188
const ViewStateKind NOT_NEW_VIEW_STATE
RcHandle< InternalDataReaderListener< T > > Listener_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

Member Data Documentation

◆ durable_

template<typename T>
const bool OpenDDS::DCPS::InternalDataReader< T >::durable_
private

Definition at line 211 of file InternalDataReader.h.

◆ instance_map_

template<typename T>
InstanceMap OpenDDS::DCPS::InternalDataReader< T >::instance_map_
private

Definition at line 246 of file InternalDataReader.h.

◆ listener_

template<typename T>
Listener_wrch OpenDDS::DCPS::InternalDataReader< T >::listener_
private

Definition at line 215 of file InternalDataReader.h.

◆ mutex_

template<typename T>
ACE_Thread_Mutex OpenDDS::DCPS::InternalDataReader< T >::mutex_
mutableprivate

Definition at line 248 of file InternalDataReader.h.


The documentation for this class was generated from the following file: