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 <netcomm/fawkes/handler.h>
28 #include <core/threading/thread.h>
29 #include <core/utils/lock_queue.h>
30 #include <core/utils/lock_list.h>
31 #include <core/utils/lock_map.h>
32 #include <config/change_handler.h>
33 #include <utils/system/fam.h>
34 #include <plugin/listener.h>
35 
36 #include <map>
37 #include <list>
38 #include <string>
39 #include <utility>
40 
41 namespace fawkes {
42 #if 0 /* just to make Emacs auto-indent happy */
43 }
44 #endif
45 
46 class ThreadCollector;
47 class FawkesNetworkHub;
48 class Plugin;
49 class PluginLoader;
50 class PluginListMessage;
51 class Configuration;
52 class FamThread;
53 
55 : public fawkes::Thread,
58 {
59  public:
62 
64  virtual void client_connected(unsigned int clid);
65  virtual void client_disconnected(unsigned int clid);
66 
67  virtual void loop();
68 
69  virtual void plugin_loaded(const char *plugin_name);
70  virtual void plugin_unloaded(const char *plugin_name);
71 
72  private:
73  PluginListMessage * list_avail();
74  PluginListMessage * list_loaded();
75  void send_load_failure(const char *plugin_name, unsigned int client_id);
76  void send_load_success(const char *plugin_name, unsigned int client_id);
77  void send_unload_failure(const char *plugin_name, unsigned int client_id);
78  void send_unload_success(const char *plugin_name, unsigned int client_id);
79  void send_loaded(const char *plugin_name);
80  void send_unloaded(const char *plugin_name);
81 
82  void load(const char *plugin_list, unsigned int clid);
83  void unload(const char *plugin_list, unsigned int clid);
84 
85  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
86  protected: virtual void run() { Thread::run(); }
87 
88  private:
89  PluginManager *__manager;
90  FawkesNetworkHub *__hub;
91 
93 
94  LockList<unsigned int> __subscribers;
96 };
97 
98 } // end namespace fawkes
99 
100 #endif
virtual void plugin_unloaded(const char *plugin_name)
Plugin unloaded event.
Definition: handler.cpp:388
PluginNetworkHandler(PluginManager *manager, FawkesNetworkHub *hub)
Constructor.
Definition: handler.cpp:66
virtual void loop()
Process all network messages that have been received.
Definition: handler.cpp:273
Fawkes library namespace.
virtual void run()
Code to execute in the thread.
Definition: thread.cpp:939
Representation of a message that is sent over the network.
Definition: message.h:75
Thread class encapsulation of pthreads.
Definition: thread.h:42
~PluginNetworkHandler()
Destructor.
Definition: handler.cpp:80
Fawkes Plugin Network Handler.
Definition: handler.h:54
Fawkes Plugin Manager.
Definition: manager.h:51
virtual void handle_network_message(FawkesNetworkMessage *msg)
Called for incoming messages that are addressed to the correct component ID.
Definition: handler.cpp:361
PluginManager listener.
Definition: listener.h:32
Fawkes Network Hub.
Definition: hub.h:33
Plugin list message.
Definition: list_message.h:34
virtual void plugin_loaded(const char *plugin_name)
Plugin loaded event.
Definition: handler.cpp:382
Network handler abstract base class.
Definition: handler.h:31
virtual void client_disconnected(unsigned int clid)
Called when a client disconnected.
Definition: handler.cpp:376
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: handler.h:86
virtual void client_connected(unsigned int clid)
Called when a new client connected.
Definition: handler.cpp:370