Public Member Functions | Public Attributes | Private Attributes
CommandShell Class Reference

Utility class which defines convenience operators for spawning processes with system calls. More...

List of all members.

Public Member Functions

 CommandShell ()
 constructor
 ~CommandShell ()
 destructor
CommandShelloperator<< (const char *cmd)
 appends cmd to sysCommand
CommandShelloperator<< (const std::string &cmd)
 convenient operator: appends string to the commandString to be executed
CommandShelloperator<< (CommandShell &(*f)(CommandShell &))
 allows passing of the flush function to the shell using <<
CommandShellflush ()
 "flushes" the shell; i.e. executes the sysCommand
void asynch_flag (const bool flag)
 set the asynchFlag
bool asynch_flag () const
 get the asynchFlag
void suppress_output_flag (const bool flag)
 set the suppressOutputFlag
bool suppress_output_flag () const
 get the suppressOutputFlag

Public Attributes

const char * workDir
 To convey working directory when useWorkdir is true:

Private Attributes

std::string sysCommand
 The command string that is constructed through one or more << insertions and then executed by flush.
bool asynchFlag
 flags nonblocking operation (background system calls)
bool suppressOutputFlag
 flags suppression of shell output (no command echo)

Detailed Description

Utility class which defines convenience operators for spawning processes with system calls.

The CommandShell class wraps the C system() utility and defines convenience operators for building a command string and then passing it to the shell.


Member Function Documentation

CommandShell & operator<< ( const char *  cmd) [inline]

appends cmd to sysCommand

convenient operator: appends string to the commandString to be executed

References CommandShell::sysCommand.

CommandShell & operator<< ( CommandShell &(*)(CommandShell &)  f) [inline]

allows passing of the flush function to the shell using <<

convenience operator: allows passing of the flush func to the shell via <<

CommandShell & flush ( )

"flushes" the shell; i.e. executes the sysCommand

Executes the sysCommand by passing it to system(). Appends an "&" if asynchFlag is set (background system call) and echos the sysCommand to Cout if suppressOutputFlag is not set.

References Dakota::abort_handler(), CommandShell::asynchFlag, CommandShell::suppressOutputFlag, CommandShell::sysCommand, and CommandShell::workDir.

Referenced by Dakota::flush().


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