librime: schema.h Source File

| librime 1.2 Rime Input Method Engine, the core library

schema.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2011-04-24 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_SCHEMA_H_
8#define RIME_SCHEMA_H_
9
10#include <rime/common.h>
11#include <rime/config.h> // for convenience
12
13namespace rime {
14
15 class Schema {
16 public:
17 Schema();
18 explicit Schema(const string& schema_id);
19 Schema(const string& schema_id, Config* config)
20 : schema_id_(schema_id), config_(config) {}
21
22 const string& schema_id() const { return schema_id_; }
23 const string& schema_name() const { return schema_name_; }
24
25 Config* config() const { return config_.get(); }
26 void set_config(Config* config) { config_.reset(config); }
27
28 int page_size() const { return page_size_; }
29 bool page_down_cycle() const { return page_down_cycle_; }
30 const string& select_keys() const { return select_keys_; }
31 void set_select_keys(const string& keys) { select_keys_ = keys; }
32
33 private:
34 void FetchUsefulConfigItems();
35
36 string schema_id_;
37 string schema_name_;
38 the<Config> config_;
39 // frequently used config items
40 int page_size_ = 5;
41 bool page_down_cycle_ = false;
42 string select_keys_;
43};
44
45 class SchemaComponent : public Config::Component {
46 public:
47 SchemaComponent(Config::Component* config_component)
48 : config_component_(config_component) {}
49 // NOTE: creates `Config` for the schema
50 Config* Create(const string& schema_id) override;
51
52 private:
53 // we do not own the config component, do not try to deallocate it
54 // also be careful that there is no guarantee it will outlive us
55 Config::Component* config_component_;
56};
57
58} // namespace rime
59
60#endif // RIME_SCHEMA_H_
common.h
config.h
rime
Definition algebra.cc:12
rime::the
std::unique_ptr< T > the
Definition common.h:58
rime::Config
Definition config_component.h:21
rime::Schema::Schema
Schema()
Definition schema.cc:12
rime::Schema::set_config
void set_config(Config *config)
Definition schema.h:26
rime::Schema::select_keys
const string & select_keys() const
Definition schema.h:30
rime::Schema::config
Config * config() const
Definition schema.h:25
rime::Schema::schema_id
const string & schema_id() const
Definition schema.h:22
rime::Schema::schema_name
const string & schema_name() const
Definition schema.h:23
rime::Schema::page_size
int page_size() const
Definition schema.h:28
rime::Schema::Schema
Schema(const string &schema_id, Config *config)
Definition schema.h:19
rime::Schema::set_select_keys
void set_select_keys(const string &keys)
Definition schema.h:31
rime::Schema::page_down_cycle
bool page_down_cycle() const
Definition schema.h:29
rime::SchemaComponent::Create
Config * Create(const string &schema_id) override
Definition schema.cc:40
rime::SchemaComponent::SchemaComponent
SchemaComponent(Config::Component *config_component)
Definition schema.h:47