]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - include/ieclass.h
git-svn-id: svn://svn.icculus.org/netradiant/trunk@54 61c419a2-8eb2-4b30-bcec-8cead03...
[xonotic/netradiant.git] / include / ieclass.h
1 /*
2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21
22 /// \file ieclass.h
23 /// \brief Entity Class definition loader API.
24
25
26 #if !defined(INCLUDED_IECLASS_H)
27 #define INCLUDED_IECLASS_H
28
29 #include "generic/constant.h"
30
31 #define MAX_FLAGS       16
32
33 // eclass show flags
34
35 #define     ECLASS_LIGHT      0x00000001
36 #define     ECLASS_ANGLE      0x00000002
37 #define     ECLASS_PATH       0x00000004
38 #define     ECLASS_MISCMODEL  0x00000008
39
40 class Shader;
41
42 class EntityClass;
43 class ListAttributeType;
44
45 class EntityClassCollector
46 {
47 public:
48   virtual void insert(EntityClass* eclass) = 0;
49   virtual void insert(const char* name, const ListAttributeType& list)
50   {
51   }
52 };
53
54 struct EntityClassScanner
55 {
56   INTEGER_CONSTANT(Version, 1);
57   STRING_CONSTANT(Name, "eclass");
58
59   void (*scanFile)(EntityClassCollector& collector, const char* filename);
60   const char* (*getExtension)();
61 };
62
63 #include "modulesystem.h"
64
65 template<typename Type>
66 class ModuleRef;
67 typedef ModuleRef<EntityClassScanner> EClassModuleRef;
68
69 template<typename Type>
70 class Modules;
71 typedef Modules<EntityClassScanner> EClassModules;
72
73 template<typename Type>
74 class ModulesRef;
75 typedef ModulesRef<EntityClassScanner> EClassModulesRef;
76
77
78
79
80
81
82 class EntityClassVisitor
83 {
84 public:
85   virtual void visit(EntityClass* eclass) = 0;
86 };
87
88 class ModuleObserver;
89
90
91 struct EntityClassManager
92 {
93   INTEGER_CONSTANT(Version, 1);
94   STRING_CONSTANT(Name, "eclassmanager");
95
96   EntityClass* (*findOrInsert)(const char* name, bool has_brushes);
97   const ListAttributeType* (*findListType)(const char* name);
98   void (*forEach)(EntityClassVisitor& visitor);
99   void (*attach)(ModuleObserver& observer);
100   void (*detach)(ModuleObserver& observer);
101   void (*realise)();
102   void (*unrealise)();
103 };
104
105 template<typename Type>
106 class GlobalModule;
107 typedef GlobalModule<EntityClassManager> GlobalEntityClassManagerModule;
108
109 template<typename Type>
110 class GlobalModuleRef;
111 typedef GlobalModuleRef<EntityClassManager> GlobalEntityClassManagerModuleRef;
112
113 inline EntityClassManager& GlobalEntityClassManager()
114 {
115   return GlobalEntityClassManagerModule::getTable();
116 }
117
118 #endif