Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * playerc_thread.h - Thread that handles the Player client connection 00004 * 00005 * Created: Mon Aug 11 22:40:45 2008 00006 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_PLAYER_PLAYERC_THREAD_H_ 00024 #define __PLUGINS_PLAYER_PLAYERC_THREAD_H_ 00025 00026 #include <core/threading/thread.h> 00027 #include <aspect/blocked_timing.h> 00028 #include <aspect/logging.h> 00029 #include <aspect/configurable.h> 00030 #include <aspect/clock.h> 00031 #include <aspect/blackboard.h> 00032 #include <aspect/network.h> 00033 00034 #include <string> 00035 #include <map> 00036 #include <list> 00037 00038 namespace PlayerCc { 00039 class PlayerClient; 00040 class ClientProxy; 00041 } 00042 00043 namespace fawkes { 00044 class ObjectPositionInterface; 00045 } 00046 00047 class PlayerProxyFawkesInterfaceMapper; 00048 00049 class PlayerClientThread 00050 : public fawkes::Thread, 00051 public fawkes::BlockedTimingAspect, 00052 public fawkes::LoggingAspect, 00053 public fawkes::ConfigurableAspect, 00054 public fawkes::ClockAspect, 00055 public fawkes::BlackBoardAspect, 00056 public fawkes::NetworkAspect 00057 { 00058 public: 00059 /** Map for Fawkes interfaces. */ 00060 typedef std::map<std::string, fawkes::Interface *> InterfaceMap; 00061 00062 /** Map for Player interfaces. */ 00063 typedef std::map<std::string, PlayerCc::ClientProxy *> ProxyMap; 00064 00065 /** Map for proxy-interface mappers. */ 00066 typedef std::list<PlayerProxyFawkesInterfaceMapper *> MapperList; 00067 00068 PlayerClientThread(); 00069 00070 virtual void init(); 00071 virtual void finalize(); 00072 virtual void loop(); 00073 00074 void sync_fawkes_to_player(); 00075 00076 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00077 protected: virtual void run() { Thread::run(); } 00078 00079 private: 00080 void open_fawkes_interfaces(); 00081 void open_player_proxies(); 00082 void create_mappers(); 00083 00084 void close_fawkes_interfaces(); 00085 void close_player_proxies(); 00086 00087 private: 00088 PlayerCc::PlayerClient *__client; 00089 00090 std::string __cfg_player_host; 00091 unsigned int __cfg_player_port; 00092 00093 InterfaceMap __imap; 00094 ProxyMap __pmap; 00095 MapperList __mappers; 00096 }; 00097 00098 00099 #endif