Truck Class Reference

A class to represent a Truck. More...

#include <Truck.h>

Inheritance diagram for Truck:

Inheritance graph
[legend]
Collaboration diagram for Truck:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Truck ()
 Default constructor.
virtual ~Truck ()
 Default destructor.
void setAW (int i, double w)
 Sets the weight of a given axle.
void setAS (int i, double s)
 Sets the spacing of a given axle.
int getNoAxles ()
 Gets the vehicle's number of axles.
double getAS (int i)
 Gets the spacing of a given axle.
double getAW (int i)
 Gets the weight of a given axle.
bool operator== (Truck &x)
bool operator< (const Truck &x)
void returnTruckData (int truckData[])
 Parses the Truck's data into an array.
void doSAFTData (char *pTruck)
void doCASTORData (char *pTruck)
void createSAFTVehicle (std::string data)
 Creates a truck from a given SAFT string.
void createCASTORVehicle (std::string data)
 Creates a truck from a given CASTOR string.
void setDriver ()
void setGVW (double weight)
 Sets the GVW of the vehicle to a given weight.

Private Member Functions

int getID ()
 Gets the class of the Vehicle.

Private Attributes

std::vector< Axle * > axles
double m_OverhangFront
double m_OverhangBack


Detailed Description

A class to represent a Truck.

Definition at line 22 of file Truck.h.


Constructor & Destructor Documentation

Truck::Truck (  ) 

Default constructor.

Default Constructor.

Definition at line 15 of file Truck.cpp.

00015             {
00016 /*
00017         HEAD    = 0;    DAY             = 0;    MONTH   = 0;    YEAR    = 5;    HOUR    = 0;
00018         MIN             = 0;    SEC             = 0;    hNDT    = 0;    SPEED   = 0;    GVW             = 0;
00019         LENGTH  = 0;    NAXLES  = 0;    DIRN    = 0;    LANE    = 0;    TRNS    = 0;
00020 */
00021 
00022 }

Truck::~Truck (  )  [virtual]

Default destructor.

Default Destructor.

Definition at line 25 of file Truck.cpp.

References Vehicle::m_vAxles.

00026 {
00027         for(int i = 0; i < m_vAxles.size(); i++)
00028                 delete m_vAxles.at(i);
00029         m_vAxles.clear();
00030 }


Member Function Documentation

void Truck::setAW ( int  i,
double  w 
)

Sets the weight of a given axle.

Parameters:
i the axle to operate upon
w the desired weight

Reimplemented from Vehicle.

void Truck::setAS ( int  i,
double  s 
)

Sets the spacing of a given axle.

The space of a given axle to the next axle

Parameters:
i the axle to operate upon
s the desired spacing

Reimplemented from Vehicle.

int Truck::getNoAxles (  ) 

Gets the vehicle's number of axles.

Returns:
the vehicle's number of axles

Reimplemented from Vehicle.

double Truck::getAS ( int  i  ) 

Gets the spacing of a given axle.

The space of a given axle to the next axle

Parameters:
i the axle to operate upon
Returns:
the space between this axle and the next

Reimplemented from Vehicle.

double Truck::getAW ( int  i  ) 

Gets the weight of a given axle.

Parameters:
i the axle to operate upon
Returns:
the weight of the axle

Reimplemented from Vehicle.

bool Truck::operator== ( Truck x  ) 

Definition at line 65 of file Truck.cpp.

References returnTruckData().

00066 {
00067         const int N = 33;
00068         int truck1[N]; int truck2[N];
00069         returnTruckData(truck1);
00070         x.returnTruckData(truck2);
00071 
00072         bool same = true; int i = 0;
00073         while(same && i < N)
00074         {
00075                 if(truck1[i] != truck2[i])
00076                         same = false;
00077                 i++;
00078         }
00079         return same;
00080 }

Here is the call graph for this function:

bool Truck::operator< ( const Truck x  ) 

Definition at line 58 of file Truck.cpp.

References Vehicle::getTime().

00059 {
00060         double a = this->getTime();
00061         double b = x.getTime();
00062         return a < b;
00063 }

Here is the call graph for this function:

void Truck::returnTruckData ( int  truckData[]  ) 

Parses the Truck's data into an array.

Definition at line 33 of file Truck.cpp.

References Vehicle::m_Day, Vehicle::m_GVW, Vehicle::m_Head, Vehicle::m_Hndt, Vehicle::m_Hour, Vehicle::m_intDir, Vehicle::m_Lane, Vehicle::m_Length, Vehicle::m_Min, Vehicle::m_Month, Vehicle::m_NoAxles, Vehicle::m_Sec, Vehicle::m_Trns, Vehicle::m_Velocity, and Vehicle::m_Year.

Referenced by operator==().

00034 {
00035 
00036         truckData[0]    = m_Head;
00037         truckData[1]    = m_Day;
00038         truckData[2]    = m_Month;
00039         truckData[3]    = m_Year;
00040         truckData[4]    = m_Hour;
00041         truckData[5]    = m_Min;
00042         truckData[6]    = m_Sec;
00043         truckData[7]    = m_Hndt;       
00044         truckData[8]    = m_Velocity;   // must change to dm/s
00045         truckData[9]    = m_GVW;                // change to kg/100
00046         truckData[10]   = m_Length;             // change to dm
00047         truckData[11]   = m_NoAxles;
00048         truckData[12]   = m_intDir;             //m_DirPointsToRight == true ? 1 : 2;
00049         truckData[13]   = m_Lane;
00050         truckData[14]   = m_Trns;
00051 
00052         for(int i = 0; i <= 33; i++)
00053         {
00054                 if( (truckData[i] < 0) || (truckData[i] > 9999) ) truckData[i] = 0;
00055         }
00056 }

void Truck::doSAFTData ( char *  pTruck  ) 

void Truck::doCASTORData ( char *  pTruck  ) 

void Truck::createSAFTVehicle ( std::string  data  ) 

Creates a truck from a given SAFT string.

Parameters:
data The SAFT string of data
This function takes in a string from a SAFT file and creates a truck based on the properties supplied by the data string

Reimplemented from Vehicle.

Definition at line 89 of file Truck.cpp.

References Vehicle::createSAFTVehicle(), m_OverhangBack, and m_OverhangFront.

00090 {
00091         Vehicle::createSAFTVehicle(data);
00092         m_OverhangFront = 0.0;
00093         m_OverhangBack = 0.0;
00094 }

Here is the call graph for this function:

void Truck::createCASTORVehicle ( std::string  data  ) 

Creates a truck from a given CASTOR string.

Parameters:
data The CASTOR string of data
This function takes in a string from a CASTOR file and creates a truck based on the properties supplied by the data string

Reimplemented from Vehicle.

Definition at line 103 of file Truck.cpp.

References Vehicle::createCASTORVehicle(), m_OverhangBack, and m_OverhangFront.

00104 {
00105         Vehicle::createCASTORVehicle(data);
00106         m_OverhangFront = 0.0;
00107         m_OverhangBack = 0.0;
00108 }

Here is the call graph for this function:

void Truck::setDriver (  ) 

void Truck::setGVW ( double  weight  ) 

Sets the GVW of the vehicle to a given weight.

Parameters:
weight the desired GVW

Reimplemented from Vehicle.

int Truck::getID (  )  [private]

Gets the class of the Vehicle.

Returns:
ID the Vehicle's class

Reimplemented from Vehicle.


Member Data Documentation

std::vector<Axle*> Truck::axles [private]

Definition at line 51 of file Truck.h.

double Truck::m_OverhangFront [private]

Definition at line 52 of file Truck.h.

Referenced by createCASTORVehicle(), and createSAFTVehicle().

double Truck::m_OverhangBack [private]

Definition at line 53 of file Truck.h.

Referenced by createCASTORVehicle(), and createSAFTVehicle().


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

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