1 /* === S I N F G =========================================================== */
3 ** \brief Template Header
5 ** $Id: uniqueid.h,v 1.1.1.1 2005/01/04 01:23:15 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_UNIQUEID_H
25 #define __SINFG_UNIQUEID_H
27 /* === H E A D E R S ======================================================= */
29 /* === M A C R O S ========================================================= */
31 /* === T Y P E D E F S ===================================================== */
33 /* === C L A S S E S & S T R U C T S ======================================= */
37 class UniqueIDLessThan;
44 friend class UniqueIDLessThan;
48 explicit UniqueID(int id_):id_(id_) { }
54 //! Returns the internal unique identifier for this object.
55 /*! The return value from this isn't really useful for
56 ** much other than debug output. Nonetheless, that is
57 ** one step above useless, so here it is. */
58 const int &get_uid()const { return id_; }
60 UniqueID():id_(next_id()) { }
62 void make_unique() { id_=next_id(); }
64 static const UniqueID nil() { return UniqueID(0); }
66 operator bool()const { return static_cast<bool>(id_); }
68 void mimic(const UniqueID& x) { id_=x.id_; }
70 bool operator==(const UniqueID &rhs)const { return id_==rhs.id_; }
71 bool operator!=(const UniqueID &rhs)const { return id_!=rhs.id_; }
72 bool operator<(const UniqueID &rhs)const { return id_<rhs.id_; }
73 }; // END of class UniqueID
75 /*! \class UniqueIDLessThan
76 ** \brief A function class used for sorting based on UniqueIDs
78 class UniqueIDLessThan
81 bool operator()(const UniqueID &lhs, const UniqueID &rhs)const
82 { return lhs.id_<rhs.id_; }
86 }; // END of namespace sinfg
88 /* === E N D =============================================================== */