00001 /* -*- mode:c++ -*- ******************************************************** 00002 * file: PollApplLayer.h 00003 * 00004 * author: Daniel Willkomm 00005 * 00006 * copyright: (C) 2004 Telecommunication Networks Group (TKN) at 00007 * Technische Universitaet Berlin, Germany. 00008 * 00009 * This program is free software; you can redistribute it 00010 * and/or modify it under the terms of the GNU General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2 of the License, or (at your option) any later 00013 * version. 00014 * For further information see file COPYING 00015 * in the top level directory 00016 *************************************************************************** 00017 * part of: framework implementation developed by tkn 00018 * description: application layer for a simple bse station who polls all 00019 * clients in a round-robin manner 00020 **************************************************************************/ 00021 00022 00023 #ifndef POLL_APPL_LAYER_H 00024 #define POLL_APPL_LAYER_H 00025 00026 #include "ClientApplLayer.h" 00027 #include <map> 00028 00029 00043 class PollApplLayer : public ClientApplLayer 00044 { 00045 public: 00046 Module_Class_Members( PollApplLayer, ClientApplLayer, 0 ); 00048 virtual void initialize(int); 00049 00050 virtual void finish(); 00051 00052 protected: 00054 int numClients; 00055 00057 int aliveClients; 00058 00060 double broadcastInterval; 00061 00063 double pollTimeout; 00064 00065 typedef std::map<int,bool> cAliveMap; 00066 typedef std::map<int,int> cNetwAddrMap; 00067 typedef cAliveMap::iterator cAliveMapIterator; 00068 00070 cAliveMap clients; 00071 00073 cNetwAddrMap clientAddrs; 00074 00076 cAliveMapIterator it; 00077 00079 cMessage* pollTimer; 00080 00081 00083 virtual void handleLowerMsg(cMessage*); 00084 00086 virtual void handleSelfMsg(cMessage*); 00087 00089 void sendBroadcast(); 00090 00092 void sendPoll(int); 00093 00095 void pollNext(); 00096 }; 00097 00098 #endif 00099