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