Fawkes API Fawkes Development Version
playerc_thread.h
1
2/***************************************************************************
3 * playerc_thread.h - Thread that handles the Player client connection
4 *
5 * Created: Mon Aug 11 22:40:45 2008
6 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7 *
8 ****************************************************************************/
9
10/* This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Library General Public License for more details.
19 *
20 * Read the full text in the LICENSE.GPL file in the doc directory.
21 */
22
23#ifndef _PLUGINS_PLAYER_PLAYERC_THREAD_H_
24#define _PLUGINS_PLAYER_PLAYERC_THREAD_H_
25
26#include <aspect/blackboard.h>
27#include <aspect/blocked_timing.h>
28#include <aspect/clock.h>
29#include <aspect/configurable.h>
30#include <aspect/logging.h>
31#include <aspect/network.h>
32#include <core/threading/thread.h>
33
34#include <list>
35#include <map>
36#include <string>
37
38namespace PlayerCc {
39class PlayerClient;
40class ClientProxy;
41} // namespace PlayerCc
42
43namespace fawkes {
44class ObjectPositionInterface;
45}
46
48
56{
57public:
58 /** Map for Fawkes interfaces. */
59 typedef std::map<std::string, fawkes::Interface *> InterfaceMap;
60
61 /** Map for Player interfaces. */
62 typedef std::map<std::string, PlayerCc::ClientProxy *> ProxyMap;
63
64 /** Map for proxy-interface mappers. */
65 typedef std::list<PlayerProxyFawkesInterfaceMapper *> MapperList;
66
68
69 virtual void init();
70 virtual void finalize();
71 virtual void loop();
72
74
75 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
76protected:
77 virtual void
79 {
80 Thread::run();
81 }
82
83private:
84 void open_fawkes_interfaces();
85 void open_player_proxies();
86 void create_mappers();
87
88 void close_fawkes_interfaces();
89 void close_player_proxies();
90
91private:
92 PlayerCc::PlayerClient *client_;
93
94 std::string cfg_player_host_;
95 unsigned int cfg_player_port_;
96
97 InterfaceMap imap_;
98 ProxyMap pmap_;
99 MapperList mappers_;
100};
101
102#endif
Player Client Thread.
virtual void finalize()
Finalize the thread.
virtual void init()
Initialize the thread.
void sync_fawkes_to_player()
Sync Fawkes to player.
virtual void loop()
Code to execute in the thread.
std::map< std::string, fawkes::Interface * > InterfaceMap
Map for Fawkes interfaces.
PlayerClientThread()
Constructor.
virtual void run()
Stub to see name in backtrace for easier debugging.
std::map< std::string, PlayerCc::ClientProxy * > ProxyMap
Map for Player interfaces.
std::list< PlayerProxyFawkesInterfaceMapper * > MapperList
Map for proxy-interface mappers.
Player proxy to Fawkes interface mapper interface.
Definition: mapper.h:29
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Thread aspect for network communication.
Definition: network.h:35
Thread class encapsulation of pthreads.
Definition: thread.h:46
Fawkes library namespace.