INET Framework for OMNeT++/OMNEST
inet::physicallayer::SimpleConstMapping Class Reference

Abstract subclass of ConstMapping which can be used as base for any ConstMapping implementation with read access of constant complexity. More...

#include <MappingBase.h>

Inheritance diagram for inet::physicallayer::SimpleConstMapping:
inet::physicallayer::ConstMapping inet::physicallayer::ConstantSimpleConstMapping inet::physicallayer::SimpleTimeConstMapping

Public Member Functions

virtual ConstMappingIteratorcreateConstIterator () const override
 Returns a pointer of a new Iterator which is able to iterate over the Mapping. More...
 
virtual ConstMappingIteratorcreateConstIterator (const Argument &pos) const override
 Returns a pointer of a new Iterator which is able to iterate over the Mapping. More...
 
 SimpleConstMapping (const DimensionSet &dims)
 Initializes a not yet iterateable SimpleConstmapping with the passed DimensionSet as domain. More...
 
 SimpleConstMapping (const SimpleConstMapping &o)
 
SimpleConstMappingoperator= (const SimpleConstMapping &copy)
 SimpleConstMapping assignment operator. More...
 
void swap (SimpleConstMapping &s)
 Swaps data with another SimpleConstMapping. More...
 
 SimpleConstMapping (const DimensionSet &dims, const Argument &key)
 Fully initializes this mapping with the passed position as key entry. More...
 
 SimpleConstMapping (const DimensionSet &dims, const Argument &key1, const Argument &key2)
 Fully initializes this mapping with the passed two positions as key entries. More...
 
 SimpleConstMapping (const DimensionSet &dims, const Argument &min, const Argument &max, const Argument &interval)
 Fully initializes this mapping with the key entries defined by the passed min, max and interval values. More...
 
void initializeArguments (const Argument &key)
 Initializes the key entry set with the passed position as entry. More...
 
void initializeArguments (const Argument &key1, const Argument &key2)
 Initializes the key entry set with the passed two positions as entries. More...
 
void initializeArguments (const Argument &min, const Argument &max, const Argument &interval)
 Initializes the key entry set with the passed min, max and interval-Arguments. More...
 
- Public Member Functions inherited from inet::physicallayer::ConstMapping
ConstMappingoperator= (const ConstMapping &copy)
 ConstMapping assignment operator. More...
 
void swap (ConstMapping &s)
 Swaps data with another ConstMapping. More...
 
 ConstMapping ()
 Initializes the ConstMapping with a the time dimension as domain. More...
 
 ConstMapping (const ConstMapping &o)
 
 ConstMapping (const DimensionSet &dimSet)
 Initializes the ConstMapping with the passed DimensionSet as Domain. More...
 
virtual ~ConstMapping ()
 
virtual argument_value_t getValue (const Argument &pos) const =0
 Returns the value of this Mapping at the position specified by the passed Argument. More...
 
virtual ConstMappingconstClone () const =0
 returns a deep copy of this mapping instance. More...
 
argument_value_t operator[] (const Argument &pos) const
 Returns the value of this Mapping at the position specified by the passed Argument. More...
 
const DimensionSetgetDimensionSet () const
 Returns this Mappings domain as DimensionSet. More...
 
template<class stream >
stream & print (stream &out, argument_value_cref_t lTimeScale=argument_value_t(1), argument_value_cref_t lLeftColScale=Argument::MappedOne, const std::string &sTableHead=std::string("o\\ms"), const Dimension *const pOnlyDim=nullptr) const
 Prints the Mapping to an output stream. More...
 

Protected Types

typedef std::set< ArgumentKeyEntrySet
 Type for a set of Arguments defining key entries. More...
 

Protected Member Functions

void createKeyEntries (const Argument &from, const Argument &to, const Argument &step, Argument &pos)
 Utility method to fill add range of key entries in the time dimension to the key entry set. More...
 
void createKeyEntries (const Argument &from, const Argument &to, const Argument &step, DimensionSet::const_iterator curDim, Argument &pos)
 Utility method to fill add range of key entries in the passed dimension (and recursively its sub dimensions) to the key entry set. More...
 

Protected Attributes

KeyEntrySet keyEntries
 A set of Arguments defining the "points of interest" an iterator should iterate over. More...
 
- Protected Attributes inherited from inet::physicallayer::ConstMapping
DimensionSet dimensions
 The dimensions of this mappings domain. More...
 

Additional Inherited Members

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

Detailed Description

Abstract subclass of ConstMapping which can be used as base for any ConstMapping implementation with read access of constant complexity.

Any subclass only has to implement the "getValue()" and the "clone()"-method.

The subclass has to define the "points of interest" an iterator should iterate over. This should be done either at construction time or later by calling the "initializeArguments()"-method.

The SimpleConstMapping class provides Iterator creation by using the SimpleConstMappingIterator which assumes that the underlying ConstMappings getValue()-method is fast enough to be called on every iteration step (which means constant complexity).

Author
Karl Wessel

Member Typedef Documentation

Type for a set of Arguments defining key entries.

Constructor & Destructor Documentation

inet::physicallayer::SimpleConstMapping::SimpleConstMapping ( const DimensionSet dims)
inline

Initializes a not yet iterateable SimpleConstmapping with the passed DimensionSet as domain.

1644  :
1645  ConstMapping(dims), keyEntries() {}
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
ConstMapping()
Initializes the ConstMapping with a the time dimension as domain.
Definition: MappingBase.h:935
inet::physicallayer::SimpleConstMapping::SimpleConstMapping ( const SimpleConstMapping o)
inline
1646  :
1647  ConstMapping(o), keyEntries(o.keyEntries) {}
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
ConstMapping()
Initializes the ConstMapping with a the time dimension as domain.
Definition: MappingBase.h:935
inet::physicallayer::SimpleConstMapping::SimpleConstMapping ( const DimensionSet dims,
const Argument key 
)
inline

Fully initializes this mapping with the passed position as key entry.

A SimpleConstMapping initialized by this constructor is able to return a valid ConstIterator.

1679  :
1680  ConstMapping(dims), keyEntries()
1681  {
1682  initializeArguments(key);
1683  }
void initializeArguments(const Argument &key)
Initializes the key entry set with the passed position as entry.
Definition: MappingBase.h:1719
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
ConstMapping()
Initializes the ConstMapping with a the time dimension as domain.
Definition: MappingBase.h:935
inet::physicallayer::SimpleConstMapping::SimpleConstMapping ( const DimensionSet dims,
const Argument key1,
const Argument key2 
)
inline

Fully initializes this mapping with the passed two positions as key entries.

A SimpleConstMapping initialized by this constructor is able to return a valid ConstIterator.

1693  :
1694  ConstMapping(dims), keyEntries()
1695  {
1696  initializeArguments(key1, key2);
1697  }
void initializeArguments(const Argument &key)
Initializes the key entry set with the passed position as entry.
Definition: MappingBase.h:1719
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
ConstMapping()
Initializes the ConstMapping with a the time dimension as domain.
Definition: MappingBase.h:935
inet::physicallayer::SimpleConstMapping::SimpleConstMapping ( const DimensionSet dims,
const Argument min,
const Argument max,
const Argument interval 
)
inline

Fully initializes this mapping with the key entries defined by the passed min, max and interval values.

A SimpleConstMapping initialized by this constructor is able to return a valid ConstIterator.

1707  :
1708  ConstMapping(dims), keyEntries()
1709  {
1710  initializeArguments(min, max, interval);
1711  }
void initializeArguments(const Argument &key)
Initializes the key entry set with the passed position as entry.
Definition: MappingBase.h:1719
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
ConstMapping()
Initializes the ConstMapping with a the time dimension as domain.
Definition: MappingBase.h:935

Member Function Documentation

virtual ConstMappingIterator* inet::physicallayer::SimpleConstMapping::createConstIterator ( ) const
inlineoverridevirtual

Returns a pointer of a new Iterator which is able to iterate over the Mapping.

This method asserts that the mapping had been fully initialized.

Implements inet::physicallayer::ConstMapping.

1624  {
1625  return new SimpleConstMappingIterator(this, &keyEntries);
1626  }
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
virtual ConstMappingIterator* inet::physicallayer::SimpleConstMapping::createConstIterator ( const Argument pos) const
inlineoverridevirtual

Returns a pointer of a new Iterator which is able to iterate over the Mapping.

The iterator starts at the passed position.

This method asserts that the mapping had been fully initialized.

Implements inet::physicallayer::ConstMapping.

1635  {
1636  return new SimpleConstMappingIterator(this, &keyEntries, pos);
1637  }
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
void inet::physicallayer::SimpleConstMapping::createKeyEntries ( const Argument from,
const Argument to,
const Argument step,
Argument pos 
)
protected

Utility method to fill add range of key entries in the time dimension to the key entry set.

331 {
332  //get iteration borders and steps
333  simtime_t_cref fromT = from.getTime();
334  simtime_t_cref toT = to.getTime();
335  simtime_t_cref stepT = step.getTime();
336 
337  //iterate over interval without the end of the interval
338  for (simtime_t t = fromT; t < toT; t += stepT) {
339  //create key entry at current position
340  pos.setTime(t);
341  keyEntries.insert(pos);
342  }
343 
344  //makes sure that the end of the interval becomes it own key entry
345  pos.setTime(toT);
346  keyEntries.insert(pos);
347 }
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
void inet::physicallayer::SimpleConstMapping::createKeyEntries ( const Argument from,
const Argument to,
const Argument step,
DimensionSet::const_iterator  curDim,
Argument pos 
)
protected

Utility method to fill add range of key entries in the passed dimension (and recursively its sub dimensions) to the key entry set.

351 {
352  //get the dimension to iterate over
353  DimensionSet::const_reference d = *curDim;
354 
355  //increase iterator to next dimension (means curDim now stores the next dimension)
356  --curDim;
357  bool nextIsTime = (*curDim == Dimension::time);
358 
359  //get our iteration borders and steps
360  argument_value_cref_t fromD = from.getArgValue(d);
361  argument_value_cref_t toD = to.getArgValue(d);
362  argument_value_cref_t stepD = step.getArgValue(d);
363 
364  //iterate over interval without the last entry
365  for (argument_value_t i = fromD; i < toD; i += stepD) {
366  pos.setArgValue(d, i); //update position
367 
368  //call iteration over sub dimension
369  if (nextIsTime) {
370  createKeyEntries(from, to, step, pos);
371  }
372  else {
373  createKeyEntries(from, to, step, curDim, pos);
374  }
375  }
376 
377  //makes sure that the end of the interval has its own key entry
378  pos.setArgValue(d, toD);
379  if (nextIsTime) {
380  createKeyEntries(from, to, step, pos);
381  }
382  else {
383  createKeyEntries(from, to, step, curDim, pos);
384  }
385 }
_Base::const_reference const_reference
Definition: MappingBase.h:155
static const Dimension time
Shortcut to the time Dimension, same as &#39;Dimension("time")&#39;, but spares the parsing of a string...
Definition: MappingBase.h:64
Argument::mapped_type_cref argument_value_cref_t
Definition: MappingBase.h:875
Argument::mapped_type argument_value_t
Definition: MappingBase.h:874
void createKeyEntries(const Argument &from, const Argument &to, const Argument &step, Argument &pos)
Utility method to fill add range of key entries in the time dimension to the key entry set...
Definition: MappingBase.cc:330
void inet::physicallayer::SimpleConstMapping::initializeArguments ( const Argument key)
inline

Initializes the key entry set with the passed position as entry.

Convenience method for simple mappings.

1720  {
1721  keyEntries.clear();
1722  keyEntries.insert(key);
1723  }
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
void inet::physicallayer::SimpleConstMapping::initializeArguments ( const Argument key1,
const Argument key2 
)
inline

Initializes the key entry set with the passed two positions as entries.

Convenience method for simple mappings.

1732  {
1733  keyEntries.clear();
1734  keyEntries.insert(key1);
1735  keyEntries.insert(key2);
1736  }
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
void inet::physicallayer::SimpleConstMapping::initializeArguments ( const Argument min,
const Argument max,
const Argument interval 
)

Initializes the key entry set with the passed min, max and interval-Arguments.

After a call to this method this SimpleConstMapping is able to return a valid ConstIterator.

390 {
391  keyEntries.clear();
393  Argument pos = min;
394 
395  if (*dimIt == Dimension::time)
396  createKeyEntries(min, max, interval, pos);
397  else
398  createKeyEntries(min, max, interval, dimIt, pos);
399 }
static const Dimension time
Shortcut to the time Dimension, same as &#39;Dimension("time")&#39;, but spares the parsing of a string...
Definition: MappingBase.h:64
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
KeyEntrySet keyEntries
A set of Arguments defining the "points of interest" an iterator should iterate over.
Definition: MappingBase.h:1599
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
DimensionSet dimensions
The dimensions of this mappings domain.
Definition: MappingBase.h:879
iterator end()
Definition: MappingBase.h:303
_Base::const_iterator const_iterator
Definition: MappingBase.h:153
void createKeyEntries(const Argument &from, const Argument &to, const Argument &step, Argument &pos)
Utility method to fill add range of key entries in the time dimension to the key entry set...
Definition: MappingBase.cc:330
SimpleConstMapping& inet::physicallayer::SimpleConstMapping::operator= ( const SimpleConstMapping copy)
inline

SimpleConstMapping assignment operator.

Parameters
copyA SimpleConstMapping of identical element and allocator types.

All the elements of copy are copied.

1656  {
1658  return *this;
1659  }
ConstMapping & operator=(const ConstMapping &copy)
ConstMapping assignment operator.
Definition: MappingBase.h:888
void inet::physicallayer::SimpleConstMapping::swap ( SimpleConstMapping s)
inline

Swaps data with another SimpleConstMapping.

Parameters
sA SimpleConstMapping of the same element and allocator types.

This exchanges the elements between two SimpleConstMapping's in constant time. Note that the global std::swap() function is specialized such that std::swap(s1,s2) will feed to this function.

1669 { ConstMapping::swap(s); /* swap the base class members */ }
value< double, units::s > s
Definition: Units.h:1049
void swap(ConstMapping &s)
Swaps data with another ConstMapping.
Definition: MappingBase.h:902

Member Data Documentation

KeyEntrySet inet::physicallayer::SimpleConstMapping::keyEntries
protected

A set of Arguments defining the "points of interest" an iterator should iterate over.


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