#include <LIBTable.h>
Public Member Functions | |
| bool | resolveLabel (std::string inInterface, int inLabel, LabelOpVector &outLabel, std::string &outInterface, int &color) |
| int | installLibEntry (int inLabel, std::string inInterface, const LabelOpVector &outLabel, std::string outInterface, int color) |
| void | removeLibEntry (int inLabel) |
Static Public Member Functions | |
| static LabelOpVector | pushLabel (int label) |
| static LabelOpVector | swapLabel (int label) |
| static LabelOpVector | popLabel () |
Protected Member Functions | |
| virtual void | initialize (int stage) |
| virtual int | numInitStages () const |
| void | handleMessage (cMessage *msg) |
| void | readTableFromXML (const cXMLElement *libtable) |
Private Attributes | |
| IPAddress | routerId |
| int | maxLabel |
| std::vector< LIBEntry > | lib |
Classes | |
| struct | LIBEntry |
|
|
00044 {
00045 ASSERT(false);
00046 }
|
|
|
00024 {
00025 if (stage==0)
00026 maxLabel = 0;
00027
00028 // we have to wait until routerId gets assigned in stage 3
00029 if (stage==4)
00030 {
00031 RoutingTableAccess routingTableAccess;
00032 RoutingTable *rt = routingTableAccess.get();
00033 routerId = rt->routerId();
00034
00035 // read configuration
00036
00037 readTableFromXML(par("conf").xmlValue());
00038
00039 WATCH_VECTOR(lib);
00040 }
00041 }
|
|
||||||||||||||||||||||||
|
00072 {
00073 if (inLabel == -1)
00074 {
00075 LIBEntry newItem;
00076 newItem.inLabel = ++maxLabel;
00077 newItem.inInterface = inInterface;
00078 newItem.outLabel = outLabel;
00079 newItem.outInterface = outInterface;
00080 newItem.color = color;
00081 lib.push_back(newItem);
00082 return newItem.inLabel;
00083 }
00084 else
00085 {
00086 for (unsigned int i = 0; i < lib.size(); i++)
00087 {
00088 if (lib[i].inLabel != inLabel)
00089 continue;
00090
00091 lib[i].inInterface = inInterface;
00092 lib[i].outLabel = outLabel;
00093 lib[i].outInterface = outInterface;
00094 lib[i].color = color;
00095 return inLabel;
00096 }
00097 ASSERT(false);
00098 return 0; // prevent warning
00099 }
00100 }
|
|
|
00067 {return 5;}
|
|
|
00197 {
00198 LabelOpVector vec;
00199 LabelOp lop;
00200 lop.optcode = POP_OPER;
00201 lop.label = 0;
00202 vec.push_back(lop);
00203 return vec;
00204 }
|
|
|
00177 {
00178 LabelOpVector vec;
00179 LabelOp lop;
00180 lop.optcode = PUSH_OPER;
00181 lop.label = label;
00182 vec.push_back(lop);
00183 return vec;
00184 }
|
|
|
00116 {
00117 ASSERT(libtable);
00118 ASSERT(!strcmp(libtable->getTagName(), "libtable"));
00119 checkTags(libtable, "libentry");
00120 cXMLElementList list = libtable->getChildrenByTagName("libentry");
00121 for (cXMLElementList::iterator it=list.begin(); it != list.end(); it++)
00122 {
00123 const cXMLElement& entry = **it;
00124
00125 checkTags(&entry, "inLabel inInterface outLabel outInterface color");
00126
00127 LIBEntry newItem;
00128 newItem.inLabel = getParameterIntValue(&entry, "inLabel");
00129 newItem.inInterface = getParameterStrValue(&entry, "inInterface");
00130 newItem.outInterface = getParameterStrValue(&entry, "outInterface");
00131 newItem.color = getParameterIntValue(&entry, "color", 0);
00132
00133 cXMLElementList ops = getUniqueChild(&entry, "outLabel")->getChildrenByTagName("op");
00134 for (cXMLElementList::iterator oit=ops.begin(); oit != ops.end(); oit++)
00135 {
00136 const cXMLElement& op = **oit;
00137 const char *val = op.getAttribute("value");
00138 const char *code = op.getAttribute("code");
00139 ASSERT(code);
00140 LabelOp l;
00141
00142 if (!strcmp(code, "push"))
00143 {
00144 l.optcode = PUSH_OPER;
00145 ASSERT(val);
00146 l.label = atoi(val);
00147 ASSERT(l.label > 0);
00148 }
00149 else if (!strcmp(code, "pop"))
00150 {
00151 l.optcode = POP_OPER;
00152 ASSERT(!val);
00153 }
00154 else if (!strcmp(code, "swap"))
00155 {
00156 l.optcode = SWAP_OPER;
00157 ASSERT(val);
00158 l.label = atoi(val);
00159 ASSERT(l.label > 0);
00160 }
00161 else
00162 ASSERT(false);
00163
00164 newItem.outLabel.push_back(l);
00165 }
00166
00167 lib.push_back(newItem);
00168
00169 ASSERT(newItem.inLabel > 0);
00170
00171 if (newItem.inLabel > maxLabel)
00172 maxLabel = newItem.inLabel;
00173 }
00174 }
|
|
|
00103 {
00104 for (unsigned int i = 0; i < lib.size(); i++)
00105 {
00106 if (lib[i].inLabel != inLabel)
00107 continue;
00108
00109 lib.erase(lib.begin() + i);
00110 return;
00111 }
00112 ASSERT(false);
00113 }
|
|
||||||||||||||||||||||||
|
00050 {
00051 bool any = (inInterface.length() == 0);
00052
00053 for (unsigned int i = 0; i < lib.size(); i++)
00054 {
00055 if (!any && lib[i].inInterface != inInterface)
00056 continue;
00057
00058 if (lib[i].inLabel != inLabel)
00059 continue;
00060
00061 outLabel = lib[i].outLabel;
00062 outInterface = lib[i].outInterface;
00063 color = lib[i].color;
00064
00065 return true;
00066 }
00067 return false;
00068 }
|
|
|
00187 {
00188 LabelOpVector vec;
00189 LabelOp lop;
00190 lop.optcode = SWAP_OPER;
00191 lop.label = label;
00192 vec.push_back(lop);
00193 return vec;
00194 }
|
|
|
|
|
|
|
|
|
|
1.4.1