Search in sources :

Example 1 with DependencyManager

use of pcgen.base.formula.base.DependencyManager in project pcgen by PCGen.

the class DropIntoContext method getDependencies.

@Override
public void getDependencies(DependencyVisitor visitor, DependencyManager fdm, Node[] args) {
    String legalScopeName = ((ASTQuotString) args[0]).getText();
    TrainingStrategy ts = new TrainingStrategy();
    DependencyManager trainer = fdm.getWith(DependencyManager.VARSTRATEGY, ts);
    if (args[1] instanceof ASTQuotString) {
    //Direct,  no dependencies
    } else if (args[1] instanceof ASTPCGenSingleWord) {
        //Variable
        args[1].jjtAccept(visitor, trainer);
    } else {
    //Error
    }
    DynamicDependency dd = new DynamicDependency(ts.getControlVar(), legalScopeName);
    fdm.get(DependencyManager.DYNAMIC).addDependency(dd);
    DependencyManager dynamic = fdm.getWith(DependencyManager.VARSTRATEGY, dd);
    //Rest of Equation
    args[2].jjtAccept(visitor, dynamic);
}
Also used : DynamicDependency(pcgen.base.formula.base.DynamicDependency) TrainingStrategy(pcgen.base.formula.base.TrainingStrategy) ASTQuotString(pcgen.base.formula.parse.ASTQuotString) DependencyManager(pcgen.base.formula.base.DependencyManager) ASTQuotString(pcgen.base.formula.parse.ASTQuotString) ASTPCGenSingleWord(pcgen.base.formula.parse.ASTPCGenSingleWord)

Example 2 with DependencyManager

use of pcgen.base.formula.base.DependencyManager in project pcgen by PCGen.

the class AbstractFormulaTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    setup = new SplitFormulaSetup();
    LegalScopeUtilities.loadLegalScopeLibrary(setup.getLegalScopeLibrary());
    localSetup = new IndividualSetup(setup, "Global", new MonitorableVariableStore());
    setup.getSolverFactory().addSolverFormat(Number.class, new Modifier() {

        @Override
        public Object process(EvaluationManager manager) {
            return 0;
        }

        @Override
        public void getDependencies(DependencyManager fdm) {
        }

        @Override
        public long getPriority() {
            return 0;
        }

        @Override
        public Class getVariableFormat() {
            return Number.class;
        }

        @Override
        public String getIdentification() {
            return "SET";
        }

        @Override
        public String getInstructions() {
            return "0";
        }
    });
    setup.getSolverFactory().addSolverFormat(String.class, new Modifier() {

        @Override
        public Object process(EvaluationManager manager) {
            return "";
        }

        @Override
        public void getDependencies(DependencyManager fdm) {
        }

        @Override
        public long getPriority() {
            return 0;
        }

        @Override
        public Class getVariableFormat() {
            return String.class;
        }

        @Override
        public String getIdentification() {
            return "SET";
        }

        @Override
        public String getInstructions() {
            return "";
        }
    });
}
Also used : SplitFormulaSetup(pcgen.base.solver.SplitFormulaSetup) IndividualSetup(pcgen.base.solver.IndividualSetup) DependencyManager(pcgen.base.formula.base.DependencyManager) EvaluationManager(pcgen.base.formula.base.EvaluationManager) MonitorableVariableStore(pcgen.cdom.formula.MonitorableVariableStore) Modifier(pcgen.base.solver.Modifier)

Example 3 with DependencyManager

use of pcgen.base.formula.base.DependencyManager in project pcgen by PCGen.

the class AbstractFormulaTestCase method getVariables.

protected List<VariableID<?>> getVariables(SimpleNode node) {
    DependencyManager fdm = generateDependencyManager(getFormulaManager(), getGlobalScopeInst(), null);
    new DependencyVisitor().visit(node, fdm);
    return fdm.getVariables();
}
Also used : DependencyVisitor(pcgen.base.formula.visitor.DependencyVisitor) DependencyManager(pcgen.base.formula.base.DependencyManager)

Example 4 with DependencyManager

use of pcgen.base.formula.base.DependencyManager in project pcgen by PCGen.

the class AbstractFormulaTestCase method getVariables.

protected List<VariableID<?>> getVariables(SimpleNode node) {
    DependencyManager fdm = managerFactory.generateDependencyManager(getFormulaManager(), getGlobalScopeInst(), null);
    new DependencyVisitor().visit(node, fdm);
    return fdm.getVariables();
}
Also used : DependencyVisitor(pcgen.base.formula.visitor.DependencyVisitor) DependencyManager(pcgen.base.formula.base.DependencyManager)

Aggregations

DependencyManager (pcgen.base.formula.base.DependencyManager)4 DependencyVisitor (pcgen.base.formula.visitor.DependencyVisitor)2 DynamicDependency (pcgen.base.formula.base.DynamicDependency)1 EvaluationManager (pcgen.base.formula.base.EvaluationManager)1 TrainingStrategy (pcgen.base.formula.base.TrainingStrategy)1 ASTPCGenSingleWord (pcgen.base.formula.parse.ASTPCGenSingleWord)1 ASTQuotString (pcgen.base.formula.parse.ASTQuotString)1 IndividualSetup (pcgen.base.solver.IndividualSetup)1 Modifier (pcgen.base.solver.Modifier)1 SplitFormulaSetup (pcgen.base.solver.SplitFormulaSetup)1 MonitorableVariableStore (pcgen.cdom.formula.MonitorableVariableStore)1