schroot::main_base Class Reference

Frontend base for schroot programs. More...

#include <schroot-main-base.h>

Inheritance diagram for schroot::main_base:

Inheritance graph
[legend]
Collaboration diagram for schroot::main_base:

Collaboration graph
[legend]
List of all members.

Public Types

enum  error_code {
  CHROOTS_NOTFOUND, CHROOT_FILE, CHROOT_FILE2, CHROOT_NOTDEFINED,
  CHROOT_NOTFOUND
}
 Error codes. More...
typedef sbuild::custom_error<
error_code
error
 Exception type.

Public Member Functions

 main_base (std::string const &program_name, std::string const &program_usage, options_base::ptr &options, bool use_syslog)
 The constructor.
virtual ~main_base ()
 The destructor.
virtual void action_list ()=0
 List chroots.
virtual void action_info ()
 Print detailed information about chroots.
virtual void action_location ()
 Print location of chroots.
virtual void action_config ()=0
 Dump configuration file for chroots.

Protected Member Functions

virtual int run_impl ()
 Run the program.
virtual sbuild::string_list get_chroot_options ()
 Get a list of chroots based on the specified options (--all, --chroot).
virtual void compat_check ()
 Check compatibility.
virtual void load_config ()
 Load configuration.
virtual void create_session (sbuild::session::operation sess_op)=0
 Create a session.

Protected Attributes

options_base::ptr options
 The program options.
sbuild::chroot_config::ptr config
 The chroot configuration.
sbuild::string_list chroots
 The chroots to use.
sbuild::session::ptr session
 The session.

Detailed Description

Frontend base for schroot programs.

This class is used to "run" schroot programs. This class contains functionality common to all schroot programs (schroot, dchroot, dchroot-dsa).

Definition at line 36 of file schroot-main-base.h.


Member Typedef Documentation

typedef sbuild::custom_error<error_code> schroot::main_base::error

Exception type.

Definition at line 50 of file schroot-main-base.h.


Member Enumeration Documentation

enum schroot::main_base::error_code

Error codes.

Enumerator:
CHROOTS_NOTFOUND  Chroots not found.
CHROOT_FILE  No chroots are defined in ....
CHROOT_FILE2  No chroots are defined in ... or ....
CHROOT_NOTDEFINED  The specified chroots are not defined.
CHROOT_NOTFOUND  Chroot not found.

Definition at line 40 of file schroot-main-base.h.


Constructor & Destructor Documentation

main_base::main_base ( std::string const &  program_name,
std::string const &  program_usage,
options_base::ptr options,
bool  use_syslog 
)

The constructor.

Parameters:
program_name the program name.
program_usage the program usage message.
options the command-line options to use.
use_syslog whether to open a connection to the system logger.

Definition at line 75 of file schroot-main-base.cc.

main_base::~main_base (  )  [virtual]

The destructor.

Reimplemented in dchroot::main_base.

Definition at line 86 of file schroot-main-base.cc.


Member Function Documentation

virtual void schroot::main_base::action_list (  )  [pure virtual]

List chroots.

Implemented in schroot::main, and dchroot::main_base.

Referenced by run_impl().

Here is the caller graph for this function:

void main_base::action_info (  )  [virtual]

Print detailed information about chroots.

Definition at line 91 of file schroot-main-base.cc.

References config.

Referenced by run_impl().

Here is the caller graph for this function:

void main_base::action_location (  )  [virtual]

Print location of chroots.

Reimplemented in dchroot::main.

Definition at line 97 of file schroot-main-base.cc.

References config.

Referenced by run_impl().

Here is the caller graph for this function:

virtual void schroot::main_base::action_config (  )  [pure virtual]

Dump configuration file for chroots.

Implemented in schroot::main, and dchroot::main_base.

Referenced by run_impl().

Here is the caller graph for this function:

int main_base::run_impl (  )  [protected, virtual]

Run the program.

This is the program-specific run method which must be implemented in a derived class.

Returns:
0 on success, 1 on failure or the exit status of the chroot command.

Implements schroot_base::main.

Definition at line 173 of file schroot-main-base.cc.

References action_config(), schroot::options_base::ACTION_CONFIG, schroot_base::main::action_help(), schroot_base::options::ACTION_HELP, action_info(), schroot::options_base::ACTION_INFO, action_list(), schroot::options_base::ACTION_LIST, action_location(), schroot::options_base::ACTION_LOCATION, schroot::options_base::ACTION_SESSION_BEGIN, schroot::options_base::ACTION_SESSION_END, schroot::options_base::ACTION_SESSION_RECOVER, schroot::options_base::ACTION_SESSION_RUN, schroot_base::main::action_version(), schroot_base::options::ACTION_VERSION, CHROOT_FILE, CHROOT_FILE2, CHROOT_NOTDEFINED, chroots, compat_check(), create_session(), get_chroot_options(), load_config(), sbuild::log_exception_error(), log_exception_warning(), sbuild::session::OPERATION_AUTOMATIC, sbuild::session::OPERATION_BEGIN, sbuild::session::OPERATION_END, sbuild::session::OPERATION_RECOVER, sbuild::session::OPERATION_RUN, session, sbuild::auth::VERBOSITY_NORMAL, sbuild::auth::VERBOSITY_QUIET, and sbuild::auth::VERBOSITY_VERBOSE.

sbuild::string_list main_base::get_chroot_options (  )  [protected, virtual]

Get a list of chroots based on the specified options (--all, --chroot).

Returns:
a list of chroots.

Definition at line 108 of file schroot-main-base.cc.

References CHROOT_NOTFOUND, CHROOTS_NOTFOUND, and config.

Referenced by run_impl().

Here is the caller graph for this function:

void main_base::compat_check (  )  [protected, virtual]

Check compatibility.

Does nothing, but derived classes may use it as they see fit.

Reimplemented in dchroot::main_base.

Definition at line 103 of file schroot-main-base.cc.

Referenced by run_impl().

Here is the caller graph for this function:

void main_base::load_config (  )  [protected, virtual]

Load configuration.

Reimplemented in dchroot::main, and dchroot_dsa::main.

Definition at line 159 of file schroot-main-base.cc.

References config.

Referenced by dchroot::main::load_config(), dchroot_dsa::main::load_config(), and run_impl().

Here is the caller graph for this function:

virtual void schroot::main_base::create_session ( sbuild::session::operation  sess_op  )  [protected, pure virtual]

Create a session.

This sets the session member.

Parameters:
sess_op the session operation to perform.

Implemented in schroot::main, dchroot::main, and dchroot_dsa::main.

Referenced by run_impl().

Here is the caller graph for this function:


Member Data Documentation

options_base::ptr schroot::main_base::options [protected]

The program options.

Definition at line 135 of file schroot-main-base.h.

sbuild::chroot_config::ptr schroot::main_base::config [protected]

The chroot configuration.

Definition at line 137 of file schroot-main-base.h.

Referenced by schroot::main::action_config(), dchroot::main_base::action_config(), action_info(), schroot::main::action_list(), dchroot::main_base::action_list(), action_location(), dchroot::main::action_location(), get_chroot_options(), load_config(), dchroot::main::load_config(), and dchroot_dsa::main::load_config().

sbuild::string_list schroot::main_base::chroots [protected]

The chroots to use.

Definition at line 139 of file schroot-main-base.h.

Referenced by run_impl().

sbuild::session::ptr schroot::main_base::session [protected]

The session.

Definition at line 141 of file schroot-main-base.h.

Referenced by schroot::main::create_session(), and run_impl().


The documentation for this class was generated from the following files:
Generated on Sun Jul 8 21:24:29 2007 for schroot by  doxygen 1.5.2