00001 /* $Id: newgrf_class.h 21593 2010-12-22 10:50:32Z alberth $ */ 00002 00003 /* 00004 * This file is part of OpenTTD. 00005 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. 00006 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00007 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. 00008 */ 00009 00012 #ifndef NEWGRF_CLASS_H 00013 #define NEWGRF_CLASS_H 00014 00015 #include "strings_type.h" 00016 00020 template <typename Tspec, typename Tid, Tid Tmax> 00021 struct NewGRFClass { 00022 uint32 global_id; 00023 StringID name; 00024 uint count; 00025 Tspec **spec; 00026 00028 static NewGRFClass<Tspec, Tid, Tmax> classes[Tmax]; 00029 00031 static void Reset(); 00032 00034 static void InsertDefaults(); 00035 00043 static Tid Allocate(uint32 global_id); 00044 00051 static void SetName(Tid cls_id, StringID name); 00052 00058 static void Assign(Tspec *spec); 00059 00060 00067 static StringID GetName(Tid cls_id); 00068 00073 static uint GetCount(); 00074 00081 static uint GetCount(Tid cls_id); 00082 00090 static const Tspec *Get(Tid cls_id, uint index); 00091 00099 static const Tspec *GetByGrf(uint32 grfid, byte local_id, int *index); 00100 }; 00101 00102 #endif /* NEWGRF_CLASS_H */