Unity Scopes API
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 #pragma once
20 
21 #include <unity/scopes/Variant.h>
22 #include <unity/util/DefinesPtrs.h>
23 #include <list>
24 #include <string>
25 #include <memory>
26 
27 namespace unity
28 {
29 
30 namespace scopes
31 {
32 
33 class Department;
34 class CannedQuery;
35 
36 namespace internal
37 {
38 class DepartmentImpl;
39 }
40 
44 typedef std::list<std::shared_ptr<Department const>> DepartmentList;
45 
49 class Department final
50 {
51 public:
53  UNITY_DEFINES_PTRS(Department);
55 
64  static Department::UPtr create(CannedQuery const& query, std::string const& label);
65 
77  static Department::UPtr create(std::string const& department_id, CannedQuery const& query, std::string const& label);
78 
82  //{@
83  Department(Department const& other);
85  Department& operator=(Department const& other);
86  Department& operator=(Department&&);
88 
90  ~Department();
92 
97  void set_subdepartments(DepartmentList const& departments);
98 
103  void add_subdepartment(Department::SCPtr const& department);
104 
113  void set_alternate_label(std::string const& label);
114 
125  void set_has_subdepartments(bool subdepartments = true);
126 
131  std::string id() const;
132 
137  std::string label() const;
138 
148  std::string alternate_label() const;
149 
154  CannedQuery query() const;
155 
160  DepartmentList subdepartments() const;
161 
166  bool has_subdepartments() const;
167 
169  VariantMap serialize() const;
171 
172 private:
173  Department(internal::DepartmentImpl *impl);
174  std::unique_ptr<internal::DepartmentImpl> p;
175  friend class internal::DepartmentImpl;
176 };
177 
178 } // namespace scopes
179 
180 } // namespace unity
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:44
Top-level namespace for all things Unity-related.
Definition: Version.h:49
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:38
Definition: ActionMetadata.h:31
A department with optional sub-departments.
Definition: Department.h:49
Parameters of a search query.
Definition: CannedQuery.h:49
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