HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GP_Graph.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: Domain pasting Library (C++)
7  *
8  * COMMENTS: Paste graph class.
9  *
10  */
11 
12 #ifndef __GP_Graph_h__
13 #define __GP_Graph_h__
14 
15 #include "GP_API.h"
16 #include "GP_NodeTree.h"
17 
19 {
20 public:
21  // Class c-tor and d-tor
22  GP_Graph(void) {}
23  GP_Graph(GP_NodeTree &cnodes); // shallow
24  GP_Graph(const GP_Graph &graph); // shallow
25  virtual ~GP_Graph(void); // clears and *destroys* the nodes
26 
27  // Clear the graph, ie. shrink the node list to 0 without deleting
28  // the nodes themselves, or destroy the nodes as well:
29  virtual void clear(void);
30  virtual void clearAndDestroy(int total = 1);
31 
32  // Clear and destroy ourselves, then copy the data from the source. If
33  // we encounter the target in the source while copying, return its copy.
34  // The method copies each node's in and out nodes as well. We first
35  // clear and destroy ourselves.
36  GP_Node *copyFrom(const GP_Graph &src, const GP_Node * = 0);
37 
38  // Copy the source into us. Shallow at the node level. All our
39  // nodes get destroyed.
40  GP_Graph &operator=(const GP_Graph &src);
41 
42  // Add another guy to us. This is just an alias:
44  {
45  merge(src);
46  return *this;
47  }
48 
49  // Merge the graph into us. The nodes will be shared but the node
50  // structures won't. You may want to clear() the src graph after
51  // this to make sure it doesn't delete my nodes too when it dies:
52  void merge(const GP_Graph &src);
53 
54  // Remove a node from the graph and return its address if found. All its
55  // links are severed.
56  GP_Node *remove(GP_Node &node);
57 
58  // Method to change the key of a node while preserving the sanity of the
59  // node tree. Return the changed node or 0 if not found.
60  GP_Node *rekey(GP_Node &node, int newkey);
61 
62  // The public gets a const handle to the nodes:
63  const GP_NodeTree &nodes(void) const { return myNodes; }
64 
65  // See how many nodes are in the graph:
66  int entries(void) const { return myNodes.entries(); }
67 
68 
69 protected:
70  // Grab the nodes:
71  GP_NodeTree &nodes(void) { return myNodes; }
72 
73 private:
74  GP_NodeTree myNodes;
75 };
76 
77 #endif
#define GP_API
Definition: GP_API.h:10
GP_Graph & operator+=(const GP_Graph &src)
Definition: GP_Graph.h:43
int entries(void) const
Definition: GP_Graph.h:66
GP_Graph(void)
Definition: GP_Graph.h:22
const GP_NodeTree & nodes(void) const
Definition: GP_Graph.h:63
GP_NodeTree & nodes(void)
Definition: GP_Graph.h:71
GLenum src
Definition: glcorearb.h:1792