History Class Reference
[Connector implementation classes and data]

A Connector that simulates a connection to an in-memory buffer of recent lines of data. More...

#include <history.h>

Inheritance diagram for History:

Inheritance graph
[legend]
Collaboration diagram for History:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 History (const int size)
 Constructor for a History object.
virtual ~History ()
std::string get_id (void) const
 Identification routine.
Dataread ()
 Add the "owning" object, which is to be notified of disconnections.
ssize_t write (const Data &)
 Write a blob of data to the underlying connection.
virtual bool connected (void) const
 Indicate that we're connected.

Private Member Functions

void connect (void)
void disconnect (void)
 Clear the CircBuffer, and return.

Private Attributes

CircBuffer< std::string > lines
 A CircBuffer of strings that are the most recent CircBuffer::circ_size lines.
pthread_mutex_t buf_mutex
 to protect the lines
bool start_a_new_line
 This bool tracks whether new data should be placed in the next line.


Detailed Description

A Connector that simulates a connection to an in-memory buffer of recent lines of data.

It also needs to handle messages asking for some [or all] of its contents, which it always has in-memory in a circular buffer.

Todo:
Implement the request/response for History.

Definition at line 97 of file history.h.


Constructor & Destructor Documentation

History::History ( const int  size  ) 

Constructor for a History object.

Parameters:
size Lines of history that should be kept. (given to CircBuffer)

Definition at line 48 of file history.cc.

References buf_mutex, and Guard::initialize_mutex().

Here is the call graph for this function:

History::~History (  )  [virtual]

Definition at line 55 of file history.cc.

References buf_mutex, Guard::destroy_mutex(), and disconnect().

Here is the call graph for this function:


Member Function Documentation

std::string History::get_id ( void   )  const [virtual]

Identification routine.

Implements Connector.

Definition at line 71 of file history.cc.

References lines, and CircBuffer< _Tp >::max_size().

Referenced by write().

Here is the call graph for this function:

Here is the caller graph for this function:

Data * History::read (  )  [virtual]

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

Implements Connector.

Definition at line 81 of file history.cc.

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

Write a blob of data to the underlying connection.

Implements Connector.

Definition at line 87 of file history.cc.

References buf_mutex, Data::data(), get_id(), Data::len(), lines, PTHREAD_CHECK_AND_THROW, CircBuffer< _Tp >::push_back(), and start_a_new_line.

Here is the call graph for this function:

virtual bool History::connected ( void   )  const [inline, virtual]

Indicate that we're connected.

The CircBuffer is set up in our constructor, so we're always connected to it.

Implements Connector.

Definition at line 113 of file history.h.

void History::connect ( void   )  [inline, private]

No-op since we don't have anything to establish/connect.

Note:
History::connect() could load lines from LogFile.

Definition at line 119 of file history.h.

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

Clear the CircBuffer, and return.

This function doesn't really disconnect anything, but go ahead and empty out the CircBuffer just to free up the memory.

Implements Connector.

Definition at line 173 of file history.cc.

References buf_mutex, and lines.

Referenced by ~History().

Here is the caller graph for this function:


Member Data Documentation

CircBuffer<std::string> History::lines [private]

A CircBuffer of strings that are the most recent CircBuffer::circ_size lines.

Definition at line 125 of file history.h.

Referenced by disconnect(), get_id(), and write().

pthread_mutex_t History::buf_mutex [private]

to protect the lines

Definition at line 126 of file history.h.

Referenced by disconnect(), History(), write(), and ~History().

bool History::start_a_new_line [private]

This bool tracks whether new data should be placed in the next line.

Definition at line 129 of file history.h.

Referenced by write().


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

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