#include "stdafx.h" #include "VisList.h" //------------------------------------------------------------------------ // // VisList.cpp // // This class wraps a CList, addining a few extra methods, to manage a list // of CVisInterface pointers. // // ------------------------------------------------------------------- // * COPYRIGHT 2001, Greg Ratajik and Ratajik Software * // * All rights Reserved * // ------------------------------------------------------------------- // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // // More information about this program can be found at: // http://www.ratajik.com/VisInterface // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //------------------------------------------------------------------------ //------------------------------------------------------------------------ // // Method: operator+= // // Description: Add the passed pointer to the list. // if it's a valid vis. // // Parms: CVisInterface * - The pointer to add. // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisList :: operator += (CVisInterface * pNewVis) { AddHead(pNewVis); } //------------------------------------------------------------------------ // // Method: operator-= // // Description: Remove the passed pointer to the list. // if it's a valid vis. // // Parms: CVisInterface * - The pointer to remove. // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisList :: operator -= (CVisInterface * pOldVis) { for (POSITION posIt = GetHeadPosition(); posIt != NULL; GetNext(posIt)) { CVisInterface* pVis = GetAt(posIt); ASSERT(pVis != NULL); // Something bad is up if this is hit. if(pVis == pOldVis) { RemoveAt(posIt); return; } } } //------------------------------------------------------------------------ // // Method: RemoveAll // // Description: Will go through the list, deleting each pointer, then will // delete the list. // // Parms: N/A // // Return: void // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ void CVisList :: RemoveAll() { for (POSITION posIt = GetHeadPosition(); posIt != NULL; GetNext(posIt)) { CVisInterface* pVis = GetAt(posIt); ASSERT(pVis != NULL); // Something bad is up if this is hit. if(pVis) { delete pVis, pVis = NULL; } } CList::RemoveAll(); } //------------------------------------------------------------------------ // // Method: Find // // Description: Find the passed pointers place in the list. // // Parms: CVisInterface * - The pointer to find. // // Return: POSITION - The position (NULL if not found) // // Exceptions: N/A // // C H A N G E L O G // ===================================================================== // Change ID Date Programmer Description // ============ ========= =========== ================================ // 02-21-01 Ratajik Initial Development //_________________________________________________________________________ POSITION CVisList :: Find(CVisInterface* pVisFind) { for (POSITION posIt = GetHeadPosition(); posIt != NULL; GetNext(posIt)) { CVisInterface *pVis = GetAt(posIt); ASSERT(pVis != NULL); if(pVis) { if(pVis == pVisFind) return(posIt); } } return(NULL); }