#include <colorUnit.h>
Classes |
|
class | NotInHexFormat |
NotInHexFormat
Exception class.
More... |
|
Public Member Functions |
|
Constructors
|
|
ColorUnit () | |
Default Constructor. |
|
ColorUnit (const ColorUnit &color_unit) | |
Copy constructor. |
|
ColorUnit (const char *value) throw (Exception::InvalidRange, NotInHexFormat) | |
Constructor with Parameter char*,
representing a value in hex format (00 - FF, or 00 - ff).
|
|
ColorUnit (const String &value) throw (Exception::InvalidRange, NotInHexFormat) | |
Constructor with Parameter String. |
|
ColorUnit (const unsigned char value) | |
Constructor with Parameter unsigned
char. |
|
ColorUnit (const short value) throw (Exception::InvalidRange) | |
Constructor with Parameter short.
|
|
ColorUnit (const unsigned short value) throw (Exception::InvalidRange) | |
Constructor with Parameter unsigned
short. |
|
ColorUnit (const int value) throw (Exception::InvalidRange) | |
Constructor with Parameter int.
|
|
ColorUnit (const unsigned int value) throw (Exception::InvalidRange) | |
Constructor with Parameter unsigned
int. |
|
ColorUnit (const long value) throw (Exception::InvalidRange) | |
Constructor with Parameter long.
|
|
ColorUnit (const unsigned long value) throw (Exception::InvalidRange) | |
Constructor with Parameter unsigned
long. |
|
ColorUnit (const float value) throw (Exception::InvalidRange) | |
Constructor with Parameter float.
|
|
ColorUnit (const double value) throw (Exception::InvalidRange) | |
Constructor with Parameter double.
|
|
Destructors
|
|
~ColorUnit () | |
Destructor. |
|
void | clear () |
Explicit default initialization.
|
|
Converters
|
|
operator String () const | |
Conversion to string. |
|
operator char () const | |
Conversion to char. |
|
operator unsigned char () const | |
Conversion to unsigned char.
|
|
operator short () const | |
Conversion to short. |
|
operator unsigned short () const | |
Conversion to unsigned short.
|
|
operator int () const | |
Conversion to int. |
|
operator unsigned int () const | |
Conversion to unsigned int. |
|
operator long () const | |
Conversion to long. |
|
operator unsigned long () const | |
Conversion to unsigned long.
|
|
operator float () const | |
Conversion to float. |
|
operator double () const | |
Conversion to double. |
|
Assignment methods
|
|
void | set (const ColorUnit &color_unit) |
Assignment. |
|
const ColorUnit & | operator= (const ColorUnit &color_unit) |
Assignment operator. |
|
void | swap (ColorUnit &color_unit) |
Swapping of colorUnits. |
|
Accessors: inspectors and mutators
|
|
void | set (const char *value) throw (Exception::InvalidRange, NotInHexFormat) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const char *value) throw (Exception::InvalidRange, NotInHexFormat) |
Assignment operator with char*.
|
|
void | get (char *value) const |
Inspection of the colorUnit's value.
|
|
void | set (const String &value) throw (Exception::InvalidRange, NotInHexFormat) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const String &value) throw (Exception::InvalidRange, NotInHexFormat) |
Assignment operator with string.
|
|
void | get (String &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const unsigned char value) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const unsigned char value) |
Assignment operator with unsigned
char. |
|
void | get (unsigned char &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const short value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const short value) throw (Exception::InvalidRange) |
Assignment operator with short.
|
|
void | get (short &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const unsigned short value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const unsigned short value) throw (Exception::InvalidRange) |
Assignment operator with unsigned
short. |
|
void | get (unsigned short &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const int value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const int value) throw (Exception::InvalidRange) |
Assignment operator with int.
|
|
void | get (int &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const unsigned int value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const unsigned int value) throw (Exception::InvalidRange) |
Assignment operator with unsigned
int. |
|
void | get (unsigned int &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const long value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const long value) throw (Exception::InvalidRange) |
Assignment operator with long.
|
|
void | get (long &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const unsigned long value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const unsigned long value) throw (Exception::InvalidRange) |
Assignment operator with unsigned
long. |
|
void | get (unsigned long &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const float value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const float value) throw (Exception::InvalidRange) |
Assignment operator with float.
|
|
void | get (float &value) const |
Inspection of the colorUnit's value.
|
|
void | set (const double value) throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
|
|
const ColorUnit & | operator= (const double value) throw (Exception::InvalidRange) |
Assignment operator with double.
|
|
void | get (double &value) const |
Inspection of the colorUnit's value.
|
|
Predicates
|
|
bool | operator== (const ColorUnit &color_unit) const |
Equality test. |
|
bool | operator!= (const ColorUnit &color_unit) const |
Unequality test. |
|
bool | operator< (const ColorUnit &color_unit) const |
Smaller test. |
|
bool | operator<= (const ColorUnit &color_unit) const |
Smaller or equal test. |
|
bool | operator> (const ColorUnit &color_unit) const |
Greater test. |
|
bool | operator>= (const ColorUnit &color_unit) const |
Greater or equal test. |
|
debuggers and diagnostics
|
|
void | dump (std::ostream &s=std::cout, Size depth=0) const |
Internal value dump. |
|
Friends |
|
Storers
|
|
std::istream & | operator>> (std::istream &s, ColorUnit &color_unit) |
Friendly stream input. |
|
std::ostream & | operator<< (std::ostream &s, const ColorUnit &color_unit) |
Friendly stream output. |
An instance of ColorUnit can represent a value for the red, green, blue and alpha component of the class ColorRGBA. Furthermore this class is used for the value and saturation component of the class ColorHSV. The class handles the many possible variations a color value can be set (e.g. integer, float, string values can be given as parameter). The integer values are of range 0-255, the float values are of range 0-1.0 and the strings given are in hex format "00"-"FF". ColorUnit provides certain conversion functions as well, that will convert its value to the needed type. This class is used by the class ColorRGBA and ColorHSV.
BALL::VIEW::ColorUnit::ColorUnit | ( | ) |
Default Constructor.
Its value will be set to zero (0).
BALL::VIEW::ColorUnit::ColorUnit | ( | const char * | value | ) | throw (Exception::InvalidRange, NotInHexFormat) |
Constructor with Parameter char*, representing a value in hex format (00 - FF, or 00 - ff).
value | the pointer to a string (00 - FF, or 00 - ff) |
InvalidRange | if string length != 2 |
|
NotInHexFormat | if string contains characters g-z or G-Z |
BALL::VIEW::ColorUnit::ColorUnit | ( | const String & | value | ) | throw (Exception::InvalidRange, NotInHexFormat) |
Constructor with Parameter String.
value | a string (00 - FF, or 00 - ff) |
InvalidRange | if string length != 2 |
|
NotInHexFormat | if string contains characters g-z or G-Z |
BALL::VIEW::ColorUnit::ColorUnit | ( | const unsigned char | value | ) |
Constructor with Parameter unsigned char.
value | a char (0 - 255) |
BALL::VIEW::ColorUnit::ColorUnit | ( | const short | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter short.
value | a short (0 - 255) |
InvalidRange | if value < 0 || value >
255 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const unsigned short | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter unsigned short.
value | a unsigned short (0 - 255) |
InvalidRange | if value > 255 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const int | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter int.
value | an int (0 - 255) |
InvalidRange | if value < 0 || value >
255 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const unsigned int | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter unsigned int.
value | an unsigned int (0 - 255) |
InvalidRange | if value > 255 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const long | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter long.
value | an long (0 - 255) |
InvalidRange | if value < 0 || value >
255 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const unsigned long | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter unsigned long.
value | an unsigned long (0 - 255) |
InvalidRange | if value > 255 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const float | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter float.
value | a float (0 - 1.0) |
InvalidRange | if value < 0.0 || value >
1.0 |
BALL::VIEW::ColorUnit::ColorUnit | ( | const double | value | ) | throw (Exception::InvalidRange) |
Constructor with Parameter double.
value | a double (0 - 1.0) |
InvalidRange | if value < 0.0 || value >
1.0 |
void BALL::VIEW::ColorUnit::clear | ( | ) |
Explicit default initialization.
Sets the value of this colorUnit to the default value. The value of this colorUnit is:
void BALL::VIEW::ColorUnit::dump | ( | std::ostream & | s =
std::cout , |
|
Size | depth =
0 |
|||
) | const |
Internal value dump.
Dumps the current value of this colorUnit to the output
ostream s with dumping depth depth. The value
will be outputed as an integer of range
0-255
.
s | output stream where to output the value of this colorUnit | |
depth | the dumping depth (depth is irrelevant here) |
void BALL::VIEW::ColorUnit::get | ( | double & | value | ) | const |
Inspection of the colorUnit's value.
value | a double receiving the value of this colorUnit (range: 0-1.0) |
void BALL::VIEW::ColorUnit::get | ( | float & | value | ) | const |
Inspection of the colorUnit's value.
value | a float receiving the value of this colorUnit (range: 0-1.0) |
void BALL::VIEW::ColorUnit::get | ( | unsigned long & | value | ) | const |
Inspection of the colorUnit's value.
value | an unsigned long receiving the value of this
colorUnit (range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | long & | value | ) | const |
Inspection of the colorUnit's value.
value | a long receiving the value of this colorUnit
(range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | unsigned int & | value | ) | const |
Inspection of the colorUnit's value.
value | an unsigned int receiving the value of this
colorUnit (range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | int & | value | ) | const |
Inspection of the colorUnit's value.
value | an int receiving the value of this colorUnit
(range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | unsigned short & | value | ) | const |
Inspection of the colorUnit's value.
value | an unsigned short receiving the value of this
colorUnit (range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | short & | value | ) | const |
Inspection of the colorUnit's value.
value | a short receiving the value of this colorUnit
(range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | unsigned char & | value | ) | const |
Inspection of the colorUnit's value.
value | an unsigned char receiving the value of this
colorUnit (range: 0-255 ) |
void BALL::VIEW::ColorUnit::get | ( | String & | value | ) | const |
Inspection of the colorUnit's value.
value | a string receiving the value of this colorUnit
in hex format ( "00"-"FF" or
"00"-"ff" ) |
void BALL::VIEW::ColorUnit::get | ( | char * | value | ) | const |
Inspection of the colorUnit's value.
Memory must be allocated for this parameter. The memory must be at least the size of 3 bytes.
value | a char* receiving the value of this colorUnit
in hex format ( "00"-"FF" or
"00"-"ff" ) |
BALL::VIEW::ColorUnit::operator char | ( | ) | const |
Conversion to char.
0 - 255
BALL::VIEW::ColorUnit::operator double | ( | ) | const |
Conversion to double.
0 -
1.0
BALL::VIEW::ColorUnit::operator float | ( | ) | const |
Conversion to float.
0 - 1.0
BALL::VIEW::ColorUnit::operator int | ( | ) | const |
Conversion to int.
0 - 255
BALL::VIEW::ColorUnit::operator long | ( | ) | const |
Conversion to long.
0 - 255
BALL::VIEW::ColorUnit::operator short | ( | ) | const |
Conversion to short.
0 - 255
BALL::VIEW::ColorUnit::operator String | ( | ) | const |
Conversion to string.
"00"-"FF"
or
"00"-"ff"
BALL::VIEW::ColorUnit::operator unsigned char | ( | ) | const |
Conversion to unsigned char.
0 -
255
BALL::VIEW::ColorUnit::operator unsigned int | ( | ) | const |
Conversion to unsigned int.
0 -
255
BALL::VIEW::ColorUnit::operator unsigned long | ( | ) | const |
Conversion to unsigned long.
0 -
255
BALL::VIEW::ColorUnit::operator unsigned short | ( | ) | const |
Conversion to unsigned short.
0 -
255
bool BALL::VIEW::ColorUnit::operator!= | ( | const ColorUnit & | color_unit | ) | const |
Unequality test.
Unequality means that the internals value (floats) of the colorUnit's are unequal.
bool BALL::VIEW::ColorUnit::operator< | ( | const ColorUnit & | color_unit | ) | const |
Smaller test.
Smaller means that the internal value (float) this is smaller than the internal value (float) of color_unit colorUnit.
bool BALL::VIEW::ColorUnit::operator<= | ( | const ColorUnit & | color_unit | ) | const |
Smaller or equal test.
Smaller or equal means that the internal value (float) this is smaller or equal than the internal value (float) of color_unit colorUnit.
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const double | value | ) | throw (Exception::InvalidRange) |
Assignment operator with double.
Calls set.
value | a double containing a value of range 0-1.0 |
InvalidRange | if value < 0.0 || value >
1.0 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const float | value | ) | throw (Exception::InvalidRange) |
Assignment operator with float.
Calls set.
value | a float containing a value of range 0-1.0 |
InvalidRange | if value < 0.0 || value >
1.0 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const unsigned long | value | ) | throw (Exception::InvalidRange) |
Assignment operator with unsigned long.
Calls set.
value | an unsigned long containing a value of range
0-255 |
InvalidRange | if value > 255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const long | value | ) | throw (Exception::InvalidRange) |
Assignment operator with long.
Calls set.
value | a long containing a value of range
0-255 |
InvalidRange | if value < 0 || value >
255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const unsigned int | value | ) | throw (Exception::InvalidRange) |
Assignment operator with unsigned int.
Calls set.
value | an unsigned int containing a value of range
0-255 |
InvalidRange | if value > 255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const int | value | ) | throw (Exception::InvalidRange) |
Assignment operator with int.
Calls set.
value | an int containing a value of range
0-255 |
InvalidRange | if value < 0 || value >
255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const unsigned short | value | ) | throw (Exception::InvalidRange) |
Assignment operator with unsigned short.
Calls set.
value | an unsigned short containing a value of range
0-255 |
InvalidRange | if value > 255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const short | value | ) | throw (Exception::InvalidRange) |
Assignment operator with short.
Calls set.
value | a short containing a value of range
0-255 |
InvalidRange | if value < 0 || value >
255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const unsigned char | value | ) |
Assignment operator with unsigned char.
Calls set.
value | an unsigned char containing a value of range
0-255 |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const String & | value | ) | throw (Exception::InvalidRange, NotInHexFormat) |
Assignment operator with string.
Calls set.
value | a string containing a value in hex format (
"00"-"FF" or
"00"-"ff" ) |
InvalidRange | if string length != 2 |
|
NotInHexFormat | if string contains characters g-z or G-Z |
const ColorUnit& BALL::VIEW::ColorUnit::operator= | ( | const char * | value | ) | throw (Exception::InvalidRange, NotInHexFormat) |
Assignment operator with char*.
Calls set.
value | the pointer to a string containing a value in
hex format ( "00"-"FF" or
"00"-"ff" ) |
InvalidRange | if string length != 2 |
|
NotInHexFormat | if string contains characters g-z or G-Z |
Assignment operator.
bool BALL::VIEW::ColorUnit::operator== | ( | const ColorUnit & | color_unit | ) | const |
Equality test.
Equality means that the internals value (floats) of the colorUnit's are equal.
bool BALL::VIEW::ColorUnit::operator> | ( | const ColorUnit & | color_unit | ) | const |
Greater test.
Greater means that the internal value (float) this is greater than the internal value (float) of color_unit colorUnit.
bool BALL::VIEW::ColorUnit::operator>= | ( | const ColorUnit & | color_unit | ) | const |
Greater or equal test.
Greater or equal means that the internal value (float) this is greater or equal than the internal value (float) of color_unit colorUnit.
void BALL::VIEW::ColorUnit::set | ( | const double | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | a double of range 0-1.0 |
InvalidRange | if value < 0.0 || value >
1.0 |
void BALL::VIEW::ColorUnit::set | ( | const float | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | a float of range 0-1.0 |
InvalidRange | if value < 0.0 || value >
1.0 |
void BALL::VIEW::ColorUnit::set | ( | const unsigned long | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | an unsigned long of range
0-255 |
InvalidRange | if value > 255 |
void BALL::VIEW::ColorUnit::set | ( | const long | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | a long of range 0-255 |
InvalidRange | if value < 0 || value >
255 |
void BALL::VIEW::ColorUnit::set | ( | const unsigned int | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | an unsigned int of range
0-255 |
InvalidRange | if value > 255 |
void BALL::VIEW::ColorUnit::set | ( | const int | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | an int of range 0-255 |
InvalidRange | if value < 0 || value >
255 |
void BALL::VIEW::ColorUnit::set | ( | const unsigned short | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | an unsigned short of range
0-255 |
InvalidRange | if value > 255 |
void BALL::VIEW::ColorUnit::set | ( | const short | value | ) | throw (Exception::InvalidRange) |
Changes the value of the colorUnit.
value | a short of range 0-255 |
InvalidRange | if value < 0 || value >
255 |
void BALL::VIEW::ColorUnit::set | ( | const unsigned char | value | ) |
Changes the value of the colorUnit.
value | an unsigned char of range
0-255 |
void BALL::VIEW::ColorUnit::set | ( | const String & | value | ) | throw (Exception::InvalidRange, NotInHexFormat) |
Changes the value of the colorUnit.
Changes the value of this colorUnit to the value represented by a string value.
value | a string (in the format "00"-"FF"
or "00"-"ff" ) |
InvalidRange | if string length != 2 |
|
NotInHexFormat | if string contains characters g-z or G-Z |
void BALL::VIEW::ColorUnit::set | ( | const char * | value | ) | throw (Exception::InvalidRange, NotInHexFormat) |
Changes the value of the colorUnit.
value | the new value of this colorUnit (a string in
the format "00"-"FF" or
"00"-"ff" ) |
InvalidRange | if string length != 2 |
|
NotInHexFormat | if string contains characters g-z or G-Z |
std::ostream& operator<< | ( | std::ostream & | s, | |
const ColorUnit & | color_unit | |||
) | [friend] |
Friendly stream output.
Writes colorUnit data to the output stream s and
store the value of this. The value will be stored in
integer format of range 0-255
.
s | output stream to where the value of this colorUnit will be stored | |
color_unit | the colorUnit from which the value will be stored |
std::istream& operator>> | ( | std::istream & | s, | |
ColorUnit & | color_unit | |||
) | [friend] |
Friendly stream input.
Reads colorUnit data from the input stream s and
restore the value of this. The value will be needed in
integer format of range 0-255
. This method is
provided for convienience.
s | input stream from where to restore the value of this colorUnit | |
color_unit | the colorUnit to which the value will be restored |