コード例 #1
0
 /// <summary> The key is either the Defclass or a string name
 /// </summary>
 public virtual bool containsTemplate(Object key)
 {
     if (key is Defclass)
     {
         Defclass dc = (Defclass)key;
         return(deftemplates.ContainsKey(dc.ClassObject.FullName));
     }
     else
     {
         return(deftemplates.ContainsKey(key));
     }
 }
コード例 #2
0
 /// <summary>
 /// Add a new ObjectTypeNode. The implementation will check to see
 /// if the node already exists. It will only Add the node if it
 /// doesn't already exist in the network.
 /// </summary>
 /// <param name="node">The node.</param>
 public virtual void addObjectTypeNode(ObjectTypeNode node)
 {
     if (!inputNodes.ContainsKey(node.Deftemplate))
     {
         inputNodes.Put(node.Deftemplate, node);
     }
 }
コード例 #3
0
ファイル: TestNode.cs プロジェクト: joaocc/creshendo--git
        /// <summary>
        /// </summary>
        public override void retractLeft(Index linx, Rete engine, IWorkingMemory mem)
        {
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);

            if (leftmem.ContainsKey(linx))
            {
                // the memory Contains the key, so we retract and propogate
                leftmem.Remove(linx);
                propogateRetract(linx, engine, mem);
            }
        }
コード例 #4
0
        public virtual bool isPartialMatch(IHashIndex index, IFact fact)
        {
            IGenericMap <Object, Object> list = (IGenericMap <Object, Object>)memory[index];

            if (list != null)
            {
                return(list.ContainsKey(fact));
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        /// <summary> Retract from the right works in the following order.
        /// 1. Remove the fact from the right memory
        /// 2. check which left memory matched
        /// 3. propogate the retract
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void retractRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            Index inx = new Index(new IFact[] { rfact });
            IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this);

            if (rightmem.ContainsKey(inx))
            {
                int count = rightmem.Count;
                rightmem.Remove(inx);
                if (count == 1 && rightmem.Count == 0)
                {
                    propogateRetract(inx, engine, mem);
                }
            }
        }
コード例 #6
0
ファイル: TestNode.cs プロジェクト: joaocc/creshendo--git
        /// <summary> Assert will first pass the facts to the parameters. Once the
        /// parameters are set, it should call execute to Get the result.
        /// </summary>
        public override void assertLeft(Index linx, Rete engine, IWorkingMemory mem)
        {
            IGenericMap <Object, Object> leftmem = (IGenericMap <Object, Object>)mem.getBetaLeftMemory(this);

            if (!leftmem.ContainsKey(linx))
            {
                Parameters = linx.Facts;
                IReturnVector rv = func.executeFunction(engine, params_Renamed);
                if (rv.firstReturnValue().BooleanValue)
                {
                    IBetaMemory bmem = new BetaMemoryImpl(linx);
                    leftmem.Put(bmem.Index, bmem);
                    propogateAssert(linx, engine, mem);
                }
            }
        }
コード例 #7
0
        /// <summary> Assert from the right side is always going to be from an
        /// Alpha node.
        /// </summary>
        /// <param name="">factInstance
        /// </param>
        /// <param name="">engine
        ///
        /// </param>
        public override void assertRight(IFact rfact, Rete engine, IWorkingMemory mem)
        {
            // we only proceed if the fact hasn't already entered
            // the join node
            Index inx = new Index(new IFact[] { rfact });
            IGenericMap <Object, Object> rightmem = (IGenericMap <Object, Object>)mem.getBetaRightMemory(this);

            if (!rightmem.ContainsKey(inx))
            {
                int count = rightmem.Count;
                rightmem.Put(inx, rfact);
                // now that we've added the facts to the list, we
                // proceed with evaluating the fact
                if (count == 0 && rightmem.Count == 1)
                {
                    propogateAssert(inx, engine, mem);
                }
            }
        }
コード例 #8
0
 /// <summary> implementation uses the deftemplate for the HashMap key and the
 /// node for the value. If the node already exists in the HashMap,
 /// or the key already exists, the compiler will not Add it to the
 /// network.
 /// </summary>
 public virtual void addObjectTypeNode(ObjectTypeNode node)
 {
     if (!inputnodes.ContainsKey(node.Deftemplate))
     {
         inputnodes.Put(node.Deftemplate, node);
     }
     // if it is the objectTypeNode for InitialFact, we go ahead and create
     // the Left Input Adapter node for it
     if (node.Deftemplate is InitialFact)
     {
         try
         {
             IFLIANode lian = new IFLIANode(engine.nextNodeId());
             node.addSuccessorNode(lian, engine, engine.workingMem);
         }
         catch (AssertException e)
         {
         }
     }
 }
コード例 #9
0
        public virtual bool isPartialMatch(NotEqHashIndex index, IFact fact)
        {
            IGenericMap <Object, Object> match = (IGenericMap <Object, Object>)memory.Get(index);

            if (match != null)
            {
                IGenericMap <Object, Object> submatch = (IGenericMap <Object, Object>)match.Get(index.SubIndex);
                if (submatch != null)
                {
                    return(submatch.ContainsKey(fact));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
コード例 #10
0
 public virtual bool containsFact(Deffact fact)
 {
     return(deffactMap.ContainsKey(fact.equalityIndex()));
 }
コード例 #11
0
 /// <summary> If the module already Contains the rule, it will return true.
 /// The lookup uses the rule name, so rule names are distinct
 /// within a single module. The same rule name may be used in
 /// multiple modules.
 /// </summary>
 public virtual bool containsRule(Rule.IRule rl)
 {
     return(rules.ContainsKey(rl.Name));
 }
コード例 #12
0
 /// <summary> The method will check to see if the fact has
 /// previously matched
 /// </summary>
 /// <param name="">rightfacts
 /// </param>
 /// <returns>
 ///
 /// </returns>
 public virtual bool matched(IFact rightfact)
 {
     return(matches.ContainsKey(rightfact));
 }