uniqueid.h

Go to the documentation of this file.
00001 /* === S Y N F I G ========================================================= */
00021 /* ========================================================================= */
00022 
00023 /* === S T A R T =========================================================== */
00024 
00025 #ifndef __SYNFIG_UNIQUEID_H
00026 #define __SYNFIG_UNIQUEID_H
00027 
00028 /* === H E A D E R S ======================================================= */
00029 
00030 /* === M A C R O S ========================================================= */
00031 
00032 /* === T Y P E D E F S ===================================================== */
00033 
00034 /* === C L A S S E S & S T R U C T S ======================================= */
00035 
00036 namespace synfig {
00037 
00038 class UniqueIDLessThan;
00039 
00043 class UniqueID
00044 {
00045     friend class UniqueIDLessThan;
00046 
00047     int id_;
00048 
00049     explicit UniqueID(int id_):id_(id_) { }
00050 
00051     static int next_id();
00052 
00053 public:
00054 
00056 
00059     const int &get_uid()const { return id_; }
00060 
00061     UniqueID():id_(next_id()) { }
00062 
00063     void make_unique() { id_=next_id(); }
00064 
00065     static const UniqueID nil() { return UniqueID(0); }
00066 
00067     operator bool()const { return static_cast<bool>(id_); }
00068 
00069     void mimic(const UniqueID& x) { id_=x.id_; }
00070 
00071     bool operator==(const UniqueID &rhs)const { return id_==rhs.id_; }
00072     bool operator!=(const UniqueID &rhs)const { return id_!=rhs.id_; }
00073     bool operator<(const UniqueID &rhs)const { return id_<rhs.id_; }
00074 }; // END of class UniqueID
00075 
00079 class UniqueIDLessThan
00080 {
00081 public:
00082     bool operator()(const UniqueID &lhs, const UniqueID &rhs)const
00083     { return lhs.id_<rhs.id_; }
00084 };
00085 
00086 
00087 }; // END of namespace synfig
00088 
00089 /* === E N D =============================================================== */
00090 
00091 #endif

Generated on Wed Dec 12 03:11:41 2007 for synfig by  doxygen 1.5.4