]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/ILookupService.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scenegraph / src / org / simantics / scenegraph / ILookupService.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 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  *******************************************************************************/
12 package org.simantics.scenegraph;
13
14 /**
15  * A bijective mapping service between unique String ID's and scene graph nodes
16  * ({@link INode}).
17  * 
18  * @author Tuukka Lehtonen
19  */
20 public interface ILookupService {
21
22     /**
23      * Associates the specified node with the specified ID. If the specified ID
24      * is already associated the previous association will be overwritten with
25      * the new one and the previously associated node is returned.
26      * 
27      * @param id the id to map to the specified node
28      * @param node node to map to specified id
29      * @return the node previously associated with the specified ID or
30      *         <code>null</code> if the specified ID no previous association
31      * @throws NullPointerException if either argument is <code>null</code>
32      */
33     INode map(String id, INode node);
34
35     /**
36      * Removes possibly existing ID <=> node mapping from the lookup service.
37      * 
38      * @param id the id to unmap
39      * @return the unmapped INode if successful, <code>null</code> otherwise
40      */
41     INode unmap(String id);
42
43     /**
44      * Removes possibly existing node <=> ID mapping from the lookup service.
45      * 
46      * @param node the node to unmap
47      * @return the unmapped ID if successful, <code>null</code> otherwise
48      */
49     String unmap(INode node);
50
51     /**
52      * Get the node mapped to the specified ID.
53      * 
54      * @param id identifier of the node to look for
55      * @return node mapped with specified id or <code>null</code> if no mapping
56      *         exists
57      */
58     INode lookupNode(String id);
59
60     /**
61      * Get the mapping ID for the specified node.
62      * 
63      * @param node node to get mapping ID for
64      * @return mapping ID of the node or <code>null</code> if node is not mapped
65      */
66     String lookupId(INode node);
67
68 }