Unity Scopes API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Department.h
1 /*
2  * Copyright (C) 2014 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Pawel Stolowski <pawel.stolowski@canonical.com>
17  */
18 
19 #ifndef UNITY_SCOPES_DEPARTMENT_H
20 #define UNITY_SCOPES_DEPARTMENT_H
21 
22 #include <unity/scopes/Variant.h>
23 #include <unity/util/DefinesPtrs.h>
24 #include <list>
25 #include <string>
26 #include <memory>
27 
28 namespace unity
29 {
30 
31 namespace scopes
32 {
33 
34 class Department;
35 class CannedQuery;
36 
37 namespace internal
38 {
39 class DepartmentImpl;
40 }
41 
45 typedef std::list<std::shared_ptr<Department const>> DepartmentList;
46 
50 class Department final
51 {
52 public:
54  UNITY_DEFINES_PTRS(Department);
56 
65  static Department::UPtr create(CannedQuery const& query, std::string const& label);
66 
78  static Department::UPtr create(std::string const& department_id, CannedQuery const& query, std::string const& label);
79 
83  //{@
84  Department(Department const& other);
86  Department& operator=(Department const& other);
87  Department& operator=(Department&&);
89 
91  ~Department();
93 
98  void set_subdepartments(DepartmentList const& departments);
99 
104  void add_subdepartment(Department::SCPtr const& department);
105 
114  void set_alternate_label(std::string const& label);
115 
126  void set_has_subdepartments(bool subdepartments = true);
127 
132  std::string id() const;
133 
138  std::string label() const;
139 
149  std::string alternate_label() const;
150 
155  CannedQuery query() const;
156 
161  DepartmentList subdepartments() const;
162 
167  bool has_subdepartments() const;
168 
170  VariantMap serialize() const;
172 
173 private:
174  Department(internal::DepartmentImpl *impl);
175  std::unique_ptr<internal::DepartmentImpl> p;
176  friend class internal::DepartmentImpl;
177 };
178 
179 } // namespace scopes
180 
181 } // namespace unity
182 
183 #endif
std::string label() const
Get the label of this department.
Definition: Department.cpp:97
void set_subdepartments(DepartmentList const &departments)
Set sub-departments of this department.
Definition: Department.cpp:77
std::string alternate_label() const
Get the alternate label of this department.
Definition: Department.cpp:102
std::string id() const
Get the identifier of this department.
Definition: Department.cpp:92
std::list< std::shared_ptr< Department const > > DepartmentList
List of departments (see unity::scopes::Department)
Definition: Department.h:45
Top-level namespace for all things Unity-related.
Definition: Version.h:50
bool has_subdepartments() const
Check if this department has subdepartments or has_subdepartments flag is set.
Definition: Department.cpp:112
std::map< std::string, Variant > VariantMap
A dictionary of (string, Variant) pairs.
Definition: Variant.h:39
Definition: ActionMetadata.h:32
A department with optional sub-departments.
Definition: Department.h:50
Parameters of a search query.
Definition: CannedQuery.h:46
static Department::UPtr create(CannedQuery const &query, std::string const &label)
Create a department with the given canned query and name.
CannedQuery query() const
Get the canned query associated with this department.
Definition: Department.cpp:107
DepartmentList subdepartments() const
Get list of sub-departments of this department.
Definition: Department.cpp:117
void set_has_subdepartments(bool subdepartments=true)
Sets has_subdepartments flag of this department.
Definition: Department.cpp:72
void add_subdepartment(Department::SCPtr const &department)
Add sub-department to this department.
Definition: Department.cpp:82
void set_alternate_label(std::string const &label)
Set the alternate label (plural of the normal label) of this department.
Definition: Department.cpp:87