home *** CD-ROM | disk | FTP | other *** search
- #ifndef _ITHECMD_
- #define _ITHECMD_
- /**************************************************************/
- /* CLASS NAME: ITheCommand */
- /* */
- /* DESCRIPTION : This is the abstract base class used to */
- /* create do, undo and redo command object. */
- /* */
- /* Hungarian is tc */
- /* */
- /* CHANGE ACTIVITY: */
- /* DATE: INITIAL: DESCRIPTION */
- /* */
- /* 081092 Kevin Leong Design/code */
- /* */
- /**************************************************************/
- /* Copyright (c) IBM Corporation 1991 */
- /**************************************************************/
- #ifndef _IBASETYP_
- #include <ibasetyp.hpp>
- #endif
-
- class ITheCommand
- {
- public:
-
- ITheCommand();
- virtual ~ITheCommand() {;}
-
- virtual void doIt() = 0;
- virtual void undoIt();
- virtual void redoIt();
-
- static ITheCommand* const theLastCommand();
- static void setLastCommand(ITheCommand* lastCmd);
- static void undoLastCommand();
- static void redoLastCommand();
-
- enum State { done=1, undone=2, redone=4 };
- Boolean isState(State s) const;
- void setState(State s);
-
- private:
-
- unsigned long flState;
- };
-
- inline ITheCommand::ITheCommand()
- /**************************************************************/
- /* Construct. */
- /**************************************************************/
- : flState(0)
- {;}
-
- inline Boolean ITheCommand::isState(State s) const
- /**************************************************************/
- /* Is the state TRUE? */
- /**************************************************************/
- { return (flState & s) ? true : false; }
-
- inline void ITheCommand::setState(State s)
- /**************************************************************/
- /* Set the object state. */
- /**************************************************************/
- {
- flState = 0;
- flState |= s;
- }
- #endif /* _ITHECMD_ */