home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / samples / visbuild / calculat / cppwv13 / icalcpu.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-16  |  3.8 KB  |  136 lines

  1. #ifndef _ICALCPU_
  2. #define _ICALCPU_
  3. /******************************************************************************
  4. * .FILE:        icalcpu.hpp                                                   *
  5. *                                                                             *
  6. * .DESCRIPTION: Header file for the class, ICalcPU                            *
  7. *                                                                             *
  8. * .CLASSES:     ICalcPU                                                       *
  9. *                                                                             *
  10. * .COPYRIGHT:                                                                 *
  11. *    Licensed Material - Program-Property of IBM                              *
  12. *    (C) Copyright IBM Corp. 1992, 1996 - All Rights Reserved                 *
  13. *                                                                             *
  14. * .DISCLAIMER:                                                                *
  15. *   The following [enclosed] code is sample code created by IBM               *
  16. *   Corporation.  This sample code is not part of any standard IBM product    *
  17. *   and is provided to you solely for the purpose of assisting you in the     *
  18. *   development of your applications.  The code is provided 'AS IS',          *
  19. *   without warranty of any kind.  IBM shall not be liable for any damages    *
  20. *   arising out of your use of the sample code, even if they have been        *
  21. *   advised of the possibility of such damages.                               *
  22. *                                                                             *
  23. * .NOTE: WE RECOMMEND USING A FIXED SPACE FONT TO LOOK AT THE SOURCE          *
  24. *                                                                             *
  25. ******************************************************************************/
  26.  
  27. #include <istring.hpp>
  28. #include <istdntfy.hpp>
  29. #include "ivbsamps.h"
  30.  
  31. //Forward declarations of other classes
  32.  
  33. class ICalcOperator;
  34. class ICalcFunction;
  35.  
  36.  
  37. //**************************************************************************
  38. // Class:   ICalcPU
  39. //
  40. // Purpose: Describes ICalcPU
  41. //   This is the Calculator Processing Unit Part
  42. //************************************************************************** */
  43.  
  44. class IVBSAMP_IMPORT ICalcPU : public IStandardNotifier
  45. {
  46. public:
  47.            ICalcPU                ();
  48.   virtual  ~ICalcPU ();
  49.  
  50. //
  51. // List of Part Events
  52. //
  53.  
  54. static INotificationId bufferId;
  55. static INotificationId evaluateId;
  56.  
  57. //
  58. // List of Part Attributes - (query and set members)
  59. //
  60.  
  61. virtual IString
  62.   buffer () const;
  63.  
  64. virtual ICalcPU&
  65.   setBuffer (const char * iBuffer);
  66.  
  67. //
  68. // List of Implementor Function Methods that are Part Actions
  69. //
  70.  
  71. virtual ICalcPU &
  72.   processOperatorResult (double iAccumulator);
  73.  
  74. virtual ICalcPU &
  75.   processDigit (IString iCurrentDigit);
  76.  
  77. virtual ICalcPU &
  78.   processOperator (ICalcOperator *iCurrentOp);
  79.  
  80. virtual ICalcPU &
  81.   processFunction (ICalcFunction *iCurrentFunc);
  82.  
  83. virtual double
  84.   evaluateOperation ();
  85.  
  86. virtual ICalcPU &
  87.   clearCalc ();
  88.  
  89. //
  90. // List of Implementor Function Methods that are not Part Actions
  91. //
  92.  
  93. virtual ICalcPU &
  94.   evaluateOperator ();
  95.  
  96. protected:
  97. //
  98. // List of enumeration types
  99. //
  100.  
  101. enum Register { none=-1, R1, R2 };
  102.  
  103. //
  104. // List of data members that are Attributes
  105. //
  106.  
  107.   IString dBuffer;   // Active Display
  108.  
  109.  
  110. //
  111. // List of Data Members that are not Attributes
  112. //
  113.  
  114.   double dRegisters[2];
  115.   unsigned long dCurrentReg;
  116.   Boolean dR2SetFromDisplay;
  117.   Boolean dExpectNewOperand;
  118.   ICalcOperator *dPendingOp;
  119.  
  120. //
  121. // List of Helping Function Methods that are not Part Actions
  122. //
  123.  
  124. virtual ICalcPU &
  125.   evaluateIt ();
  126.  
  127. virtual ICalcPU &
  128.   setDisplayFromAccumulator (double iAccumulator);
  129.  
  130. virtual ICalcPU &
  131.   setCurrentRegFromDisplay ();
  132.  
  133. };
  134.  
  135. #endif
  136.