Alex Bikfalvi
SimStream Documentation
Node.h
00001 #pragma once 00002 00003 #include "Object.h" 00004 #include "Codes.h" 00005 #include "Address.h" 00006 #include "Info.h" 00007 #include "Link.h" 00008 #include "Route.h" 00009 00010 #include "LayerIp.h" 00011 #include "LayerIpLocal.h" 00012 #include "LayerIpMcast.h" 00013 #include "LayerIgmp.h" 00014 #include "LayerUdp.h" 00015 00016 class CNode : public CObject 00017 { 00018 private: 00019 // Links 00020 __uint32 numLinks; 00021 __uint32 currentLink; 00022 00023 CLink** links; 00024 __uint32* linkEntries; 00025 map<__uint32, __uint32> linkIndices; 00026 00027 // Stat 00028 __uint64 statPacketsRead; 00029 __uint64 statPacketsWrite; 00030 00031 __uint64 statDataRead; 00032 __uint64 statDataWrite; 00033 00034 protected: 00035 // Global 00036 __uint32 id; 00037 CAddress address; 00038 CInfo* info; 00039 CRoute* route; 00040 00041 // Layers 00042 CLayerIp* layerIp; 00043 CLayerIpLocal* layerIpLocal; 00044 CLayerIpMcast* layerIpMcast; 00045 CLayerUdp* layerUdp; 00046 00047 // Base layer delegate 00048 Delegate2<CNode, void, __uint32, CPacket*>* delegateSend; 00049 00050 // Base layer event 00051 Event2<void, __uint32, CPacket*>* eventRecv; 00052 00053 public: 00054 CNode( 00055 __uint32 id, 00056 CSimHandler* sim, 00057 CAddress address, 00058 __uint32 numLinks, 00059 CRoute* route, 00060 CInfo* info 00061 ); 00062 virtual ~CNode(); 00063 00064 // Global 00065 inline __uint32 Id() { return this->id; } 00066 inline CAddress Address() { return this->address; } 00067 00068 // Links 00069 void AddLink(CLink* link); 00070 00071 inline __uint32 NumLinks() { assert(this->numLinks == this->currentLink); return this->numLinks; } 00072 inline CLink* Link(__uint32 index) { assert(index < this->currentLink); return this->links[index]; } 00073 inline __uint32 LinkEntry(__uint32 index) { assert(index < this->currentLink); return this->linkEntries[index]; } 00074 inline __uint32 LinkIndex(__uint32 id) { assert(this->linkIndices.find(id) != this->linkIndices.end()); return this->linkIndices.find(id)->second; } 00075 00076 // Receive 00077 virtual ENetworkCode Recv(CObject* sender, __uint32 entry, CPacket* packet); 00078 00079 // Stat 00080 inline __uint64 StatPacketsRead() { return this->statPacketsRead; } 00081 inline __uint64 StatPacketsWrite() { return this->statPacketsWrite; } 00082 00083 inline __uint64 StatDataRead() { return this->statDataRead; } 00084 inline __uint64 StatDataWrite() { return this->statDataWrite; } 00085 00086 // Finalizer 00087 virtual void Finalize(); 00088 00089 00090 private: 00091 void Send(__uint32 entry, CPacket* packet); 00092 };
Last updated: February 8, 2011