MCS
0.3.3-alpha7
|
Server side administrative thread. More...
#include <mcs.hh>
Public Member Functions | |
virtual void | hk_log (UserThread *p, Event e) |
Virtual method called each time the BaseThread.Log() method is executed. More... | |
LocalThread (const LocalThread &) | |
Declared to avoid using of default copy constructor. More... | |
LocalThread (Thread *parent) | |
Constructor. More... | |
LocalThread & | operator= (const LocalThread &) |
Declared to avoid using of default assignment operator. More... | |
~LocalThread () | |
Destructor. More... | |
![]() | |
BaseThread (const BaseThread &) | |
Declared to avoid using of default copy constructor. More... | |
BaseThread (Thread *parent, int lID) | |
Constructor invoked from ClienThread objects. More... | |
BaseThread (Thread *parent, const char *ltID) | |
Constructor invoked from other objects. More... | |
int | chkExt (string &s) |
Check if an external program or script is registered in the configuration file. More... | |
BaseThread & | operator= (const BaseThread &) |
Declared to avoid using of default assignment operator. More... | |
const char * | tid () |
Return the thread identifier. More... | |
~BaseThread () | |
Destructor. More... | |
![]() | |
Event * | error () |
Return last error message. More... | |
int | id () |
Returns the Thread object identificator. More... | |
Thread * | parent () |
Returns the address of the parent. More... | |
void | start () |
Start a new thread in the joinable state. More... | |
void | startDetached (bool selfDelete=false) |
Start a new thread in the detached state. More... | |
int | state () |
Return the state of the thread. More... | |
void | stop () |
Stop thread execution. More... | |
Thread (int id=0, Thread *parent=NULL) | |
Declared to avoid using of default copy constructor. More... | |
virtual | ~Thread () |
Destructor. More... | |
Public Attributes | |
Record | recv |
Record of Data objects received from other threads. More... | |
Protected Member Functions | |
void | dataDispatcher () |
Dispatch Data objects in the "send" vector to UserThread object's "send" vectors. More... | |
UserThread ** | serverClients () |
Returns the Server.pClient variable. More... | |
bool | userID2clientID (int userid, int *cid) |
Search for a client ID (CID) associated with a destination ID. More... | |
![]() | |
RetValue | Log (Event e) |
Logging facility. More... | |
![]() | |
virtual void | final () |
Finalization method. More... | |
virtual void | initial () |
Initialization method. More... | |
virtual void | notify (int id, Thread *ref) |
A method called from child threads to notify their termination. More... | |
void | set_cancel_state (bool cancel) |
Set cancellation state for current thread. More... | |
void | test_cancel () |
Test if a cancellation request is pending. More... | |
Protected Attributes | |
UserThread ** | client |
![]() | |
Event * | lerror |
Last error. More... | |
Private Member Functions | |
virtual void | run () |
Thread body. More... | |
Private Attributes | |
MCS_DEBUG_ALLOC | |
Additional Inherited Members | |
![]() | |
static int | fileType (string fn) |
Determine the file type of an external program or script. More... | |
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. More... | |
![]() | |
static Env * | env |
Pointer to the actual Env object, this can be seen in all threaded object. More... | |
Server side administrative thread.
An object of this class will be automatically istantiated from the Server object. If this class is not derived its run() method (running in its own thread) will forward any Data object in the "send" Record to the corresponding UserThread object. You can also derive this class to do all the necessary "local" (which means server-side work such as database insertion or mainteinance, software updates, or everything is necessary to your information service.
This class can also be used to monitor clients activities using the hk_log() method, which is a virtual method called each time the BaseThread.Log() is executed. Since all clients activities are logged you can overload this method to perform monitoring.
mcs::LocalThread::LocalThread | ( | const LocalThread & | ) |
Declared to avoid using of default copy constructor.
mcs::LocalThread::LocalThread | ( | Thread * | parent | ) |
Constructor.
This method simply pass the parameter to its parent class constructor (BaseThread).
Definition at line 28 of file LocalThread.cc.
mcs::LocalThread::~LocalThread | ( | ) |
Destructor.
Definition at line 39 of file LocalThread.cc.
|
protected |
Dispatch Data objects in the "send" vector to UserThread object's "send" vectors.
This method will extract objects from the "send" vector and put them in the "send" vector of the corresponding UserThread object (see mcsid() method).
Definition at line 65 of file LocalThread.cc.
|
virtual |
Virtual method called each time the BaseThread.Log() method is executed.
This method calls the cb_log() and cbwa_log() callback functions if defined. If you overload this method the callback functions won't be called anymore.
This method can be overloaded to monitor client activities, since each command and server reply are logged.
p | Address of the UserThread object whose logging; |
e | Event object describing what has been logged. |
Definition at line 110 of file LocalThread.cc.
LocalThread& mcs::LocalThread::operator= | ( | const LocalThread & | ) |
Declared to avoid using of default assignment operator.
|
privatevirtual |
Thread body.
This method can be overloadd to customize the "local" behaviour of the server. In this class then run() method wait until there are some Data object in the "send" vector. When an object appear it will call the dataDispatcher() method.
Reimplemented from mcs::Thread.
Definition at line 90 of file LocalThread.cc.
|
protected |
Returns the Server.pClient variable.
Definition at line 120 of file LocalThread.cc.
|
protected |
Search for a client ID (CID) associated with a destination ID.
Client ID (CID) are the positions in the Server.pClient array that holds the address of UserThread objects associated with the client. Each Data object has a destination ID (Data.getDest() method) and each UserThread object has a destination ID (UserThread.getDestinationId() method). This method search the client ID (CID) associated with the UserThread object whose destination ID is equal to the destination ID of the Data object passed as parameter.
d | Data object; |
id | Address of an object where the client ID (CID) will be stored. |
Definition at line 45 of file LocalThread.cc.
Record mcs::LocalThread::recv |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha7
|