00001 #ifndef __PASTRYNEIGHBORHOODSET_H 00002 #define __PASTRYNEIGHBORHOODSET_H 00003 00004 // 00005 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 // 00021 00027 #include <vector> 00028 00029 #include <omnetpp.h> 00030 00031 #include <NodeHandle.h> 00032 00033 #include "PastryStateObject.h" 00034 #include "PastryTypes.h" 00035 #include "PastryMessage_m.h" 00036 00045 class PastryNeighborhoodSet : public PastryStateObject 00046 { 00047 public: 00048 00056 void initializeSet(uint32_t numberOfNeighbors, 00057 uint32_t bitsPerDigit, 00058 const NodeHandle& owner); 00059 00065 virtual void dumpToStateMessage(PastryStateMessage* msg) const; 00066 00078 virtual const NodeHandle& findCloserNode(const OverlayKey& destination, 00079 bool optimize = false); 00080 00081 void findCloserNodes(const OverlayKey& destination, 00082 NodeVector* nodes); 00083 00091 virtual bool mergeNode(const NodeHandle& node, simtime_t prox); 00092 00100 virtual void dumpToVector(std::vector<TransportAddress>& affected) const; 00101 00107 virtual const TransportAddress& failedNode(const TransportAddress& failed); 00108 00109 private: 00110 uint32_t numberOfNeighbors; 00111 std::vector<PastryExtendedNode> neighbors; 00112 virtual void earlyInit(void); 00113 }; 00114 00119 std::ostream& operator<<(std::ostream& os, const PastryExtendedNode& n); 00120 00121 #endif