P2pnsCache.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // 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 General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // 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 
00024 #ifndef __P2PNSCACHE_H_
00025 #define __P2PNSCACHE_H_
00026 
00027 #include <set>
00028 #include <vector>
00029 #include <sstream>
00030 
00031 #include <omnetpp.h>
00032 
00033 #include <NodeHandle.h>
00034 #include <InitStages.h>
00035 #include <BinaryValue.h>
00036 
00047 struct P2pnsCacheEntry
00048 {
00049     BinaryValue value;
00050     cMessage* ttlMessage;
00051     friend std::ostream& operator<<(std::ostream& Stream,
00052                                     const P2pnsCacheEntry entry);
00053 };
00054 
00055 class P2pnsCache : public cSimpleModule
00056 {
00057   public:
00058     virtual int numInitStages() const
00059     {
00060         return MAX_STAGE_APP;
00061     }
00062     
00063     virtual void initialize(int stage);
00064     virtual void handleMessage(cMessage* msg);
00065 
00071     virtual uint32_t getSize();
00072 
00076     virtual void clear();
00077 
00083     virtual bool isEmpty();
00084 
00091     virtual const BinaryValue& getData(const BinaryValue& name);
00092 
00099     virtual cMessage* getTtlMessage(const BinaryValue& name);
00100 
00107     virtual const BinaryValue& getDataAtPos(uint32_t pos = 0);
00108 
00116     virtual void addData(BinaryValue name, BinaryValue value, cMessage* ttlMessage = NULL);
00117 
00123     virtual void removeData(const BinaryValue& name);
00124     void display ();
00125 
00126   protected:
00127     std::map<BinaryValue, P2pnsCacheEntry> cache; 
00132     void updateDisplayString();
00133 
00137     void updateTooltip();
00138 };
00139 
00140 #endif

Generated on Wed Mar 25 16:32:49 2009 for OverSim by  doxygen 1.5.5