home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / programming / dreamscape / source / Dreamscape / Headers / abstract / h / command < prev    next >
Encoding:
Text File  |  1996-07-17  |  1008 b   |  44 lines

  1.  
  2. // abstract.h.command
  3.  
  4. // Dreamscape - C++ class library for RISC OS
  5. // Copyright (c) 1996 Mark Seaborn <mseaborn@argonet.co.uk>
  6. //
  7. // This library is free software; you can redistribute it and/or
  8. // modify it under the terms of the GNU Library General Public
  9. // License as published by the Free Software Foundation; either
  10. // version 2 of the License, or (at your option) any later version.
  11. // See the Dreamscape documentation for more information.
  12.  
  13. #ifndef dreamscape_command_H
  14. #define dreamscape_command_H
  15.  
  16. #include "list.h"
  17.  
  18. class Command {
  19. public:
  20.   virtual void execute() = 0;
  21. };
  22.  
  23. class MultiCommand: public Command {
  24. public:
  25.   List<Command *> commands;
  26.   inline void execute();
  27. };
  28.  
  29. inline void MultiCommand::execute()
  30. {
  31.   for(ListIterator<Command *> l=commands.begin(); l!=commands.end(); ++l)
  32.     (*l)->execute();
  33. }
  34.  
  35. template <class Type>
  36. class DeleteObjectCommand: public Command {
  37.   Type *object;
  38. public:
  39.   DeleteObjectCommand(Type *o): object(o) {}
  40.   void execute() { delete object; }
  41. };
  42.  
  43. #endif
  44.