Lunchbox
1.4.0
|
00001 00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 00004 * This library is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU Lesser General Public License version 2.1 as published 00006 * by the Free Software Foundation. 00007 * 00008 * This library is distributed in the hope that it will be useful, but WITHOUT 00009 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00010 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00011 * details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this library; if not, write to the Free Software Foundation, Inc., 00015 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00016 */ 00017 00018 #ifndef LUNCHBOX_HASH_H 00019 #define LUNCHBOX_HASH_H 00020 00021 #include <lunchbox/refPtr.h> 00022 #include <lunchbox/stdExt.h> 00023 00024 namespace lunchbox 00025 { 00027 template<class K, class T> class PtrHash 00028 #ifdef _MSC_VER 00029 : public stde::hash_map< K, T, stde::hash_compare< const void* > > 00030 #else 00031 : public stde::hash_map< K, T, stde::hash< const void* > > 00032 #endif 00033 {}; 00034 00036 #ifdef _MSC_VER 00037 template< typename T > 00038 class hashRefPtr : public stde::hash_compare< RefPtr< T > > 00039 { 00040 public: 00041 size_t operator() ( const RefPtr< T >& key ) const 00042 { 00043 stde::hash_compare< const void* > comp; 00044 return comp( key.get( )); 00045 } 00046 00047 bool operator() ( const RefPtr< T >& k1, const RefPtr< T >& k2 ) const 00048 { 00049 return k1 < k2; 00050 } 00051 }; 00052 00053 template< class K, class T > class RefPtrHash 00054 : public stde::hash_map< RefPtr< K >, T, hashRefPtr< K > > 00055 {}; 00056 00057 #else 00058 template< typename T > struct hashRefPtr 00059 { 00060 size_t operator()( RefPtr< T > key ) const 00061 { 00062 return stde::hash< const void* >()( key.get() ); 00063 } 00064 }; 00065 00067 template< class K, class T > class RefPtrHash 00068 : public stde::hash_map< RefPtr< K >, T, hashRefPtr< K > > 00069 {}; 00070 #endif 00071 00073 template<class T> class UUIDHash : public stde::hash_map<lunchbox::UUID, T> {}; 00074 00075 } 00076 #endif // LUNCHBOX_HASH_H