wvdbusserver: implement NameHasOwner request.
[wvstreams.git] / include / wvlink.h
bloba94c54c49e4d13619ab6692eb11ba15f2e683a95
1 /* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
5 * WvLink is one element of a linked list.
6 * Used by wvlinklist.h.
7 */
8 #ifndef __WVLINK_H
9 #define __WVLINK_H
11 #include <stdlib.h> // for 'NULL'
13 /**
14 * WvLink is one element of a WvList<T>.
16 * Note that WvLink itself is untyped to minimize the amount of
17 * generated code. This means that WvLink cannot handle the
18 * autofree behaviour itself which would require static type
19 * information. Instead, it defers this behaviour to the
20 * template instantiation of WvList<T> that uses it.
23 class WvLink
25 public:
26 void *data;
27 WvLink *next;
28 const char *id;
30 private:
31 bool autofree : 1;
33 public:
34 WvLink(void *_data, bool _autofree, const char *_id = NULL):
35 data(_data), next(NULL), id(_id), autofree(_autofree)
38 WvLink(void *_data, WvLink *prev, WvLink *&tail, bool _autofree,
39 const char *_id = NULL);
41 bool get_autofree()
43 return autofree;
46 void set_autofree(bool _autofree)
48 autofree = _autofree;
51 void unlink(WvLink *prev)
53 prev->next = next;
54 delete this;
58 #define WvIterStuff(_type_) \
59 /*! @brief Returns a reference to the current element. */ \
60 _type_ &operator () () const \
61 { return *ptr(); } \
62 /*! @brief Returns a pointer to the current element. */ \
63 _type_ *operator -> () const \
64 { return ptr(); } \
65 /*! @brief Returns a reference to the current element. */ \
66 _type_ &operator* () const \
67 { return *ptr(); }
69 #endif // __WVLINK_H