BALL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Classes | Private Member Functions | Private Attributes
BALL::VIEW::ColorUnit Class Reference

#include <BALL/VIEW/DATATYPE/colorUnit.h>

List of all members.

Classes

class  NotInHexFormat

Public Member Functions

Constructors
 ColorUnit ()
 ColorUnit (const ColorUnit &color_unit)
 ColorUnit (const char *value)
 ColorUnit (const String &value)
 ColorUnit (const unsigned char value)
 ColorUnit (const short value)
 ColorUnit (const unsigned short value)
 ColorUnit (const int value)
 ColorUnit (const unsigned int value)
 ColorUnit (const long value)
 ColorUnit (const unsigned long value)
 ColorUnit (const float value)
 ColorUnit (const double value)
Destructors
 ~ColorUnit ()
void clear ()
Converters
 operator String () const
 operator char () const
 operator unsigned char () const
 operator short () const
 operator unsigned short () const
 operator int () const
 operator unsigned int () const
 operator long () const
 operator unsigned long () const
 operator float () const
 operator double () const
Assignment methods
void set (const ColorUnit &color_unit)
const ColorUnitoperator= (const ColorUnit &color_unit)
void swap (ColorUnit &color_unit)
Accessors: inspectors and mutators
void set (const char *value)
const ColorUnitoperator= (const char *value)
void get (char *value) const
void set (const String &value)
const ColorUnitoperator= (const String &value)
void get (String &value) const
void set (const unsigned char value)
const ColorUnitoperator= (const unsigned char value)
void get (unsigned char &value) const
void set (const short value)
const ColorUnitoperator= (const short value)
void get (short &value) const
void set (const unsigned short value)
const ColorUnitoperator= (const unsigned short value)
void get (unsigned short &value) const
void set (const int value)
const ColorUnitoperator= (const int value)
void get (int &value) const
void set (const unsigned int value)
const ColorUnitoperator= (const unsigned int value)
void get (unsigned int &value) const
void set (const long value)
const ColorUnitoperator= (const long value)
void get (long &value) const
void set (const unsigned long value)
const ColorUnitoperator= (const unsigned long value)
void get (unsigned long &value) const
void set (const float value)
const ColorUnitoperator= (const float value)
void get (float &value) const
void set (const double value)
const ColorUnitoperator= (const double value)
void get (double &value) const
Predicates
bool operator== (const ColorUnit &color_unit) const
bool operator!= (const ColorUnit &color_unit) const
bool operator< (const ColorUnit &color_unit) const
bool operator<= (const ColorUnit &color_unit) const
bool operator> (const ColorUnit &color_unit) const
bool operator>= (const ColorUnit &color_unit) const
debuggers and diagnostics
void dump (std::ostream &s=std::cout, Size depth=0) const

Private Member Functions

float hexToFloat_ (const char *value)

Private Attributes

float value_

Friends

Storers
std::istream & operator>> (std::istream &s, ColorUnit &color_unit)
std::ostream & operator<< (std::ostream &s, const ColorUnit &color_unit)

Detailed Description

ColorUnit class. 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.

Definition at line 36 of file colorUnit.h.


Constructor & Destructor Documentation

Default Constructor. Its value will be set to zero (0).

Copy constructor.

BALL::VIEW::ColorUnit::ColorUnit ( const char *  value)

Constructor with Parameter char*, representing a value in hex format (00 - FF, or 00 - ff).

Parameters:
valuethe pointer to a string (00 - FF, or 00 - ff)
Exceptions:
InvalidRangeif string length != 2
NotInHexFormatif string contains characters g-z or G-Z

Constructor with Parameter String.

Parameters:
valuea string (00 - FF, or 00 - ff)
Exceptions:
InvalidRangeif string length != 2
NotInHexFormatif string contains characters g-z or G-Z
BALL::VIEW::ColorUnit::ColorUnit ( const unsigned char  value)

Constructor with Parameter unsigned char.

Parameters:
valuea char (0 - 255)
BALL::VIEW::ColorUnit::ColorUnit ( const short  value)

Constructor with Parameter short.

Parameters:
valuea short (0 - 255)
Exceptions:
InvalidRangeif value < 0 || value > 255
BALL::VIEW::ColorUnit::ColorUnit ( const unsigned short  value)

Constructor with Parameter unsigned short.

Parameters:
valuea unsigned short (0 - 255)
Exceptions:
InvalidRangeif value > 255
BALL::VIEW::ColorUnit::ColorUnit ( const int  value)

Constructor with Parameter int.

Parameters:
valuean int (0 - 255)
Exceptions:
InvalidRangeif value < 0 || value > 255
BALL::VIEW::ColorUnit::ColorUnit ( const unsigned int  value)

Constructor with Parameter unsigned int.

Parameters:
valuean unsigned int (0 - 255)
Exceptions:
InvalidRangeif value > 255
BALL::VIEW::ColorUnit::ColorUnit ( const long  value)

Constructor with Parameter long.

Parameters:
valuean long (0 - 255)
Exceptions:
InvalidRangeif value < 0 || value > 255
BALL::VIEW::ColorUnit::ColorUnit ( const unsigned long  value)

Constructor with Parameter unsigned long.

Parameters:
valuean unsigned long (0 - 255)
Exceptions:
InvalidRangeif value > 255

Constructor with Parameter float.

Parameters:
valuea float (0 - 1.0)
Exceptions:
InvalidRangeif value < 0.0 || value > 1.0

Constructor with Parameter double.

Parameters:
valuea double (0 - 1.0)
Exceptions:
InvalidRangeif value < 0.0 || value > 1.0

Destructor.


Member Function Documentation

Explicit default initialization. Sets the value of this colorUnit to the default value. The value of this colorUnit is:

  • value is zero (0)
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.

Parameters:
soutput stream where to output the value of this colorUnit
depththe dumping depth (depth is irrelevant here)
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.

Parameters:
valuea char* receiving the value of this colorUnit in hex format ( "00"-"FF" or "00"-"ff")
void BALL::VIEW::ColorUnit::get ( String value) const

Inspection of the colorUnit's value.

Parameters:
valuea string receiving the value of this colorUnit in hex format ( "00"-"FF" or "00"-"ff")
void BALL::VIEW::ColorUnit::get ( unsigned char &  value) const

Inspection of the colorUnit's value.

Parameters:
valuean unsigned char receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( short &  value) const

Inspection of the colorUnit's value.

Parameters:
valuea short receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( unsigned short &  value) const

Inspection of the colorUnit's value.

Parameters:
valuean unsigned short receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( int &  value) const

Inspection of the colorUnit's value.

Parameters:
valuean int receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( unsigned int &  value) const

Inspection of the colorUnit's value.

Parameters:
valuean unsigned int receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( long &  value) const

Inspection of the colorUnit's value.

Parameters:
valuea long receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( unsigned long &  value) const

Inspection of the colorUnit's value.

Parameters:
valuean unsigned long receiving the value of this colorUnit (range: 0-255)
void BALL::VIEW::ColorUnit::get ( float value) const

Inspection of the colorUnit's value.

Parameters:
valuea float receiving the value of this colorUnit (range: 0-1.0)
void BALL::VIEW::ColorUnit::get ( double value) const

Inspection of the colorUnit's value.

Parameters:
valuea double receiving the value of this colorUnit (range: 0-1.0)
float BALL::VIEW::ColorUnit::hexToFloat_ ( const char *  value) [private]
BALL::VIEW::ColorUnit::operator char ( ) const

Conversion to char.

Returns:
char with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator double ( ) const

Conversion to double.

Returns:
double with a value of range 0 - 1.0
BALL::VIEW::ColorUnit::operator float ( ) const

Conversion to float.

Returns:
float with a value of range 0 - 1.0
BALL::VIEW::ColorUnit::operator int ( ) const

Conversion to int.

Returns:
int with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator long ( ) const

Conversion to long.

Returns:
long with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator short ( ) const

Conversion to short.

Returns:
short with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator String ( ) const

Conversion to string.

Returns:
string with format "00"-"FF" or "00"-"ff"
BALL::VIEW::ColorUnit::operator unsigned char ( ) const

Conversion to unsigned char.

Returns:
unsigned char with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator unsigned int ( ) const

Conversion to unsigned int.

Returns:
unsigned int with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator unsigned long ( ) const

Conversion to unsigned long.

Returns:
unsigned long with a value of range 0 - 255
BALL::VIEW::ColorUnit::operator unsigned short ( ) const

Conversion to unsigned short.

Returns:
unsigned short with a value of range 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 ColorUnit color_unit)

Assignment operator.

See also:
set
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const char *  value)

Assignment operator with char*. Calls set.

Parameters:
valuethe pointer to a string containing a value in hex format ( "00"-"FF" or "00"-"ff")
Exceptions:
InvalidRangeif string length != 2
NotInHexFormatif string contains characters g-z or G-Z
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const String value)

Assignment operator with string. Calls set.

Parameters:
valuea string containing a value in hex format ( "00"-"FF" or "00"-"ff")
Exceptions:
InvalidRangeif string length != 2
NotInHexFormatif string contains characters g-z or G-Z
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const unsigned char  value)

Assignment operator with unsigned char. Calls set.

Parameters:
valuean unsigned char containing a value of range 0-255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const short  value)

Assignment operator with short. Calls set.

Parameters:
valuea short containing a value of range 0-255
Exceptions:
InvalidRangeif value < 0 || value > 255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const unsigned short  value)

Assignment operator with unsigned short. Calls set.

Parameters:
valuean unsigned short containing a value of range 0-255
Exceptions:
InvalidRangeif value > 255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const int  value)

Assignment operator with int. Calls set.

Parameters:
valuean int containing a value of range 0-255
Exceptions:
InvalidRangeif value < 0 || value > 255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const unsigned int  value)

Assignment operator with unsigned int. Calls set.

Parameters:
valuean unsigned int containing a value of range 0-255
Exceptions:
InvalidRangeif value > 255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const long  value)

Assignment operator with long. Calls set.

Parameters:
valuea long containing a value of range 0-255
Exceptions:
InvalidRangeif value < 0 || value > 255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const unsigned long  value)

Assignment operator with unsigned long. Calls set.

Parameters:
valuean unsigned long containing a value of range 0-255
Exceptions:
InvalidRangeif value > 255
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const float  value)

Assignment operator with float. Calls set.

Parameters:
valuea float containing a value of range 0-1.0
Exceptions:
InvalidRangeif value < 0.0 || value > 1.0
const ColorUnit& BALL::VIEW::ColorUnit::operator= ( const double  value)

Assignment operator with double. Calls set.

Parameters:
valuea double containing a value of range 0-1.0
Exceptions:
InvalidRangeif value < 0.0 || value > 1.0
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 ColorUnit color_unit)

Assignment.

void BALL::VIEW::ColorUnit::set ( const char *  value)

Changes the value of the colorUnit.

Parameters:
valuethe new value of this colorUnit (a string in the format "00"-"FF" or "00"-"ff")
Exceptions:
InvalidRangeif string length != 2
NotInHexFormatif string contains characters g-z or G-Z
void BALL::VIEW::ColorUnit::set ( const String value)

Changes the value of the colorUnit. Changes the value of this colorUnit to the value represented by a string value.

Parameters:
valuea string (in the format "00"-"FF" or "00"-"ff")
Exceptions:
InvalidRangeif string length != 2
NotInHexFormatif string contains characters g-z or G-Z
void BALL::VIEW::ColorUnit::set ( const unsigned char  value)

Changes the value of the colorUnit.

Parameters:
valuean unsigned char of range 0-255
void BALL::VIEW::ColorUnit::set ( const short  value)

Changes the value of the colorUnit.

Parameters:
valuea short of range 0-255
Exceptions:
InvalidRangeif value < 0 || value > 255
void BALL::VIEW::ColorUnit::set ( const unsigned short  value)

Changes the value of the colorUnit.

Parameters:
valuean unsigned short of range 0-255
Exceptions:
InvalidRangeif value > 255
void BALL::VIEW::ColorUnit::set ( const int  value)

Changes the value of the colorUnit.

Parameters:
valuean int of range 0-255
Exceptions:
InvalidRangeif value < 0 || value > 255
void BALL::VIEW::ColorUnit::set ( const unsigned int  value)

Changes the value of the colorUnit.

Parameters:
valuean unsigned int of range 0-255
Exceptions:
InvalidRangeif value > 255
void BALL::VIEW::ColorUnit::set ( const long  value)

Changes the value of the colorUnit.

Parameters:
valuea long of range 0-255
Exceptions:
InvalidRangeif value < 0 || value > 255
void BALL::VIEW::ColorUnit::set ( const unsigned long  value)

Changes the value of the colorUnit.

Parameters:
valuean unsigned long of range 0-255
Exceptions:
InvalidRangeif value > 255
void BALL::VIEW::ColorUnit::set ( const float  value)

Changes the value of the colorUnit.

Parameters:
valuea float of range 0-1.0
Exceptions:
InvalidRangeif value < 0.0 || value > 1.0
void BALL::VIEW::ColorUnit::set ( const double  value)

Changes the value of the colorUnit.

Parameters:
valuea double of range 0-1.0
Exceptions:
InvalidRangeif value < 0.0 || value > 1.0
void BALL::VIEW::ColorUnit::swap ( ColorUnit color_unit)

Swapping of colorUnits.


Friends And Related Function Documentation

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.

Parameters:
soutput stream to where the value of this colorUnit will be stored
color_unitthe 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.

Parameters:
sinput stream from where to restore the value of this colorUnit
color_unitthe colorUnit to which the value will be restored

Member Data Documentation

Definition at line 528 of file colorUnit.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines