MiXiM  2.3
RSAMConstMappingIterator Class Reference

ConstMapingIterator implementation for a RSAM. More...

#include <PhyUtils.h>

Inheritance diagram for RSAMConstMappingIterator:
Collaboration diagram for RSAMConstMappingIterator:

List of all members.

Public Member Functions

 RSAMConstMappingIterator (const RadioStateAnalogueModel *rsam, simtime_t_cref signalStart, simtime_t_cref signalEnd)
 Initializes the iterator with the passed values.
virtual void jumpTo (const Argument &pos)
 Lets the iterator point to the passed position.
virtual void setNextPosition ()
 Helper function that sets member nextPosition. Presumes that iterator it and member position are set correctly.
virtual void jumpToBegin ()
 Lets the iterator point to the begin of the function.
virtual void iterateTo (const Argument &pos)
 Iterates to the specified position. This method should be used if the new position is near the current position.
virtual void next ()
 Iterates to the next position of the function.
virtual bool inRange () const
 Returns true if the current position of the iterator is in range of the function.
virtual bool hasNext () const
 Returns true if the iterator has a next value inside its range.
virtual const ArgumentgetPosition () const
 Returns the current position of the iterator.
virtual const ArgumentgetNextPosition () const
 Returns the position the next call to "next()" of this Iterator would iterate to.
virtual argument_value_t getValue () const
 Returns the value of the function at the current position.
virtual void iterateToOverZeroSwitches (simtime_t_cref t)
 Iterates to valid entry for timepoint t over all zero-time switches starting from the current position of iterator it.

Protected Attributes

const RadioStateAnalogueModelrsam
 Pointer to the RSAM module.
RadioStateAnalogueModel::time_attenuation_collection_type::const_iterator it
 List iterator pointing to the current position.
Argument position
 The current position of this iterator.
Argument nextPosition
 The next position the iterator will jump to.
simtime_t signalStart
 The start time of the signal this iterators mapping attenuates.
simtime_t signalEnd
 The end time of the signal this iterators mapping attenuates.

Private Member Functions

 RSAMConstMappingIterator (const RSAMConstMappingIterator &)
 Copy constructor is not allowed.
RSAMConstMappingIteratoroperator= (const RSAMConstMappingIterator &)
 Assignment operator is not allowed.

Detailed Description

ConstMapingIterator implementation for a RSAM.


Member Function Documentation

bool RSAMConstMappingIterator::inRange ( ) const [virtual]

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.

Implements ConstMappingIterator.

References Argument::getTime(), position, RadioStateAnalogueModel::radioStateAttenuation, rsam, signalEnd, and signalStart.

{
  simtime_t_cref t             = position.getTime();
  simtime_t_cref lastEntryTime = std::max(rsam->radioStateAttenuation.back().getTime(), signalStart);

  return  signalStart <= t
      && t <= signalEnd
      && t <= lastEntryTime;

}
void RSAMConstMappingIterator::jumpTo ( const Argument pos) [virtual]

Lets the iterator point to the passed position.

The passed new position can be at arbitary places, jumping explicitly before signalStart is allowed.

Implements ConstMappingIterator.

References Argument::getTime(), it, position, RadioStateAnalogueModel::radioStateAttenuation, rsam, setNextPosition(), and Argument::setTime().

Referenced by RSAMMapping::createConstIterator().

{
  // extract the time-component from the argument
  simtime_t_cref t = pos.getTime();

  assert( !(rsam->radioStateAttenuation.empty()) &&
      !(t < rsam->radioStateAttenuation.front().getTime()) );

  // current position is already correct
  if( t == position.getTime() )
    return;

  // this automatically goes over all zero time switches
  it = upper_bound(rsam->radioStateAttenuation.begin(), rsam->radioStateAttenuation.end(), t);

  --it;
  position.setTime(t);
  setNextPosition();
}
virtual void RSAMConstMappingIterator::jumpToBegin ( ) [inline, virtual]

Lets the iterator point to the begin of the function.

The beginning of the function depends on the implementation.

Implements ConstMappingIterator.

References ConstMappingIterator::jumpTo().

Referenced by RSAMConstMappingIterator().

virtual void RSAMConstMappingIterator::next ( ) [inline, virtual]

Iterates to the next position of the function.

The next position depends on the implementation of the Function.

Implements ConstMappingIterator.

References ConstMappingIterator::iterateTo().

void RSAMConstMappingIterator::setNextPosition ( ) [virtual]

Helper function that sets member nextPosition. Presumes that iterator it and member position are set correctly.

This function does not care for zero time switches! This must be done before!

Might be helpful if position of iterator it has not been set by upper_bound before (it has not just been standing on the "nextPosition").

References Argument::getTime(), hasNext(), MappingUtils::incNextPosition(), it, nextPosition, position, MappingUtils::pre(), Argument::setTime(), and signalStart.

Referenced by iterateTo(), and jumpTo().

{
  if (hasNext()) // iterator it does not stand on last entry and next entry is before signal end
  {
    if(position.getTime() < signalStart) //signal start is our first key entry
    {
      nextPosition.setTime(signalStart);
    } else
    {
        RadioStateAnalogueModel::time_attenuation_collection_type::const_iterator it2 = it;
      ++it2;

      assert(it->getTime() <= position.getTime() && position.getTime() < it2->getTime());

      //point in time for the "pre step" of the next real key entry
      simtime_t_cref preTime = MappingUtils::pre(it2->getTime());

      if(position.getTime() == preTime) {
        nextPosition.setTime(it2->getTime());
      }
      else {
        nextPosition.setTime(preTime);
      }
    }

  } else // iterator it stands on last entry or next entry whould be behind signal end
  {
    nextPosition.setTime(MappingUtils::incNextPosition(position.getTime()));
  }
}

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