home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Apple Shared Library Manager / ASLM Examples / Example Tools / Sources / TSchedulerExample.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-19  |  2.1 KB  |  89 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        TSchedulerExample.h
  3.  
  4.     Contains:    Declaration of TReport, a TOperation subclass. TOperation objects
  5.                 contain the implementation of the task to be performed. This operation
  6.                 is placed in TPriorityScheduler, and TSerialScheduler to be performed
  7.                 at a requested time. TReport's operation is to display a grade report
  8.                 for a student.
  9.  
  10.     Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11.  
  12. */
  13.  
  14. #ifndef __TSCHEDULEREXAMPLE__
  15. #define __TSCHEDULEREXAMPLE__
  16.  
  17. ///————————————————————————————————————————————————————————————————————————————————————
  18. ///    CONSTANTS
  19. ///————————————————————————————————————————————————————————————————————————————————————
  20.  
  21. enum  Grade     {kNoGrade, kA, kB, kC, kD, kCredit, kF};
  22.  
  23. ///————————————————————————————————————————————————————————————————————————————————————
  24. ///    TReport
  25. ///————————————————————————————————————————————————————————————————————————————————————
  26.  
  27. class TReport : public TOperation {
  28.  
  29.     public:
  30.                         TReport();            // Constructor
  31.     virtual                ~TReport();            // Destructor
  32.     
  33.     virtual void         Process();            // Override
  34.  
  35.     // --- New Methods ---
  36.     
  37.             Grade        GetGrade() const;
  38.             void        SetGrade(Grade grade);
  39.             char*        GetStudent() const;
  40.             void        NewStudent(char *name);
  41.  
  42.     private:
  43.         char            fStudent[256];        // name of the student
  44.         Grade            fGrade;                // current grade
  45. };
  46.  
  47. ///————————————————————————————————————————————————————————————————————————————————————
  48. ///    TREPORT IMPLEMENTATION
  49. ///————————————————————————————————————————————————————————————————————————————————————
  50.  
  51.     inline Grade TReport::GetGrade() const
  52.     {
  53.         return fGrade;
  54.     }
  55.     
  56.     inline void TReport::SetGrade(Grade grade)
  57.     {
  58.         fGrade = grade;
  59.     }
  60.     
  61.     inline char* TReport::GetStudent() const
  62.     {
  63.         return fStudent;
  64.     }
  65.     
  66.     inline void TReport::NewStudent(char *name)
  67.     {
  68.         strcpy(fStudent, name );
  69.     }
  70.     
  71.     TReport::TReport()
  72.     {
  73.         *fStudent = 0;
  74.         fGrade = kNoGrade;
  75.     }
  76.  
  77.     TReport::~TReport()
  78.     {
  79.     }
  80.  
  81.     void TReport::Process()
  82.     {
  83.         cout << "Student: " << fStudent << "\t\t Grade: " << (char)('@'+fGrade) << endl;
  84.  
  85.         // delete the TReport so creator doesn't need to keep track of operation.
  86.         delete this;
  87.     }
  88.  
  89. #endif