1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
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
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.impl.query;
14 import org.simantics.db.exception.DatabaseException;
15 import org.simantics.db.impl.graph.ReadGraphImpl;
19 public abstract class CacheEntry<Procedure> {
21 final public static int HAS_BEEN_BOUND = 1;
23 abstract boolean isFresh();
24 abstract boolean isReady();
25 abstract boolean isRefuted();
26 abstract boolean isPending();
27 abstract boolean isDiscarded();
28 abstract boolean isExcepted();
30 abstract void setReady();
31 abstract void refute();
32 abstract void setPending(QuerySupport querySupport);
33 abstract void discard();
34 abstract void except(Throwable t);
35 abstract void clearResult(QuerySupport support);
37 abstract void prepareRecompute(QuerySupport querySupport);
39 abstract public Object getOriginalRequest();
40 abstract Query getQuery();
42 abstract CacheEntry pruneFirstParents();
43 abstract void pruneParentSet();
44 abstract void removeParent(CacheEntry entry);
45 abstract void addParent(CacheEntry entry);
46 abstract boolean hasParents();
47 abstract Iterable<CacheEntry<?>> getParents(QueryProcessor processor);
48 abstract CacheEntry getFirstParent(QueryProcessor processor);
49 abstract boolean moreThanOneParent(QueryProcessor processor);
50 abstract int parentCount(QueryProcessor processor);
52 abstract <T> T getResult();
53 abstract void setResult(Object result);
55 abstract Object performFromCache(ReadGraphImpl graph, Procedure procedure) throws DatabaseException;
57 abstract boolean isImmutable(ReadGraphImpl graph) throws DatabaseException;
59 abstract boolean shouldBeCollected();
61 abstract short getLevel();
62 abstract short setLevel(short level);
64 abstract int getGCStatus();
65 abstract int setGCStatus(int status);
66 abstract void setGCStatusFlag(int flag, boolean value);