OpenDDS  Snapshot(2021/08/12-21:42)
Classes | Public Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::AddressCache< Key > Class Template Reference

#include <AddressCache.h>

Collaboration diagram for OpenDDS::DCPS::AddressCache< Key >:
Collaboration graph
[legend]

Classes

struct  ScopedAccess
 

Public Member Functions

typedef OPENDDS_MAP_T (Key, RcHandle< AddressCacheEntry >) MapType
 
typedef OPENDDS_VECTOR (Key) KeyVec
 
typedef OPENDDS_MAP_T (GUID_t, KeyVec) IdMapType
 
 AddressCache ()
 
virtual ~AddressCache ()
 
bool load (const Key &key, AddrSet &addrs) const
 
void store (const Key &key, const AddrSet &addrs, const MonotonicTimePoint &expires=MonotonicTimePoint::max_value)
 
bool remove (const Key &key)
 
void remove_id (const GUID_t &val)
 

Private Attributes

ACE_Thread_Mutex mutex_
 
MapType map_
 
IdMapType id_map_
 

Detailed Description

template<typename Key>
class OpenDDS::DCPS::AddressCache< Key >

Definition at line 53 of file AddressCache.h.

Constructor & Destructor Documentation

◆ AddressCache()

template<typename Key>
OpenDDS::DCPS::AddressCache< Key >::AddressCache ( )
inline

Definition at line 66 of file AddressCache.h.

66 {}

◆ ~AddressCache()

template<typename Key>
virtual OpenDDS::DCPS::AddressCache< Key >::~AddressCache ( )
inlinevirtual

Definition at line 67 of file AddressCache.h.

67 {}

Member Function Documentation

◆ load()

template<typename Key>
bool OpenDDS::DCPS::AddressCache< Key >::load ( const Key &  key,
AddrSet &  addrs 
) const
inline

Definition at line 116 of file AddressCache.h.

117  {
119  typename MapType::const_iterator pos = map_.find(key);
120  if (pos != map_.end()) {
121  if (MonotonicTimePoint::now() < pos->second->expires_) {
122  const AddrSet& as = pos->second->addrs_;
123  for (AddrSet::const_iterator it = as.begin(); it != as.end(); ++it) {
124  addrs.insert(*it);
125  }
126  return true;
127  }
128  }
129  return false;
130  }
sequence< octet > key
static TimePoint_T< MonotonicClock > now()
Definition: TimePoint_T.inl:41

◆ OPENDDS_MAP_T() [1/2]

template<typename Key>
typedef OpenDDS::DCPS::AddressCache< Key >::OPENDDS_MAP_T ( Key  ,
RcHandle< AddressCacheEntry  
)

◆ OPENDDS_MAP_T() [2/2]

template<typename Key>
typedef OpenDDS::DCPS::AddressCache< Key >::OPENDDS_MAP_T ( GUID_t  ,
KeyVec   
)

◆ OPENDDS_VECTOR()

template<typename Key>
typedef OpenDDS::DCPS::AddressCache< Key >::OPENDDS_VECTOR ( Key  )

◆ remove()

template<typename Key>
bool OpenDDS::DCPS::AddressCache< Key >::remove ( const Key &  key)
inline

Definition at line 149 of file AddressCache.h.

150  {
152  return map_.erase(key) != 0;
153  }
sequence< octet > key

◆ remove_id()

template<typename Key>
void OpenDDS::DCPS::AddressCache< Key >::remove_id ( const GUID_t val)
inline

Definition at line 155 of file AddressCache.h.

Referenced by OpenDDS::DCPS::RtpsUdpDataLink::remove_locator_and_bundling_cache().

156  {
158  typename IdMapType::iterator pos = id_map_.find(val);
159  if (pos != id_map_.end()) {
160  for (typename KeyVec::iterator it = pos->second.begin(); it != pos->second.end(); ++it) {
161  map_.erase(*it);
162  }
163  id_map_.erase(pos);
164  }
165  }

◆ store()

template<typename Key>
void OpenDDS::DCPS::AddressCache< Key >::store ( const Key &  key,
const AddrSet &  addrs,
const MonotonicTimePoint expires = MonotonicTimePoint::max_value 
)
inline

Definition at line 132 of file AddressCache.h.

133  {
135  RcHandle<AddressCacheEntry>& rch = map_[key];
136  if (rch) {
137  rch->addrs_ = addrs;
138  rch->expires_ = expires;
139  } else {
140  rch = make_rch<AddressCacheEntry>(addrs, expires);
141  GuidSet set;
142  key.get_contained_guids(set);
143  for (GuidSet::const_iterator it = set.begin(); it != set.end(); ++it) {
144  id_map_[*it].push_back(key);
145  }
146  }
147  }
sequence< octet > key

Member Data Documentation

◆ id_map_

template<typename Key>
IdMapType OpenDDS::DCPS::AddressCache< Key >::id_map_
private

◆ map_

template<typename Key>
MapType OpenDDS::DCPS::AddressCache< Key >::map_
private

◆ mutex_

template<typename Key>
ACE_Thread_Mutex OpenDDS::DCPS::AddressCache< Key >::mutex_
mutableprivate

Definition at line 169 of file AddressCache.h.


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