00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef SCHROOT_OPTIONS_BASE_H
00021 #define SCHROOT_OPTIONS_BASE_H
00022
00023 #include <sbuild/sbuild-session.h>
00024 #include <sbuild/sbuild-types.h>
00025
00026 #include <string>
00027
00028 #ifdef HAVE_TR1_MEMORY
00029 #include <tr1/memory>
00030 #elif HAVE_BOOST_SHARED_PTR_HPP
00031 #include <boost/shared_ptr.hpp>
00032 namespace std { namespace tr1 { using boost::shared_ptr; } }
00033 #else
00034 #error A shared_ptr implementation is not available
00035 #endif
00036
00037 #include <boost/program_options.hpp>
00038
00039 namespace schroot
00040 {
00041
00047 class options_base
00048 {
00049 public:
00051 enum action_type
00052 {
00053 ACTION_SESSION_AUTO,
00054 ACTION_SESSION_BEGIN,
00055 ACTION_SESSION_RECOVER,
00056 ACTION_SESSION_RUN,
00057 ACTION_SESSION_END,
00058 ACTION_VERSION,
00059 ACTION_LIST,
00060 ACTION_INFO,
00061 ACTION_LOCATION,
00062 ACTION_CONFIG
00063 };
00064
00066 typedef std::tr1::shared_ptr<options_base> ptr;
00067
00074 options_base (int argc,
00075 char *argv[]);
00076
00078 virtual ~options_base ();
00079
00081 action_type action;
00083 sbuild::string_list chroots;
00085 std::string chroot_path;
00087 sbuild::string_list command;
00089 std::string user;
00091 bool preserve;
00093 bool quiet;
00095 bool verbose;
00097 bool all;
00099 bool all_chroots;
00101 bool all_sessions;
00103 bool load_chroots;
00105 bool load_sessions;
00107 bool session_force;
00108
00109 protected:
00116 void
00117 set_action (action_type action);
00118
00125 bool
00126 all_used () const
00127 {
00128 return (this->all || this->all_chroots || this->all_sessions);
00129 }
00130
00131 virtual void
00132 add_options ();
00133
00134 virtual void
00135 parse_options (int argc,
00136 char *argv[]);
00137
00138 virtual void
00139 check_options ();
00140
00141 virtual void
00142 check_actions ();
00143
00144 boost::program_options::options_description general;
00145 boost::program_options::options_description chroot;
00146 boost::program_options::options_description chrootenv;
00147 boost::program_options::options_description session;
00148 boost::program_options::options_description hidden;
00149 boost::program_options::positional_options_description positional;
00150 boost::program_options::options_description visible;
00151 boost::program_options::options_description global;
00152 boost::program_options::variables_map vm;
00153 };
00154
00155 }
00156
00157 #endif
00158
00159
00160
00161
00162
00163
00164