OSDN Git Service

データ構造決定記念バックアップ♪
[wordring-tm/wordring-tm.git] / proxy / tmservice.h
1 #ifndef TMSERVICE_H
2 #define TMSERVICE_H
3
4 #include "language.h"
5 #include "tmtext.h"
6 #include "tmdatabase.h"
7
8 #include <QObject>
9 #include <QString>
10 #include <QByteArray>
11 #include <QJsonArray>
12 #include <QMap>
13
14 #include <QIcon>
15
16 #include <QMutex>
17
18 QT_BEGIN_NAMESPACE
19 QT_END_NAMESPACE
20
21 class Language;
22 class Settings;
23
24 namespace TM
25 {
26
27 class Service : public QObject
28 {
29         Q_OBJECT
30 public:
31         Service(Settings *settings, QObject *parent = 0);
32         ~Service();
33
34         // CRC32
35         void setup_crc_table();
36         quint32 crc32(QString const &string);
37         quint32 crc32(int code, QString const &string);
38
39         // 言語プラグイン
40         void load_languages(QString const &path);
41
42         Text::pointer divide_into_sentences(int code, QString string);
43         Text::pointer divide_into_words(int code, Text::pointer sentence);
44
45         // データベース
46         quint32 find_site_id(QString host_name);
47
48         void insert_sentence(quint32 site_id, int scode, int tcode,
49                         TextSentence::pointer sentence, quint32 previous_crc, quint32 next_crc);
50
51         void find_sentence(quint32 site_id, int scode, int tcode,
52                                 Text::pointer ssentence, Database::sentence_callback callback);
53 private:
54         sentence_data_type::pointer stuff_sentence_data(int code, Text::pointer text);
55 public:
56 signals:
57         /*!
58          * \brief 言語プラグインが読み込まれたときに発火するシグナルです。
59          * \param code 言語コードです。
60          * \param name 言語名です。
61          * \param icon 言語を表現するアイコンです。
62          */
63         void languageLoaded(int code, QString name, QIcon icon);
64
65 public slots:
66
67 public:
68         QMutex m_mutex;
69
70         Settings *m_settings;
71
72         quint32 m_crc_table[256];
73
74         QMap<int, Language*> m_languages;
75
76         QThread *m_database_thread;
77         Database *m_database;
78 };
79
80 } // namespace TM
81
82 #endif // TMSERVICE_H