Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

identity.h

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 namespace sc {
00040 
00041 class Identity;
00042 
00050 class Identifier {
00051   private:
00052     const void* id;
00053   public:
00055     Identifier(): id(0) {}
00057     Identifier(const Identity* i): id((void*)i) {}
00059     Identifier(const Identifier& i): id(i.id) {}
00061     ~Identifier() {}
00062 
00064     void operator = (const Identifier& i) { id = i.id; }
00065 
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; }
00077     int operator != (const Identifier&i) const { return id != i.id; }
00078 
00079     void print(std::ostream&) const;
00080 };
00081 
00082 std::ostream & operator << (std::ostream &o, const Identifier &i);
00083 
00089 class Identity {
00090   public:
00091     virtual ~Identity();
00094     Identifier identifier() { return this; }
00095 };
00097 inline int lt(const Identity*i, const Identity*j) { return i < j; }
00099 inline int gt(const Identity*i, const Identity*j) { return i > j; }
00101 inline int le(const Identity*i, const Identity*j) { return i <= j; }
00103 inline int ge(const Identity*i, const Identity*j) { return i >= j; }
00105 inline int eq(const Identity*i, const Identity*j) { return i == j; }
00107 inline int ne(const Identity*i, const Identity*j) { return i != j; }
00110 inline int cmp(const Identity*i, const Identity*j)
00111 {
00112   return (i==j)?0:((i<j)?-1:1);
00113 }
00114 
00115 }
00116 
00117 #endif
00118 
00119 // Local Variables:
00120 // mode: c++
00121 // c-file-style: "CLJ"
00122 // End:

Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14.