File: /home/alex/dev/work/webapps/branches/scopes/doc/src/bindings/src/search-query.js
/**
*
* Represents a particular query
*
* A scope must return an instance of this class from its implementation of Scope.search().
*
* @module ScopeJS
*
* @class SearchQuery
*
* @example
var scopes = require('unity-js-scopes')
function on_search(canned_query, metadata) {
return new scopes.lib.search_query(
canned_query,
metadata,
// run
function(search_reply) {}
// cancelled
function() {});
}
scopes.self.initialize(
{}
,
{
run: function() { },
start: function(scope_id) { },
search: on_search,
}
);
*
* @constructor
* @param canned_query
* @param metadata
* @param run Function({SearchReply}) Function callback that is to be called by the scope runtime to start the query.
Your implementation of run() can use the provided SearchReply object to
push results for the query and call finished() on the reply object when
you are done with pushing results. You can push results from within run(),
in which case the query implicitly completes when run() returns.
Alternatively, run() can store the reply object and return immediately.
* @param cancelled Function() Called by the scopes runtime when the query originator cancels a query.
Your implementation of this method should ensure that the scope stops
processing the current query as soon as possible. Any calls to a `push()` method
once a query is cancelled are ignored, so continuing to push after cancellation
only wastes CPU cycles.*/
function SearchQuery(){}
SearchQuery.prototype = {
/**
* Get a canned query for this search request
* @method query
* @return CannedQuery
*/
query: function() {
},
/**
* Get metadata for this search request
* @method search_metadata
* @return SearchMetadata
*/
search_metadata: function() {
},
/**
* Check whether this query is still valid
* @method valid
* @return Boolean False if the query is finished or was cancelled ealier.
*/
valid: function() {
},
/**
* Returns a dictionary with the scope's current settings
* @method settings
* @return Dictionary
*/
settings: function() {
}
};