// ========================================================================================
// IMPORTANT: You should not edit this file
// ========================================================================================

#ifndef _JOB_H_
#define _JOB_H_

#include "timestamp.h"

// The Job class holds all necessary information about each student
// autograding submission.  A Job object with an empty string for the
// course is used to represent an idle processor.

class Job {
public:
  // CONSTRUCTORS
  Job() : name("") {}
  Job(const std::string &course, const std::string &gradeable, const std::string &username,
      const TimeStamp &upload_time, int p, int m, int a) : 
    name(course+"_"+gradeable+"_"+username), needed_processors(p),
    maximum_runtime(m), actual_runtime(a), upload(upload_time) {}
  
  // ACCESSORS
  const std::string& getName() const { return name; }
  int getNeededProcessors() const { assert (name != ""); return needed_processors; }
  int getMaximumRuntime() const { assert (name != ""); return maximum_runtime; }
  const TimeStamp& getUploadTime() const { assert (name != ""); return upload; }
  const TimeStamp& getStartTime() const { assert (name != ""); return start; }
  const TimeStamp& getFinishTime() const { assert (name != ""); return finish; }
  
  int waiting_time() const { assert (name != ""); return elapsed(upload, start); }
  int grading_time() const { assert (name != ""); return elapsed(start, finish); }
  
  // MODIFIER
  void startGrading(const TimeStamp &s) { assert (name != "");
    start = s; finish = s; finish.addTime(actual_runtime); }
  
private:
  // REPRESENTATION
  std::string name;
  int needed_processors;
  int maximum_runtime;
  int actual_runtime;
  TimeStamp upload;
  TimeStamp start;
  TimeStamp finish;
};

#endif
