Fawkes API Fawkes Development Version
handler.h
1
2/***************************************************************************
3 * handler.h - Fawkes plugin network handler
4 *
5 * Created: Thu Feb 12 10:23:02 2009
6 * Copyright 2006-2009 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 _PLUGIN_NET_HANDLER_H_
25#define _PLUGIN_NET_HANDLER_H_
26
27#include <config/change_handler.h>
28#include <core/threading/thread.h>
29#include <core/utils/lock_list.h>
30#include <core/utils/lock_map.h>
31#include <core/utils/lock_queue.h>
32#include <netcomm/fawkes/handler.h>
33#include <plugin/listener.h>
34#include <utils/system/fam.h>
35
36#include <list>
37#include <map>
38#include <string>
39#include <utility>
40
41namespace fawkes {
42
43class ThreadCollector;
44class FawkesNetworkHub;
45class Plugin;
46class PluginLoader;
47class PluginListMessage;
48class Configuration;
49class FamThread;
50
54{
55public:
58
60 virtual void client_connected(unsigned int clid);
61 virtual void client_disconnected(unsigned int clid);
62
63 virtual void loop();
64
65 virtual void plugin_loaded(const char *plugin_name);
66 virtual void plugin_unloaded(const char *plugin_name);
67
68private:
69 PluginListMessage *list_avail();
70 PluginListMessage *list_loaded();
71 void send_load_failure(const char *plugin_name, unsigned int client_id);
72 void send_load_success(const char *plugin_name, unsigned int client_id);
73 void send_unload_failure(const char *plugin_name, unsigned int client_id);
74 void send_unload_success(const char *plugin_name, unsigned int client_id);
75 void send_loaded(const char *plugin_name);
76 void send_unloaded(const char *plugin_name);
77
78 void load(const char *plugin_list, unsigned int clid);
79 void unload(const char *plugin_list, unsigned int clid);
80
81 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
82protected:
83 virtual void
85 {
87 }
88
89private:
90 PluginManager * manager_;
91 FawkesNetworkHub *hub_;
92
94
95 LockList<unsigned int> subscribers_;
97};
98
99} // end namespace fawkes
100
101#endif
Plugin representation for JSON transfer.
Definition: Plugin.h:28
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
Plugin list message.
Definition: list_message.h:35
PluginManager listener.
Definition: listener.h:30
Fawkes Plugin Manager.
Definition: manager.h:48
Fawkes Plugin Network Handler.
Definition: handler.h:54
~PluginNetworkHandler()
Destructor.
Definition: handler.cpp:73
virtual void handle_network_message(FawkesNetworkMessage *msg)
Called for incoming messages that are addressed to the correct component ID.
Definition: handler.cpp:350
virtual void plugin_unloaded(const char *plugin_name)
Plugin unloaded event.
Definition: handler.cpp:375
virtual void loop()
Process all network messages that have been received.
Definition: handler.cpp:261
PluginNetworkHandler(PluginManager *manager, FawkesNetworkHub *hub)
Constructor.
Definition: handler.cpp:61
virtual void client_connected(unsigned int clid)
Called when a new client connected.
Definition: handler.cpp:358
virtual void client_disconnected(unsigned int clid)
Called when a client disconnected.
Definition: handler.cpp:363
virtual void plugin_loaded(const char *plugin_name)
Plugin loaded event.
Definition: handler.cpp:369
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: handler.h:84
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.