X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2Fhints%2FIHintObservable.java;fp=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2Fhints%2FIHintObservable.java;h=9d31c1c6365b5b114d7ed5b51ac24ac86f42e9ee;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git 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 index 000000000..9d31c1c63 --- /dev/null +++ b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/hints/IHintObservable.java @@ -0,0 +1,127 @@ +/******************************************************************************* + * Copyright (c) 2007, 2015 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + * Semantum Oy - added getHintsUnsafe + *******************************************************************************/ +/* + * + * @author Toni Kalajainen + */ +package org.simantics.utils.datastructures.hints; + +import java.util.Map; + +import org.simantics.utils.datastructures.hints.IHintContext.Key; +import org.simantics.utils.threads.IThreadWorkQueue; + + +public interface IHintObservable { + + /** + * Check if this observable contains a value for the specified hint key. + * + * @param key the key to check for a value + * @return true if there is a value, false otherwise + */ + boolean containsHint(Key key); + + /** + * Get hint + * @param type of the object bound to the specified key + * @param key key + * @return the hint or null if does not exist + */ + E getHint(Key key); + + /** + * Get all hints in this context + * @return a snapshot of all the hints in this context + */ + Map getHints(); + + /** + * Get all hints in this context without creating defensive copies in the + * implementation if possible. + *

+ * Use this only when reading and you know what you're doing. + * + * @return the backing map of hints in this context without extra copying if possible + */ + Map getHintsUnsafe(); + + /** + * Get all hints whose key is a subclass of clazz + * @param + * @param clazz the class + * @return key object map + */ + Map getHintsOfClass(Class clazz); + + /** + * Adds hint listener, which gets events for all hint changes + * + * @param listener + */ + void addHintListener(IHintListener listener); + + /** + * Removes hint listener + * + * @param listener + */ + void removeHintListener(IHintListener listener); + + /** + * Adds hint listener for a specific key + * @param key + * @param listener + */ + void addKeyHintListener(Key key, IHintListener listener); + + /** + * Removes hint listener + * @param key + * @param listener + */ + void removeKeyHintListener(Key key, IHintListener listener); + + /** + * Adds hint listener, which gets events for all hint changes + * + * @param threadAccess + * @param listener + */ + void addHintListener(IThreadWorkQueue threadAccess, IHintListener listener); + + /** + * Removes hint listener + * + * @param threadAccess + * @param listener + */ + void removeHintListener(IThreadWorkQueue threadAccess, IHintListener listener); + + /** + * Adds hint listener for a specific key + * @param threadAccess + * @param key + * @param listener + */ + void addKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener); + + /** + * Removes hint listener + * @param threadAccess + * @param key + * @param listener + */ + void removeKeyHintListener(IThreadWorkQueue threadAccess, Key key, IHintListener listener); + +}