Functor.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Functor.inl
00006  *
00007  *  $Id: Functor.inl 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  Inlinable method definitions for non-templatized classes
00010  *  and template specializations implementing the GOF Command Pattern,
00011  *  and STL-style functors.
00012  *
00013  *
00014  *  @author Chris Gill           <cdgill@cs.wustl.edu>
00015  *
00016  * Based on Command Pattern implementations originally done by
00017  *
00018  * Carlos O'Ryan        <coryan@cs.wustl.edu>
00019  * Douglas C. Schmidt   <schmidt@cs.wustl.edu>
00020  * Sergio Flores-Gaitan <sergio@cs.wustl.edu>
00021  *
00022  * and on STL-style functor implementations originally done by
00023  * Irfan Pyarali  <irfan@cs.wustl.edu>
00024  */
00025 //=============================================================================
00026 
00027 
00028 #include "ace/ACE.h"
00029 #include "ace/OS_NS_string.h"
00030 
00031 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 //////////////////////////////////////////////////////////////
00034 // GOF Command Pattern Classes and Template Specializations //
00035 //////////////////////////////////////////////////////////////
00036 
00037 // Default constructor.
00038 
00039 ACE_INLINE
00040 ACE_Command_Base::ACE_Command_Base (void)
00041 {
00042 }
00043 
00044 ////////////////////////////////////////////////////////////
00045 // STL-style Functor Classes and Template Specializations //
00046 ////////////////////////////////////////////////////////////
00047 
00048 ACE_INLINE unsigned long
00049 ACE_Hash<char>::operator () (char t) const
00050 {
00051   return t;
00052 }
00053 
00054 #if defined (ACE_HAS_WCHAR) && ! defined (ACE_LACKS_NATIVE_WCHAR_T)
00055 ACE_INLINE unsigned long
00056 ACE_Hash<wchar_t>::operator () (wchar_t t) const
00057 {
00058   return t;
00059 }
00060 #endif /* ACE_HAS_WCHAR && ! ACE_LACKS_NATIVE_WCHAR_T */
00061 
00062 ACE_INLINE unsigned long
00063 ACE_Hash<signed char>::operator () (signed char t) const
00064 {
00065   return t;
00066 }
00067 
00068 ACE_INLINE unsigned long
00069 ACE_Hash<unsigned char>::operator () (unsigned char t) const
00070 {
00071   return t;
00072 }
00073 
00074 #if 0
00075 ACE_INLINE unsigned long
00076 ACE_Hash<ACE_INT16>::operator () (ACE_INT16 t) const
00077 {
00078   return t;
00079 }
00080 
00081 ACE_INLINE unsigned long
00082 ACE_Hash<ACE_UINT16>::operator () (ACE_UINT16 t) const
00083 {
00084   return t;
00085 }
00086 
00087 ACE_INLINE unsigned long
00088 ACE_Hash<ACE_INT32>::operator () (ACE_INT32 t) const
00089 {
00090   return static_cast<unsigned long> (t);
00091 }
00092 
00093 ACE_INLINE unsigned long
00094 ACE_Hash<ACE_UINT32>::operator () (ACE_UINT32 t) const
00095 {
00096   return t;
00097 }
00098 
00099 ACE_INLINE unsigned long
00100 ACE_Hash<ACE_UINT64>::operator () (ACE_UINT64 t) const
00101 {
00102 #if (ACE_SIZEOF_LONG == 4)
00103   return ACE_U64_TO_U32 (t);
00104 #else
00105   return static_cast<unsigned long> (t);
00106 #endif /* ACE_SIZEOF_LONG */
00107 }
00108 #endif
00109 
00110 ACE_INLINE unsigned long
00111 ACE_Hash<short>::operator () (short t) const
00112 {
00113   return static_cast<unsigned long> (t);
00114 }
00115 
00116 ACE_INLINE unsigned long
00117 ACE_Hash<unsigned short>::operator () (unsigned short t) const
00118 {
00119   return static_cast<unsigned long> (t);
00120 }
00121 
00122 ACE_INLINE unsigned long
00123 ACE_Hash<int>::operator () (int t) const
00124 {
00125   return static_cast<unsigned long> (t);
00126 }
00127 
00128 ACE_INLINE unsigned long
00129 ACE_Hash<unsigned int>::operator () (unsigned int t) const
00130 {
00131   return static_cast<unsigned long> (t);
00132 }
00133 
00134 ACE_INLINE unsigned long
00135 ACE_Hash<long>::operator () (long t) const
00136 {
00137   return static_cast<unsigned long> (t);
00138 }
00139 
00140 ACE_INLINE unsigned long
00141 ACE_Hash<unsigned long>::operator () (unsigned long t) const
00142 {
00143   return t;
00144 }
00145 
00146 // This #if needs to match the one in Functor.h
00147 #if !defined (ACE_LACKS_LONGLONG_T) && (ACE_SIZEOF_LONG < 8)
00148 ACE_INLINE unsigned long
00149 ACE_Hash<ACE_INT64>::operator () (ACE_INT64 t) const
00150 {
00151   return static_cast<unsigned long> (t);
00152 }
00153 #endif /* !ACE_LACKS_LONGLONG_T && ACE_SIZEOF_LONG < 8 */
00154 
00155 #if (ACE_SIZEOF_LONG < 8)
00156 ACE_INLINE unsigned long
00157 ACE_Hash<ACE_UINT64>::operator () (const ACE_UINT64 &t) const
00158 {
00159 #if (ACE_SIZEOF_LONG == 4)
00160   return ACE_U64_TO_U32 (t);
00161 #else
00162   return static_cast<unsigned long> (t);
00163 #endif /* ACE_SIZEOF_LONG */
00164 }
00165 #endif /* !ACE_LACKS_UNSIGNEDLONGLONG_T */
00166 
00167 ACE_INLINE unsigned long
00168 ACE_Hash<const char *>::operator () (const char *t) const
00169 {
00170   return ACE::hash_pjw (t);
00171 }
00172 
00173 ACE_INLINE unsigned long
00174 ACE_Hash<char *>::operator () (const char *t) const
00175 {
00176   return ACE::hash_pjw (t);
00177 }
00178 
00179 ACE_INLINE unsigned long
00180 ACE_Hash<void *>::operator () (const void *t) const
00181 {
00182   return static_cast<unsigned long> (reinterpret_cast<uintptr_t> (t));
00183 }
00184 
00185 /***********************************************************************/
00186 ACE_INLINE int
00187 ACE_Equal_To<const char *>::operator () (const char *lhs, const char *rhs) const
00188 {
00189   return !ACE_OS::strcmp (lhs, rhs);
00190 }
00191 
00192 ACE_INLINE int
00193 ACE_Equal_To<char *>::operator () (const char *lhs, const char *rhs) const
00194 {
00195   return !ACE_OS::strcmp (lhs, rhs);
00196 }
00197 
00198 ACE_INLINE int
00199 ACE_Equal_To<ACE_UINT16>::operator () (const ACE_UINT16 lhs, const ACE_UINT16 rhs) const
00200 {
00201   return (lhs == rhs);
00202 }
00203 
00204 ACE_INLINE int
00205 ACE_Equal_To<ACE_INT16>::operator () (const ACE_INT16 lhs, const ACE_INT16 rhs) const
00206 {
00207   return (lhs == rhs);
00208 }
00209 
00210 ACE_INLINE int
00211 ACE_Equal_To<ACE_UINT32>::operator () (const ACE_UINT32 lhs, const ACE_UINT32 rhs) const
00212 {
00213   return (lhs == rhs);
00214 }
00215 
00216 ACE_INLINE int
00217 ACE_Equal_To<ACE_INT32>::operator () (const ACE_INT32 lhs, const ACE_INT32 rhs) const
00218 {
00219   return (lhs == rhs);
00220 }
00221 
00222 ACE_INLINE int
00223 ACE_Equal_To<ACE_UINT64>::operator () (const ACE_UINT64 lhs, const ACE_UINT64 rhs) const
00224 {
00225   return (lhs == rhs);
00226 }
00227 
00228 /****************************************************************************/
00229 ACE_INLINE int
00230 ACE_Less_Than<const char *>::operator () (const char *lhs, const char *rhs) const
00231 {
00232   return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
00233 }
00234 
00235 ACE_INLINE int
00236 ACE_Less_Than<char *>::operator () (const char *lhs, const char *rhs) const
00237 {
00238   return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
00239 }
00240 
00241 
00242 #if defined (ACE_HAS_WCHAR)
00243 
00244 ACE_INLINE unsigned long
00245 ACE_Hash<const wchar_t *>::operator () (const wchar_t *t) const
00246 {
00247   return ACE::hash_pjw (t);
00248 }
00249 
00250 ACE_INLINE unsigned long
00251 ACE_Hash<wchar_t *>::operator () (const wchar_t *t) const
00252 {
00253   return ACE::hash_pjw (t);
00254 }
00255 
00256 ACE_INLINE int
00257 ACE_Equal_To<const wchar_t *>::operator () (const wchar_t *lhs,
00258                                             const wchar_t *rhs) const
00259 {
00260   return !ACE_OS::strcmp (lhs, rhs);
00261 }
00262 
00263 ACE_INLINE int
00264 ACE_Equal_To<wchar_t *>::operator () (const wchar_t *lhs,
00265                                       const wchar_t *rhs) const
00266 {
00267   return !ACE_OS::strcmp (lhs, rhs);
00268 }
00269 
00270 ACE_INLINE int
00271 ACE_Less_Than<const wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const
00272 {
00273   return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
00274 }
00275 
00276 ACE_INLINE int
00277 ACE_Less_Than<wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const
00278 {
00279   return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
00280 }
00281 
00282 #endif  // ACE_HAS_WCHAR
00283 
00284 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:18:39 2010 for ACE by  doxygen 1.4.7