Ejemplo n.º 1
0
        private void OnStructureChange(object obj, StructureChangeType chType, bool isPropagated)
        {
            #region Rule #1. If a vertex loses or gains a predecessor, it invalidates all of its sucessors.
            if (StructureChangeTypeSvc.IsPreEdgeChange(chType))
            {
                if (obj is Vertex)
                {
                    Vertex    vertex     = (Vertex)obj;
                    ArrayList successors = new ArrayList();
                    successors.AddRange(vertex.GetSuccessors());
                    while (successors.Count > 0)
                    {
                        IHasValidity ihv = (IHasValidity)successors[0];
                        successors.RemoveAt(0);
                        if (ihv is Tasks.Task)
                        {
                            ((Tasks.Task)ihv).SelfValidState = false;
                        }
                        else
                        {
                            successors.AddRange(ihv.GetSuccessors());
                        }
                    }
                }
            }
            #endregion

            m_dirty = true;
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Establishes mappings between validity nodes and the elements they monitor.
            /// </summary>
            public void EstablishMappingsToValidityNodes()
            {
                if (m_successors.Count > 0)
                {
                    if (!(m_successors[0] is ValidityNode))
                    {
                        for (int i = 0; i < m_successors.Count; i++)
                        {
                            m_successors[i] = m_validationService.m_htNodes[m_successors[i]];
                        }
                    }
                }

                if (m_children.Count > 0)
                {
                    if (!(m_children[0] is ValidityNode))
                    {
                        for (int i = 0; i < m_children.Count; i++)
                        {
                            m_children[i] = m_validationService.m_htNodes[m_children[i]];
                        }
                    }
                }

                IHasValidity myParent = m_mine.GetParent();

                if (m_parent == null && myParent != null)
                {
                    m_parent = (ValidityNode)m_validationService.m_htNodes[myParent];
                }
            }
Ejemplo n.º 3
0
        /// <summary>
        /// Notifies the specified object in the graph of its self state change.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        public void NotifySelfStateChange(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn != null)
            {
                vn.NotifySelfStateChange(ihv.SelfState);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the invalid child count of the specified object in the graph.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        /// <returns>The invalid child count of the specified object in the graph.</returns>
        public int GetInvalidChildCountOf(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return(int.MinValue);
            }
            return(vn.InvalidChildCount);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the aggregate validity state of the children of the specified object in the graph.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        /// <returns>The aggregate validity state of the children of the specified object in the graph.</returns>
        public Validity GetChildValidityState(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return(Validity.Invalid);
            }
            return(vn.ChildrenValid?Validity.Valid:Validity.Invalid);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the state of validity of the predecessors of the specified object in the graph.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        /// <returns>The state of validity of the predecessors of the specified object in the graph.</returns>
        public Validity GetPredecessorValidityState(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return(Validity.Invalid);
            }
            return(vn.PredecessorsValid?Validity.Valid:Validity.Invalid);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Gets the overall state of the validity of the specified object in the graph.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        /// <returns>The</returns>
        public Validity GetValidityState(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return(Validity.Invalid);
            }
            return(vn.OverallValid?Validity.Valid:Validity.Invalid);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates a status report that describes the validity state of the graph, at and below the provided node.
        /// </summary>
        /// <param name="ihv">The provided node that is to be the root of this report.</param>
        /// <returns></returns>
        public string StatusReport(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return("Unknown object - " + ihv);
            }
            else
            {
                return(vn.Name + " : Self " + vn.SelfValid + ", Preds = " + vn.PredecessorsValid + "(" + vn.InvalidPredecessorCount + ") Children = " + vn.ChildrenValid + "(" + vn.InvalidChildCount + ").\r\n");
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Creates a new instance of the <see cref="T:ValidationService"/> class.
 /// </summary>
 /// <param name="root">The root task of the directed acyclic graph.</param>
 public ValidationService(Tasks.Task root)
 {
     m_root                    = root.PreVertex;
     m_suspensions             = 0;
     m_dirty                   = true;
     m_structureChangeListener = new StructureChangeHandler(OnStructureChange);
     if (s_diagnostics)
     {
         m_suspendResumeStack = new Stack();
     }
     _knownServices.Add(this);
     Refresh();
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Gets the parent of the specified object in the graph.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        /// <returns>The parent of the specified object in the graph.</returns>
        public IHasValidity GetParentOf(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return(null);
            }
            if (vn.Parent == null)
            {
                return(null);
            }
            return(vn.Parent.Mine);
        }
Ejemplo n.º 11
0
 private void AddNode(IHasValidity ihv)
 {
     if (!m_htNodes.Contains(ihv))
     {
         ValidityNode vn = new ValidityNode(this, ihv);
         m_htNodes.Add(ihv, vn);
         IList list = ihv.GetSuccessors();
         if (list.Count > 0)
         {
             foreach (object obj in list)
             {
                 IHasValidity successor = (IHasValidity)obj;
                 AddNode(successor);
             }
         }
     }
     ihv.StructureChangeHandler += m_structureChangeListener;
 }
Ejemplo n.º 12
0
 public ValidityNode(ValidationService validationService, IHasValidity mine)
 {
     m_nInvalidChildren     = 0;
     m_nInvalidPredecessors = 0;
     m_validationService    = validationService;
     m_mine = mine;
     m_mine.ValidationService = m_validationService;
     m_successors             = new ArrayList(mine.GetSuccessors());
     m_children     = new ArrayList(mine.GetChildren());
     m_predecessors = new ArrayList();
     if (m_mine is SimCore.IHasName)
     {
         m_name = ((SimCore.IHasName)m_mine).Name;
     }
     else
     {
         m_name = m_mine.GetType().ToString();
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the children of the specified object in the graph.
        /// </summary>
        /// <param name="ihv">The specified object in the graph.</param>
        /// <returns>The children of the specified object in the graph.</returns>
        public IList GetChildrenOf(IHasValidity ihv)
        {
            ValidityNode vn = (ValidityNode)m_htNodes[ihv];

            if (vn == null)
            {
                return(s_empty_List);
            }

            ArrayList retval = new ArrayList();

            foreach (ValidityNode subNode in vn.Children)
            {
                IHasValidity ihv2 = subNode.Mine;
                retval.Add(ihv2);
            }

            return(retval);
        }