00001 #include <utility> 00002 #include <map> 00003 #include <list> 00004 #include "Node.h" 00005 00006 using namespace std; 00007 00008 00009 class OwnSlotsNode: public Node 00010 { 00011 public: 00012 OwnSlotsNode(void){node_type = OWNSLOTS_NODE;}; 00013 int node_type; 00014 NodeGroup own_slot; 00015 virtual void printNode(); 00016 virtual int qualifyNode(); 00017 void addOwnSlot(NodeGroup* ng); 00018 void addOwnSlot(OwnSlotNode* os); 00019 }; 00020 00021 void OwnSlotsNode::addOwnSlot(NodeGroup* ng) 00022 { 00023 list<Node*>::iterator it; 00024 for(it = ng->Sons.begin(); it!=ng->Sons.end(); ++it) 00025 own_slot.addNode(*it); 00026 } 00027 00028 void OwnSlotsNode::addOwnSlot(OwnSlotNode* os) 00029 { 00030 //OwnSlotNode* osn = new OwnSlotNode; 00031 // own_slots.Sons.push_back(new OwnSlotNode); 00032 00033 own_slot.addNode(os); 00034 } 00035 00036 00037 void OwnSlotsNode::printNode() 00038 { 00039 cout<<"OwnSlotsNode: Node type is "<<node_type<<"\n"; 00040 list<Node*>::iterator it; 00041 for(it = own_slot.Sons.begin(); it!=own_slot.Sons.end(); ++it) 00042 (*it)->printNode(); 00043 } 00044 00045 int OwnSlotsNode::qualifyNode() 00046 {return node_type;} 00047 00048 class ClassNode: public Node 00049 { 00050 public: 00051 ClassNode(void){node_type = CLASS_NODE;}; 00052 int node_type; 00053 OwnSlotsNode own_slots; 00054 00055 void addOwnSlots(OwnSlotsNode* own_slots); 00056 virtual void printNode(); 00057 virtual int qualifyNode(); 00058 }; 00059 00060 void ClassNode::addOwnSlots(OwnSlotsNode* sn) 00061 { 00062 own_slots.addOwnSlot(&sn->own_slot); 00063 } 00064 00065 void ClassNode::printNode() 00066 { 00067 cout<<"ClassNode: Node type is "<<node_type<<"\n"; 00068 own_slots.printNode(); 00069 } 00070 00071 int ClassNode::qualifyNode() 00072 {return node_type;} 00073 00074 class ClassesNode: public Node 00075 { 00076 public: 00077 ClassesNode(void){node_type = CLASSES_NODE;}; 00078 int node_type; 00079 NodeGroup classn; 00080 void addClass(ClassNode* cn); 00081 virtual void printNode(); 00082 virtual int qualifyNode(); 00083 }; 00084 00085 void ClassesNode::addClass(ClassNode* cn) 00086 { 00087 classn.Sons.push_back(new ClassNode); 00088 ClassNode* clp = (ClassNode*) classn.Sons.front(); 00089 00090 clp->addOwnSlots(&cn->own_slots); 00091 00092 00093 } 00094 00095 void ClassesNode::printNode() 00096 { 00097 cout<<"ClassesNode: Node type is "<<node_type<<"\n"; 00098 list<Node*>::iterator it; 00099 for(it = classn.Sons.begin(); it!=classn.Sons.end(); ++it) 00100 (*it)->printNode(); 00101 00102 } 00103 00104 int ClassesNode::qualifyNode() 00105 {return node_type;} 00106 00107 00108