NetThread Class Reference
[NetworkingSingle inited classes]

A class for polling network interfaces regularly. More...

#include <netthread.h>

Inheritance diagram for NetThread:

Inheritance graph
[legend]
Collaboration diagram for NetThread:

Collaboration graph
[legend]
List of all members.

Public Member Functions

DECLSPEC NetThread (const char *name, BasicObject *p, bool server=true, bool debug=true)
DECLSPEC NetThread (TiXmlElement *el, BasicObject *p)
virtual const char * getClassName ()
DECLSPEC void connectSocket (NetSocket *s, const IPaddress &ip, BasicObject::Callback c, BasicObject *obj=NULL)
void setServerCheck (bool active)

Static Public Member Functions

static DECLSPEC NetThreadgetThe ()

Static Public Attributes

static NetThreadthe

Protected Member Functions

virtual DECLSPEC int onRun ()
virtual DECLSPEC void onCycle ()
virtual DECLSPEC void onInit ()
virtual DECLSPEC void onDestroy ()

Classes

struct  DATA

Detailed Description

A class for polling network interfaces regularly.

This class handles network-events parallely.
Define "WEB_CLIENT", if this class need/must not poll the WebServer.
Use lock/unlock, when you want another thread/process to access the network.

If NetThread is not created with XML-data then it is automatically started when onInit() is called and stopped with onDestroy()!

This class must not be used in two variables at a time.

See also:
Single inited classes


Constructor & Destructor Documentation

NetThread::NetThread ( const char *  name,
BasicObject p,
bool  server = true,
bool  debug = true 
)

Constructor, if WEB_CLIENT undefined.

Parameters:
server if true, the webserver will be polled regularly if false not (equals WEB_CLIENT defined)
debug if true, a log file is used for debugging, if false nothing will be logged.

NetThread::NetThread ( TiXmlElement el,
BasicObject p 
)

Constructor, for XML data.

Parameters:
el the XML data, if the attribute "StartOnInit" is set true or does not exist, then the thread is started, when onInit() is called and stopped in onDestroy().


Member Function Documentation

virtual const char* NetThread::getClassName (  )  [inline, virtual]

This function should be overriden in every sub-class of BasicObject!

Returns:
the name of the class.

Reimplemented from BasicThread.

void NetThread::connectSocket ( NetSocket s,
const IPaddress &  ip,
BasicObject::Callback  c,
BasicObject obj = NULL 
)

Tries to connect the socket to the given IP address. This function may block the thread for some time.

Parameters:
s the socket to connect
ip the IP address to connect to
c the function to call, when the task was done; NULL, if no function should be called
obj the object, that recieves the function-call

void NetThread::setServerCheck ( bool  active  )  [inline]

(De-)activates checking the webserver for requests.

Parameters:
active must be true to activate the HTTP-server-functionality.

NetThread * NetThread::getThe (  )  [static]

Returns:
a pointer to the NetThread-variable, or NULL if not initialized. (There is only one variable of the type NetThread allowed in an application)
Every netrinjo-class that can only exist once at a time, has this static function.
See also:
Single inited classes

int NetThread::onRun (  )  [protected, virtual]

inherit onRun to have a function, called once (done in the new thread), when the thread is started

Reimplemented from BasicThread.

void NetThread::onCycle (  )  [protected, virtual]

inherit onCycle to get a function, called once per loop-cycle after starting the thread when using onCycle, the cycle-functions return a usable result note that this only happens, if onRun is not inherited or if it is called by a inherited function

Reimplemented from BasicThread.

void NetThread::onInit (  )  [protected, virtual]

Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.

Reimplemented from BasicLog.

void NetThread::onDestroy (  )  [protected, virtual]

May be called to reinitialise this object or stop an initialised module. Calls all children's onDestroy(). Most classes do not use this method. But sometimes it is useful to reset the functionality of an object.

Reimplemented from BasicObject.


Member Data Documentation

NetThread * NetThread::the [static]

only accessible in Linux, and equals the result of getThe()


The documentation for this class was generated from the following files:
Generated on Wed May 9 17:36:32 2007 for netrinjo by  doxygen 1.5.1