V0.01 beat3
[FreeRecite.git] / Manager.h
blob2b710bfc3d469d901b3b8bfdf7249e8363645e94
1 /**
2 * FileName: Manager.h.
3 * Used to define the class Manager which is used to handle the tasks.
5 * Copyright (C) 2008 Kermit Mei (中文名:梅延涛).
6 * All Rights Reserved.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation.
22 * Written by Kermit Mei <kermit.mei@gmail.com>
24 * Many of the ideas implemented here are from the author's experiment.
25 * But the dictionary's format coincide with the other word recite software
26 * to help the users get more available data. And the review times designed
27 * by means of the theory named Forgetting Curve which dicoveried by the
28 * German psychologist named Hermann Ebbinghaus(1850–1909).
30 **/
33 #ifndef MANAGER_H
34 #define MANAGER_H
36 #include <list>
37 #include <map>
38 #include <vector>
40 #include "Task.h"
42 namespace freeRecite {
44 class Manager
46 public:
47 //Read the information from freeRecite.mgr file.
48 //If the loadfile can not be read, it returns false.
49 bool load(const std::string &dir);
51 //Save the information to freeRecite.mgr file.
52 bool save();
54 //Refresh the Manager information.
55 bool refresh();
57 //Test whether this task ID is available.
58 bool hasTask(time_t taskID);
60 //Get the task's name.
61 const std::string &getTaskName(time_t taskID)const;
63 //Get the amount of the words from a task.
64 int getTaskAmount(time_t taskID) const;
66 //Get the step of the task.
67 int getTaskStep(time_t taskID) const;
69 //Creat a new task with the words set.
70 bool creatTask(const std::set<std::string> &words,
71 const char *taskName = 0);
72 //Get the number of the tasks that should be reviewed.
73 int getActiveTaskNum() const;
75 //Get the default directory.
76 const std::string &getDir() const;
78 /**
79 * Get a point to the Task which is active.
80 **/
81 const std::vector<time_t> &getActiveTasks() const;
83 // Call this method will add one to the task's words amount.
84 void addWord(time_t taskID);
86 // Call this method will subtract one from task's words amount.
87 void removeWord(time_t taskID);
89 /**
90 * This method is used to test whether the mark you got can pass
91 * this test. If you pass it, the task will come to the next step,
92 * else it won't.
94 * Return Value:
95 * true: If you can pass it.
96 * false: If you can't pass it.
98 * After calling this method, itr will point to the tested Task
99 * object, see Task::test() for more information.
101 bool test(time_t taskID,int mark);
102 private:
104 * mgrDir is the directory where default freeRecite.mgr
105 * file is saved. This file name is set by default, and
106 * anyone can NOT modify it at Run-time,including that
107 * they can't creat a file with this name under the same
108 * directory.
110 std::string mgrDir;
111 std::map<time_t,Task> allTasks;
112 std::vector<time_t> activeID;
114 static const std::string managerFile;
117 inline
118 const std::string &Manager::getDir() const {
119 return mgrDir;
133 } //namaspace freeRecite end
135 #endif