00001 /* 00002 Copyright (C) 1999-2006 Id Software, Inc. and contributors. 00003 For a list of contributors, see the accompanying CONTRIBUTORS file. 00004 00005 This file is part of GtkRadiant. 00006 00007 GtkRadiant is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2 of the License, or 00010 (at your option) any later version. 00011 00012 GtkRadiant is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GtkRadiant; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00024 00025 00026 #if !defined(INCLUDED_IECLASS_H) 00027 #define INCLUDED_IECLASS_H 00028 00029 #include "generic/constant.h" 00030 00031 #define MAX_FLAGS 16 00032 00033 class Shader; 00034 00035 class EntityClass; 00036 class ListAttributeType; 00037 00038 class EntityClassCollector 00039 { 00040 public: 00041 virtual ~EntityClassCollector () 00042 { 00043 } 00044 00045 virtual void insert (EntityClass* eclass) = 0; 00046 virtual void insert (const char* name, const ListAttributeType& list) 00047 { 00048 } 00049 }; 00050 00052 struct EntityClassScanner 00053 { 00054 INTEGER_CONSTANT(Version, 1); 00055 STRING_CONSTANT(Name, "eclass"); 00056 00057 void (*scanFile) (EntityClassCollector& collector, const std::string& filename); 00058 const std::string (*getFilename) (); 00059 }; 00060 00061 #include "modulesystem.h" 00062 00063 template<typename Type> 00064 class ModuleRef; 00065 typedef ModuleRef<EntityClassScanner> EClassModuleRef; 00066 00067 template<typename Type> 00068 class Modules; 00069 typedef Modules<EntityClassScanner> EClassModules; 00070 00071 template<typename Type> 00072 class ModulesRef; 00073 typedef ModulesRef<EntityClassScanner> EClassModulesRef; 00074 00075 class EntityClassVisitor 00076 { 00077 public: 00078 virtual ~EntityClassVisitor () 00079 { 00080 } 00081 virtual void visit (EntityClass* eclass) = 0; 00082 }; 00083 00084 class ModuleObserver; 00085 00090 struct EntityClassManager 00091 { 00092 INTEGER_CONSTANT(Version, 1); 00093 STRING_CONSTANT(Name, "eclassmanager"); 00094 00095 EntityClass* (*findOrInsert) (const std::string& name, bool has_brushes); 00096 const ListAttributeType* (*findListType) (const std::string& name); 00097 void (*forEach) (EntityClassVisitor& visitor); 00098 void (*attach) (ModuleObserver& observer); 00099 void (*detach) (ModuleObserver& observer); 00100 void (*realise) (); 00101 void (*unrealise) (); 00102 }; 00103 00104 template<typename Type> 00105 class GlobalModule; 00106 typedef GlobalModule<EntityClassManager> GlobalEntityClassManagerModule; 00107 00108 template<typename Type> 00109 class GlobalModuleRef; 00110 typedef GlobalModuleRef<EntityClassManager> GlobalEntityClassManagerModuleRef; 00111 00112 inline EntityClassManager& GlobalEntityClassManager () 00113 { 00114 return GlobalEntityClassManagerModule::getTable(); 00115 } 00116 00117 #endif