1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18package android.filterfw.core;
19
20/**
21 * @hide
22 */
23public class ProgramVariable {
24
25    private Program mProgram;
26    private String mVarName;
27
28    public ProgramVariable(Program program, String varName) {
29        mProgram = program;
30        mVarName = varName;
31    }
32
33    public Program getProgram() {
34        return mProgram;
35    }
36
37    public String getVariableName() {
38        return mVarName;
39    }
40
41    public void setValue(Object value) {
42        if (mProgram == null) {
43            throw new RuntimeException("Attempting to set program variable '" + mVarName
44                + "' but the program is null!");
45        }
46        mProgram.setHostValue(mVarName, value);
47    }
48
49    public Object getValue() {
50        if (mProgram == null) {
51            throw new RuntimeException("Attempting to get program variable '" + mVarName
52                + "' but the program is null!");
53        }
54        return mProgram.getHostValue(mVarName);
55    }
56
57}
58