home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / include / MotifApp / InterruptibleCmd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-17  |  2.2 KB  |  65 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. //////////////////////////////////////////////////////////////
  22. // InterruptibleCmd.h: Abstract class that supports lengthy,
  23. //                     user-interruptible activities
  24. //////////////////////////////////////////////////////////////
  25. #ifndef INTERRUPTIBLECMD_H
  26. #define INTERRUPTIBLECMD_H
  27. #include <Xm/Xm.h>
  28. #include "NoUndoCmd.h"
  29.  
  30. // Define a type for the callback invoked when the task is finished
  31.  
  32. class InterruptibleCmd;
  33.  
  34. typedef void (*TaskDoneCallback) ( InterruptibleCmd *, Boolean, void * );
  35.  
  36. class InterruptibleCmd : public NoUndoCmd {
  37.     
  38.   private:
  39.     
  40.     XtWorkProcId     _wpId;         // The ID of the workproc
  41.     TaskDoneCallback _callback;     // Application-defined callback
  42.     void            *_clientData;
  43.     Boolean workProc ();
  44.     static Boolean  workProcCallback ( XtPointer );
  45.     static void     interruptCallback ( void * );
  46.     void interrupt(); 
  47.     
  48.   protected:
  49.     
  50.     Boolean      _done;         // TRUE if the task has been completed
  51.     virtual void cleanup();     // Called when task ends
  52.     virtual void updateMessage ( char * );
  53.     
  54.     // Derived classes must implement doit(), declared by Cmd
  55.     
  56.   public:
  57.     
  58.     InterruptibleCmd ( char * , int );
  59.     virtual ~InterruptibleCmd();
  60.     
  61.     virtual void execute();  // Overrides base class member function
  62.     virtual void execute ( TaskDoneCallback, void * );
  63. };
  64. #endif
  65.