]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/CacheEntry.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / CacheEntry.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.db.impl.query;
13
14 import java.util.Collection;
15
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.impl.graph.ReadGraphImpl;
18
19
20
21 public abstract class CacheEntry<Procedure> {
22         
23     final public static int HAS_BEEN_BOUND = 1;
24
25     abstract boolean isFresh();
26     abstract boolean isReady();
27     abstract boolean isRefuted();
28     abstract boolean isPending();
29     abstract boolean isDiscarded();
30     abstract boolean isExcepted();
31
32     abstract void setReady();
33     abstract void refute();
34     abstract void setPending(QuerySupport querySupport);
35     abstract void discard();
36     abstract void except(Throwable t);
37     abstract void clearResult(QuerySupport support);
38
39     abstract void prepareRecompute(QuerySupport querySupport);
40     
41     abstract public Object getOriginalRequest();
42     abstract Query getQuery();
43
44     abstract CacheEntry pruneFirstParents();
45     abstract void pruneParentSet();
46     abstract void removeParent(CacheEntry entry);
47     abstract void addParent(CacheEntry entry);
48     abstract boolean hasParents();
49     abstract Collection<CacheEntry<?>> getParents(QueryProcessor processor);
50     abstract CacheEntry getFirstParent(QueryProcessor processor);
51     abstract boolean moreThanOneParent(QueryProcessor processor);
52     abstract int parentCount(QueryProcessor processor);
53     
54     abstract <T> T getResult();
55     abstract void setResult(Object result);
56     
57     abstract Object performFromCache(ReadGraphImpl graph, Procedure procedure) throws DatabaseException;
58     
59     abstract boolean isImmutable(ReadGraphImpl graph) throws DatabaseException;
60     
61     abstract boolean shouldBeCollected();
62     
63     abstract short getLevel();
64     abstract short setLevel(short level);
65     
66     abstract int getGCStatus();
67     abstract int setGCStatus(int status);
68     abstract void setGCStatusFlag(int flag, boolean value);
69
70 }