MCS  0.3.3-alpha7
mcs::LocalThread Class Reference

Server side administrative thread. More...

#include <mcs.hh>

+ Inheritance diagram for mcs::LocalThread:

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...
 
LocalThreadoperator= (const LocalThread &)
 Declared to avoid using of default assignment operator. More...
 
 ~LocalThread ()
 Destructor. More...
 
- Public Member Functions inherited from mcs::BaseThread
 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...
 
BaseThreadoperator= (const BaseThread &)
 Declared to avoid using of default assignment operator. More...
 
const char * tid ()
 Return the thread identifier. More...
 
 ~BaseThread ()
 Destructor. More...
 
- Public Member Functions inherited from mcs::Thread
Eventerror ()
 Return last error message. More...
 
int id ()
 Returns the Thread object identificator. More...
 
Threadparent ()
 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...
 
- Protected Member Functions inherited from mcs::BaseThread
RetValue Log (Event e)
 Logging facility. More...
 
- Protected Member Functions inherited from mcs::Thread
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
 
- Protected Attributes inherited from mcs::Thread
Eventlerror
 Last error. More...
 

Private Member Functions

virtual void run ()
 Thread body. More...
 

Private Attributes

 MCS_DEBUG_ALLOC
 

Additional Inherited Members

- Static Public Member Functions inherited from mcs::BaseThread
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 Protected Attributes inherited from mcs::BaseThread
static Envenv
 Pointer to the actual Env object, this can be seen in all threaded object. More...
 

Detailed Description

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.

Definition at line 6741 of file mcs.hh.

Constructor & Destructor Documentation

◆ LocalThread() [1/2]

mcs::LocalThread::LocalThread ( const LocalThread )

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.

◆ LocalThread() [2/2]

mcs::LocalThread::LocalThread ( Thread parent)

Constructor.

This method simply pass the parameter to its parent class constructor (BaseThread).

Parameters
parentAddress of the parent Server object;
lIDThread identifier;

Definition at line 28 of file LocalThread.cc.

◆ ~LocalThread()

mcs::LocalThread::~LocalThread ( )

Destructor.

Definition at line 39 of file LocalThread.cc.

Member Function Documentation

◆ dataDispatcher()

void mcs::LocalThread::dataDispatcher ( )
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.

◆ hk_log()

void mcs::LocalThread::hk_log ( UserThread p,
Event  e 
)
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.

Parameters
pAddress of the UserThread object whose logging;
eEvent object describing what has been logged.

Definition at line 110 of file LocalThread.cc.

◆ operator=()

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

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.

◆ run()

void mcs::LocalThread::run ( )
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.

◆ serverClients()

UserThread ** mcs::LocalThread::serverClients ( )
protected

Returns the Server.pClient variable.

Definition at line 120 of file LocalThread.cc.

◆ userID2clientID()

bool mcs::LocalThread::userID2clientID ( int  userid,
int *  cid 
)
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.

Parameters
dData object;
idAddress of an object where the client ID (CID) will be stored.
Returns
True if the method found at least one UserThread object with the required destination ID, false otherwise.

Definition at line 45 of file LocalThread.cc.

Member Data Documentation

◆ recv

Record mcs::LocalThread::recv

Record of Data objects received from other threads.

Definition at line 6843 of file mcs.hh.


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

mcslogo

MCS (My Customizable Server) ver. 0.3.3-alpha7
Documentation generated on Mon May 28 07:39:41 UTC 2018