Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef ABSTRACTNUMERICALKEY_H
00029 #define ABSTRACTNUMERICALKEY_H
00030
00031 #include "QGpCoreToolsDLLExport.h"
00032
00033 namespace QGpCoreTools {
00034
00035 class AbstractNumericalCache;
00036
00037 class QGPCORETOOLS_EXPORT AbstractNumericalKey
00038 {
00039 public:
00040 AbstractNumericalKey() {}
00041 virtual ~AbstractNumericalKey() {}
00042
00043 virtual bool operator==(const AbstractNumericalKey& o)=0;
00044 virtual int hash() const=0;
00045 virtual int byteCount() const=0;
00046 virtual AbstractNumericalCache * createCache()=0;
00047
00048 virtual int id() const=0;
00049 static int newId() {return _newId++;}
00050 private:
00051 static int _newId;
00052 };
00053
00054 #define DECLARE_NUMERICALKEY(_KeyClass_) \
00055 public: \
00056 virtual int id() const {return _id;} \
00057 private: \
00058 friend class _KeyClass_##Register; \
00059 static int _id;
00060
00061 #define IMPLEMENT_NUMERICALKEY(_KeyClass_) \
00062 int _KeyClass_::_id=0; \
00063 class _KeyClass_##Register \
00064 { \
00065 public: \
00066 _KeyClass_##Register() {_KeyClass_::_id=AbstractNumericalKey::newId();} \
00067 }; \
00068 _KeyClass_##Register autoRegister##_KeyClass_;
00069
00070 }
00071
00072 #endif // ABSTRACTNUMERICALKEY_H