16template <
typename Tindex>
25template <
typename Tspec,
typename Tindex>
29 static_assert(std::is_base_of_v<NewGRFSpecBase<Tindex>, Tspec>);
39 static inline std::vector<NewGRFClass<Tspec, Tindex>>
classes;
45 using spec_type = Tspec;
46 using index_type = Tindex;
58 std::span<Tspec * const>
Specs()
const {
return this->spec; }
68 Tindex Index()
const {
return this->index; }
74 uint
GetSpecCount()
const {
return static_cast<uint
>(this->spec.size()); }
96 static NewGRFClass *
Get(Tindex class_index);
98 static const Tspec *
GetByGrf(uint32_t grfid, uint16_t local_id);
static Tindex Allocate(uint32_t global_id)
Allocate a class with a given global class ID.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
static void Reset()
Reset the classes, i.e.
static void InsertDefaults()
Initialise the defaults.
std::span< Tspec *const > Specs() const
Get read-only span of specs of this class.
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
uint GetSpecCount() const
Get the number of allocated specs within the class.
void Insert(Tspec *spec)
Insert a spec into the class, and update its index.
std::vector< AirportSpec * > spec
static uint GetUIClassCount()
Get the number of classes available to the user.
static std::span< NewGRFClass< Tspec, Tindex > const > Classes()
Get read-only span of all classes of this type.
static std::vector< NewGRFClass< AirportSpec, AirportClassID > > classes
static void Assign(Tspec *spec)
Assign a spec to one of the classes.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
static uint GetClassCount()
Get the number of allocated classes.
static const Tspec * GetByGrf(uint32_t grfid, uint16_t local_id)
Retrieve a spec by GRF location.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Base for each type of NewGRF spec to be used with NewGRFClass.
uint16_t index
Index within class of this spec, invalid until inserted into class.
Tindex class_index
Class index of this spec, invalid until class is allocated.