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

  1. #ifndef _ISTRGEN_
  2.   #define _ISTRGEN_
  3. /*******************************************************************************
  4. * FILE NAME: istrgen.hpp                                                       *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IStringGenerator                                                         *
  9. *     IStringGeneratorFn                                                       *
  10. *     IStringGeneratorMemberFn                                                 *
  11. *     IStringGeneratorRefMemberFn                                              *
  12. *                                                                              *
  13. * COPYRIGHT:                                                                   *
  14. *   IBM Open Class Library                                                     *
  15. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  16. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  17. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  18. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  19. *                                                                              *
  20. *******************************************************************************/
  21. #include <ibase.hpp>
  22. #include <irefcnt.hpp>
  23. #include <istring.hpp>
  24.  
  25. #pragma implementation("istrgen.c")
  26. #pragma pack(4)
  27.  
  28.  
  29. template < class T >
  30. class IStringGeneratorFn : public IRefCounted {
  31.  
  32. typedef IRefCounted
  33.   Inherited;
  34.  
  35. public:
  36.  
  37.   IStringGeneratorFn  ( ){}
  38.  
  39. virtual
  40.  ~IStringGeneratorFn  ( ){}
  41.  
  42. /*------------------------- Generate String ----------------------------------*/
  43. virtual IString
  44.   stringFor           ( const T& object ) = 0;
  45.  
  46. private:
  47. /*------------------------- Hidden Members -----------------------------------*/
  48.   IStringGeneratorFn  ( const IStringGeneratorFn<T>& generatorFunction );
  49.  
  50. IStringGeneratorFn<T>
  51.  &operator=           ( const IStringGeneratorFn<T>& generatorFunction );
  52.  
  53. }; // class IStringGeneratorFn<T>
  54.  
  55.  
  56.  
  57.  
  58.  
  59. template < class T >
  60. class IStringGeneratorMemberFn : public IStringGeneratorFn<T> {
  61.  
  62. typedef IStringGeneratorFn<T>
  63.   Inherited;
  64.  
  65. public:
  66. /*------------------------- Constructors -------------------------------------*/
  67.   IStringGeneratorMemberFn ( IString ( T::* member )( ) );
  68.  
  69. virtual
  70.  ~IStringGeneratorMemberFn ( );
  71.  
  72. /*------------------------- Generate String ----------------------------------*/
  73. virtual IString
  74.   stringFor                ( const T& object );
  75.  
  76. private:
  77. /*------------------------- Hidden Members -----------------------------------*/
  78.   IStringGeneratorMemberFn ( const IStringGeneratorMemberFn<T>&
  79.                                 generatorMemberFunction );
  80.  
  81. IStringGeneratorMemberFn<T>
  82.  &operator=                ( const IStringGeneratorMemberFn<T>&
  83.                                 generatorMemberFunction );
  84.  
  85. /*------------------------- Private ------------------------------------------*/
  86.  
  87. IString ( T::
  88.  *memberFunction )( );
  89.  
  90. }; // IStringGeneratorMemberFn<T>
  91.  
  92.  
  93.  
  94.  
  95.  
  96. template < class T, class U>
  97. class IStringGeneratorRefMemberFn : public IStringGeneratorFn<T> {
  98.  
  99. typedef IStringGeneratorFn<T>
  100.   Inherited;
  101.  
  102. public:
  103. /*------------------------- Constructors -------------------------------------*/
  104.   IStringGeneratorRefMemberFn ( IString ( U :: *member )( ) );
  105.  
  106. virtual
  107.  ~IStringGeneratorRefMemberFn ( );
  108.  
  109. /*------------------------- Generate String ----------------------------------*/
  110. virtual IString
  111.   stringFor                   ( const T& object );
  112.  
  113. private:
  114. /*------------------------- Hidden Members -----------------------------------*/
  115.   IStringGeneratorRefMemberFn ( const IStringGeneratorRefMemberFn<T,U>&
  116.                                    generatorRefMemberFunction );
  117.  
  118. IStringGeneratorRefMemberFn<T,U>
  119.  &operator=                   ( const IStringGeneratorRefMemberFn<T,U>&
  120.                                    generatorRefMemberFunction );
  121.  
  122. /*------------------------- Private ------------------------------------------*/
  123. IString ( U::
  124.  *memberFunction )( );
  125. }; // IStringGeneratorRefMemberFn<T,U>
  126.  
  127.  
  128.  
  129.  
  130.  
  131. template <class Element> class IStringGenerator : public IBase {
  132.  
  133. typedef IBase
  134.   Inherited;
  135.  
  136. public:
  137. /*------------------------- Constructors -------------------------------------*/
  138.   IStringGenerator ( const IReference< IStringGeneratorFn<Element> >&
  139.                                                       generatorFunction = 0 );
  140.  
  141.   IStringGenerator ( const IStringGenerator<Element>& stringGenerator );
  142.  
  143. IStringGenerator<Element>
  144.  &operator=        ( const IStringGenerator<Element>& stringGenerator );
  145.  
  146. virtual
  147.  ~IStringGenerator ( );
  148.  
  149. /*------------------------- Generate String ----------------------------------*/
  150. IString
  151.   stringFor        ( const Element& element ) const;
  152.  
  153. private:
  154. /*------------------------- Private ------------------------------------------*/
  155. IReference < IStringGeneratorFn<Element> >
  156.   fgeneratorFunction;
  157.  
  158. }; // IStringGenerator<Element>
  159.  
  160. #if ! defined (__TEMPINC__)
  161. #include <istrgen.c>
  162. #endif
  163.  
  164.  
  165. #pragma pack()
  166.  
  167. #endif  /* _ISTRGEN_ */
  168.