8 #ifndef _QI_APPLICATION_HPP_
9 #define _QI_APPLICATION_HPP_
11 #include <boost/function.hpp>
21 Application(
const std::string &name,
int& argc,
char** &argv);
27 static const std::vector<std::string>& arguments();
29 static const char**
argv();
30 static void setName(
const std::string &name);
31 static std::string name();
32 static void setArguments(
int argc,
char** argv);
33 static void setArguments(
const std::vector<std::string>& arguments);
35 static void* loadModule(
const std::string& name,
int flags=-1);
36 static void unloadModule(
void* handle);
37 static bool terminated();
38 static bool initialized();
42 static bool atEnter(boost::function<
void()> func);
43 static bool atExit(boost::function<
void()> func);
44 static bool atStop(boost::function<
void()> func);
45 static bool atSignal(boost::function<
void(
int)> func,
int signal);
49 #define QI_AT_ENTER(func) \
50 static bool QI_UNIQ_DEF(_qi_atenter) = ::qi::Application::atEnter(func);
52 #define QI_AT_EXIT(func) \
53 static bool QI_UNIQ_DEF(_qi_atexit) = ::qi::Application::atExit(func);
66 #define _QI_COMMAND_LINE_OPTIONS(desc, opts) \
67 static void QI_UNIQ_DEF(_qi_opt_func)() { \
68 namespace po = boost::program_options; \
69 po::variables_map vm; \
70 po::command_line_parser p(::qi::Application::arguments()); \
71 po::options_description options(desc); \
73 using namespace boost::program_options; \
74 options.add_options() opts; \
76 po::parsed_options res = p.options(options) \
77 .allow_unregistered() \
83 po::options_description descTmp; \
84 descTmp.add_options() \
86 po::variables_map vmTmp; \
87 po::store(po::command_line_parser(qi::Application::arguments()) \
88 .options(descTmp).allow_unregistered().run(), vmTmp); \
89 if (vmTmp.count("help")) \
90 std::cout << options << std::endl; \
92 std::vector<std::string> args \
93 = po::collect_unrecognized(res.options, po::include_positional); \
95 ::qi::Application::setArguments(args); \
97 QI_AT_ENTER(boost::bind(&(QI_UNIQ_DEF(_qi_opt_func))))
100 #endif // _QI_APPLICATION_HPP_
QI_API_DEPRECATED const char ** argv()
Deprecated, see detailed description.
QI_API_DEPRECATED int argc()
Deprecated, see detailed description.
Class handling startup and teardown of an application.
dll import/export and compiler message
QI_API_DEPRECATED const char * program()
Deprecated, see detailed description.