Albert
Loading...
Searching...
No Matches
albert::AsyncGeneratorQueryHandler Class Referenceabstract

#include <albert/asyncgeneratorqueryhandler.h>

Description

Coroutine-based asynchronous generator query handler.

Convenience base class for implementing triggered query handlers using C++ coroutines. Results are produced lazily via an asynchronous item generator. The items are displayed in the order they are yielded.

This class is suitable for I/O-bound query handling (e.g. network requests, subprocessing, etc.). For CPU-bound work, prefer GeneratorQueryHandler or its subclasses.

If you derive this class you want to link against QCoro which provides coroutine support for Qt classes. Note that QCoro is still in development.

Inheritance diagram for albert::AsyncGeneratorQueryHandler:
[legend]

Public Member Functions

virtual AsyncItemGenerator items (QueryContext &context)=0
 Yields batches of items for context asynchronously and lazily.
 
- Public Member Functions inherited from albert::QueryHandler
virtual QString synopsis (const QString &query) const
 Returns the input hint for the given query.
 
virtual bool allowTriggerRemap () const
 Returns true if the user is allowed to set a custom trigger, otherwise returns false.
 
virtual QString defaultTrigger () const
 Returns the default trigger.
 
virtual bool supportsFuzzyMatching () const
 Returns true if the handler supports fuzzy matching, otherwise returns false.
 
- Public Member Functions inherited from albert::Extension
virtual QString id () const =0
 Returns the extension identifier.
 
virtual QString name () const =0
 Returns the pretty, human readable extension name.
 
virtual QString description () const =0
 Returns the brief extension description.
 

Protected Member Functions

 ~AsyncGeneratorQueryHandler () override
 Destructs the handler.
 
std::unique_ptr< QueryExecutionexecution (QueryContext &context) override
 Returns an asynchronous generator query execution for context.
 
- Protected Member Functions inherited from albert::QueryHandler
 ~QueryHandler () override
 Destructs the handler.
 
virtual void setFuzzyMatching (bool enabled)
 Sets the fuzzy matching mode to enabled.
 
virtual void setTrigger (const QString &trigger)
 Notifies that the user-defined trigger has changed to trigger.
 
- Protected Member Functions inherited from albert::Extension
virtual ~Extension ()
 Destructs the extension.
 

Constructor & Destructor Documentation

◆ ~AsyncGeneratorQueryHandler()

albert::AsyncGeneratorQueryHandler::~AsyncGeneratorQueryHandler ( )
overrideprotected

Destructs the handler.

Member Function Documentation

◆ execution()

std::unique_ptr< QueryExecution > albert::AsyncGeneratorQueryHandler::execution ( QueryContext context)
overrideprotectedvirtual

Returns an asynchronous generator query execution for context.

Implements albert::QueryHandler.

◆ items()

virtual AsyncItemGenerator albert::AsyncGeneratorQueryHandler::items ( QueryContext context)
pure virtual

Yields batches of items for context asynchronously and lazily.

The batch size is defined by the implementation.

Note
Called from main thread. Do not run blocking operations in it.

The documentation for this class was generated from the following file: