hash.h

00001 
00002 /* Copyright (c) 2005-2009, 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 EQBASE_HASH_H
00019 #define EQBASE_HASH_H
00020 
00021 #include <eq/base/base.h>
00022 #include <eq/base/refPtr.h>
00023 #include <eq/base/stdExt.h>
00024 
00025 namespace eq
00026 {
00027 namespace base
00028 {
00030     template<class K, class T> class PtrHash 
00031 #ifdef WIN32_VC
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 WIN32_VC
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 >
00062     struct hashRefPtr
00063     {
00064         size_t operator()( RefPtr< T > key ) const
00065         {
00066             return stde::hash< const void* >()( key.get() );
00067         }
00068     };
00069 
00071     template< class K, class T > class RefPtrHash 
00072         : public stde::hash_map< RefPtr< K >, T, hashRefPtr< K > >
00073     {};
00074 #endif
00075 }
00076 
00077 }
00078 #endif // EQBASE_HASH_H
Generated on Mon Aug 10 18:58:39 2009 for Equalizer 0.9 by  doxygen 1.5.8