OpenTTD Source  20241125-master-g5b02f51e17
VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH > Class Template Referenceabstract

Default handler for saving/loading a vector to/from disk. More...

#include <saveload.h>

Inheritance diagram for VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >:
DefaultSaveLoadHandler< TImpl, TObject > SaveLoadHandler

Public Member Functions

virtual std::vector< TElementType > & GetVector (TObject *object) const =0
 Get instance of vector to load/save. More...
 
virtual size_t GetLength () const
 Get number of elements to load into vector. More...
 
void Save (TObject *object) const override
 
void Load (TObject *object) const override
 
- Public Member Functions inherited from DefaultSaveLoadHandler< TImpl, TObject >
SaveLoadTable GetDescription () const override
 Get the description of the fields in the savegame.
 
SaveLoadCompatTable GetCompatDescription () const override
 Get the pre-header description of the fields in the savegame.
 
virtual void Save ([[maybe_unused]] TObject *object) const
 
void Save (void *object) const override
 
virtual void Load ([[maybe_unused]] TObject *object) const
 
void Load (void *object) const override
 
virtual void LoadCheck ([[maybe_unused]] TObject *object) const
 
void LoadCheck (void *object) const override
 
virtual void FixPointers ([[maybe_unused]] TObject *object) const
 
void FixPointers (void *object) const override
 
- Public Member Functions inherited from SaveLoadHandler
virtual void Save ([[maybe_unused]] void *object) const
 Save the object to disk. More...
 
virtual void Load ([[maybe_unused]] void *object) const
 Load the object from disk. More...
 
virtual void LoadCheck ([[maybe_unused]] void *object) const
 Similar to load, but used only to validate savegames. More...
 
virtual void FixPointers ([[maybe_unused]] void *object) const
 A post-load callback to fix SL_REF integers into pointers. More...
 
SaveLoadTable GetLoadDescription () const
 Get the description for how to load the chunk. More...
 

Additional Inherited Members

- Data Fields inherited from SaveLoadHandler
std::optional< std::vector< SaveLoad > > load_description
 

Detailed Description

template<class TImpl, class TObject, class TElementType, size_t MAX_LENGTH = UINT32_MAX>
class VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >

Default handler for saving/loading a vector to/from disk.

This handles a few common things for handlers, meaning the actual handler needs less code.

Template Parameters
TImplThe class initializing this template.
TObjectThe class of the object using this SaveLoadHandler.
TElementTypeThe type of the elements contained within the vector.
MAX_LENGTHmaximum number of elements to load.

Definition at line 1341 of file saveload.h.

Member Function Documentation

◆ GetLength()

template<class TImpl , class TObject , class TElementType , size_t MAX_LENGTH = UINT32_MAX>
virtual size_t VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >::GetLength ( ) const
inlinevirtual

Get number of elements to load into vector.

Returns
Number of elements to load into the vector.
Note
This is only overridden if the number of elements comes from a different location due to savegame changes.

Reimplemented in SlStationSpecList< T >.

Definition at line 1355 of file saveload.h.

References SlGetStructListLength().

◆ GetVector()

template<class TImpl , class TObject , class TElementType , size_t MAX_LENGTH = UINT32_MAX>
virtual std::vector<TElementType>& VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >::GetVector ( TObject *  object) const
pure virtual

Get instance of vector to load/save.

Parameters
objectObject containing vector.
Returns
Vector to load/save.

Implemented in SlVehicleShipPath, SlVehicleRoadVehPath, SlIndustryProduced, SlIndustryAccepted, SlAllowListData, SlRoadStopTileData, and SlStationSpecList< T >.


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