1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 /** 6 * @fileoverview Base interface for all speech rule stores. 7 * 8 * A speech rule store exposes the minimal set of methods a speech rule 9 * author needs for a particular markup type such as MathML or HTML 10 * (definition). A rule provider also acts as the permanent and authoritative 11 * store for all rules for such markup (lookup). 12 */ 13 14 goog.provide('cvox.SpeechRuleStore'); 15 16 /** 17 * @interface 18 */ 19 cvox.SpeechRuleStore = goog.abstractMethod; 20 21 22 /** 23 * Adds a new speech rule. 24 * @param {cvox.SpeechRule} rule The speech rule to be added. 25 */ 26 cvox.SpeechRuleStore.prototype.addRule = goog.abstractMethod; 27 28 29 /** 30 * Deletes a speech rule if it exists. 31 * @param {cvox.SpeechRule} rule The speech rule to be deleted. 32 */ 33 cvox.SpeechRuleStore.prototype.deleteRule = goog.abstractMethod; 34 35 36 /** 37 * Retrieves the first rule satisfying a given predicate. 38 * @param {function(cvox.SpeechRule): boolean} pred A predicate on speech rules. 39 * @return {cvox.SpeechRule} The first speech rule in the store satisfying pred. 40 */ 41 cvox.SpeechRuleStore.prototype.findRule = goog.abstractMethod; 42 43 44 /** 45 * Retrieves all rules satisfying a given predicate. 46 * @param {function(cvox.SpeechRule): boolean} pred A predicate on speech rules. 47 * @return {Array.<cvox.SpeechRule>} All speech rules in the store satisfying 48 * pred. 49 */ 50 cvox.SpeechRuleStore.prototype.findAllRules = goog.abstractMethod; 51 52 53 /** 54 * Retrieves a rule for the given node if one exists. 55 * @param {Node} node A node. 56 * @param {!cvox.SpeechRule.DynamicCstr} dynamic Additional dynamic 57 * constraints. These are matched against properties of a rule. 58 * @return {cvox.SpeechRule} The actions of the speech rule if it exists. 59 */ 60 cvox.SpeechRuleStore.prototype.lookupRule = goog.abstractMethod; 61 62 63 // TODO(sorge): Propagate this documentation *everywhere* once these 64 // args/descriptions are hardened/cleared up. 65 /** 66 * Defines a new speech rule from given components. 67 * @param {string} name Name of the rule. It does not have to be unique. 68 * @param {string} dynamic Dynamic constraint annotation of the rule. 69 * @param {string} action String version of the speech rule. 70 * @param {string} prec Precondition of the rule. 71 * @param {...string} constr Additional constraints. 72 * @return {cvox.SpeechRule} The newly defined rule. 73 */ 74 cvox.SpeechRuleStore.prototype.defineRule = goog.abstractMethod; 75