libglass::GlassClient Class Reference

#include <glassclient.h>

Inheritance diagram for libglass::GlassClient:

libglass::Glass libglass::GlassThread

List of all members.

Public Member Functions

 GlassClient (Protocol *p, const char *server) throw (Exception)
 ~GlassClient ()
unsigned int getTotalNodes (void)
std::set< nodeIdgetClientList (void)
bool isMaster (void)
void killAll (void)

Protected Member Functions

void execute (void)
void cleanup (void)
bool sendPacket (Packet &p)
virtual bool rootPacket (Packet &p)
virtual nodeId registerNode (nodeFD fd)

Protected Attributes

string server
boost::condition_variable cond
boost::mutex mut
nodeId serverId


Detailed Description

Definition at line 35 of file glassclient.h.


Constructor & Destructor Documentation

libglass::GlassClient::GlassClient ( Protocol p,
const char *  server 
) throw (Exception)

Constructor.

Parameters:
p The protocol to use.
server The server name or IP.
Exceptions:
Exception. 

libglass::GlassClient::~GlassClient (  ) 


Member Function Documentation

void libglass::GlassClient::cleanup ( void   )  [protected, virtual]

Thread method.

Implements libglass::GlassThread.

void libglass::GlassClient::execute ( void   )  [protected, virtual]

Thread method.

Implements libglass::GlassThread.

std::set<nodeId> libglass::GlassClient::getClientList ( void   ) 

Returns the list of all client nodes.

The returned value is not guaranteed to be valid, as nodes may join or leave at any time.

Bug:
As it is, there may be a racing condition if a packet containing a new list arrives at the precise moment this function is called. A mutex could solve the problem in theory, but it would have to be called after return or require an extra copy to a temporary variable.
Returns:
A set with all valid nodeIds at the moment the call was executed, or an empty list if an error occurred.

unsigned int libglass::GlassClient::getTotalNodes ( void   )  [virtual]

Returns the number CLIENT nodes connected to the network.

This function returns the number CLIENT nodes connected to the network. There's only one server around.

The returned number is not guaranteed to be valid, as nodes may join or leave at any time.

Bug:
As it is, there may be a racing condition if a packet containing a new list arrives at the precise moment this function is called. A mutex could solve the problem in theory, but it would have to be called after return or require an extra copy to a temporary variable.
Returns:
The number of CLIENT nodes connected to the network, or zero if an error occurred.

Reimplemented from libglass::Glass.

bool libglass::GlassClient::isMaster ( void   ) 

Is this node the master?

Bug:
As it is, there may be a racing condition if a packet containing a new list arrives at the precise moment this function is called. A mutex could solve the problem in theory, but it would have to be called after return or require an extra copy to a temporary variable.
Return values:
true if this is the node with lowest id.
false otherwise.

void libglass::GlassClient::killAll ( void   ) 

Close all nodes, including this one.

virtual nodeId libglass::GlassClient::registerNode ( nodeFD  fd  )  [protected, virtual]

Registers a node.

Parameters:
fd A valid node descriptor.
Returns:
A new node Id, or nobodyId if an error occurred.
See also:
unregisterNode().

Implements libglass::Glass.

virtual bool libglass::GlassClient::rootPacket ( Packet p  )  [protected, virtual]

Responsible for processing

Parameters:
p The packet to process.
Return values:
True on success.
False .

Implements libglass::Glass.

bool libglass::GlassClient::sendPacket ( Packet p  )  [protected, virtual]

Forwards the packet to the Protocol, guaranteeing protectedness. It is also responsible for translating the Packet's nodeIds to nodeFDs.

Parameters:
p The packet to send.
Return values:
True on success.
False if packet couldn't be sent for some reason.

Reimplemented from libglass::Glass.


Member Data Documentation

boost::condition_variable libglass::GlassClient::cond [protected]

initialization condition variable

Definition at line 47 of file glassclient.h.

boost::mutex libglass::GlassClient::mut [protected]

initialization mutex

Definition at line 48 of file glassclient.h.

server name

Definition at line 45 of file glassclient.h.

Definition at line 49 of file glassclient.h.


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

Generated on Fri May 28 13:19:01 2010 for libGlass by  doxygen 1.5.8