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 00025 #ifndef __SCRIBEGROUP_H_ 00026 #define __SCRIBEGROUP_H_ 00027 00028 #include <set> 00029 #include "OverlayKey.h" 00030 #include "NodeHandle.h" 00031 00032 class ScribeGroup; 00033 00034 #include "ScribeMessage_m.h" 00035 00040 class ScribeGroup 00041 { 00042 private: 00043 OverlayKey groupId; 00044 NodeHandle rendezvousPoint; 00045 NodeHandle parent; 00046 std::set<NodeHandle> children; 00047 bool subscription; 00048 bool amISource; 00049 00050 ScribeTimer* parentTimer; 00051 ScribeTimer* heartbeatTimer; 00052 00053 public: 00059 ScribeGroup( OverlayKey id ); 00060 ~ScribeGroup( ); 00061 00068 std::pair<std::set<NodeHandle>::iterator, bool> addChild( const NodeHandle& node ); 00069 00075 void removeChild( const NodeHandle& node ); 00076 00082 std::set<NodeHandle>::iterator getChildrenBegin(); 00083 00089 std::set<NodeHandle>::iterator getChildrenEnd(); 00090 00096 int numChildren() const { return children.size(); } 00097 00103 bool isForwarder() const; 00104 00114 bool getAmISource() const { return amISource; } 00115 00125 void setAmISource( bool source ) { amISource = source; } 00126 00132 bool getSubscription() const { return subscription; } 00133 00139 void setSubscription( bool subscribe ) { subscription = subscribe; } 00140 00146 NodeHandle getParent() const { return parent; } 00147 00153 void setParent( NodeHandle& _parent ) { parent = _parent; } 00154 00160 NodeHandle getRendezvousPoint() const { return rendezvousPoint; } 00161 00167 void setRendezvousPoint( const NodeHandle& _rendezvousPoint ) { rendezvousPoint = _rendezvousPoint; } 00168 00174 OverlayKey getGroupId() const { return groupId; } 00175 00184 ScribeTimer* getParentTimer() { return parentTimer; } 00185 00194 void setParentTimer(ScribeTimer* t ) { parentTimer = t; } 00195 00204 ScribeTimer* getHeartbeatTimer() { return heartbeatTimer; } 00205 00214 void setHeartbeatTimer(ScribeTimer* t ) { heartbeatTimer = t; } 00215 00222 bool operator== (const OverlayKey& id) const { return id == groupId; }; 00223 00230 bool operator== (const ScribeGroup& a) const { return a.getGroupId() == groupId; }; 00231 00238 bool operator< (const OverlayKey& id) const { return id < groupId; }; 00239 00246 bool operator< (const ScribeGroup& a) const { return groupId < a.getGroupId(); }; 00247 }; 00248 00249 #endif