Blame view

morfeusz/DictionariesRepository.hpp 1.67 KB
Michał Lenart authored
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* 
 * File:   DictionariesRepository.hpp
 * Author: lennyn
 *
 * Created on August 8, 2014, 3:49 PM
 */

#ifndef DICTIONARIESREPOSITORY_HPP
#define	DICTIONARIESREPOSITORY_HPP

#include "morfeusz2.h"
#include "Dictionary.hpp"
#include "const.hpp"
#include <map>
#include <string>
Michał Lenart authored
16
#include <list>
Michał Lenart authored
17
18
19
20
21

namespace morfeusz {

    class DictionariesRepository {
    public:
Michał Lenart authored
22
23
24

        DictionariesRepository();
Michał Lenart authored
25
26
        const Dictionary* getDictionary(const std::string& name, MorfeuszProcessorType processorType);
Michał Lenart authored
27
        const Dictionary* getDefaultDictionary(MorfeuszProcessorType processorType);
Michał Lenart authored
28
Michał Lenart authored
29
30
        static std::string getDictionaryFilename(const std::string& name, MorfeuszProcessorType processorType);
Michał Lenart authored
31
        static DictionariesRepository& getInstance();
Michał Lenart authored
32
33

    private:
Michał Lenart authored
34
35

        struct RepositoryEntry {
Michał Lenart authored
36
            RepositoryEntry(): analyzerDictionary(NULL), generatorDictionary(NULL) {}
Michał Lenart authored
37
38
            Dictionary* analyzerDictionary;
            Dictionary* generatorDictionary;
Michał Lenart authored
39
            Dictionary* getDictionary(MorfeuszProcessorType processorType) const;
Michał Lenart authored
40
41
        };
Michał Lenart authored
42
43
44
45
46
47
48
49
50
        bool hasLoadedDictionary(const std::string& name, MorfeuszProcessorType processorType) const;

        bool tryToLoadDictionary(const std::string& name, MorfeuszProcessorType processorType);

        void doLoadDictionary(const std::string& dictName, const std::string& filepath, MorfeuszProcessorType processorType);

        static std::map<std::string, DictionariesRepository::RepositoryEntry> getDefaultEntriesMap();
Michał Lenart authored
51
52
53
54
55
56
        std::map<std::string, RepositoryEntry> entriesMap;
    };
}

#endif	/* DICTIONARIESREPOSITORY_HPP */