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 <core/threading/thread.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/clock.h>
31 #include <aspect/blackboard.h>
32 #include <aspect/network.h>
33 
34 #include <string>
35 #include <map>
36 #include <list>
37 
38 namespace PlayerCc {
39  class PlayerClient;
40  class ClientProxy;
41 }
42 
43 namespace fawkes {
44  class ObjectPositionInterface;
45 }
46 
48 
50 : public fawkes::Thread,
52  public fawkes::LoggingAspect,
54  public fawkes::ClockAspect,
57 {
58  public:
59  /** Map for Fawkes interfaces. */
60  typedef std::map<std::string, fawkes::Interface *> InterfaceMap;
61 
62  /** Map for Player interfaces. */
63  typedef std::map<std::string, PlayerCc::ClientProxy *> ProxyMap;
64 
65  /** Map for proxy-interface mappers. */
66  typedef std::list<PlayerProxyFawkesInterfaceMapper *> MapperList;
67 
69 
70  virtual void init();
71  virtual void finalize();
72  virtual void loop();
73 
74  void sync_fawkes_to_player();
75 
76  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
77  protected: virtual void run() { Thread::run(); }
78 
79  private:
80  void open_fawkes_interfaces();
81  void open_player_proxies();
82  void create_mappers();
83 
84  void close_fawkes_interfaces();
85  void close_player_proxies();
86 
87  private:
88  PlayerCc::PlayerClient *__client;
89 
90  std::string __cfg_player_host;
91  unsigned int __cfg_player_port;
92 
93  InterfaceMap __imap;
94  ProxyMap __pmap;
95  MapperList __mappers;
96 };
97 
98 
99 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
std::list< PlayerProxyFawkesInterfaceMapper * > MapperList
Map for proxy-interface mappers.
Fawkes library namespace.
std::map< std::string, fawkes::Interface * > InterfaceMap
Map for Fawkes interfaces.
Thread aspect for network communication.
Definition: network.h:37
Thread class encapsulation of pthreads.
Definition: thread.h:42
Thread aspect to use blocked timing.
Player proxy to Fawkes interface mapper interface.
Definition: mapper.h:28
virtual void run()
Stub to see name in backtrace for easier debugging.
Player Client Thread.
Thread aspect to log output.
Definition: logging.h:35
std::map< std::string, PlayerCc::ClientProxy * > ProxyMap
Map for Player interfaces.
Thread aspect to access configuration data.
Definition: configurable.h:35