Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes

SpecializedVehicle< T, Type > Struct Template Reference

Class defining several overloaded accessors so we don't have to cast vehicle types that often. More...

#include <vehicle_base.h>

Inheritance diagram for SpecializedVehicle< T, Type >:
Vehicle Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool > BaseVehicle GroundVehicle< T, Type >

Public Types

typedef SpecializedVehicle< T,
Type > 
SpecializedVehicleBase
 Our type.

Public Member Functions

 SpecializedVehicle ()
 Set vehicle type correctly.
T * First () const
 Get the first vehicle in the chain.
T * Last ()
 Get the last vehicle in the chain.
const T * Last () const
 Get the last vehicle in the chain.
T * Next () const
 Get next vehicle in the chain.
T * Previous () const
 Get previous vehicle in the chain.
T * GetNextArticulatedPart ()
 Get the next part of an articulated engine.
T * GetNextArticulatedPart () const
 Get the next part of an articulated engine.
T * GetFirstEnginePart ()
 Get the first part of an articulated engine.
const T * GetFirstEnginePart () const
 Get the first part of an articulated engine.
T * GetLastEnginePart ()
 Get the last part of an articulated engine.
T * GetNextVehicle () const
 Get the next real (non-articulated part) vehicle in the consist.
T * GetPrevVehicle () const
 Get the previous real (non-articulated part) vehicle in the consist.
void UpdateViewport (bool force_update, bool update_delta)
 Update vehicle sprite- and position caches.

Static Public Member Functions

static bool IsValidID (size_t index)
 Tests whether given index is a valid index for vehicle of this type.
static T * Get (size_t index)
 Gets vehicle with given index.
static T * GetIfValid (size_t index)
 Returns vehicle if the index is a valid index for this vehicle type.
static T * From (Vehicle *v)
 Converts a Vehicle to SpecializedVehicle with type checking.
static const T * From (const Vehicle *v)
 Converts a const Vehicle to const SpecializedVehicle with type checking.

Static Public Attributes

static const VehicleType EXPECTED_TYPE = Type
 Specialized type.

Detailed Description

template<class T, VehicleType Type>
struct SpecializedVehicle< T, Type >

Class defining several overloaded accessors so we don't have to cast vehicle types that often.

Definition at line 853 of file vehicle_base.h.


Member Function Documentation

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::First (  )  const [inline]

Get the first vehicle in the chain.

Returns:
first vehicle in the chain

Reimplemented from Vehicle.

Definition at line 867 of file vehicle_base.h.

Referenced by GroundVehicle< T, Type >::CargoChanged(), SpecializedVehicle< RoadVehicle, Type >::First(), FINAL::HasToUseGetSlopePixelZ(), and GroundVehicle< T, Type >::PowerChanged().

template<class T, VehicleType Type>
static T* SpecializedVehicle< T, Type >::From ( Vehicle v  )  [inline, static]

Converts a Vehicle to SpecializedVehicle with type checking.

Parameters:
v Vehicle pointer
Returns:
pointer to SpecializedVehicle

Definition at line 970 of file vehicle_base.h.

Referenced by CmdSellRailWagon(), GroundVehicle< T, Type >::GetAcceleration(), GroundVehicle< T, Type >::PowerChanged(), and TrainApproachingCrossingEnum().

template<class T, VehicleType Type>
static const T* SpecializedVehicle< T, Type >::From ( const Vehicle v  )  [inline, static]

Converts a const Vehicle to const SpecializedVehicle with type checking.

Parameters:
v Vehicle pointer
Returns:
pointer to SpecializedVehicle

Definition at line 981 of file vehicle_base.h.

template<class T, VehicleType Type>
static T* SpecializedVehicle< T, Type >::Get ( size_t  index  )  [inline, static]

Gets vehicle with given index.

Returns:
pointer to vehicle with given index casted to T *

Definition at line 951 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::Get(), SpecializedVehicle< RoadVehicle, Type >::GetIfValid(), GetTrainStopLocation(), FINAL::GetWeight(), and SpecializedVehicle< RoadVehicle, Type >::IsValidID().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::GetFirstEnginePart (  )  [inline]

Get the first part of an articulated engine.

Returns:
First part of the engine.

Reimplemented from Vehicle.

Definition at line 911 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::GetFirstEnginePart().

template<class T, VehicleType Type>
const T* SpecializedVehicle< T, Type >::GetFirstEnginePart (  )  const [inline]

Get the first part of an articulated engine.

Returns:
First part of the engine.

Reimplemented from Vehicle.

Definition at line 917 of file vehicle_base.h.

template<class T, VehicleType Type>
static T* SpecializedVehicle< T, Type >::GetIfValid ( size_t  index  )  [inline, static]

Returns vehicle if the index is a valid index for this vehicle type.

Returns:
pointer to vehicle with given index if it's a vehicle of this type

Definition at line 960 of file vehicle_base.h.

Referenced by CmdForceTrainProceed(), CmdMoveRailVehicle(), CmdReverseTrainDirection(), and CmdTurnRoadVeh().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::GetLastEnginePart (  )  [inline]

Get the last part of an articulated engine.

Returns:
Last part of the engine.

Reimplemented from Vehicle.

Definition at line 923 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::GetLastEnginePart().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::GetNextArticulatedPart (  )  [inline]

Get the next part of an articulated engine.

Returns:
Next part of the articulated engine.
Precondition:
The vehicle is an articulated engine.

Definition at line 898 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::GetNextArticulatedPart().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::GetNextArticulatedPart (  )  const [inline]

Get the next part of an articulated engine.

Returns:
Next part of the articulated engine.
Precondition:
The vehicle is an articulated engine.

Reimplemented from Vehicle.

Definition at line 905 of file vehicle_base.h.

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::GetNextVehicle (  )  const [inline]

Get the next real (non-articulated part) vehicle in the consist.

Returns:
Next vehicle in the consist.

Reimplemented from Vehicle.

Definition at line 929 of file vehicle_base.h.

Referenced by FINAL::GetNextUnit(), and SpecializedVehicle< RoadVehicle, Type >::GetNextVehicle().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::GetPrevVehicle (  )  const [inline]

Get the previous real (non-articulated part) vehicle in the consist.

Returns:
Previous vehicle in the consist.

Reimplemented from Vehicle.

Definition at line 935 of file vehicle_base.h.

Referenced by FINAL::GetPrevUnit(), and SpecializedVehicle< RoadVehicle, Type >::GetPrevVehicle().

template<class T, VehicleType Type>
static bool SpecializedVehicle< T, Type >::IsValidID ( size_t  index  )  [inline, static]

Tests whether given index is a valid index for vehicle of this type.

Parameters:
index tested index
Returns:
is this index valid index of T?

Definition at line 942 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::GetIfValid(), and SpecializedVehicle< RoadVehicle, Type >::IsValidID().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::Last (  )  [inline]

Get the last vehicle in the chain.

Returns:
last vehicle in the chain

Reimplemented from Vehicle.

Definition at line 873 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::Last().

template<class T, VehicleType Type>
const T* SpecializedVehicle< T, Type >::Last (  )  const [inline]

Get the last vehicle in the chain.

Returns:
last vehicle in the chain

Reimplemented from Vehicle.

Definition at line 879 of file vehicle_base.h.

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::Next (  )  const [inline]

Get next vehicle in the chain.

Returns:
next vehicle in the chain

Reimplemented from Vehicle.

Definition at line 885 of file vehicle_base.h.

Referenced by FINAL::CalcNextVehicleOffset(), and SpecializedVehicle< RoadVehicle, Type >::Next().

template<class T, VehicleType Type>
T* SpecializedVehicle< T, Type >::Previous (  )  const [inline]

Get previous vehicle in the chain.

Returns:
previous vehicle in the chain

Reimplemented from Vehicle.

Definition at line 891 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::Previous().

template<class T, VehicleType Type>
void SpecializedVehicle< T, Type >::UpdateViewport ( bool  force_update,
bool  update_delta 
) [inline]

Update vehicle sprite- and position caches.

Parameters:
force_update Force updating the vehicle on the viewport.
update_delta Also update the delta?

Definition at line 992 of file vehicle_base.h.

Referenced by GroundVehicle< RoadVehicle, VEH_ROAD >::UpdateInclination().


The documentation for this struct was generated from the following file: