Public Types | Public Member Functions | Data Fields | Friends

ts::detail::IpMapBase< N > Struct Template Reference

Base template class for IP maps. More...

Collaboration diagram for ts::detail::IpMapBase< N >:
Collaboration graph
[legend]

Public Types

typedef IpMapBase self
 Self reference type.
typedef N::ArgType ArgType
 Import type.
typedef N::Metric Metric
 Import type.g482.
typedef IntrusiveDList< RBNode,&RBNode::_next,&RBNode::_prevNodeList
 In order list of nodes.

Public Member Functions

 IpMapBase ()
 ~IpMapBase ()
selfmark (ArgType min, ArgType max, void *data=0)
 Mark a range.
selfunmark (ArgType min, ArgType max)
 Unmark addresses.
selffill (ArgType min, ArgType max, void *data=0)
 Fill addresses.
bool contains (ArgType target, void **ptr=0) const
 Test for membership.
selfclear ()
 Remove all addresses in the map.
N * lowerBound (ArgType target)
 Lower bound for target.
void insertAfter (N *spot, N *n)
 Insert n after spot.
void insertBefore (N *spot, N *n)
 Insert n before spot.
void prepend (N *n)
 Add node n as the first node.
void append (N *n)
 Add node n as the last node.
void remove (N *n)
 Remove a node.
void validate ()
 Validate internal data structures.
size_t getCount () const
selfprint ()
 Print all spans.
N * prev (RBNode *n) const
N * next (RBNode *n) const
N * parent (RBNode *n) const
N * left (RBNode *n) const
N * right (RBNode *n) const
N * getHead ()
N * getTail ()

Data Fields

N * _root
 Root node.
NodeList _list
 This keeps track of all allocated nodes in order.

Friends

class ::IpMap

Detailed Description

template<typename N>
struct ts::detail::IpMapBase< N >

Base template class for IP maps.

This class is templated by the N type which must be a subclass of RBNode. This class carries information about the addresses stored in the map. This includes the type, the common argument type, and some utility methods to operate on the address.

Definition at line 434 of file IpMap.cc.


Member Typedef Documentation

template<typename N>
typedef N::ArgType ts::detail::IpMapBase< N >::ArgType

Import type.

Definition at line 438 of file IpMap.cc.

template<typename N>
typedef N::Metric ts::detail::IpMapBase< N >::Metric

Import type.g482.

Definition at line 439 of file IpMap.cc.

In order list of nodes.

For ugly compiler reasons, this is a list of base class pointers even though we really store N instances on it.

Definition at line 561 of file IpMap.cc.

template<typename N>
typedef IpMapBase ts::detail::IpMapBase< N >::self

Self reference type.

Definition at line 437 of file IpMap.cc.


Constructor & Destructor Documentation

template<typename N>
ts::detail::IpMapBase< N >::IpMapBase (  )  [inline]

Definition at line 441 of file IpMap.cc.

template<typename N>
ts::detail::IpMapBase< N >::~IpMapBase (  )  [inline]

Definition at line 442 of file IpMap.cc.


Member Function Documentation

template<typename N>
void ts::detail::IpMapBase< N >::append ( N *  n  ) 
template<typename N >
IpMapBase< N > & ts::detail::IpMapBase< N >::clear ( void   ) 

Remove all addresses in the map.

Note:
This is much faster than using unmark with a range of all addresses.
Returns:
This object.

Definition at line 583 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, ts::detail::IpMapBase< N >::_root, IntrusiveDList< T, N, P >::clear(), IntrusiveDList< T, N, P >::getHead(), and ts::detail::IpMapBase< N >::next().

Referenced by IpMap::clear(), and ts::detail::IpMapBase< Ip6Node >::~IpMapBase().

template<typename N >
bool ts::detail::IpMapBase< N >::contains ( ArgType  target,
void **  ptr = 0 
) const

Test for membership.

Returns:
true if the address is in the map, false if not. If the address is in the map and ptr is not NULL, *ptr is set to the client data for the address.
Parameters:
target Search target value.
ptr Client data return.

Definition at line 916 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_root, ts::detail::IpMapBase< N >::left(), and ts::detail::IpMapBase< N >::right().

Referenced by IpMap::contains().

template<typename N >
IpMapBase< N > & ts::detail::IpMapBase< N >::fill ( ArgType  min,
ArgType  max,
void *  data = 0 
)

Fill addresses.

This background fills using the range. All addresses in the range that are not present in the map are added. No previously present address is changed.

Note:
This is useful for filling in first match tables.
Returns:
This object.

Definition at line 597 of file IpMap.cc.

References ts::detail::IpMapBase< N >::append(), ts::detail::IpMapBase< N >::getHead(), ts::detail::IpMapBase< N >::insertBefore(), ts::detail::IpMapBase< N >::lowerBound(), max(), min(), and ts::detail::IpMapBase< N >::next().

Referenced by IpMap::fill().

template<typename N >
size_t ts::detail::IpMapBase< N >::getCount (  )  const
Returns:
The number of distinct ranges.

Definition at line 931 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, and IntrusiveDList< T, N, P >::getCount().

Referenced by IpMap::getCount().

template<typename N>
N* ts::detail::IpMapBase< N >::getHead (  )  [inline]
template<typename N>
N* ts::detail::IpMapBase< N >::getTail (  )  [inline]

Definition at line 555 of file IpMap.cc.

Referenced by IpMap::iterator::operator++(), and IpMap::iterator::operator--().

template<typename N>
void ts::detail::IpMapBase< N >::insertAfter ( N *  spot,
N *  n 
)

Insert n after spot.

Caller is responsible for ensuring that spot is in this container and the proper location for n.

Parameters:
spot Node in list.
n Node to insert.

Definition at line 875 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, ts::detail::IpMapBase< N >::_root, IntrusiveDList< T, N, P >::insertAfter(), and ts::detail::IpMapBase< N >::right().

Referenced by ts::detail::IpMapBase< N >::mark(), and ts::detail::IpMapBase< N >::unmark().

template<typename N>
void ts::detail::IpMapBase< N >::insertBefore ( N *  spot,
N *  n 
)

Insert n before spot.

Caller is responsible for ensuring that spot is in this container and the proper location for n.

Parameters:
spot Node in list.
n Node to insert.

Definition at line 885 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, ts::detail::IpMapBase< N >::_root, IntrusiveDList< T, N, P >::insertBefore(), and ts::detail::IpMapBase< N >::left().

Referenced by ts::detail::IpMapBase< N >::fill(), and ts::detail::IpMapBase< N >::mark().

template<typename N>
N* ts::detail::IpMapBase< N >::left ( RBNode n  )  const [inline]
template<typename N >
N * ts::detail::IpMapBase< N >::lowerBound ( ArgType  target  ) 

Lower bound for target.

Returns:
The node whose minimum value is the largest that is not greater than target, or NULL if all minimum values are larger than target.

Definition at line 568 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_root, ts::detail::IpMapBase< N >::left(), and ts::detail::IpMapBase< N >::right().

Referenced by ts::detail::IpMapBase< N >::fill(), ts::detail::IpMapBase< N >::mark(), and ts::detail::IpMapBase< N >::unmark().

template<typename N >
IpMapBase< N > & ts::detail::IpMapBase< N >::mark ( ArgType  min,
ArgType  max,
void *  data = 0 
)

Mark a range.

All addresses in the range [ min , max ] are marked with data.

Returns:
This object.
Parameters:
min Minimum value in range.
max Maximum value in range.
data Client data payload.

Definition at line 715 of file IpMap.cc.

References ts::detail::IpMapBase< N >::append(), ts::detail::IpMapBase< N >::getHead(), ts::detail::IpMapBase< N >::insertAfter(), ts::detail::IpMapBase< N >::insertBefore(), ts::detail::IpMapBase< N >::lowerBound(), ts::detail::IpMapBase< N >::next(), ts::detail::IpMapBase< N >::prepend(), and ts::detail::IpMapBase< N >::prev().

Referenced by IpMap::mark().

template<typename N>
N* ts::detail::IpMapBase< N >::next ( RBNode n  )  const [inline]
template<typename N>
N* ts::detail::IpMapBase< N >::parent ( RBNode n  )  const [inline]

Definition at line 551 of file IpMap.cc.

template<typename N>
void ts::detail::IpMapBase< N >::prepend ( N *  n  ) 
template<typename N>
N* ts::detail::IpMapBase< N >::prev ( RBNode n  )  const [inline]

Definition at line 549 of file IpMap.cc.

Referenced by ts::detail::IpMapBase< N >::mark().

template<typename N >
IpMapBase< N > & ts::detail::IpMapBase< N >::print (  ) 

Print all spans.

Returns:
This map.

Definition at line 952 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, ts::detail::RBNode::_next, and IntrusiveDList< T, N, P >::getHead().

template<typename N>
void ts::detail::IpMapBase< N >::remove ( N *  n  ) 

Remove a node.

Parameters:
n Node to remove.

Definition at line 909 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, ts::detail::IpMapBase< N >::_root, and IntrusiveDList< T, N, P >::take().

template<typename N>
N* ts::detail::IpMapBase< N >::right ( RBNode n  )  const [inline]
template<typename N >
IpMapBase< N > & ts::detail::IpMapBase< N >::unmark ( ArgType  min,
ArgType  max 
)

Unmark addresses.

All addresses in the range [ min , max ] are cleared (removed from the map), no longer marked.

Returns:
This object.

Definition at line 838 of file IpMap.cc.

References ts::detail::IpMapBase< N >::insertAfter(), ts::detail::IpMapBase< N >::lowerBound(), and ts::detail::IpMapBase< N >::next().

Referenced by IpMap::unmark().

template<typename N >
void ts::detail::IpMapBase< N >::validate (  ) 

Validate internal data structures.

Note:
Intended for debugging, not general client use.

Definition at line 934 of file IpMap.cc.

References ts::detail::IpMapBase< N >::_list, ts::detail::RBNode::_next, ts::detail::IpMapBase< N >::_root, and IntrusiveDList< T, N, P >::getHead().


Friends And Related Function Documentation

template<typename N>
friend class ::IpMap [friend]

Reimplemented in ts::detail::Ip4Map, and ts::detail::Ip6Map.

Definition at line 435 of file IpMap.cc.


Field Documentation

template<typename N>
NodeList ts::detail::IpMapBase< N >::_list
template<typename N>
N* ts::detail::IpMapBase< N >::_root

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