/ Published in: C++
Expand |
Embed | Plain Text
/*----scheduler.h----------------------------------------------------- This header file defines a Scheduler data type. Basic Operations include: constructor: Constructs a schedule empty: checks if there are no tasks scheduled display: Displays tasks in the schedule first: accesses first task copy constructor: copies the given schedule destructor: Deletes the schedule after execution of program insert: inserts a task into the schedule delete: deletes a task in the schedule ---------------------------------------------------------------------*/ #include <iostream> using namespace std; #ifndef SCHEDULER #define SCHEDULER typedef int Element; class Scheduler { public: class Task; typedef Task *TaskPointer; //function members //constructor Scheduler(); /*------------------------------------------------------------------- Constructs scheduler object. first_task initialized to a null pointer --------------------------------------------------------------------*/ ~Scheduler(); //Class Destructor /********Copy Constructor******/ Scheduler(const Scheduler & origSched); /******Assignment******/ const Scheduler & operator=(const Scheduler & rightHandSide); /******Empty Function****/ bool empty() const; //checks if stack is empty. Returns true/false. /*******Insert Function*****/ void insert(TaskPointer t, const int &thePT); /********First Function*******/ Element first() const; /********Delete Function********/ /*********Display Function*****/ void display(ostream &out) const; /***********Accessor Function****/ int getCounter() const; /***********Mutator Function*****/ void incCounter(); //increments counter by 1 when adding a task void decCounter(); //decrements counter by 1 when removing a task private: int counter; // Counts the number of tasks in the Scheduler TaskPointer first_task; //points to first task class Task { public: /**********Accessor Functions*****/ int getID() const{ return ID;} int getPT() const{ return PT;} Task* getLink() const { return next;} Task * next; //Task constructor Task(){} Task(int ID_val, int PT_val, Task *nextLink = 0) : ID(ID_val), PT(PT_val), next(nextLink) {} void setNextTask(Task* pointer){ next = pointer; } Element ID; Element PT; }; }; //------ Prototype of output operator ostream & operator<< (ostream &out, const Scheduler & aScheduler); #endif
You need to login to post a comment.
