StApplication Class Reference

StApplication is representation of application with some arguments. More...

#include <stapplication.h>

Inheritance diagram for StApplication:

StThread StScript StScriptFile List of all members.

Public Member Functions

 StApplication ()
 StApplication (const StFile &file, const StDir &dir=StDir(ST_DEFAULT_TEMP))
 StApplication (const StFile &file, const StStringList &args, const StDir &dir=StDir(ST_DEFAULT_TEMP))
bool setExecutable (const StFile &file)
void setWorkDirectory (const StDir &dir)
void setTempDirectory (const StDir &dir)
void setArguments (const StStringList &args)
void setArguments (const StString &arg)
bool execute (bool wait=true, bool outputToFile=true)
StStringList getNormalOutput ()
StStringList getErrorOutput ()
int getReturnCode ()

Protected Member Functions

virtual void run ()

Protected Attributes

StDir tempDir
StDir workDir

Private Member Functions

void init ()
void clear ()
StFile genFileName () const

Private Attributes

StFile executable
StStringList args
volatile int returnCode
volatile bool outputToFile
StStringList normalOutput
StStringList errorOutput

Detailed Description

StApplication is representation of application with some arguments.

Let's think of StApplication like single line in bash shell. This can be for example "ls" and for this task we use setExecutable(). We can attach to it some arguments like "ls -alh" by setArguments(). When we execute() application like that, it will generate output and error output accessable by getNormalOutput() and getErrorOutput() and it will also return exit code in getReturnCode();

Warning:
Don't forget to setTempDirectory() before execute(). If you forget that, temporary files will be saved directly in /tmp directory which is dangerous for some reasons.


Constructor & Destructor Documentation

StApplication::StApplication (  )  [inline]

StApplication::StApplication ( const StFile file,
const StDir dir = StDir(ST_DEFAULT_TEMP) 
) [inline]

StApplication::StApplication ( const StFile file,
const StStringList args,
const StDir dir = StDir(ST_DEFAULT_TEMP) 
) [inline]


Member Function Documentation

void StApplication::clear (  )  [inline, private]

Reimplemented in StScript.

bool StApplication::execute ( bool  wait = true,
bool  outputToFile = true 
)

Executes application

Parameters:
wait wait for application to close
Returns:
true if execute is done

Reimplemented in StScript, and StScriptFile.

StFile StApplication::genFileName (  )  const [private]

StStringList StApplication::getErrorOutput (  )  [inline]

Returns:
Output from stderr

StStringList StApplication::getNormalOutput (  )  [inline]

Returns:
Output from stdout

int StApplication::getReturnCode (  )  [inline]

Returns:
Application exit code

void StApplication::init (  )  [inline, private]

Reimplemented from StThread.

void StApplication::run (  )  [protected, virtual]

You must implement this function to make StThread work. Inside should be code that will be executed in thread.

Implements StThread.

void StApplication::setArguments ( const StString arg  )  [inline]

Overloaded version of function above.

Reimplemented in StScript, and StScriptFile.

void StApplication::setArguments ( const StStringList args  )  [inline]

With what arguments execute binary.

Reimplemented in StScript, and StScriptFile.

bool StApplication::setExecutable ( const StFile file  ) 

Set where is binary to execute.

Returns:
true if binary is executable.

Reimplemented in StScript, and StScriptFile.

void StApplication::setTempDirectory ( const StDir dir  ) 

Where output files will be stored while executing.

void StApplication::setWorkDirectory ( const StDir dir  )  [inline]

Where program will be execute.


Member Data Documentation

StStringList StApplication::args [private]

Reimplemented in StScript, and StScriptFile.

StStringList StApplication::errorOutput [private]

StFile StApplication::executable [private]

StStringList StApplication::normalOutput [private]

volatile bool StApplication::outputToFile [private]

volatile int StApplication::returnCode [private]

StDir StApplication::tempDir [protected]

StDir StApplication::workDir [protected]


The documentation for this class was generated from the following files:
Generated on Tue Nov 14 21:15:09 2006 for Smart Tools Library by  doxygen 1.4.7