コード例 #1
0
 public void Push(IntendedPlan ip)
 {
     plans.Insert(0, ip);
     if (ip.IsAtomic())
     {
         atomicCount++;
     }
 }
コード例 #2
0
        public IntendedPlan Pop()
        {
            IntendedPlan top = plans[0];

            plans.RemoveAt(0);

            if (IsAtomic() && top.IsAtomic())
            {
                atomicCount--;
            }
            return(top);
        }
コード例 #3
0
        public object Clone()
        {
            IntendedPlan c = new IntendedPlan();

            c.unif = unif.Clone();
            if (planBody != null)
            {
                c.planBody = planBody.ClonePB();
            }
            c.trigger = trigger.Clone();
            c.plan    = plan;
            return(c);
        }
コード例 #4
0
        // Remove all IP until the lowest IP with trigger te
        public virtual bool DropDesire(Trigger te, Unifier un)
        {
            bool         r  = false;
            IntendedPlan ip = GetIntendedPlan(te, un);

            while (ip != null)
            {
                r = true;
                while (Peek() != ip)
                {
                    Pop();
                }
                Pop();                        // Remove IP
                ip = GetIntendedPlan(te, un); // Keep removing other occurrences of te
            }
            return(r);
        }
コード例 #5
0
        public virtual KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c)
        {
            Trigger failTrigger           = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral());
            IEnumerator <IntendedPlan> ii = GetEnumerator();
            int posInStak = Size();

            // synchronized (pl.GetLock())
            while (!pl.HasCandidatePlan(failTrigger) && ii.MoveNext())
            {
                IntendedPlan ip = ii.Current;
                tevent      = ip.GetTrigger();
                failTrigger = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral());
                posInStak--;
            }
            if (tevent.IsDesire() && tevent.IsAddition() && pl.HasCandidatePlan(failTrigger))
            {
                return(new KeyValuePair <Event, int>(new Event(failTrigger.Clone(), this), posInStak));
            }
            else
            {
                return(new KeyValuePair <Event, int>(null, 0));
            }
        }