OpenDDS  Snapshot(2023/04/07-19:43)
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 84 of file AddressCache.h.

Constructor & Destructor Documentation

◆ AddressCache()

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

Definition at line 97 of file AddressCache.h.

97 {}

◆ ~AddressCache()

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

Definition at line 98 of file AddressCache.h.

98 {}

Member Function Documentation

◆ load()

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

Definition at line 182 of file AddressCache.h.

183  {
185  const typename MapType::const_iterator pos = map_.find(key);
186  if (pos != map_.end()) {
187  if (MonotonicTimePoint::now() < pos->second->expires_) {
188  const AddrSet& as = pos->second->addrs_;
189  for (AddrSet::const_iterator it = as.begin(), limit = as.end(); it != limit; ++it) {
190  addrs.insert(*it);
191  }
192  return true;
193  }
194  }
195  return false;
196  }
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 215 of file AddressCache.h.

216  {
218  return map_.erase(key) != 0;
219  }
sequence< octet > key

◆ remove_id()

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

Definition at line 221 of file AddressCache.h.

Referenced by OpenDDS::DCPS::RtpsUdpDataLink::remove_locator_and_bundling_cache(), and OpenDDS::DCPS::RtpsUdpDataLink::RtpsWriter::update_remote_guids_cache_i().

222  {
224  const typename IdMapType::iterator pos = id_map_.find(val);
225  if (pos != id_map_.end()) {
226  for (typename KeyVec::iterator it = pos->second.begin(), limit = pos->second.end(); it != limit; ++it) {
227  map_.erase(*it);
228  }
229  id_map_.erase(pos);
230  }
231  }

◆ 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 198 of file AddressCache.h.

199  {
201  RcHandle<AddressCacheEntry>& rch = map_[key];
202  if (rch) {
203  rch->addrs_ = addrs;
204  rch->expires_ = expires;
205  } else {
206  rch = make_rch<AddressCacheEntry>(addrs, expires);
207  GuidSet set;
208  key.get_contained_guids(set);
209  for (GuidSet::const_iterator it = set.begin(), limit = set.end(); it != limit; ++it) {
210  id_map_[*it].push_back(key);
211  }
212  }
213  }
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 235 of file AddressCache.h.


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