Fawkes API  Fawkes Development Version
plugin_tool.h
1 
2 /***************************************************************************
3  * plugin_tool.h - Fawkes plugin tool
4  *
5  * Created: Sun Nov 26 16:44:00 2006
6  * Copyright 2006 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 _TOOLS_PLUGIN_PLUGIN_TOOL_H_
24 #define _TOOLS_PLUGIN_PLUGIN_TOOL_H_
25 
26 #include <netcomm/fawkes/client_handler.h>
27 #include <utils/system/signal.h>
28 
29 namespace fawkes {
30 class FawkesNetworkClient;
31 class FawkesNetworkMessage;
32 class ArgumentParser;
33 } // namespace fawkes
34 
36 {
37 public:
40  ~PluginTool();
41 
42  void handle_signal(int signum);
43 
44  void set_load_plugin(const char *plugin_name);
45  void set_unload_plugin(const char *plugin_name);
46  void set_watch_mode();
47  void set_list_mode();
48 
49  void run();
50 
51  static void print_usage(const char *program_name);
52 
53 private:
54  void load();
55  void unload();
56  void list_loaded();
57  void watch();
58  void list_avail();
59 
60  virtual void deregistered(unsigned int id) throw();
61  virtual void inbound_received(fawkes::FawkesNetworkMessage *msg, unsigned int id) throw();
62  virtual void connection_died(unsigned int id) throw();
63  virtual void connection_established(unsigned int id) throw();
64 
65 private:
66  typedef enum {
67  M_LIST_LOADED,
68  M_LIST_AVAIL,
69  M_LOAD,
70  M_UNLOAD,
71  M_RELOAD,
72  M_WATCH,
73  M_UNKNOWN
74  } OperationMode;
75 
77  OperationMode opmode;
78  const char * plugin_name;
79  const char * program_name_;
80  bool quit;
81 
82  bool list_found;
83 };
84 
85 #endif
PluginTool::set_unload_plugin
void set_unload_plugin(const char *plugin_name)
Unload plugin on next run.
Definition: plugin_tool.cpp:130
PluginTool::~PluginTool
~PluginTool()
Destructor.
Definition: plugin_tool.cpp:90
fawkes::SignalHandler
Interface for signal handling.
Definition: signal.h:36
PluginTool::PluginTool
PluginTool(fawkes::ArgumentParser *argp, fawkes::FawkesNetworkClient *c)
Constructor.
Definition: plugin_tool.cpp:46
PluginTool::set_watch_mode
void set_watch_mode()
Set watch mode.
Definition: plugin_tool.cpp:140
fawkes::FawkesNetworkClientHandler
Message handler for FawkesNetworkClient.
Definition: client_handler.h:32
fawkes
Fawkes library namespace.
fawkes::ArgumentParser
Parse command line arguments.
Definition: argparser.h:64
PluginTool
Program to communicate with plugin manager via Fawkes network.
Definition: plugin_tool.h:36
PluginTool::set_list_mode
void set_list_mode()
Set list mode.
Definition: plugin_tool.cpp:149
PluginTool::run
void run()
Run opmode as requested determined by the arguments.
Definition: plugin_tool.cpp:379
fawkes::FawkesNetworkMessage
Representation of a message that is sent over the network.
Definition: message.h:77
fawkes::FawkesNetworkClient
Simple Fawkes network client.
Definition: client.h:52
PluginTool::handle_signal
void handle_signal(int signum)
Handle signals.
Definition: plugin_tool.cpp:158
PluginTool::print_usage
static void print_usage(const char *program_name)
Print usage.
Definition: plugin_tool.cpp:98
PluginTool::set_load_plugin
void set_load_plugin(const char *plugin_name)
Load plugin on next run.
Definition: plugin_tool.cpp:118