00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef UPDATE_SEQ
00016 #define UPDATE_SEQ
00017
00018 #include "pandabase.h"
00019 #include "pmutex.h"
00020 #include "mutexHolder.h"
00021 #include "atomicAdjust.h"
00022 #include "numeric_types.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 class EXPCL_PANDA_PUTIL UpdateSeq {
00044 PUBLISHED:
00045 INLINE UpdateSeq();
00046 INLINE static UpdateSeq initial();
00047 INLINE static UpdateSeq old();
00048 INLINE static UpdateSeq fresh();
00049
00050 INLINE UpdateSeq(const UpdateSeq ©);
00051 INLINE UpdateSeq &operator = (const UpdateSeq ©);
00052
00053 INLINE void clear();
00054
00055 INLINE bool is_initial() const;
00056 INLINE bool is_old() const;
00057 INLINE bool is_fresh() const;
00058 INLINE bool is_special() const;
00059
00060 INLINE bool operator == (const UpdateSeq &other) const;
00061 INLINE bool operator != (const UpdateSeq &other) const;
00062 INLINE bool operator < (const UpdateSeq &other) const;
00063 INLINE bool operator <= (const UpdateSeq &other) const;
00064 INLINE bool operator > (const UpdateSeq &other) const;
00065 INLINE bool operator >= (const UpdateSeq &other) const;
00066
00067 INLINE UpdateSeq operator ++ ();
00068 INLINE UpdateSeq operator ++ (int);
00069
00070 INLINE void output(ostream &out) const;
00071
00072 private:
00073 INLINE static bool priv_is_special(AtomicAdjust::Integer seq);
00074 INLINE static bool priv_lt(AtomicAdjust::Integer a, AtomicAdjust::Integer b);
00075 INLINE static bool priv_le(AtomicAdjust::Integer a, AtomicAdjust::Integer b);
00076
00077 private:
00078 enum SpecialCases {
00079 SC_initial = 0,
00080 SC_old = 1,
00081 SC_fresh = ~(unsigned int)0,
00082 };
00083
00084 AtomicAdjust::Integer _seq;
00085 };
00086
00087 INLINE ostream &operator << (ostream &out, const UpdateSeq &value);
00088
00089 #include "updateSeq.I"
00090
00091 #endif