Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Functor_T.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Functor_T.h
00006  *
00007  *  $Id: Functor_T.h,v 1.1.1.3 2001/12/04 14:33:01 chad Exp $
00008  *
00009  *   Templatized classes for implementing function objects that are
00010  *   used in various places in ACE.  There are currently two major
00011  *   categories of function objects in ACE: GOF Command Pattern
00012  *   objects, and STL-style functors for comparison of container
00013  *   elements.  The command objects are invoked via an <execute>
00014  *   method, while the STL-style functors are invoked via an
00015  *   <operator()> method.
00016  *
00017  *
00018  *  @author Chris Gill <cdgill@cs.wustl.edu>
00019  *  @author Based on Command Pattern implementations originally done by
00020  *  @author Carlos O'Ryan <coryan@cs.wustl.edu>
00021  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00022  *  @author Sergio Flores-Gaitan <sergio@cs.wustl.edu>
00023  *  @author and on STL-style functor implementations originally done by
00024  *  @author Irfan Pyarali  <irfan@cs.wustl.edu> 
00025  */
00026 //=============================================================================
00027 
00028 
00029 #ifndef ACE_FUNCTOR_T_H
00030 #define ACE_FUNCTOR_T_H
00031 #include "ace/pre.h"
00032 
00033 #include "ace/Functor.h"
00034 
00035 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00036 # pragma once
00037 #endif /* ACE_LACKS_PRAGMA_ONCE */
00038 
00039 ///////////////////////////////////
00040 // GOF Command Pattern Templates //
00041 ///////////////////////////////////
00042 
00043 /**
00044  * @class ACE_Command_Callback
00045  *
00046  * @brief Defines a class template that allows us to invoke a GOF
00047  * command style callback to an object without knowing anything
00048  * about the object except its type.
00049  *
00050  * This class declares an interface to execute operations,
00051  * binding a RECEIVER object with an ACTION.  The RECEIVER knows
00052  * how to implement the operation.  A class can invoke operations
00053  * without knowing anything about it, or how it was implemented.
00054  */
00055 template <class RECEIVER, class ACTION>
00056 class ACE_Command_Callback : public ACE_Command_Base
00057 {
00058 public:
00059   /// Constructor: sets the <receiver_> of the Command to recvr, and the
00060   /// <action_> of the Command to <action>.
00061   ACE_Command_Callback (RECEIVER &recvr, ACTION action);
00062 
00063   /// Virtual destructor.
00064   virtual ~ACE_Command_Callback (void);
00065 
00066   /// Invokes the method <action_> from the object <receiver_>.
00067   virtual int execute (void *arg = 0);
00068 
00069 private:
00070   /// Object where the method resides.
00071   RECEIVER &receiver_;
00072 
00073   /// Method that is going to be invoked.
00074   ACTION action_;
00075 };
00076 
00077 /////////////////////////////////
00078 // STL-style Functor Templates //
00079 /////////////////////////////////
00080 
00081 /**
00082  * @class ACE_Hash
00083  *
00084  * @brief Function object for hashing
00085  */
00086 template <class TYPE>
00087 class ACE_Hash
00088 {
00089 public:
00090   /// Simply calls t.hash ()
00091   u_long operator () (const TYPE &t) const;
00092 };
00093 
00094 /**
00095  * @class ACE_Pointer_Hash
00096  *
00097  * @brief Function object for hashing pointers
00098  */
00099 template <class TYPE>
00100 class ACE_Pointer_Hash
00101 {
00102 public:
00103   /// Simply returns t.
00104   u_long operator () (TYPE t) const;
00105 };
00106 
00107 /**
00108  * @class ACE_Equal_To
00109  *
00110  * @brief Function object for comparing two objects of
00111  * the given type for equality.
00112  */
00113 template <class TYPE>
00114 class ACE_Equal_To
00115 {
00116 public:
00117   /// Simply calls operator==
00118   int operator () (const TYPE &lhs,
00119                    const TYPE &rhs) const;
00120 };
00121 
00122 /**
00123  * @class ACE_Less_Than
00124  *
00125  * @brief Function object for determining whether the first object of
00126  * the given type is less than the second object of the same
00127  * type.
00128  */
00129 template <class TYPE>
00130 class ACE_Less_Than
00131 {
00132 public:
00133   /// Simply calls operator<
00134   int operator () (const TYPE &lhs,
00135                    const TYPE &rhs) const;
00136 };
00137 
00138 #if defined (__ACE_INLINE__)
00139 #include "ace/Functor_T.i"
00140 #endif /* __ACE_INLINE__ */
00141 
00142 
00143 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00144 #include "ace/Functor_T.cpp"
00145 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
00146 
00147 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00148 #pragma implementation ("Functor_T.cpp")
00149 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
00150 
00151 #include "ace/post.h"
00152 #endif /* ACE_FUNCTOR_T_H */

Generated on Mon Jun 16 11:19:44 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002