reSIProcate/rutil  9694
HashMap.hxx
Go to the documentation of this file.
00001 #if !defined(RESIP_HASHMAP_HXX)
00002 #define RESIP_HASHMAP_HXX 
00003 
00004 // !cj! if all these machine have to use map then we can just delete them and use the default 
00005 
00014 #  if ( (__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) ) || ( __GNUC__ > 4 )
00015 #    include <tr1/unordered_map>
00016 #    include <tr1/unordered_set>
00017 #    define HASH_MAP_NAMESPACE std::tr1
00018 #    define HashMap std::tr1::unordered_map
00019 #    define HashSet std::tr1::unordered_set
00020 #    define HashMultiMap std::tr1::unordered_multimap
00021 
00022 #define HashValue(type)                           \
00023 namespace std                                     \
00024 {                                                 \
00025 namespace tr1                                     \
00026 {                                                 \
00027 template <>                                       \
00028 struct hash<type>                                 \
00029 {                                                 \
00030       size_t operator()(const type& data) const;  \
00031 };                                                \
00032 }                                                 \
00033 }
00034 #define HashValueImp(type, ret) size_t HASH_MAP_NAMESPACE::hash<type>::operator()(const type& data) const { return ret; }
00035 
00036 #  elif ( (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1) ) || ( __GNUC__ > 3 )
00037 #    include <ext/hash_map>
00038 #    include <ext/hash_set>
00039 #    define HASH_MAP_NAMESPACE __gnu_cxx
00040 #    define HashMap __gnu_cxx::hash_map
00041 #    define HashSet __gnu_cxx::hash_set
00042 #    define HashMultiMap __gnu_cxx::hash_multimap
00043 // this allows us to hash on a pointer as the key 
00044 namespace HASH_MAP_NAMESPACE
00045 {
00049 template <class T>
00050 struct hash<T*>
00051 {
00052       size_t operator()(const T* t) const
00053       {
00054          return size_t(t);
00055       }
00056 };
00057  
00058 }
00059 
00060 #define HashValue(type)                           \
00061 namespace HASH_MAP_NAMESPACE                      \
00062 {                                                 \
00063 template <>                                       \
00064 struct hash<type>                                 \
00065 {                                                 \
00066       size_t operator()(const type& data) const;  \
00067 };                                                \
00068 }                                   
00069 #define HashValueImp(type, ret) size_t HASH_MAP_NAMESPACE::hash<type>::operator()(const type& data) const { return ret; }
00070 
00071 #  elif  defined(__INTEL_COMPILER )
00072 #    include <hash_map>
00073 #    define HASH_MAP_NAMESPACE std
00074 #    define HashMap std::hash_map
00075 #    define HashSet std::hash_set
00076 #    define HashMultiMap std::hash_multimap
00077 #    define HashValue(type)              \
00078      namespace HASH_MAP_NAMESPACE        \
00079      {                                   \
00080      size_t hash_value(const type& data);\
00081      }                                   
00082 #    define HashValueImp(type, ret) size_t HASH_MAP_NAMESPACE::hash_value(const type& data) { return ret; }
00083 #  elif  defined(WIN32) && defined(_MSC_VER) && (_MSC_VER >= 1310)  // hash_map is in stdext namespace for VS.NET 2003
00084 #    include <hash_map>
00085 #    include <hash_set>
00086 #    define HASH_MAP_NAMESPACE stdext
00087 #    define HashMap stdext::hash_map
00088 #    define HashSet stdext::hash_set
00089 #    define HashMultiMap stdext::hash_multimap
00090 #    define HashValue(type)              \
00091      namespace HASH_MAP_NAMESPACE        \
00092      {                                   \
00093      size_t hash_value(const type& data);\
00094      }                                   
00095 #    define HashValueImp(type, ret) size_t HASH_MAP_NAMESPACE::hash_value(const type& data) { return ret; }
00096 #  else
00097 #    include <map>
00098 #    define HashMap std::map
00099 #    define HashSet std::set
00100 #    define HashMultiMap std::multimap
00101 #    define HashValue(type)    
00102 #    define HashValueImp(type, ret) 
00103 #  endif
00104 
00105 #endif
00106 
00107 /* ====================================================================
00108  * The Vovida Software License, Version 1.0 
00109  * 
00110  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00111  * 
00112  * Redistribution and use in source and binary forms, with or without
00113  * modification, are permitted provided that the following conditions
00114  * are met:
00115  * 
00116  * 1. Redistributions of source code must retain the above copyright
00117  *    notice, this list of conditions and the following disclaimer.
00118  * 
00119  * 2. Redistributions in binary form must reproduce the above copyright
00120  *    notice, this list of conditions and the following disclaimer in
00121  *    the documentation and/or other materials provided with the
00122  *    distribution.
00123  * 
00124  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00125  *    and "Vovida Open Communication Application Library (VOCAL)" must
00126  *    not be used to endorse or promote products derived from this
00127  *    software without prior written permission. For written
00128  *    permission, please contact vocal@vovida.org.
00129  *
00130  * 4. Products derived from this software may not be called "VOCAL", nor
00131  *    may "VOCAL" appear in their name, without prior written
00132  *    permission of Vovida Networks, Inc.
00133  * 
00134  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00135  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00136  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00137  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00138  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00139  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00140  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00141  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00142  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00143  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00145  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00146  * DAMAGE.
00147  * 
00148  * ====================================================================
00149  * 
00150  * This software consists of voluntary contributions made by Vovida
00151  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00152  * Inc.  For more information on Vovida Networks, Inc., please see
00153  * <http://www.vovida.org/>.
00154  *
00155  */