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.

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 ConstMappingIterator * | createConstIterator ()=0 |
| Returns a pointer of a new Iterator which is able to iterate over this Mapping. | |
| virtual ConstMappingIterator * | createConstIterator (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 ConstMapping * | constClone () 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 DimensionSet & | getDimensionSet () 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) |
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.
Definition at line 630 of file MappingBase.h.
| 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()));
}
| 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] |
Returns a pointer of a new Iterator which is able to iterate over this Mapping.
See class ConstIterator for details.
Implemented in Mapping, SimpleConstMapping, ConstMappingWrapper, ConcatConstMapping< Operator >, and RSAMMapping.
Referenced by SNRThresholdDecider::canAnswerCSR(), ConcatConstMapping< Operator >::createConstIterator(), ConstMappingWrapper::createConstIterator(), ConstMappingWrapper::createIterator(), LinearIntplMapping::createIterator(), UWBIRIEEE802154APathlossModel::filterSignal(), MappingUtils::findMax(), MappingUtils::findMin(), print(), ThresholdDecider::printMapping(), and Decider802154Narrow::processSignalEnd().
| virtual double ConstMapping::getValue | ( | const Argument & | pos | ) | const [pure virtual] |
Returns the value of this Mapping at the position specified by the passed Argument.
The complexity of this method depends on the actual implementation.
Implemented in SimpleConstMapping, TimeMapping< Interpolator >, LinearIntplMapping, ConstantSimpleConstMapping, ConstMappingWrapper, MultiDimMapping< Interpolator >, ConcatConstMapping< Operator >, RSAMMapping, JakesFadingMapping, SimplePathlossConstMapping, SimpleTimeConstMapping, TimeMapping< Linear >, and MultiDimMapping< Linear >.
Referenced by ConcatConstMapping< Operator >::getValue(), ConstMappingWrapper::getValue(), LinearIntplMapping::getValue(), SimpleConstMappingIterator::getValue(), operator[](), ThresholdDecider::printMapping(), Decider802154Narrow::processNewSignal(), and Decider802154Narrow::processSignalEnd().
| 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;
}
1.7.1