Connection Class Reference
[Connection implementation classes and data]

The top-level class for any type of connection. More...

#include <connection.h>

Inheritance diagram for Connection:

Inheritance graph
[legend]
Collaboration diagram for Connection:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Connection (ConnectorP &)
 Constructor/destructor.
virtual ~Connection () throw ()
void shutdown (void)
 Close down a connection.
virtual std::string class_name (void) const
 Sub-class identification strings (abstract virtual).
virtual std::string get_id (void) const =0

Protected Member Functions

virtual void start_engine (void)=0
virtual void stop_engine (void)=0
 Close down the processing engine, if one is running.
void note_disconnect (void)
 Note (to the MasterController) that we've disconnected.

Protected Attributes

ConnectorP base
 The underlying Connector.
bool please_exit

Private Member Functions

void manager (void)
 Connection manager.

Static Private Member Functions

static void * manager_thread (void *)
 Wrapper function for the manager() method.

Private Attributes

pthread_mutex_t mutex
 Locks the data members of Connection, principally base and conn_state.
pthread_t tid_manager
 The thread-id of the manager() thread.


Detailed Description

The top-level class for any type of connection.

This is not much more than an interface, really, but provides the basic functionality, and some code exists to manage connections on a level where we don't need to know the details of their implementation.

Todo:
Should Connection have initiate_connection() and/or shutdown() methods? Currently the thinking is "No", but it may need them if we move to a design other than "connected at construction" and "disconnect [only] at destruction".

Definition at line 89 of file connection.h.


Constructor & Destructor Documentation

Connection::Connection ( ConnectorP c  ) 

Constructor/destructor.

Definition at line 52 of file connection.cc.

References manager_thread(), mutex, PTHREAD_CHECK_AND_THROW, and tid_manager.

Here is the call graph for this function:

Connection::~Connection ( void   )  throw () [virtual]

Definition at line 72 of file connection.cc.

References mutex.


Member Function Documentation

void * Connection::manager_thread ( void *  instance  )  [static, private]

Wrapper function for the manager() method.

These wrapper function(s) exist so that class methods may be invoked as new threads via pthread_create(). These need to be static methods, to therefore have "C" name-bindings.

manager_thread() is private because it's [currently] only expected to be called by Connection::Connection.

Definition at line 96 of file connection.cc.

References manager().

Referenced by Connection().

Here is the call graph for this function:

Here is the caller graph for this function:

void Connection::manager ( void   )  [private]

Connection manager.

Manages an established connection. It is responsible for starting threads to manage reading and writing, and expected to continue to run as a thread waiting for messages (and state-changes ?).

Definition at line 110 of file connection.cc.

References base, CATCH_STR_OR_DIE, class_name(), get_id(), Messageable::get_message(), Messageable::handle_message(), mutex, MUTEX_LOG, note_disconnect(), please_exit, PTHREAD_CHECK_AND_THROW, shutdown(), start_engine(), stop_engine(), and CMException::what().

Referenced by manager_thread().

Here is the call graph for this function:

Here is the caller graph for this function:

void Connection::shutdown ( void   ) 

Close down a connection.

Shutdown an existing (possibly established) connection.

This calls virtual methods which will know the details for shutting down each type of connection.

Definition at line 389 of file connection.cc.

References Message::C_None, CATCH_OR_DIE, get_id(), please_exit, Messageable::queue_message(), and stop_engine().

Referenced by Messageable::handle_message(), and manager().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void Connection::start_engine ( void   )  [protected, pure virtual]

Start a thread, if needed for the specific sub-class, that will act as the processing engine for this connection.

Implemented in BiDirConn, and Outlet.

Referenced by manager().

Here is the caller graph for this function:

virtual void Connection::stop_engine ( void   )  [protected, pure virtual]

Close down the processing engine, if one is running.

Implemented in BiDirConn, and Outlet.

Referenced by manager(), and shutdown().

Here is the caller graph for this function:

virtual std::string Connection::class_name ( void   )  const [inline, virtual]

Sub-class identification strings (abstract virtual).

Reimplemented in BiDirConn, and Outlet.

Definition at line 160 of file connection.h.

Referenced by manager().

Here is the caller graph for this function:

virtual std::string Connection::get_id ( void   )  const [pure virtual]

Implements Messageable.

Implemented in BiDirConn, and Outlet.

Referenced by manager(), and shutdown().

Here is the caller graph for this function:

void Connection::note_disconnect ( void   )  [protected]

Note (to the MasterController) that we've disconnected.

Note our disconnection to the MasterController.

Set our own state to disconnected (if we're tracking our state), and send a message to the MasterController telling it we're disconnected. It will call our reconnect() method, or shut us down, or any such other thing depending on its desires.

Definition at line 300 of file connection.cc.

References Message::C_Disconnected, MasterController::get_instance(), and Messageable::queue_message().

Referenced by manager(), BiDirConn::reader(), and Outlet::write_data().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

bool Connection::please_exit [protected]

A variable set true by stop_engine and/or shutdown, so that manager() knows to go away.

Note:
XXX - Oh, this is so likely *not* the right way to do things...

Definition at line 175 of file connection.h.

Referenced by manager(), shutdown(), and Outlet::writer().

pthread_mutex_t Connection::mutex [private]

Locks the data members of Connection, principally base and conn_state.

Definition at line 179 of file connection.h.

Referenced by Connection(), manager(), BiDirConn::~BiDirConn(), ~Connection(), and Outlet::~Outlet().

pthread_t Connection::tid_manager [private]

The thread-id of the manager() thread.

Definition at line 188 of file connection.h.

Referenced by Connection().


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

Generated on Tue May 13 11:32:45 2008 for consmgr by  doxygen 1.5.5