Fawkes API Fawkes Development Version
handler.h
1
2/***************************************************************************
3 * handler.h - BlackBoard Network Handler
4 *
5 * Created: Sat Mar 01 15:57:59 2008
6 * Copyright 2006-2011 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. A runtime exception applies to
14 * this software (see LICENSE.GPL_WRE file mentioned below for details).
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Library General Public License for more details.
20 *
21 * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22 */
23
24#ifndef _FAWKES_BLACKBOARD_NETWORK_HANDLER_H_
25#define _FAWKES_BLACKBOARD_NETWORK_HANDLER_H_
26
27#include <core/threading/thread.h>
28#include <core/utils/lock_map.h>
29#include <core/utils/lock_queue.h>
30#include <netcomm/fawkes/handler.h>
31#include <utils/uuid.h>
32
33#include <list>
34
35namespace fawkes {
36
37class Interface;
38class BlackBoard;
39class FawkesNetworkHub;
40class BlackBoardNetHandlerInterfaceListener;
41class BlackBoardNetHandlerInterfaceObserver;
42
44{
45public:
48
49 /* from FawkesNetworkHandler interface */
51 virtual void client_connected(unsigned int clid);
52 virtual void client_disconnected(unsigned int clid);
53 virtual void loop();
54
55 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
56protected:
57 virtual void
59 {
61 }
62
63private:
64 void send_opensuccess(unsigned int clid, Interface *interface);
65 void send_openfailure(unsigned int clid, unsigned int error_code);
66
67 BlackBoard * bb_;
69
70 // All interfaces, key is the instance serial, value the interface
73
74 std::map<Uuid, BlackBoardNetHandlerInterfaceListener *> listeners_;
75 std::map<Uuid, BlackBoardNetHandlerInterfaceListener *>::iterator lit_;
76
78
79 // Map from instance serial to clid
80 LockMap<Uuid, unsigned int> serial_to_clid_;
81
82 // Interfaces per client, key is the client ID, value a list of interfaces opened by client
84 std::list<Interface *>::iterator ciit_;
85
86 FawkesNetworkHub *nhub_;
87};
88
89} // end namespace fawkes
90
91#endif
Interface observer for blackboard network handler.
BlackBoard Network Handler.
Definition: handler.h:44
virtual void client_connected(unsigned int clid)
Client connected.
Definition: handler.cpp:422
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: handler.h:58
virtual void client_disconnected(unsigned int clid)
Client disconnected.
Definition: handler.cpp:431
~BlackBoardNetworkHandler()
Destructor.
Definition: handler.cpp:67
virtual void handle_network_message(FawkesNetworkMessage *msg)
Handle network message.
Definition: handler.cpp:411
virtual void loop()
Process all network messages that have been received.
Definition: handler.cpp:83
BlackBoardNetworkHandler(BlackBoard *blackboard, FawkesNetworkHub *hub)
Constructor.
Definition: handler.cpp:55
The BlackBoard abstract class.
Definition: blackboard.h:46
Network handler abstract base class.
Definition: handler.h:32
Fawkes Network Hub.
Definition: hub.h:34
Representation of a message that is sent over the network.
Definition: message.h:77
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Map with a lock.
Definition: lock_map.h:36
Thread class encapsulation of pthreads.
Definition: thread.h:46
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:918
Fawkes library namespace.