BrooseBucket.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 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 __BROOSEBUCKET_H_
00025 #define __BROOSEBUCKET_H_
00026 
00027 #include <omnetpp.h>
00028 #include "BrooseHandle.h"
00029 #include "Broose.h"
00030 #include <map>
00031 #include <OverlayKey.h>
00032 
00033 class Broose;
00034 
00043 class BrooseBucket : public cSimpleModule
00044 {
00045 public:
00046     virtual int numInitStages() const
00047     {
00048         return MAX_STAGE_OVERLAY + 1;
00049     }
00050 
00051     virtual void initialize(int stage);
00052     virtual void handleMessage(cMessage* msg);
00053 
00054     // bucket functions
00063     virtual bool add(const NodeHandle& node, bool isAlive = false,
00064                      simtime_t rtt = MAXTIME);
00065 
00071     virtual void remove(const NodeHandle& node);
00072 
00078     virtual const BrooseHandle& get(uint32_t pos = 0);
00079 
00085     virtual const OverlayKey& getDist(uint32_t pos = 0);
00086 
00096     virtual void initializeBucket(int shiftingBits, uint32_t prefix,
00097                                   int size, Broose* overlay,
00098                                   bool isBBucket = false);
00099 
00105     virtual uint32_t getSize();
00106 
00112     virtual uint32_t getMaxSize();
00113 
00120     virtual void fillVector(NodeVector* result);
00121 
00127     virtual bool isEmpty();
00128 
00132     virtual void clear();
00133 
00139     virtual int longestPrefix(void);
00140 
00147     virtual bool keyInRange(const OverlayKey& key);
00148 
00155     virtual int getPos(const NodeHandle& node);
00156 
00163     virtual int getFailedResponses (const NodeHandle& node);
00164 
00170     virtual void increaseFailedResponses (const NodeHandle& node);
00171 
00177     virtual void resetFailedResponses (const NodeHandle& node);
00178 
00185     virtual void setRTT(const NodeHandle& node, simtime_t rpcRTT);
00186 
00193     virtual simtime_t getRTT(const NodeHandle& node);
00194 
00201     virtual void setLastSeen(const NodeHandle& node, simtime_t lastSeen);
00202 
00209     virtual simtime_t getLastSeen(const NodeHandle& node);
00210 
00216     void output(int maxEntries = 0);
00217 
00218 
00219 protected:
00220     // parameter
00221     std::map<OverlayKey, BrooseHandle> bucket; 
00222     std::map<OverlayKey, BrooseHandle>::iterator bucketIter; 
00224     unsigned int maxSize; 
00225     OverlayKey key; 
00226     Broose* overlay; 
00227     bool isBBucket; 
00228 };
00229 #endif
Generated on Wed May 26 16:21:13 2010 for OverSim by  doxygen 1.6.3