#ifndef __TASK_HPP__ #define __TASK_HPP__ #include #include /** * Note that Task doesn't have any data members that can't be * copied safely, so doesn't need the copy and move constructors * and assignment operators. They are included here only so we * can add output statements to them to see when they are called. */ namespace todo { class Task { public: /** * Creates an uncompleted task with a zero time estimate and empty * description. (Needed so we can have arrays of Tasks w/o bothering * with array initializers; when we start with STL we can replace * our arrays with vectors, which does away with the need to have * this default constructor. */ Task(); #ifdef SHOW_COPY_MOVE_CALLS /** * Creates a copy of the given task */ Task(const Task& toCopy); /** * Creates a task by moving data from the given task. */ Task(Task&& toMove); /** * Makes this task a copy of the given task. * * @param rhs a task * @return this task */ Task& operator=(const Task& rhs); /** * Moves the data from the given task into this task. * The given task is left in a valid but arbitrary state. * * @param rhs a task * @return this task */ Task& operator=(Task&& rhs); #endif /** * Creates an uncompleted task with the given description and * estimated completion time. * * @param d a string * @param t a positive integer */ Task(const std::string& d, int t); /** * Marks this task as completed. */ void complete(); /** * Reports whether this task has been completed. * * @return true if and only if this task has been completed */ bool isCompleted() const; /** * Outputs a printable representation of this task to the given * stream. * * @param os a stream */ void print(std::ostream& os) const; /** * Returns the estimated time for this task. * * @return the estimated time */ int time() const; private: std::string description; int estimatedTime; bool completed; }; } #endif