/
TargetPolicy.ts
84 lines (70 loc) · 3.01 KB
/
TargetPolicy.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/** @module adaptation */
import { MenuManager } from "../../elements/MenuManager";
import { DataManager } from "../../data/DataManager";
import { Item } from "../../elements/Item";
import { ItemGroup } from "../../elements/ItemGroup";
/**
* Interface of an object containing an item and its score
* (according to a certain policy).
*/
export interface ItemWithScore {
item: Item;
score: number;
}
/**
* Interface of an object containing a group and its score
* (according to a certain policy).
*/
export interface ItemGroupWithScore {
group: ItemGroup;
score: number;
}
export interface TargetPolicy {
/**
* Name of the target policy.
* It must be unique among all policies.
*/
readonly name: string;
// ===========================================================================
// Item scoring & sorting
// ===========================================================================
/**
* Get a sorted list of all items (from all menus) with scores assigned by the policy.
* The policy is responsible for assigning scores and sorting the items accordingly.
*
* @param menuManager The menu manager containing the items to rank and sort.
* @param dataManager The data manager containing data for the policy.
* @return A sorted list of items with their scores.
*/
getSortedItemsWithScores (menuManager: MenuManager, dataManager?: DataManager): ItemWithScore[];
/**
* Get a list of all items (from all menus) sorted by their scores,
* i.e. in the same order than the list returned by [[getSortedItemsWithScores]].
*
* @param menuManager The menu manager containing the items to sort.
* @param dataManager The data manager containing data for the policy.
* @return A sorted list of items.
*/
getSortedItems (menuManager: MenuManager, dataManager?: DataManager): Item[];
// ===========================================================================
// Group scoring & sorting
// ===========================================================================
/**
* Get a sorted list of all groups (from all menus) with scores assigned by the policy.
* The policy is responsible for assigning scores and sorting the groups accordingly.
*
* @param menuManager The menu manager containing the groups to rank and sort.
* @param dataManager The data manager containing data for the policy.
* @return A sorted list of groups with their scores.
*/
getSortedItemGroupsWithScores (menuManager: MenuManager, dataManager?: DataManager): ItemGroupWithScore[];
/**
* Get a list of all groups (from all menus) sorted by their scores,
* i.e. in the same order than the list returned by [[getSortedItemGroupsWithScores]].
*
* @param menuManager The menu manager containing the groups to sort.
* @param dataManager The data manager containing data for the policy.
* @return A sorted list of groups.
*/
getSortedItemGroups (menuManager: MenuManager, dataManager?: DataManager): ItemGroup[];
}