TTYConnector Class Reference
[Connector implementation classes and data]

A connection to a TTY. More...

#include <ttyconn.h>

Inheritance diagram for TTYConnector:

Inheritance graph
[legend]
Collaboration diagram for TTYConnector:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TTYConnector (const std::string &)
 TTYConnector (const int, const int)
virtual ~TTYConnector () throw ()
virtual Dataread ()
 Add the "owning" object, which is to be notified of disconnections.
virtual ssize_t write (const Data &b)
 Write a blob of data to the underlying connection.
string get_id (void) const
 Instance identification string (abstract virtual).
virtual bool connected (void) const
 Are we connected?

Protected Member Functions

void setup_fds (int, int)
void open_device (string)

Protected Attributes

int read_fd
 The fd we read from.
int write_fd
 The fd we write to.
pthread_mutex_t mutex
 Protect changes to the fd's.

Private Member Functions

void connect (void)
 Connect to a TTY (for reading and writing...).
void disconnect (void)
 Disconnect from the TTY we're connected to.

Private Attributes

struct termios * saved_state
 When putting a TTY into raw mode, save the state to be restored here.


Detailed Description

A connection to a TTY.

This TTY could be a serial device, or a UNIX TTY. Should that be divided somehow into two classes? Perhaps a FileConnector could handle some aspects of serial devices, since they'll appear as device files under /dev.

Definition at line 56 of file ttyconn.h.


Constructor & Destructor Documentation

TTYConnector::TTYConnector ( const std::string &  dev  ) 

Definition at line 50 of file ttyconn.cc.

References connect(), mutex, open_device(), and PTHREAD_CHECK_AND_THROW.

Here is the call graph for this function:

TTYConnector::TTYConnector ( const   int,
const   int 
)

Definition at line 61 of file ttyconn.cc.

References connect(), mutex, PTHREAD_CHECK_AND_THROW, and setup_fds().

Here is the call graph for this function:

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

Definition at line 72 of file ttyconn.cc.

References CATCH_OR_DIE, disconnect(), and mutex.

Here is the call graph for this function:


Member Function Documentation

Data * TTYConnector::read (  )  [virtual]

Add the "owning" object, which is to be notified of disconnections.

Implements Connector.

Definition at line 245 of file ttyconn.cc.

References Connector::BufSize, and read_fd.

ssize_t TTYConnector::write ( const Data b  )  [virtual]

Write a blob of data to the underlying connection.

Implements Connector.

Definition at line 261 of file ttyconn.cc.

References Data::data(), Data::len(), and write_fd.

Here is the call graph for this function:

void TTYConnector::setup_fds ( int  r,
int  w 
) [protected]

Definition at line 115 of file ttyconn.cc.

References mutex, read_fd, saved_state, and write_fd.

Referenced by TTYConnector().

Here is the caller graph for this function:

void TTYConnector::open_device ( string  dev_fn  )  [protected]

Definition at line 152 of file ttyconn.cc.

References mutex, read_fd, and write_fd.

Referenced by TTYConnector().

Here is the caller graph for this function:

string TTYConnector::get_id ( void   )  const [virtual]

Instance identification string (abstract virtual).

Implements Connector.

Definition at line 218 of file ttyconn.cc.

References read_fd, and write_fd.

bool TTYConnector::connected ( void   )  const [virtual]

Are we connected?

Return an indication of whether or not we're connected.

At the moment, we require both input and output fd's to be >= 0.

Implements Connector.

Definition at line 232 of file ttyconn.cc.

References mutex, read_fd, and write_fd.

void TTYConnector::connect ( void   )  [private]

Connect to a TTY (for reading and writing...).

Definition at line 174 of file ttyconn.cc.

References mutex, read_fd, and write_fd.

Referenced by TTYConnector().

Here is the caller graph for this function:

void TTYConnector::disconnect ( void   )  [private, virtual]

Disconnect from the TTY we're connected to.

Disconnect us from the TTYs, optionally restoring saved TTY state to the input fd.

Implements Connector.

Definition at line 198 of file ttyconn.cc.

References read_fd, saved_state, and write_fd.

Referenced by ~TTYConnector().

Here is the caller graph for this function:


Member Data Documentation

struct termios* TTYConnector::saved_state [read, private]

When putting a TTY into raw mode, save the state to be restored here.

Definition at line 98 of file ttyconn.h.

Referenced by disconnect(), and setup_fds().

int TTYConnector::read_fd [protected]

The fd we read from.

..

Definition at line 101 of file ttyconn.h.

Referenced by connect(), connected(), disconnect(), get_id(), open_device(), read(), and setup_fds().

int TTYConnector::write_fd [protected]

The fd we write to.

..

Definition at line 102 of file ttyconn.h.

Referenced by connect(), connected(), disconnect(), get_id(), open_device(), setup_fds(), and write().

pthread_mutex_t TTYConnector::mutex [protected]

Protect changes to the fd's.

Definition at line 103 of file ttyconn.h.

Referenced by connect(), connected(), open_device(), setup_fds(), TTYConnector(), and ~TTYConnector().


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

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