source: trunk/debathena/third/schroot/bin/schroot/schroot-options-base.h @ 24167

Revision 24167, 4.2 KB checked in by broder, 15 years ago (diff)
Import schroot upstream into subversion.
Line 
1/* Copyright © 2005-2007  Roger Leigh <rleigh@debian.org>
2 *
3 * schroot is free software: you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * schroot is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program.  If not, see
15 * <http://www.gnu.org/licenses/>.
16 *
17 *********************************************************************/
18
19#ifndef SCHROOT_OPTIONS_BASE_H
20#define SCHROOT_OPTIONS_BASE_H
21
22#include <sbuild/sbuild-session.h>
23#include <sbuild/sbuild-types.h>
24
25#include <schroot-base/schroot-base-options.h>
26
27#include <string>
28
29#ifdef HAVE_TR1_MEMORY
30#include <tr1/memory>
31#elif HAVE_BOOST_SHARED_PTR_HPP
32#include <boost/shared_ptr.hpp>
33namespace std { namespace tr1 { using boost::shared_ptr; } }
34#else
35#error A shared_ptr implementation is not available
36#endif
37
38#include <boost/program_options.hpp>
39
40namespace schroot
41{
42
43  /**
44   * Basic schroot command-line options.  This is specialised by the
45   * frontends to suit their particular command-line options and
46   * behaviour.  This class contains functionality and options common
47   * to all schroot programs (schroot, dchroot, dchroot-dsa).
48   */
49  class options_base : public schroot_base::options
50  {
51  public:
52    /// Begin, run and end a session.
53    static const action_type ACTION_SESSION_AUTO;
54    /// Begin a session.
55    static const action_type ACTION_SESSION_BEGIN;
56    /// Recover an existing session.
57    static const action_type ACTION_SESSION_RECOVER;
58    /// Run an existing session.
59    static const action_type ACTION_SESSION_RUN;
60    /// End an existing session.
61    static const action_type ACTION_SESSION_END;
62    /// Display a list of chroots.
63    static const action_type ACTION_LIST;
64    /// Display chroot information.
65    static const action_type ACTION_INFO;
66    /// Display chroot location information.
67    static const action_type ACTION_LOCATION;
68    /// Display chroot configuration.
69    static const action_type ACTION_CONFIG;
70
71    /// A shared_ptr to an options_base object.
72    typedef std::tr1::shared_ptr<options_base> ptr;
73
74    /// The constructor.
75    options_base ();
76
77    /// The destructor.
78    virtual ~options_base ();
79
80    /// Chroots to use.
81    sbuild::string_list  chroots;
82    /// Chroot to print path.
83    std::string          chroot_path;
84    /// Command to run.
85    sbuild::string_list  command;
86    /// Directory to use.
87    std::string          directory;
88    /// User to run as.
89    std::string          user;
90    /// Preserve environment.
91    bool                 preserve;
92    /// Use all chroots and sessions.
93    bool                 all;
94    /// Use all chroots.
95    bool                 all_chroots;
96    /// Use all sessions.
97    bool                 all_sessions;
98    /// Load chroots.
99    bool                 load_chroots;
100    /// Load sessions.
101    bool                 load_sessions;
102    /// Session name.
103    std::string          session_name;
104    /// Force session operations.
105    bool                 session_force;
106
107  protected:
108    /**
109     * Check if any of the --all options have been used.
110     *
111     * @returns true if any of the options have been used, otherwise
112     * false.
113     */
114    bool
115    all_used () const
116    {
117      return (this->all || this->all_chroots || this->all_sessions);
118    }
119
120    virtual void
121    add_options ();
122
123    virtual void
124    add_option_groups ();
125
126    virtual void
127    check_options ();
128
129    virtual void
130    check_actions ();
131
132    /// Chroot options group.
133    boost::program_options::options_description chroot;
134    /// Chroot environment options group.
135    boost::program_options::options_description chrootenv;
136    /// Session actions group.
137    boost::program_options::options_description session_actions;
138    /// Session options group.
139    boost::program_options::options_description session_options;
140  };
141
142}
143
144#endif /* SCHROOT_OPTIONS_BASE_H */
145
146/*
147 * Local Variables:
148 * mode:C++
149 * End:
150 */
151
Note: See TracBrowser for help on using the repository browser.