unity.scopes.Department

A department with optional sub-departments. More...

#include <unity/scopes/Department.h>

Public Member Functions

void set_subdepartments (DepartmentList const &departments)
 Set sub-departments of this department. More...
 
void add_subdepartment (Department::SCPtr const &department)
 Add sub-department to this department. More...
 
void set_alternate_label (std::string const &label)
 Set the alternate label (plural of the normal label) of this department. More...
 
void set_has_subdepartments (bool subdepartments=true)
 Sets has_subdepartments flag of this department. More...
 
std::string id () const
 Get the identifier of this department. More...
 
std::string label () const
 Get the label of this department. More...
 
std::string alternate_label () const
 Get the alternate label of this department. More...
 
CannedQuery query () const
 Get the canned query associated with this department. More...
 
DepartmentList subdepartments () const
 Get list of sub-departments of this department. More...
 
bool has_subdepartments () const
 Check if this department has subdepartments or has_subdepartments flag is set. More...
 
Copy and assignment

Copy and assignment operators (move and non-move versions) have the usual value semantics.

 Department (Department const &other)
 
 Department (Department &&)
 
Departmentoperator= (Department const &other)
 
Departmentoperator= (Department &&)
 

Static Public Member Functions

static Department::UPtr create (CannedQuery const &query, std::string const &label)
 Create a department with the given canned query and name. More...
 
static Department::UPtr create (std::string const &department_id, CannedQuery const &query, std::string const &label)
 Create a department with the given department identifier, canned query, and name. More...
 

Detailed Description

A department with optional sub-departments.

Member Function Documentation

void unity::scopes::Department::add_subdepartment ( Department::SCPtr const &  department)

Add sub-department to this department.

Parameters
departmentThe subdepartment instance.
std::string unity::scopes::Department::alternate_label ( ) const

Get the alternate label of this department.

Return the alternate label of this department. The alternate label expresses the plural "all" form of the normal label. For example, if the normal label is "Books", then the alternate label is "All Books". Note that alternate label and can be empty - in that case the normal label should be displayed instead.

Returns
The alternate label.
static Department::UPtr unity::scopes::Department::create ( CannedQuery const &  query,
std::string const &  label 
)
static

Create a department with the given canned query and name.

The identifier of this department instance is that of the query instance (CannedQuery::department_id()).

Parameters
queryThe query (and associated parameters, such as filter state) to be executed when the user selects this department.
labelThe display name of this department.
static Department::UPtr unity::scopes::Department::create ( std::string const &  department_id,
CannedQuery const &  query,
std::string const &  label 
)
static

Create a department with the given department identifier, canned query, and name.

The canned query's target department identifier is updated with department_id. This constructor is convenient for creating multiple departments that use the same query and only need a different department identifier.

Parameters
department_idThe department identifier.
queryThe canned query (and associated parameters, such as filter state) to be executed when the user selects this department.
labelThe display name of this department.
bool unity::scopes::Department::has_subdepartments ( ) const

Check if this department has subdepartments or has_subdepartments flag is set.

Returns
true if this deparment has subdepartments or has_subdepartments flag is set
std::string unity::scopes::Department::id ( ) const

Get the identifier of this department.

Returns
The department identifier.
std::string unity::scopes::Department::label ( ) const

Get the label of this department.

Returns
The department label.
CannedQuery unity::scopes::Department::query ( ) const

Get the canned query associated with this department.

Returns
The canned query for this department.
void unity::scopes::Department::set_alternate_label ( std::string const &  label)

Set the alternate label (plural of the normal label) of this department.

The alternate label should express the plural "all" form of the normal label. For example, if the normal label is "Books", then the alternate label should be "All Books". The alternate label needs to be provided for the current department only.

Parameters
labelThe alternate label to display when showing plural form of this department's name.
void unity::scopes::Department::set_has_subdepartments ( bool  subdepartments = true)

Sets has_subdepartments flag of this department.

This flag is a display hint for the Shell that indicates if this department has sub-departments and as such should be displayed in a way that suggests further navigation to the user. Setting this flag is not needed when sub-departments have been added with set_subdepartments() method. Setting this flag to false after adding sub-departments with set_subdepartments() throws unity::LogicException.

Exceptions
unity::LogicExceptionif called with false after adding sub-departments with unity::scopes::Department::set_subdepartments()
void unity::scopes::Department::set_subdepartments ( DepartmentList const &  departments)

Set sub-departments of this department.

Parameters
departmentsThe list of sub-departments.
DepartmentList unity::scopes::Department::subdepartments ( ) const

Get list of sub-departments of this department.

Returns
The list of sub-departments.