home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / ibmcli / ithecmd.hp_ / ITHECMD.HPP
Encoding:
C/C++ Source or Header  |  1992-10-26  |  2.5 KB  |  70 lines

  1. #ifndef _ITHECMD_
  2.   #define _ITHECMD_
  3. /**************************************************************/
  4. /* CLASS NAME:  ITheCommand                                   */
  5. /*                                                            */
  6. /* DESCRIPTION  : This is the abstract base class used to     */
  7. /*                create do, undo and redo command object.    */
  8. /*                                                            */
  9. /* Hungarian is tc                                            */
  10. /*                                                            */
  11. /* CHANGE ACTIVITY:                                           */
  12. /*   DATE:     INITIAL:        DESCRIPTION                    */
  13. /*                                                            */
  14. /*   081092    Kevin Leong     Design/code                    */
  15. /*                                                            */
  16. /**************************************************************/
  17. /* Copyright (c) IBM Corporation 1991                         */
  18. /**************************************************************/
  19. #ifndef _IBASETYP_
  20.   #include <ibasetyp.hpp>
  21. #endif
  22.  
  23. class ITheCommand
  24. {
  25.   public:
  26.  
  27.     ITheCommand();
  28.     virtual ~ITheCommand() {;}
  29.  
  30.     virtual void doIt() = 0;
  31.     virtual void undoIt();
  32.     virtual void redoIt();
  33.  
  34.     static ITheCommand* const theLastCommand();
  35.     static void setLastCommand(ITheCommand* lastCmd);
  36.     static void undoLastCommand();
  37.     static void redoLastCommand();
  38.  
  39.     enum State { done=1, undone=2, redone=4 };
  40.     Boolean isState(State s) const;
  41.     void setState(State s);
  42.  
  43.   private:
  44.  
  45.     unsigned long flState;
  46. };
  47.  
  48. inline ITheCommand::ITheCommand()
  49. /**************************************************************/
  50. /* Construct.                                                 */
  51. /**************************************************************/
  52.   : flState(0)
  53. {;}
  54.  
  55. inline Boolean ITheCommand::isState(State s) const
  56. /**************************************************************/
  57. /* Is the state TRUE?                                         */
  58. /**************************************************************/
  59. { return (flState & s) ? true : false; }
  60.  
  61. inline void ITheCommand::setState(State s)
  62. /**************************************************************/
  63. /* Set the object state.                                      */
  64. /**************************************************************/
  65. {
  66.   flState = 0;
  67.   flState |= s;
  68. }
  69. #endif /* _ITHECMD_ */
  70.