Add s alternative
[FreeRecite.git] / src / Task.h
blobe0a70ad132c34f6971b23d8e09a06bd817d79a19
1 /**
2 * FileName: Task.h
3 * Used to define the class Task which is used to indicate the status about
4 * the user's reciting process.
6 * Copyright (C) 2008 Kermit Mei (中文名:梅延涛).
7 * All Rights Reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation.
23 * Written by Kermit Mei <kermit.mei@gmail.com>
25 * Many of the ideas implemented here are from the author's experiment.
26 * But the dictionary's format coincide with the other word recite software
27 * to help the users get more available data. And the review times designed
28 * by means of the theory named Forgetting Curve which dicoveried by the
29 * German psychologist named Hermann Ebbinghaus(1850–1909).
31 **/
33 #ifndef TASK_H
34 #define TASK_H
36 #include <ctime>
37 #include <iostream>
39 namespace freeRecite {
41 class Task
43 public:
44 Task(time_t initID = 0,
45 const char *initName = 0);
46 ~Task();
48 friend std::istream & operator>>(std::istream &, Task &);
49 friend std::ostream & operator<<(std::ostream &, const Task &);
50 friend bool operator>(const Task&, const Task&);
51 friend bool operator<(const Task&, const Task&);
52 friend bool operator==(const Task&, const Task&);
54 time_t getID() const;
55 time_t getReviewTime() const;
56 int getStep() const;
57 const std::string &getName() const;
58 bool shouldReview() const;
59 bool hasFinished() const;
60 bool isAvailable() const;
62 bool test(int mark);
63 private:
64 time_t id;
65 time_t reviewTime;
66 int step;
67 std::string name;
70 inline
71 Task::Task(time_t initID, const char *initName)
72 :id(initID),reviewTime(0),step(0)
74 if(initName != 0)
75 name = initName;
78 inline
79 time_t Task::getID() const {
80 return id;
83 inline
84 time_t Task::getReviewTime() const {
85 return reviewTime;
88 inline
89 int Task::getStep() const {
90 return step;
93 inline
94 const std::string &Task::getName() const {
95 return name;
98 inline
99 bool Task::hasFinished() const {
100 return step == 8;
103 inline
104 bool Task::isAvailable() const {
105 return id == 0 ? false : true;
108 } //namespace freeRecite end
111 #endif