00001
00002
00003
00004
00005
00006
00007 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H
00008 #define BALL_VIEW_DATATYPE_COLORUNIT_H
00009
00010 #ifndef BALL_COMMON_H
00011 # include <BALL/common.h>
00012 #endif
00013
00014 #ifndef BALL_DATATYPE_STRING_H
00015 # include <BALL/DATATYPE/string.h>
00016 #endif
00017
00018 #include <iostream>
00019 #include <stdio.h>
00020
00021 namespace BALL
00022 {
00023 namespace VIEW
00024 {
00038 class BALL_VIEW_EXPORT ColorUnit
00039 {
00040 public:
00041
00042
00043
00047
00054 class BALL_VIEW_EXPORT NotInHexFormat: public Exception::GeneralException
00055 {
00056 public:
00057
00058 NotInHexFormat(const char* file, int line, const string& data);
00059 };
00060
00062
00065
00069 ColorUnit();
00070
00073 ColorUnit(const ColorUnit& color_unit);
00074
00081 ColorUnit(const char* value)
00082 throw(Exception::InvalidRange, NotInHexFormat);
00083
00089 ColorUnit(const String& value)
00090 throw(Exception::InvalidRange, NotInHexFormat);
00091
00095 ColorUnit(const unsigned char value);
00096
00101 ColorUnit(const short value)
00102 throw(Exception::InvalidRange);
00103
00108 ColorUnit(const unsigned short value)
00109 throw(Exception::InvalidRange);
00110
00115 ColorUnit(const int value)
00116 throw(Exception::InvalidRange);
00117
00122 ColorUnit(const unsigned int value)
00123 throw(Exception::InvalidRange);
00124
00129 ColorUnit(const long value)
00130 throw(Exception::InvalidRange);
00131
00136 ColorUnit(const unsigned long value)
00137 throw(Exception::InvalidRange);
00138
00143 ColorUnit(const float value)
00144 throw(Exception::InvalidRange);
00145
00150 ColorUnit(const double value)
00151 throw(Exception::InvalidRange);
00152
00154
00156
00159 ~ColorUnit();
00160
00167 void clear();
00168
00170
00173
00177 operator String () const;
00178
00182 operator char () const;
00183
00187 operator unsigned char () const;
00188
00192 operator short () const;
00193
00197 operator unsigned short () const;
00198
00202 operator int () const;
00203
00207 operator unsigned int () const;
00208
00212 operator long () const;
00213
00217 operator unsigned long () const;
00218
00222 operator float () const;
00223
00227 operator double () const;
00228
00230
00233
00236 void set(const ColorUnit& color_unit);
00237
00241 const ColorUnit& operator = (const ColorUnit& color_unit);
00242
00245 void swap(ColorUnit& color_unit);
00246
00248
00251
00257 void set(const char* value)
00258 throw(Exception::InvalidRange, NotInHexFormat);
00259
00266 const ColorUnit& operator = (const char* value)
00267 throw(Exception::InvalidRange, NotInHexFormat);
00268
00274 void get(char* value) const;
00275
00283 void set(const String& value)
00284 throw(Exception::InvalidRange, NotInHexFormat);
00285
00292 const ColorUnit& operator = (const String& value)
00293 throw(Exception::InvalidRange, NotInHexFormat);
00294
00298 void get(String& value) const;
00299
00303 void set(const unsigned char value);
00304
00309 const ColorUnit& operator = (const unsigned char value);
00310
00314 void get(unsigned char& value) const;
00315
00320 void set(const short value)
00321 throw(Exception::InvalidRange);
00322
00328 const ColorUnit& operator = (const short value)
00329 throw(Exception::InvalidRange);
00330
00334 void get(short& value) const;
00335
00340 void set(const unsigned short value)
00341 throw(Exception::InvalidRange);
00342
00348 const ColorUnit& operator = (const unsigned short value)
00349 throw(Exception::InvalidRange);
00350
00354 void get(unsigned short& value) const;
00355
00360 void set(const int value)
00361 throw(Exception::InvalidRange);
00362
00368 const ColorUnit& operator = (const int value)
00369 throw(Exception::InvalidRange);
00370
00374 void get(int& value) const;
00375
00380 void set(const unsigned int value)
00381 throw(Exception::InvalidRange);
00382
00388 const ColorUnit& operator = (const unsigned int value)
00389 throw(Exception::InvalidRange);
00390
00394 void get(unsigned int& value) const;
00395
00400 void set(const long value)
00401 throw(Exception::InvalidRange);
00402
00408 const ColorUnit& operator = (const long value)
00409 throw(Exception::InvalidRange);
00410
00414 void get(long& value) const;
00415
00420 void set(const unsigned long value)
00421 throw(Exception::InvalidRange);
00422
00428 const ColorUnit& operator = (const unsigned long value)
00429 throw(Exception::InvalidRange);
00430
00434 void get(unsigned long& value) const;
00435
00440 void set(const float value)
00441 throw(Exception::InvalidRange);
00442
00448 const ColorUnit& operator = (const float value)
00449 throw(Exception::InvalidRange);
00450
00454 void get(float& value) const;
00455
00460 void set(const double value)
00461 throw(Exception::InvalidRange);
00462
00468 const ColorUnit& operator = (const double value)
00469 throw(Exception::InvalidRange);
00470
00474 void get(double& value) const;
00475
00477
00480
00485 bool operator == (const ColorUnit& color_unit) const;
00486
00491 bool operator != (const ColorUnit& color_unit) const;
00492
00497 bool operator < (const ColorUnit& color_unit) const;
00498
00503 bool operator <= (const ColorUnit& color_unit) const;
00504
00509 bool operator > (const ColorUnit& color_unit) const;
00510
00515 bool operator >= (const ColorUnit& color_unit) const;
00516
00518
00521
00529 void dump(std::ostream& s = std::cout, Size depth = 0) const;
00530
00532
00535
00543 friend std::istream& operator >> (std::istream& s, ColorUnit& color_unit);
00544
00551 friend std::ostream& operator << (std::ostream& s, const ColorUnit& color_unit);
00553
00554 private:
00555
00556 float hexToFloat_(const char* value)
00557 throw(Exception::InvalidRange, NotInHexFormat);
00558
00559 float value_;
00560
00561 };
00562
00563 # ifndef BALL_NO_INLINE_FUNCTIONS
00564 # include <BALL/VIEW/DATATYPE/colorUnit.iC>
00565 # endif
00566
00567 }
00568 }
00569
00570 #endif // BALL_VIEW_DATATYPE_COLORUNIT_H