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 __GIAMESSAGEBOOKKEEPING_H_ 00025 #define __GIAMESSAGEBOOKKEEPING_H_ 00026 00027 #include <vector> 00028 #include <queue> 00029 #include <map> 00030 00031 #include "GiaNeighbors.h" 00032 #include "GiaMessage_m.h" 00033 #include "GiaNode.h" 00034 00035 00042 class GiaMessageBookkeeping 00043 { 00044 public: 00045 00051 GiaMessageBookkeeping( GiaNeighbors* neighbors, uint32_t timeout ); 00052 00056 ~GiaMessageBookkeeping(); 00057 00062 uint32_t getSize(); 00063 00068 void addMessage( GiaIDMessage* msg ); 00069 00074 void removeMessage( GiaIDMessage* msg ); 00075 00080 bool contains( GiaIDMessage* msg ); 00081 00087 NodeHandle getNextHop( GiaIDMessage* msg ); 00088 00092 void removeTimedoutMessages(); 00093 00094 protected: 00095 00096 class GiaNodeQueueCompare : public std::binary_function<FullGiaNodeInfo, FullGiaNodeInfo, FullGiaNodeInfo> 00097 { 00098 public: 00099 bool operator()(const FullGiaNodeInfo& x, const FullGiaNodeInfo& y); 00100 }; 00101 00102 struct MessageItem 00103 { 00104 std::vector<GiaNode> remainNodes; 00105 simtime_t timestamp; 00106 }; 00107 std::map<OverlayKey, MessageItem> messages; 00108 GiaNeighbors* neighbors; 00109 uint32_t timeout; 00110 }; 00111 00112 #endif