Functor.inl

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

Generated on Thu Nov 9 09:41:51 2006 for ACE by doxygen 1.3.6