CConfigData Class Reference

A class for containing all of the configuration prameters for the program. More...

#include <ConfigData.h>

Collaboration diagram for CConfigData:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void SetDefaults ()
 CConfigData ()
virtual ~CConfigData ()
bool ReadData (std::string inFile)

Public Attributes

struct CConfigData::IDM_Config IDM
struct CConfigData::Road_Config Road
struct CConfigData::Time_Config Time
struct
CConfigData::VehicleID_Config 
VehicleID
struct CConfigData::View_Config View

Private Member Functions

void ExtractData ()
COLORREF stringToColour (string line)
string GetNextDataLine ()
double stringToDouble (string line)
int stringToInt (string line)
bool stringToBool (string line)

Private Attributes

string m_CommentString
CCSVParse m_CSV

Classes

struct  IDM_Config
struct  Road_Config
struct  Time_Config
struct  VehicleID_Config
struct  View_Config


Detailed Description

A class for containing all of the configuration prameters for the program.

Definition at line 17 of file ConfigData.h.


Constructor & Destructor Documentation

CConfigData::CConfigData (  ) 

Definition at line 19 of file ConfigData.cpp.

References m_CommentString, and SetDefaults().

00020 {
00021         m_CommentString = "//";
00022         SetDefaults();
00023 }

Here is the call graph for this function:

CConfigData::~CConfigData (  )  [virtual]

Definition at line 25 of file ConfigData.cpp.

00026 {
00027 
00028 }


Member Function Documentation

void CConfigData::SetDefaults (  ) 

Definition at line 108 of file ConfigData.cpp.

References CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_BACKGRND, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_COMPOSITION, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_FLOWDENSITY, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_HEADWAY, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_OUTPUT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_FEAT_GRADIENT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_FEAT_SPEEDLIMIT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_LEGEND_TEXT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_ROAD_LINES, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_ROAD_SURFACE, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_RULER_LINES, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_RULER_TEXT, CConfigData::View_Config::Colours, CConfigData::VehicleID_Config::CRANE_AVERAGE_SPACING, CConfigData::VehicleID_Config::CRANE_MAX_SPACING, CConfigData::View_Config::DATATIP_DELAY, CConfigData::Time_Config::DAYS_PER_MT, CConfigData::View_Config::View_Colours::DrawElements, CConfigData::VehicleID_Config::LOWLOADER_MIN_MAX_SPACING, CConfigData::View_Config::MIN_VIEW_SCALE, CConfigData::Time_Config::MTS_PER_YR, CConfigData::VehicleID_Config::SMALL_TRUCK_NO_AXLES, Time, CConfigData::VehicleID_Config::TRUCK_WEIGHT_THRESHOLD, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_CAR, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_CRANE, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_LARGETRUCK, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_LOWLOADER, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_SMALLTRUCK, VehicleID, CConfigData::View_Config::View_Colours::Vehicles, and View.

Referenced by CConfigData().

00109 {
00110         IDM.LANECHANGE_MIN_GAP                  = 2.0;
00111         IDM.MIN_SPACE_FOR_NEXT_VEHICLE  = 27.0;
00112         IDM.SAFE_BRAKING                                = -12.0;
00113         IDM.T_DELAY                                             = 1.6;
00114 
00115 
00116         Road.ROAD_END_BUFFER                                                            = 1000;
00117         
00118         Road.RoadFeatures.MAX_NO_ROAD_FEATURES                          = 10;
00119         
00120         Road.RoadFeatures.SpeedLimit.SPEEDLIMIT_MIN                     = 10;
00121         Road.RoadFeatures.SpeedLimit.SPEEDLIMIT_MAX                     = 200;
00122         
00123         Road.RoadFeatures.Gradient.MAX_SLOPE                            = 15;
00124         Road.RoadFeatures.Gradient.IDM_Modifiers.A_FLAG         = true;
00125         Road.RoadFeatures.Gradient.IDM_Modifiers.A_MIN          = 0.1;
00126         Road.RoadFeatures.Gradient.IDM_Modifiers.B_FLAG         = true;
00127         Road.RoadFeatures.Gradient.IDM_Modifiers.T_SLOPE        = 10.0;
00128         Road.RoadFeatures.Gradient.IDM_Modifiers.V0_MIN         = 0.1;
00129         Road.RoadFeatures.Gradient.IDM_Modifiers.V0_SLOPE       = 0.2;
00130         
00131 
00132         Time.DAYS_PER_MT        = 25;
00133         Time.MTS_PER_YR         = 10;
00134         
00135 
00136         VehicleID.CRANE_AVERAGE_SPACING         = 2.5;
00137         VehicleID.CRANE_MAX_SPACING                     = 4.5;
00138         VehicleID.LOWLOADER_MIN_MAX_SPACING     = 7.5;
00139         VehicleID.SMALL_TRUCK_NO_AXLES          = 3;
00140         VehicleID.TRUCK_WEIGHT_THRESHOLD        = 35;
00141 
00142         
00143         View.MIN_VIEW_SCALE                                     = 0.1;
00144         View.DATATIP_DELAY                                      = 20.0;
00145         
00146         View.Colours.Vehicles.VEH_COLOR_CAR                     = RGB(0,0,0);
00147         View.Colours.Vehicles.VEH_COLOR_SMALLTRUCK      = RGB(0,0,255);
00148         View.Colours.Vehicles.VEH_COLOR_LARGETRUCK      = RGB(255,0,0);
00149         View.Colours.Vehicles.VEH_COLOR_CRANE           = RGB(0,255,0);
00150         View.Colours.Vehicles.VEH_COLOR_LOWLOADER       = RGB(100,100,100);
00151         
00152         View.Colours.DrawElements.CLR_BACKGRND                  = RGB(255,255,255);
00153         View.Colours.DrawElements.CLR_ROAD_SURFACE              = RGB(200,200,200);
00154         View.Colours.DrawElements.CLR_ROAD_LINES                = RGB(0,0,0);
00155         View.Colours.DrawElements.CLR_RULER_LINES               = RGB(0,0,0);
00156         View.Colours.DrawElements.CLR_RULER_TEXT                = RGB(0,0,0);
00157         View.Colours.DrawElements.CLR_LEGEND_TEXT               = RGB(0,0,0);
00158         View.Colours.DrawElements.CLR_DET_OUTPUT                = RGB(255,255,0);
00159         View.Colours.DrawElements.CLR_DET_FLOWDENSITY   = RGB(0,255,0);
00160         View.Colours.DrawElements.CLR_DET_HEADWAY               = RGB(0,0,255);
00161         View.Colours.DrawElements.CLR_DET_COMPOSITION   = RGB(0,0,0);
00162         View.Colours.DrawElements.CLR_FEAT_SPEEDLIMIT   = RGB(255,0,0);
00163         View.Colours.DrawElements.CLR_FEAT_GRADIENT             = RGB(0,255,0);
00164 }

bool CConfigData::ReadData ( std::string  inFile  ) 

Definition at line 34 of file ConfigData.cpp.

References ExtractData(), m_CSV, and CCSVParse::OpenFile().

Referenced by CEvolveTrafficApp::InitInstance().

00035 {
00036         if( m_CSV.OpenFile(inFile, ",") )
00037         {
00038                 ExtractData();
00039                 return true;
00040         }
00041         return false;
00042 }

Here is the call graph for this function:

void CConfigData::ExtractData (  )  [private]

Definition at line 44 of file ConfigData.cpp.

References CCSVParse::CloseFile(), CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_BACKGRND, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_COMPOSITION, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_FLOWDENSITY, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_HEADWAY, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_DET_OUTPUT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_FEAT_GRADIENT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_FEAT_SPEEDLIMIT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_LEGEND_TEXT, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_ROAD_LINES, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_ROAD_SURFACE, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_RULER_LINES, CConfigData::View_Config::View_Colours::Col_DrawElements::CLR_RULER_TEXT, CConfigData::View_Config::Colours, CConfigData::VehicleID_Config::CRANE_AVERAGE_SPACING, CConfigData::VehicleID_Config::CRANE_MAX_SPACING, CConfigData::View_Config::DATATIP_DELAY, CConfigData::Time_Config::DAYS_PER_MT, CConfigData::View_Config::View_Colours::DrawElements, GetNextDataLine(), CConfigData::VehicleID_Config::LOWLOADER_MIN_MAX_SPACING, m_CSV, CConfigData::View_Config::MIN_VIEW_SCALE, CConfigData::Time_Config::MTS_PER_YR, CConfigData::VehicleID_Config::SMALL_TRUCK_NO_AXLES, stringToBool(), stringToColour(), stringToDouble(), stringToInt(), Time, CConfigData::VehicleID_Config::TRUCK_WEIGHT_THRESHOLD, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_CAR, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_CRANE, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_LARGETRUCK, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_LOWLOADER, CConfigData::View_Config::View_Colours::Col_Vehicles::VEH_COLOR_SMALLTRUCK, VehicleID, CConfigData::View_Config::View_Colours::Vehicles, and View.

Referenced by ReadData().

00045 {
00046                 string str;
00047 
00048                 str = GetNextDataLine();        IDM.LANECHANGE_MIN_GAP                  = stringToDouble(str);
00049                 str = GetNextDataLine();        IDM.MIN_SPACE_FOR_NEXT_VEHICLE  = stringToDouble(str);
00050                 str = GetNextDataLine();        IDM.SAFE_BRAKING                                = stringToDouble(str);
00051                 str = GetNextDataLine();        IDM.T_DELAY                                             = stringToDouble(str);
00052 
00053                 str = GetNextDataLine();        Road.ROAD_END_BUFFER                                                            = stringToInt(str);
00054                 str = GetNextDataLine();        Road.RoadFeatures.SpeedLimit.SPEEDLIMIT_MIN                     = stringToInt(str);
00055                 str = GetNextDataLine();        Road.RoadFeatures.SpeedLimit.SPEEDLIMIT_MAX                     = stringToInt(str);
00056                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.MAX_SLOPE                            = stringToInt(str);
00057                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.IDM_Modifiers.A_FLAG         = stringToBool(str);
00058                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.IDM_Modifiers.A_MIN          = stringToDouble(str);
00059                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.IDM_Modifiers.B_FLAG         = stringToBool(str);
00060                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.IDM_Modifiers.T_SLOPE        = stringToDouble(str);
00061                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.IDM_Modifiers.V0_MIN         = stringToDouble(str);
00062                 str = GetNextDataLine();        Road.RoadFeatures.Gradient.IDM_Modifiers.V0_SLOPE       = stringToDouble(str);
00063 
00064                 str = GetNextDataLine();        Time.DAYS_PER_MT        = stringToInt(str);
00065                 str = GetNextDataLine();        Time.MTS_PER_YR         = stringToInt(str);
00066                 
00067                 str = GetNextDataLine();        VehicleID.CRANE_AVERAGE_SPACING         = stringToDouble(str);
00068                 str = GetNextDataLine();        VehicleID.CRANE_MAX_SPACING                     = stringToDouble(str);
00069                 str = GetNextDataLine();        VehicleID.LOWLOADER_MIN_MAX_SPACING     = stringToDouble(str);
00070                 str = GetNextDataLine();        VehicleID.SMALL_TRUCK_NO_AXLES          = stringToInt(str);
00071                 str = GetNextDataLine();        VehicleID.TRUCK_WEIGHT_THRESHOLD        = stringToInt(str);
00072 
00073                 str = GetNextDataLine();        View.MIN_VIEW_SCALE                                     = stringToDouble(str);  
00074                 str = GetNextDataLine();        View.DATATIP_DELAY                                      = stringToDouble(str);
00075                 str = GetNextDataLine();        View.Colours.Vehicles.VEH_COLOR_CAR                             = stringToColour(str);
00076                 str = GetNextDataLine();        View.Colours.Vehicles.VEH_COLOR_SMALLTRUCK              = stringToColour(str);
00077                 str = GetNextDataLine();        View.Colours.Vehicles.VEH_COLOR_LARGETRUCK              = stringToColour(str);
00078                 str = GetNextDataLine();        View.Colours.Vehicles.VEH_COLOR_CRANE                   = stringToColour(str);
00079                 str = GetNextDataLine();        View.Colours.Vehicles.VEH_COLOR_LOWLOADER               = stringToColour(str);
00080                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_BACKGRND                  = stringToColour(str);
00081                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_ROAD_SURFACE              = stringToColour(str);
00082                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_ROAD_LINES                = stringToColour(str);
00083                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_RULER_LINES               = stringToColour(str);
00084                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_RULER_TEXT                = stringToColour(str);
00085                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_LEGEND_TEXT               = stringToColour(str);
00086                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_DET_OUTPUT                = stringToColour(str);
00087                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_DET_FLOWDENSITY   = stringToColour(str);
00088                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_DET_HEADWAY               = stringToColour(str);
00089                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_DET_COMPOSITION   = stringToColour(str);
00090                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_FEAT_SPEEDLIMIT   = stringToColour(str);
00091                 str = GetNextDataLine();        View.Colours.DrawElements.CLR_FEAT_GRADIENT             = stringToColour(str);
00092                 
00093                 m_CSV.CloseFile();
00094 }

Here is the call graph for this function:

COLORREF CConfigData::stringToColour ( string  line  )  [private]

Definition at line 192 of file ConfigData.cpp.

References CCSVParse::getfield(), m_CSV, and stringToInt().

Referenced by ExtractData().

00193 {
00194         int red, green, blue;
00195         string str;
00196         
00197         str = m_CSV.getfield(0);        red = stringToInt(str);
00198         str = m_CSV.getfield(1);        green = stringToInt(str);
00199         str = m_CSV.getfield(2);        blue = stringToInt(str);
00200 
00201         return RGB(red,green,blue);
00202 }

Here is the call graph for this function:

string CConfigData::GetNextDataLine (  )  [private]

Definition at line 96 of file ConfigData.cpp.

References CCSVParse::getline(), m_CommentString, and m_CSV.

Referenced by ExtractData().

00097 {
00098         string line;
00099         m_CSV.getline(line);
00100         while(line.substr(0,2) == m_CommentString)
00101                 m_CSV.getline(line);
00102 
00103         return line;
00104 }

Here is the call graph for this function:

double CConfigData::stringToDouble ( string  line  )  [private]

Definition at line 166 of file ConfigData.cpp.

Referenced by ExtractData().

00167 {
00168         double val;     char data[15]; 
00169         line.copy(data, 14, 0);  
00170         val = atof(data);
00171         return val;
00172 }

int CConfigData::stringToInt ( string  line  )  [private]

Definition at line 174 of file ConfigData.cpp.

Referenced by ExtractData(), stringToBool(), and stringToColour().

00175 {
00176         int val = 0;    char data[15]; 
00177         line.copy(data, 14, 0);  
00178         val = atoi(data);
00179         return val;
00180 }

bool CConfigData::stringToBool ( string  line  )  [private]

Definition at line 182 of file ConfigData.cpp.

References stringToInt().

Referenced by ExtractData().

00183 {
00184         int val = stringToInt(line);
00185         if(val == 1)
00186                 return true;
00187         else
00188                 return false;
00189 }

Here is the call graph for this function:


Member Data Documentation

string CConfigData::m_CommentString [private]

Definition at line 125 of file ConfigData.h.

Referenced by CConfigData(), and GetNextDataLine().

Definition at line 127 of file ConfigData.h.

Referenced by ExtractData(), GetNextDataLine(), ReadData(), and stringToColour().


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

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