Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2005-2011, 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 COBASE_HASH_H 00019 #define COBASE_HASH_H 00020 00021 #include <co/base/refPtr.h> 00022 #include <co/base/stdExt.h> 00023 #include <co/base/uuid.h> 00024 00025 namespace co 00026 { 00027 namespace base 00028 { 00030 template<class K, class T> class PtrHash 00031 #ifdef _MSC_VER 00032 : public stde::hash_map< K, T, stde::hash_compare< const void* > > 00033 #else 00034 : public stde::hash_map< K, T, stde::hash< const void* > > 00035 #endif 00036 {}; 00037 00039 #ifdef _MSC_VER 00040 template< typename T > 00041 class hashRefPtr : public stde::hash_compare< RefPtr< T > > 00042 { 00043 public: 00044 size_t operator() ( const RefPtr< T >& key ) const 00045 { 00046 stde::hash_compare< const void* > comp; 00047 return comp( key.get( )); 00048 } 00049 00050 bool operator() ( const RefPtr< T >& k1, const RefPtr< T >& k2 ) const 00051 { 00052 return k1 < k2; 00053 } 00054 }; 00055 00056 template< class K, class T > class RefPtrHash 00057 : public stde::hash_map< RefPtr< K >, T, hashRefPtr< K > > 00058 {}; 00059 00060 #else 00061 template< typename T > struct hashRefPtr 00062 { 00063 size_t operator()( RefPtr< T > key ) const 00064 { 00065 return stde::hash< const void* >()( key.get() ); 00066 } 00067 }; 00068 00070 template< class K, class T > class RefPtrHash 00071 : public stde::hash_map< RefPtr< K >, T, hashRefPtr< K > > 00072 {}; 00073 #endif 00074 00076 template<class T> class UUIDHash : public stde::hash_map<co::base::UUID, T> {}; 00077 00078 } 00079 00080 } 00081 #endif // COBASE_HASH_H