Public Types | |
enum | _PriorityType { IMMEDIATE = 0, FIRST = 1, ULTRA_HIGH = 10000, VERY_HIGH = 20000, HIGH = 30000, NORMAL = 40000, LOW = 50000, VERY_LOW = 60000, ULTRA_LOW = 70000, LAST = 0x8FFFFFFE } |
typedef enum nrEngine::CPriority::_PriorityType | PriorityType |
Public Member Functions | |
CPriority () | |
Normal constructor. | |
~CPriority () | |
non-virtual destructor to prevent deriving of classes | |
CPriority (const CPriority &p) | |
Copy constructor for priorities. | |
CPriority (const int32 &n) | |
Create priority object from a number. | |
CPriority (const std::string &str) | |
operator int32 () const | |
Get the priority as an integer number, Number will be saturated. | |
operator uint32 () const | |
Get the priority number. | |
CPriority & | operator+= (const CPriority &p) |
add new value to the priority number | |
CPriority & | operator+= (const uint32 &p) |
CPriority & | operator+= (const int32 &p) |
Add an integer value can produce negative values. | |
CPriority & | operator-= (const CPriority &p) |
Substract a value from the priority by appropriate conversion between these types. | |
CPriority & | operator-= (const int32 &p) |
CPriority & | operator-= (const uint32 &p) |
bool | operator< (const CPriority &p) const |
Check the priority eqiuvalence and order to other values. | |
bool | operator> (const CPriority &p) const |
bool | operator== (const CPriority &p) const |
bool | operator!= (const CPriority &p) const |
bool | operator<= (const CPriority &p) const |
bool | operator>= (const CPriority &p) const |
bool | operator< (const int32 &p) const |
Check the priority eqiuvalence and order to other integer values. | |
bool | operator> (const int32 &p) const |
bool | operator== (const int32 &p) const |
bool | operator!= (const int32 &p) const |
bool | operator<= (const int32 &p) const |
bool | operator>= (const int32 &p) const |
bool | operator< (PriorityType p) const |
Check to PriorityType. | |
bool | operator> (PriorityType p) const |
bool | operator== (PriorityType p) const |
bool | operator!= (PriorityType p) const |
bool | operator<= (PriorityType p) const |
bool | operator>= (PriorityType p) const |
operator std::string () | |
Convert to a string. |
Priorities definition. Priorities are used very often to determine for example which object should be removed first or which one has to get access to some resources.
In our engine we understand under priority numbers some numbers that handles like integers. You have two operations defined on the priorities: addidition and substraction. You can add integers to priority numbers to increase or decrease the meaning of such a priority.
The class which use such priorities should know how to handle with them. That means it has to know if the priority numbers are in increasing or decreasing order. Increasing order means that the element with the lowest priority is coming at last and with the highest as first. So to say colloquially, lower priority is better than higher. There can also be another way: decreasing order. Which is converse to increasing order.
All default priority numbers are stored in decreasing order. That means the best priority is the priority with the smallest number. So you are welcome to use this definition or just write you classes according to increasing definition.
You can also create priority numbers from strings. The given string will first be scanned for known names like "PRIORITY_FIRST" or "NR_PRIORITY_FIRST" and so on. If such known string was found, so the value according to such a string will be assigned. If no such name found, so standard boost's lexical cast will be used to cast for the value. So this can also fail if the given string could not been casted. (e.g. "5bla" -> not castable)
Definition at line 54 of file Priority.h.
Couple of pririoty default definitions. Can be used to specify a priority of any elements with CPriority-Class
Couple of pririoty default definitions. Can be used to specify a priority of any elements with CPriority-Class
Definition at line 61 of file Priority.h.
nrEngine::CPriority::CPriority | ( | const std::string & | str | ) |
Create the priority from a string. String can contain either a number or a character array with priority names e.g. "PRIORITY_LAST"
Definition at line 113 of file Priority.h.