Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Reference_Reader Class Reference

An abstract class whose subclasses can read different trace formats. More...

#include <Reference_Reader.hh>

Inheritance diagram for Reference_Reader:

Binary_Raw_Reader Instruction_Reduced_Reader Page_Reduced_Reader Text_Raw_Reader List of all members.

Public Methods

 Reference_Reader ()
 The default constructor.

 Reference_Reader (const char *const reference_trace_pathname)
 The common constructor.

virtual ~Reference_Reader ()
 The deconstructor.

virtual void read (reference_record_s *const reference_record)=0
 Read the next record from the reference trace.


Protected Attributes

FILE * reference_stream
 The reference trace input stream.

char buffer [BUFFER_SIZE]
 A buffer used for input and parsing.


Detailed Description

An abstract class whose subclasses can read different trace formats.

This abstract class is a simple one. It will open and close the file, and provide the ability to rewind that file. It does not define how the file is read, but rather provides the method that a subclass must define in order to read a specific reference trace format.

Definition at line 49 of file Reference_Reader.hh.


Constructor & Destructor Documentation

Reference_Reader::Reference_Reader   [inline]
 

The default constructor.

Intended for subclasses that do not open a single file, and therefore choose not to use the provided file stream data member.

Definition at line 60 of file Reference_Reader.hh.

00060 {}

Reference_Reader::Reference_Reader const char *const    reference_trace_pathname
 

The common constructor.

Parameters:
reference_trace_pathname The pathname of the reference trace to be read.
Set up a Reference_Reader object by opening the reference trace file and holding a stream for it.

Definition at line 33 of file Reference_Reader.cc.

00033                                              {
00034 
00035   // Attempt to open the trace file.
00036   reference_stream = fopen(reference_trace_pathname, "r");
00037 
00038   // Did the reference trace open correctly?
00039   if (reference_stream == NULL) {
00040 
00041     // No.  Emit the error and exit.
00042     perror("Failed opening reference trace");
00043     exit(1);
00044 
00045   }
00046 } // Reference_Reader

Reference_Reader::~Reference_Reader   [virtual]
 

The deconstructor.

Deconstruct a Reference_Reader. Close the reference trace file.

Definition at line 52 of file Reference_Reader.cc.

References reference_stream.

00052                                      {
00053 
00054   // Was the reference stream opened?  (A subclass is not required to
00055   // use this data member.)
00056   if (reference_stream != NULL) {
00057 
00058     // Yes.  Attempt to close it, ensuring success.
00059     int reference_result = fclose(reference_stream);
00060     if (reference_result == EOF) {
00061       perror("Failed closing reference trace");
00062       exit(1);
00063     }
00064 
00065   }
00066 } // ~Consumer


Member Function Documentation

virtual void Reference_Reader::read reference_record_s *const    reference_record [pure virtual]
 

Read the next record from the reference trace.

See also:
reference_record_s
Parameters:
reference_record A data structure that will hold the needed data from the trace record.
This pure virtual method must be defined in a subclass so that it reads the next record, parses it, and places the required information into the data structure passed to it. Any errors in reading (I/O errors or premature EOF) are expected to abort processing.

Implemented in Binary_Raw_Reader, Instruction_Reduced_Reader, Page_Reduced_Reader, and Text_Raw_Reader.

Referenced by Consumer::merge(), and Consumer::synchronize().


Member Data Documentation

char Reference_Reader::buffer[BUFFER_SIZE] [protected]
 

A buffer used for input and parsing.

Definition at line 102 of file Reference_Reader.hh.

Referenced by Text_Raw_Reader::read().

FILE* Reference_Reader::reference_stream [protected]
 

The reference trace input stream.

Definition at line 99 of file Reference_Reader.hh.

Referenced by ~Reference_Reader().


The documentation for this class was generated from the following files:
Generated on Fri Jan 31 10:33:40 2003 for Laplace-merge by doxygen1.3-rc2