Robot Simulator of the Robotics Group for Self-Organization of Control: ColorSchema Class Reference

# ColorSchema Class Reference

A store for colors with a set of aliases. More...

`#include <colorschema.h>`

Collaboration diagram for ColorSchema:
[legend]

List of all members.

## Public Types
typedef HashMap< std::string, Color > | ColorMap
typedef std::vector< std::string > | AliasVector
typedef HashMap< std::string, AliasVector > | AliasMap
## Public Member Functions
| ColorSchema ()
Color | color (const std::string &name_or_id_or_alias) const
| retrieves a color with the given name/id/alias if no color is found that matches the id/alias then the default color is returned.
Color | color (const std::string &name_or_id_or_alias, int alias_set) const
| retrieves a color with the given name/id/alias from given alias_set if not found then the default alias_set (0) is checked
bool | color (Color &color, const std::string &name_or_id_or_alias, int alias_set=0) const
| call by reference version returns false if color not found
bool | existsColor (const std::string &name) const
| checks whether color with the name exists (no aliases are checked)
int | loadPalette (const std::string &gplfilename)
| loads a gpl (gimp pallette file) and returns the number loaded colors The name of the colors should not contain white spaces!
int | loadAliases (const std::string &filename, int alias_set_offset=0)
| loads aliases from text file with lines containing: aliasname colorname/id [alias-set]
void | addColor (const Color &color, const std::string &name)
| adds a color to the color store (to add the id call the function twice with id as name)
bool | addAlias (const std::string &name, const std::string &alias, int alias_set=0)
| adds a color alias (into the given alias-set)
void | setDefaultColor (const Color &c)
const Color & | getDefaultColor () const
std::string | getLoadErrorString (int value) const
| returns error string for value returned by loadPalette and loadAliases
void | print (std::ostream &out) const
| prints all colors and aliases
## Protected Member Functions
bool | getColor (Color &, const std::string &name) const

## Detailed Description

A store for colors with a set of aliases.

The alias-sets are numbered where the 0'th plays the role of a default set.

## Member Typedef Documentation

typedef HashMap<std::string, AliasVector > AliasMap

typedef std::vector<std::string> AliasVector

typedef HashMap<std::string, Color> ColorMap

## Constructor & Destructor Documentation

ColorSchema | ( |  | ) |

## Member Function Documentation

bool addAlias | ( | const std::string & | name,
|  | const std::string & | alias,
|  | int | alias_set = `0` |
| ) |  |  |

adds a color alias (into the given alias-set)

Parameters:

  | name | name/id of existing color
  | alias | new name

Returns:
  true if alias was stored or false if color name does not exists or alias names a color and is therefor rejected

void addColor | ( | const Color & | color,
|  | const std::string & | name |
| ) |  |  |

adds a color to the color store (to add the id call the function twice with id as name)

bool color | ( | Color & | color,
|  | const std::string & | name_or_id_or_alias,
|  | int | alias_set = `0` |
| ) |  |  | const

call by reference version returns false if color not found

Color color | ( | const std::string & | name_or_id_or_alias,
|  | int | alias_set |
| ) |  |  | const

retrieves a color with the given name/id/alias from given alias_set if not found then the default alias_set (0) is checked

Color color | ( | const std::string & | name_or_id_or_alias | ) | const

retrieves a color with the given name/id/alias if no color is found that matches the id/alias then the default color is returned.

Always the alias-set 0 is checked first

bool existsColor | ( | const std::string & | name | ) | const

checks whether color with the name exists (no aliases are checked)

bool getColor | ( | Color & | c,
|  | const std::string & | name |
| ) |  |  | const`[protected]`

const Color & getDefaultColor | ( |  | ) | const

std::string getLoadErrorString | ( | int | value | ) | const

returns error string for value returned by loadPalette and loadAliases

int loadAliases | ( | const std::string & | filename,
|  | int | alias_set_offset = `0` |
| ) |  |  |

loads aliases from text file with lines containing:
aliasname colorname/id [alias-set]

Parameters:

  | alias_set_offset | number that is added to the alias_set number in the file

int loadPalette | ( | const std::string & | gplfilename | ) |

loads a gpl (gimp pallette file) and returns the number loaded colors The name of the colors should not contain white spaces!

void print | ( | std::ostream & | out | ) | const

prints all colors and aliases

void setDefaultColor | ( | const Color & | c | ) |

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

- colorschema.h
- colorschema.cpp