QGpCoreTools/AbstractNumericalKey.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpCoreTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2009-04-11
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
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 } // namespace QGpCoreTools
00071 
00072 #endif // ABSTRACTNUMERICALKEY_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines