diff options
author | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-12-30 19:31:23 +0000 |
---|---|---|
committer | cdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-12-30 19:31:23 +0000 |
commit | 787f8122255799dec288f230e9590e36f603298a (patch) | |
tree | 27e685bf77df1116adeba51ebdd3c3c2cbbe6a8f /ace | |
parent | 05ed3507e1b04a46534ed03c6c51aec23fe31450 (diff) | |
download | ATCD-787f8122255799dec288f230e9590e36f603298a.tar.gz |
Functor, RB_Tree, and pSOS fixes
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Functor.cpp | 8 | ||||
-rw-r--r-- | ace/Functor.h | 303 | ||||
-rw-r--r-- | ace/Functor.i | 191 | ||||
-rw-r--r-- | ace/Functor_T.cpp | 12 | ||||
-rw-r--r-- | ace/Functor_T.h | 156 | ||||
-rw-r--r-- | ace/Functor_T.i | 34 | ||||
-rw-r--r-- | ace/Hash_Map_Manager.h | 209 | ||||
-rw-r--r-- | ace/Hash_Map_Manager.i | 133 | ||||
-rw-r--r-- | ace/Hash_Map_Manager_T.h | 26 | ||||
-rw-r--r-- | ace/Hash_Map_Manager_T.i | 13 | ||||
-rw-r--r-- | ace/OS.h | 8 | ||||
-rw-r--r-- | ace/RB_Tree.cpp | 130 | ||||
-rw-r--r-- | ace/RB_Tree.h | 33 | ||||
-rw-r--r-- | ace/RB_Tree.i | 44 | ||||
-rw-r--r-- | ace/config-psos-diab.h | 8 |
15 files changed, 666 insertions, 642 deletions
diff --git a/ace/Functor.cpp b/ace/Functor.cpp index 625a8ff578f..9cab490320f 100644 --- a/ace/Functor.cpp +++ b/ace/Functor.cpp @@ -11,8 +11,8 @@ // // = DESCRIPTION // Non-inlinable method definitions for non-templatized classes -// implementing the GOF Command Pattern, also known as functors -// or function objects. +// and template specializations implementing the GOF Command Pattern, +// and STL-style functors. // // = AUTHOR // Chris Gill <cdgill@cs.wustl.edu> @@ -23,6 +23,10 @@ // Douglas C. Schmidt <schmidt@cs.wustl.edu> and // Sergio Flores-Gaitan <sergio@cs.wustl.edu> // +// and on STL-style functor implementations originally done by +// +// Irfan Pyarali <irfan@cs.wustl.edu> +// // ============================================================================ #if !defined (ACE_FUNCTOR_C) diff --git a/ace/Functor.h b/ace/Functor.h index 40f58dbca53..55b42143e9b 100644 --- a/ace/Functor.h +++ b/ace/Functor.h @@ -10,6 +10,13 @@ // Functor.h // // = DESCRIPTION +// Non-templatized classes and class template specializations for +// implementing function objects that are used in various places +// in ACE. There are currently two major categories of function +// objects in ACE: GOF Command Pattern objects, and STL-style +// functors for comparison of container elements. The command objects +// are invoked via an execute () method, while the STL-style functors are +// invoked via an operator() () method. // Non-templatized classes for implementing the GOF Command Pattern, // also known as functors or function objects. // @@ -22,6 +29,10 @@ // Douglas C. Schmidt <schmidt@cs.wustl.edu> and // Sergio Flores-Gaitan <sergio@cs.wustl.edu> // +// and on STL-style functor implementations originally done by +// +// Irfan Pyarali <irfan@cs.wustl.edu> +// // ============================================================================ #ifndef ACE_FUNCTOR_H @@ -33,6 +44,10 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +////////////////////////////////////////////////////////////// +// GOF Command Pattern Classes and Template Specializations // +////////////////////////////////////////////////////////////// + class ACE_Export ACE_Command_Base { // = TITLE @@ -59,6 +74,294 @@ public: // will never occur. }; +//////////////////////////////////////////////////////////// +// STL-style Functor Classes and Template Specializations // +//////////////////////////////////////////////////////////// + +// Forward declaration since we are going to specialize that template +// here. The template itself requires this file so every user of the +// template should also see the specialization. +template <class TYPE> class ACE_Hash; +template <class TYPE> class ACE_Equal_To; +template <class TYPE> class ACE_Less_Than; + +class ACE_Export ACE_Hash<char> +{ + // = TITLE + // Function object for hashing a char +public: + u_long operator () (char t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<signed char> +{ + // = TITLE + // Function object for hashing a signed char +public: + u_long operator () (signed char t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<unsigned char> +{ + // = TITLE + // Function object for hashing an unsigned char +public: + u_long operator () (unsigned char t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<short> +{ + // = TITLE + // Function object for hashing a short +public: + u_long operator () (short t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<unsigned short> +{ + // = TITLE + // Function object for hashing an unsigned short +public: + u_long operator () (unsigned short t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<int> +{ + // = TITLE + // Function object for hashing an int +public: + u_long operator () (int t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<unsigned int> +{ + // = TITLE + // Function object for hashing an unsigned int +public: + u_long operator () (unsigned int t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<long> +{ + // = TITLE + // Function object for hashing a long +public: + u_long operator () (long t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<unsigned long> +{ + // = TITLE + // Function object for hashing an unsigned long +public: + u_long operator () (unsigned long t) const; + // Simply returns t +}; + +class ACE_Export ACE_Hash<const char *> +{ + // = TITLE + // Function object for hashing a const string +public: + u_long operator () (const char *t) const; + // Calls ACE::hash_pjw +}; + +class ACE_Export ACE_Hash<char *> +{ + // = TITLE + // Function object for hashing a string +public: + u_long operator () (const char *t) const; + // Calls ACE::hash_pjw +}; + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) +class ACE_Export ACE_Hash<const wchar_t *> +{ + // = TITLE + // Function object for hashing a const wide string +public: + u_long operator () (const wchar_t *t) const; + // Calls ACE::hash_pjw +}; + +class ACE_Export ACE_Hash<wchar_t *> +{ + // = TITLE + // Function object for hashing a wide string +public: + u_long operator () (const wchar_t *t) const; + // Calls ACE::hash_pjw +}; +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) +class ACE_Export ACE_Hash<const ACE_USHORT16 *> +{ + // = TITLE + // Function object for hashing a const wide string +public: + u_long operator () (const ACE_USHORT16 *t) const; + // Calls ACE::hash_pjw +}; + +class ACE_Export ACE_Hash<ACE_USHORT16 *> +{ + // = TITLE + // Function object for hashing a wide string +public: + u_long operator () (const ACE_USHORT16 *t) const; + // Calls ACE::hash_pjw +}; +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ + +class ACE_Export ACE_Equal_To<const char *> +{ + // = TITLE + // Function object for determining whether two const strings are equal. +public: + int operator () (const char *lhs, + const char *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +class ACE_Export ACE_Equal_To<char *> +{ + // = TITLE + // Function object for determining whether two non-const + // strings are equal. +public: + int operator () (const char *lhs, + const char *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) +class ACE_Export ACE_Equal_To<const wchar_t *> +{ + // = TITLE + // Function object for determining whether two const wide + // strings are equal. +public: + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +class ACE_Export ACE_Equal_To<wchar_t *> +{ + // = TITLE + // Function object for determining whether two wide strings are equal. +public: + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; + // Simply calls ACE_OS::strcmp +}; +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) +class ACE_Export ACE_Equal_To<const ACE_USHORT16 *> +{ + // = TITLE + // Function object for determining whether two const wide + // strings are equal. +public: + int operator () (const ACE_USHORT16 *lhs, + const ACE_USHORT16 *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +class ACE_Export ACE_Equal_To<ACE_USHORT16 *> +{ + // = TITLE + // Function object for determining whether two wide strings are equal. +public: + int operator () (const ACE_USHORT16 *lhs, + const ACE_USHORT16 *rhs) const; + // Simply calls ACE_OS::strcmp +}; +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ + + +class ACE_Export ACE_Less_Than<const char *> +{ + // = TITLE + // Function object for determining whether the first const string + // is less than the second const string. +public: + int operator () (const char *lhs, + const char *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +class ACE_Export ACE_Less_Than<char *> +{ + // = TITLE + // Function object for determining whether the first string + // is less than the second string. +public: + int operator () (const char *lhs, + const char *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) +class ACE_Export ACE_Less_Than<const wchar_t *> +{ + // = TITLE + // Function object for determining whether the first const wide string + // is less than the second const wide string. +public: + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +class ACE_Export ACE_Less_Than<wchar_t *> +{ + // = TITLE + // Function object for determining whether the first wide string + // is less than the second wide string. +public: + int operator () (const wchar_t *lhs, + const wchar_t *rhs) const; + // Simply calls ACE_OS::strcmp +}; +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) +class ACE_Export ACE_Less_Than<const ACE_USHORT16 *> +{ + // = TITLE + // Function object for determining whether the first const wide string + // is less than the second const wide string. +public: + int operator () (const ACE_USHORT16 *lhs, + const ACE_USHORT16 *rhs) const; + // Simply calls ACE_OS::strcmp +}; + +class ACE_Export ACE_Less_Than<ACE_USHORT16 *> +{ + // = TITLE + // Function object for determining whether the first wide string + // is less than the second wide string. +public: + int operator () (const ACE_USHORT16 *lhs, + const ACE_USHORT16 *rhs) const; + // Simply calls ACE_OS::strcmp +}; +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ + #if defined (__ACE_INLINE__) #include "ace/Functor.i" #endif /* __ACE_INLINE__ */ diff --git a/ace/Functor.i b/ace/Functor.i index 1c8dc99a25c..39599c3ef5c 100644 --- a/ace/Functor.i +++ b/ace/Functor.i @@ -11,8 +11,8 @@ // // = DESCRIPTION // Inlinable method definitions for non-templatized classes -// implementing the GOF Command Pattern, also known as functors -// or function objects. +// and template specializations implementing the GOF Command Pattern, +// and STL-style functors. // // = AUTHOR // Chris Gill <cdgill@cs.wustl.edu> @@ -23,8 +23,16 @@ // Douglas C. Schmidt <schmidt@cs.wustl.edu> and // Sergio Flores-Gaitan <sergio@cs.wustl.edu> // +// and on STL-style functor implementations originally done by +// +// Irfan Pyarali <irfan@cs.wustl.edu> +// // ============================================================================ +////////////////////////////////////////////////////////////// +// GOF Command Pattern Classes and Template Specializations // +////////////////////////////////////////////////////////////// + // Default constructor. ACE_INLINE @@ -38,3 +46,182 @@ ACE_INLINE ACE_Command_Base::~ACE_Command_Base (void) { } + +//////////////////////////////////////////////////////////// +// STL-style Functor Classes and Template Specializations // +//////////////////////////////////////////////////////////// + +ACE_INLINE u_long +ACE_Hash<char>::operator () (char t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<signed char>::operator () (signed char t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<unsigned char>::operator () (unsigned char t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<short>::operator () (short t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<unsigned short>::operator () (unsigned short t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<int>::operator () (int t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<unsigned int>::operator () (unsigned int t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<long>::operator () (long t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<unsigned long>::operator () (unsigned long t) const +{ + return t; +} + +ACE_INLINE u_long +ACE_Hash<const char *>::operator () (const char *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE u_long +ACE_Hash<char *>::operator () (const char *t) const +{ + return ACE::hash_pjw (t); +} + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) +ACE_INLINE u_long +ACE_Hash<const wchar_t *>::operator () (const wchar_t *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE u_long +ACE_Hash<wchar_t *>::operator () (const wchar_t *t) const +{ + return ACE::hash_pjw (t); +} +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) +ACE_INLINE u_long +ACE_Hash<const ACE_USHORT16 *>::operator () (const ACE_USHORT16 *t) const +{ + return ACE::hash_pjw (t); +} + +ACE_INLINE u_long +ACE_Hash<ACE_USHORT16 *>::operator () (const ACE_USHORT16 *t) const +{ + return ACE::hash_pjw (t); +} +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ + +ACE_INLINE int +ACE_Equal_To<const char *>::operator () (const char *lhs, const char *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Equal_To<char *>::operator () (const char *lhs, const char *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) +ACE_INLINE int +ACE_Equal_To<const wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Equal_To<wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) +ACE_INLINE int +ACE_Equal_To<const ACE_USHORT16 *>::operator () (const ACE_USHORT16 *lhs, const ACE_USHORT16 *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} + +ACE_INLINE int +ACE_Equal_To<ACE_USHORT16 *>::operator () (const ACE_USHORT16 *lhs, const ACE_USHORT16 *rhs) const +{ + return !ACE_OS::strcmp (lhs, rhs); +} +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ + +ACE_INLINE int +ACE_Less_Than<const char *>::operator () (const char *lhs, const char *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +ACE_INLINE int +ACE_Less_Than<char *>::operator () (const char *lhs, const char *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) +ACE_INLINE int +ACE_Less_Than<const wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +ACE_INLINE int +ACE_Less_Than<wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ + +#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) +ACE_INLINE int +ACE_Less_Than<const ACE_USHORT16 *>::operator () (const ACE_USHORT16 *lhs, const ACE_USHORT16 *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +ACE_INLINE int +ACE_Less_Than<ACE_USHORT16 *>::operator () (const ACE_USHORT16 *lhs, const ACE_USHORT16 *rhs) const +{ + return (ACE_OS::strcmp (lhs, rhs) < 0) ? 1 : 0; +} + +#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ diff --git a/ace/Functor_T.cpp b/ace/Functor_T.cpp index 534edb64401..42fafc62c74 100644 --- a/ace/Functor_T.cpp +++ b/ace/Functor_T.cpp @@ -11,8 +11,7 @@ // // = DESCRIPTION // Non-inlinable method definitions for templatized classes -// implementing the GOF Command Pattern, also known as functors -// or function objects. +// implementing the GOF Command Pattern, or STL-style functors. // // = AUTHOR // Chris Gill <cdgill@cs.wustl.edu> @@ -23,6 +22,10 @@ // Douglas C. Schmidt <schmidt@cs.wustl.edu> and // Sergio Flores-Gaitan <sergio@cs.wustl.edu> // +// and on STL-style functor implementations originally done by +// +// Irfan Pyarali <irfan@cs.wustl.edu> +// // ============================================================================ #ifndef ACE_FUNCTOR_T_C @@ -43,6 +46,11 @@ ACE_RCSID(ace, Functor_T, "$Id$") ACE_ALLOC_HOOK_DEFINE(ACE_Command_Callback) + +/////////////////////////////////// +// GOF Command Pattern Templates // +/////////////////////////////////// + // Constructor. template <class RECEIVER, class ACTION> diff --git a/ace/Functor_T.h b/ace/Functor_T.h index 4f671652a10..052b10fa993 100644 --- a/ace/Functor_T.h +++ b/ace/Functor_T.h @@ -10,8 +10,12 @@ // Functor_T.h // // = DESCRIPTION -// Templatized classes for implementing the GOF Command Pattern, -// also known as functors or function objects. +// Templatized classes for implementing function objects that are used in +// various places in ACE. There are currently two major categories of +// function objects in ACE: GOF Command Pattern objects, and STL-style +// functors for comparison of container elements. The command objects +// are invoked via an execute () method, while the STL-style functors are +// invoked via an operator() () method. // // = AUTHOR // Chris Gill <cdgill@cs.wustl.edu> @@ -22,6 +26,10 @@ // Douglas C. Schmidt <schmidt@cs.wustl.edu> and // Sergio Flores-Gaitan <sergio@cs.wustl.edu> // +// and on STL-style functor implementations originally done by +// +// Irfan Pyarali <irfan@cs.wustl.edu> +// // ============================================================================ #ifndef ACE_FUNCTOR_T_H @@ -33,12 +41,17 @@ # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ +/////////////////////////////////// +// GOF Command Pattern Templates // +/////////////////////////////////// + template <class RECEIVER, class ACTION> class ACE_Command_Callback : public ACE_Command_Base { // = TITLE - // Defines a class template that allows us to invoke a callback to an - // object without knowing anything about the object except its type. + // Defines a class template that allows us to invoke a GOF command style + // callback to an object without knowing anything about the object except + // its type. // // = DESCRIPTION // This class declares an interface to execute operations, @@ -66,139 +79,48 @@ private: // Method that is going to be invoked. }; -///////////////////////////// -// Unary functor templates // -///////////////////////////// - -template <class OPERAND> -class ACE_Unary_Functor_Base -{ - // = TITLE - // Defines a class template that allows us to invoke a function object - // over a single non-const parameterized type without knowing anything - // about the function and operand objects except their types. - // - // = DESCRIPTION - // This class declares an interface to execute a unary operation over a - // single object of the non-const paramterized type. A class can invoke - // such operation without knowing anything about it, or how it was - // implemented. - // -public: - - virtual ~ACE_Unary_Functor_Base () {}; - // Virtual destructor. - - virtual int execute (OPERAND &operand) = 0; - // Invokes the function object. - - virtual ACE_Unary_Functor_Base * clone () = 0; - // Creates another object of the same type. -}; - -template <class OPERAND> -class ACE_Const_Unary_Functor_Base -{ - // = TITLE - // Defines a class template that allows us to invoke a function object - // over a single parameterized type without knowing anything about - // the function and operand objects except their types. - // - // = DESCRIPTION - // This class declares an interface to execute a unary operation over a - // single object of the paramterized type. A class can invoke such - // an operation without knowing anything about it, or its implementation. - // -public: - - virtual ~ACE_Const_Unary_Functor_Base () {}; - // Virtual destructor. - - virtual int execute (const OPERAND &operand) = 0; - // Invokes the function object. - - virtual ACE_Const_Unary_Functor_Base * clone () = 0; - // Creates another object of the same type. -}; - -///////////////////////////// -// Binary functor templates // -///////////////////////////// +///////////////////////////////// +// STL-style Functor Templates // +///////////////////////////////// -template <class OPERAND1, class OPERAND2> -class ACE_Binary_Functor_Base +template <class TYPE> +class ACE_Hash { // = TITLE - // Defines a class template that allows us to invoke a binary function - // object over two non-const parameterized types without knowing anything - // about the function and operand objects except their types. // - // = DESCRIPTION - // This class declares an interface to execute a binary operation over two - // objects of the paramterized non-const types. A class can invoke such - // an operation without knowing anything about it, or its implementation. + // Function object for hashing // public: - - virtual ~ACE_Binary_Functor_Base () {}; - // Virtual destructor. - - virtual int execute (OPERAND1 &operand1, OPERAND2 &operand2) = 0; - // Invokes the function object. - - virtual ACE_Binary_Functor_Base * clone () = 0; - // Creates another object of the same type. + u_long operator () (const TYPE &t) const; + // Simply calls t.hash () }; -template <class OPERAND1, class OPERAND2> -class ACE_Const_Binary_Functor_Base +template <class TYPE> +class ACE_Equal_To { // = TITLE - // Defines a class template that allows us to invoke a binary function - // object over two parameterized types without knowing anything about - // the function and operand objects except their types. // - // = DESCRIPTION - // This class declares an interface to execute a binary operation over two - // objects of the paramterized types. A class can invoke such - // an operation without knowing anything about it, or its implementation. + // Function object for comparing two objects of + // the given type for equality. // public: - - virtual ~ACE_Const_Binary_Functor_Base () {}; - // Virtual destructor. - - virtual int execute (const OPERAND1 &operand1, const OPERAND2 &operand2) = 0; - // Invokes the function object. - - virtual ACE_Const_Binary_Functor_Base * clone () = 0; - // Creates another object of the same type. + int operator () (const TYPE &lhs, + const TYPE &rhs) const; + // Simply calls operator== }; - -template <class OPERAND1, class OPERAND2> -class ACE_Less_Than_Functor : - public ACE_Const_Binary_Functor_Base<OPERAND1, OPERAND2> +template <class TYPE> +class ACE_Less_Than { // = TITLE - // Defines a class template that allows us to invoke a binary less than - // function over two parameterized types without knowing anything about - // the function and operand objects except their types. // - // = DESCRIPTION - // This class depends on the definition - // objects of the paramterized types. A class can invoke such - // an operation without knowing anything about it, or its implementation. + // Function object for determining whether the first object of the + // given type is less than the second object of the same type. // public: - - virtual int execute (const OPERAND1 &operand1, const OPERAND2 &operand2); - // Invokes the function object. - - virtual - ACE_Const_Binary_Functor_Base<OPERAND1, OPERAND2> - * clone (); - // Creates another object of the same type. + int operator () (const TYPE &lhs, + const TYPE &rhs) const; + // Simply calls operator< }; diff --git a/ace/Functor_T.i b/ace/Functor_T.i index cf4171c0984..0024cd3fd23 100644 --- a/ace/Functor_T.i +++ b/ace/Functor_T.i @@ -11,8 +11,7 @@ // // = DESCRIPTION // Inlinable method definitions for templatized classes -// implementing the GOF Command Pattern, also known as functors -// or function objects. +// implementing the GOF Command Pattern, or STL-style functors. // // = AUTHOR // Chris Gill <cdgill@cs.wustl.edu> @@ -23,23 +22,34 @@ // Douglas C. Schmidt <schmidt@cs.wustl.edu> and // Sergio Flores-Gaitan <sergio@cs.wustl.edu> // +// and on STL-style functor implementations originally done by +// +// Irfan Pyarali <irfan@cs.wustl.edu> +// // ============================================================================ -// Invokes the less than function object. +///////////////////////////////// +// STL-style Functor Templates // +///////////////////////////////// -template <class OPERAND1, class OPERAND2> ACE_INLINE int -ACE_Less_Than_Functor<OPERAND1, OPERAND2>::execute (const OPERAND1 &operand1, - const OPERAND2 &operand2) +template <class TYPE> ACE_INLINE u_long +ACE_Hash<TYPE>::operator () (const TYPE &t) const { - return (operand1 < operand2) ? 1 : 0; + return t.hash (); } -// Creates another object of the same type. +template <class TYPE> ACE_INLINE int +ACE_Equal_To<TYPE>::operator () (const TYPE &lhs, + const TYPE &rhs) const +{ + return lhs == rhs; +} -template <class OPERAND1, class OPERAND2> ACE_INLINE -ACE_Const_Binary_Functor_Base<OPERAND1, OPERAND2> * -ACE_Less_Than_Functor<OPERAND1, OPERAND2>::clone () +template <class TYPE> ACE_INLINE int +ACE_Less_Than<TYPE>::operator () (const TYPE &lhs, + const TYPE &rhs) const { - return new ACE_Less_Than_Functor<OPERAND1, OPERAND2>; + return (lhs < rhs) ? 1 : 0; } + diff --git a/ace/Hash_Map_Manager.h b/ace/Hash_Map_Manager.h index e7f2bc612eb..f2735981288 100644 --- a/ace/Hash_Map_Manager.h +++ b/ace/Hash_Map_Manager.h @@ -18,219 +18,12 @@ #define ACE_HASH_MAP_MANAGER_H #include "ace/OS.h" +#include "ace/Functor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -// Forward declaration since we are going to specialize that template -// here. The template itself requires this file so every user of the -// template should also see the specialization. -template <class TYPE> class ACE_Hash; -template <class TYPE> class ACE_Equal_To; - -class ACE_Export ACE_Hash<char> -{ - // = TITLE - // Function object for hashing a char -public: - u_long operator () (char t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<signed char> -{ - // = TITLE - // Function object for hashing a signed char -public: - u_long operator () (signed char t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<unsigned char> -{ - // = TITLE - // Function object for hashing an unsigned char -public: - u_long operator () (unsigned char t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<short> -{ - // = TITLE - // Function object for hashing a short -public: - u_long operator () (short t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<unsigned short> -{ - // = TITLE - // Function object for hashing an unsigned short -public: - u_long operator () (unsigned short t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<int> -{ - // = TITLE - // Function object for hashing an int -public: - u_long operator () (int t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<unsigned int> -{ - // = TITLE - // Function object for hashing an unsigned int -public: - u_long operator () (unsigned int t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<long> -{ - // = TITLE - // Function object for hashing a long -public: - u_long operator () (long t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<unsigned long> -{ - // = TITLE - // Function object for hashing an unsigned long -public: - u_long operator () (unsigned long t) const; - // Simply returns t -}; - -class ACE_Export ACE_Hash<const char *> -{ - // = TITLE - // Function object for hashing a const string -public: - u_long operator () (const char *t) const; - // Calls ACE::hash_pjw -}; - -class ACE_Export ACE_Hash<char *> -{ - // = TITLE - // Function object for hashing a string -public: - u_long operator () (const char *t) const; - // Calls ACE::hash_pjw -}; - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) -class ACE_Export ACE_Hash<const wchar_t *> -{ - // = TITLE - // Function object for hashing a const wide string -public: - u_long operator () (const wchar_t *t) const; - // Calls ACE::hash_pjw -}; - -class ACE_Export ACE_Hash<wchar_t *> -{ - // = TITLE - // Function object for hashing a wide string -public: - u_long operator () (const wchar_t *t) const; - // Calls ACE::hash_pjw -}; -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) -class ACE_Export ACE_Hash<const ACE_USHORT16 *> -{ - // = TITLE - // Function object for hashing a const wide string -public: - u_long operator () (const ACE_USHORT16 *t) const; - // Calls ACE::hash_pjw -}; - -class ACE_Export ACE_Hash<ACE_USHORT16 *> -{ - // = TITLE - // Function object for hashing a wide string -public: - u_long operator () (const ACE_USHORT16 *t) const; - // Calls ACE::hash_pjw -}; -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ - -class ACE_Export ACE_Equal_To<const char *> -{ - // = TITLE - // Function object for comparing two const strings -public: - int operator () (const char *lhs, - const char *rhs) const; - // Simply calls strcmp -}; - -class ACE_Export ACE_Equal_To<char *> -{ - // = TITLE - // Function object for comparing two strings -public: - int operator () (const char *lhs, - const char *rhs) const; - // Simply calls strcmp -}; - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) -class ACE_Export ACE_Equal_To<const wchar_t *> -{ - // = TITLE - // Function object for comparing two const wide strings -public: - int operator () (const wchar_t *lhs, - const wchar_t *rhs) const; - // Simply calls strcmp -}; - -class ACE_Export ACE_Equal_To<wchar_t *> -{ - // = TITLE - // Function object for comparing two wide strings -public: - int operator () (const wchar_t *lhs, - const wchar_t *rhs) const; - // Simply calls strcmp -}; -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) -class ACE_Export ACE_Equal_To<const ACE_USHORT16 *> -{ - // = TITLE - // Function object for comparing two const wide strings -public: - int operator () (const ACE_USHORT16 *lhs, - const ACE_USHORT16 *rhs) const; - // Simply calls strcmp -}; - -class ACE_Export ACE_Equal_To<ACE_USHORT16 *> -{ - // = TITLE - // Function object for comparing two wide strings -public: - int operator () (const ACE_USHORT16 *lhs, - const ACE_USHORT16 *rhs) const; - // Simply calls strcmp -}; -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ // Include the templates here. #include "ace/Hash_Map_Manager_T.h" diff --git a/ace/Hash_Map_Manager.i b/ace/Hash_Map_Manager.i index 038ad1157f5..74e88caa0c5 100644 --- a/ace/Hash_Map_Manager.i +++ b/ace/Hash_Map_Manager.i @@ -1,135 +1,2 @@ // $Id$ -ACE_INLINE u_long -ACE_Hash<char>::operator () (char t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<signed char>::operator () (signed char t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<unsigned char>::operator () (unsigned char t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<short>::operator () (short t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<unsigned short>::operator () (unsigned short t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<int>::operator () (int t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<unsigned int>::operator () (unsigned int t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<long>::operator () (long t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<unsigned long>::operator () (unsigned long t) const -{ - return t; -} - -ACE_INLINE u_long -ACE_Hash<const char *>::operator () (const char *t) const -{ - return ACE::hash_pjw (t); -} - -ACE_INLINE u_long -ACE_Hash<char *>::operator () (const char *t) const -{ - return ACE::hash_pjw (t); -} - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) -ACE_INLINE u_long -ACE_Hash<const wchar_t *>::operator () (const wchar_t *t) const -{ - return ACE::hash_pjw (t); -} - -ACE_INLINE u_long -ACE_Hash<wchar_t *>::operator () (const wchar_t *t) const -{ - return ACE::hash_pjw (t); -} -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) -ACE_INLINE u_long -ACE_Hash<const ACE_USHORT16 *>::operator () (const ACE_USHORT16 *t) const -{ - return ACE::hash_pjw (t); -} - -ACE_INLINE u_long -ACE_Hash<ACE_USHORT16 *>::operator () (const ACE_USHORT16 *t) const -{ - return ACE::hash_pjw (t); -} -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ - -ACE_INLINE int -ACE_Equal_To<const char *>::operator () (const char *lhs, const char *rhs) const -{ - return !ACE_OS::strcmp (lhs, rhs); -} - -ACE_INLINE int -ACE_Equal_To<char *>::operator () (const char *lhs, const char *rhs) const -{ - return !ACE_OS::strcmp (lhs, rhs); -} - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_CHAR) -ACE_INLINE int -ACE_Equal_To<const wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const -{ - return !ACE_OS::strcmp (lhs, rhs); -} - -ACE_INLINE int -ACE_Equal_To<wchar_t *>::operator () (const wchar_t *lhs, const wchar_t *rhs) const -{ - return !ACE_OS::strcmp (lhs, rhs); -} -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_CHAR */ - -#if !defined (ACE_HAS_WCHAR_TYPEDEFS_USHORT) -ACE_INLINE int -ACE_Equal_To<const ACE_USHORT16 *>::operator () (const ACE_USHORT16 *lhs, const ACE_USHORT16 *rhs) const -{ - return !ACE_OS::strcmp (lhs, rhs); -} - -ACE_INLINE int -ACE_Equal_To<ACE_USHORT16 *>::operator () (const ACE_USHORT16 *lhs, const ACE_USHORT16 *rhs) const -{ - return !ACE_OS::strcmp (lhs, rhs); -} -#endif /* ! ACE_HAS_WCHAR_TYPEDEFS_USHORT */ diff --git a/ace/Hash_Map_Manager_T.h b/ace/Hash_Map_Manager_T.h index 0280d93630e..a05bee99170 100644 --- a/ace/Hash_Map_Manager_T.h +++ b/ace/Hash_Map_Manager_T.h @@ -18,36 +18,12 @@ #define ACE_HASH_MAP_MANAGER_T_H #include "ace/OS.h" +#include "ace/Functor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -template <class TYPE> -class ACE_Hash -{ - // = TITLE - // - // Function object for hashing - // -public: - u_long operator () (const TYPE &t); - // Simply calls t.hash () -}; - -template <class TYPE> -class ACE_Equal_To -{ - // = TITLE - // - // Function object for comparing types - // -public: - int operator () (const TYPE &lhs, - const TYPE &rhs); - // Simply calls operator== -}; - template <class EXT_ID, class INT_ID> class ACE_Hash_Map_Entry { diff --git a/ace/Hash_Map_Manager_T.i b/ace/Hash_Map_Manager_T.i index e9be5323221..c0decdeaf7e 100644 --- a/ace/Hash_Map_Manager_T.i +++ b/ace/Hash_Map_Manager_T.i @@ -2,19 +2,6 @@ #include "ace/Synch.h" -template <class TYPE> ACE_INLINE u_long -ACE_Hash<TYPE>::operator () (const TYPE &t) -{ - return t.hash (); -} - -template <class TYPE> ACE_INLINE int -ACE_Equal_To<TYPE>::operator () (const TYPE &lhs, - const TYPE &rhs) -{ - return lhs == rhs; -} - template <class EXT_ID, class INT_ID, class HASH_KEY, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE ACE_Hash_Map_Manager_Ex<EXT_ID, INT_ID, HASH_KEY, COMPARE_KEYS, ACE_LOCK>::ACE_Hash_Map_Manager_Ex (size_t size, ACE_Allocator *alloc) @@ -778,6 +778,12 @@ typedef struct # define ACE_PLATFORM_A "pSOS" # define ACE_PLATFORM_EXE_SUFFIX_A "" +# if defined (ACE_HAS_MOSTLY_UNICODE_APIS) +# define ASYS_WIDE_STRING(ASCII_STRING) ACE_WString (ASCII_STRING).fast_rep () +# else +# define ASYS_WIDE_STRING(ASCII_STRING) ASCII_STRING +# endif /* ACE_HAS_MOSTLY_UNICODE_APIS */ + # if defined (ACE_HAS_UNICODE) # define ACE_DIRECTORY_SEPARATOR_STR_W L"/" # define ACE_DIRECTORY_SEPARATOR_CHAR_W L'/' @@ -6145,7 +6151,7 @@ ace_main_i (int, char *[]); /* forward declaration */ \ ACE_MAIN () /* user's entry point, e.g., "main" w/out argc, argv */ \ { \ int argc = 1; /* dummy arg count */ \ - char *argv[] = {""}; /* dummy arg list */ \ + char *argv[] = {"root"}; /* dummy arg list */ \ ACE_Object_Manager ace_object_manager; /* has program lifetime */ \ ace_main_i (argc, argv); /* call user main, ignore result */ \ } \ diff --git a/ace/RB_Tree.cpp b/ace/RB_Tree.cpp index dd36270cb7f..5b619313e6d 100644 --- a/ace/RB_Tree.cpp +++ b/ace/RB_Tree.cpp @@ -56,35 +56,21 @@ ACE_RB_Tree_Node<KEY, T>::~ACE_RB_Tree_Node () // Constructor. -template <class KEY, class T> -ACE_RB_Tree<KEY, T>::ACE_RB_Tree ( - ACE_Const_Binary_Functor_Base<KEY, KEY> *less_than_functor, - int free_functor) - : root_ (0), - less_than_functor_ (less_than_functor), - free_functor_ (free_functor) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree () + : root_ (0) { - if (less_than_functor_ == 0) - { - less_than_functor_ = new ACE_Less_Than_Functor<KEY, KEY>; - free_functor_ = 1; - } } // Copy constructor. -template <class KEY, class T> -ACE_RB_Tree<KEY, T>::ACE_RB_Tree (const ACE_RB_Tree<KEY, T> &rbt) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree (const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &rbt) : root_ (0) { - // Make a copy of the comparison functor. - less_than_functor_ = (rbt.less_than_functor_ == 0) - ? 0 : rbt.less_than_functor_->clone (); - free_functor_ = 1; - // Make a deep copy of the passed tree. - ACE_RB_Tree_Iterator<KEY, T> iter(rbt); + ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK> iter(rbt); for (iter.first (); iter.is_done () == 0; iter.next ()) { insert (*(iter.key ()), *(iter.item ())); @@ -94,15 +80,9 @@ ACE_RB_Tree<KEY, T>::ACE_RB_Tree (const ACE_RB_Tree<KEY, T> &rbt) // Destructor. -template <class KEY, class T> -ACE_RB_Tree<KEY, T>::~ACE_RB_Tree () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree () { - // Free the comparison functor if needed. - if (free_functor_) - { - delete less_than_functor_; - } - // Clear away all nodes in the tree. clear (); } @@ -110,25 +90,14 @@ ACE_RB_Tree<KEY, T>::~ACE_RB_Tree () // Assignment operator. -template <class KEY, class T> void -ACE_RB_Tree<KEY, T>::operator = (const ACE_RB_Tree<KEY, T> &rbt) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> void +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::operator = (const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &rbt) { - // Free the comparison functor if needed. - if (free_functor_) - { - delete less_than_functor_; - } - - // Make a copy of the passed tree's comparison functor. - less_than_functor_ = (rbt.less_than_functor_ == 0) - ? 0 : rbt.less_than_functor_->clone (); - free_functor_ = 1; - // Clear out the existing tree. clear (); // Make a deep copy of the passed tree. - ACE_RB_Tree_Iterator<KEY, T> iter(rbt); + ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK> iter(rbt); for (iter.first (); iter.is_done () == 0; iter.next ()) { insert (*(iter.key ()), *(iter.item ())); @@ -138,27 +107,18 @@ ACE_RB_Tree<KEY, T>::operator = (const ACE_RB_Tree<KEY, T> &rbt) // Less than comparison function for keys, default // functor implementation returns 1 if k1 < k2, 0 otherwise. -template <class KEY, class T> int -ACE_RB_Tree<KEY, T>::lessthan (const KEY &k1, const KEY &k2) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> int +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::lessthan (const KEY &k1, const KEY &k2) { - if (less_than_functor_ == 0) - { - ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("%p\n"), - ASYS_TEXT ("\nNull comparison functor pointer.\n")), - 0); - } - else - { - return less_than_functor_->execute (k1, k2); - } + return this->compare_keys_ (k1, k2); } // Returns a pointer to the item corresponding to the // given key, or 0 if it cannot find the key in the tree. -template <class KEY, class T> T* -ACE_RB_Tree<KEY, T>::find (const KEY &k) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> T* +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::find (const KEY &k) { // Find the closest matching node, if there is one. ACE_RB_Tree_Node<KEY, T> *current = find_node (k); @@ -196,8 +156,8 @@ ACE_RB_Tree<KEY, T>::find (const KEY &k) // the returned pointer addresses the existing item // associated with the existing key. -template <class KEY, class T> T* -ACE_RB_Tree<KEY, T>::insert (const KEY &k, const T &t) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> T* +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::insert (const KEY &k, const T &t) { // Find the closest matching node, if there is one. ACE_RB_Tree_Node<KEY, T> *current = find_node (k); @@ -301,8 +261,8 @@ ACE_RB_Tree<KEY, T>::insert (const KEY &k, const T &t) // and successfully destroyed it, 0 if it did not find the // item, or -1 if an error occurred. -template <class KEY, class T> int -ACE_RB_Tree<KEY, T>::remove (const KEY &k) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> int +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::remove (const KEY &k) { // Find a matching node, if there is one. ACE_RB_Tree_Node<KEY, T> *x, *z; @@ -375,8 +335,8 @@ ACE_RB_Tree<KEY, T>::remove (const KEY &k) // Method for right rotation of the tree about a given node. -template <class KEY, class T> void -ACE_RB_Tree<KEY, T>::RB_rotate_right (ACE_RB_Tree_Node<KEY, T> * x) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> void +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_rotate_right (ACE_RB_Tree_Node<KEY, T> * x) { if (! x) { @@ -423,8 +383,8 @@ ACE_RB_Tree<KEY, T>::RB_rotate_right (ACE_RB_Tree_Node<KEY, T> * x) // Method for left rotation of the tree about a given node. -template <class KEY, class T> void -ACE_RB_Tree<KEY, T>::RB_rotate_left (ACE_RB_Tree_Node<KEY, T> * x) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> void +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_rotate_left (ACE_RB_Tree_Node<KEY, T> * x) { if (! x) { @@ -471,8 +431,8 @@ ACE_RB_Tree<KEY, T>::RB_rotate_left (ACE_RB_Tree_Node<KEY, T> * x) // Method for restoring Red-Black properties after deletion. -template <class KEY, class T> void -ACE_RB_Tree<KEY, T>::RB_delete_fixup (ACE_RB_Tree_Node<KEY, T> * x) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> void +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_delete_fixup (ACE_RB_Tree_Node<KEY, T> * x) { while ((x) && (x->parent ()) && (x->color () == ACE_RB_Tree_Node_Base::BLACK)) { @@ -555,8 +515,8 @@ ACE_RB_Tree<KEY, T>::RB_delete_fixup (ACE_RB_Tree_Node<KEY, T> * x) // if the tree is not empty and there is no such match, // or 0 if the tree is empty. -template <class KEY, class T> ACE_RB_Tree_Node<KEY, T> * -ACE_RB_Tree<KEY, T>::find_node (const KEY &k) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::find_node (const KEY &k) { ACE_RB_Tree_Node<KEY, T> *current = root_; @@ -604,8 +564,8 @@ ACE_RB_Tree<KEY, T>::find_node (const KEY &k) // Rebalance the tree after insertion of a node. -template <class KEY, class T> void -ACE_RB_Tree<KEY, T>::RB_rebalance (ACE_RB_Tree_Node<KEY, T> * x) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> void +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_rebalance (ACE_RB_Tree_Node<KEY, T> * x) { ACE_RB_Tree_Node<KEY, T> *y = 0; @@ -679,8 +639,8 @@ ACE_RB_Tree<KEY, T>::RB_rebalance (ACE_RB_Tree_Node<KEY, T> * x) // Method to find the successor node of the given node in the tree. -template <class KEY, class T> ACE_RB_Tree_Node<KEY, T> * -ACE_RB_Tree<KEY, T>::RB_tree_successor (ACE_RB_Tree_Node<KEY, T> *x) const +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_tree_successor (ACE_RB_Tree_Node<KEY, T> *x) const { if (x->right ()) { @@ -700,8 +660,8 @@ ACE_RB_Tree<KEY, T>::RB_tree_successor (ACE_RB_Tree_Node<KEY, T> *x) const // Method to find the predecessor node of the given node in the tree. -template <class KEY, class T> ACE_RB_Tree_Node<KEY, T> * -ACE_RB_Tree<KEY, T>::RB_tree_predecessor (ACE_RB_Tree_Node<KEY, T> *x) const +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_tree_predecessor (ACE_RB_Tree_Node<KEY, T> *x) const { if (x->left ()) { @@ -721,8 +681,8 @@ ACE_RB_Tree<KEY, T>::RB_tree_predecessor (ACE_RB_Tree_Node<KEY, T> *x) const // Method to find the minimum node of the subtree rooted at the given node. -template <class KEY, class T> ACE_RB_Tree_Node<KEY, T> * -ACE_RB_Tree<KEY, T>::RB_tree_minimum (ACE_RB_Tree_Node<KEY, T> *x) const +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_tree_minimum (ACE_RB_Tree_Node<KEY, T> *x) const { while ((x) && (x->left ())) { @@ -735,8 +695,8 @@ ACE_RB_Tree<KEY, T>::RB_tree_minimum (ACE_RB_Tree_Node<KEY, T> *x) const // Method to find the maximum node of the subtree rooted at the given node. -template <class KEY, class T> ACE_RB_Tree_Node<KEY, T> * -ACE_RB_Tree<KEY, T>::RB_tree_maximum (ACE_RB_Tree_Node<KEY, T> *x) const +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_RB_Tree_Node<KEY, T> * +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::RB_tree_maximum (ACE_RB_Tree_Node<KEY, T> *x) const { while ((x) && (x->right ())) { @@ -749,15 +709,15 @@ ACE_RB_Tree<KEY, T>::RB_tree_maximum (ACE_RB_Tree_Node<KEY, T> *x) const -///////////////////////////////////////////////// -// template class ACE_RB_Tree_Iterator<KEY, T> // -///////////////////////////////////////////////// +////////////////////////////////////////////////////////// +// template class ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK> // +////////////////////////////////////////////////////////// // Constructor. -template <class KEY, class T> -ACE_RB_Tree_Iterator<KEY, T>::ACE_RB_Tree_Iterator (const ACE_RB_Tree<KEY, T> &tree) +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::ACE_RB_Tree_Iterator (const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &tree) : tree_ (tree), node_ (0) { // Position the iterator at the first node in the tree. @@ -767,8 +727,8 @@ ACE_RB_Tree_Iterator<KEY, T>::ACE_RB_Tree_Iterator (const ACE_RB_Tree<KEY, T> &t // Destructor. -template <class KEY, class T> -ACE_RB_Tree_Iterator<KEY, T>::~ACE_RB_Tree_Iterator () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::~ACE_RB_Tree_Iterator () { } diff --git a/ace/RB_Tree.h b/ace/RB_Tree.h index b4de225acef..30f56376a2d 100644 --- a/ace/RB_Tree.h +++ b/ace/RB_Tree.h @@ -96,7 +96,7 @@ private: // Pointer to node's right child. }; -template <class KEY, class T> +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> class ACE_RB_Tree { // = TITLE @@ -105,26 +105,24 @@ class ACE_RB_Tree // 1990, MIT, chapter 14. // // = Description - // Optional flag passed to constructor indicates whether or not the - // passed functor should be deleted by the ACE_RB_Tree's destructor. + // If an ACE allocator is passed to the RB_Tree constructor, it is used + // for all dynamic allocations done by the tree. public: // = Initialization and termination methods. - ACE_RB_Tree (ACE_Const_Binary_Functor_Base<KEY, KEY> *less_than_functor = 0, - int free_functor = 0); + ACE_RB_Tree (); // Constructor. - ACE_RB_Tree (const ACE_RB_Tree<KEY, T> &rbt); + ACE_RB_Tree (const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &rbt); // Copy constructor. virtual ~ACE_RB_Tree (void); // Destructor. - void operator= (const ACE_RB_Tree<KEY, T> &rbt); + void operator= (const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &rbt); // Assignment operator. virtual int lessthan (const KEY &k1, const KEY &k2); - // Less than comparison function for keys. Default implementation returns 1 - // if k1 < k2, and 0 otherwise. + // Less than comparison function for keys, using comparison functor. T* find (const KEY &k); // Returns a pointer to the item corresponding to the @@ -196,22 +194,19 @@ public: ACE_RB_Tree_Node<KEY, T> *root_; // The root of the tree. - ACE_Const_Binary_Functor_Base<KEY, KEY> *less_than_functor_; - // "Less than" functor for comparing nodes in the tree. + COMPARE_KEYS compare_keys_; + // Comparison functor for comparing nodes in the tree. - int free_functor_; - // Flag indicating whether or not to delete functor in destructor - // and assignment operator. }; -template <class KEY, class T> +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> class ACE_RB_Tree_Iterator { // = TITLE // Implements an iterator for a Red-Black Tree ADT. public: // = Initialization and termination methods. - ACE_RB_Tree_Iterator (const ACE_RB_Tree<KEY, T> &tree); + ACE_RB_Tree_Iterator (const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &tree); // Constructor. ~ACE_RB_Tree_Iterator (void); @@ -244,13 +239,13 @@ private: // Explicitly prevent assignment and copy construction of iterators. ACE_UNIMPLEMENTED_FUNC ( - ACE_RB_Tree_Iterator (const ACE_RB_Tree_Iterator<KEY, T> &)) + ACE_RB_Tree_Iterator (const ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK> &)) ACE_UNIMPLEMENTED_FUNC ( - void operator = (const ACE_RB_Tree_Iterator<KEY, T> &)) + void operator = (const ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK> &)) // Private members. - const ACE_RB_Tree<KEY, T> &tree_; + const ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> &tree_; // Reference to the ACE_RB_Tree over which we're iterating. ACE_RB_Tree_Node <KEY, T> *node_; diff --git a/ace/RB_Tree.i b/ace/RB_Tree.i index b423d77d5dd..3ddfee0f079 100644 --- a/ace/RB_Tree.i +++ b/ace/RB_Tree.i @@ -98,15 +98,15 @@ ACE_RB_Tree_Node<KEY, T>::right (ACE_RB_Tree_Node<KEY, T> * r) -//////////////////////////////////////// -// template class ACE_RB_Tree<KEY, T> // -//////////////////////////////////////// +//////////////////////////////////////////////////////////////// +// template class ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK> // +//////////////////////////////////////////////////////////////// // Destroys all nodes and sets the root pointer null. -template <class KEY, class T> ACE_INLINE void -ACE_RB_Tree<KEY, T>::clear () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE void +ACE_RB_Tree<KEY, T, COMPARE_KEYS, ACE_LOCK>::clear () { delete root_; root_ = 0; @@ -114,15 +114,15 @@ ACE_RB_Tree<KEY, T>::clear () -///////////////////////////////////////////////// -// template class ACE_RB_Tree_Iterator<KEY, T> // -///////////////////////////////////////////////// +////////////////////////////////////////////////////////// +// template class ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK> // +////////////////////////////////////////////////////////// // Accessor for key of node under iterator (if any). -template <class KEY, class T> ACE_INLINE KEY * -ACE_RB_Tree_Iterator<KEY, T>::key () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE KEY * +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::key () { return node_ ? (&(node_->key ())) : 0; } @@ -130,8 +130,8 @@ ACE_RB_Tree_Iterator<KEY, T>::key () // Accessor for item of node under iterator (if any). -template <class KEY, class T> ACE_INLINE T * -ACE_RB_Tree_Iterator<KEY, T>::item () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE T * +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::item () { return node_ ? (&(node_->item ())) : 0; } @@ -139,8 +139,8 @@ ACE_RB_Tree_Iterator<KEY, T>::item () // Move to the first item in the tree. -template <class KEY, class T> ACE_INLINE int -ACE_RB_Tree_Iterator<KEY, T>::first () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::first () { node_ = tree_.RB_tree_minimum (tree_.root_); return node_ ? 1 : 0; @@ -149,8 +149,8 @@ ACE_RB_Tree_Iterator<KEY, T>::first () // Move to the last item in the tree. -template <class KEY, class T> ACE_INLINE int -ACE_RB_Tree_Iterator<KEY, T>::last () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::last () { node_ = tree_.RB_tree_maximum (tree_.root_); return node_ ? 1 : 0; @@ -160,8 +160,8 @@ ACE_RB_Tree_Iterator<KEY, T>::last () // Moves to the next item in the tree, // returns 1 if there is a next item, 0 otherwise. -template <class KEY, class T> ACE_INLINE int -ACE_RB_Tree_Iterator<KEY, T>::next () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::next () { node_ = tree_.RB_tree_successor (node_); return node_ ? 1 : 0; @@ -171,15 +171,15 @@ ACE_RB_Tree_Iterator<KEY, T>::next () // Moves to the previous item in the tree, // returns 1 if there is a previous item, 0 otherwise. -template <class KEY, class T> ACE_INLINE int -ACE_RB_Tree_Iterator<KEY, T>::previous () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::previous () { node_ = tree_.RB_tree_predecessor (node_); return node_ ? 1 : 0; } -template <class KEY, class T> ACE_INLINE int -ACE_RB_Tree_Iterator<KEY, T>::is_done () +template <class KEY, class T, class COMPARE_KEYS, class ACE_LOCK> ACE_INLINE int +ACE_RB_Tree_Iterator<KEY, T, COMPARE_KEYS, ACE_LOCK>::is_done () { return node_ ? 0 : 1; } diff --git a/ace/config-psos-diab.h b/ace/config-psos-diab.h index 9dc9b81405f..a1e7a871e54 100644 --- a/ace/config-psos-diab.h +++ b/ace/config-psos-diab.h @@ -22,6 +22,8 @@ #define ACE_LACKS_FILELOCKS +#define ACE_LACKS_FSYNC + #define ACE_LACKS_INLINE_FUNCTIONS #define ACE_LACKS_TEMPLATE_AS_TEMPLATE_PARAMETER @@ -37,6 +39,8 @@ #define ACE_HAS_CPLUSPLUS_HEADERS +#define ACE_HAS_BROKEN_EXPLICIT_TYPECAST_OPERATOR_INVOCATION + #define ACE_HAS_BROKEN_CONDITIONAL_STRING_CASTS #define ACE_HAS_BROKEN_EXPLICIT_DESTRUCTOR @@ -91,7 +95,7 @@ #define ACE_LACKS_READV // rename the main entry point -// #define ACE_MAIN extern "C" void root +#define ACE_MAIN extern "C" void root // All this was commented out for the single threaded port @@ -215,6 +219,8 @@ #define ACE_PSOS_SNARFS_HEADER_INFO +#define ACE_PSOS_LACKS_ARGC_ARGV + #if !defined (ACE_PSOS) #define ACE_PSOS #endif /* ACE_PSOS */ |