3 //=============================================================================
7 * Inlinable method definitions for non-templatized classes
8 * and template specializations implementing the GOF Command Pattern,
9 * and STL-style functors.
11 * @author Chris Gill <cdgill@cs.wustl.edu>
13 * Based on Command Pattern implementations originally done by
15 * Carlos O'Ryan <coryan@cs.wustl.edu>
16 * Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
17 * Sergio Flores-Gaitan <sergio@cs.wustl.edu>
19 * and on STL-style functor implementations originally done by
20 * Irfan Pyarali <irfan@cs.wustl.edu>
22 //=============================================================================
26 #include "ace/OS_NS_string.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 //////////////////////////////////////////////////////////////
31 // GOF Command Pattern Classes and Template Specializations //
32 //////////////////////////////////////////////////////////////
34 // Default constructor.
37 ACE_Command_Base::ACE_Command_Base ()
41 ////////////////////////////////////////////////////////////
42 // STL-style Functor Classes and Template Specializations //
43 ////////////////////////////////////////////////////////////
45 ACE_INLINE unsigned long
46 ACE_Hash<char>::operator () (char t) const
51 #if defined (ACE_HAS_WCHAR) && ! defined (ACE_LACKS_NATIVE_WCHAR_T)
52 ACE_INLINE unsigned long
53 ACE_Hash<wchar_t>::operator () (wchar_t t) const
57 #endif /* ACE_HAS_WCHAR && ! ACE_LACKS_NATIVE_WCHAR_T */
59 ACE_INLINE unsigned long
60 ACE_Hash<signed char>::operator () (signed char t) const
65 ACE_INLINE unsigned long
66 ACE_Hash<unsigned char>::operator () (unsigned char t) const
71 ACE_INLINE unsigned long
72 ACE_Hash<short>::operator () (short t) const
74 return static_cast<unsigned long> (t);
77 ACE_INLINE unsigned long
78 ACE_Hash<unsigned short>::operator () (unsigned short t) const
80 return static_cast<unsigned long> (t);
83 ACE_INLINE unsigned long
84 ACE_Hash<int>::operator () (int t) const
86 return static_cast<unsigned long> (t);
89 ACE_INLINE unsigned long
90 ACE_Hash<unsigned int>::operator () (unsigned int t) const
92 return static_cast<unsigned long> (t);
95 ACE_INLINE unsigned long
96 ACE_Hash<long>::operator () (long t) const
98 return static_cast<unsigned long> (t);
101 ACE_INLINE unsigned long
102 ACE_Hash<unsigned long>::operator () (unsigned long t) const
107 #if (ACE_SIZEOF_LONG == 8)
108 ACE_INLINE unsigned long
109 ACE_Hash<long long>::operator () (long long t) const
111 return static_cast<unsigned long> (t);
113 #endif /* ACE_SIZEOF_LONG == 8 */
115 #if (ACE_SIZEOF_LONG == 8)
116 ACE_INLINE unsigned long
117 ACE_Hash<unsigned long long>::operator () (unsigned long long t) const
119 return static_cast<unsigned long> (t);
121 #endif /* ACE_SIZEOF_LONG == 8 */
123 // This #if needs to match the one in Functor.h
124 #if (ACE_SIZEOF_LONG < 8)
125 ACE_INLINE unsigned long
126 ACE_Hash<ACE_INT64>::operator () (ACE_INT64 t) const
128 return static_cast<unsigned long> (t);
130 #endif /* ACE_SIZEOF_LONG < 8 */
132 #if (ACE_SIZEOF_LONG < 8)
133 ACE_INLINE unsigned long
134 ACE_Hash<ACE_UINT64>::operator () (const ACE_UINT64 &t) const
136 #if (ACE_SIZEOF_LONG == 4)
137 return ACE_U64_TO_U32 (t);
139 return static_cast<unsigned long> (t);
140 #endif /* ACE_SIZEOF_LONG */
142 #endif /* ACE_SIZEOF_LONG < 8 */
144 ACE_INLINE unsigned long
145 ACE_Hash<const char *>::operator () (const char *t) const
147 return ACE::hash_pjw (t);
150 ACE_INLINE unsigned long
151 ACE_Hash<char *>::operator () (const char *t) const
153 return ACE::hash_pjw (t);
156 ACE_INLINE unsigned long
157 ACE_Hash<void *>::operator () (const void *t) const
159 return static_cast<unsigned long> (reinterpret_cast<uintptr_t> (t));
162 /***********************************************************************/
164 ACE_Equal_To<const char *>::operator () (const char *lhs, const char *rhs) const
166 return !ACE_OS::strcmp (lhs, rhs);
170 ACE_Equal_To<char *>::operator () (const char *lhs, const char *rhs) const
172 return !ACE_OS::strcmp (lhs, rhs);
176 ACE_Equal_To<ACE_UINT16>::operator () (const ACE_UINT16 lhs, const ACE_UINT16 rhs) const
182 ACE_Equal_To<ACE_INT16>::operator () (const ACE_INT16 lhs, const ACE_INT16 rhs) const
188 ACE_Equal_To<ACE_UINT32>::operator () (const ACE_UINT32 lhs, const ACE_UINT32 rhs) const
194 ACE_Equal_To<ACE_INT32>::operator () (const ACE_INT32 lhs, const ACE_INT32 rhs) const
200 ACE_Equal_To<ACE_UINT64>::operator () (const ACE_UINT64 lhs, const ACE_UINT64 rhs) const
205 /****************************************************************************/
207 ACE_Less_Than<const char *>::operator () (const char *lhs, const char *rhs) const
209 return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
213 ACE_Less_Than<char *>::operator () (const char *lhs, const char *rhs) const
215 return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
219 #if defined (ACE_HAS_WCHAR)
221 ACE_INLINE unsigned long
222 ACE_Hash<const wchar_t *>::operator () (const wchar_t *t) const
224 return ACE::hash_pjw (t);
227 ACE_INLINE unsigned long
228 ACE_Hash<wchar_t *>::operator () (const wchar_t *t) const
230 return ACE::hash_pjw (t);
234 ACE_Equal_To<const wchar_t *>::operator () (const wchar_t *lhs,
235 const wchar_t *rhs) const
237 return !ACE_OS::strcmp (lhs, rhs);
241 ACE_Equal_To<wchar_t *>::operator () (const wchar_t *lhs,
242 const wchar_t *rhs) const
244 return !ACE_OS::strcmp (lhs, rhs);
248 ACE_Less_Than<const wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const
250 return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
254 ACE_Less_Than<wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const
256 return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0;
259 #endif // ACE_HAS_WCHAR
261 ACE_END_VERSIONED_NAMESPACE_DECL