01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.caching;
17:
18: import org.geotools.data.Query;
19:
20: import org.opengis.filter.Filter;
21:
22: /** Records information about queries,
23: * in order to be able to tell to a DataCache if the data requested
24: * are already known, or else what data should be asked for to the source DataStore.
25: *
26: * Actual implementation should allow query-specific optimization.
27: *
28: * @author Christophe Rousson, SoC 2007, CRG-ULAVAL
29: *
30: */
31: public interface QueryTracker {
32: /** Take notice that the data for the query q have been retrieved once.
33: * So they should be in the cache.
34: *
35: * @param q the Query to register
36: */
37: public abstract void register(Query q);
38:
39: /** Take notice that the data for the Filter f have been retrieved once.
40: * So they should be in the cache.
41: *
42: * @param f the Filter to register
43: */
44: public abstract void register(Filter f);
45:
46: /** Restrict the Filter f to a new filter
47: * that will yield only the complementary set of data the cache doesn't hold.
48: * If all data are known, implementation should return
49: * Filter.EXCLUDE which is a filter that yields nothing.
50: *
51: * @param f the filter to restrict
52: * @return a restricted filter, or otherwise the input filter
53: */
54: public abstract Filter match(Filter f);
55:
56: /** Restrict the Query q to a new query
57: * that will yield only the complementary set of data the cache doesn't hold.
58: * If all data are known, implementation should return
59: * new DefaultQuery(q.getTypeName(), Filter.EXCLUDE) which is a query that yields nothing.
60: *
61: * @param q the query to restrict
62: * @return a restricted query, or otherwise the input query
63: */
64: public abstract Query match(Query q);
65:
66: /** Forget about the query q.
67: * When this query will be issued again, or a related query, the cache will have to get data from the source DataStore.
68: * This is used when the cache has reached its maximum capacity,
69: * and needs to make room for new features.
70: * For example, the input query can be the extent (bbox) of the deleted feature in the cache.
71: *
72: * @param q the query to forget about.
73: */
74: public abstract void unregister(Query q);
75:
76: /** Forget about the filter f.
77: * When this filter will be used again, or a related query, the cache will have to get data from the source DataStore.
78: * This is used when the cache has reached its maximum capacity,
79: * and needs to make room for new features.
80: * For example, the input filter can be the extent (bbox) of the deleted feature in the cache.
81: *
82: * @param q the query to forget about.
83: */
84: public abstract void unregister(Filter f);
85:
86: /** Forget every query ever registered.
87: * Blank mind for new days !
88: *
89: */
90: public abstract void clear();
91: }
|