00001 // 00002 // identity.h --- definition of the Identity class 00003 // 00004 // Copyright (C) 1996 Limit Point Systems, Inc. 00005 // 00006 // Author: Curtis Janssen <cljanss@limitpt.com> 00007 // Maintainer: LPS 00008 // 00009 // This file is part of the SC Toolkit. 00010 // 00011 // The SC Toolkit is free software; you can redistribute it and/or modify 00012 // it under the terms of the GNU Library General Public License as published by 00013 // the Free Software Foundation; either version 2, or (at your option) 00014 // any later version. 00015 // 00016 // The SC Toolkit is distributed in the hope that it will be useful, 00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 // GNU Library General Public License for more details. 00020 // 00021 // You should have received a copy of the GNU Library General Public License 00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to 00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 00024 // 00025 // The U.S. Government is granted a limited license as per AL 91-7. 00026 // 00027 00028 #ifndef _util_ref_identity_h 00029 #define _util_ref_identity_h 00030 00031 #ifdef __GNUG__ 00032 #pragma interface 00033 #endif 00034 00035 #include <iostream> 00036 00037 #include <scconfig.h> 00038 00039 class Identity; 00040 00048 class Identifier { 00049 private: 00050 const void* id; 00051 public: 00053 Identifier(): id(0) {} 00055 Identifier(const Identity* i): id((void*)i) {} 00057 Identifier(const Identifier& i): id(i.id) {} 00059 ~Identifier() {} 00060 00062 void operator = (const Identifier& i) { id = i.id; } 00063 00065 int operator < (const Identifier&i) const { return id < i.id; } 00067 int operator > (const Identifier&i) const { return id > i.id; } 00069 int operator == (const Identifier&i) const { return id == i.id; } 00071 int operator <= (const Identifier&i) const { return id <= i.id; } 00073 int operator >= (const Identifier&i) const { return id >= i.id; } 00075 int operator != (const Identifier&i) const { return id != i.id; } 00076 00077 void print(std::ostream&) const; 00078 }; 00079 00080 std::ostream & operator << (std::ostream &o, const Identifier &i); 00081 00087 class Identity { 00088 public: 00089 virtual ~Identity(); 00092 Identifier identifier() { return this; } 00093 }; 00095 inline int lt(const Identity*i, const Identity*j) { return i < j; } 00097 inline int gt(const Identity*i, const Identity*j) { return i > j; } 00099 inline int le(const Identity*i, const Identity*j) { return i <= j; } 00101 inline int ge(const Identity*i, const Identity*j) { return i >= j; } 00103 inline int eq(const Identity*i, const Identity*j) { return i == j; } 00105 inline int ne(const Identity*i, const Identity*j) { return i != j; } 00108 inline int cmp(const Identity*i, const Identity*j) 00109 { 00110 return (i==j)?0:((i<j)?-1:1); 00111 } 00112 00113 #endif 00114 00115 // Local Variables: 00116 // mode: c++ 00117 // c-file-style: "CLJ" 00118 // End: