00001 #ifndef Impala_Basis_Quid_h
00002 #define Impala_Basis_Quid_h
00003
00004 #include <iostream>
00005
00006 namespace Impala
00007 {
00008
00009
00010 typedef unsigned long long Quid;
00011
00012
00013 static const Quid QUID_CLASS_MASK = 0xFF00000000000000LL;
00014 static const int QUID_CLASS_WIDTH = 8;
00015 static const int QUID_CLASS_SHIFT = 56;
00016 static const Quid QUID_SET_MASK = 0x00FF000000000000LL;
00017 static const int QUID_SET_WIDTH = 8;
00018 static const int QUID_SET_SHIFT = 48;
00019 static const Quid QUID_OBJECT_MASK = 0x0000FFFF00000000LL;
00020 static const int QUID_OBJECT_WIDTH = 16;
00021 static const int QUID_OBJECT_SHIFT = 32;
00022 static const Quid QUID_ID_MASK = 0x00000000FFFFFFFFLL;
00023 static const int QUID_ID_WIDTH = 32;
00024 static const int QUID_ID_SHIFT = 0;
00025
00026 inline Quid
00027 MakeQuid(int qClass, int qSet, int qObject, int id)
00028 {
00029 return (((Quid) qClass) << QUID_CLASS_SHIFT) |
00030 (((Quid) qSet) << QUID_SET_SHIFT) |
00031 (((Quid) qObject) << QUID_OBJECT_SHIFT) |
00032 (((Quid) id) << QUID_ID_SHIFT);
00033 }
00034
00035 inline int
00036 QuidClass(Quid q)
00037 {
00038 return (q & QUID_CLASS_MASK) >> QUID_CLASS_SHIFT;
00039 }
00040
00041 inline int
00042 QuidSet(Quid q)
00043 {
00044 return (q & QUID_SET_MASK) >> QUID_SET_SHIFT;
00045 }
00046
00047 inline int
00048 QuidObject(Quid q)
00049 {
00050 return (q & QUID_OBJECT_MASK) >> QUID_OBJECT_SHIFT;
00051 }
00052
00053 inline int
00054 QuidId(Quid q)
00055 {
00056 return (q & QUID_ID_MASK) >> QUID_ID_SHIFT;
00057 }
00058
00059 inline bool
00060 QuidValid(Quid q)
00061 {
00062 return QuidClass(q) != 0;
00063 }
00064
00065
00066
00067 inline bool
00068 QuidClassEqual(Quid q1, Quid q2)
00069 {
00070 return QuidValid(q1) && (QuidClass(q1) == (QuidClass(q2)));
00071 }
00072
00073 inline bool
00074 QuidSetEqual(Quid q1, Quid q2)
00075 {
00076 return QuidValid(q1) && (QuidSet(q1) == (QuidSet(q2)));
00077 }
00078
00079 inline bool
00080 QuidObjectEqual(Quid q1, Quid q2)
00081 {
00082 return QuidValid(q1) && (QuidObject(q1) == (QuidObject(q2)));
00083 }
00084
00085 inline bool
00086 QuidIdEqual(Quid q1, Quid q2)
00087 {
00088 return QuidValid(q1) && (QuidId(q1) == (QuidId(q2)));
00089 }
00090
00091
00092
00093 inline Quid
00094 QuidObjectChange(Quid q, int newObject)
00095 {
00096 return MakeQuid(QuidClass(q), QuidSet(q), newObject, QuidId(q));
00097 }
00098
00099 }
00100
00101 #endif