unity.scopes.PreviewQueryBase

Abstract base class to represent a particular preview. More...

#include <unity/scopes/PreviewQueryBase.h>

Inheritance diagram for unity::scopes::PreviewQueryBase: src="https://assets.ubuntu.com/v1/9637dfb9-classunity_1_1scopes_1_1_preview_query_base__inherit__graph.png" border="0" alt="Inheritance graph"/>

Public Member Functions

virtual void run (PreviewReplyProxy const &reply)=0
 Called by scopes runtime to start the preview. More...
 
Result result () const
 Get result for this preview request. More...
 
ActionMetadata action_metadata () const
 Get metadata for this preview request. More...
 
src="https://assets.ubuntu.com/v1/c6607712-closed.png" alt="-"/> Public Member Functions inherited from unity::scopes::QueryBase
virtual void cancelled ()=0
 Called by the scopes runtime when the query originator cancels a query. More...
 
bool valid () const
 Check whether this query is still valid. More...
 
unity::scopes::VariantMap settings () const
 Returns a dictionary with the scope's current settings. More...
 

Protected Member Functions

 PreviewQueryBase (Result const &result, ActionMetadata const &metadata)
 Instantiates a PreviewQueryBase. More...
 

Detailed Description

Abstract base class to represent a particular preview.

A scope must return an instance of this class from its implementation of ScopeBase::preview().

Note
The constructor of the instance must complete in a timely manner. Do not perform anything in the constructor that might block.

Constructor & Destructor Documentation

unity::scopes::PreviewQueryBase::PreviewQueryBase ( Result const &  result,
ActionMetadata const &  metadata 
)
protected

Instantiates a PreviewQueryBase.

Parameters
resultThe result to be previewed.
metadataAdditional data for the preview.

Member Function Documentation

ActionMetadata unity::scopes::PreviewQueryBase::action_metadata ( ) const

Get metadata for this preview request.

Returns
search metadata
Exceptions
unity::LogicExceptionif preview metadata was not initialized (the default ctor was used).
Result unity::scopes::PreviewQueryBase::result ( ) const

Get result for this preview request.

Exceptions
unity::LogicExceptionif result was not initialized (the default ctor was used).
Returns
result
virtual void unity::scopes::PreviewQueryBase::run ( PreviewReplyProxy const &  reply)
pure virtual

Called by scopes runtime to start the preview.

Your implementation of run() can use the reply proxy to push results for the preview. You can push results from within run(), in which case the preview implicitly completes when run() returns. Alternatively, run() can store the reply proxy and return immediately. In this case, you can use the stored proxy to push results from another thread. It is safe to call push() from multiple threads without synchronization.

The preview completes either when run() returns, or when the last stored reply proxy goes out of scope (whichever happens last).

Parameters
replyThe proxy on which to push results for the preview.

Implemented in unity::scopes::qt::QPreviewQueryBaseAPI.