~zhangew401/scope-aggregator/fix-empty-query-to-clickstore

« back to all changes in this revision

Viewing changes to src/aggchildscope.cpp

  • Committer: Gary.Wzl
  • Date: 2016-06-30 05:00:45 UTC
  • mfrom: (163.1.12 4.8-local-hints)
  • Revision ID: gary.wang@canonical.com-20160630050045-2p38uwpqgkdnge1x
Tags: 4.8
1.compile time optimization for string(QStringLiteral).
2.load the various json files once aggregator scope startup.
3.specify 'const' keyword for some variable in some cases.
4.pass by reference instead of by value if possible.
5.don't allocated memory(make_shared) based on local variable to avoid copy constructor.
6 remove duplicate obj creation.
7.fix invalid pointer for us::Category::SCPtr when look_up is called.
8.remove redundant files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
namespace us = unity::scopes;
23
23
 
24
 
AggChildScope::AggChildScope(const std::string id) :
 
24
AggChildScope::AggChildScope(std::string const &id) :
25
25
    id_(id)
26
26
{
27
27
}
28
28
 
29
 
void AggChildScope::set_local_id(const std::string local_id)
 
29
void AggChildScope::set_local_id(std::string const &local_id)
30
30
{
31
31
    local_id_ = local_id;
32
32
}
33
33
 
34
 
std::string AggChildScope::local_id()
 
34
const std::string & AggChildScope::local_id() const
35
35
{
36
36
    return local_id_;
37
37
}
38
38
 
39
 
void AggChildScope::set_category_title(const std::string title_)
 
39
void AggChildScope::set_category_title(std::string const &title_)
40
40
{
41
41
    cat_title = title_;
42
42
}
43
43
 
44
 
std::string AggChildScope::category_title()
 
44
const std::string & AggChildScope::category_title() const
45
45
{
46
46
    return cat_title;
47
47
}
77
77
    return cat;
78
78
}
79
79
 
80
 
void AggChildScope::set_first_result_template(const std::string first_result_template)
81
 
{
82
 
    TEMPLATE_FIRST_RESULT = first_result_template;
83
 
}
84
 
 
85
 
std::string AggChildScope::first_result_template()
86
 
{
87
 
    return TEMPLATE_FIRST_RESULT;
88
 
}
89
 
 
90
 
void AggChildScope::set_surface_template(const std::string surface_template)
91
 
{
92
 
    TEMPLATE_SURFACE = surface_template;
93
 
}
94
 
 
95
 
std::string AggChildScope::surface_template()
96
 
{
97
 
    return TEMPLATE_SURFACE;
 
80
void AggChildScope::set_first_result_template(std::string const &first_result_template)
 
81
{
 
82
    template_first_result_ = first_result_template;
 
83
}
 
84
 
 
85
const std::string & AggChildScope::first_result_template() const
 
86
{
 
87
    return template_first_result_;
 
88
}
 
89
 
 
90
void AggChildScope::set_surface_template(std::string const &surface_template)
 
91
{
 
92
    template_surface_ = surface_template;
 
93
}
 
94
 
 
95
const std::string & AggChildScope::surface_template() const
 
96
{
 
97
    return template_surface_;
98
98
}
99
99
 
100
100
void AggChildScope::set_override_surface_template(bool b)
107
107
    return override_surface_template_;
108
108
}
109
109
 
110
 
std::string AggChildScope::search_template()
 
110
const std::string & AggChildScope::search_template() const
111
111
{
112
 
    return TEMPLATE_SEARCH;
 
112
    return template_search_;
113
113
}
114
114
 
115
 
void AggChildScope::set_search_template(const std::string search_template)
 
115
void AggChildScope::set_search_template(std::string const &search_template)
116
116
{
117
 
    TEMPLATE_SEARCH = search_template;
 
117
    template_search_ = search_template;
118
118
}
119
119
 
120
120
void AggChildScope::set_override_search_template(bool b)
127
127
    return override_search_template_;
128
128
}
129
129
 
130
 
void AggChildScope::set_child_department(const std::string id_)
 
130
void AggChildScope::set_child_department(std::string const &id_)
131
131
{
132
132
    subsearch_dept_id = id_;
133
133
}
134
134
 
135
 
std::string AggChildScope::child_department()
 
135
const std::string & AggChildScope::child_department() const
136
136
{
137
137
    return subsearch_dept_id;
138
138
}
139
139
 
140
 
void AggChildScope::set_department(const std::string id_)
 
140
void AggChildScope::set_department(std::string const &id_)
141
141
{
142
142
    dept_id = id_;
143
143
}
144
144
 
145
 
std::string AggChildScope::department()
 
145
const std::string & AggChildScope::department() const
146
146
{
147
147
    return dept_id;
148
148
}
149
149
 
150
 
void AggChildScope::set_child_category(const std::string category_id)
 
150
void AggChildScope::set_child_category(std::string const &category_id)
151
151
{
152
152
    category_id_ = category_id;
153
153
    using_category = true;
154
154
}
155
155
 
156
 
std::string AggChildScope::child_category()
 
156
const std::string & AggChildScope::child_category() const
157
157
{
158
158
    return category_id_;
159
159
}
184
184
    return cardinality_;
185
185
}
186
186
 
187
 
std::string AggChildScope::id()
 
187
const std::string & AggChildScope::id() const
188
188
{
189
189
    return id_;
190
190
}
199
199
    return using_category_link_to_child;
200
200
}
201
201
 
202
 
void AggChildScope::set_proxy(us::RegistryProxy registry)
 
202
void AggChildScope::set_proxy(us::RegistryProxy const &registry)
203
203
{
204
204
 
205
205
    auto scopes = registry->list();
222
222
    return scope_metadata_;
223
223
}
224
224
 
225
 
bool AggChildScope::enabled(const us::VariantMap settings)
 
225
bool AggChildScope::enabled(us::VariantMap const & settings)
226
226
{
227
227
    if (! settings.at(id()).get_bool())
228
228
    {
266
266
    return category_scope_;
267
267
}
268
268
 
269
 
void AggChildScope::set_category_id(std::string id)
 
269
void AggChildScope::set_category_id(std::string const &id)
270
270
{
271
271
    category_scope_id_ = id;
272
272
}
273
273
 
274
 
std::string AggChildScope::category_id()
 
274
const std::string & AggChildScope::category_id() const
275
275
{
276
276
    return category_scope_id_;
277
277
}
286
286
    return keyword_scope_;
287
287
}
288
288
 
289
 
void AggChildScope::set_keyword(std::string kw)
 
289
void AggChildScope::set_keyword(std::string const &kw)
290
290
{
291
291
    keyword_ = kw;
292
292
}
293
293
 
294
 
std::string AggChildScope::keyword()
 
294
const std::string & AggChildScope::keyword() const
295
295
{
296
296
    return keyword_;
297
297
}
298
298
 
299
 
void AggChildScope::set_keyword_scope_shared_cat_name(std::string cat)
 
299
void AggChildScope::set_keyword_scope_shared_cat_name(std::string const &cat)
300
300
{
301
301
    keyword_scope_shared_cat_name_ = cat;
302
302
    uses_shared_cat_ = true;
303
303
}
304
304
 
305
 
std::string AggChildScope::keyword_scope_shared_cat_name()
 
305
const std::string & AggChildScope::keyword_scope_shared_cat_name() const
306
306
{
307
307
    return keyword_scope_shared_cat_name_;
308
308
}
332
332
    return source_finder_;
333
333
}
334
334
 
335
 
void AggChildScope::set_first_common_template_id(std::string id)
 
335
void AggChildScope::set_first_common_template_id(std::string const &id)
336
336
{
337
337
    first_common_template_id_ = id;
338
338
}
339
339
 
340
 
std::string AggChildScope::first_common_template_id()
 
340
const std::string & AggChildScope::first_common_template_id() const
341
341
{
342
342
    return first_common_template_id_;
343
343
}
344
344
 
345
 
void AggChildScope::set_surface_common_template_id(std::string id)
 
345
void AggChildScope::set_surface_common_template_id(std::string const &id)
346
346
{
347
347
    surface_common_template_id_ = id;
348
348
}
349
349
 
350
 
std::string AggChildScope::surface_common_template_id()
 
350
const std::string & AggChildScope::surface_common_template_id() const
351
351
{
352
352
    return surface_common_template_id_;
353
353
}