unity.scopes.ActivationResponse

Response to a result activation. More...

#include <unity/scopes/ActivationResponse.h>

Public Types

enum  Status {
  NotHandled, ShowDash, HideDash, ShowPreview,
  PerformQuery, UpdateResult, UpdatePreview
}
 Status of a unity::scopes::ScopeBase::activate, unity::scopes::ScopeBase::perform_action, or unity::scopes::ScopeBase::activate_result_action request. More...
 

Public Member Functions

 ActivationResponse (Status status)
 Creates ActivationResponse with given status. More...
 
 ActivationResponse (CannedQuery const &query)
 Creates an ActivationResponse with status Status::PerformQuery and a search query to be executed. More...
 
 ActivationResponse (Result const &updated_result)
 Creates an ActivationResponse with status Status::UpdateResult and an updated result that replaces the original result of the action. More...
 
 ActivationResponse (PreviewWidgetList const &updated_widgets)
 Creates ActivationResponse with status Status::UpdatePreview and an updated list of preview widgets that replace the original widgets in the preview. Widgets not included in this list stay intact and are still displayed in the preview. Responding with this type of ActivationResponse outside of a preview context will not have any effect. More...
 
ActivationResponse::Status status () const
 Get activation status. More...
 
void set_scope_data (Variant const &data)
 Attach arbitrary data to this response. More...
 
Variant scope_data () const
 Get data attached to this response object. More...
 
CannedQuery query () const
 A query to be executed if status is Status::PerformQuery. More...
 
Result updated_result () const
 The updated result if status is Status::UpdateResult. More...
 
PreviewWidgetList updated_widgets () const
 The updated widgets if status is Status::UpdatePreview. More...
 
Copy and assignment

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

 ActivationResponse (ActivationResponse const &other)
 
 ActivationResponse (ActivationResponse &&other)
 
ActivationResponseoperator= (ActivationResponse const &other)
 
ActivationResponseoperator= (ActivationResponse &&other)
 

Detailed Description

Response to a result activation.

Member Enumeration Documentation

enum unity::scopes::ActivationResponse::Status

Status of a unity::scopes::ScopeBase::activate, unity::scopes::ScopeBase::perform_action, or unity::scopes::ScopeBase::activate_result_action request.

Enumerator
NotHandled 

Activation of this result wasn't handled by the scope

ShowDash 

Activation of this result was handled, show the Dash

HideDash 

Activation of this result was handled, hide the Dash

ShowPreview 

Preview should be requested for this result

PerformQuery 

Perform new search. This state is implied if creating ActivationResponse with CannedQuery object and is invalid otherwise

UpdateResult 

Update the result. This state is implied if creating ActivationResponse with Result object and is invalid otherwise

UpdatePreview 

Update the preview. This state is implied if creating ActivationResponse with PreviewWidgetList and is invalid otherwise

Constructor & Destructor Documentation

unity::scopes::ActivationResponse::ActivationResponse ( Status  status)

Creates ActivationResponse with given status.

Parameters
statusThe activation status.
Exceptions
unity::InvalidArgumentExceptionif status is Status::PerformQuery or Status::Update. To create an ActivationResponse for one of these types, use the ActivationResponse(CannedQuery const&) or ActivationResponse(Result const&) constructors.
unity::scopes::ActivationResponse::ActivationResponse ( CannedQuery const &  query)

Creates an ActivationResponse with status Status::PerformQuery and a search query to be executed.

Parameters
queryThe search query to be executed by the client.
unity::scopes::ActivationResponse::ActivationResponse ( Result const &  updated_result)

Creates an ActivationResponse with status Status::UpdateResult and an updated result that replaces the original result of the action.

Parameters
updated_resultThe updated result to replace the original result of the action.
unity::scopes::ActivationResponse::ActivationResponse ( PreviewWidgetList const &  updated_widgets)

Creates ActivationResponse with status Status::UpdatePreview and an updated list of preview widgets that replace the original widgets in the preview. Widgets not included in this list stay intact and are still displayed in the preview. Responding with this type of ActivationResponse outside of a preview context will not have any effect.

Parameters
updated_widgetsThe updated widgets to replace the original widgets in the preview.
Exceptions
unity::InvalidArgumentExceptionif updated_widgets list is empty.

Member Function Documentation

CannedQuery unity::scopes::ActivationResponse::query ( ) const

A query to be executed if status is Status::PerformQuery.

Exceptions
unity::LogicExceptionif the status of this ActivationResponse is anything other than Status::PerformQuery.
Returns
The query to be executed by the client.
Variant unity::scopes::ActivationResponse::scope_data ( ) const

Get data attached to this response object.

Returns
The data attached to the response.
void unity::scopes::ActivationResponse::set_scope_data ( Variant const &  data)

Attach arbitrary data to this response.

The attached data is sent back to the scope if the status of this response is Status::ShowPreview.

Parameters
dataAn arbitrary value attached to the response.
ActivationResponse::Status unity::scopes::ActivationResponse::status ( ) const

Get activation status.

Returns
The activation status.
Result unity::scopes::ActivationResponse::updated_result ( ) const

The updated result if status is Status::UpdateResult.

Exceptions
unity::LogicExceptionif the status of this ActivationResponse is anything other than Status::UpdateResult.
Returns
The result to be displayed instead of the original result.
PreviewWidgetList unity::scopes::ActivationResponse::updated_widgets ( ) const

The updated widgets if status is Status::UpdatePreview.

Exceptions
unity::LogicExceptionif the status of this ActivationResponse is anything other than Status::UpdatePreview.
Returns
The widgets to be displayed instead of the original widgets with same IDs.