]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.impl/src/org/simantics/db/impl/query/BinaryQuery.java
Generate parts of db client query code
[simantics/platform.git] / bundles / org.simantics.db.impl / src / org / simantics / db / impl / query / BinaryQuery.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 org.simantics.db.exception.DatabaseException;
15 import org.simantics.db.impl.graph.ReadGraphImpl;
16 import org.simantics.db.request.RequestFlags;
17
18
19 abstract public class BinaryQuery<Procedure> extends CacheEntryBase<Procedure> implements Query {
20
21         final public long id;
22
23         public BinaryQuery(final long r1, final long r2) {
24         assert(r1 != 0);
25         assert(r2 != 0);
26         id = id(r1,r2);
27         assert(id != 0);
28     }
29         
30         @Override
31         int makeHash() {
32                 return r1() ^ r2();
33         }
34         
35     final public int r1() {
36         return (int)(id>>>32);
37     }
38     
39     final public int r2() {
40         return (int)id;
41     }
42     
43     final protected static long id(long r1, long r2) {
44         long result = (r1<<32) | (r2 & 0xffffffffL); 
45         return result;
46     }
47     
48     @Override
49     public int type() {
50         return RequestFlags.INVALIDATE;
51     }
52     
53         @Override
54     final public boolean equals(Object object) {
55         if (this == object)
56             return true;
57         else if (object == null)
58             return false;
59         else if (getClass() != object.getClass())
60             return false;
61         BinaryQuery<?> other = (BinaryQuery<?>)object;
62         return id == other.id;
63     }
64         
65     @Override
66     final public Query getQuery() {
67         return this;
68     }
69     
70 //    @Override
71 //    public void recompute(ReadGraphImpl graph, Object provider, CacheEntry entry) throws DatabaseException {
72 //        recompute(graph, (QueryProcessor)provider);
73 //    }
74 //    
75 //    @SuppressWarnings("unchecked")
76 //    @Override
77 //    public Object performFromCache(ReadGraphImpl graph, Object provider, Object procedure) throws DatabaseException {
78 //        return performFromCache(graph, (QueryProcessor)provider, (Procedure)procedure);
79 //    }
80
81     //abstract public void recompute(ReadGraphImpl graph, QueryProcessor provider) throws DatabaseException ;
82     //abstract public void compute(ReadGraphImpl graph, Procedure procedure) throws DatabaseException ;
83     //abstract public Object performFromCache(ReadGraphImpl graph, QueryProcessor provider, Procedure procedure) throws DatabaseException;
84     //abstract public void putEntry(QueryProcessor provider);
85     abstract public void removeEntry(QueryProcessor provider);
86
87 }