Your Ad Here

Posted By

Axon on 03/18/10


Tagged


Versions (?)

h file 1


 / Published in: C++
 

  1. /*----scheduler.h-----------------------------------------------------
  2.  
  3.   This header file defines a Scheduler data type.
  4.   Basic Operations include:
  5. constructor: Constructs a schedule
  6. empty: checks if there are no tasks scheduled
  7. display: Displays tasks in the schedule
  8. first: accesses first task
  9. copy constructor: copies the given schedule
  10. destructor: Deletes the schedule after execution of program
  11. insert: inserts a task into the schedule
  12. delete: deletes a task in the schedule
  13. ---------------------------------------------------------------------*/
  14.  
  15. #include <iostream>
  16. using namespace std;
  17.  
  18. #ifndef SCHEDULER
  19. #define SCHEDULER
  20.  
  21. typedef int Element;
  22.  
  23.  
  24. class Scheduler
  25. {
  26.  
  27. public:
  28. class Task;
  29. typedef Task *TaskPointer;
  30. //function members
  31. //constructor
  32. Scheduler();
  33. /*-------------------------------------------------------------------
  34.   Constructs scheduler object. first_task initialized to a null pointer
  35.   --------------------------------------------------------------------*/
  36.  
  37. ~Scheduler(); //Class Destructor
  38. /********Copy Constructor******/
  39. Scheduler(const Scheduler & origSched);
  40.  
  41. /******Assignment******/
  42. const Scheduler & operator=(const Scheduler & rightHandSide);
  43.  
  44. /******Empty Function****/
  45. bool empty() const; //checks if stack is empty. Returns true/false.
  46.  
  47. /*******Insert Function*****/
  48. void insert(TaskPointer t, const int &thePT);
  49.  
  50. /********First Function*******/
  51. Element first() const;
  52.  
  53. /********Delete Function********/
  54.  
  55. /*********Display Function*****/
  56. void display(ostream &out) const;
  57.  
  58. /***********Accessor Function****/
  59. int getCounter() const;
  60.  
  61. /***********Mutator Function*****/
  62. void incCounter(); //increments counter by 1 when adding a task
  63. void decCounter(); //decrements counter by 1 when removing a task
  64.  
  65. private:
  66. int counter; // Counts the number of tasks in the Scheduler
  67. TaskPointer first_task; //points to first task
  68. class Task
  69. {
  70. public:
  71. /**********Accessor Functions*****/
  72. int getID() const{
  73. return ID;}
  74.  
  75. int getPT() const{
  76. return PT;}
  77.  
  78. Task* getLink() const {
  79. return next;}
  80.  
  81. Task * next;
  82. //Task constructor
  83. Task(){}
  84. Task(int ID_val, int PT_val, Task *nextLink = 0)
  85. : ID(ID_val), PT(PT_val), next(nextLink)
  86. {}
  87.  
  88. void setNextTask(Task* pointer){
  89. next = pointer;
  90. }
  91.  
  92.  
  93. Element ID;
  94. Element PT;
  95.  
  96.  
  97. };
  98. };
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. //------ Prototype of output operator
  106. ostream & operator<< (ostream &out, const Scheduler & aScheduler);
  107.  
  108. #endif

Report this snippet  

You need to login to post a comment.