INET Framework for OMNeT++/OMNEST
inet::physicallayer::TimeMappingIterator< Interpolator > Class Template Reference

Provides an implementation of the MappingIterator- Interface which is able to iterate over TimeMappings. More...

#include <MappingUtils.h>

Inheritance diagram for inet::physicallayer::TimeMappingIterator< Interpolator >:
inet::physicallayer::MappingIterator inet::physicallayer::ConstMappingIterator

Public Member Functions

 TimeMappingIterator (const iterator &it)
 Initializes the Iterator to use the passed InterpolateableMapIterator. More...
 
 TimeMappingIterator (const TimeMappingIterator< Interpolator > &o)
 
virtual ~TimeMappingIterator ()
 
void jumpTo (const Argument &pos) override
 Lets the iterator point to the passed position. More...
 
void iterateTo (const Argument &pos) override
 Iterates to the specified position. More...
 
virtual void next () override
 Iterates to the next position of the function. More...
 
virtual bool inRange () const override
 Returns true if the current position of the iterator is in range of the function. More...
 
virtual const ArgumentgetPosition () const override
 Returns the current position of the iterator. More...
 
virtual const ArgumentgetNextPosition () const override
 Returns the next position a call to "next()" would jump to. More...
 
virtual mapped_type getValue () const override
 Returns the value of the function at the current position. More...
 
virtual void jumpToBegin () override
 Lets the iterator point to the begin of the mapping. More...
 
virtual bool hasNext () const override
 Returns true if the iterator has a next value inside its range a call to "next()" can jump to. More...
 
virtual void setValue (argument_value_cref_t value) override
 Changes the value of the function at the current position. More...
 
- Public Member Functions inherited from inet::physicallayer::MappingIterator
 MappingIterator ()
 
virtual ~MappingIterator ()
 
virtual void setValue (argument_value_cref_t value)=0
 Changes the value of the Mapping at the current position. More...
 
- Public Member Functions inherited from inet::physicallayer::ConstMappingIterator
 ConstMappingIterator ()
 
virtual ~ConstMappingIterator ()
 
 ConstMappingIterator (const ConstMappingIterator &)
 Copy constructor. More...
 
ConstMappingIteratoroperator= (const ConstMappingIterator &)
 ConstMappingIterator assignment operator. More...
 
void swap (ConstMappingIterator &)
 Swaps data with another ConstMappingIterator. More...
 

Protected Types

typedef InterpolateableMap< Interpolator< std::map< simtime_t, argument_value_t > > > interpolator_map_type
 The templated InterpolateableMap the underlying Mapping uses std::map as storage type. More...
 
typedef interpolator_map_type::interpolator_type interpolator_type
 
typedef interpolator_map_type::mapped_type mapped_type
 
typedef interpolator_map_type::iterator_intpl iterator
 
typedef interpolator_map_type::const_iterator_intpl const_iterator
 

Protected Member Functions

void updateNextPos ()
 

Protected Attributes

iterator valueIt
 Stores the current position iterator inside the Mapping. More...
 
Argument position
 Stores the current position of the iterator. More...
 
Argument nextPosition
 Stores the next position a call of "next()" would jump to. More...
 
bool isStepMapping
 Stores if this mapping represents a step function. More...
 
bool atPreStep
 

Additional Inherited Members

- Public Types inherited from inet::physicallayer::ConstMappingIterator
typedef Argument::mapped_type argument_value_t
 
typedef Argument::mapped_type_cref argument_value_cref_t
 

Detailed Description

template<template< typename > class Interpolator>
class inet::physicallayer::TimeMappingIterator< Interpolator >

Provides an implementation of the MappingIterator- Interface which is able to iterate over TimeMappings.

Author
Karl Wessel

Member Typedef Documentation

template<template< typename > class Interpolator>
typedef interpolator_map_type::const_iterator_intpl inet::physicallayer::TimeMappingIterator< Interpolator >::const_iterator
protected
template<template< typename > class Interpolator>
typedef InterpolateableMap<Interpolator<std::map<simtime_t, argument_value_t> > > inet::physicallayer::TimeMappingIterator< Interpolator >::interpolator_map_type
protected

The templated InterpolateableMap the underlying Mapping uses std::map as storage type.

template<template< typename > class Interpolator>
typedef interpolator_map_type::interpolator_type inet::physicallayer::TimeMappingIterator< Interpolator >::interpolator_type
protected
template<template< typename > class Interpolator>
typedef interpolator_map_type::iterator_intpl inet::physicallayer::TimeMappingIterator< Interpolator >::iterator
protected
template<template< typename > class Interpolator>
typedef interpolator_map_type::mapped_type inet::physicallayer::TimeMappingIterator< Interpolator >::mapped_type
protected

Constructor & Destructor Documentation

template<template< typename > class Interpolator>
inet::physicallayer::TimeMappingIterator< Interpolator >::TimeMappingIterator ( const iterator it)
inline

Initializes the Iterator to use the passed InterpolateableMapIterator.

177  : MappingIterator()
178  , valueIt(it)
179  , position()
180  , nextPosition()
181  , isStepMapping(it.getInterpolator().isStepping())
182  , atPreStep(false)
183  {
184  interpolator_type UsedInterpolator;
185 
186  isStepMapping = UsedInterpolator.isStepping();
188  updateNextPos();
189  }
interpolator_map_type::interpolator_type interpolator_type
Definition: MappingUtils.h:135
void setTime(simtime_t_cref time)
Changes the time value of this argument.
Definition: MappingBase.cc:64
void updateNextPos()
Definition: MappingUtils.h:162
MappingIterator()
Definition: MappingBase.h:1221
bool isStepMapping
Stores if this mapping represents a step function.
Definition: MappingUtils.h:157
key_cref_type getPosition() const
Returns the current position of the iterator.
Definition: Interpolation.h:758
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
bool atPreStep
Definition: MappingUtils.h:159
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
inet::physicallayer::TimeMappingIterator< Interpolator >::TimeMappingIterator ( const TimeMappingIterator< Interpolator > &  o)
inline
192  : MappingIterator(o)
193  , valueIt(o.valueIt)
194  , position(o.position)
195  , nextPosition(o.nextPosition)
196  , isStepMapping(o.isStepMapping)
197  , atPreStep(o.atPreStep)
198  {}
MappingIterator()
Definition: MappingBase.h:1221
bool isStepMapping
Stores if this mapping represents a step function.
Definition: MappingUtils.h:157
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
bool atPreStep
Definition: MappingUtils.h:159
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
virtual inet::physicallayer::TimeMappingIterator< Interpolator >::~TimeMappingIterator ( )
inlinevirtual
200 {}

Member Function Documentation

template<template< typename > class Interpolator>
virtual const Argument& inet::physicallayer::TimeMappingIterator< Interpolator >::getNextPosition ( ) const
inlineoverridevirtual

Returns the next position a call to "next()" would jump to.

This method has constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

290  {
291  return nextPosition;
292  }
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
template<template< typename > class Interpolator>
virtual const Argument& inet::physicallayer::TimeMappingIterator< Interpolator >::getPosition ( ) const
inlineoverridevirtual

Returns the current position of the iterator.

This method has constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

280  {
281  return position;
282  }
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
virtual mapped_type inet::physicallayer::TimeMappingIterator< Interpolator >::getValue ( ) const
inlineoverridevirtual

Returns the value of the function at the current position.

This method has constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

301  {
302  return *valueIt.getValue();
303  }
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
interpolated getValue() const
Returns the interpolated value at the current position of the Iterator.
Definition: Interpolation.h:739
template<template< typename > class Interpolator>
virtual bool inet::physicallayer::TimeMappingIterator< Interpolator >::hasNext ( ) const
inlineoverridevirtual

Returns true if the iterator has a next value inside its range a call to "next()" can jump to.

Constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

326  {
327  return valueIt.hasNext();
328  }
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
bool hasNext() const
Returns true if the a call of "next()" would increase to the position of an a valid entry of the data...
Definition: Interpolation.h:728
template<template< typename > class Interpolator>
virtual bool inet::physicallayer::TimeMappingIterator< Interpolator >::inRange ( ) const
inlineoverridevirtual

Returns true if the current position of the iterator is in range of the function.

This method should be used as end-condition when iterating over the function with the "next()" method.

THis method has constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

270  {
271  return valueIt.inRange();
272  }
bool inRange() const
Returns true if the current position of the iterator is between the position of the first and the las...
Definition: Interpolation.h:714
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
template<template< typename > class Interpolator>
void inet::physicallayer::TimeMappingIterator< Interpolator >::iterateTo ( const Argument pos)
inlineoverridevirtual

Iterates to the specified position.

This method should be used if the new position is near the current position.

The passed position should compared bigger than the current position.

This method has linear complexity over the number of key-entries between the current position and the passed position. So if the passed position is near the current position the complexity is nearly constant.

Implements inet::physicallayer::ConstMappingIterator.

230  {
231  atPreStep = false;
232  valueIt.iterateTo(pos.getTime());
233  position.setTime(pos.getTime());
235  updateNextPos();
236  }
void setTime(simtime_t_cref time)
Changes the time value of this argument.
Definition: MappingBase.cc:64
void updateNextPos()
Definition: MappingUtils.h:162
void iterateTo(key_cref_type pos)
forward iterates the iterator to the passed position.
Definition: Interpolation.h:673
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
key_type getNextPosition()
Definition: Interpolation.h:702
bool atPreStep
Definition: MappingUtils.h:159
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
void inet::physicallayer::TimeMappingIterator< Interpolator >::jumpTo ( const Argument pos)
inlineoverridevirtual

Lets the iterator point to the passed position.

The passed new position can be at arbitrary places.

This method has logarithmic complexity.

Implements inet::physicallayer::ConstMappingIterator.

210  {
211  atPreStep = false;
212  valueIt.jumpTo(pos.getTime());
213  position.setTime(pos.getTime());
215  updateNextPos();
216  }
void setTime(simtime_t_cref time)
Changes the time value of this argument.
Definition: MappingBase.cc:64
void updateNextPos()
Definition: MappingUtils.h:162
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
key_type getNextPosition()
Definition: Interpolation.h:702
bool atPreStep
Definition: MappingUtils.h:159
void jumpTo(key_cref_type pos)
Moves the iterator to the passed position.
Definition: Interpolation.h:639
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
virtual void inet::physicallayer::TimeMappingIterator< Interpolator >::jumpToBegin ( )
inlineoverridevirtual

Lets the iterator point to the begin of the mapping.

The beginning of the mapping is the smallest key entry in the InterpolateableMap.

Constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

314  {
317  }
void setTime(simtime_t_cref time)
Changes the time value of this argument.
Definition: MappingBase.cc:64
void jumpToBegin()
Moves the iterator to the first element.
Definition: Interpolation.h:653
key_cref_type getPosition() const
Returns the current position of the iterator.
Definition: Interpolation.h:758
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
virtual void inet::physicallayer::TimeMappingIterator< Interpolator >::next ( )
inlineoverridevirtual

Iterates to the next position of the function.

The next position is the next bigger key entry of the InterpoalteableMap.

This method has constant complexity.

Implements inet::physicallayer::ConstMappingIterator.

247  {
248  if (isStepMapping && !atPreStep) {
250  atPreStep = true;
251  }
252  else {
253  valueIt.next();
254  atPreStep = false;
255  }
257  updateNextPos();
258  }
void setTime(simtime_t_cref time)
Changes the time value of this argument.
Definition: MappingBase.cc:64
void updateNextPos()
Definition: MappingUtils.h:162
simtime_t_cref getTime() const
Returns the time value of this argument.
Definition: MappingBase.cc:59
bool isStepMapping
Stores if this mapping represents a step function.
Definition: MappingUtils.h:157
void iterateTo(key_cref_type pos)
forward iterates the iterator to the passed position.
Definition: Interpolation.h:673
key_cref_type getPosition() const
Returns the current position of the iterator.
Definition: Interpolation.h:758
void next()
Iterates to the next entry in the underlying data structure.
Definition: Interpolation.h:692
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
bool atPreStep
Definition: MappingUtils.h:159
Argument position
Stores the current position of the iterator.
Definition: MappingUtils.h:144
template<template< typename > class Interpolator>
virtual void inet::physicallayer::TimeMappingIterator< Interpolator >::setValue ( argument_value_cref_t  value)
inlineoverridevirtual

Changes the value of the function at the current position.

This method has constant complexity.

337  {
338  valueIt.setValue(value);
339  }
void setValue(mapped_cref_type value)
: Changes (and adds if necessary) the value for the entry at the current position of the iterator to ...
Definition: Interpolation.h:817
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
template<template< typename > class Interpolator>
void inet::physicallayer::TimeMappingIterator< Interpolator >::updateNextPos ( )
inlineprotected
163  {
164  simtime_t t = valueIt.getNextPosition();
165  if (isStepMapping && !atPreStep) {
166  t.setRaw(t.raw() - 1);
167  }
169  }
void setTime(simtime_t_cref time)
Changes the time value of this argument.
Definition: MappingBase.cc:64
bool isStepMapping
Stores if this mapping represents a step function.
Definition: MappingUtils.h:157
iterator valueIt
Stores the current position iterator inside the Mapping.
Definition: MappingUtils.h:141
Argument nextPosition
Stores the next position a call of "next()" would jump to.
Definition: MappingUtils.h:147
key_type getNextPosition()
Definition: Interpolation.h:702
bool atPreStep
Definition: MappingUtils.h:159

Member Data Documentation

template<template< typename > class Interpolator>
bool inet::physicallayer::TimeMappingIterator< Interpolator >::atPreStep
protected
template<template< typename > class Interpolator>
bool inet::physicallayer::TimeMappingIterator< Interpolator >::isStepMapping
protected

Stores if this mapping represents a step function.

Assures that the steps are considered when iterating the mapping by adding a second key-entry as short as possible before every key entry set by the user. The additional key-entry defines the value the mapping has just before the key entry the user added.

template<template< typename > class Interpolator>
Argument inet::physicallayer::TimeMappingIterator< Interpolator >::nextPosition
protected

Stores the next position a call of "next()" would jump to.

template<template< typename > class Interpolator>
Argument inet::physicallayer::TimeMappingIterator< Interpolator >::position
protected

Stores the current position of the iterator.

template<template< typename > class Interpolator>
iterator inet::physicallayer::TimeMappingIterator< Interpolator >::valueIt
protected

Stores the current position iterator inside the Mapping.


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