OpenDDS  Snapshot(2023/04/28-20:55)
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

class  SampleHolder
 

Public Types

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

Public Member Functions

 InternalDataWriter (const DDS::DataWriterQos &qos)
 
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 write (const T &sample)
 
void dispose (const T &sample)
 
void unregister_instance (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 DDS::DataWriterQos qos_
 
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 46 of file InternalDataWriter.h.

Member Typedef Documentation

◆ InternalDataReader_rch

Definition at line 48 of file InternalDataWriter.h.

◆ InternalDataReader_wrch

Definition at line 49 of file InternalDataWriter.h.

Constructor & Destructor Documentation

◆ InternalDataWriter()

template<typename T>
OpenDDS::DCPS::InternalDataWriter< T >::InternalDataWriter ( const DDS::DataWriterQos qos)
inlineexplicit

Definition at line 51 of file InternalDataWriter.h.

52  : qos_(qos)
53  {}

Member Function Documentation

◆ add_reader()

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

Definition at line 57 of file InternalDataWriter.h.

58  {
60  readers_.insert(reader);
61 
62  if (qos_.durability.kind == DDS::TRANSIENT_LOCAL_DURABILITY_QOS && reader->durable()) {
63  for (typename InstanceMap::iterator pos = instance_map_.begin(), limit = instance_map_.end();
64  pos != limit; ++pos) {
65  pos->second.add_reader(reader, static_rchandle_cast<InternalEntity>(rchandle_from(this)));
66  }
67  }
68  }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
#define ACE_GUARD(MUTEX, OBJ, LOCK)
DurabilityQosPolicy durability
DurabilityQosPolicyKind kind

◆ dispose()

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

Definition at line 109 of file InternalDataWriter.h.

110  {
112 
114  typename InstanceMap::iterator pos = instance_map_.find(sample);
115  if (pos != instance_map_.end()) {
116  pos->second.dispose();
117  }
118  }
119 
120  for (typename ReaderSet::const_iterator pos = readers_.begin(), limit = readers_.end(); pos != limit; ++pos) {
121  InternalDataReader_rch reader = pos->lock();
122  if (reader) {
123  reader->dispose(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
124  }
125  }
126  }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
#define ACE_GUARD(MUTEX, OBJ, LOCK)
DurabilityQosPolicy durability
RcHandle< InternalDataReader< T > > InternalDataReader_rch
DurabilityQosPolicyKind kind

◆ has_reader()

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

Definition at line 78 of file InternalDataWriter.h.

79  {
81  return readers_.count(reader);
82  }
#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 84 of file InternalDataWriter.h.

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

◆ remove_reader()

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

Definition at line 70 of file InternalDataWriter.h.

71  {
73  if (readers_.erase(reader)) {
74  reader->remove_publication(static_rchandle_cast<InternalEntity>(rchandle_from(this)), qos_.writer_data_lifecycle.autodispose_unregistered_instances);
75  }
76  }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
#define ACE_GUARD(MUTEX, OBJ, LOCK)
WriterDataLifecycleQosPolicy writer_data_lifecycle

◆ unregister_instance()

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

Definition at line 128 of file InternalDataWriter.h.

129  {
131 
133  instance_map_.erase(sample);
134  }
135 
136  for (typename ReaderSet::const_iterator pos = readers_.begin(), limit = readers_.end(); pos != limit; ++pos) {
137  InternalDataReader_rch reader = pos->lock();
138  if (reader) {
140  reader->dispose(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
141  }
142  reader->unregister_instance(static_rchandle_cast<InternalEntity>(rchandle_from(this)), sample);
143  }
144  }
145  }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
#define ACE_GUARD(MUTEX, OBJ, LOCK)
DurabilityQosPolicy durability
RcHandle< InternalDataReader< T > > InternalDataReader_rch
DurabilityQosPolicyKind kind
WriterDataLifecycleQosPolicy writer_data_lifecycle

◆ write()

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

Definition at line 92 of file InternalDataWriter.h.

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

Member Data Documentation

◆ 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

◆ qos_

template<typename T>
const DDS::DataWriterQos OpenDDS::DCPS::InternalDataWriter< T >::qos_
private

◆ readers_

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

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