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 
14 class UniHashTreeBase;
15 
16 // parameters: a node (won't be NULL), userdata
17 typedef wv::function<void(const UniHashTreeBase*,
18  void*)> UniHashTreeBaseVisitor;
19 // parameters: 1st node (may be NULL), 2nd node (may be NULL), userdata
20 typedef wv::function<bool(const UniHashTreeBase*,
21  const UniHashTreeBase*)> UniHashTreeBaseComparator;
22 
24 {
25 protected:
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 
36 public:
37  ~UniHashTreeBase();
38 
40  const UniConfKey &key() const
41  { return xkey; }
42 
44  bool haschildren() const;
45 
46 protected:
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 
65 private:
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;
77 protected:
78  class Iter : public Container::Iter
79  {
80  public:
82  };
83  friend class Iter;
84 };
85 
86 #endif //__UNIHASHTREE_H
UniHashTreeBase::xchildren
Container * xchildren
Definition: unihashtree.h:63
WvScatterHash::Iter
Definition: wvscatterhash.h:180
UniHashTreeBase::key
const UniConfKey & key() const
Returns the key field.
Definition: unihashtree.h:40
UniHashTreeBase::Iter
Definition: unihashtree.h:78
UniConfKey
Represents a UniConf key which is a path in a hierarchy structured much like the traditional Unix fil...
Definition: uniconfkey.h:38
UniHashTreeBase::xparent
UniHashTreeBase * xparent
Definition: unihashtree.h:62
UniHashTreeBase::Accessor
Definition: unihashtree.h:26
WvScatterHash
Definition: wvscatterhash.h:125
UniHashTreeBase
Definition: unihashtree.h:23
UniHashTreeBase::haschildren
bool haschildren() const
Returns true if the node has children.
Definition: unihashtree.cc:114