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;
insert(const char * name,const ListAttributeType & list)49 virtual void insert( const char* name, const ListAttributeType& list ){
50 }
51 };
52
53 struct EntityClassScanner
54 {
55 INTEGER_CONSTANT( Version, 1 );
56 STRING_CONSTANT( Name, "eclass" );
57
58 void ( *scanFile )( EntityClassCollector& collector, const char* filename );
59 const char* ( *getExtension )( );
60 };
61
62 #include "modulesystem.h"
63
64 template<typename Type>
65 class ModuleRef;
66 typedef ModuleRef<EntityClassScanner> EClassModuleRef;
67
68 template<typename Type>
69 class Modules;
70 typedef Modules<EntityClassScanner> EClassModules;
71
72 template<typename Type>
73 class ModulesRef;
74 typedef ModulesRef<EntityClassScanner> EClassModulesRef;
75
76
77
78
79
80
81 class EntityClassVisitor
82 {
83 public:
84 virtual void visit( EntityClass* eclass ) = 0;
85 };
86
87 class ModuleObserver;
88
89
90 struct EntityClassManager
91 {
92 INTEGER_CONSTANT( Version, 1 );
93 STRING_CONSTANT( Name, "eclassmanager" );
94
95 EntityClass* ( *findOrInsert )( const char* name, bool has_brushes );
96 const ListAttributeType* ( *findListType )(const char* name);
97 void ( *forEach )( EntityClassVisitor& visitor );
98 void ( *attach )( ModuleObserver& observer );
99 void ( *detach )( ModuleObserver& observer );
100 void ( *realise )();
101 void ( *unrealise )();
102 };
103
104 template<typename Type>
105 class GlobalModule;
106 typedef GlobalModule<EntityClassManager> GlobalEntityClassManagerModule;
107
108 template<typename Type>
109 class GlobalModuleRef;
110 typedef GlobalModuleRef<EntityClassManager> GlobalEntityClassManagerModuleRef;
111
GlobalEntityClassManager()112 inline EntityClassManager& GlobalEntityClassManager(){
113 return GlobalEntityClassManagerModule::getTable();
114 }
115
116 #endif
117