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.

Member Typedef Documentation

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

The container of the actions.


Constructor & Destructor Documentation

option_action::option_action (  ) 

The constructor.

option_action::~option_action (  )  [virtual]

The destructor.


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.

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 (  ) 

References default_action.

void option_action::set_default ( action_type const &  action  ) 

Set the default action.

Parameters:
action the action to set.

References default_action, and valid().

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

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.

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.

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]

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

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


Member Data Documentation

Default action.

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

Current action.

Referenced by get(), and set().

Allowed actions.

Referenced by add(), and valid().


The documentation for this class was generated from the following files:

Generated on Sat Jul 5 12:01:22 2008 for schroot by  doxygen 1.5.6