X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fnetradiant.git;a=blobdiff_plain;f=include%2Fientity.h;h=dd3f253c8082be09116f28f25c213f776adae627;hp=c74ed7c625de4568dc675ca772fda3195b9f4fa6;hb=bbc02ec651dae2fe14d30941b841980161345dd6;hpb=bfc8a12a6b315ae261101a34db8ba1b682c67bb7 diff --git a/include/ientity.h b/include/ientity.h index c74ed7c6..dd3f253c 100644 --- a/include/ientity.h +++ b/include/ientity.h @@ -1,25 +1,25 @@ /* -Copyright (C) 2001-2006, William Joseph. -All Rights Reserved. + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ -#if !defined(INCLUDED_IENTITY_H) +#if !defined( INCLUDED_IENTITY_H ) #define INCLUDED_IENTITY_H #include "generic/constant.h" @@ -29,66 +29,63 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class EntityClass; -typedef Callback1 KeyObserver; +typedef Callback KeyObserver; class EntityKeyValue { public: - virtual const char* c_str() const = 0; - virtual void assign(const char* other) = 0; - virtual void attach(const KeyObserver& observer) = 0; - virtual void detach(const KeyObserver& observer) = 0; +virtual ~EntityKeyValue() = default; +virtual const char* c_str() const = 0; +virtual void assign( const char* other ) = 0; +virtual void attach( const KeyObserver& observer ) = 0; +virtual void detach( const KeyObserver& observer ) = 0; }; class Entity { public: - STRING_CONSTANT(Name, "Entity"); - - class Observer - { - public: - virtual void insert(const char* key, EntityKeyValue& value) = 0; - virtual void erase(const char* key, EntityKeyValue& value) = 0; - virtual void clear() { }; - }; - - class Visitor - { - public: - virtual void visit(const char* key, const char* value) = 0; - }; - - virtual const EntityClass& getEntityClass() const = 0; - virtual void forEachKeyValue(Visitor& visitor) const = 0; - virtual void setKeyValue(const char* key, const char* value) = 0; - virtual const char* getKeyValue(const char* key) const = 0; - virtual bool isContainer() const = 0; - virtual void attach(Observer& observer) = 0; - virtual void detach(Observer& observer) = 0; +STRING_CONSTANT( Name, "Entity" ); + +class Observer +{ +public: +virtual void insert( const char* key, EntityKeyValue& value ) = 0; +virtual void erase( const char* key, EntityKeyValue& value ) = 0; +virtual void clear() { }; }; -class EntityCopyingVisitor : public Entity::Visitor +class Visitor { - Entity& m_entity; public: - EntityCopyingVisitor(Entity& entity) - : m_entity(entity) - { - } - - void visit(const char* key, const char* value) - { - if(!string_equal(key, "classname")) - { - m_entity.setKeyValue(key, value); - } - } +virtual void visit( const char* key, const char* value ) = 0; }; -inline Entity* Node_getEntity(scene::Node& node) +virtual const EntityClass& getEntityClass() const = 0; +virtual void forEachKeyValue( Visitor& visitor ) const = 0; +virtual void setKeyValue( const char* key, const char* value ) = 0; +virtual const char* getKeyValue( const char* key ) const = 0; +virtual bool isContainer() const = 0; +virtual void attach( Observer& observer ) = 0; +virtual void detach( Observer& observer ) = 0; +}; + +class EntityCopyingVisitor : public Entity::Visitor { - return NodeTypeCast::cast(node); +Entity& m_entity; +public: +EntityCopyingVisitor( Entity& entity ) + : m_entity( entity ){ +} + +void visit( const char* key, const char* value ){ + if ( !string_equal( key, "classname" ) ) { + m_entity.setKeyValue( key, value ); + } +} +}; + +inline Entity* Node_getEntity( scene::Node& node ){ + return NodeTypeCast::cast( node ); } @@ -99,14 +96,14 @@ class Reference; namespace scene { - class Node; +class Node; } typedef Reference NodeReference; namespace scene { - typedef Stack Path; +typedef Stack Path; } class Counter; @@ -114,26 +111,26 @@ class Counter; class EntityCreator { public: - INTEGER_CONSTANT(Version, 2); - STRING_CONSTANT(Name, "entity"); +INTEGER_CONSTANT( Version, 2 ); +STRING_CONSTANT( Name, "entity" ); - virtual scene::Node& createEntity(EntityClass* eclass) = 0; +virtual scene::Node& createEntity( EntityClass* eclass ) = 0; - typedef void (*KeyValueChangedFunc)(); - virtual void setKeyValueChangedFunc(KeyValueChangedFunc func) = 0; +typedef void ( *KeyValueChangedFunc )(); +virtual void setKeyValueChangedFunc( KeyValueChangedFunc func ) = 0; - virtual void setCounter(Counter* counter) = 0; +virtual void setCounter( Counter* counter ) = 0; - virtual void connectEntities(const scene::Path& e1, const scene::Path& e2, int index) = 0; +virtual void connectEntities( const scene::Path& e1, const scene::Path& e2, int index ) = 0; - virtual void setLightRadii(bool lightRadii) = 0; - virtual bool getLightRadii() = 0; - virtual void setShowNames(bool showNames) = 0; - virtual bool getShowNames() = 0; - virtual void setShowAngles(bool showAngles) = 0; - virtual bool getShowAngles() = 0; +virtual void setLightRadii( bool lightRadii ) = 0; +virtual bool getLightRadii() const = 0; +virtual void setShowNames( bool showNames ) = 0; +virtual bool getShowNames() = 0; +virtual void setShowAngles( bool showAngles ) = 0; +virtual bool getShowAngles() = 0; - virtual void printStatistics() const = 0; +virtual void printStatistics() const = 0; }; #include "modulesystem.h" @@ -146,9 +143,8 @@ template class GlobalModuleRef; typedef GlobalModuleRef GlobalEntityModuleRef; -inline EntityCreator& GlobalEntityCreator() -{ - return GlobalEntityModule::getTable(); +inline EntityCreator& GlobalEntityCreator(){ + return GlobalEntityModule::getTable(); } #endif