// $Id: IDList.h 8019 2007-07-14 22:30:11Z trick $

/* ***** BEGIN LICENSE BLOCK *****
 * Version: MPL 1.1
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * The Original Code is Deadly Rooms of Death.
 *
 * The Initial Developer of the Original Code is
 * Caravel Software.
 * Portions created by the Initial Developer are Copyright (C) 1995, 1996, 
 * 1997, 2000, 2001, 2002 Caravel Software. All Rights Reserved.
 *
 * Contributor(s):
 * Mike Rimer (mrimer)
 *
 * ***** END LICENSE BLOCK ***** */

//IDList.h
//Declarations for CIDList.
//Class for managing a list of ID values.

#ifndef IDLIST_H
#define IDLIST_H

#include "Types.h"
#include "AttachableObject.h"

//Used to maintain a set of IDs with generic attached data.
//If attached data is not required, only a set of IDs, then use the
//simpler and more efficient CIDSet instead.

struct IDNODE
{
	DWORD dwID;
	CAttachableObject *pvPrivate;
	bool bIsAttached;
	IDNODE *pNext;
};

class CIDList : public CAttachableObject
{
public:
	CIDList();
	virtual ~CIDList() {Clear();}

	CIDList(const CIDList &Src);
	CIDList &operator= (const CIDList &Src);
	void operator += (const CIDList &Src);
	void operator -= (const CIDList &Src);
	
	void  Add(const DWORD dwID, CAttachableObject *pvPrivate = NULL, const bool bIsAttached=false);
	bool  AreIDsInList(const UINT wIDArrayCount, const DWORD *pdwIDArray) const;
	void  Clear();
	IDNODE *Get(const DWORD dwIndex) const;
	IDNODE *GetByID(const DWORD dwID) const;
	DWORD GetID(const DWORD dwIndex) const;
	DWORD GetSize() const {return this->dwSize;}
	bool  IsIDInList(const DWORD dwID) const;
	void  Remove(const DWORD dwID);

protected:
	void  RemoveNode(IDNODE* pSeek, IDNODE* pBeforeSeek);

	IDNODE *pFirstID;
	IDNODE *pLastID;
	DWORD dwSize;
};

#endif //...#ifndef IDLIST_H
