[6916] Fixed typos in spell checking code.
[getmangos.git] / dep / ACE_wrappers / ace / Functor.h
blob8504cf0764beb8d3da87f99842c6d4b3357b7054
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Functor.h
7 * $Id: Functor.h 80826 2008-03-04 14:51:23Z wotte $
9 * Non-templatized classes and class template specializations for
10 * implementing function objects that are used in various places
11 * in ACE. There are currently two major categories of function
12 * objects in ACE: GoF Command Pattern objects, and STL-style
13 * functors for comparison of container elements. The command objects
14 * are invoked via an execute () method, while the STL-style functors are
15 * invoked via an operator() () method.
16 * Non-templatized classes for implementing the GoF Command Pattern,
17 * also known as functors or function objects.
20 * @author Chris Gill <cdgill@cs.wustl.edu>
21 * @author Based on Command Pattern implementations originally done by
22 * @author Carlos O'Ryan <coryan@cs.wustl.edu>
23 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
24 * @author Sergio Flores-Gaitan <sergio@cs.wustl.edu>
25 * @author and on STL-style functor implementations originally done by
26 * @author Irfan Pyarali <irfan@cs.wustl.edu>
28 //==========================================================================
31 #ifndef ACE_FUNCTOR_H
32 #define ACE_FUNCTOR_H
33 #include /**/ "ace/pre.h"
35 #include /**/ "ace/config-all.h"
37 #if !defined (ACE_LACKS_PRAGMA_ONCE)
38 # pragma once
39 #endif /* ACE_LACKS_PRAGMA_ONCE */
41 #include /**/ "ace/ACE_export.h"
42 #include "ace/Basic_Types.h"
44 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
46 //////////////////////////////////////////////////////////////
47 // GOF Command Pattern Classes and Template Specializations //
48 //////////////////////////////////////////////////////////////
50 /**
51 * @class ACE_Command_Base
53 * @brief Defines an abstract class that allows us to invoke commands
54 * without knowing anything about the implementation.
56 * This class declares an interface to execute a command
57 * independent of the effect of the command, or the objects used
58 * to implement it.
60 class ACE_Export ACE_Command_Base
62 public:
63 // = Initialization and termination methods.
64 /// Default constructor.
65 ACE_Command_Base (void);
67 /// Virtual destructor.
68 virtual ~ACE_Command_Base (void);
70 /**
71 * Invokes the method encapsulated by the command, passing along the
72 * passed argument (if any). Users of classes derived from this
73 * class must ensure that the resulting invocation can tolerate a
74 * null void pointer being passed, or otherwise ensure that this
75 * will never occur.
77 virtual int execute (void *arg = 0) = 0;
80 ////////////////////////////////////////////////////////////
81 // STL-style Functor Classes and Template Specializations //
82 ////////////////////////////////////////////////////////////
84 // Forward declaration since we are going to specialize that template
85 // here. The template itself requires this file so every user of the
86 // template should also see the specialization.
87 template <class TYPE> class ACE_Hash;
88 template <class TYPE> class ACE_Equal_To;
89 template <class TYPE> class ACE_Less_Than;
91 /**
92 * @class ACE_Hash<char>
94 * @brief Function object for hashing a char
96 template<>
97 class ACE_Export ACE_Hash<char>
99 public:
100 /// Simply returns t
101 unsigned long operator () (char t) const;
105 * @class ACE_Hash<signed char>
107 * @brief Function object for hashing a signed char
109 template<>
110 class ACE_Export ACE_Hash<signed char>
112 public:
113 /// Simply returns t
114 unsigned long operator () (signed char t) const;
118 * @class ACE_Hash<unsigned char>
120 * @brief Function object for hashing an unsigned char
122 template<>
123 class ACE_Export ACE_Hash<unsigned char>
125 public:
126 /// Simply returns t
127 unsigned long operator () (unsigned char t) const;
130 #if 0
131 // @@ ADD HASHES FOR ACE TYPES
134 * @class ACE_Hash<ACE_INT16>
136 * @brief Function object for hashing a 16-bit signed number
138 template<>
139 class ACE_Export ACE_Hash<ACE_INT16>
141 public:
142 /// Simply returns t
143 unsigned long operator () (ACE_INT16 t) const;
147 * @class ACE_Hash<ACE_UINT16>
149 * @brief Function object for hashing a 16-bit unsigned number
151 template<>
152 class ACE_Export ACE_Hash<ACE_UINT16>
154 public:
155 /// Simply returns t
156 unsigned long operator () (ACE_UINT16 t) const;
160 * @class ACE_Hash<ACE_INT32>
162 * @brief Function object for hashing a 32-bit signed number
164 template<>
165 class ACE_Export ACE_Hash<ACE_INT32>
167 public:
168 /// Simply returns t
169 unsigned long operator () (ACE_INT32 t) const;
173 * @class ACE_Hash<ACE_UINT32>
175 * @brief Function object for hashing a 32-bit unsigned number
177 template<>
178 class ACE_Export ACE_Hash<ACE_UINT32>
180 public:
181 /// Simply returns t
182 unsigned long operator () (ACE_UINT32 t) const;
186 * @class ACE_Hash<ACE_UINT64>
188 * @brief Function object for hashing a 64-bit unsigned number
190 template<>
191 class ACE_Export ACE_Hash<ACE_UINT64>
193 public:
194 /// Simply returns t
195 unsigned long operator () (ACE_UINT64 t) const;
198 // @@ DONE ADDING HASHES FOR ACE TYPES
199 #endif
202 * @class ACE_Hash<short>
204 * @brief Function object for hashing a short number
206 template<>
207 class ACE_Export ACE_Hash<short>
209 public:
210 /// Simply returns t
211 unsigned long operator () (short t) const;
215 * @class ACE_Hash<unsigned short>
217 * @brief Function object for hashing an unsigned short number
219 template<>
220 class ACE_Export ACE_Hash<unsigned short>
222 public:
223 /// Simply returns t
224 unsigned long operator () (unsigned short t) const;
228 * @class ACE_Hash<int>
230 * @brief Function object for hashing an int number
232 template<>
233 class ACE_Export ACE_Hash<int>
235 public:
236 /// Simply returns t
237 unsigned long operator () (int t) const;
241 * @class ACE_Hash<unsigned int>
243 * @brief Function object for hashing an unsigned int number
245 template<>
246 class ACE_Export ACE_Hash<unsigned int>
248 public:
249 /// Simply returns t
250 unsigned long operator () (unsigned int t) const;
254 * @class ACE_Hash<long>
256 * @brief Function object for hashing a long number
258 template<>
259 class ACE_Export ACE_Hash<long>
261 public:
262 /// Simply returns t
263 unsigned long operator () (long t) const;
267 * @class ACE_Hash<unsigned long>
269 * @brief Function object for hashing an unsigned long number
271 template<>
272 class ACE_Export ACE_Hash<unsigned long>
274 public:
275 /// Simply returns t
276 unsigned long operator () (unsigned long t) const;
279 #if !defined (ACE_LACKS_LONGLONG_T) && (ACE_SIZEOF_LONG < 8)
281 * @class ACE_Hash<ACE_INT64>
283 * @brief Function object for hashing a signed 64-bit number
285 template<>
286 class ACE_Export ACE_Hash<ACE_INT64>
288 public:
289 /// Simply returns t
290 unsigned long operator () (ACE_INT64 t) const;
292 #endif /* !ACE_LACKS_LONGLONG_T && ACE_SIZEOF_LONG < 8 */
294 // We can do this even if ACE_LACKS_UNSIGNEDLONGLONG_T because there's an
295 // emulation for it in ACE_U_LongLong.
296 #if (ACE_SIZEOF_LONG < 8)
298 * @class ACE_Hash<ACE_UINT64>
300 * @brief Function object for hashing an unsigned 64-bit number
302 template<>
303 class ACE_Export ACE_Hash<ACE_UINT64>
305 public:
306 /// Simply returns t
307 unsigned long operator () (const ACE_UINT64 &t) const;
309 #endif /* ACE_SIZEOF_LONG < 8 */
312 * @class ACE_Hash<const char *>
314 * @brief Function object for hashing a const string
316 template<>
317 class ACE_Export ACE_Hash<const char *>
319 public:
320 /// Calls ACE::hash_pjw
321 unsigned long operator () (const char *t) const;
325 * @class ACE_Hash<char *>
327 * @brief Function object for hashing a string
329 template<>
330 class ACE_Export ACE_Hash<char *>
332 public:
333 /// Calls ACE::hash_pjw
334 unsigned long operator () (const char *t) const;
338 * @class ACE_Hash<void *>
340 * @brief Function object for hashing a void *
342 template<>
343 class ACE_Export ACE_Hash<void *>
345 public:
346 unsigned long operator () (const void *) const;
350 * @class ACE_Equal_To<const char *>
352 * @brief Function object for determining whether two const strings are equal.
354 template<>
355 class ACE_Export ACE_Equal_To<const char *>
357 public:
358 /// Simply calls ACE_OS::strcmp
359 int operator () (const char *lhs,
360 const char *rhs) const;
364 * @class ACE_Equal_To<char *>
366 * @brief Function object for determining whether two non-const
367 * strings are equal.
369 template<>
370 class ACE_Export ACE_Equal_To<char *>
372 public:
373 /// Simply calls ACE_OS::strcmp
374 int operator () (const char *lhs,
375 const char *rhs) const;
379 * @class ACE_Equal_To<ACE_UINT16>
381 * @brief Function object for determining whether two unsigned
382 * 16 bit ints are equal.
384 template<>
385 class ACE_Export ACE_Equal_To<ACE_UINT16>
387 public:
388 /// Simply calls built-in operators
389 int operator () (const ACE_UINT16 lhs,
390 const ACE_UINT16 rhs) const;
394 * @class ACE_Equal_To<ACE_INT16>
396 * @brief Function object for determining whether two
397 * 16 bit ints are equal.
399 template<>
400 class ACE_Export ACE_Equal_To<ACE_INT16>
402 public:
403 /// Simply calls built-in operators
404 int operator () (const ACE_INT16 lhs,
405 const ACE_INT16 rhs) const;
409 * @class ACE_Equal_To<ACE_UINT32>
411 * @brief Function object for determining whether two unsigned
412 * 32 bit ints are equal.
414 template<>
415 class ACE_Export ACE_Equal_To<ACE_UINT32>
417 public:
418 /// Simply calls built-in operators
419 int operator () (const ACE_UINT32 lhs,
420 const ACE_UINT32 rhs) const;
424 * @class ACE_Equal_To<ACE_INT32>
426 * @brief Function object for determining whether two
427 * 32 bit ints are equal.
429 template<>
430 class ACE_Export ACE_Equal_To<ACE_INT32>
432 public:
433 /// Simply calls built-in operators
434 int operator () (const ACE_INT32 lhs,
435 const ACE_INT32 rhs) const;
439 * @class ACE_Equal_To<ACE_UINT64>
441 * @brief Function object for determining whether two unsigned
442 * 64 bit ints are equal.
444 template<>
445 class ACE_Export ACE_Equal_To<ACE_UINT64>
447 public:
448 /// Simply calls built-in operators
449 int operator () (const ACE_UINT64 lhs,
450 const ACE_UINT64 rhs) const;
454 * @class ACE_Less_Than<const char*>
456 * @brief Function object for determining whether the first const string
457 * is less than the second const string.
459 template<>
460 class ACE_Export ACE_Less_Than<const char *>
462 public:
463 /// Simply calls ACE_OS::strcmp
464 int operator () (const char *lhs,
465 const char *rhs) const;
469 * @class ACE_Less_Than<char *>
471 * @brief Function object for determining whether the first string
472 * is less than the second string.
474 template<>
475 class ACE_Export ACE_Less_Than<char *>
477 public:
478 /// Simply calls ACE_OS::strcmp
479 int operator () (const char *lhs,
480 const char *rhs) const;
483 #if defined (ACE_HAS_WCHAR)
485 # if ! defined (ACE_LACKS_NATIVE_WCHAR_T)
487 * @class ACE_Hash<wchar_t>
489 * @brief Function object for hashing a wchar_t
491 template<>
492 class ACE_Export ACE_Hash<wchar_t>
494 public:
495 /// Simply returns t
496 unsigned long operator () (wchar_t t) const;
498 # endif /* ACE_LACKS_NATIVE_WCHAR_T */
500 * @class ACE_Hash<const wchar_t *>
502 * @brief Function object for hashing a const string
504 template<>
505 class ACE_Export ACE_Hash<const wchar_t *>
507 public:
508 /// Calls ACE::hash_pjw
509 unsigned long operator () (const wchar_t *t) const;
513 * @class ACE_Hash<wchar_t *>
515 * @brief Function object for hashing a string
517 template<>
518 class ACE_Export ACE_Hash<wchar_t *>
520 public:
521 /// Calls ACE::hash_pjw
522 unsigned long operator () (const wchar_t *t) const;
526 * @class ACE_Equal_To<const wchar_t *>
528 * @brief Function object for determining whether two const strings are equal.
530 template<>
531 class ACE_Export ACE_Equal_To<const wchar_t *>
533 public:
534 /// Simply calls ACE_OS::strcmp
535 int operator () (const wchar_t *lhs,
536 const wchar_t *rhs) const;
540 * @class ACE_Equal_To<wchar_t *>
542 * @brief Function object for determining whether two non-const
543 * strings are equal.
545 template<>
546 class ACE_Export ACE_Equal_To<wchar_t *>
548 public:
549 /// Simply calls ACE_OS::strcmp
550 int operator () (const wchar_t *lhs,
551 const wchar_t *rhs) const;
555 * @class ACE_Less_Than<const wchar_t *>
557 * @brief Function object for determining whether the first const string
558 * is less than the second const string.
560 template<>
561 class ACE_Export ACE_Less_Than<const wchar_t *>
563 public:
564 /// Simply calls ACE_OS::strcmp
565 int operator () (const wchar_t *lhs,
566 const wchar_t *rhs) const;
570 * @class ACE_Less_Than<wchar_t *>
572 * @brief Function object for determining whether the first string
573 * is less than the second string.
575 template<>
576 class ACE_Export ACE_Less_Than<wchar_t *>
578 public:
579 /// Simply calls ACE_OS::strcmp
580 int operator () (const wchar_t *lhs,
581 const wchar_t *rhs) const;
584 #endif // ACE_HAS_WCHAR
586 ACE_END_VERSIONED_NAMESPACE_DECL
588 #if defined (__ACE_INLINE__)
589 #include "ace/Functor.inl"
590 #endif /* __ACE_INLINE__ */
592 #include /**/ "ace/post.h"
593 #endif /* ACE_FUNCTOR_H */