home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / istrtest.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  3.5 KB  |  122 lines

  1.  
  2. #ifndef _ISTRTEST_
  3. #define _ISTRTEST_
  4. /*******************************************************************************
  5. * FILE NAME: istrtest.hpp                                                      *
  6. *                                                                              *
  7. * DESCRIPTION:                                                                 *
  8. *   Declaration of the classes:                                                *
  9. *     IStringTest                                                              *
  10. *                                                                              *
  11. * COPYRIGHT:                                                                   *
  12. *   IBM Open Class Library                                                     *
  13. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  14. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  15. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  16. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  17. *                                                                              *
  18. *******************************************************************************/
  19. #include <ivbase.hpp>
  20.  
  21. #pragma pack(4)
  22.  
  23. extern "C"
  24.   {
  25.   typedef IBase::Boolean ICStrTestFn( int );
  26.   }
  27.  
  28.  
  29.  
  30. class IStringTest : public IVBase {
  31. typedef IVBase
  32.   Inherited;
  33.  
  34. public:
  35.  
  36. /*------------------------- Function Types -----------------------------------*/
  37. typedef ICStrTestFn
  38.   CFunction;
  39. typedef Boolean
  40.   CPPFunction( int );
  41.  
  42. /*------------------------- Constructors -------------------------------------*/
  43.   IStringTest ( CFunction   &cFunc );
  44.  ~IStringTest ( );
  45.  
  46. /*------------------------- Testing ------------------------------------------*/
  47. virtual Boolean
  48.   test        ( int c ) const;
  49.  
  50. protected:
  51. /*------------------------- Test Function Description ------------------------*/
  52. enum FnType {
  53.   user,
  54.   c,
  55.   cpp,
  56.   memFn,
  57.   cMemFn
  58.   };
  59.  
  60. FnType
  61.   type;
  62.  
  63. union { CFunction *cFn; void *user; } data;
  64.  
  65. /*------------------------ Protected Constructors ----------------------------*/
  66.   IStringTest ( FnType  type,
  67.                 void   *userData );
  68.  
  69. }; // class IStringTest
  70.  
  71. template < class T >
  72. class IStringTestMemberFn : public IStringTest {
  73. public:
  74. /*------------------------- Function Types -----------------------------------*/
  75. typedef Boolean
  76.  ( T::*ConstFn )( int ) const;
  77. typedef Boolean
  78.  ( T::*NonconstFn )( int );
  79.  
  80. /*------------------------- Constructors -------------------------------------*/
  81.   IStringTestMemberFn ( const T    &object,
  82.                         ConstFn     constFn )
  83.     : IStringTest ( user, (void*)&object ),
  84.       cMF         ( constFn )
  85.     {
  86.     }
  87.   IStringTestMemberFn ( T          &object,
  88.                         NonconstFn  nonconstFn )
  89.     : IStringTest ( user, (void*)&object ),
  90.       ncMF        ( nonconstFn )
  91.     {
  92.     }
  93.  
  94. /*------------------------- Testing ------------------------------------------*/
  95. virtual Boolean
  96.   test                ( int c ) const
  97.     {
  98.     if ( this->type == cMemFn )
  99.       return ((const T*)data.user->*cMF)( c );
  100.     else
  101.       return ((T*)data.user->*ncMF)( c );
  102.     }
  103.  
  104. private:
  105. /*------------------------------ Private ------------------------------------*/
  106. union { ConstFn cMF; NonconstFn ncMF; };
  107.  
  108.  
  109.  
  110. };
  111.  
  112.  
  113.  
  114. #pragma pack()
  115.  
  116.   #include <istrtest.inl>
  117.  
  118. #endif // _ISTRTEST_
  119.  
  120.  
  121.  
  122.