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, Tcache, Tzero >::PoolItem<&_vehicle_pool > BaseVehicle GroundVehicle< T, Type >

Public Types

typedef SpecializedVehicle< T,
Type > 
SpecializedVehicleBase
 Our type.

Public Member Functions

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

Static Public Member Functions

static FORCEINLINE bool IsValidID (size_t index)
 Tests whether given index is a valid index for vehicle of this type.
static FORCEINLINE T * Get (size_t index)
 Gets vehicle with given index.
static FORCEINLINE T * GetIfValid (size_t index)
 Returns vehicle if the index is a valid index for this vehicle type.
static FORCEINLINE T * From (Vehicle *v)
 Converts a Vehicle to SpecializedVehicle with type checking.
static FORCEINLINE 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 819 of file vehicle_base.h.


Member Function Documentation

template<class T, VehicleType Type>
FORCEINLINE T* SpecializedVehicle< T, Type >::First (  )  const [inline]
template<class T, VehicleType Type>
static FORCEINLINE 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 947 of file vehicle_base.h.

template<class T, VehicleType Type>
static FORCEINLINE 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 936 of file vehicle_base.h.

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

template<class T, VehicleType Type>
static FORCEINLINE T* SpecializedVehicle< T, Type >::Get ( size_t  index  )  [inline, static]
template<class T, VehicleType Type>
FORCEINLINE 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 883 of file vehicle_base.h.

template<class T, VehicleType Type>
FORCEINLINE 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 877 of file vehicle_base.h.

Referenced by CmdMoveRailVehicle(), CmdSellRailWagon(), SpecializedVehicle< RoadVehicle, Type >::GetFirstEnginePart(), and GetVehicleSet().

template<class T, VehicleType Type>
static FORCEINLINE 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

Reimplemented from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >.

Definition at line 926 of file vehicle_base.h.

template<class T, VehicleType Type>
FORCEINLINE 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 889 of file vehicle_base.h.

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

template<class T, VehicleType Type>
FORCEINLINE 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 871 of file vehicle_base.h.

template<class T, VehicleType Type>
FORCEINLINE 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 864 of file vehicle_base.h.

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

template<class T, VehicleType Type>
FORCEINLINE 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 895 of file vehicle_base.h.

Referenced by ArrangeTrains(), ConnectMultiheadedTrains(), DrawTrainDetails(), Train::GetNextUnit(), SpecializedVehicle< RoadVehicle, Type >::GetNextVehicle(), Train::GetRunningCost(), GetTrainDetailsWndVScroll(), and NormaliseDualHeads().

template<class T, VehicleType Type>
FORCEINLINE 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 901 of file vehicle_base.h.

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

template<class T, VehicleType Type>
static FORCEINLINE 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?

Reimplemented from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_vehicle_pool >.

Definition at line 908 of file vehicle_base.h.

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

template<class T, VehicleType Type>
FORCEINLINE 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 845 of file vehicle_base.h.

template<class T, VehicleType Type>
FORCEINLINE T* SpecializedVehicle< T, Type >::Last (  )  [inline]
template<class T, VehicleType Type>
FORCEINLINE T* SpecializedVehicle< T, Type >::Next (  )  const [inline]
template<class T, VehicleType Type>
FORCEINLINE 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 857 of file vehicle_base.h.

Referenced by AdvanceWagonsAfterSwap(), AdvanceWagonsBeforeSwap(), NormaliseSubtypes(), SpecializedVehicle< RoadVehicle, Type >::Previous(), RemoveFromConsist(), and RestoreTrainBackup().

template<class T, VehicleType Type>
FORCEINLINE void SpecializedVehicle< T, Type >::UpdateViewport ( bool  moved,
bool  turned 
) [inline]

Update vehicle sprite- and position caches.

Parameters:
moved Was the vehicle moved?
turned Did the vehicle direction change?

Definition at line 958 of file vehicle_base.h.

Referenced by Train::MarkDirty(), RoadVehicle::MarkDirty(), SetAircraftPosition(), GroundVehicle< RoadVehicle, VEH_ROAD >::UpdateInclination(), UpdateStatusAfterSwap(), and VehicleEnterDepot().


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

Generated on Wed Apr 13 00:49:03 2011 for OpenTTD by  doxygen 1.6.1