PastryStateObject.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 
00019 
00020 #ifndef __PASTRYSTATEOBJECT_H
00021 #define __PASTRYSTATEOBJECT_H
00022 
00028 #include <vector>
00029 
00030 #include <omnetpp.h>
00031 
00032 #include <NodeHandle.h>
00033 #include <NodeVector.h>
00034 
00035 #include "PastryTypes.h"
00036 #include "PastryMessage_m.h"
00037 
00047 class PastryStateObject : public cSimpleModule
00048 {
00049   public:
00050 
00051     void handleMessage(cMessage* msg);
00052 
00053     int numInitStages(void) const;
00054 
00055     void initialize(int stage);
00056 
00064     virtual const NodeHandle& getDestinationNode(const OverlayKey& destination);
00065 
00077     virtual const NodeHandle& findCloserNode(const OverlayKey& destination,
00078                                              bool optimize = false) = 0;
00079 
00080     virtual void findCloserNodes(const OverlayKey& destination,
00081                                  NodeVector* nodes) = 0;
00082 
00089     virtual const TransportAddress& failedNode(const TransportAddress& failed) = 0;
00090 
00099     virtual const TransportAddress& repair(const PastryStateMessage* msg,
00100                                            const PastryStateMsgProximity& prox);
00101 
00107     virtual void dumpToStateMessage(PastryStateMessage* msg) const = 0;
00108 
00116     bool mergeState(const PastryStateMessage* msg,
00117                     const PastryStateMsgProximity* prox);
00118 
00125     virtual void dumpToVector(std::vector<TransportAddress>& affected)
00126         const = 0;
00127 
00136     bool isCloser(const NodeHandle& test, const OverlayKey& destination,
00137                   const NodeHandle& reference =
00138                       NodeHandle::UNSPECIFIED_NODE) const;
00139 
00152     bool specialCloserCondition(const NodeHandle& test,
00153                                 const OverlayKey& destination,
00154                                 const NodeHandle& reference =
00155                                     NodeHandle::UNSPECIFIED_NODE) const;
00156 
00157   protected:
00158 
00163     NodeHandle owner;
00164 
00165     uint32_t bitsPerDigit;
00166 
00170   private:
00171     static const PastryExtendedNode* _unspecNode;
00172 
00173   protected:
00174     static const PastryExtendedNode& unspecNode()
00175     {
00176         if (_unspecNode == NULL)
00177             _unspecNode = new PastryExtendedNode();
00178         return *_unspecNode;
00179     }
00180 
00181   private:
00182 
00186     virtual void earlyInit(void) = 0;
00187 
00195     virtual bool mergeNode(const NodeHandle& node, simtime_t prox) = 0;
00196 
00204     const OverlayKey* keyDist(const OverlayKey& a, const OverlayKey& b) const;
00205 };
00206 
00207 #endif
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3