コード例 #1
0
 protected LocatableSetBase(Pathable parent)
     : base()
 {
     Check.Require(parent != null, "parent must not be null");
     this.parent = parent;
     Check.Ensure(this.parent != null, "parent must not be null");
 }
コード例 #2
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Id != null
                    ? Id.GetHashCode()
                    : 0;
                hashCode = (hashCode * 397) ^ (Title != null
                    ? Title.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (Name != null
                    ? Name.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (int)Type;
                hashCode = (hashCode * 397) ^ (Category != null
                    ? Category.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ Pathable.GetHashCode();
                hashCode = (hashCode * 397) ^ (Parent != null
                    ? Parent.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ (ExtraTitleInfo != null
                    ? ExtraTitleInfo.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ Segmentable.GetHashCode();
                hashCode = (hashCode * 397) ^ (Description != null
                    ? Description.GetHashCode()
                    : 0);
                hashCode = (hashCode * 397) ^ AllowedForReporting.GetHashCode();

                return hashCode;
            }
        }
コード例 #3
0
ファイル: Pather.cs プロジェクト: Jeffersah/FP1
        public static Path GeneratePath(Pathable s, Pathable endPoint)
        {
            closedList.Clear();
            OpenHeap.openHeap.Clear();

            PathNode start = new PathNode(s, endPoint);

            start.setF(0);
            closedList.Add(start);

            foreach (Pathable s2 in start.element.getConnected())
            {
                OpenHeap.addToHeap(new PathNode(s2, endPoint, start));
            }

            bool done = false;

            while (!done)
            {
                if (OpenHeap.openHeap.Count == 0)
                {
                    return(null);
                }

                PathNode next = OpenHeap.removeFirst();

                if (next.element == endPoint)
                {
                    return(next.generatePath());
                }

                closedList.Add(next);
                foreach (Pathable s2 in next.element.getConnected())
                {
                    PathNode pnext = new PathNode(s2, endPoint, next);

                    if (!closedList.Contains(pnext))
                    {
                        if (!OpenHeap.contains(pnext))
                        {
                            OpenHeap.addToHeap(pnext);
                        }
                        else
                        {
                            if (OpenHeap.openHeap[OpenHeap.openHeap.IndexOf(pnext)].F > pnext.F)
                            {
                                OpenHeap.openHeap[OpenHeap.openHeap.IndexOf(pnext)].parentNode = next;
                                OpenHeap.openHeap[OpenHeap.openHeap.IndexOf(pnext)].setF(next);
                            }
                            else
                            {
                            }
                        }
                    }
                }
            }

            return(null);
        }
コード例 #4
0
ファイル: Pather.cs プロジェクト: Jeffersah/FP1
        public PathNode(Pathable s, Pathable hub, PathNode parent)
        {
            parentNode = parent;
            element    = s;
            H          = s.getHeuristicScore(hub);

            setF(parent.F + s.getMoveScore(parentNode.element));
        }
コード例 #5
0
ファイル: Path.cs プロジェクト: jascou/ROTNS
 public Path(Pathable <T> Start, Pathable <T> Destination, Func <T, T, bool> FinishState)
     : this((T)Start, (T)Destination,
            P => ((Pathable <T>)P).Passable,
            (P1, P2) => ((Pathable <T>)P1).DistanceTo(P2),
            (P1, P2) => ((Pathable <T>)P1).HeuristicDistanceTo(P2),
            P => ((Pathable <T>)P).Neighbors(),
            FinishState)
 {
 }
コード例 #6
0
ファイル: PathableList.cs プロジェクト: panky2sharma/OpenEHR
        internal PathableList(Pathable parent)
            : this()
        {
            Check.Require(parent != null, "parent must not be null");

            this.parent = parent;

            Check.Invariant(this.parent != null, "parent must not be null");
        }
コード例 #7
0
        protected override void AddItem(T item)
        {
            Check.Invariant(identifiedLocatables != null, "identifiedLocatables must not be null");

            Pathable locatable = item as Pathable;

            Check.Assert(item != null, "item must not be null");

            if (item.Parent == null)
            {
                item.Parent = this.Parent;
            }

            else if (this.Parent == null)
            {
                this.Parent = item.Parent;
            }

            else if (!Object.ReferenceEquals(item.Parent, this.Parent))
            {
                throw new ApplicationException("item parent must have same parent as other items");
            }

            LocatableBindingListView <T> namedLocatables;

            if (identifiedLocatables.ContainsKey(item.ArchetypeNodeId))
            {
                namedLocatables = identifiedLocatables[item.ArchetypeNodeId];
            }
            else
            {
                namedLocatables = new LocatableBindingListView <T>();
                identifiedLocatables.Add(item.ArchetypeNodeId, namedLocatables);
            }

            DvCodedText codedName = item.Name as DvCodedText;

            if (codedName != null)
            {
                if (namedLocatables.Contains(codedName.DefiningCode.TerminologyId.Value, codedName.DefiningCode.CodeString))
                {
                    throw new ApplicationException(string.Format("locatable ({0}) name ({1}) already existing in the namedLocatable list.",
                                                                 item.ArchetypeNodeId, codedName.ToString()));
                }
            }
            else if (namedLocatables.Contains(item.Name.Value))
            {
                throw new ApplicationException(string.Format("locatable ({0}) name ({1}) already existing in this namedLocatable list",
                                                             item.ArchetypeNodeId, item.Name.Value));
            }

            namedLocatables.Add(item);

            base.AddItem(item);
        }
コード例 #8
0
        public static Path GeneratePath(Pathable start, Pathable end)
        {
            OpenHeap2       openList   = new OpenHeap2();
            List <PathNode> closedList = new List <PathNode>();
            Pathable        next       = start;
            PathNode        thefirst   = new PathNode(next, end);

            thefirst.setF(0);
            closedList.Add(thefirst);

            foreach (Pathable s2 in thefirst.element.getConnected())
            {
                openList.openHeap.Add(new PathNode(s2, end, thefirst));
            }

            while (openList.openHeap.Count > 0)
            {
                PathNode nextpathnode = openList.getFirst();
                closedList.Add(nextpathnode);

                if (nextpathnode.element.Equals(end))
                {
                    return(nextpathnode.generatePath());
                }

                foreach (Pathable s2 in nextpathnode.element.getConnected())
                {
                    PathNode pn = new PathNode(s2, end, nextpathnode);
                    if (closedList.Contains(pn))
                    {
                    }
                    else if (openList.contains(pn))
                    {
                        int index = openList.openHeap.IndexOf(pn);
                        if (openList.openHeap[index].F > nextpathnode.F)
                        {
                            openList.openHeap[index].parentNode = nextpathnode;
                            openList.openHeap[index].setF(nextpathnode);
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        openList.add(pn);
                    }
                }
            }

            return(null);
        }
コード例 #9
0
ファイル: PathableList.cs プロジェクト: panky2sharma/OpenEHR
        internal PathableList(Pathable parent, System.Collections.Generic.IEnumerable <T> items)
            : this(parent)
        {
            if (items != null)
            {
                foreach (T item in items)
                {
                    item.Parent = null;
                    AddItem(item);
                }
            }

            Check.Invariant(this.parent != null, "parent must not be null");
        }
コード例 #10
0
ファイル: ActivePath.cs プロジェクト: Jeffersah/FP1
 /// <summary>
 /// The specified pathable was reached - advance the path
 /// </summary>
 /// <param name="p">Which pathable was reached</param>
 public void reached(Pathable p)
 {
     if (isPathDone)
     {
         return;
     }
     if (p == base.getLast())
     {
         isPathDone = true;
     }
     else
     {
         currentlyReached = base.getNext(p);
     }
 }
コード例 #11
0
        private object ItemAtPathUtil(string path)
        {
            DesignByContract.Check.Require(!string.IsNullOrEmpty(path), "Path must not be null or empty.");

            object itemAtPath;

            if (path == "/")
            {
                Pathable pathableObject = this;

                while (pathableObject.Parent != null)
                {
                    pathableObject = pathableObject.Parent;
                }

                itemAtPath = pathableObject;
            }
            else
            {
                Path pathProcessor = new Path(path);

                //// The itemAtPath can be a single item which is a pathable, a locatable
                //// or a non-pathable item.
                //// The itemAtPath can be an IList instance when the path points to
                //// a locatable collection with multiple items or a single item;
                //// or it can be an IList with one or more
                //// locatables when the path looks like //*[archetype ID] (i.e. the path is not
                //// named and is terminal)
                //// The itemAtPath can be null when the path doesn't exist.
                //object itemAtPath = this.ItemAtPathPathProcessorUtil(pathProcessor);
                itemAtPath = pathProcessor.ItemAtPath(this);

                if (this.itemAtPathDictionary == null)
                {
                    itemAtPathDictionary = new System.Collections.Generic.Dictionary <string, object>();
                }
                // this function is called only when the itemAtPathDictionary doesn't have the key - path,
                // therefore, don't need to check whether the dictionary has the key or not before
                // adding the key-value pair.
                Check.Assert(!this.itemAtPathDictionary.ContainsKey(path), "itemAtPathDiction must not contain path");
                if (itemAtPath != null)
                {
                    this.itemAtPathDictionary.Add(path, itemAtPath);
                }
            }
            return(itemAtPath);
        }
コード例 #12
0
ファイル: ActivePath.cs プロジェクト: Jeffersah/FP1
 /// <summary>
 /// The next pathable was reached - advance the path
 /// </summary>
 public void reachedNext()
 {
     if (isPathDone)
     {
         return;
     }
     if (currentlyReached == null)
     {
         currentlyReached = getFirst();
     }
     if (currentlyReached == base.getLast())
     {
         isPathDone = true;
     }
     else
     {
         currentlyReached = base.getNext(currentlyReached);
     }
 }
コード例 #13
0
        /// <summary>
        /// In this method, it is assumed that the locatable must be the child of this class.
        /// </summary>
        /// <param name="locatable"></param>
        /// <returns></returns>
        private string PathOfItemSimple(Pathable item)
        {
            Check.Require(item != null);

            string path          = null;
            string pathSeperator = "/";

            System.Collections.Generic.ICollection <System.Collections.Generic.KeyValuePair <string, object> > keyValueList
                = this.attributesDictionary as System.Collections.Generic.ICollection <System.Collections.Generic.KeyValuePair <string, object> >;
            foreach (System.Collections.Generic.KeyValuePair <string, object> listItem in keyValueList)
            {
                ILocatableList locatableList = listItem.Value as ILocatableList;
                Pathable       locatableItem = listItem.Value as Pathable;

                if (locatableList != null)
                {
                    Locatable itemLocatable = item as Locatable;
                    if (locatableList.Contains(itemLocatable))
                    {
                        DesignByContract.Check.Assert(itemLocatable.Name != null);

                        return(path = pathSeperator + listItem.Key + "[" + itemLocatable.ArchetypeNodeId +
                                      " and name/value='" + itemLocatable.Name.Value + "']");
                    }
                }
                else if (listItem.Value == item)
                {
                    // must be locatable
                    if (item is Locatable)
                    {
                        return(path = pathSeperator + listItem.Key + "[" + ((Locatable)item).ArchetypeNodeId + "]");
                    }
                    else
                    {
                        return(path = pathSeperator + listItem.Key);
                    }
                }
            }

            // raise exception?
            throw new InvalidOperationException("item not found in parent's items");
        }
コード例 #14
0
        /// <summary>
        /// The path to an item relative to the root of this archetyped structure.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override string PathOfItem(Pathable item)
        {
            //throw new Exception("The method or operation is not implemented.");
            DesignByContract.Check.Require(item != null);

            //Locatable item = locatable as Locatable;
            DesignByContract.Check.Assert(item != null);

            AttributeDictionaryPathable itemParent = item.Parent as AttributeDictionaryPathable;

            Check.Assert(item.Parent == null || itemParent != null, "itemParent must not be null");

            // when the item is the top level (e.g. composition) or doesn't have a parent,
            // the path is "/"
            if (itemParent == null)
            {
                return("/");
            }

            string path = "";

            while (!this.Equals(itemParent))
            {
                path = itemParent.PathOfItemSimple(item) + path;
                item = itemParent;
                if (item.Parent == null)
                {
                    throw new ApplicationException("root of item not found, item is not a decendent of this object");
                }

                itemParent = item.Parent as AttributeDictionaryPathable;
                Check.Assert(item.Parent == null || itemParent != null, "itemParent must not be null");
            }

            path = itemParent.PathOfItemSimple(item) + path;

            return(path);
        }
コード例 #15
0
ファイル: PathableList.cs プロジェクト: panky2sharma/OpenEHR
        protected override void AddItem(T item)
        {
            Pathable pathable = item as Pathable;

            Check.Assert(item != null, "item must not be null");

            if (item.Parent == null)
            {
                item.Parent = this.parent;
            }

            else if (this.parent == null)
            {
                this.parent = item.Parent;
            }

            else if (!Object.ReferenceEquals(item.Parent, this.parent))
            {
                throw new ApplicationException("item parent must have same parent as other items");
            }

            base.AddItem(item);
        }
コード例 #16
0
 public override string PathOfItem(Pathable item)
 {
     throw new Exception("The method or operation is not implemented.");
 }
コード例 #17
0
ファイル: Pather.cs プロジェクト: Jeffersah/FP1
 public PathNode(Pathable s, Pathable hub)
 {
     parentNode = null;
     element    = s;
     H          = s.getHeuristicScore(hub);
 }
コード例 #18
0
ファイル: IsmTransition.cs プロジェクト: nickvane/vela
 ///<summary>
 /// The path to an item relative to the root of this archetyped structure.
 ///</summary>
 ///<param name="item"></param>
 ///<returns></returns>
 public override string GetPathOfItem(Pathable item)
 {
     throw new NotImplementedException();
 }
コード例 #19
0
        /// <summary>
        /// The path to an item relative to the root of this archetyped structure.
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public override string PathOfItem(Pathable item)
        {
            //throw new Exception("The method or operation is not implemented.");
            DesignByContract.Check.Require(item != null);

            //Locatable item = locatable as Locatable;
            DesignByContract.Check.Assert(item != null);

            AttributeDictionaryPathable itemParent = item.Parent as AttributeDictionaryPathable;
            Check.Assert(item.Parent == null || itemParent != null, "itemParent must not be null");

            // when the item is the top level (e.g. composition) or doesn't have a parent,
            // the path is "/"
            if (itemParent == null)
                return "/";

            string path = "";

            while (!this.Equals(itemParent))
            {
                path = itemParent.PathOfItemSimple(item) + path;
                item = itemParent;
                if (item.Parent == null)
                    throw new ApplicationException("root of item not found, item is not a decendent of this object");

                itemParent = item.Parent as AttributeDictionaryPathable;
                Check.Assert(item.Parent == null || itemParent != null, "itemParent must not be null");
            }

            path = itemParent.PathOfItemSimple(item) + path;

            return path;
        }
コード例 #20
0
        /// <summary>
        /// In this method, it is assumed that the locatable must be the child of this class.
        /// </summary>
        /// <param name="locatable"></param>
        /// <returns></returns>
        private string PathOfItemSimple(Pathable item)
        {
            Check.Require(item != null);

            string path = null;
            string pathSeperator = "/";

            System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>> keyValueList
                = this.attributesDictionary as System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>;
            foreach (System.Collections.Generic.KeyValuePair<string, object> listItem in keyValueList)
            {
                ILocatableList locatableList = listItem.Value as ILocatableList;
                Pathable locatableItem = listItem.Value as Pathable;

                if (locatableList != null)
                {
                    Locatable itemLocatable = item as Locatable;
                    if (locatableList.Contains(itemLocatable))
                    {
                        DesignByContract.Check.Assert(itemLocatable.Name != null);

                        return path = pathSeperator + listItem.Key + "[" + itemLocatable.ArchetypeNodeId +
                                      " and name/value='" + itemLocatable.Name.Value + "']";
                    }
                }
                else if (listItem.Value == item)
                {
                    // must be locatable
                    if (item is Locatable)
                        return path = pathSeperator + listItem.Key + "[" + ((Locatable)item).ArchetypeNodeId + "]";
                    else
                        return path = pathSeperator + listItem.Key;
                }
            }

            // raise exception?
            throw new InvalidOperationException("item not found in parent's items");
        }
コード例 #21
0
 public override string PathOfItem(Pathable item)
 {
     throw new Exception("The method or operation is not implemented.");
 }
コード例 #22
0
ファイル: InstructionDetails.cs プロジェクト: nickvane/vela
 ///<summary>
 /// The path to an item relative to the root of this archetyped structure.
 ///</summary>
 ///<param name="item"></param>
 ///<returns></returns>
 public override string GetPathOfItem(Pathable item)
 {
     throw new NotImplementedException();
 }
コード例 #23
0
ファイル: Path.cs プロジェクト: jascou/ROTNS
 public Path(Pathable <T> Start, Pathable <T> Destination)
     : this(Start, Destination, DefaultFinishState)
 {
 }