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); } }
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); } }
public void Notify() { ColObserver pNode = this.pHead; while (pNode != null) { pNode.Notify(); pNode = (ColObserver)pNode.pNext; } }
//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; } }
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; } }
//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; } }
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; } }
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; } }
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; } }
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; } }
//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; } }
//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); } }
public ColSubject() { this.pHead = null; this.pObjA = null; this.pObjB = null; }
public void Attach(ColObserver observer) { this.poSubject.Attach(observer); }
private DelayedObjectManager() { this.pHeadColObserver = null; }
private DelayedObjectMan() { this.head = null; }
public void Detach(ColObserver observer) { base.baseDetach(observer); }
public void Attach(ColObserver observer) { // protection Debug.Assert(observer != null); base.baseAttach(observer); }