2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
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.
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.
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
22 #if !defined(INCLUDED_IENTITY_H)
23 #define INCLUDED_IENTITY_H
25 #include "generic/constant.h"
27 #include "string/string.h"
35 STRING_CONSTANT(Name, "Entity");
40 virtual void visit(const char* key, const char* value) = 0;
43 virtual const EntityClass& getEntityClass() const = 0;
44 virtual void forEachKeyValue(Visitor& visitor) const = 0;
45 virtual void setKeyValue(const char* key, const char* value) = 0;
46 virtual const char* getKeyValue(const char* key) const = 0;
47 virtual bool isContainer() const = 0;
50 class EntityCopyingVisitor : public Entity::Visitor
54 EntityCopyingVisitor(Entity& entity)
59 void visit(const char* key, const char* value)
61 if(!string_equal(key, "classname"))
63 m_entity.setKeyValue(key, value);
68 inline Entity* Node_getEntity(scene::Node& node)
70 return NodeTypeCast<Entity>::cast(node);
74 template<typename value_type>
76 template<typename Contained>
84 typedef Reference<scene::Node> NodeReference;
88 typedef Stack<NodeReference> Path;
96 INTEGER_CONSTANT(Version, 2);
97 STRING_CONSTANT(Name, "entity");
99 virtual scene::Node& createEntity(EntityClass* eclass) = 0;
101 typedef void (*KeyValueChangedFunc)();
102 virtual void setKeyValueChangedFunc(KeyValueChangedFunc func) = 0;
104 virtual void setCounter(Counter* counter) = 0;
106 virtual void connectEntities(const scene::Path& e1, const scene::Path& e2) = 0;
108 virtual void setLightRadii(bool lightRadii) = 0;
109 virtual bool getLightRadii() = 0;
110 virtual void setShowNames(bool showNames) = 0;
111 virtual bool getShowNames() = 0;
112 virtual void setShowAngles(bool showAngles) = 0;
113 virtual bool getShowAngles() = 0;
116 #include "modulesystem.h"
118 template<typename Type>
120 typedef GlobalModule<EntityCreator> GlobalEntityModule;
122 template<typename Type>
123 class GlobalModuleRef;
124 typedef GlobalModuleRef<EntityCreator> GlobalEntityModuleRef;
126 inline EntityCreator& GlobalEntityCreator()
128 return GlobalEntityModule::getTable();