WvStreams
debian/libwvstreams-dev/usr/include/wvstreams/unihashtree.h
1/* -*- Mode: C++ -*-
2 * Worldvisions Weaver Software:
3 * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4 *
5 * UniConf low-level tree storage abstraction.
6 */
7#ifndef __UNIHASHTREE_H
8#define __UNIHASHTREE_H
9
10#include "uniconfkey.h"
11#include "wvtr1.h"
12#include "wvscatterhash.h"
13
14class UniHashTreeBase;
15
16// parameters: a node (won't be NULL), userdata
17typedef wv::function<void(const UniHashTreeBase*,
18 void*)> UniHashTreeBaseVisitor;
19// parameters: 1st node (may be NULL), 2nd node (may be NULL), userdata
20typedef wv::function<bool(const UniHashTreeBase*,
21 const UniHashTreeBase*)> UniHashTreeBaseComparator;
22
24{
25protected:
26 struct Accessor
27 {
28 static const UniConfKey *get_key(const UniHashTreeBase *obj)
29 { return &obj->key(); }
30 };
31
33 typedef UniHashTreeBaseVisitor BaseVisitor;
34 typedef UniHashTreeBaseComparator BaseComparator;
35
36public:
38
40 const UniConfKey &key() const
41 { return xkey; }
42
44 bool haschildren() const;
45
46protected:
48
49 UniConfKey _fullkey(const UniHashTreeBase *ancestor = NULL) const;
50 UniHashTreeBase *_find(const UniConfKey &key) const;
51 UniHashTreeBase *_findchild(const UniConfKey &key) const;
52
53 static bool _recursivecompare(
54 const UniHashTreeBase *a, const UniHashTreeBase *b,
55 const UniHashTreeBaseComparator &comparator);
56
57 static void _recursive_unsorted_visit(
58 const UniHashTreeBase *a,
59 const UniHashTreeBaseVisitor &visitor, void *userdata,
60 bool preorder, bool postorder);
61
65private:
66 void _setparent(UniHashTreeBase *parent);
67 UniHashTreeBase *_root() const;
68
70 void link(UniHashTreeBase *node);
71
73 void unlink(UniHashTreeBase *node);
74
75 UniConfKey xkey;
77protected:
78 class Iter : public Container::Iter
79 {
80 public:
82 };
83 friend class Iter;
84};
85
86#endif //__UNIHASHTREE_H
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
const UniConfKey & key() const
Returns the key field.
bool haschildren() const
Returns true if the node has children.