mcs::BaseThread Class Reference

#include <mcs.hh>

Inheritance diagram for mcs::BaseThread:

Inheritance graph
[legend]

List of all members.


Detailed Description

Base class for MCS threaded objects.

This is the basic class for all threaded objects inside MCS. It offers a log facility as well as a static access to a Env object.

Definition at line 6112 of file mcs.hh.


Public Member Functions

 BaseThread (Thread *parent, const char *ltID)
 Constructor invoked from other objects.
 BaseThread (Thread *parent, int lID)
 Constructor invoked from ClienThread objects.
 BaseThread (const BaseThread &)
 Declared to avoid using of default copy constructor.
int chkExt (string &s)
 Check if an external program or script is registered in the configuration file.
BaseThreadoperator= (const BaseThread &)
 Declared to avoid using of default assignment operator.
const char * tid ()
 Return the thread identifier.
 ~BaseThread ()
 Destructor.

Static Public Member Functions

static int fileType (string fn)
 Determine the file type of an external program or script.
static int spawn (string fn, string pars, string wpath=".", string thrID="x", string user="x", string pass="x", string dbname="x", string fout="out", string ferr="err")
 Execute an external program or script in a dedicated environment.

Protected Member Functions

RetValue Log (Event e)
 Logging facility.

Static Protected Attributes

static Envenv
 Pointer to the actual Env object, this can be seen in all threaded object.

Private Attributes

 MCS_DEBUG_ALLOC
char tID [4]
 Thread identifier stored as a null terminated string.

Constructor & Destructor Documentation

mcs::BaseThread::BaseThread ( const BaseThread  ) 

Declared to avoid using of default copy constructor.

Warning:
This constructor is declared but not implemented. If you try to use it you will get a compilation error.

mcs::BaseThread::BaseThread ( Thread parent,
int  lID 
)

Constructor invoked from ClienThread objects.

ClienThread objects are identified by a numeric identifier.

Parameters:
parent Parent thread;
lID Numeric identifier.

Definition at line 75 of file BaseThread.cc.

mcs::BaseThread::BaseThread ( Thread parent,
const char *  ltID 
)

Constructor invoked from other objects.

The other objects are identified by a mnemonic string identifier.

Parameters:
parent Parent thread;
ltID String identifier.

Definition at line 81 of file BaseThread.cc.

mcs::BaseThread::~BaseThread (  ) 

Destructor.

Definition at line 87 of file BaseThread.cc.


Member Function Documentation

int mcs::BaseThread::chkExt ( string &  s  ) 

Check if an external program or script is registered in the configuration file.

The name (as registered in the configuration file) must be given as parameter. Upon return the parameter will contain the complete path to the real file.

An exception will be thrown if the external program or script is not registered in the configuration file or if the file type (as returned by ()) is fileType MCS_FT_UNKNOWN.

Returns:
The value returned by fileType().

Definition at line 140 of file BaseThread.cc.

int mcs::BaseThread::fileType ( string  fn  )  [static]

Determine the file type of an external program or script.

This method is used when a user issue a MCS_CMD_EXEC command, to execute an external program or script, to determine the file type. Return value can be one of the following:

Parameters:
fn Path to file.
Returns:
file type.
Exceptions:
ERROR MSG_CANT_OPEN_FILE.

Definition at line 112 of file BaseThread.cc.

RetValue mcs::BaseThread::Log ( Event  e  )  [protected]

Logging facility.

Parameters:
e Event object containing information about an event.
Returns:
The event type (Event.type()).

Definition at line 29 of file BaseThread.cc.

BaseThread& mcs::BaseThread::operator= ( const BaseThread  ) 

Declared to avoid using of default assignment operator.

Warning:
This operator is declared but not implemented. If you try to use it you will get a compilation error.

int mcs::BaseThread::spawn ( string  fn,
string  pars,
string  wpath = ".",
string  thrID = "x",
string  user = "x",
string  pass = "x",
string  dbname = "x",
string  fout = "out",
string  ferr = "err" 
) [static]

Execute an external program or script in a dedicated environment.

This routine will create an environment with the following variables, the content of which can be specified via this method's parameters:

Then the external program or script will be executed in the directory specified in the "wpath" parameter, and its standard output and error will be captured in the files specified in the "fout" and "ferr" parameters.

Scripts will be executed under the "sh" shell. The "wpath", "fout", "ferr" parameters can be either absolute paths or path relative to the current working dir, that is what is returned by mcs::Pwd().

Parameters:
fn Complete path to the program or script;
pars Arguments to the program or script;
wpath Directory where the program or script will be executed, also content of the PWD environment variable;
thrID Content of the MCS_CID environment variable;
user Content of the MCS_USER environment variable;
pass Content of the MCS_PASS environment variable;
dbname Content of the MCS_DBNAME environment variable;
fout Path to the file that will contain the standard output result;
ferr Path to the file that will contain the standard error result;
Returns:
The exit code of the program or script;

Definition at line 159 of file BaseThread.cc.

const char * mcs::BaseThread::tid (  ) 

Return the thread identifier.

Definition at line 90 of file BaseThread.cc.


Member Data Documentation

Env * mcs::BaseThread::env [static, protected]

Pointer to the actual Env object, this can be seen in all threaded object.

Definition at line 6130 of file mcs.hh.

char mcs::BaseThread::tID[4] [private]

Thread identifier stored as a null terminated string.

Definition at line 6117 of file mcs.hh.


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

MCS (My Customizable Server) ver. 0.3.3-alpha3
Documentation generated on Thu Mar 22 13:22:23 UTC 2012