]> git.vomp.tv Git - vompclient.git/blob - list.h
Corruption fixes
[vompclient.git] / list.h
1 /*
2     Copyright 2004-2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #ifndef LIST_H
22 #define LIST_H
23
24 #include <stdio.h>
25 #include <malloc.h>
26 #include "node.h"
27
28 class List
29 {
30   public:
31     List();
32     ~List();
33     void add(void *);
34     void *getCurrent(void) const;
35     void *remove(void);   // Removes node from current position from list
36                           // and passes it back to be deleted
37     void remove(void *); // Removes node passed in from list, does not delete it
38     void reset(void);
39     void next(void);
40     short isEmpty(void) const;
41     short eol(void) const;
42     void save(char *, long int);
43     int load(char *);
44     unsigned long int getNumElements();
45
46   private:
47     Node *start;
48     Node *current;
49     Node *prev;
50     unsigned long int numElements;
51 };
52
53 /* The list class can not delete the object stored in the node object because
54    it does not know the length of it. All the node has is a void *. This is why
55    List always passes back the actual stored object to the calling method.
56 */
57
58 /* Fixed memory hole, when delete List, it deletes any remaining Nodes but not
59    stored objects. That's just tuff.
60 */
61
62 /* The new saving code will work as long as the objects don't contain any
63    pointers to other areas of memory. Only for use with self-contained objects!
64 */
65
66 #endif