Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -35,44 +35,73 @@ |
* Abstract base class for filters |
* |
* @param {string} text string representation of the filter |
* @constructor |
*/ |
function Filter(text) |
{ |
this.text = text; |
- this.subscriptions = new Set(); |
+ |
+ /** |
+ * Subscriptions to which this filter belongs. |
+ * @type {Set.<Subscription>} |
+ * @private |
+ */ |
+ this._subscriptions = new Set(); |
} |
exports.Filter = Filter; |
Filter.prototype = |
{ |
/** |
* String representation of the filter |
* @type {string} |
*/ |
text: null, |
/** |
- * Filter subscriptions the filter belongs to |
- * @type {Set.<Subscription>} |
- */ |
- subscriptions: null, |
- |
- /** |
* Filter type as a string, e.g. "blocking". |
* @type {string} |
*/ |
get type() |
{ |
throw new Error("Please define filter type in the subclass"); |
}, |
/** |
+ * Yields subscriptions to which the filter belongs. |
+ * @yields {Subscription} |
+ */ |
+ *subscriptions() |
+ { |
+ yield* this._subscriptions; |
+ }, |
+ |
+ /** |
+ * Adds a subscription to the set of subscriptions to which the filter |
+ * belongs. |
+ * @param {Subscription} subscription |
+ */ |
+ addSubscription(subscription) |
+ { |
+ this._subscriptions.add(subscription); |
+ }, |
+ |
+ /** |
+ * Removes a subscription from the set of subscriptions to which the filter |
+ * belongs. |
+ * @param {Subscription} subscription |
+ */ |
+ removeSubscription(subscription) |
+ { |
+ this._subscriptions.delete(subscription); |
+ }, |
+ |
+ /** |
* Serializes the filter to an array of strings for writing out on the disk. |
* @param {string[]} buffer buffer to push the serialization results into |
*/ |
serialize(buffer) |
{ |
buffer.push("[Filter]"); |
buffer.push("text=" + this.text); |
}, |