]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - 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
diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/IHintObservable.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/IHintObservable.java
new file mode 100644 (file)
index 0000000..9d31c1c
--- /dev/null
@@ -0,0 +1,127 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2015 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *     Semantum Oy - added getHintsUnsafe\r
+ *******************************************************************************/\r
+/*\r
+ *\r
+ * @author Toni Kalajainen\r
+ */\r
+package org.simantics.utils.datastructures.hints;\r
+\r
+import java.util.Map;\r
+\r
+import org.simantics.utils.datastructures.hints.IHintContext.Key;\r
+import org.simantics.utils.threads.IThreadWorkQueue;\r
+\r
+\r
+public interface IHintObservable {\r
+\r
+    /**\r
+     * Check if this observable contains a value for the specified hint key.\r
+     * \r
+     * @param key the key to check for a value \r
+     * @return <code>true</code> if there is a value, <code>false</code> otherwise\r
+     */\r
+    boolean containsHint(Key key);\r
+\r
+       /**\r
+        * Get hint\r
+     * @param <E> type of the object bound to the specified key\r
+        * @param key key\r
+        * @return the hint or <code>null</code> if does not exist\r
+        */\r
+       <E> E getHint(Key key);\r
+       \r
+       /**\r
+        * Get all hints in this context\r
+        * @return a snapshot of all the hints in this context\r
+        */\r
+       Map<Key, Object> getHints();\r
+       \r
+       /**\r
+        * Get all hints in this context without creating defensive copies in the\r
+        * implementation if possible.\r
+        * <p>\r
+        * Use this only when reading and you know what you're doing.\r
+        * \r
+        * @return the backing map of hints in this context without extra copying if possible\r
+        */\r
+       Map<Key, Object> getHintsUnsafe();\r
+       \r
+       /**\r
+        * Get all hints whose key is a subclass of <code>clazz</code>\r
+        * @param <E> \r
+        * @param clazz the class\r
+        * @return key object map\r
+        */\r
+       <E extends Key> Map<E, Object> getHintsOfClass(Class<E> clazz);\r
+       \r
+       /**\r
+        * Adds hint listener, which gets events for all hint changes\r
+        * \r
+        * @param listener\r
+        */\r
+       void addHintListener(IHintListener listener);\r
+       \r
+       /**\r
+        * Removes hint listener\r
+        * \r
+        * @param listener\r
+        */\r
+       void removeHintListener(IHintListener listener);\r
+       \r
+       /**\r
+        * Adds hint listener for a specific key\r
+        * @param key\r
+        * @param listener\r
+        */\r
+       void addKeyHintListener(Key key, IHintListener listener);\r
+       \r
+       /**\r
+        * Removes hint listener\r
+        * @param key\r
+        * @param listener\r
+        */\r
+       void removeKeyHintListener(Key key, IHintListener listener);\r
+       \r
+       /**\r
+        * Adds hint listener, which gets events for all hint changes\r
+        * \r
+     * @param threadAccess \r
+        * @param listener\r
+        */\r
+       void addHintListener(IThreadWorkQueue threadAccess, IHintListener listener);\r
+       \r
+       /**\r
+        * Removes hint listener\r
+        * \r
+     * @param threadAccess \r
+        * @param listener\r
+        */\r
+       void removeHintListener(IThreadWorkQueue threadAccess, IHintListener listener);\r
+       \r
+       /**\r
+        * Adds hint listener for a specific key\r
+        * @param threadAccess \r
+        * @param key\r
+        * @param listener\r
+        */\r
+       void addKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener);\r
+       \r
+       /**\r
+        * Removes hint listener\r
+     * @param threadAccess \r
+        * @param key\r
+        * @param listener\r
+        */\r
+       void removeKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener);     \r
+       \r
+}\r