#include <FileHandler.h>
Public Member Functions | |
int | getPercentComplete () |
std::vector< Vehicle * > | loadTruckGroup (int no) |
Facilitates the buffering of a number of vehicles, rather than line by line input. | |
virtual void | writeLine (Vehicle *pVeh)=0 |
virtual Vehicle * | readLine ()=0 |
FileHandler () | |
Default Constructor. | |
virtual | ~FileHandler () |
Default Destructor. | |
Protected Member Functions | |
void | setInFileSize () |
Protected Attributes | |
std::ifstream | m_InFile |
std::ofstream | m_OutFile |
std::vector< Vehicle * > | m_Vehicles |
char * | m_pCharVeh |
char | m_VehCharArry [78] |
int | m_CurLine |
int | m_InFileSize |
int | TRUCK_WEIGHT_THRESHOLD |
Definition at line 21 of file FileHandler.h.
FileHandler::FileHandler | ( | ) |
Default Constructor.
Definition at line 23 of file FileHandler.cpp.
References m_CurLine, CConfigData::VehicleID_Config::TRUCK_WEIGHT_THRESHOLD, TRUCK_WEIGHT_THRESHOLD, and CConfigData::VehicleID.
00024 { 00025 TRUCK_WEIGHT_THRESHOLD = g_ConfigData.VehicleID.TRUCK_WEIGHT_THRESHOLD; 00026 00027 m_CurLine = 0; 00028 }
FileHandler::~FileHandler | ( | ) | [virtual] |
int FileHandler::getPercentComplete | ( | ) |
Definition at line 61 of file FileHandler.cpp.
References m_CurLine, and m_InFileSize.
Referenced by Road::populate().
00062 { 00063 double prop = (double)(m_CurLine) / m_InFileSize; 00064 00065 int percent = int(prop * 100 + 0.5); 00066 00067 return percent; 00068 }
std::vector< Vehicle * > FileHandler::loadTruckGroup | ( | int | no | ) |
Facilitates the buffering of a number of vehicles, rather than line by line input.
no | The number of vehicles to buffer |
Definition at line 41 of file FileHandler.cpp.
References m_Vehicles, and readLine().
Referenced by Road::init().
00042 { 00043 for(int i = 0; i < no; i++) 00044 { 00045 Vehicle* pVeh = readLine(); 00046 m_Vehicles.push_back(pVeh); 00047 } 00048 00049 return m_Vehicles; 00050 }
virtual void FileHandler::writeLine | ( | Vehicle * | pVeh | ) | [pure virtual] |
virtual Vehicle* FileHandler::readLine | ( | ) | [pure virtual] |
void FileHandler::setInFileSize | ( | ) | [protected] |
Definition at line 52 of file FileHandler.cpp.
References m_InFile, and m_InFileSize.
Referenced by CASTORFile::CASTORFile(), and SAFTFile::SAFTFile().
00053 { 00054 m_InFileSize = std::count( std::istreambuf_iterator<char>(m_InFile), 00055 std::istreambuf_iterator<char>(), 00056 '\n'); 00057 00058 m_InFile.seekg(0,std::ios::beg); // go back to start of file 00059 }
std::ifstream FileHandler::m_InFile [protected] |
Definition at line 33 of file FileHandler.h.
Referenced by CASTORFile::CASTORFile(), SAFTFile::readLine(), CASTORFile::readLine(), SAFTFile::SAFTFile(), setInFileSize(), CASTORFile::~CASTORFile(), and SAFTFile::~SAFTFile().
std::ofstream FileHandler::m_OutFile [protected] |
Definition at line 34 of file FileHandler.h.
Referenced by CASTORFile::CASTORFile(), SAFTFile::SAFTFile(), SAFTFile::writeLine(), CASTORFile::writeLine(), CASTORFile::~CASTORFile(), and SAFTFile::~SAFTFile().
std::vector<Vehicle*> FileHandler::m_Vehicles [protected] |
Definition at line 35 of file FileHandler.h.
Referenced by loadTruckGroup(), CASTORFile::~CASTORFile(), and SAFTFile::~SAFTFile().
char* FileHandler::m_pCharVeh [protected] |
Definition at line 36 of file FileHandler.h.
Referenced by CASTORFile::CASTORFile(), SAFTFile::SAFTFile(), SAFTFile::writeLine(), and CASTORFile::writeLine().
char FileHandler::m_VehCharArry[78] [protected] |
Definition at line 37 of file FileHandler.h.
Referenced by CASTORFile::CASTORFile(), and SAFTFile::SAFTFile().
int FileHandler::m_CurLine [protected] |
Definition at line 39 of file FileHandler.h.
Referenced by FileHandler(), getPercentComplete(), SAFTFile::readLine(), and CASTORFile::readLine().
int FileHandler::m_InFileSize [protected] |
Definition at line 40 of file FileHandler.h.
Referenced by getPercentComplete(), and setInFileSize().
int FileHandler::TRUCK_WEIGHT_THRESHOLD [protected] |
Definition at line 42 of file FileHandler.h.
Referenced by FileHandler(), SAFTFile::readLine(), and CASTORFile::readLine().