mcs::LocalThread Class Reference

#include <mcs.hh>

Inheritance diagram for mcs::LocalThread:

Inheritance graph
[legend]

List of all members.


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 6758 of file mcs.hh.


Public Member Functions

virtual void hk_log (UserThread *p, Event e)
 Virtual method called each time the BaseThread.Log() method is executed.
 LocalThread (Thread *parent)
 Constructor.
 LocalThread (const LocalThread &)
 Declared to avoid using of default copy constructor.
LocalThreadoperator= (const LocalThread &)
 Declared to avoid using of default assignment operator.
 ~LocalThread ()
 Destructor.

Public Attributes

Record recv
 Record of Data objects received from other threads.

Protected Member Functions

void dataDispatcher ()
 Dispatch Data objects in the "send" vector to UserThread object's "send" vectors.
UserThread ** serverClients ()
 Returns the Server.pClient variable.
bool userID2clientID (int userid, int *cid)
 Search for a client ID (CID) associated with a destination ID.

Protected Attributes

UserThread ** client

Private Member Functions

virtual void run ()
 Thread body.

Private Attributes

 MCS_DEBUG_ALLOC

Constructor & Destructor Documentation

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.

mcs::LocalThread::LocalThread ( Thread parent  ) 

Constructor.

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

Parameters:
parent Address of the parent Server object;
lID Thread identifier;

Definition at line 28 of file LocalThread.cc.

mcs::LocalThread::~LocalThread (  ) 

Destructor.

Definition at line 39 of file LocalThread.cc.


Member Function Documentation

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.

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 overloadd to monitor client activities, since each command and server reply are logged.

Parameters:
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.

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

void mcs::LocalThread::run (  )  [private, virtual]

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.

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

Returns the Server.pClient variable.

Definition at line 120 of file LocalThread.cc.

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:
d Data object;
id Address 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

Record mcs::LocalThread::recv

Record of Data objects received from other threads.

Definition at line 6860 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