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 873 of file vehicle_base.h.


Member Function Documentation

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 990 of file vehicle_base.h.

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

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 1001 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 971 of file vehicle_base.h.

Referenced by SpecializedVehicle< RoadVehicle, Type >::Get(), SpecializedVehicle< RoadVehicle, Type >::GetIfValid(), 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 931 of file vehicle_base.h.

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

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 937 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 980 of file vehicle_base.h.

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 943 of file vehicle_base.h.

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

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 918 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 925 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 949 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>
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 955 of file vehicle_base.h.

Referenced by Train::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 962 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]
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 899 of file vehicle_base.h.

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

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

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 1012 of file vehicle_base.h.

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


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