/******************************************************************************/
/*																										*/
/*	Name		:	ILIST.H			  																*/
/* Date     :  4/30/1997                                                      */
/* Author   :  Jim Susoy                                                      */
/* Notice   :  (C) 1997 Qualcomm, Inc. - All Rights Reserved                  */
/* Copyright (c) 2016, Computer History Museum 
All rights reserved. 
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to 
the limitations in the disclaimer below) provided that the following conditions are met: 
 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 
 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 
   disclaimer in the documentation and/or other materials provided with the distribution. 
 * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products 
   derived from this software without specific prior written permission. 
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE 
COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
DAMAGE. */

/*	Desc.		:	Linked list manager class definitions									*/
/*																										*/
/******************************************************************************/
#ifndef _ILIST_H_
#define _ILIST_H_

typedef struct TAGITEM {
	struct TAGITEM		*pPrev;
	struct TAGITEM    *pNext;
} ITEM;
typedef ITEM * LPITEM;

/* IList creation types																			*/
typedef enum {
	ILIST_SINGLE,								/* Not Yet Supported							*/
	ILIST_DOUBLE,
} ILIST_TYPE;

/* IList creation flags																			*/
#define ILIST_NOFLAGS			0x000000
#define ILIST_APPEND				0x000001	/* Unsorted append to list					*/
#define ILIST_PREPEND   		0x000002	/* Unsorted prepend to list            */
#define ILIST_ASCENDING			0x000004	/*	Not Yet Supported			            */
#define ILIST_DESCENDING 		0x000008	/* Not Yet Supported			            */
#define ILIST_STANDARDALLOC	0x000010	/* Use free instead of calling FreeCB	*/

/* Values for wWhere paramater to Insert()												*/
#define ILIST_INS_BEFORE		1
#define ILIST_INS_AFTER			2
#define ILIST_INS_SORTED      3			/* Not yet supported							*/

/* Returns values for verify linkage														*/
#define ILIST_OK					0
#define ILIST_BADFORLINK      1
#define ILIST_BADBACKLINK     2

/* Handly-Dandy helper macros																	*/
#define ILIST_ITEMNEXT(i)		(LPVOID)((LPITEM)i)->pNext
#define ILIST_ITEMPREV(i)     (LPVOID)((LPITEM)i)->pPrev

typedef void (*ILISTFREECB)(LPITEM pItem,LPVOID pUser);

typedef class IListMan * LPILISTMAN;
class IListMan : public IUnknown
{
public:
	BOOL     virtual PASCAL Initialize(ILISTFREECB pCB,LPVOID pUser) PURE;
	void 		virtual PASCAL Attach(LPVOID pItem) PURE;
	void		virtual PASCAL Insert(LPVOID pRefItem,LPVOID pItem,WORD wWhere) PURE;
	LPVOID 	virtual PASCAL Unlink(LPVOID pItem) PURE;
	void		virtual PASCAL DeleteItem(LPVOID pItem) PURE;
	void 		virtual PASCAL Erase(void) PURE;
	LPVOID	virtual PASCAL Head(void) PURE;
	DWORD   	virtual PASCAL Count(void) PURE;
	void 		virtual PASCAL Push(LPVOID pItem) PURE;
	LPVOID	virtual PASCAL Pop() PURE;
	WORD		virtual PASCAL VerifyList(void) PURE;
} ;

/* CLSID_IList 	15f307c0-cb19-11d0-8d36-00a02471d0b1 (Generated by uuidgen.exe) */
#define ILISTMAN_CLASS_STR	L"{15f307c0-cb19-11d0-8d36-00a02471d0b1}"
DEFINE_GUID(CLSID_IListMan,0x15f307c0,0xcb19,0x11d0,0x8d,0x36,0x00,0xa0,0x24,0x71,0xd0,0xb1);

/* IID_ILIST 		421291c0-cb19-11d0-8d36-00a02471d0b1 (Generated by uuidgen.exe) */
#define ILISTMAN_IID_STR	L"{421291c0-cb19-11d0-8d36-00a02471d0b1}"
DEFINE_GUID(IID_IListMan, 	0x421291c0,0xcb19,0x11d0,0x8d,0x36,0x00,0xa0,0x24,0x71,0xd0,0xb1);

#endif


