diff options
author | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-03-20 00:49:10 +0400 |
---|---|---|
committer | Tetsuo Kiso <tetsuo-s@is.naist.jp> | 2012-03-20 00:49:10 +0400 |
commit | 8987fed667c8c7cedfb714b28a061fb7b8030d6c (patch) | |
tree | 153d8406fcf4b558e952fc00b7c9a1b2403c9d49 /mert/Vocabulary.cpp | |
parent | 1678ee37695a94e237b1ca1d07a22373a0f3a0cb (diff) |
Add thread unsafe Singleton class.
- Add Vocabulary factory and the unit test.
- Remove Scorer::ClearVocabulary().
Diffstat (limited to 'mert/Vocabulary.cpp')
-rw-r--r-- | mert/Vocabulary.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mert/Vocabulary.cpp b/mert/Vocabulary.cpp new file mode 100644 index 000000000..40b04bf99 --- /dev/null +++ b/mert/Vocabulary.cpp @@ -0,0 +1,21 @@ +#include "Vocabulary.h" +#include "Singleton.h" + +namespace mert { +namespace { +Vocabulary* g_vocab = NULL; +} // namespace + +Vocabulary* VocabularyFactory::GetVocabulary() { + if (g_vocab == NULL) { + return Singleton<Vocabulary>::GetInstance(); + } else { + return g_vocab; + } +} + +void VocabularyFactory::SetVocabulary(Vocabulary* vocab) { + g_vocab = vocab; +} + +} // namespace mert |