WvStreams
wvlink.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * WvLink is one element of a linked list.
6  * Used by wvlinklist.h.
7  */
8 #ifndef __WVLINK_H
9 #define __WVLINK_H
10 
11 #include <stdlib.h> // for 'NULL'
12 
23 class WvLink
24 {
25 public:
26  void *data;
27  WvLink *next;
28  const char *id;
29 
30 private:
31  bool autofree : 1;
32 
33 public:
34  WvLink(void *_data, bool _autofree, const char *_id = NULL):
35  data(_data), next(NULL), id(_id), autofree(_autofree)
36  {}
37 
38  WvLink(void *_data, WvLink *prev, WvLink *&tail, bool _autofree,
39  const char *_id = NULL);
40 
41  bool get_autofree()
42  {
43  return autofree;
44  }
45 
46  void set_autofree(bool _autofree)
47  {
48  autofree = _autofree;
49  }
50 
51  void unlink(WvLink *prev)
52  {
53  prev->next = next;
54  delete this;
55  }
56 };
57 
58 #define WvIterStuff(_type_) \
59  \
60  _type_ &operator () () const \
61  { return *ptr(); } \
62  \
63  _type_ *operator -> () const \
64  { return ptr(); } \
65  \
66  _type_ &operator* () const \
67  { return *ptr(); }
68 
69 #endif // __WVLINK_H