KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > hp > hpl > jena > reasoner > rulesys > impl > GenericChoiceFrame


1 /******************************************************************
2  * File: GenericChoiceFrame.java
3  * Created by: Dave Reynolds
4  * Created on: 07-Aug-2003
5  *
6  * (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
7  * [See end of file]
8  * $Id: GenericChoiceFrame.java,v 1.4 2005/02/21 12:17:40 andy_seaborne Exp $
9  *****************************************************************/

10 package com.hp.hpl.jena.reasoner.rulesys.impl;
11
12 /**
13  * Core properties of choice frames used use to represent the OR state of
14  * the backtracking search. Specific variants of this need to preserve additional
15  * choice state.
16  * <p>
17  * This is used in the inner loop of the interpreter and so is a pure data structure
18  * not an abstract data type and assumes privileged access to the interpreter state.
19  * </p>
20  *
21  * @author <a HREF="mailto:der@hplb.hpl.hp.com">Dave Reynolds</a>
22  * @version $Revision: 1.4 $ on $Date: 2005/02/21 12:17:40 $
23  */

24 public class GenericChoiceFrame extends FrameObject {
25
26     /** The environment frame describing the state of the AND tree at this choice point */
27     EnvironmentFrame envFrame;
28
29     /** The top of the trail stack at the time of the call */
30     int trailIndex;
31     
32     /** The continuation program counter offet in the parent clause's byte code */
33     int cpc;
34     
35     /** The continuation argument counter offset in the parent clause's arg stream */
36     int cac;
37
38     /**
39      * Initialize a choice point to preserve the current context of the given intepreter
40      * and then call the given set of predicates.
41      * @param interpreter the LPInterpreter whose state is to be preserved
42      */

43     public void init(LPInterpreter interpreter) {
44         envFrame = interpreter.envFrame;
45         trailIndex = interpreter.trail.size();
46     }
47
48     /**
49      * Set the continuation point for this frame.
50      */

51     public void setContinuation(int pc, int ac) {
52         cpc = pc;
53         cac = ac;
54     }
55
56 }
57
58
59 /*
60     (c) Copyright 2003, 2004, 2005 Hewlett-Packard Development Company, LP
61     All rights reserved.
62
63     Redistribution and use in source and binary forms, with or without
64     modification, are permitted provided that the following conditions
65     are met:
66
67     1. Redistributions of source code must retain the above copyright
68        notice, this list of conditions and the following disclaimer.
69
70     2. Redistributions in binary form must reproduce the above copyright
71        notice, this list of conditions and the following disclaimer in the
72        documentation and/or other materials provided with the distribution.
73
74     3. The name of the author may not be used to endorse or promote products
75        derived from this software without specific prior written permission.
76
77     THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
78     IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
79     OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
80     IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
81     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
82     NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
83     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
84     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
86     THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
87 */
Popular Tags