|
INET Framework for OMNeT++/OMNEST
|
00001 // 00002 // Copyright (C) 2005 Andras Varga 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU Lesser General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 00019 #ifndef __INET_ANSAINTERFACETABLE_H 00020 #define __INET_ANSAINTERFACETABLE_H 00021 00022 #include <vector> 00023 #include <omnetpp.h> 00024 #include "INETDefs.h" 00025 #include "IInterfaceTable.h" 00026 #include "InterfaceEntry.h" 00027 #include "NotificationBoard.h" 00028 00029 00067 class INET_API AnsaInterfaceTable : public cSimpleModule, public IInterfaceTable, protected INotifiable 00068 { 00069 protected: 00070 NotificationBoard *nb; // cached pointer 00071 00072 // primary storage for interfaces: vector indexed by id; may contain NULLs; 00073 // slots are never reused to ensure id uniqueness 00074 typedef std::vector<InterfaceEntry *> InterfaceVector; 00075 InterfaceVector idToInterface; 00076 00077 // fields to support getNumInterfaces() and getInterface(pos) 00078 int tmpNumInterfaces; // caches number of non-NULL elements of idToInterface; -1 if invalid 00079 InterfaceEntry **tmpInterfaceList; // caches non-NULL elements of idToInterface; NULL if invalid 00080 00081 protected: 00082 // displays summary above the icon 00083 virtual void updateDisplayString(); 00084 00085 // discover and store which nwlayer/host gates connect to this interface 00086 virtual void discoverConnectingGates(InterfaceEntry *entry, cModule *ifmod); 00087 00088 // called from InterfaceEntry 00089 virtual void interfaceChanged(InterfaceEntry *entry, int category); 00090 00091 // internal 00092 virtual void invalidateTmpInterfaceList(); 00093 00094 public: 00095 AnsaInterfaceTable(); 00096 virtual ~AnsaInterfaceTable(); 00097 virtual std::string getFullPath() const {return cSimpleModule::getFullPath();} 00098 00099 protected: 00100 virtual int numInitStages() const {return 2;} 00101 virtual void initialize(int stage); 00102 00106 virtual void handleMessage(cMessage *); 00107 00108 public: 00113 virtual void receiveChangeNotification(int category, const cPolymorphic *details); 00114 00122 virtual void addInterface(InterfaceEntry *entry, cModule *ifmod); 00123 00129 virtual void deleteInterface(InterfaceEntry *entry); 00130 00134 virtual int getNumInterfaces(); 00135 00145 virtual InterfaceEntry *getInterface(int pos); 00146 00152 virtual InterfaceEntry *getInterfaceById(int id); 00153 00158 virtual InterfaceEntry *getInterfaceByNodeOutputGateId(int id); 00159 00164 virtual InterfaceEntry *getInterfaceByNodeInputGateId(int id); 00165 00170 virtual InterfaceEntry *getInterfaceByNetworkLayerGateIndex(int index); 00171 00175 virtual InterfaceEntry *getInterfaceByName(const char *name); 00176 00183 virtual InterfaceEntry *getFirstLoopbackInterface(); 00184 00185 InterfaceEntry *getFirstInterface(); 00186 }; 00187 00188 #endif 00189