OpenTTD Source: TemporaryStorageArray< TYPE, SIZE > Struct Template Reference

OpenTTD Source 15.0-RC2

Public Types | Public Member Functions | Data Fields
TemporaryStorageArray< TYPE, SIZE > Struct Template Reference

Class for temporary storage of data. More...

`#include <newgrf_storage.h>`

## Public Types
using | StorageType = std::array< TYPE, SIZE >
using | StorageInitType = std::array< uint16_t, SIZE >

## Public Member Functions
void | StoreValue (uint pos, int32_t value)
| Stores some value at a given position.
TYPE | GetValue (uint pos) const
| Gets the value from a given position.
void | ClearChanges ()

## Data Fields
StorageType | storage {}
| Memory for the storage array.
StorageInitType | init {}
| Storage has been assigned, if this equals 'init_key'.
uint16_t | init_key = 1
| Magic key to 'init'.

## Detailed Description

template<typename TYPE, uint SIZE>
struct TemporaryStorageArray< TYPE, SIZE >

Class for temporary storage of data.

On ClearChanges that data is always zero-ed.

Template Parameters

  TYPE | the type of variable to store.
  SIZE | the size of the array.

Definition at line 133 of file newgrf_storage.h.

## Member Typedef Documentation

## ◆ StorageInitType

template<typename TYPE , uint SIZE>

using TemporaryStorageArray< TYPE, SIZE >::StorageInitType = std::array<uint16_t, SIZE>

Definition at line 135 of file newgrf_storage.h.

## ◆ StorageType

template<typename TYPE , uint SIZE>

using TemporaryStorageArray< TYPE, SIZE >::StorageType = std::array<TYPE, SIZE>

Definition at line 134 of file newgrf_storage.h.

## Member Function Documentation

## ◆ ClearChanges()

template<typename TYPE , uint SIZE>

void TemporaryStorageArray< TYPE, SIZE >::ClearChanges | ( |  | ) |
| inline

Definition at line 173 of file newgrf_storage.h.

## ◆ GetValue()

template<typename TYPE , uint SIZE>

TYPE TemporaryStorageArray< TYPE, SIZE >::GetValue | ( | uint | pos | ) | const
| inline

Gets the value from a given position.

Parameters

  pos | the position to get the data from

Returns
  the data from that position

Definition at line 160 of file newgrf_storage.h.

References TemporaryStorageArray< TYPE, SIZE >::init, and TemporaryStorageArray< TYPE, SIZE >::storage.

Referenced by ResolverObject::GetRegister().

## ◆ StoreValue()

template<typename TYPE , uint SIZE>

void TemporaryStorageArray< TYPE, SIZE >::StoreValue | ( | uint | pos,
|  | int32_t | value
| ) |  |
| inline

Stores some value at a given position.

Parameters

  pos | the position to write at
  value | the value to write

Definition at line 146 of file newgrf_storage.h.

References TemporaryStorageArray< TYPE, SIZE >::init, TemporaryStorageArray< TYPE, SIZE >::init_key, and TemporaryStorageArray< TYPE, SIZE >::storage.

Referenced by ResolverObject::SetRegister().

## Field Documentation

## ◆ init

template<typename TYPE , uint SIZE>

StorageInitType TemporaryStorageArray< TYPE, SIZE >::init {}

Storage has been assigned, if this equals 'init_key'.

Definition at line 138 of file newgrf_storage.h.

Referenced by TemporaryStorageArray< TYPE, SIZE >::GetValue(), and TemporaryStorageArray< TYPE, SIZE >::StoreValue().

## ◆ init_key

template<typename TYPE , uint SIZE>

uint16_t TemporaryStorageArray< TYPE, SIZE >::init_key = 1

Magic key to 'init'.

Definition at line 139 of file newgrf_storage.h.

Referenced by TemporaryStorageArray< TYPE, SIZE >::StoreValue().

## ◆ storage

template<typename TYPE , uint SIZE>

StorageType TemporaryStorageArray< TYPE, SIZE >::storage {}

Memory for the storage array.

Definition at line 137 of file newgrf_storage.h.

Referenced by TemporaryStorageArray< TYPE, SIZE >::GetValue(), and TemporaryStorageArray< TYPE, SIZE >::StoreValue().

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

- src/newgrf_storage.h