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

#include <InternalDataWriter.h>

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

Classes

struct  SampleHolder
 

Public Types

typedef RcHandle< InternalDataReader< T > > InternalDataReader_rch
 
typedef WeakRcHandle< InternalDataReader< T > > InternalDataReader_wrch
 

Public Member Functions

 InternalDataWriter (bool durable)
 
InternalTopic Interface
void add_reader (InternalDataReader_rch reader)
 
void remove_reader (InternalDataReader_rch reader)
 
bool has_reader (InternalDataReader_rch reader)
 
InternalEntity_wrch publication_handle ()
 
User Interface
void register_instance (const T &sample)
 
void write (const T &sample)
 
void unregister_instance (const T &sample)
 
void dispose (const T &sample)
 
- 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 (InternalDataReader_wrch) ReaderSet
 
typedef OPENDDS_MAP_T (T, SampleHolder) InstanceMap
 

Private Attributes

const bool durable_
 
ReaderSet readers_
 
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::InternalDataWriter< T >

Definition at line 26 of file InternalDataWriter.h.

Member Typedef Documentation

◆ InternalDataReader_rch

Definition at line 28 of file InternalDataWriter.h.

◆ InternalDataReader_wrch

Definition at line 29 of file InternalDataWriter.h.

Constructor & Destructor Documentation

◆ InternalDataWriter()

template<typename T>
OpenDDS::DCPS::InternalDataWriter< T >::InternalDataWriter ( bool  durable)
inlineexplicit

Definition at line 31 of file InternalDataWriter.h.

32  : durable_(durable)
33  {}

Member Function Documentation

◆ add_reader()

template<typename T>
void OpenDDS::DCPS::InternalDataWriter< T >::add_reader ( InternalDataReader_rch  reader)
inline

Definition at line 37 of file InternalDataWriter.h.

38  {
40  readers_.insert(reader);
41 
42  if (durable_ && reader->durable()) {
43  for (typename InstanceMap::const_iterator pos = instance_map_.begin(), limit = instance_map_.end();
44  pos != limit; ++pos) {
45  if (pos->second.valid_data) {
46  reader->write(static_rchandle_cast<InternalEntity>(rchandle_from(this)), pos->second.sample);
47  } else {
48  reader->register_instance(static_rchandle_cast<InternalEntity>(rchandle_from(this)), pos->first);
49  }
50  }
51  }
52  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ dispose()

template<typename T>
void OpenDDS::DCPS::InternalDataWriter< T >::dispose ( const T &  sample)
inline

Definition at line 126 of file InternalDataWriter.h.

127  {
129 
130  if (durable_) {
131  instance_map_.erase(sample);
132  }
133 
134  for (typename ReaderSet::const_iterator pos = readers_.begin(), limit = readers_.end(); pos != limit; ++pos) {
135  InternalDataReader_rch reader = pos->lock();
136  if (reader) {
137  reader->dispose(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
138  }
139  }
140  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataReader< T > > InternalDataReader_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ has_reader()

template<typename T>
bool OpenDDS::DCPS::InternalDataWriter< T >::has_reader ( InternalDataReader_rch  reader)
inline

Definition at line 62 of file InternalDataWriter.h.

63  {
65  return readers_.count(reader);
66  }
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)

◆ OPENDDS_MAP_T()

template<typename T>
typedef OpenDDS::DCPS::InternalDataWriter< T >::OPENDDS_MAP_T ( ,
SampleHolder   
)
private

◆ OPENDDS_SET()

template<typename T>
typedef OpenDDS::DCPS::InternalDataWriter< T >::OPENDDS_SET ( InternalDataReader_wrch  )
private

◆ publication_handle()

template<typename T>
InternalEntity_wrch OpenDDS::DCPS::InternalDataWriter< T >::publication_handle ( )
inline

Definition at line 68 of file InternalDataWriter.h.

69  {
70  return static_rchandle_cast<InternalEntity>(rchandle_from(this));
71  }
RcHandle< T > static_rchandle_cast(const RcHandle< U > &h)
Definition: RcHandle_T.h:202
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ register_instance()

template<typename T>
void OpenDDS::DCPS::InternalDataWriter< T >::register_instance ( const T &  sample)
inline

Definition at line 76 of file InternalDataWriter.h.

77  {
79 
80  if (durable_) {
81  instance_map_.insert(std::make_pair(sample, SampleHolder()));
82  }
83 
84  for (typename ReaderSet::const_iterator pos = readers_.begin(), limit = readers_.end(); pos != limit; ++pos) {
85  InternalDataReader_rch reader = pos->lock();
86  if (reader) {
87  reader->register_instance(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
88  }
89  }
90  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataReader< T > > InternalDataReader_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ remove_reader()

template<typename T>
void OpenDDS::DCPS::InternalDataWriter< T >::remove_reader ( InternalDataReader_rch  reader)
inline

Definition at line 54 of file InternalDataWriter.h.

55  {
57  if (readers_.erase(reader)) {
58  reader->remove_publication(static_rchandle_cast<InternalEntity>(rchandle_from(this)));
59  }
60  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ unregister_instance()

template<typename T>
void OpenDDS::DCPS::InternalDataWriter< T >::unregister_instance ( const T &  sample)
inline

Definition at line 110 of file InternalDataWriter.h.

111  {
113 
114  if (durable_) {
115  instance_map_.erase(sample);
116  }
117 
118  for (typename ReaderSet::const_iterator pos = readers_.begin(), limit = readers_.end(); pos != limit; ++pos) {
119  InternalDataReader_rch reader = pos->lock();
120  if (reader) {
121  reader->unregister_instance(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
122  }
123  }
124  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataReader< T > > InternalDataReader_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ write()

template<typename T>
void OpenDDS::DCPS::InternalDataWriter< T >::write ( const T &  sample)
inline

Definition at line 92 of file InternalDataWriter.h.

93  {
95 
96  if (durable_) {
97  const std::pair<typename InstanceMap::iterator, bool> p = instance_map_.insert(std::make_pair(sample, SampleHolder()));
98  p.first->second.sample = sample;
99  p.first->second.valid_data = true;
100  }
101 
102  for (typename ReaderSet::const_iterator pos = readers_.begin(), limit = readers_.end(); pos != limit; ++pos) {
103  InternalDataReader_rch reader = pos->lock();
104  if (reader) {
105  reader->write(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
106  }
107  }
108  }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataReader< T > > InternalDataReader_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

Member Data Documentation

◆ durable_

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

◆ instance_map_

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

◆ mutex_

template<typename T>
ACE_Thread_Mutex OpenDDS::DCPS::InternalDataWriter< T >::mutex_
private

◆ readers_

template<typename T>
ReaderSet OpenDDS::DCPS::InternalDataWriter< T >::readers_
private

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