/
RegisteredRuleset.ts
53 lines (48 loc) · 1.66 KB
/
RegisteredRuleset.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module Core
*/
import { IDisposable } from "@itwin/core-bentley";
import { Rule } from "./rules/Rule";
import { Ruleset, SupplementationInfo } from "./rules/Ruleset";
import { VariablesGroup } from "./rules/Variables";
/**
* A ruleset that is registered in a ruleset manager.
* @public
*/
export class RegisteredRuleset implements IDisposable, Ruleset {
private _ruleset: Ruleset;
private _uniqueIdentifier: string;
private _disposeFunc: (ruleset: RegisteredRuleset) => void;
/** Create a registered ruleset */
public constructor(ruleset: Ruleset, uniqueIdentifier: string, disposeFunc: (ruleset: RegisteredRuleset) => void) {
this._disposeFunc = disposeFunc;
this._ruleset = ruleset;
this._uniqueIdentifier = uniqueIdentifier;
}
/** Dispose registered ruleset. */
public dispose() {
this._disposeFunc(this);
}
public get uniqueIdentifier() {
return this._uniqueIdentifier;
}
public get id(): string {
return this._ruleset.id;
}
public get supplementationInfo(): SupplementationInfo | undefined {
return this._ruleset.supplementationInfo;
}
public get rules(): Rule[] {
return this._ruleset.rules;
}
public get vars(): VariablesGroup[] | undefined {
return this._ruleset.vars;
}
public toJSON(): Ruleset {
return this._ruleset;
}
}