00001
00002
00003
00004 #ifndef DEV_W3_ORG__2001_BLINDFOLD_SRC_LOOPSTATE_H
00005 #define DEV_W3_ORG__2001_BLINDFOLD_SRC_LOOPSTATE_H
00006 #include "config.h"
00007
00008
00017 class LoopState {
00018
00019 public:
00020
00021
00022 LoopState();
00023 LoopState(const LoopState& other);
00024 const LoopState& operator=(const LoopState& other);
00025 bool operator==(const LoopState& other) const;
00026 bool operator<(const LoopState& other) const;
00027 size_t hash() const;
00028 friend std::ostream& operator<<(std::ostream& s, const LoopState& me);
00029 std::ostream& print_to(std::ostream& stream) const;
00030 ~LoopState();
00031
00032
00033
00034
00038 union {
00039 void* as_ptr;
00040 int as_int;
00041 unsigned long as_ulong;
00042 } data;
00043
00044
00048 void (*reset_handler)(LoopState&);
00049
00053 void reset() {
00054 if (reset_handler) {
00055 (*reset_handler)(*this);
00056 } else {
00057 data.as_ptr = 0;
00058 }
00059 }
00060
00061
00062 private:
00063
00064
00065 };
00066
00067
00068 inline LoopState::LoopState() {
00069 data.as_ptr = 0;
00070 reset_handler = 0;
00071 }
00072
00073 inline LoopState::~LoopState() {
00074 reset();
00075 }
00076
00077
00137 STANDARD_EXTERNAL(LoopState)
00138
00139 #endif