00001 00002 #include <utility> 00003 #include <map> 00004 #include <list> 00005 #include "Node.h" 00006 00007 using namespace std; 00008 00009 class ValueNode: public Node 00010 { 00011 public: 00012 ValueNode(void){node_type = VALUE_NODE;value = "empty";}; 00013 int node_type; 00014 string value; //tra due tag 00015 virtual void printNode(); 00016 virtual int qualifyNode(); 00017 00018 void setValue(ValueNode vn){value = vn.value;}; 00019 void setValue(const char* cvn){value = cvn;}; 00020 }; 00021 00022 void ValueNode::printNode() 00023 { 00024 cout<<"ValueNode: Node type is "<<node_type<<"\n"; 00025 cout<<"ValueNode: Node value is "<<value<<"\n"; 00026 } 00027 00028 int ValueNode::qualifyNode() 00029 {return node_type;} 00030 00031 class EntryNode: public Node 00032 { 00033 public: 00034 EntryNode(void){node_type = ENTRY_NODE; type = "empty";}; 00035 int node_type; 00036 const char* type; 00037 ValueNode value; 00038 void addValue(ValueNode vn); 00039 void setEntry(EntryNode en); 00040 virtual void printNode(); 00041 virtual int qualifyNode(); 00042 }; 00043 void EntryNode::addValue(ValueNode vn) 00044 { 00045 value.setValue(vn); 00046 } 00047 void EntryNode::setEntry(EntryNode en) 00048 { 00049 type = en.type; 00050 addValue(en.value); 00051 } 00052 00053 void EntryNode::printNode() 00054 { 00055 cout<<"EntryNode: Node type is "<<node_type<<"\n"; 00056 cout<<"EntryNode: Node attr. type is "<<type<<"\n"; 00057 value.printNode(); 00058 } 00059 00060 int EntryNode::qualifyNode() 00061 {return node_type;} 00062 00063 class OwnSlotNode: public Node 00064 { 00065 public: 00066 OwnSlotNode(void){node_type = OWNSLOT_NODE; name = "empty";}; 00067 int node_type; 00068 const char* name; 00069 EntryNode entry; 00070 virtual void printNode(); 00071 virtual int qualifyNode(); 00072 void addEntry(EntryNode en); 00073 void setName(const char* s){name = s;}; 00074 }; 00075 00076 void OwnSlotNode::printNode() 00077 { 00078 cout<<"OwnSlotNode: Node type is "<<node_type<<"\n"; 00079 cout<<"OwnSlotNode: Node name is "<<name<<"\n"; 00080 entry.printNode(); 00081 } 00082 00083 int OwnSlotNode::qualifyNode() 00084 {return node_type;} 00085 00086 void OwnSlotNode::addEntry(EntryNode en) 00087 { 00088 entry.setEntry(en); 00089 } 00090 00091 class SlotNode: public Node 00092 { 00093 public: 00094 SlotNode(void){node_type = SLOT_NODE;}; 00095 int node_type; 00096 NodeGroup own_slot; 00097 virtual void printNode(); 00098 virtual int qualifyNode(); 00099 void addOwnSlot(OwnSlotNode* os); 00100 00101 }; 00102 00103 void SlotNode::addOwnSlot(OwnSlotNode* os) 00104 { 00105 //OwnSlotNode* osn = new OwnSlotNode; 00106 // own_slots.Sons.push_back(new OwnSlotNode); 00107 00108 own_slot.addNode(os); 00109 } 00110 00111 void SlotNode::printNode() 00112 { 00113 cout<<"SlotNode: Node type is "<<node_type<<"\n"; 00114 list<Node*>::iterator it; 00115 for(it = own_slot.Sons.begin(); it!=own_slot.Sons.end(); ++it) 00116 (*it)->printNode(); 00117 } 00118 00119 int SlotNode::qualifyNode() 00120 {return node_type;} 00121 00122 class SlotsNode: public Node 00123 { 00124 public: 00125 SlotsNode(void){node_type = SLOTS_NODE;}; 00126 int node_type; 00127 NodeGroup slot; 00128 void addSlot(SlotNode* sn); 00129 virtual void printNode(); 00130 virtual int qualifyNode(); 00131 }; 00132 00133 void SlotsNode::addSlot(SlotNode* sn) 00134 { 00135 slot.Sons.push_back(new SlotNode); 00136 SlotNode* slp = (SlotNode*) slot.Sons.front(); 00137 list<Node*>::iterator it; 00138 for(it = sn->own_slot.Sons.begin(); it!=sn->own_slot.Sons.end(); ++it) 00139 slp->addOwnSlot(((OwnSlotNode*)(*it))); 00140 } 00141 00142 void SlotsNode::printNode() 00143 { 00144 cout<<"SlotsNode: Node type is "<<node_type<<"\n"; 00145 list<Node*>::iterator it; 00146 for(it = slot.Sons.begin(); it!=slot.Sons.end(); ++it) 00147 (*it)->printNode(); 00148 } 00149 00150 int SlotsNode::qualifyNode() 00151 {return node_type;}