Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

wvlink.h

Go to the documentation of this file.
00001 /*
00002  * Worldvisions Weaver Software:
00003  *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
00004  *
00005  * WvLink is one element of a linked list.  Used by wvlinklist.h, wvhashtable.h,
00006  * and so on.
00007  */
00008 #ifndef __WVLINK_H
00009 #define __WVLINK_H
00010 
00011 #include <stdlib.h>  // for 'NULL'
00012 
00013 // note: auto_free behaviour is a little bit weird; since WvLink does not
00014 // know what data type it has received, there is no way it can call the
00015 // right destructor.  So, the WvList needs to handle the data deletion
00016 // by itself.  On the other hand, the auto_free flag needs to be stored in
00017 // the WvLink.  <sigh>...
00018 //
00019 class WvLink
00020 {
00021 public:
00022     void *data;
00023     WvLink *next;
00024     char *id;
00025     unsigned auto_free : 1;
00026 
00027     WvLink(void *_data, bool _auto_free, char *_id = NULL)
00028         { data = _data; next = NULL; auto_free = (unsigned)_auto_free;
00029             id = _id; }
00030 
00031     WvLink(void *_data, WvLink *prev, WvLink *&tail, bool _auto_free,
00032            char *_id = NULL);
00033 
00034     void unlink(WvLink *prev)
00035     {
00036         prev->next = next;
00037         delete this;
00038     }
00039 };
00040 
00041 #define WvIterStuff(_type_) \
00042         operator _type_& () const \
00043             { return *ptr(); } \
00044         _type_ &operator () () const \
00045             { return *ptr(); } \
00046         _type_ *operator -> () const \
00047             { return ptr(); } \
00048         _type_ &operator* () const \
00049             { return *ptr(); }
00050 
00051 #endif // __WVLINK_H

Generated on Sat Aug 24 21:37:01 2002 for WvStreams by doxygen1.2.15