#include <wipal/tool/iterable.hh>
Public Types | |
typedef HIDDEN | exact_type |
Iterator types | |
typedef HIDDEN | iterator |
typedef iterator | const_iterator |
Public Member Functions | |
iterator | begin () const |
iterator | end () const |
template<class OutputIterator> | |
void | operator() (const OutputIterator &output) const |
Apply a function/functor to each element | |
template<class Functor> | |
void | for_each (Functor &f) const |
template<class Functor> | |
void | for_each (const Functor &f) const |
Downcast methods | |
const exact_type & | exact () const |
exact_type & | exact () |
const exact_type * | exact_ptr () const |
exact_type * | exact_ptr () |
An iterable oject aggregates elements on which iteration is possible. iterable provides basic mechanisms to permorm this iteration. That is, it provides the iterable::iterator and iterable::const_iterator types, begin() / end() methods, and operator()().
In order to subclass iterable, you must define an iterator type for your iterable class. This type must have a similar constructor:
my_iterator::my_iterator(const my_iterable& e, bool at_end);
The first argument refers to the object you want to iterate on. The second one indicates whether to point the iterator at the begining or past the end of this object's elements.
Once you defined this iterator type, just declare it as part of your iterable class' virtual types :
template <MyIterableParams> struct types< MyIterable<MyIterableParams> > { typedef my_iterator iterator; };
typedef HIDDEN tool::iterable< Bottom >::exact_type |
Exact type for this template instantiation.
Reimplemented from tool::static_base< Bottom >.
Reimplemented in pcapxx::descriptor< Bottom >.
iterable< B >::iterator tool::iterable< B >::begin | ( | ) | const [inline] |
Get an iterator to the first element.
References tool::static_base< Bottom >::exact().
Referenced by tool::iterable< Bottom >::operator()().
iterable< B >::iterator tool::iterable< B >::end | ( | ) | const [inline] |
Get an iterator to the end (past the last element).
References tool::static_base< Bottom >::exact().
Referenced by tool::iterable< Bottom >::operator()(), and pcapxx::descriptor< Bottom >::operator[]().
void tool::iterable< B >::operator() | ( | const O & | output | ) | const [inline] |
Copy elements to output
.
References tool::iterable< Bottom >::begin(), and tool::iterable< Bottom >::end().
const static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact | ( | ) | const [inline, inherited] |
Safely downcast to the exact type as a const reference.
Referenced by tool::iterable< Bottom >::begin(), phy::header< Bottom >::decapsulate(), tool::iterable< Bottom >::end(), phy::time< Bottom >::get(), phy::header< Bottom >::len(), phy::time< Bottom >::operator+(), phy::header< Bottom >::time_get(), and phy::header< Bottom >::time_set().
static_base< Bottom >::exact_type & tool::static_base< Bottom >::exact | ( | ) | [inline, inherited] |
Safely downcast to the exact type as a non-const reference.
const static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr | ( | ) | const [inline, inherited] |
Safely downcast to the exact type as a const pointer.
Referenced by pcapxx::frame_descriptor< PCAPDescriptor >::frame_descriptor().
static_base< Bottom >::exact_type * tool::static_base< Bottom >::exact_ptr | ( | ) | [inline, inherited] |
Safely downcast to the exact type as a non-const pointer.