Public Member Functions | Protected Types | Protected Attributes

RSAMConstMappingIterator Class Reference
[phyLayer - physical layer modules]

ConstMapingIterator implementation for a RSAM. More...

#include <PhyUtils.h>

Inherits ConstMappingIterator.

Collaboration diagram for RSAMConstMappingIterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RSAMConstMappingIterator (const RadioStateAnalogueModel *rsam, simtime_t signalStart, simtime_t 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 double getValue () const
 Returns the value of the function at the current position.
virtual void iterateToOverZeroSwitches (simtime_t t)
 Iterates to valid entry for timepoint t over all zero-time switches starting from the current position of iterator it.

Protected Types

typedef std::list
< RadioStateAnalogueModel::ListEntry
CurrList
 Type for the list of attenuation entries.

Protected Attributes

const RadioStateAnalogueModelrsam
 Pointer to the RSAM module.
CurrList::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.

Detailed Description

ConstMapingIterator implementation for a RSAM.

Definition at line 421 of file PhyUtils.h.


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.

Definition at line 297 of file PhyUtils.cc.

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

{
  simtime_t t = position.getTime();
  simtime_t 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.

Definition at line 218 of file PhyUtils.cc.

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

Referenced by RSAMMapping::createConstIterator(), and jumpToBegin().

{
  // extract the time-component from the argument
  simtime_t 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.

Definition at line 477 of file PhyUtils.h.

References jumpTo(), and signalStart.

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.

Definition at line 494 of file PhyUtils.h.

References iterateTo(), and nextPosition.

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").

Definition at line 238 of file PhyUtils.cc.

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

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
    {
      CurrList::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 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(position.getTime() + 1);
  }

}


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