5 #ifndef BPP_GRAPHICS_COLORSET_H 6 #define BPP_GRAPHICS_COLORSET_H 9 #include "../Utils/MapTools.h" 75 std::map<std::string, RGBColor>::const_iterator it = colors_.find(name);
76 if (it != colors_.end())
return it->second;
77 else throw Exception(
"AbstractColorSet::getColor(name): no color with name " + name);
82 if (index >= colors_.size())
throw IndexOutOfBoundsException(
"AbstractColorSet::getColor(index): invalid index.", index, 0, colors_.size() - 1);
83 std::map<std::string, RGBColor>::const_iterator it = colors_.begin();
84 for (
unsigned int i = 0; i < index; i++) { it++;}
93 #endif // BPP_GRAPHICS_COLORSET_H
std::map< std::string, RGBColor > colors_
Partial implementation of the ColorSet interface.
Describe a color according to its red, green and blue componants.
const RGBColor & getColor(unsigned int index) const
Get the ith color object in the set.
Specify a set of color definitions.
virtual size_t getNumberOfColors() const =0
const RGBColor & getColor(const std::string &name) const
Get the color object corresponding to a given name.
virtual std::vector< std::string > getColorNames() const =0
Exception base class. Overload exception constructor (to control the exceptions mechanism). Destructor is already virtual (from std::exception)
size_t getNumberOfColors() const
virtual ~AbstractColorSet()
std::vector< std::string > getColorNames() const
virtual const RGBColor & getColor(const std::string &name) const =0
Get the color object corresponding to a given name.
Index out of bounds exception class.