schroot_base::option_action Class Reference

Actions specified as command-line options. More...

#include <schroot-base-option-action.h>

Collaboration diagram for schroot_base::option_action:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::string action_type

Public Member Functions

 option_action ()
 The constructor.
virtual ~option_action ()
 The destructor.
void add (action_type const &action)
 Add an action.
action_type const & get_default ()
void set_default (action_type const &action)
 Set the default action.
action_type const & get ()
void set (action_type const &action)
 Set the action to perform.
bool valid (action_type const &action)
 Check if an action is valid.
option_actionoperator= (action_type const &action)
bool operator== (action_type const &action)
bool operator!= (action_type const &action)

Private Types

typedef std::set< std::string > action_set
 The container of the actions.

Private Attributes

std::string default_action
 Default action.
std::string current_action
 Current action.
action_set actions
 Allowed actions.

Detailed Description

Actions specified as command-line options.

This class contains all allowed options. This replaced the use of enums to allow extension of the options by inheritance.

Todo:
Construct from iterator pair.
Todo:
: Throw logic_error if an invalid action is set.

Definition at line 37 of file schroot-base-option-action.h.


Member Typedef Documentation

typedef std::string schroot_base::option_action::action_type

Definition at line 40 of file schroot-base-option-action.h.

typedef std::set<std::string> schroot_base::option_action::action_set [private]

The container of the actions.

Definition at line 118 of file schroot-base-option-action.h.


Constructor & Destructor Documentation

option_action::option_action (  ) 

The constructor.

Definition at line 37 of file schroot-base-option-action.cc.

option_action::~option_action (  )  [virtual]

The destructor.

Definition at line 44 of file schroot-base-option-action.cc.


Member Function Documentation

void option_action::add ( action_type const &  action  ) 

Add an action.

The specified action is added to the list of permitted actions.

Parameters:
action the action to add.

Definition at line 49 of file schroot-base-option-action.cc.

References actions.

Referenced by schroot_base::options::add_options().

Here is the caller graph for this function:

option_action::action_type const & option_action::get_default (  ) 

Definition at line 55 of file schroot-base-option-action.cc.

References default_action.

void option_action::set_default ( action_type const &  action  ) 

Set the default action.

Parameters:
action the action to set.

Definition at line 61 of file schroot-base-option-action.cc.

References default_action, and valid().

option_action::action_type const & option_action::get (  ) 

Definition at line 70 of file schroot-base-option-action.cc.

References current_action, and default_action.

void option_action::set ( action_type const &  action  ) 

Set the action to perform.

This detects if an action has already been set (only one action may be specified at once).

Parameters:
action the action to set.
Todo:
Throw a custom error, and add a more informative error in main::run.

Definition at line 79 of file schroot-base-option-action.cc.

References current_action, and valid().

bool option_action::valid ( action_type const &  action  ) 

Check if an action is valid.

Parameters:
action the action to check.
Returns:
if action is a valid action, otherwise false.

Definition at line 93 of file schroot-base-option-action.cc.

References actions.

Referenced by set(), and set_default().

Here is the caller graph for this function:

option_action& schroot_base::option_action::operator= ( action_type const &  action  )  [inline]

Definition at line 97 of file schroot-base-option-action.h.

bool schroot_base::option_action::operator== ( action_type const &  action  )  [inline]

Definition at line 103 of file schroot-base-option-action.h.

bool schroot_base::option_action::operator!= ( action_type const &  action  )  [inline]

Definition at line 111 of file schroot-base-option-action.h.


Member Data Documentation

std::string schroot_base::option_action::default_action [private]

Default action.

Definition at line 121 of file schroot-base-option-action.h.

Referenced by get(), get_default(), and set_default().

std::string schroot_base::option_action::current_action [private]

Current action.

Definition at line 124 of file schroot-base-option-action.h.

Referenced by get(), and set().

action_set schroot_base::option_action::actions [private]

Allowed actions.

Definition at line 127 of file schroot-base-option-action.h.

Referenced by add(), and valid().


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