#include <soft_state_map.hpp>
Classes | |
class | ExpiryWithKey |
struct | ValueWithHandle |
Public Types | |
using | key_type = KEY |
using | mapped_type = VALUE |
using | value_type = std::pair<const key_type&, mapped_type&> |
using | creator_type = CTOR |
using | map_range = boost::transformed_range<data_transform, const boost::filtered_range<data_filter, data_range>> |
Public Member Functions | |
template<typename T = CTOR> | |
SoftStateMap (const Runtime &rt, typename std::enable_if< std::is_default_constructible< T >::value >::type *=nullptr) | |
SoftStateMap (const Runtime &rt, creator_type &&ctor) | |
void | set_lifetime (Clock::duration lifetime) |
mapped_type & | get_value (const key_type &key) |
mapped_type * | get_value_ptr (const key_type &key) |
const mapped_type * | get_value_ptr (const key_type &key) const |
bool | has_value (const key_type &key) const |
mapped_type & | refresh (const key_type &key) |
void | drop_expired () |
map_range | map () |
const map_range | map () const |
Private Types | |
using | heap_type = boost::heap::binomial_heap<ExpiryWithKey, boost::heap::compare<std::greater<ExpiryWithKey>>> |
using | map_type = std::unordered_map<key_type, ValueWithHandle> |
using | data_range = boost::iterator_range<typename map_type::iterator> |
using | data_filter = std::function<bool(const typename map_type::value_type&)> |
using | data_transform = std::function<value_type(typename map_type::value_type&)> |
Private Member Functions | |
ValueWithHandle & | get_data (const key_type &key) |
ValueWithHandle * | get_data_ptr (const key_type &key) |
const ValueWithHandle * | get_data_ptr (const key_type &key) const |
bool | is_expired (const ExpiryWithKey &expiry) const |
void | refresh (typename heap_type::handle_type &handle) |
Private Attributes | |
const Runtime & | m_runtime |
Clock::duration | m_lifetime |
creator_type | m_creator |
heap_type | m_heap |
map_type | m_map |
SoftStateMap is a map data structure with expiring entries
KEY | key type |
VALUE | mapped type |
CTOR | optional creator of values |
Definition at line 33 of file soft_state_map.hpp.
using vanetza::geonet::SoftStateMap< KEY, VALUE, CTOR >::creator_type = CTOR |
Definition at line 39 of file soft_state_map.hpp.
|
private |
Definition at line 69 of file soft_state_map.hpp.
|
private |
Definition at line 68 of file soft_state_map.hpp.
|
private |
Definition at line 70 of file soft_state_map.hpp.
|
private |
Definition at line 54 of file soft_state_map.hpp.
using vanetza::geonet::SoftStateMap< KEY, VALUE, CTOR >::key_type = KEY |
Definition at line 36 of file soft_state_map.hpp.
using vanetza::geonet::SoftStateMap< KEY, VALUE, CTOR >::map_range = boost::transformed_range<data_transform, const boost::filtered_range<data_filter, data_range>> |
Definition at line 174 of file soft_state_map.hpp.
|
private |
Definition at line 66 of file soft_state_map.hpp.
using vanetza::geonet::SoftStateMap< KEY, VALUE, CTOR >::mapped_type = VALUE |
Definition at line 37 of file soft_state_map.hpp.
using vanetza::geonet::SoftStateMap< KEY, VALUE, CTOR >::value_type = std::pair<const key_type&, mapped_type&> |
Definition at line 38 of file soft_state_map.hpp.
|
inline |
Construct SoftStateMap
rt | runtime object |
Definition at line 79 of file soft_state_map.hpp.
|
inline |
Construct SoftStateMap
rt | runtime object |
ctor | value creator |
Definition at line 89 of file soft_state_map.hpp.
|
inline |
Drop all entries with expired lifetime. Expired but still stored entries are only hided at retrieval until calling this method.
Definition at line 166 of file soft_state_map.hpp.
|
inlineprivate |
Definition at line 198 of file soft_state_map.hpp.
|
inlineprivate |
Definition at line 213 of file soft_state_map.hpp.
|
inlineprivate |
Definition at line 219 of file soft_state_map.hpp.
|
inline |
Get value mapped to key
key |
Definition at line 108 of file soft_state_map.hpp.
|
inline |
Get non-expired value pointer mapped to key
key |
Definition at line 118 of file soft_state_map.hpp.
|
inline |
Get non-expired value pointer mapped to key
key |
Definition at line 129 of file soft_state_map.hpp.
|
inline |
Check if non-expired value for given key exists
key |
Definition at line 140 of file soft_state_map.hpp.
|
inlineprivate |
Definition at line 225 of file soft_state_map.hpp.
|
inline |
Create a range of all non-expired entries mimicking STL's map interface
Definition at line 179 of file soft_state_map.hpp.
|
inline |
Definition at line 192 of file soft_state_map.hpp.
|
inline |
Refresh lifetime of entry associated with given key
key |
Definition at line 150 of file soft_state_map.hpp.
|
inlineprivate |
Definition at line 230 of file soft_state_map.hpp.
|
inline |
Set lifetime duration used for new and refreshed entries
lifetime | entry lieftime |
Definition at line 98 of file soft_state_map.hpp.
|
private |
Definition at line 239 of file soft_state_map.hpp.
|
private |
Definition at line 240 of file soft_state_map.hpp.
|
private |
Definition at line 238 of file soft_state_map.hpp.
|
private |
Definition at line 241 of file soft_state_map.hpp.
|
private |
Definition at line 237 of file soft_state_map.hpp.