//*************************************** // Implements a list of message header objects which can manipulated by position // Items can be added to a position (moving items to make space - if necessary) // Items can be deleted from a specified position (moving items to fill the emptied // space. // Also you can retrieve any item by its position. // Based on object described in Carrano Walls and Mirrors book. // AUTHOR: Chris Wild // DATE: July 25, 1997 //**************************************** #ifndef LIST_MESSAGE_H #define LIST_MESSAGE_H #include "message.h" typedef struct { char topic[SIZE_TOPIC+1]; // topic of this message char fileName[10]; // file name where message is kept } Item ; struct ListNode; typedef ListNode* ListPtr; struct ListNode { Item item; ListPtr next; }; class CListMsgs { public: // Default constructor builds an empty message CListMsgs(); // This constructor reads message list from file CListMsgs(HANDLE listHandle); ~CListMsgs(); // Adds topic to list in "position" // moves other messages down to make room bool AddItem(int position, Item thisItem); bool DeleteItem(int position); bool GetItem(int position, Item& thisItem) const; bool ReadListMsgs(HANDLE listHandle); bool WriteListMsgs(HANDLE listHandle) const; int length() const; private: ListPtr PtrTo(int position) const; int size; ListPtr head; }; #endif