schroot-options-base.h

Go to the documentation of this file.
00001 /* Copyright © 2005-2006  Roger Leigh <rleigh@debian.org>
00002  *
00003  * schroot is free software; you can redistribute it and/or modify it
00004  * under the terms of the GNU General Public License as published by
00005  * the Free Software Foundation; either version 2 of the License, or
00006  * (at your option) any later version.
00007  *
00008  * schroot is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011  * General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00016  * MA  02111-1307  USA
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 /* SCHROOT_OPTIONS_BASE_H */
00158 
00159 /*
00160  * Local Variables:
00161  * mode:C++
00162  * End:
00163  */
00164 

Generated on Mon Jun 26 12:50:25 2006 for schroot by  doxygen 1.4.7