00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Cristin Barghiel 00008 * Side Effects Software Inc. 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: Domain pasting Library (C++) 00015 * 00016 * COMMENTS: Paste node class. 00017 * 00018 */ 00019 00020 #ifndef __GP_Node_h__ 00021 #define __GP_Node_h__ 00022 00023 #include "GP_API.h" 00024 #include "GP_NodeTree.h" 00025 00026 00027 class GP_API GP_Node 00028 { 00029 public: 00030 // Class c-tors and d-tor 00031 GP_Node(int akey = 0) { myKey = akey; } 00032 GP_Node(const GP_Node &node) { myKey = node.myKey; } 00033 virtual ~GP_Node(void); // clear node lists, but in/out nodes stay 00034 00035 // Produce a brand new copy of ourselves. Must free it yourself. 00036 // Does not copy our in and out nodes! 00037 virtual GP_Node *copy(void) const; 00038 00039 // Copy the in nodes and out-nodes from a pool of already built nodes: 00040 // Return 0 if OK and -1 otherwise. Use with discretion. 00041 virtual int copyInNodes (const GP_Node &src, 00042 const GP_NodeTree &destpool); 00043 virtual int copyOutNodes(const GP_Node &src, 00044 const GP_NodeTree &destpool); 00045 00046 // Create a a brand new object of the same type as us just using the 00047 // default c-tor. 00048 virtual GP_Node *newSpecies(void) const; 00049 00050 // Remove the in or out edges and return the node address if found. 00051 void removeInEdges (void); 00052 void removeOutEdges(void); 00053 00054 // Return the descendents or 0 if none. Must free the object yourself. 00055 GP_NodeTree *descendents(void) const; 00056 00057 // Return the in/out degree, ie the number of nodes in each list: 00058 int inDegree (void) const { return myInNodes.entries ();} 00059 int outDegree(void) const { return myOutNodes.entries();} 00060 00061 // Query or set the key: 00062 int key(void) const { return myKey; } 00063 void key(int k) { myKey = k; } 00064 00065 // Query or set the in and out node collections: 00066 GP_NodeTree &inNodes (void) { return myInNodes; } 00067 const GP_NodeTree &inNodes (void) const { return myInNodes; } 00068 GP_NodeTree &outNodes(void) { return myOutNodes; } 00069 const GP_NodeTree &outNodes(void) const { return myOutNodes; } 00070 00071 private: 00072 GP_NodeTree myInNodes; 00073 GP_NodeTree myOutNodes; 00074 int myKey; 00075 }; 00076 00077 #endif
1.5.9