]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/IHintObservable.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.utils.datastructures / src / org / simantics / utils / datastructures / hints / IHintObservable.java
1 /*******************************************************************************\r
2  * Copyright (c) 2007, 2015 Association for Decentralized Information Management\r
3  * in Industry THTH ry.\r
4  * All rights reserved. This program and the accompanying materials\r
5  * are made available under the terms of the Eclipse Public License v1.0\r
6  * which accompanies this distribution, and is available at\r
7  * http://www.eclipse.org/legal/epl-v10.html\r
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *     Semantum Oy - added getHintsUnsafe\r
12  *******************************************************************************/\r
13 /*\r
14  *\r
15  * @author Toni Kalajainen\r
16  */\r
17 package org.simantics.utils.datastructures.hints;\r
18 \r
19 import java.util.Map;\r
20 \r
21 import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
22 import org.simantics.utils.threads.IThreadWorkQueue;\r
23 \r
24 \r
25 public interface IHintObservable {\r
26 \r
27     /**\r
28      * Check if this observable contains a value for the specified hint key.\r
29      * \r
30      * @param key the key to check for a value \r
31      * @return <code>true</code> if there is a value, <code>false</code> otherwise\r
32      */\r
33     boolean containsHint(Key key);\r
34 \r
35         /**\r
36          * Get hint\r
37      * @param <E> type of the object bound to the specified key\r
38          * @param key key\r
39          * @return the hint or <code>null</code> if does not exist\r
40          */\r
41         <E> E getHint(Key key);\r
42         \r
43         /**\r
44          * Get all hints in this context\r
45          * @return a snapshot of all the hints in this context\r
46          */\r
47         Map<Key, Object> getHints();\r
48         \r
49         /**\r
50          * Get all hints in this context without creating defensive copies in the\r
51          * implementation if possible.\r
52          * <p>\r
53          * Use this only when reading and you know what you're doing.\r
54          * \r
55          * @return the backing map of hints in this context without extra copying if possible\r
56          */\r
57         Map<Key, Object> getHintsUnsafe();\r
58         \r
59         /**\r
60          * Get all hints whose key is a subclass of <code>clazz</code>\r
61          * @param <E> \r
62          * @param clazz the class\r
63          * @return key object map\r
64          */\r
65         <E extends Key> Map<E, Object> getHintsOfClass(Class<E> clazz);\r
66         \r
67         /**\r
68          * Adds hint listener, which gets events for all hint changes\r
69          * \r
70          * @param listener\r
71          */\r
72         void addHintListener(IHintListener listener);\r
73         \r
74         /**\r
75          * Removes hint listener\r
76          * \r
77          * @param listener\r
78          */\r
79         void removeHintListener(IHintListener listener);\r
80         \r
81         /**\r
82          * Adds hint listener for a specific key\r
83          * @param key\r
84          * @param listener\r
85          */\r
86         void addKeyHintListener(Key key, IHintListener listener);\r
87         \r
88         /**\r
89          * Removes hint listener\r
90          * @param key\r
91          * @param listener\r
92          */\r
93         void removeKeyHintListener(Key key, IHintListener listener);\r
94         \r
95         /**\r
96          * Adds hint listener, which gets events for all hint changes\r
97          * \r
98      * @param threadAccess \r
99          * @param listener\r
100          */\r
101         void addHintListener(IThreadWorkQueue threadAccess, IHintListener listener);\r
102         \r
103         /**\r
104          * Removes hint listener\r
105          * \r
106      * @param threadAccess \r
107          * @param listener\r
108          */\r
109         void removeHintListener(IThreadWorkQueue threadAccess, IHintListener listener);\r
110         \r
111         /**\r
112          * Adds hint listener for a specific key\r
113          * @param threadAccess \r
114          * @param key\r
115          * @param listener\r
116          */\r
117         void addKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener);\r
118         \r
119         /**\r
120          * Removes hint listener\r
121      * @param threadAccess \r
122          * @param key\r
123          * @param listener\r
124          */\r
125         void removeKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener);     \r
126         \r
127 }\r