16template <
typename Tindex>
25template <
typename Tspec,
typename Tindex, Tindex Tmax>
29 static_assert(std::is_base_of_v<NewGRFSpecBase<Tindex>, Tspec>);
32 Tindex
index =
static_cast<Tindex
>(0);
39 static inline std::vector<NewGRFClass<Tspec, Tindex, Tmax>>
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; }
70 uint
GetSpecCount()
const {
return static_cast<uint
>(this->spec.size()); }
84 static NewGRFClass *
Get(Tindex class_index);
86 static const Tspec *
GetByGrf(uint32_t grfid, uint16_t local_id);
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
static void Assign(Tspec *spec)
Assign a spec to one of the classes.
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
void Insert(Tspec *spec)
Insert a spec into the class, and update its index.
bool IsUIAvailable(uint index) const
Check whether the spec will be available to the user at some point in time.
std::span< Tspec *const > Specs() const
Get read-only span of specs of this class.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
static void InsertDefaults()
Initialise the defaults.
static uint GetUIClassCount()
Get the number of classes available to the user.
static Tindex Allocate(uint32_t global_id)
Allocate a class with a given global class ID.
static const Tspec * GetByGrf(uint32_t grfid, uint16_t local_id)
Retrieve a spec by GRF location.
std::vector< AirportSpec * > spec
uint GetSpecCount() const
Get the number of allocated specs within the class.
static uint GetClassCount()
Get the number of allocated classes.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
static std::vector< NewGRFClass< AirportSpec, AirportClassID, Tmax > > classes
static void Reset()
Reset the classes, i.e.
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
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.