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"
32 typedef Callback<void(const char*)> KeyObserver;
37 virtual ~EntityKeyValue() = default;
38 virtual const char* c_str() const = 0;
39 virtual void assign( const char* other ) = 0;
40 virtual void attach( const KeyObserver& observer ) = 0;
41 virtual void detach( const KeyObserver& observer ) = 0;
47 STRING_CONSTANT( Name, "Entity" );
52 virtual void insert( const char* key, EntityKeyValue& value ) = 0;
53 virtual void erase( const char* key, EntityKeyValue& value ) = 0;
54 virtual void clear() { };
60 virtual void visit( const char* key, const char* value ) = 0;
63 virtual const EntityClass& getEntityClass() const = 0;
64 virtual void forEachKeyValue( Visitor& visitor ) const = 0;
65 virtual void setKeyValue( const char* key, const char* value ) = 0;
66 virtual const char* getKeyValue( const char* key ) const = 0;
67 virtual bool isContainer() const = 0;
68 virtual void attach( Observer& observer ) = 0;
69 virtual void detach( Observer& observer ) = 0;
72 class EntityCopyingVisitor : public Entity::Visitor
76 EntityCopyingVisitor( Entity& entity )
80 void visit( const char* key, const char* value ){
81 if ( !string_equal( key, "classname" ) ) {
82 m_entity.setKeyValue( key, value );
87 inline Entity* Node_getEntity( scene::Node& node ){
88 return NodeTypeCast<Entity>::cast( node );
92 template<typename value_type>
94 template<typename Contained>
102 typedef Reference<scene::Node> NodeReference;
106 typedef Stack<NodeReference> Path;
114 INTEGER_CONSTANT( Version, 2 );
115 STRING_CONSTANT( Name, "entity" );
117 virtual scene::Node& createEntity( EntityClass* eclass ) = 0;
119 typedef void ( *KeyValueChangedFunc )();
120 virtual void setKeyValueChangedFunc( KeyValueChangedFunc func ) = 0;
122 virtual void setCounter( Counter* counter ) = 0;
124 virtual void connectEntities( const scene::Path& e1, const scene::Path& e2, int index ) = 0;
126 virtual void setLightRadii( bool lightRadii ) = 0;
127 virtual bool getLightRadii() = 0;
128 virtual void setShowNames( bool showNames ) = 0;
129 virtual bool getShowNames() = 0;
130 virtual void setShowAngles( bool showAngles ) = 0;
131 virtual bool getShowAngles() = 0;
133 virtual void printStatistics() const = 0;
136 #include "modulesystem.h"
138 template<typename Type>
140 typedef GlobalModule<EntityCreator> GlobalEntityModule;
142 template<typename Type>
143 class GlobalModuleRef;
144 typedef GlobalModuleRef<EntityCreator> GlobalEntityModuleRef;
146 inline EntityCreator& GlobalEntityCreator(){
147 return GlobalEntityModule::getTable();