Public Member Functions | Protected Attributes | Private Member Functions

ConstMapping Class Reference
[mapping - classes representing mathematical mappings]

Represents a not changeable mapping (mathematical function) from domain with at least the time to a double value. More...

#include <MappingBase.h>

Inherited by BaseDelayedMapping< ConstMapping >, ConcatConstMapping< Operator >, Mapping, RSAMMapping, and SimpleConstMapping.

Collaboration diagram for ConstMapping:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ConstMapping ()
 Initializes the ConstMapping with a the time dimension as domain.
 ConstMapping (const DimensionSet &dimSet)
 Initializes the ConstMapping with the passed DimensionSet as Domain.
virtual double getValue (const Argument &pos) const =0
 Returns the value of this Mapping at the position specified by the passed Argument.
virtual ConstMappingIteratorcreateConstIterator ()=0
 Returns a pointer of a new Iterator which is able to iterate over this Mapping.
virtual ConstMappingIteratorcreateConstIterator (const Argument &pos)=0
 Returns a pointer of a new Iterator which is able to iterate over the function. The iterator starts at the passed position.
virtual ConstMappingconstClone () const =0
 returns a deep copy of this mapping instance.
double operator[] (const Argument &pos) const
 Returns the value of this Mapping at the position specified by the passed Argument.
const DimensionSetgetDimensionSet () const
 Returns this Mappings domain as DimensionSet.
template<class stream >
void print (stream &out)
 Prints the Mapping to an output stream.

Protected Attributes

DimensionSet dimensions
 The dimensions of this mappings domain.

Private Member Functions

template<class T >
std::string toString (T v, unsigned int length)
std::string toString (simtime_t v, unsigned int length)

Detailed Description

Represents a not changeable mapping (mathematical function) from domain with at least the time to a double value.

This class is an interface which describes a mapping (math.) from a arbitrary dimensional domain (represented by a DimensionSet) to a double value.

Author:
Karl Wessel

Definition at line 630 of file MappingBase.h.


Constructor & Destructor Documentation

ConstMapping::ConstMapping ( const DimensionSet dimSet  )  [inline]

Initializes the ConstMapping with the passed DimensionSet as Domain.

The passed DimensionSet has to contain the time dimension!

Definition at line 666 of file MappingBase.h.

References DimensionSet::hasDimension(), and Dimension::time_static().

                                          :
    dimensions(dimSet) {

    assert(dimSet.hasDimension(Dimension::time_static()));
  }


Member Function Documentation

virtual ConstMappingIterator* ConstMapping::createConstIterator ( const Argument pos  )  [pure virtual]

Returns a pointer of a new Iterator which is able to iterate over the function. The iterator starts at the passed position.

See class ConstIterator for details.

Implemented in Mapping, SimpleConstMapping, ConstMappingWrapper, ConcatConstMapping< Operator >, and RSAMMapping.

virtual ConstMappingIterator* ConstMapping::createConstIterator (  )  [pure virtual]
virtual double ConstMapping::getValue ( const Argument pos  )  const [pure virtual]
template<class stream >
void ConstMapping::print ( stream &  out  )  [inline]

Prints the Mapping to an output stream.

This implementation is still pretty ugly, but it does the job.

Definition at line 725 of file MappingBase.h.

References Argument::begin(), createConstIterator(), Argument::end(), Argument::getArgValue(), getDimensionSet(), ConstMappingIterator::getPosition(), Argument::getTime(), ConstMappingIterator::getValue(), ConstMappingIterator::hasNext(), ConstMappingIterator::inRange(), FWMath::mW2dBm(), ConstMappingIterator::next(), Argument::setArgValue(), Argument::setTime(), and Dimension::time.

                          {
    ConstMapping& m = *this;
    Dimension otherDim;
    const DimensionSet& dims = m.getDimensionSet();
    out << "Mapping domain: time";
    for(DimensionSet::iterator it = dims.begin(); it != dims.end(); ++it) {
      if(*it != Dimension::time){
        otherDim = *it;
        out << ", " << *it;
      }
    }
    out << endl;

    ConstMappingIterator* it = m.createConstIterator();

    if(!it->inRange()) {
      out << "Mapping is empty." << endl;
      return;
    }

    Argument min = it->getPosition();
    Argument max = it->getPosition();

    std::set<simtime_t> timePositions;
    std::set<double> otherPositions;

    timePositions.insert(it->getPosition().getTime());
    if(dims.size() == 2){
      otherPositions.insert(it->getPosition().begin()->second);
    }

    while(it->hasNext()) {
      it->next();
      const Argument& pos = it->getPosition();

      min.setTime(std::min(min.getTime(), pos.getTime()));
      max.setTime(std::max(max.getTime(), pos.getTime()));

      timePositions.insert(pos.getTime());

      for(Argument::const_iterator itA = pos.begin(); itA != pos.end(); ++itA) {
        if(dims.size() == 2){
          otherPositions.insert(itA->second);
        }
        min.setArgValue(itA->first, std::min(min.getArgValue(itA->first), itA->second));
        max.setArgValue(itA->first, std::max(max.getArgValue(itA->first), itA->second));
      }
    }
    delete it;

    if(dims.size() > 2) {
      out << "domain - min=" << min << " max=" << max << endl;
      return;
    }

    out << "------+---------------------------------------------------------" << endl;
    out << "o\\t   | ";
    std::set<simtime_t>::const_iterator tIt;
    for(tIt = timePositions.begin();
      tIt != timePositions.end(); ++tIt)
    {
      out << m.toString(*tIt * 1000, 6) << " ";
    }
    out << endl;
    out << "------+---------------------------------------------------------" << endl;

    it = m.createConstIterator();


    if(dims.size() == 1) {
      out << "value" << " | ";
      while(it->inRange()) {
        out << m.toString(FWMath::mW2dBm(it->getValue()), 6) << " ";

        if(!it->hasNext()) {
          break;
        }
        it->next();
      }
    } else {
      tIt = timePositions.begin();
      std::set<double>::const_iterator fIt = otherPositions.begin();
      out << m.toString(*fIt, 5) << " | ";
      while(it->inRange()) {
        if(*fIt != it->getPosition().getArgValue(otherDim)) {
          ++fIt;
          out << endl << m.toString(*fIt, 5) << " | ";
          tIt = timePositions.begin();
          assert(*fIt == it->getPosition().getArgValue(otherDim));
        }

        while(*tIt < it->getPosition().getTime()){
          ++tIt;
          out << "      ";
        }

        out << m.toString(FWMath::mW2dBm(it->getValue()), 6) << " ";

        if(!it->hasNext()) {
          break;
        }
        it->next();
      }
    }
    out << endl << "------+---------------------------------------------------------" << endl;

  }


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