00001 // OutputDetector.cpp: implementation of the OutputDetector class. 00002 // 00004 00005 #include "stdafx.h" 00006 #include "OutputDetector.h" 00007 00008 #ifdef _DEBUG 00009 #undef THIS_FILE 00010 static char THIS_FILE[]=__FILE__; 00011 #define new DEBUG_NEW 00012 #endif 00013 00015 // Construction/Destruction 00017 00024 OutputDetector::OutputDetector(int loc, bool DirPos, FileHandler* fh) 00025 { 00026 m_Location = loc; 00027 m_DirPos = DirPos; 00028 m_pFileHandler = fh; 00029 } 00030 00032 OutputDetector::~OutputDetector() 00033 { 00034 00035 } 00036 00042 void OutputDetector::addVehicle(Vehicle *pVeh, double curTime) 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 } 00050 00052 void OutputDetector::WriteVehiclesToFile() 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 } 00059 00064 void OutputDetector::setFileHandler(FileHandler *fh) 00065 { 00066 m_pFileHandler = fh; 00067 } 00068 00069 void OutputDetector::clear() 00070 { 00071 m_vVehicles.clear(); 00072 }