Add functions for cycling inside an enum.

This commit is contained in:
Juanjo
2013-06-18 16:32:04 +02:00
committed by pelya
parent 381c4e98aa
commit fbd9b7c906

View File

@@ -28,6 +28,19 @@
}
/** Some enums need to have cycling through values */
#define DECLARE_CYCLE(type, min_val, max_val) \
inline type CycleUp(type e) \
{ \
assert(!((int)e < min_val || (int)e > max_val)); \
return e == max_val ? (type)min_val : (type)((int)e + 1); \
} \
inline type CycleDown(type e) \
{ \
assert(!((int)e < min_val || (int)e > max_val)); \
return e == min_val ? (type)max_val : (type)((int)e - 1); \
}
/** Operators to allow to work with enum as with type safe bit set in C++ */
# define DECLARE_ENUM_AS_BIT_SET(mask_t) \