00001 #ifndef GRAL_BASE_GB_GRID_FACET_HANDLE_H
00002 #define GRAL_BASE_GB_GRID_FACET_HANDLE_H
00003
00004
00005
00006
00007 #include "Config/compiler-config.h"
00008
00009 #include <iostream.h>
00010 #include <stdlib.h>
00011
00012
00029
00030
00031
00032
00033 template<class CHandle>
00034 struct facet_handle {
00035 CHandle c;
00036 int lf;
00037
00038 facet_handle() {}
00039 facet_handle(CHandle cc, int llf) : c(cc), lf(llf) {}
00040
00041 int local_facet() const { return lf;}
00042 };
00043
00046 template<class CHandle>
00047 inline
00048 bool operator== (facet_handle<CHandle> const& ls, facet_handle<CHandle> const& rs)
00049 { return ((ls.c == rs.c) && (ls.lf == rs.lf)); }
00050
00053 template<class CHandle>
00054 inline
00055 bool operator!= (facet_handle<CHandle> const& ls, facet_handle<CHandle> const& rs)
00056 { return ! (ls == rs) }
00057
00060 template<class CHandle>
00061 inline
00062 bool operator< (facet_handle<CHandle> const& ls, facet_handle<CHandle> const& rs)
00063 { return ((ls.c < rs.c) || ((ls.c == rs.c) && (ls.lf < rs.lf))); }
00064
00067 template<class CHandle>
00068 inline
00069 ostream& operator<< ( ostream& out, facet_handle<CHandle> const& e)
00070 { return (out << e.c << ' ' << e.lf);}
00071
00074 template<class CHandle>
00075 inline
00076 istream& operator>> ( istream& in, facet_handle<CHandle> & e)
00077 { return (in >> e.c >> e.lf);}
00078
00081 inline size_t hash_facet_handle(facet_handle<int> const& h)
00082 { return (8*h.c + h.lf);}
00083
00088 template<class T> class hash;
00089 struct hash<facet_handle<int> > {
00090 public:
00091 typedef facet_handle<int> argument_type;
00092 typedef size_t result_type;
00093
00094
00095
00096
00097 size_t operator()(const facet_handle<int>& h) const
00098 { return (8*h.c + h.lf);}
00099 };
00100
00101 #endif
00102