📄 rip_n.cc
字号:
//-----------------------------------------//// Generated by nedtool, version 3.3// date: Sat May 3 16:37:33 2008////-----------------------------------------#include <math.h>#include "omnetpp.h"// NEDC version check#define NEDC_VERSION 0x0303#if (NEDC_VERSION!=OMNETPP_VERSION)# error Version mismatch! Probably this file was generated by an earlier version of nedc: 'make clean' should help.#endif// Disable warnings about unused variables. For MSVC and BC only:// GCC has no way to turn on its -Wunused option in a source file :(#ifdef _MSC_VER# pragma warning(disable:4101)#endif#ifdef __BORLANDC__# pragma warn -waus# pragma warn -wuse#endifstatic cModuleType *_getModuleType(const char *modname){ cModuleType *modtype = findModuleType(modname); if (!modtype) throw new cRuntimeError("Module type definition %s not found (Define_Module() missing from C++ code?)", modname); return modtype;}static void _checkModuleVectorSize(int vectorsize, const char *mod){ if (vectorsize<0) throw new cRuntimeError("Negative module vector size %s[%d]", mod, vectorsize);}static void _readModuleParameters(cModule *mod){ int n = mod->params(); for (int k=0; k<n; k++) if (mod->par(k).isInput()) mod->par(k).read();}static int _checkModuleIndex(int index, int vectorsize, const char *modname){ if (index<0 || index>=vectorsize) throw new cRuntimeError("Submodule index %s[%d] out of range, sizeof(%s) is %d", modname, index, modname, vectorsize); return index;}static cGate *_checkGate(cModule *mod, const char *gatename){ cGate *g = mod->gate(gatename); if (!g) throw new cRuntimeError("%s has no gate named %s",mod->fullPath().c_str(), gatename); return g;}static cGate *_checkGate(cModule *mod, const char *gatename, int gateindex){ cGate *g = mod->gate(gatename, gateindex); if (!g) throw new cRuntimeError("%s has no gate %s[%d]",mod->fullPath().c_str(), gatename, gateindex); return g;}static cGate *_getFirstUnusedParentModGate(cModule *mod, const char *gatename){ int baseId = mod->findGate(gatename); if (baseId<0) throw new cRuntimeError("%s has no %s[] gate",mod->fullPath().c_str(), gatename); int n = mod->gate(baseId)->size(); for (int i=0; i<n; i++) if (!mod->gate(baseId+i)->isConnectedInside()) return mod->gate(baseId+i); throw new cRuntimeError("%s[] gates are all connected, no gate left for `++' operator",mod->fullPath().c_str(), gatename);}static cGate *_getFirstUnusedSubmodGate(cModule *mod, const char *gatename){ int baseId = mod->findGate(gatename); if (baseId<0) throw new cRuntimeError("%s has no %s[] gate",mod->fullPath().c_str(), gatename); int n = mod->gate(baseId)->size(); for (int i=0; i<n; i++) if (!mod->gate(baseId+i)->isConnectedOutside()) return mod->gate(baseId+i); int newBaseId = mod->setGateSize(gatename,n+1); return mod->gate(newBaseId+n);}static cFunctionType *_getFunction(const char *funcname, int argcount){ cFunctionType *functype = findFunction(funcname,argcount); if (!functype) throw new cRuntimeError("Function %s with %d args not found", funcname, argcount); return functype;}static cChannel *_createChannel(const char *channeltypename){ cChannelType *channeltype = findChannelType(channeltypename); if (!channeltype) throw new cRuntimeError("Channel type %s not found", channeltypename); cChannel *channel = channeltype->create("channel"); return channel;}static cChannel *_createNonTypedBasicChannel(double delay, double error, double datarate){ cBasicChannel *channel = new cBasicChannel("channel"); if (delay!=0) channel->setDelay(delay); if (error!=0) channel->setError(error); if (datarate!=0) channel->setDatarate(datarate); return channel;}static cXMLElement *_getXMLDocument(const char *fname, const char *pathexpr=NULL){ cXMLElement *node = ev.getXMLDocument(fname, pathexpr); if (!node) throw new cRuntimeError(!pathexpr ? "xmldoc(\"%s\"): element not found" : "xmldoc(\"%s\", \"%s\"): element not found",fname,pathexpr); return node;}ModuleInterface(RIP) // gates: Gate(out[], GateDir_Output) Gate(in[], GateDir_Input)EndInterfaceRegister_ModuleInterface(RIP)//// Sample code:// class RIP : public cSimpleModule// {// Module_Class_Members(RIP,cSimpleModule,16384)// virtual void activity();// // Add you own member functions here!// };//// Define_Module(RIP);//// void RIP::activity()// {// // Put code for simple module activity here!// }//ModuleInterface(rip)EndInterfaceRegister_ModuleInterface(rip);class rip : public cCompoundModule{ public: rip() : cCompoundModule() {} protected: virtual void doBuildInside();};Define_Module(rip);void rip::doBuildInside(){ cModule *mod = this; // temporary variables: cPar tmpval; const char *modtypename; mod->setBackgroundDisplayString("b=580,449"); // submodules: cModuleType *modtype = NULL; int submodindex; // // submodule 'RIP': // int RIP_size = 1; modtype = _getModuleType("RIP"); cModule *RIP_p = modtype->create("RIP", mod); { cContextSwitcher __ctx(RIP_p); // do the rest in this module's context _readModuleParameters(RIP_p); RIP_p->setDisplayString("i=abstract/router;p=72,80"); } // // submodule 'RIP1': // int RIP1_size = 1; modtype = _getModuleType("RIP"); cModule *RIP1_p = modtype->create("RIP1", mod); { cContextSwitcher __ctx(RIP1_p); // do the rest in this module's context _readModuleParameters(RIP1_p); RIP1_p->setDisplayString("i=abstract/router;p=144,80"); } // // submodule 'RIP2': // int RIP2_size = 1; modtype = _getModuleType("RIP"); cModule *RIP2_p = modtype->create("RIP2", mod); { cContextSwitcher __ctx(RIP2_p); // do the rest in this module's context _readModuleParameters(RIP2_p); RIP2_p->setDisplayString("i=abstract/router;p=208,80"); } // // submodule 'RIP3': // int RIP3_size = 1; modtype = _getModuleType("RIP"); cModule *RIP3_p = modtype->create("RIP3", mod); { cContextSwitcher __ctx(RIP3_p); // do the rest in this module's context _readModuleParameters(RIP3_p); RIP3_p->setDisplayString("i=abstract/router;p=280,80"); } // // submodule 'RIP4': // int RIP4_size = 1; modtype = _getModuleType("RIP"); cModule *RIP4_p = modtype->create("RIP4", mod); { cContextSwitcher __ctx(RIP4_p); // do the rest in this module's context _readModuleParameters(RIP4_p); RIP4_p->setDisplayString("i=abstract/router;p=336,80"); } // // submodule 'RIP5': // int RIP5_size = 1; modtype = _getModuleType("RIP"); cModule *RIP5_p = modtype->create("RIP5", mod); { cContextSwitcher __ctx(RIP5_p); // do the rest in this module's context _readModuleParameters(RIP5_p); RIP5_p->setDisplayString("i=abstract/router;p=392,80"); } // // submodule 'RIP6': // int RIP6_size = 1; modtype = _getModuleType("RIP"); cModule *RIP6_p = modtype->create("RIP6", mod); { cContextSwitcher __ctx(RIP6_p); // do the rest in this module's context _readModuleParameters(RIP6_p); RIP6_p->setDisplayString("i=abstract/router;p=448,80"); } // // submodule 'RIP7': // int RIP7_size = 1; modtype = _getModuleType("RIP"); cModule *RIP7_p = modtype->create("RIP7", mod); { cContextSwitcher __ctx(RIP7_p); // do the rest in this module's context _readModuleParameters(RIP7_p); RIP7_p->setDisplayString("i=abstract/router;p=512,80"); } // // submodule 'RIP8': // int RIP8_size = 1; modtype = _getModuleType("RIP"); cModule *RIP8_p = modtype->create("RIP8", mod); { cContextSwitcher __ctx(RIP8_p); // do the rest in this module's context _readModuleParameters(RIP8_p); RIP8_p->setDisplayString("i=abstract/router;p=512,160"); } // // submodule 'RIP9': // int RIP9_size = 1; modtype = _getModuleType("RIP"); cModule *RIP9_p = modtype->create("RIP9", mod); { cContextSwitcher __ctx(RIP9_p); // do the rest in this module's context _readModuleParameters(RIP9_p); RIP9_p->setDisplayString("i=abstract/router;p=448,160"); } // // submodule 'RIP10': // int RIP10_size = 1; modtype = _getModuleType("RIP"); cModule *RIP10_p = modtype->create("RIP10", mod); { cContextSwitcher __ctx(RIP10_p); // do the rest in this module's context _readModuleParameters(RIP10_p); RIP10_p->setDisplayString("i=abstract/router;p=392,160"); } // // submodule 'RIP11': // int RIP11_size = 1; modtype = _getModuleType("RIP"); cModule *RIP11_p = modtype->create("RIP11", mod); { cContextSwitcher __ctx(RIP11_p); // do the rest in this module's context _readModuleParameters(RIP11_p); RIP11_p->setDisplayString("i=abstract/router;p=336,160"); } // // submodule 'RIP12': // int RIP12_size = 1; modtype = _getModuleType("RIP"); cModule *RIP12_p = modtype->create("RIP12", mod); { cContextSwitcher __ctx(RIP12_p); // do the rest in this module's context _readModuleParameters(RIP12_p); RIP12_p->setDisplayString("i=abstract/router;p=272,160"); } // // submodule 'RIP13': // int RIP13_size = 1; modtype = _getModuleType("RIP"); cModule *RIP13_p = modtype->create("RIP13", mod); { cContextSwitcher __ctx(RIP13_p); // do the rest in this module's context _readModuleParameters(RIP13_p); RIP13_p->setDisplayString("i=abstract/router;p=200,160"); } // // submodule 'RIP14': // int RIP14_size = 1; modtype = _getModuleType("RIP"); cModule *RIP14_p = modtype->create("RIP14", mod); { cContextSwitcher __ctx(RIP14_p); // do the rest in this module's context _readModuleParameters(RIP14_p);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -