CNamedServerCollection Class Reference

Inheritance diagram for CNamedServerCollection:

Inheritance graph
[legend]
Collaboration diagram for CNamedServerCollection:

Collaboration graph
[legend]

List of all members.


Detailed Description

A class that implements a collection of named instances of IServerControl and that allows you to control all of the instances as one and also manipulate individual instances by name.


Public Member Functions

 CNamedServerCollection ()
 Creates an empty collection.
 ~CNamedServerCollection ()
void AddServer (const JetByteTools::Win32::_tstring &name, IServerControl *pServer)
 Adds an instance of IServerControl to the collection and takes ownership of the instance; it will be deleted when the collection is destroyed.
void AddServer (const JetByteTools::Win32::_tstring &name, IServerControl &server)
 Adds an instance of IServerControl to the collection and does not take ownership of the instance.
IServerControlRemoveServer (const JetByteTools::Win32::_tstring &name)
 Locates an instance of IServerControl by name and removes it from the collection and returns it. If the instance was owned by the collection then it is no longer owned by the collection and the caller now owns the instance. Returns 0 if an instance of the supplied name does not exist.
void RemoveServers ()
 Removes all instances from the collection and destroys those instances that the collection owns.
IServerControlGetServer (const JetByteTools::Win32::_tstring &name)
 Obtains a reference to an instance of IServerControl from the collection by name. If the named instance does not exist then an exception is thrown.
virtual void Start ()
virtual void StartAcceptingConnections ()
virtual void StopAcceptingConnections ()
virtual void InitiateShutdown ()
 Starts the shutdown process and returns immediately.
virtual void WaitForShutdownToComplete ()
 Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed.
virtual bool WaitForShutdownToComplete (const Milliseconds timeout)
 Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole.
virtual void ForceShutdown ()
 If a shutdown is hung due to sockets still being active then you can force a shutdown to complete by calling this function. Note: USE WITH CARE!!! The usual usage pattern is to call WaitForShutdownToComplete() with a timeout and if that fails then to call ForceShutdown() to allow the object in question to be destroyed (in general the object would call WaitForShutdownToComplete() in its destructor and hang there!).
bool WaitForShutdownToComplete (const Milliseconds timeout, INamedServerShutdownCallback &callback, void *pUserData)
 Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole. Note that you are called back for each server that is shutting down via the supplied callback interface.


Constructor & Destructor Documentation

CNamedServerCollection (  ) 

Creates an empty collection.

~CNamedServerCollection (  ) 


Member Function Documentation

void AddServer ( const JetByteTools::Win32::_tstring name,
IServerControl pServer 
)

Adds an instance of IServerControl to the collection and takes ownership of the instance; it will be deleted when the collection is destroyed.

void AddServer ( const JetByteTools::Win32::_tstring name,
IServerControl server 
)

Adds an instance of IServerControl to the collection and does not take ownership of the instance.

IServerControl* RemoveServer ( const JetByteTools::Win32::_tstring name  ) 

Locates an instance of IServerControl by name and removes it from the collection and returns it. If the instance was owned by the collection then it is no longer owned by the collection and the caller now owns the instance. Returns 0 if an instance of the supplied name does not exist.

void RemoveServers (  ) 

Removes all instances from the collection and destroys those instances that the collection owns.

IServerControl& GetServer ( const JetByteTools::Win32::_tstring name  ) 

Obtains a reference to an instance of IServerControl from the collection by name. If the named instance does not exist then an exception is thrown.

void Start (  )  [virtual]

Implements IServerControl.

void StartAcceptingConnections (  )  [virtual]

Implements IServerControl.

void StopAcceptingConnections (  )  [virtual]

Implements IServerControl.

void InitiateShutdown (  )  [virtual]

Starts the shutdown process and returns immediately.

Implements IServerControl.

void WaitForShutdownToComplete (  )  [virtual]

Initiates a shutdown (if one isn't already in progresss) and then waits for it to complete. Does not return until the shutdown has completed.

Implements IServerControl.

bool WaitForShutdownToComplete ( const Milliseconds  timeout  )  [virtual]

Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole.

Implements IServerControl.

void ForceShutdown (  )  [virtual]

If a shutdown is hung due to sockets still being active then you can force a shutdown to complete by calling this function. Note: USE WITH CARE!!! The usual usage pattern is to call WaitForShutdownToComplete() with a timeout and if that fails then to call ForceShutdown() to allow the object in question to be destroyed (in general the object would call WaitForShutdownToComplete() in its destructor and hang there!).

Implements IServerControl.

bool WaitForShutdownToComplete ( const Milliseconds  timeout,
INamedServerShutdownCallback callback,
void *  pUserData 
)

Initiates a shutdown (if one isn't already in progresss) and then waits for the supplied number of milliseconds for it to complete. Returns true if the shutdown completed successfully before the timeout expired and false if it didn't. Note that EACH server in the collection is given the timeout to shutdown. The timeout does NOT apply to the collection as a whole. Note that you are called back for each server that is shutting down via the supplied callback interface.


Generated on Mon Sep 7 14:09:38 2009 for JetByte Socket Tools - v6.1 by  doxygen 1.5.3