Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Types | Static Protected Member Functions | Protected Attributes | Friends

Dimension Class Reference
[mapping - classes representing mathematical mappings]

Specifies a dimension for mappings (like time, frequency, etc.). More...

#include <MappingBase.h>

Collaboration diagram for Dimension:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Dimension (const std::string &name)
 Creates a new dimension instance representing the dimension with the passed name.
bool operator== (const Dimension &other) const
 Returns true if the ids of the two dimensions are equal.
bool operator< (const Dimension &other) const
 Returns true if the id of the other dimension is greater then the id of this dimension.
bool operator<= (const Dimension &other) const
 Sorting operator by dimension ID.
bool operator> (const Dimension &other) const
 Sorting operator by dimension ID.
bool operator>= (const Dimension &other) const
 Sorting operator by dimension ID.
bool operator!= (const Dimension &other) const
 Sorting operator by dimension ID.
std::string getName () const
 Returns the name of this dimension.
int getID () const
 Returns the unique id of the dimension this instance represents.

Static Public Member Functions

static Dimensiontime_static ()
 Shortcut to the time Dimension, same as 'Dimension("time")', but spares the parsing of a string.
static Dimensionfrequency_static ()
 Shortcut to the frequency Dimension, same as 'Dimension("frequency")', but spares the parsing of a string.

Static Public Attributes

static const Dimension time = Dimension::time_static()
 Shortcut to the time Dimension, same as 'Dimension("time")', but spares the parsing of a string.
static const Dimension frequency = Dimension::frequency_static()
 Shortcut to the frequency Dimension, same as 'Dimension("frequency")', but spares the parsing of a string.

Protected Types

typedef std::map< std::string,
int > 
DimensionIDMap
 Type for map from dimension name to ID.
typedef std::map< int,
std::string > 
DimensionNameMap
 Type for map from ID to dimension name.

Static Protected Member Functions

static DimensionIDMapdimensionIDs ()
 stores the registered dimensions ids.
static DimensionNameMapdimensionNames ()
 ConstMapping from id to name of registered dimensions.
static int & nextFreeID ()
 Stores the next free ID for a new dimension.
static int getDimensionID (const std::string &name)
 Returns an instance of dimension which represents the dimension with the passed name.

Protected Attributes

int id
 The unique id of the dimension this instance represents.

Friends

std::ostream & operator<< (std::ostream &out, const Dimension &d)
 Output operator for a dimension.

Detailed Description

Specifies a dimension for mappings (like time, frequency, etc.).

The dimension is represented external by a string (like "time") and internally by an unique ID.

Note: Since the ID for a Dimensions is set the first time an instance of this dimensions is created and the id is used to provide a defined ordering of the Dimensions it DOES matter which dimensions are instantiated the first time. Only the time dimension will always have zero as unique id.

Author:
Karl Wessel

Definition at line 30 of file MappingBase.h.


Member Function Documentation

Dimension::DimensionIDMap & Dimension::dimensionIDs (  )  [static, protected]

stores the registered dimensions ids.

Uses "construct-on-first-use" idiom to ensure correct initialization of static members.

Definition at line 13 of file MappingBase.cc.

Referenced by getDimensionID().

                                                 {
  //use "construct-on-first-use" idiom to ensure correct order of
  //static initialization
  static DimensionIDMap* dimIDs = new DimensionIDMap();
  return *dimIDs;
}

Dimension::DimensionNameMap & Dimension::dimensionNames (  )  [static, protected]

ConstMapping from id to name of registered dimensions.

Uses "construct-on-first-use" idiom to ensure correct initialization of static members.

Definition at line 20 of file MappingBase.cc.

Referenced by getDimensionID(), and getName().

                                                     {
  //use "construct-on-first-use" idiom to ensure correct order of
  //static initialization
  static DimensionNameMap* names = new DimensionNameMap();
  return *names;
}

Dimension & Dimension::frequency_static (  )  [static]

Shortcut to the frequency Dimension, same as 'Dimension("frequency")', but spares the parsing of a string.

This method should be used instead of the static "frequency" member when used during initialization of static variables since it assures the correct order of initialization.

Definition at line 34 of file MappingBase.cc.

Referenced by Decider80211::calcChannelSenseRSSI(), Decider80211::checkIfSignalOk(), BaseMacLayer::createSingleFrequencyMapping(), and Decider80211::processNewSignal().

                                       {
  static Dimension* freq = new Dimension("frequency");
  return *freq;
}

int Dimension::getID (  )  const [inline]

Returns the unique id of the dimension this instance represents.

The id is used to uniquely identify dimensions as well as to provide a sorting of dimensions. Note: The "time"-dimension will always have the ID zero.

Definition at line 150 of file MappingBase.h.

References id.

{ return id; }

int & Dimension::nextFreeID (  )  [static, protected]

Stores the next free ID for a new dimension.

Uses "construct-on-first-use" idiom to ensure correct initialization of static members.

Definition at line 8 of file MappingBase.cc.

Referenced by getDimensionID().

                            {
  static int* nextID = new int(1);
  return *nextID;
}

bool Dimension::operator< ( const Dimension other  )  const

Returns true if the id of the other dimension is greater then the id of this dimension.

This is needed to be able to use Dimension as a key in std::map.

Definition at line 72 of file MappingBase.cc.

References id.

{
  return id < other.id;
}

Dimension & Dimension::time_static (  )  [static]

Shortcut to the time Dimension, same as 'Dimension("time")', but spares the parsing of a string.

This method should be used instead of the static "time" member when used during initialization of static variables since it assures the correct order of initialization.

Definition at line 27 of file MappingBase.cc.

References time.

Referenced by Argument::Argument(), ConstMapping::ConstMapping(), Argument::find(), Argument::getDimensions(), Argument::lower_bound(), and Argument::setArgValue().

                                  {
  //use "construct-on-first-use" idiom to ensure correct order of
  //static initialization
  static Dimension* time = new Dimension("time");
  return *time;
}


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