Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColorSchema Class Reference

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

#include <colorschema.h>

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. More...
 
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 More...
 
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 More...
 
bool existsColor (const std::string &name) const
 checks whether color with the name exists (no aliases are checked) More...
 
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! More...
 
int loadAliases (const std::string &filename, int alias_set_offset=0)
 loads aliases from text file with lines containing:
aliasname colorname/id [alias-set] More...
 
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) More...
 
bool addAlias (const std::string &name, const std::string &alias, int alias_set=0)
 adds a color alias (into the given alias-set) More...
 
void setDefaultColor (const Color &c)
 
const ColorgetDefaultColor () const
 
std::string getLoadErrorString (int value) const
 returns error string for value returned by loadPalette and loadAliases More...
 
void print (std::ostream &out) const
 prints all colors and aliases More...
 

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

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
namename/id of existing color
aliasnew 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)

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

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)

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_offsetnumber 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: