Fawkes API  Fawkes Development Version
init_options.h
1 
2 /***************************************************************************
3  * init_options.h - Fawkes run-time initialization options
4  *
5  * Created: Tue Jun 07 14:06:56 2011
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 _LIBS_BASEAPP_INIT_OPTIONS_H_
25 #define _LIBS_BASEAPP_INIT_OPTIONS_H_
26 
27 #include <logging/logger.h>
28 #include <utils/system/dynamic_module/module.h>
29 
30 namespace fawkes {
31 namespace runtime {
32 
33 class InitOptions
34 {
35 public:
36  InitOptions(const char *basename);
37  InitOptions(int argc, char **argv);
38  InitOptions(const InitOptions &options);
39  ~InitOptions();
40 
41  InitOptions &operator=(const InitOptions &options);
42 
43  InitOptions &net_tcp_port(unsigned short int port);
44  InitOptions &net_service_name(const char *service_name);
45  InitOptions &
46  daemonize(bool daemonize, bool kill = false, bool status = false, const char *pid_file = 0);
47  InitOptions &loggers(const char *loggers);
50  InitOptions &user(const char *username);
51  InitOptions &group(const char *groupname);
52  InitOptions &config_file(const char *config_file);
55  InitOptions &load_plugins(const char *plugin_list);
59 
60  const char *basename() const;
61 
62  bool has_net_tcp_port() const;
63  unsigned short int net_tcp_port() const;
64  bool has_net_service_name() const;
65  const char * net_service_name() const;
66 
67  bool has_load_plugin_list() const;
68  const char *load_plugin_list() const;
69  const char *default_plugin() const;
70 
71  bool has_loggers() const;
72  const char * loggers() const;
74 
75  bool show_help() const;
76  bool bb_cleanup() const;
77  bool init_plugin_cache() const;
78 
79  bool daemonize() const;
80  bool daemonize_kill() const;
81  bool daemonize_status() const;
82  const char *daemon_pid_file() const;
83 
84  bool has_username() const;
85  const char *username() const;
86  bool has_groupname() const;
87  const char *groupname() const;
88 
89  const char *config_file() const;
90 
92 
93  bool default_signal_handlers() const;
94 
95 private:
96  char *basename_;
97 
98  bool has_net_tcp_port_;
99  unsigned short int net_tcp_port_;
100 
101  bool has_load_plugin_list_;
102  char *load_plugin_list_;
103  char *default_plugin_;
104 
105  bool has_loggers_;
106  char * loggers_;
107  Logger::LogLevel log_level_;
108 
109  bool has_net_service_name_;
110  char *net_service_name_;
111 
112  bool has_username_;
113  char *username_;
114  bool has_groupname_;
115  char *groupname_;
116 
117  char *config_file_;
118 
119  bool daemonize_;
120  char *daemon_pid_file_;
121  bool daemonize_kill_;
122  bool daemonize_status_;
123 
124  bool show_help_;
125  bool bb_cleanup_;
126 
127  bool init_plugin_cache_;
128  Module::ModuleFlags plugin_module_flags_;
129  bool default_signal_handlers_;
130 };
131 
132 } // end namespace runtime
133 } // end namespace fawkes
134 
135 #endif
fawkes::runtime::InitOptions::default_plugin
const char * default_plugin() const
Get name of default plugin.
Definition: init_options.cpp:626
fawkes::Module::ModuleFlags
ModuleFlags
Flags for the loading process.
Definition: module.h:49
fawkes::runtime::InitOptions::net_service_name
const char * net_service_name() const
Get network service name.
Definition: init_options.cpp:662
fawkes::runtime::InitOptions::daemonize_status
bool daemonize_status() const
Check if status of daemon has been requested.
Definition: init_options.cpp:770
fawkes::runtime::InitOptions::groupname
const char * groupname() const
Get group name to run as.
Definition: init_options.cpp:815
fawkes::runtime::InitOptions::has_groupname
bool has_groupname() const
Check if group name has been passed.
Definition: init_options.cpp:806
fawkes::runtime::InitOptions::has_loggers
bool has_loggers() const
Check if logger string has been passed.
Definition: init_options.cpp:689
fawkes::runtime::InitOptions::daemonize_kill
bool daemonize_kill() const
Check if killing of daemon has been requested.
Definition: init_options.cpp:761
fawkes::runtime::InitOptions::has_load_plugin_list
bool has_load_plugin_list() const
Check if plugin load list has been set.
Definition: init_options.cpp:671
fawkes::runtime::InitOptions::daemonize
bool daemonize() const
Check if daemonization has been requested.
Definition: init_options.cpp:752
fawkes::runtime::InitOptions::has_net_tcp_port
bool has_net_tcp_port() const
Check if TCP port has been passed.
Definition: init_options.cpp:635
fawkes::runtime::InitOptions::InitOptions
InitOptions(const char *basename)
Constructor.
Definition: init_options.cpp:55
fawkes::runtime::InitOptions::has_username
bool has_username() const
Check if user name has been passed.
Definition: init_options.cpp:788
fawkes::runtime::InitOptions::config_file
const char * config_file() const
Get config file path.
Definition: init_options.cpp:824
fawkes::runtime::InitOptions::load_plugins
InitOptions & load_plugins(const char *plugin_list)
Set list of plugins to load during startup.
Definition: init_options.cpp:525
fawkes
fawkes::runtime::InitOptions::init_plugin_cache
bool init_plugin_cache() const
Check if plugin cache initialization has been requested.
Definition: init_options.cpp:734
fawkes::runtime::InitOptions::bb_cleanup
bool bb_cleanup() const
Check if blackboard cleanup has been requested.
Definition: init_options.cpp:725
fawkes::runtime::InitOptions::net_tcp_port
unsigned short int net_tcp_port() const
Get Fawkes network TCP port.
Definition: init_options.cpp:644
fawkes::runtime::InitOptions::~InitOptions
~InitOptions()
Destructor.
Definition: init_options.cpp:274
fawkes::runtime::InitOptions::default_signal_handlers
bool default_signal_handlers() const
Check if default signal handlers should be enabled.
Definition: init_options.cpp:743
fawkes::runtime::InitOptions::has_net_service_name
bool has_net_service_name() const
Check if network service name has been passed.
Definition: init_options.cpp:653
fawkes::runtime::InitOptions::operator=
InitOptions & operator=(const InitOptions &options)
Assignment operator.
Definition: init_options.cpp:299
fawkes::runtime::InitOptions::group
InitOptions & group(const char *groupname)
Set group name to run as.
Definition: init_options.cpp:544
fawkes::runtime::InitOptions::log_level
Logger::LogLevel log_level() const
Get log level.
Definition: init_options.cpp:707
fawkes::runtime::InitOptions::loggers
const char * loggers() const
Get logger string.
Definition: init_options.cpp:698
fawkes::runtime::InitOptions::user
InitOptions & user(const char *username)
Set user name to run as.
Definition: init_options.cpp:507
fawkes::runtime::InitOptions::load_plugin_list
const char * load_plugin_list() const
Get plugin load list.
Definition: init_options.cpp:680
fawkes::runtime::InitOptions::username
const char * username() const
Get user name to run as.
Definition: init_options.cpp:797
fawkes::Logger::LogLevel
LogLevel
Log level.
Definition: logger.h:50
fawkes::runtime::InitOptions::basename
const char * basename() const
Get program basename.
Definition: init_options.cpp:613
fawkes::runtime::InitOptions::daemon_pid_file
const char * daemon_pid_file() const
Get daemon PID file.
Definition: init_options.cpp:779
fawkes::runtime::InitOptions::plugin_module_flags
Module::ModuleFlags plugin_module_flags() const
Get plugin module flags.
Definition: init_options.cpp:833
fawkes::runtime::InitOptions::show_help
bool show_help() const
Check if help has been requested.
Definition: init_options.cpp:716
fawkes::runtime::InitOptions
Definition: init_options.h:42