HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GP_NodeTree.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GP_NodeTree.h (C++)
7  *
8  * COMMENTS: paste nodes stored in a splay tree structure
9  *
10  *
11  */
12 
13 #ifndef __GP_NodeTree_h__
14 #define __GP_NodeTree_h__
15 
16 
17 #include "GP_API.h"
18 #include <UT/UT_SplayTree.h>
19 
20 class GP_Node;
21 
23 {
24 public:
25  // Constructors and destructor:
26  GP_NodeTree(void);
27  GP_NodeTree(const GP_NodeTree &tree); // shallow
28  virtual ~GP_NodeTree(void); // does a clear(), not a clearAndDestroy()
29 
30  // Clear and DESTROY ourselves, then copy the data from the source. If
31  // we encounter the target in the source while copying, return its copy.
32  GP_Node *copyFrom(const GP_NodeTree &src, const GP_Node * = 0);
33 
34  // Another copy method that looks for the nodes to insert in a pool of
35  // destination nodes rather than copying the source nodes. Return 0 if
36  // all source nodes were found in the destination, else -1.
37  // We first clear ourselves.
38  int copyFrom(const GP_NodeTree &src,
39  const GP_NodeTree &destpool);
40 
41  // Insert a node into the structure. Return 0 if the node is already
42  // in the tree. Otherwise return 1.
43  int insert(const GP_Node &d)
44  {
45  return UT_SplayTree::add(&d);
46  }
47  int append(const GP_Node &d)
48  {
49  return UT_SplayTree::add(&d);
50  }
51 
52  // Remove a node from the structure and return its address if found.
53  const GP_Node *remove(void) // removes root
54  {
55  return (const GP_Node*)UT_SplayTree::remove();
56  }
57  const GP_Node *remove(int key);
58  const GP_Node *remove(const GP_Node &d)
59  {
60  return (const GP_Node*)UT_SplayTree::remove(&d);
61  }
62 
63  // Search for a given node and return it if found. The search is by
64  // key, so the address might differ.
65  const GP_Node *find(int key) const;
66  const GP_Node *find(const GP_Node &d) const
67  {
68  return (const GP_Node*)UT_SplayTree::find(&d);
69  }
70 
71  // Inquire about a given node:
72  int contains(int key) const;
73  int contains(const GP_Node &d) const
74  {
75  return (UT_SplayTree::find(&d) != 0);
76  }
77 
78  // Clear the structure, or clear and destroy its GP_Node contents too:
79  void clear(void) { UT_SplayTree::clear(); }
80  void clearAndDestroy(void);
81 
82 private:
83  // Nothing.
84 };
85 
86 #endif
#define GP_API
Definition: GP_API.h:10
int insert(const GP_Node &d)
Definition: GP_NodeTree.h:43
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
const void * find(const void *data) const
const void * remove(const void *=0)
int contains(const GP_Node &d) const
Definition: GP_NodeTree.h:73
const GP_Node * find(const GP_Node &d) const
Definition: GP_NodeTree.h:66
void clear(void)
Definition: GP_NodeTree.h:79
int add(const void *, unsigned maxDepth=0)
int append(const GP_Node &d)
Definition: GP_NodeTree.h:47
void clear(void)
GLenum src
Definition: glcorearb.h:1792