Ejemplo n.º 1
0
        static public void Process()
        {
            DelayedObjectMan pDelayMan = DelayedObjectMan.PrivGetInstance();

            ColObserver pNode = pDelayMan.head;

            while (pNode != null)
            {
                // Fire off listener
                pNode.Execute();

                pNode = (ColObserver)pNode.pNext;
            }


            // remove
            pNode = pDelayMan.head;
            ColObserver pTmp = null;

            while (pNode != null)
            {
                pTmp  = pNode;
                pNode = (ColObserver)pNode.pNext;

                // remove
                pDelayMan.PrivDetach(pTmp, ref pDelayMan.head);
            }
        }
Ejemplo n.º 2
0
        static public void Process()
        {
            DelayedObjectMan pDelayMan = DelayedObjectMan.PrivGetInstance();

            ColObserver pNode = pDelayMan.head;

            while (pNode != null)
            {
                pNode.Execute();

                pNode = (ColObserver)pNode.pNext;
            }

            pNode = pDelayMan.head;
            ColObserver pTemp = null;

            while (pNode != null)
            {
                pTemp = pNode;

                pNode = (ColObserver)pNode.pNext;

                //this might have been my issue with my timermanager references
                pDelayMan.PrivDetach(pTemp, ref pDelayMan.head);
            }
        }
Ejemplo n.º 3
0
        public void Notify()
        {
            ColObserver pNode = this.pHead;

            while (pNode != null)
            {
                pNode.Notify();

                pNode = (ColObserver)pNode.pNext;
            }
        }
Ejemplo n.º 4
0
        //subject notifies all the observers watching it
        //this will trigger their reaction via Execute() function
        public void Notify()
        {
            ColObserver pNode = this.pHead;

            while (pNode != null)
            {
                // Fire off listener
                pNode.Notify();

                pNode = (ColObserver)pNode.pMNext;
            }
        }
Ejemplo n.º 5
0
        private void PrivDetach(ColObserver node, ref ColObserver head)
        {
            // protection
            Debug.Assert(node != null);

            if (node.pPrev != null)
            {   // middle or last node
                node.pPrev.pNext = node.pNext;
            }
            else
            {  // first
                head = (ColObserver)node.pNext;
            }

            if (node.pNext != null)
            {   // middle node
                node.pNext.pPrev = node.pPrev;
            }
        }
Ejemplo n.º 6
0
        //just like how we use DLink's RemoveNode method
        private void PrivDetach(ColObserver node, ref ColObserver head)
        {
            Debug.Assert(node != null);

            if (node.pPrev != null)
            {
                node.pPrev.pNext = node.pNext;
            }

            else
            {
                head = (ColObserver)node.pNext;
            }

            if (node.pNext != null)
            {
                node.pNext.pPrev = node.pPrev;
            }
        }
Ejemplo n.º 7
0
        public void Attach(ColObserver observer)
        {
            Debug.Assert(observer != null);

            observer.pSubject = this;

            if (pHead == null)
            {
                pHead          = observer;
                observer.pNext = null;
                observer.pPrev = null;
            }

            else
            {
                observer.pNext = pHead;
                pHead.pPrev    = observer;
                pHead          = observer;
            }
        }
Ejemplo n.º 8
0
        public void Attach(ColObserver observer)
        {
            // protection
            Debug.Assert(observer != null);

            observer.pSubject = this;

            // add to front
            if (pHead == null)
            {
                pHead           = observer;
                observer.pMNext = null;
                observer.pMPrev = null;
            }
            else
            {
                observer.pMNext = pHead;
                pHead.pMPrev    = observer;
                pHead           = observer;
            }
        }
Ejemplo n.º 9
0
        static public void Attach(ColObserver observer)
        {
            // protection
            Debug.Assert(observer != null);

            DelayedObjectManager pDelayMan = DelayedObjectManager.privGetInstance();

            // add to front
            if (pDelayMan.pHeadColObserver == null)
            {
                pDelayMan.pHeadColObserver = observer;
                observer.pMNext            = null;
                observer.pMPrev            = null;
            }
            else
            {
                observer.pMNext = pDelayMan.pHeadColObserver;
                observer.pMPrev = null;
                pDelayMan.pHeadColObserver.pMPrev = observer;
                pDelayMan.pHeadColObserver        = observer;
            }
        }
Ejemplo n.º 10
0
        static public void Attach(ColObserver observer)
        {
            // protection
            Debug.Assert(observer != null);

            DelayedObjectMan pDelayMan = DelayedObjectMan.PrivGetInstance();

            // add to front
            if (pDelayMan.head == null)
            {
                pDelayMan.head = observer;
                observer.pNext = null;
                observer.pPrev = null;
            }
            else
            {
                observer.pNext       = pDelayMan.head;
                observer.pPrev       = null;
                pDelayMan.head.pPrev = observer;
                pDelayMan.head       = observer;
            }
        }
Ejemplo n.º 11
0
        //Constructor is towards the bottom of the class body
        static public void Attach(ColObserver observer)
        {
            Debug.Assert(observer != null);

            DelayedObjectMan pDelayMan = DelayedObjectMan.PrivGetInstance();

            //adding to the front
            //first time
            if (pDelayMan.head == null)
            {
                pDelayMan.head = observer;
                observer.pNext = null;
                observer.pPrev = null;
            }

            //every other time
            else
            {
                observer.pNext       = pDelayMan.head;
                observer.pPrev       = null;
                pDelayMan.head.pPrev = observer;
                pDelayMan.head       = observer;
            }
        }
Ejemplo n.º 12
0
        //process any observers in the update loop of main game
        static public void Process()
        {
            //get the manager instance
            DelayedObjectManager pDelayMan = DelayedObjectManager.privGetInstance();

            //First - Fire off all the observers currently on the list

            //get the head observer
            ColObserver pNode = pDelayMan.pHeadColObserver;

            //iterate through the observer list
            while (pNode != null)
            {
                // Fire off listener
                pNode.Execute();

                //get the next observer
                pNode = (ColObserver)pNode.pMNext;
            }


            //done executing all observers - now remove them
            pNode = pDelayMan.pHeadColObserver;
            ColObserver pTmp = null;

            //iterate through the observer list
            while (pNode != null)
            {
                //hold current observer in pTmp for reference after removal
                pTmp  = pNode;
                pNode = (ColObserver)pNode.pMNext;

                // remove observer
                pDelayMan.privDetach(pTmp, ref pDelayMan.pHeadColObserver);
            }
        }
Ejemplo n.º 13
0
 public ColSubject()
 {
     this.pHead = null;
     this.pObjA = null;
     this.pObjB = null;
 }
Ejemplo n.º 14
0
 public void Attach(ColObserver observer)
 {
     this.poSubject.Attach(observer);
 }
Ejemplo n.º 15
0
 private DelayedObjectManager()
 {
     this.pHeadColObserver = null;
 }
Ejemplo n.º 16
0
 private DelayedObjectMan()
 {
     this.head = null;
 }
Ejemplo n.º 17
0
 public void Detach(ColObserver observer)
 {
     base.baseDetach(observer);
 }
Ejemplo n.º 18
0
 public void Attach(ColObserver observer)
 {
     // protection
     Debug.Assert(observer != null);
     base.baseAttach(observer);
 }