xorp

RunShellCommand Class Reference

A class for running an external command by invoking a shell. More...

#include <run_command.hh>

Inheritance diagram for RunShellCommand:
RunCommandBase

List of all members.

Public Types

typedef XorpCallback2< void,
RunShellCommand *, const
string & >::RefPtr 
OutputCallback
typedef XorpCallback3< void,
RunShellCommand *, bool, const
string & >::RefPtr 
DoneCallback
typedef XorpCallback2< void,
RunShellCommand *, int >
::RefPtr 
StoppedCallback

Public Member Functions

 RunShellCommand (EventLoop &eventloop, const string &command, const string &argument_string, RunShellCommand::OutputCallback stdout_cb, RunShellCommand::OutputCallback stderr_cb, RunShellCommand::DoneCallback done_cb, int task_priority=XorpTask::PRIORITY_DEFAULT)
 Constructor for a given command and its list with arguments.
void set_stopped_cb (StoppedCallback cb)
 Set the callback to dispatch when the program is stopped.

Private Member Functions

void stdout_cb_dispatch (const string &output)
 A method called when there is output on the program's stdout.
void stderr_cb_dispatch (const string &output)
 A method called when there is output on the program's stderr.
void done_cb_dispatch (bool success, const string &error_msg)
 A method called when the program execution is completed.
void stopped_cb_dispatch (int stop_signal)
 A method called when the program has been stopped.
bool redirect_stderr_to_stdout () const
 Test if the stderr should be redirected to stdout.

Private Attributes

OutputCallback _stdout_cb
OutputCallback _stderr_cb
DoneCallback _done_cb
StoppedCallback _stopped_cb

Detailed Description

A class for running an external command by invoking a shell.


Constructor & Destructor Documentation

RunShellCommand::RunShellCommand ( EventLoop eventloop,
const string &  command,
const string &  argument_string,
RunShellCommand::OutputCallback  stdout_cb,
RunShellCommand::OutputCallback  stderr_cb,
RunShellCommand::DoneCallback  done_cb,
int  task_priority = XorpTask::PRIORITY_DEFAULT 
)

Constructor for a given command and its list with arguments.

Parameters:
eventloopthe event loop.
commandthe command to execute.
argument_stringthe string with the arguments for the command to execute.
stdout_cbthe callback to call when there is data on the standard output.
stderr_cbthe callback to call when there is data on the standard error.
done_cbthe callback to call when the command is completed.
task_prioritythe priority to read stdout and stderr.

Member Function Documentation

void RunShellCommand::done_cb_dispatch ( bool  success,
const string &  error_msg 
) [inline, private, virtual]

A method called when the program execution is completed.

Parameters:
successif true the program execution has succeeded, otherwise it has failed.
error_msgif error, the string with the error message.

Implements RunCommandBase.

bool RunShellCommand::redirect_stderr_to_stdout ( ) const [inline, private, virtual]

Test if the stderr should be redirected to stdout.

Returns:
true if the stderr should be redirected to stdout, otherwise false.

Implements RunCommandBase.

void RunShellCommand::set_stopped_cb ( StoppedCallback  cb) [inline]

Set the callback to dispatch when the program is stopped.

Parameters:
cbthe callback's value.
void RunShellCommand::stderr_cb_dispatch ( const string &  output) [inline, private, virtual]

A method called when there is output on the program's stderr.

Parameters:
outputthe string with the output.

Implements RunCommandBase.

void RunShellCommand::stdout_cb_dispatch ( const string &  output) [inline, private, virtual]

A method called when there is output on the program's stdout.

Parameters:
outputthe string with the output.

Implements RunCommandBase.

void RunShellCommand::stopped_cb_dispatch ( int  stop_signal) [inline, private, virtual]

A method called when the program has been stopped.

Parameters:
stop_signalthe signal used to stop the program.

Implements RunCommandBase.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations