OutputDetector Class Reference

A derived class representing a detector which tracks when vehicles pass a point. More...

#include <OutputDetector.h>

Inheritance diagram for OutputDetector:

Inheritance graph
[legend]
Collaboration diagram for OutputDetector:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 OutputDetector (int loc, bool DirPos, FileHandler *fh)
 Constructor.
virtual ~OutputDetector ()
 Default Desctructor.
void setFileHandler (FileHandler *fh)
 Sets the OutputDetector's filehandler.
void WriteVehiclesToFile ()
 Writes the OutputDetector's vehicles to file.
std::vector< Vehicle * > getVehicles ()
void addVehicle (Vehicle *pVeh, double curTime)
 Adds a vehicle to the OutputDetector.

Private Member Functions

void clear ()

Private Attributes

FileHandlerm_pFileHandler


Detailed Description

A derived class representing a detector which tracks when vehicles pass a point.

Definition at line 19 of file OutputDetector.h.


Constructor & Destructor Documentation

OutputDetector::OutputDetector ( int  loc,
bool  DirPos,
FileHandler fh 
)

Constructor.

Parameters:
loc The location of the OutputDetector
DirPos Whether or not the OutputDetector is in the positive direction
fh The filehandler to use

Definition at line 24 of file OutputDetector.cpp.

References Detector::m_DirPos, Detector::m_Location, and m_pFileHandler.

00025 {
00026         m_Location = loc;
00027         m_DirPos = DirPos;
00028         m_pFileHandler = fh;
00029 }

OutputDetector::~OutputDetector (  )  [virtual]

Default Desctructor.

Definition at line 32 of file OutputDetector.cpp.

00033 {
00034 
00035 }


Member Function Documentation

void OutputDetector::setFileHandler ( FileHandler fh  ) 

Sets the OutputDetector's filehandler.

Parameters:
fh The filehandler to use

Definition at line 64 of file OutputDetector.cpp.

References m_pFileHandler.

00065 {
00066         m_pFileHandler = fh;
00067 }

void OutputDetector::WriteVehiclesToFile (  ) 

Writes the OutputDetector's vehicles to file.

Definition at line 52 of file OutputDetector.cpp.

References m_pFileHandler, Detector::m_vVehicles, and FileHandler::writeLine().

Referenced by Direction::update().

00053 {
00054         for(int i = 0; i < m_vVehicles.size(); i++)
00055                 m_pFileHandler->writeLine(m_vVehicles.at(i));
00056         // once written, they must be deleted
00057         m_vVehicles.clear();
00058 }

Here is the call graph for this function:

std::vector<Vehicle*> OutputDetector::getVehicles (  ) 

void OutputDetector::addVehicle ( Vehicle pVeh,
double  curTime 
) [virtual]

Adds a vehicle to the OutputDetector.

Parameters:
pVeh The vehicle to add
curTime The current simulation time

Reimplemented from Detector.

Definition at line 42 of file OutputDetector.cpp.

References Detector::FindDetectorArrivalTime(), Detector::m_vVehicles, and Vehicle::setTime().

Referenced by Lane::CheckDetectors().

00043 {
00044         // set the vehicle time to the arrival time at the detector
00045         double ArrivalTime = FindDetectorArrivalTime(pVeh, curTime);
00046         pVeh->setTime(ArrivalTime);
00047         // now add to vector prior to writing
00048         m_vVehicles.push_back(pVeh);
00049 }

Here is the call graph for this function:

void OutputDetector::clear (  )  [private]

Definition at line 69 of file OutputDetector.cpp.

References Detector::m_vVehicles.

00070 {
00071         m_vVehicles.clear();
00072 }


Member Data Documentation

Definition at line 33 of file OutputDetector.h.

Referenced by OutputDetector(), setFileHandler(), and WriteVehiclesToFile().


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

Generated on Wed Aug 20 00:48:49 2008 for EvolveTraffic by  doxygen 1.5.6