00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _NR_C_PRIORITY__H_
00015 #define _NR_C_PRIORITY__H_
00016
00017
00018
00019
00020
00021 #include "Prerequisities.h"
00022
00023
00024 namespace nrEngine{
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 class _NRExport CPriority{
00055 public:
00056
00057
00058
00059
00060
00061 typedef enum _PriorityType{
00062
00063
00064 IMMEDIATE = 0,
00065
00066
00067 FIRST = 1,
00068
00069
00070 ULTRA_HIGH = 10000,
00071
00072
00073 VERY_HIGH = 20000,
00074
00075
00076 HIGH = 30000,
00077
00078
00079 NORMAL = 40000,
00080
00081
00082 LOW = 50000,
00083
00084
00085 VERY_LOW = 60000,
00086
00087
00088 ULTRA_LOW = 70000,
00089
00090
00091 LAST = 0x8FFFFFFE
00092
00093 }PriorityType;
00094
00095
00096 CPriority(): mPriority(NORMAL){}
00097
00098
00099 ~CPriority() {}
00100
00101
00102 CPriority(const CPriority& p){
00103 mPriority = p.get();
00104 }
00105
00106
00107 CPriority(const int32& n): mPriority(n) {}
00108
00109
00110
00111
00112
00113 CPriority(const std::string& str){
00114
00115 if (str.length() == 0){ mPriority = NORMAL;}
00116 #define _PRIORITY_(name) else if (str == #name){ mPriority = name;}
00117 _PRIORITY_(FIRST)
00118 _PRIORITY_(ULTRA_HIGH)
00119 _PRIORITY_(VERY_HIGH)
00120 _PRIORITY_(HIGH)
00121 _PRIORITY_(NORMAL)
00122 _PRIORITY_(LOW)
00123 _PRIORITY_(VERY_LOW)
00124 _PRIORITY_(ULTRA_LOW)
00125 _PRIORITY_(LAST)
00126 #undef _PRIORITY_
00127 else{
00128 mPriority = boost::lexical_cast<uint32>(str);
00129 }
00130 }
00131
00132
00133 operator int32() const { return u2i(mPriority);}
00134
00135
00136 operator uint32() const { return mPriority;}
00137
00138
00139 CPriority& operator += (const CPriority& p) {mPriority += p.get(); return *this;}
00140 CPriority& operator += (const uint32& p) {mPriority += p; return *this;}
00141
00142
00143 CPriority& operator += (const int32& p) {mPriority = i2u(u2i(mPriority) + p); return *this;}
00144
00145
00146 CPriority& operator -= (const CPriority& p) {mPriority = i2u(u2i(mPriority) - u2i(p.get())); return *this;}
00147 CPriority& operator -= (const int32& p) {mPriority = i2u(u2i(mPriority) - p); return *this;}
00148 CPriority& operator -= (const uint32& p) {mPriority = i2u(u2i(mPriority) - u2i(p)); return *this;}
00149
00150
00151 bool operator < (const CPriority& p) const{return mPriority < p.get();}
00152 bool operator > (const CPriority& p) const{return mPriority > p.get();}
00153 bool operator ==(const CPriority& p) const{return mPriority == p.get();}
00154 bool operator !=(const CPriority& p) const{return mPriority != p.get();}
00155 bool operator <=(const CPriority& p) const{return mPriority <= p.get();}
00156 bool operator >=(const CPriority& p) const{return mPriority >= p.get();}
00157
00158
00159 bool operator < (const int32& p) const{return mPriority < i2u(p);}
00160 bool operator > (const int32& p) const{return mPriority > i2u(p);}
00161 bool operator ==(const int32& p) const{return mPriority == i2u(p);}
00162 bool operator !=(const int32& p) const{return mPriority != i2u(p);}
00163 bool operator <=(const int32& p) const{return mPriority <= i2u(p);}
00164 bool operator >=(const int32& p) const{return mPriority >= i2u(p);}
00165
00166
00167 bool operator < (PriorityType p) const{return mPriority < (uint32)p;}
00168 bool operator > (PriorityType p) const{return mPriority > (uint32)p;}
00169 bool operator ==(PriorityType p) const{return mPriority == (uint32)p;}
00170 bool operator !=(PriorityType p) const{return mPriority != (uint32)p;}
00171 bool operator <=(PriorityType p) const{return mPriority <= (uint32)p;}
00172 bool operator >=(PriorityType p) const{return mPriority >= (uint32)p;}
00173
00174
00175 operator std::string(){
00176 if (false){}
00177 #define _PRIORITY_(name) else if (mPriority == name){ return std::string(#name);}
00178 _PRIORITY_(IMMEDIATE)
00179 _PRIORITY_(FIRST)
00180 _PRIORITY_(ULTRA_HIGH)
00181 _PRIORITY_(VERY_HIGH)
00182 _PRIORITY_(HIGH)
00183 _PRIORITY_(NORMAL)
00184 _PRIORITY_(LOW)
00185 _PRIORITY_(VERY_LOW)
00186 _PRIORITY_(ULTRA_LOW)
00187 _PRIORITY_(LAST)
00188 #undef _PRIORITY_
00189 else{
00190 return boost::lexical_cast<std::string>(mPriority);
00191 }
00192 }
00193
00194 private:
00195
00196 uint32 mPriority;
00197
00198
00199 const uint32& get()const {return mPriority;}
00200
00201
00202 uint32 i2u(const int32& i) const{
00203 if (i >= 0) return static_cast<uint32>(i);
00204 else return 0;
00205 }
00206
00207
00208 int32 u2i(const uint32& i) const {
00209 if (i < 0x8FFFFFFF) return static_cast<uint32>(i);
00210 else return 0x8FFFFFFE;
00211 }
00212
00213 };
00214
00215
00216 typedef CPriority Priority;
00217
00218 };
00219
00220 #endif
00221