OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::NetworkConfigMonitor Class Referenceabstract

#include <NetworkConfigMonitor.h>

Inheritance diagram for OpenDDS::DCPS::NetworkConfigMonitor:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::NetworkConfigMonitor:
Collaboration graph
[legend]

Public Member Functions

typedef OPENDDS_LIST (NetworkInterfaceAddress) List
 
 NetworkConfigMonitor ()
 
virtual ~NetworkConfigMonitor ()
 
void connect (RcHandle< InternalTopic< NetworkInterfaceAddress > > topic)
 
virtual bool open ()=0
 
virtual bool close ()=0
 
void disconnect (RcHandle< InternalTopic< NetworkInterfaceAddress > > topic)
 
- 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
 

Protected Member Functions

void set (const List &list)
 
void clear ()
 
void set (const NetworkInterfaceAddress &nia)
 
void remove_interface (const OPENDDS_STRING &name)
 
void remove_address (const OPENDDS_STRING &name, const NetworkAddress &address)
 
- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Private Attributes

RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_
 
List list_
 
ACE_Thread_Mutex mutex_
 

Detailed Description

Definition at line 78 of file NetworkConfigMonitor.h.

Constructor & Destructor Documentation

◆ NetworkConfigMonitor()

OpenDDS::DCPS::NetworkConfigMonitor::NetworkConfigMonitor ( )

Definition at line 41 of file NetworkConfigMonitor.cpp.

42  : writer_(make_rch<InternalDataWriter<NetworkInterfaceAddress> >(DataWriterQosBuilder().durability_transient_local()))
43 {}
RcHandle< T > make_rch()
Definition: RcHandle_T.h:256
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ ~NetworkConfigMonitor()

OpenDDS::DCPS::NetworkConfigMonitor::~NetworkConfigMonitor ( )
virtual

Definition at line 45 of file NetworkConfigMonitor.cpp.

46 {}

Member Function Documentation

◆ clear()

void OpenDDS::DCPS::NetworkConfigMonitor::clear ( void  )
protected

Definition at line 86 of file NetworkConfigMonitor.cpp.

References ACE_GUARD, list_, mutex_, and writer_.

87 {
89 
90  for (List::const_iterator pos = list_.begin(), limit = list_.end(); pos != limit; ++pos) {
91  writer_->unregister_instance(*pos);
92  }
93 
94  list_.clear();
95 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ close()

virtual bool OpenDDS::DCPS::NetworkConfigMonitor::close ( )
pure virtual

◆ connect()

void OpenDDS::DCPS::NetworkConfigMonitor::connect ( RcHandle< InternalTopic< NetworkInterfaceAddress > >  topic)

Definition at line 48 of file NetworkConfigMonitor.cpp.

References writer_.

Referenced by OpenDDS::DCPS::Service_Participant::get_domain_participant_factory().

49 {
50  topic->connect(writer_);
51 }
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ disconnect()

void OpenDDS::DCPS::NetworkConfigMonitor::disconnect ( RcHandle< InternalTopic< NetworkInterfaceAddress > >  topic)

Definition at line 53 of file NetworkConfigMonitor.cpp.

References writer_.

Referenced by OpenDDS::DCPS::Service_Participant::get_domain_participant_factory(), and OpenDDS::DCPS::Service_Participant::shutdown().

54 {
55  topic->disconnect(writer_);
56 }
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ open()

virtual bool OpenDDS::DCPS::NetworkConfigMonitor::open ( )
pure virtual

◆ OPENDDS_LIST()

typedef OpenDDS::DCPS::NetworkConfigMonitor::OPENDDS_LIST ( NetworkInterfaceAddress  )

◆ remove_address()

void OpenDDS::DCPS::NetworkConfigMonitor::remove_address ( const OPENDDS_STRING name,
const NetworkAddress address 
)
protected

Definition at line 127 of file NetworkConfigMonitor.cpp.

References ACE_GUARD, list_, mutex_, OPENDDS_END_VERSIONED_NAMESPACE_DECL, and writer_.

128 {
130 
131  for (List::iterator pos = list_.begin(), limit = list_.end(); pos != limit;) {
132  if (pos->name == name && pos->address == address) {
133  writer_->unregister_instance(*pos);
134  list_.erase(pos++);
135  } else {
136  ++pos;
137  }
138  }
139 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
const char *const name
Definition: debug.cpp:60
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ remove_interface()

void OpenDDS::DCPS::NetworkConfigMonitor::remove_interface ( const OPENDDS_STRING name)
protected

Definition at line 113 of file NetworkConfigMonitor.cpp.

References ACE_GUARD, list_, mutex_, and writer_.

114 {
116 
117  for (List::iterator pos = list_.begin(), limit = list_.end(); pos != limit;) {
118  if (pos->name == name) {
119  writer_->unregister_instance(*pos);
120  list_.erase(pos++);
121  } else {
122  ++pos;
123  }
124  }
125 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
const char *const name
Definition: debug.cpp:60
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ set() [1/2]

void OpenDDS::DCPS::NetworkConfigMonitor::set ( const List &  list)
protected

Definition at line 58 of file NetworkConfigMonitor.cpp.

References ACE_GUARD, list_, mutex_, and writer_.

59 {
61 
62  for (List::const_iterator pos = list.begin(), limit = list.end(); pos != limit; ++pos) {
63  List::const_iterator iter = std::find_if(list_.begin(), list_.end(), NetworkInterfaceAddressKeyEqual(*pos));
64  if (iter != list_.end()) {
65  if (*iter != *pos) {
66  // Change.
67  writer_->write(*pos);
68  }
69  } else {
70  // New.
71  writer_->write(*pos);
72  }
73  }
74 
75  for (List::const_iterator pos = list_.begin(), limit = list_.end(); pos != limit; ++pos) {
76  List::const_iterator iter = std::find_if(list.begin(), list.end(), NetworkInterfaceAddressKeyEqual(*pos));
77  if (iter == list.end()) {
78  // Deleted.
79  writer_->unregister_instance(*pos);
80  }
81  }
82 
83  list_ = list;
84 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

◆ set() [2/2]

void OpenDDS::DCPS::NetworkConfigMonitor::set ( const NetworkInterfaceAddress nia)
protected

Definition at line 97 of file NetworkConfigMonitor.cpp.

References ACE_GUARD, list_, mutex_, and writer_.

98 {
100 
101  List::iterator pos = std::find_if(list_.begin(), list_.end(), NetworkInterfaceAddressKeyEqual(nia));
102  if (pos != list_.end()) {
103  if (*pos != nia) {
104  writer_->write(nia);
105  *pos = nia;
106  }
107  } else {
108  writer_->write(nia);
109  list_.push_back(nia);
110  }
111 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< InternalDataWriter< NetworkInterfaceAddress > > writer_

Member Data Documentation

◆ list_

List OpenDDS::DCPS::NetworkConfigMonitor::list_
private

Definition at line 101 of file NetworkConfigMonitor.h.

Referenced by clear(), remove_address(), remove_interface(), and set().

◆ mutex_

ACE_Thread_Mutex OpenDDS::DCPS::NetworkConfigMonitor::mutex_
mutableprivate

Definition at line 103 of file NetworkConfigMonitor.h.

Referenced by clear(), remove_address(), remove_interface(), and set().

◆ writer_

RcHandle<InternalDataWriter<NetworkInterfaceAddress> > OpenDDS::DCPS::NetworkConfigMonitor::writer_
private

Definition at line 99 of file NetworkConfigMonitor.h.

Referenced by clear(), connect(), disconnect(), remove_address(), remove_interface(), and set().


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