Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

PostOffice Class Reference

#include <PostOffice.h>

List of all members.

Public Slots

string connectTo (const string &host, int port, bool block=true)
bool servicePort (int port)
void closePort (int port)
void addAddressToGroup (const POAddress &adr, const POAddress &group)
void removeAddressFromGroup (const POAddress &adr, const POAddress &group)
POBoxregisterPOBox (const string &name)
POGroupregisterGroup (const string &name, bool throw_exception=true)
bool closeGroup (const string &name)
bool closePOBox (const string &name, bool dodelete=false)
void connectClient (POClient *client)
void addConnectedClient (POClient *client)
bool sendMessage (const POMessage *msg, bool throw_exception=true)
void sendMessage (POMessage *msg, const string &from, const POAddress &to)
void newClientPOBox (const string &cname, const string &boxname)

Signals

void newClient (const string &poname, const string &cname)
void newPOBox (const string &poname, const string &cname, const string &boxname)
void newPOBox (const string &poname, const string &boxname)
void clientClosed (const string &poname, const string &cname)
void portClosed (int port)
void portOpened (int port)

Public Member Functions

 PostOffice (const string &name)
 ~PostOffice ()
POClientgetClient (const string &cname) const
POBoxgetPOBox (const string &boxname) const
POGroupgetGroup (const string &name, bool create=true, bool throw_exception=true)
map< string, POClient * > getAllClients () const
map< string, POBox * > getAllBoxes () const
string getName () const
const POMessagepopMessage (const string &pobox_name)
bool hasMessage (const string &pobox_name)

Static Public Member Functions

map< string, PostOffice * > getAllPostOffices ()
PostOfficegetPostOffice (const string &name)


Constructor & Destructor Documentation

PostOffice::PostOffice const string &  name  ) 
 

Constructor

Parameters:
name - the name of the post office

PostOffice::~PostOffice  ) 
 


Member Function Documentation

void PostOffice::addAddressToGroup const POAddress adr,
const POAddress groupadr
[slot]
 

Adds the specified address to the group. This is useful for aggregating groups. Be careful, the group may not be able to send to the specified address.

Parameters:
adr - the address to add to the group
groupadr - the address of the group
Exceptions:
a POErrorMsg if the group address cannot be resolved

void PostOffice::addConnectedClient POClient client  )  [slot]
 

Takes a connected client and adds it to the client list, m_clients

Parameters:
client - the client to add

void PostOffice::clientClosed const string &  poname,
const string &  cname
[signal]
 

bool PostOffice::closeGroup const string &  name  )  [slot]
 

Removes a group

Parameters:
name - the name of the group to close
Returns:
true if the group was closed

bool PostOffice::closePOBox const string &  boxname,
bool  dodelete = false
[slot]
 

Removes the box from the post officeThis should only be called by ~POBox() when you delete it.

Parameters:
boxname - the name of the box to remove
dodelete - true if you want the post office box to be deleted as well
Returns:
true if success, otherwise false

void PostOffice::closePort int  port  )  [slot]
 

Closes the server on a given port

Parameters:
port - the port to close

void PostOffice::connectClient POClient client  )  [slot]
 

This function is called when a POServer gets a new connection. The connection is connected by sending it a list of POBoxes in this post office.

Parameters:
client - the new client

string PostOffice::connectTo const string &  host,
int  port,
bool  block = true
[slot]
 

Creates a new client and attempts to connect to the specified server

Parameters:
host - the hostname/ip of the server
port - the port to use
Returns:
The name of the remote post office

map<string, POBox*> PostOffice::getAllBoxes  )  const [inline]
 

map< string, POClient * > PostOffice::getAllClients  )  const
 

Returns:
Returns a map of all connected clients, this should not be used by non-api developers.

map< string, PostOffice * > PostOffice::getAllPostOffices  )  [static]
 

This function returns a pointer to all post offices running within the current process

Returns:
a map of Post Office Name to PostOffice pointer.

POClient * PostOffice::getClient const string &  cname  )  const
 

POGroup * PostOffice::getGroup const string &  name,
bool  create = true,
bool  throw_exception = true
 

Returns a pointer to the group based on name Throws an error if the group doesn't exist and create == false

Parameters:
name - the name of the group to get
create - true if the group should be created if it doesn't exist
Returns:
a pointer to the group

string PostOffice::getName  )  const [inline]
 

POBox * PostOffice::getPOBox const string &  name  )  const
 

returns a pointer to the specified pobox

Exceptions:
a POErrorMsg* if the POBox doesn't exist
Parameters:
name - the name for the POBox
Returns:
a pointer to the new po box

PostOffice * PostOffice::getPostOffice const string &  name  )  [static]
 

bool PostOffice::hasMessage const string &  box_name  ) 
 

Checks a POBox for messages

Parameters:
box_name - the name of the box to check
Returns:
true if there are messages, otherwise false

void PostOffice::newClient const string &  poname,
const string &  cname
[signal]
 

void PostOffice::newClientPOBox const string &  cname,
const string &  boxname
[slot]
 

void PostOffice::newPOBox const string &  poname,
const string &  boxname
[signal]
 

void PostOffice::newPOBox const string &  poname,
const string &  cname,
const string &  boxname
[signal]
 

const POMessage * PostOffice::popMessage const string &  box_name  ) 
 

This function allows you to pop a message from the specified POBox

Parameters:
box_name - the name of the POBox to pop the message from
Returns:
a pointer to the oldest message in the box, NULL if no message found

void PostOffice::portClosed int  port  )  [signal]
 

void PostOffice::portOpened int  port  )  [signal]
 

POGroup * PostOffice::registerGroup const string &  name,
bool  throw_exception = true
[slot]
 

Creates a new group with the specified name

Exceptions:
POErrorMsg* if the group name is already in use by another POBox
Parameters:
name - the name of the group
Exceptions:
POErrorMsg if the group could not be created and throw_exception is true
Returns:
a pointer to the group, null on error

POBox * PostOffice::registerPOBox const string &  name  )  [slot]
 

Creates a new post office box and updates all connections

Exceptions:
a POErrorMsg* if the name has already been registered
Parameters:
name - the name for the POBox
Returns:
a pointer to the new po box

void PostOffice::removeAddressFromGroup const POAddress adr,
const POAddress groupadr
[slot]
 

Adds the specified address to the group. This is useful for aggregating groups. Be careful, the group may not be able to send to the specified address.

Parameters:
adr - the address to add to the group
groupadr - the address of the group
Exceptions:
a POErrorMsg if the group address cannot be resolved

void PostOffice::sendMessage POMessage msg,
const string &  from,
const POAddress to
[slot]
 

Sends a message to the specified address from the specified pobox in this PostOffice to the specified addres and returns true if the destination exists Throws a POErrorMsg* if the destination can't be found

Parameters:
msg - the message to send
from - the local POBox name
to - the destination address

bool PostOffice::sendMessage const POMessage msg,
bool  throw_exception = true
[slot]
 

Identifies where the message needs to go and sends it. Assumes that the to/from fields have been filled out by the POBox

Parameters:
msg - a pointer to the message
throw_exception - true if you want to throw an exception instead of returning false.
Exceptions:
POErrorMsg if the destination post office cannot be found and and throw_exception is true
Returns:
true on success, false on failure

bool PostOffice::servicePort int  port  )  [slot]
 

Creates a new POServer that listens for connections on the specified port

Parameters:
port - the port to listen on


The documentation for this class was generated from the following files:
Generated on Tue Jun 15 12:49:29 2004 for pexpr by doxygen 1.3.4