FileStatsTarget Class Reference

FileStatsTarget implements the StatsTarget interface by writing to a simple text file. More...

#include <FileStatsTarget.h>

Inheritance diagram for FileStatsTarget:

StatsTarget List of all members.

Public Member Functions

 FileStatsTarget (std::string filename)
 Creates a new FileStatsTarget.
std::string getFilename () const
 Gets name of file receiving stats.
virtual void beginSnapshot ()
 Begins recording a snapshot.
virtual void endSnapshot ()
 Finishes recording a snapshot.
virtual void writeCounter (std::string name, int64_t value)
 Writes one int counter.
virtual void onThreadStart ()
 Receives notification that stats polling is starting via a TimerThread.
virtual void onThreadEnd ()
 Receives notification that stats polling via a TimerThread is ending.

Private Attributes

std::string filename
std::ofstream snapshotStream

Detailed Description

FileStatsTarget implements the StatsTarget interface by writing to a simple text file.

Definition at line 37 of file FileStatsTarget.h.


Constructor & Destructor Documentation

FileStatsTarget::FileStatsTarget ( std::string  filename  )  [explicit]

Creates a new FileStatsTarget.

Parameters:
filename name of file into which to write stats

Definition at line 30 of file FileStatsTarget.cpp.

References filename.

00031 {
00032     filename = filenameInit;
00033 }


Member Function Documentation

std::string FileStatsTarget::getFilename (  )  const

Gets name of file receiving stats.

Definition at line 35 of file FileStatsTarget.cpp.

References filename.

00036 {
00037     return filename;
00038 }

void FileStatsTarget::beginSnapshot (  )  [virtual]

Begins recording a snapshot.

Called before all writeCounter invocations for the snapshot.

Implements StatsTarget.

Definition at line 40 of file FileStatsTarget.cpp.

References filename, and snapshotStream.

00041 {
00042     assert(!filename.empty());
00043     snapshotStream.open(filename.c_str(),std::ios::trunc);
00044 
00045     // TODO:  re-enable this.  I disabled it since /tmp/fennel.stats
00046     // can't be opened on mingw; need to parameterize it better
00047     // (or put in Performance Monitor integration)
00048 
00049     // assert(snapshotStream.good());
00050 }

void FileStatsTarget::endSnapshot (  )  [virtual]

Finishes recording a snapshot.

Called after all writeCounter invocations for the snapshot.

Implements StatsTarget.

Definition at line 52 of file FileStatsTarget.cpp.

References snapshotStream.

00053 {
00054     snapshotStream.close();
00055 }

void FileStatsTarget::writeCounter ( std::string  name,
int64_t  value 
) [virtual]

Writes one int counter.

This is called from a StatsSource implementation in response to writeStats().

Parameters:
name name of counter
value snapshot value

Implements StatsTarget.

Definition at line 57 of file FileStatsTarget.cpp.

References snapshotStream.

00058 {
00059     snapshotStream << name << ' ' << value << std::endl;
00060 }

void StatsTarget::onThreadStart (  )  [virtual, inherited]

Receives notification that stats polling is starting via a TimerThread.

Reimplemented in JavaTraceTarget.

Definition at line 111 of file StatsTimer.cpp.

Referenced by StatsTimer::onThreadStart().

00112 {
00113     // by default do nothing
00114 }

void StatsTarget::onThreadEnd (  )  [virtual, inherited]

Receives notification that stats polling via a TimerThread is ending.

Reimplemented in JavaTraceTarget.

Definition at line 116 of file StatsTimer.cpp.

Referenced by StatsTimer::onThreadEnd().

00117 {
00118     // by default do nothing
00119 }


Member Data Documentation

std::string FileStatsTarget::filename [private]

Definition at line 39 of file FileStatsTarget.h.

Referenced by beginSnapshot(), FileStatsTarget(), and getFilename().

std::ofstream FileStatsTarget::snapshotStream [private]

Definition at line 40 of file FileStatsTarget.h.

Referenced by beginSnapshot(), endSnapshot(), and writeCounter().


The documentation for this class was generated from the following files:
Generated on Mon Jun 22 04:00:32 2009 for Fennel by  doxygen 1.5.1