NicEntry.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        NicEntry.h
00003  *
00004  * author:      Daniel Willkomm
00005  *
00006  * copyright:   (C) 2005 Telecommunication Networks Group (TKN) at
00007  *              Technische Universitaet Berlin, Germany.
00008  *
00009  *              This program is free software; you can redistribute it
00010  *              and/or modify it under the terms of the GNU General Public
00011  *              License as published by the Free Software Foundation; either
00012  *              version 2 of the License, or (at your option) any later
00013  *              version.
00014  *              For further information see file COPYING
00015  *              in the top level directory
00016  ***************************************************************************
00017  * part of:     framework implementation developed by tkn
00018  * description: Class to store information about a nic for the
00019  *              ConnectionManager module
00020  **************************************************************************/
00021 
00022 #ifndef NICENTRY_H
00023 #define NICENTRY_H
00024 
00025 #include <omnetpp.h>
00026 #include <map>
00027 
00028 #include "Coord.h"
00029 
00030 class ChannelAccess;
00031 
00032 
00041 class NicEntry : public cObject
00042 {
00043 protected:
00044   class NicEntryComparator {
00045     public:
00046     bool operator() (const NicEntry* nic1, const NicEntry* nic2) const {
00047       return nic1->nicId < nic2->nicId;
00048     }
00049   };
00050   public:
00052     typedef std::map<const NicEntry*, cGate*, NicEntryComparator> GateList;
00053 
00055     int nicId;
00056 
00058     cModule *nicPtr;
00059 
00061     int hostId;
00062 
00064     Coord pos;
00065 
00067     ChannelAccess* chAccess;
00068 
00069   protected:
00071     bool coreDebug;
00072 
00080     GateList outConns;
00081 
00082   public:
00086     NicEntry(bool debug) : nicId(0), nicPtr(0), hostId(0){
00087         coreDebug = debug;
00088     };
00089 
00093     virtual ~NicEntry() {}
00094 
00096     virtual void connectTo(NicEntry*) = 0;
00097 
00099     virtual void disconnectFrom(NicEntry*) = 0;
00100 
00102     const GateList& getGateList(){
00103       return outConns;
00104     }
00105 
00107     bool isConnected(const NicEntry* other) {
00108         return (outConns.find(other) != outConns.end());
00109     };
00110 
00119     const cGate* getOutGateTo(const NicEntry* to)
00120     {
00121       return outConns[to];
00122     };
00123 
00124 };
00125 
00126 #endif