senf::console::Executor Class Reference

Execute config/console commands. More...

#include <senf/Utils/Console/Executor.hh>

List of all members.


Detailed Description

Execute config/console commands.

The Executor interprets parsed config/console commands and executes them. It manages the current execution context (current directory, directory stack and so on).

The executor is normally called directly by the parser callback for each command.

Executing the built-in 'exit' command will throw Executor::ExitException. This exception (which is not derived from std::exception since it's not a real exception) must be handled by the caller.

All directories are managed using weak pointers. If any of the directories expires (current directory, directory stack, last directory) it will be replaced with the root directory. Directories expire when they are destructed or when they are detached from the config tree root node.

Definition at line 57 of file Executor.hh.


Classes

struct   ExitException
  Thrown by built-in 'exit' command. More...
struct   IgnoreCommandException
  Thrown by the SecurityPolicy to silently ignore a command. More...
struct   InvalidCommandException
struct   InvalidDirectoryException
struct   InvalidPathException

Public Types

typedef boost::function< void(DirectoryNode
&, std::string const &)> 
SecurityPolicy
  Executor policy function.
typedef void  result_type

Public Member Functions

void  execute (std::ostream &output, ParseCommandInfo const &command)
  Execute command.
void  operator() (std::ostream &output, ParseCommandInfo const &command)
  Execute command.
GenericNode getNode (ParseCommandInfo const &command)
DirectoryNode cwd () const
  Current working directory.
void  cwd (DirectoryNode &dir)
  Change current directory.
std::string  cwdPath () const
  Return pathname of current directory.
bool  skipping () const
  true, if currently skipping a directory group
bool  autocd () const
  Get current autocd status.
Executor autocd (bool v)
  Set autocd status.
bool  autocomplete () const
  Get current autocomplete status.
Executor autocomplete (bool v)
  Set autocomplete status.
DirectoryNode chroot () const
  Get root node.
Executor chroot (DirectoryNode &node)
  chroot into given directory
Executor policy (SecurityPolicy policy=SecurityPolicy())
  Set security policy.
  Executor ()

Member Typedef Documentation

typedef void senf::console::Executor::
result_type

Definition at line 75 of file Executor.hh.

typedef boost::function<void (DirectoryNode &,std::string const &)> senf::console::Executor::
SecurityPolicy

Executor policy function.

Definition at line 70 of file Executor.hh.


Constructor & Destructor Documentation

senf::console::Executor::
Executor ()

Definition at line 36 of file Executor.cci.


Member Function Documentation

senf::console::Executor & senf::console::Executor::
autocd ( bool  v )

Set autocd status.

See also:
autocd()

Definition at line 64 of file Executor.cci.

bool senf::console::Executor::
autocd ()

Get current autocd status.

if autocd is enabled, specifying a directory name as command will cd to that directory. Disabled by default (but enabled automatically by the interactive console).

Definition at line 58 of file Executor.cci.

senf::console::Executor & senf::console::Executor::
autocomplete ( bool  v )

Set autocomplete status.

See also:
autocomplete()

Definition at line 76 of file Executor.cci.

bool senf::console::Executor::
autocomplete ()

Get current autocomplete status.

if autocomplete is enabled, path components which can be uniquely completed will be completed automatically. Disabled by default (but enabled automatically by the interactive console).

Definition at line 70 of file Executor.cci.

senf::console::Executor & senf::console::Executor::
chroot ( DirectoryNode node )

chroot into given directory

After this call, all path's are interpreted relative to node and only nodes in the tree rooted at node are accessible via the executor. This value defaults to senf::console::root().

Definition at line 88 of file Executor.cci.

senf::console::DirectoryNode & senf::console::Executor::
chroot ()

Get root node.

The root node defaults to senf::console::root(). If changed, all path references are relative to this node and objects outside that tree cannot be accessed.

Definition at line 82 of file Executor.cci.

void senf::console::Executor::
cwd ( DirectoryNode dir )

Change current directory.

Definition at line 49 of file Executor.cci.

senf::console::DirectoryNode & senf::console::Executor::
cwd ()

Current working directory.

Definition at line 58 of file Executor.cc.

std::string senf::console::Executor::
cwdPath ()

Return pathname of current directory.

Definition at line 67 of file Executor.cc.

void senf::console::Executor::
execute ( std::ostream &  output,
ParseCommandInfo const &  command )

Execute command.

Output will be written to output. Same as operator()().

Definition at line 80 of file Executor.cc.

senf::console::GenericNode & senf::console::Executor::
getNode ( ParseCommandInfo const &  command )

Definition at line 172 of file Executor.cc.

void senf::console::Executor::
operator() ( std::ostream &  output,
ParseCommandInfo const &  command )

Execute command.

Output will be written to output. Same as execute().

Definition at line 43 of file Executor.cci.

senf::console::Executor & senf::console::Executor::
policy ( SecurityPolicy  policy = SecurityPolicy() )

Set security policy.

The security policy is called before traversing a node to validate that access.

Definition at line 97 of file Executor.cci.

bool senf::console::Executor::
skipping ()

true, if currently skipping a directory group

Definition at line 103 of file Executor.cci.


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