update dict
[QFreeRecite.git] / src / core / ConfigHolder.h
blobc55831b67071b022d027a8cef48acce1700ed5f7
1 /**
2 * FileName: ConfigHolder.h
3 * Used to define the class ConfigHolder which is used to hold the config files.
5 * Copyright (C) 2008 Kermit Mei <kermit.mei@gmail.com>
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 version 3 as
10 * published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation.
21 * Written by Kermit Mei <kermit.mei@gmail.com>
23 * Many of the ideas implemented here are from the author's experiment.
24 * But the dictionary's format coincide with the other word recite software
25 * to help the users get more available data. And the review times designed
26 * by means of the theory named Forgetting Curve which dicoveried by the
27 * German psychologist named Hermann Ebbinghaus(1850–1909).
29 **/
31 #ifndef CONFIGHOLDER_H
32 #define CONFIGHOLDER_H
34 #include <string>
35 #include <vector>
37 namespace freeRecite {
39 class ConfigHolder;
40 extern ConfigHolder configHolder;
42 class ConfigHolder
44 public:
45 ConfigHolder();
46 void load(const char *rootDir, const char *globleDir,
47 const char *soundDir = 0);
48 void setRootDir(const char *dir);
49 void setGlobalDir(const char *dir);
50 void soundDir(const char *dir);
52 std::string rootDir() const;
53 std::string tasksDir() const;
54 std::string mgrFile() const;
55 std::string localDictFile() const;
56 std::string globalDictFile() const;
57 std::string keyFile() const;
58 std::string doneFile() const;
59 std::string soundDir() const;
60 std::string musicDir() const;
62 const std::vector<unsigned> *e_list();
63 const std::vector<unsigned> *r_list();
64 const std::vector<unsigned> *s_list();
65 const std::vector<unsigned> *t_list();
67 private:
68 std::string rootDirectory;
69 std::string globalDirectory;
70 std::string soundDirectory;
71 std::vector<unsigned> initPt;
74 inline
75 std::string ConfigHolder::doneFile() const {
76 #ifdef WIN32
77 return rootDirectory + "tasks\\done.txt";
78 #else
79 return rootDirectory + "tasks/done.txt";
80 #endif
83 inline
84 std::string ConfigHolder::rootDir() const {
85 return rootDirectory;
88 inline
89 std::string ConfigHolder::tasksDir() const {
90 #ifdef WIN32
91 return rootDirectory + "tasks\\";
92 #else
93 return rootDirectory + "tasks/";
94 #endif
97 inline
98 std::string ConfigHolder::mgrFile() const {
99 return rootDirectory + "freeRecite.mgr";
102 inline
103 std::string ConfigHolder::localDictFile() const {
104 return rootDirectory + "freeRecite.dict";
107 inline
108 std::string ConfigHolder::globalDictFile() const {
109 return globalDirectory + "freeRecite.dict";
112 inline
113 std::string ConfigHolder::keyFile() const {
114 return rootDirectory + "keystone.txt";
117 inline
118 std::string ConfigHolder::soundDir() const {
119 #ifdef WIN32
120 return soundDirectory;
121 #else
122 return soundDirectory;
123 #endif
126 inline
127 std::string ConfigHolder::musicDir() const {
128 #ifdef WIN32
129 return globalDirectory + "music\\";
130 #else
131 return globalDirectory + "music/";
132 #endif
135 }//End of namespace freeRecite.
137 #endif