LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
swoc::IPSpace< PAYLOAD > Class Template Reference

#include <IPRange.h>

Collaboration diagram for swoc::IPSpace< PAYLOAD >:
Collaboration graph

Classes

class  const_iterator
 
class  iterator
 

Public Types

using payload_t = PAYLOAD
 
using value_type = detail::ip_space_value_type<PAYLOAD>
 Iterator value, a range and payload.
 

Public Member Functions

 IPSpace ()=default
 Construct an empty space.
 
self_typemark (IPRange const &range, PAYLOAD const &payload)
 
self_typemark_bulk (std::pair< DiscreteRange< IP4Addr >, PAYLOAD > *range_payloads, size_t size, bool is_sorted=false)
 
self_typemark_bulk (std::vector< std::pair< DiscreteRange< IP4Addr >, PAYLOAD > > &range_payloads, bool is_sorted=false)
 vector-based interface for the previous function.
 
self_typemark_bulk (std::pair< DiscreteRange< IP6Addr >, PAYLOAD > *range_payloads, size_t size, bool is_sorted=false)
 
self_typemark_bulk (std::vector< std::pair< DiscreteRange< IP6Addr >, PAYLOAD > > &range_payloads, bool is_sorted=false)
 vector-based interface for the previous function.
 
self_typefill (IPRange const &range, PAYLOAD const &payload)
 
self_typeerase (IPRange const &range)
 
template<typename F, typename U = PAYLOAD>
self_typeblend (IPRange const &range, U const &color, F &&blender)
 
template<typename F, typename U = PAYLOAD>
self_typeblend (IP4Range const &range, U const &color, F &&blender)
 
template<typename F, typename U = PAYLOAD>
self_typeblend (IP6Range const &range, U const &color, F &&blender)
 
size_t count () const
 
size_t count_ip4 () const
 
size_t count_ip6 () const
 
size_t count (sa_family_t f) const
 
bool empty () const
 
void clear ()
 Remove all ranges.
 
iterator find (IPAddr const &addr)
 
const_iterator find (IPAddr const &addr) const
 
iterator find (IP4Addr const &addr)
 
const_iterator find (IP4Addr const &addr) const
 
iterator find (IP6Addr const &addr)
 
const_iterator find (IP6Addr const &addr) const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
iterator begin_ip4 ()
 
const_iterator begin_ip4 () const
 
iterator end_ip4 ()
 
const_iterator end_ip4 () const
 
iterator begin_ip6 ()
 
const_iterator begin_ip6 () const
 
iterator end_ip6 ()
 
const_iterator end_ip6 () const
 
const_iterator begin (sa_family_t family) const
 
const_iterator end (sa_family_t family) const
 
std::pair< iterator, iteratorintersection (IP4Range const &r)
 
std::pair< iterator, iteratorintersection (IP6Range const &r)
 
std::pair< iterator, iteratorintersection (IPRange const &r)
 
template<typename F, typename U>
auto blend (IPRange const &range, U const &color, F &&blender) -> self_type &
 
template<typename F, typename U>
auto blend (IP4Range const &range, U const &color, F &&blender) -> self_type &
 
template<typename F, typename U>
auto blend (IP6Range const &range, U const &color, F &&blender) -> self_type &
 

Protected Member Functions

iterator iterator_at (typename IP4Space::const_iterator const &spot)
 
iterator iterator_at (typename IP6Space::const_iterator const &spot)
 

Protected Attributes

IP4Space _ip4
 Sub-space containing IPv4 ranges.
 
IP6Space _ip6
 sub-space containing IPv6 ranges.
 

Friends

class IPRangeSet
 

Detailed Description

template<typename PAYLOAD>
class swoc::IPSpace< PAYLOAD >

Coloring of IP address space.

Template Parameters
PAYLOADThe color class.

This is a class to do fast coloring and lookup of the IP address space. It is range oriented and performs well for ranges, much less well for singletons. Conceptually every IP address is a key in the space and can have a color / payload of type PAYLOAD.

PAYLOAD must have the properties

  • Cheap to copy.
  • Comparable via the equality and inequality operators.

Definition at line 1117 of file IPRange.h.

Member Typedef Documentation

◆ payload_t

template<typename PAYLOAD>
using swoc::IPSpace< PAYLOAD >::payload_t = PAYLOAD

Export payload type.

Definition at line 1123 of file IPRange.h.

◆ value_type

template<typename PAYLOAD>
using swoc::IPSpace< PAYLOAD >::value_type = detail::ip_space_value_type<PAYLOAD>

Iterator value, a range and payload.

Definition at line 1125 of file IPRange.h.

Member Function Documentation

◆ begin() [1/3]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin ( )
Returns
An iterator to the first element.

Definition at line 2589 of file IPRange.h.

◆ begin() [2/3]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin ( ) const
Returns
A constant iterator to the first element.

Definition at line 2595 of file IPRange.h.

◆ begin() [3/3]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin ( sa_family_t family) const
Returns
Iterator to the first address of family.

Definition at line 2713 of file IPRange.h.

◆ begin_ip4() [1/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin_ip4 ( )
Returns
Iterator to the first IPv4 address.

Definition at line 2613 of file IPRange.h.

◆ begin_ip4() [2/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin_ip4 ( ) const
Returns
Iterator to the first IPv4 address.

Definition at line 2619 of file IPRange.h.

◆ begin_ip6() [1/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin_ip6 ( )
Returns
Iterator at the first IPv6 address.

Definition at line 2637 of file IPRange.h.

◆ begin_ip6() [2/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::begin_ip6 ( ) const
Returns
Iterator at the first IPv6 address.

Definition at line 2643 of file IPRange.h.

◆ blend() [1/4]

template<typename PAYLOAD>
template<typename F, typename U>
auto swoc::IPSpace< PAYLOAD >::blend ( IP4Range const & range,
U const & color,
F && blender ) -> self_type &

Definition at line 2567 of file IPRange.h.

◆ blend() [2/4]

template<typename PAYLOAD>
template<typename F, typename U>
auto swoc::IPSpace< PAYLOAD >::blend ( IP6Range const & range,
U const & color,
F && blender ) -> self_type &

Definition at line 2575 of file IPRange.h.

◆ blend() [3/4]

template<typename PAYLOAD>
template<typename F, typename U = PAYLOAD>
self_type & swoc::IPSpace< PAYLOAD >::blend ( IPRange const & range,
U const & color,
F && blender )

Blend color in to the range.

Template Parameters
FBlending functor type (deduced).
UData to blend in to payloads.
Parameters
rangeTarget range.
colorData to blend in to existing payloads in range.
blenderBlending functor.
Returns
this

blender is required to have the signature void(PAYLOAD& lhs , U CONST&rhs). It must act as a compound assignment operator, blending rhs into lhs. That is, if the result of blending rhs in to lhs is defined as "lhs @ rhs" for the binary operator "@", then blender computes "lhs @= rhs".

Every address in range is assigned a payload. If the address does not already have a color, it is assigned the default constructed PAYLOAD blended with color. If the address has a PAYLOAD p, p is updated by invoking blender(p, color), with the expectation that p will be updated in place.

◆ blend() [4/4]

template<typename PAYLOAD>
template<typename F, typename U>
auto swoc::IPSpace< PAYLOAD >::blend ( IPRange const & range,
U const & color,
F && blender ) -> self_type &

Definition at line 2555 of file IPRange.h.

◆ clear()

template<typename PAYLOAD>
void swoc::IPSpace< PAYLOAD >::clear ( )

Remove all ranges.

Definition at line 2582 of file IPRange.h.

◆ count() [1/2]

template<typename PAYLOAD>
size_t swoc::IPSpace< PAYLOAD >::count ( ) const
Returns
The number of distinct ranges.

Definition at line 2747 of file IPRange.h.

◆ count() [2/2]

template<typename PAYLOAD>
size_t swoc::IPSpace< PAYLOAD >::count ( sa_family_t f) const

Number of rnages for a specific address family.

Parameters
fAddress family.
Returns
The number of ranges of family.

Definition at line 2753 of file IPRange.h.

◆ count_ip4()

template<typename PAYLOAD>
size_t swoc::IPSpace< PAYLOAD >::count_ip4 ( ) const
Returns
The number of IPv4 ranges.

Definition at line 2735 of file IPRange.h.

◆ count_ip6()

template<typename PAYLOAD>
size_t swoc::IPSpace< PAYLOAD >::count_ip6 ( ) const
Returns
The number of IPv6 ranges.

Definition at line 2741 of file IPRange.h.

◆ empty()

template<typename PAYLOAD>
bool swoc::IPSpace< PAYLOAD >::empty ( ) const
Returns
true if there are no ranges in the space, false otherwise.

Definition at line 2759 of file IPRange.h.

◆ end() [1/3]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end ( )
Returns
An iterator past the last element.

Definition at line 2601 of file IPRange.h.

◆ end() [2/3]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end ( ) const
Returns
A constant iterator past the last element.

Definition at line 2607 of file IPRange.h.

◆ end() [3/3]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end ( sa_family_t family) const
Returns
Iterator past the last address of family.

Definition at line 2724 of file IPRange.h.

◆ end_ip4() [1/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end_ip4 ( )
Returns
Iterator past the last IPv4 address.

Definition at line 2625 of file IPRange.h.

◆ end_ip4() [2/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end_ip4 ( ) const
Returns
Iterator past the last IPv4 address.

Definition at line 2631 of file IPRange.h.

◆ end_ip6() [1/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end_ip6 ( )
Returns
Iterator past the last IPv6 address.

Definition at line 2649 of file IPRange.h.

◆ end_ip6() [2/2]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::end_ip6 ( ) const
Returns
Iterator past the last IPv6 address.

Definition at line 2655 of file IPRange.h.

◆ erase()

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::erase ( IPRange const & range)

Erase addresses in range.

Parameters
rangeAddress range.
Returns
this

Definition at line 2543 of file IPRange.h.

◆ fill()

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::fill ( IPRange const & range,
PAYLOAD const & payload )

Fill the range with payload.

Parameters
rangeDestination range.
payloadPayload for range.
Returns
this

Addresses in range are set to have payload if the address does not already have a payload.

Definition at line 2532 of file IPRange.h.

◆ find() [1/6]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::find ( IP4Addr const & addr)

Find the payload for an addr.

Parameters
addrAddress to find.
Returns
An iterator which is valid if addr was found, end if not.

Definition at line 2683 of file IPRange.h.

◆ find() [2/6]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::find ( IP4Addr const & addr) const

Find the payload for an addr.

Parameters
addrAddress to find.
Returns
An iterator which is valid if addr was found, end if not.

Definition at line 2692 of file IPRange.h.

◆ find() [3/6]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::find ( IP6Addr const & addr)

Find the payload for an addr.

Parameters
addrAddress to find.
Returns
An iterator which is valid if addr was found, end if not.

Definition at line 2701 of file IPRange.h.

◆ find() [4/6]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::find ( IP6Addr const & addr) const

Find the payload for an addr.

Parameters
addrAddress to find.
Returns
An iterator which is valid if addr was found, end if not.

Definition at line 2707 of file IPRange.h.

◆ find() [5/6]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::find ( IPAddr const & addr)

Find the payload for an addr.

Parameters
addrAddress to find.
Returns
Iterator for the range containing addr.

Definition at line 2661 of file IPRange.h.

◆ find() [6/6]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::find ( IPAddr const & addr) const

Find the payload for an addr.

Parameters
addrAddress to find.
Returns
Iterator for the range containing addr.

Definition at line 2672 of file IPRange.h.

◆ intersection() [1/3]

template<typename PAYLOAD>
std::pair< iterator, iterator > swoc::IPSpace< PAYLOAD >::intersection ( IP4Range const & r)
inline

Sequnce of ranges that intersect r.

Parameters
rSearch range.
Returns
Iterator pair covering ranges that intersect r.

Definition at line 1487 of file IPRange.h.

◆ intersection() [2/3]

template<typename PAYLOAD>
std::pair< iterator, iterator > swoc::IPSpace< PAYLOAD >::intersection ( IP6Range const & r)
inline

Sequnce of ranges that intersect r.

Parameters
rSearch range.
Returns
Iterator pair covering ranges that intersect r.

Definition at line 1498 of file IPRange.h.

◆ intersection() [3/3]

template<typename PAYLOAD>
std::pair< iterator, iterator > swoc::IPSpace< PAYLOAD >::intersection ( IPRange const & r)
inline

Sequnce of ranges that intersect r.

Parameters
rSearch range.
Returns
Iterator pair covering ranges that intersect r.

Definition at line 1509 of file IPRange.h.

◆ iterator_at() [1/2]

template<typename PAYLOAD>
iterator swoc::IPSpace< PAYLOAD >::iterator_at ( typename IP4Space::const_iterator const & spot)
inlineprotected

Definition at line 1523 of file IPRange.h.

◆ iterator_at() [2/2]

template<typename PAYLOAD>
iterator swoc::IPSpace< PAYLOAD >::iterator_at ( typename IP6Space::const_iterator const & spot)
inlineprotected

Definition at line 1527 of file IPRange.h.

◆ mark()

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::mark ( IPRange const & range,
PAYLOAD const & payload )

Mark the range r with payload.

Parameters
rangeRange to mark.
payloadPayload to assign.
Returns
this

All addresses in r are set to have the payload.

Definition at line 2521 of file IPRange.h.

◆ mark_bulk() [1/4]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::mark_bulk ( std::pair< DiscreteRange< IP4Addr >, PAYLOAD > * range_payloads,
size_t size,
bool is_sorted = false )

Mark ranges of IP4Addr in the IPSpace in one operation.

Parameters
range_payloadsArray of range/payload pairs.
sizeNumber of elements in range_payloads.
is_sortedtrue if input is sorted, false if not. Assumes not sorted.
Returns
this

Definition at line 2493 of file IPRange.h.

◆ mark_bulk() [2/4]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::mark_bulk ( std::pair< DiscreteRange< IP6Addr >, PAYLOAD > * range_payloads,
size_t size,
bool is_sorted = false )

Mark ranges of IP6Addr in the IPSpace in one operation.

Parameters
range_payloadsArray of range/payload pairs.
sizeNumber of elements in range_payloads.
is_sortedtrue if input is sorted, false if not. Assumes not sorted.
Returns
this

Definition at line 2500 of file IPRange.h.

◆ mark_bulk() [3/4]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::mark_bulk ( std::vector< std::pair< DiscreteRange< IP4Addr >, PAYLOAD > > & range_payloads,
bool is_sorted = false )

vector-based interface for the previous function.

Definition at line 2507 of file IPRange.h.

◆ mark_bulk() [4/4]

template<typename PAYLOAD>
auto swoc::IPSpace< PAYLOAD >::mark_bulk ( std::vector< std::pair< DiscreteRange< IP6Addr >, PAYLOAD > > & range_payloads,
bool is_sorted = false )

vector-based interface for the previous function.

Definition at line 2514 of file IPRange.h.

Friends And Related Symbol Documentation

◆ IPRangeSet

template<typename PAYLOAD>
friend class IPRangeSet
friend

Definition at line 1531 of file IPRange.h.

Member Data Documentation

◆ _ip4

template<typename PAYLOAD>
IP4Space swoc::IPSpace< PAYLOAD >::_ip4
protected

Sub-space containing IPv4 ranges.

Definition at line 1519 of file IPRange.h.

◆ _ip6

template<typename PAYLOAD>
IP6Space swoc::IPSpace< PAYLOAD >::_ip6
protected

sub-space containing IPv6 ranges.

Definition at line 1520 of file IPRange.h.


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