# HG changeset patch # User cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1244920330 0 # Node ID 8eec4c078223733ef1121ab43b90e4e4556ca228 # Parent 475f83e227e04e687f4b86bed01a5e4a3bdf521e * Removed ObjectLoader as it was both unused and unusable (Closes #353) * Overloaded == and != operators to check if two objects are equal * Const correctness in FIFE::Object diff -r 475f83e227e0 -r 8eec4c078223 engine/core/model/metamodel/object.cpp --- a/engine/core/model/metamodel/object.cpp Sat Jun 13 15:47:16 2009 +0000 +++ b/engine/core/model/metamodel/object.cpp Sat Jun 13 19:12:10 2009 +0000 @@ -81,7 +81,7 @@ return a; } - Action* Object::getAction(const std::string& identifier) { + Action* Object::getAction(const std::string& identifier) const { std::map::const_iterator i; if (m_actions) { i = m_actions->find(identifier); @@ -99,7 +99,7 @@ m_pather = pather; } - bool Object::isBlocking() { + bool Object::isBlocking() const { if (m_blocking) { return true; } @@ -109,7 +109,7 @@ return false; } - bool Object::isStatic() { + bool Object::isStatic() const { if (m_static) { return true; } @@ -118,4 +118,12 @@ } return false; } + + bool Object::operator==(const Object& obj) const { + return m_id == obj.getId() && m_namespace == obj.getNamespace(); + } + + bool Object::operator!=(const Object& obj) const { + return m_id != obj.getId() || m_namespace != obj.getNamespace(); + } } diff -r 475f83e227e0 -r 8eec4c078223 engine/core/model/metamodel/object.h --- a/engine/core/model/metamodel/object.h Sat Jun 13 15:47:16 2009 +0000 +++ b/engine/core/model/metamodel/object.h Sat Jun 13 19:12:10 2009 +0000 @@ -65,8 +65,8 @@ */ ~Object(); - const std::string& getId() { return m_id; } - const std::string& getNamespace() { return m_namespace; } + const std::string& getId() const { return m_id; } + const std::string& getNamespace() const { return m_namespace; } /** Adds new action with given id. In case there is action already * with given id, returns it instead of new object @@ -81,11 +81,11 @@ /** Gets action with given id. If not found, returns NULL */ - Action* getAction(const std::string& identifier); + Action* getAction(const std::string& identifier) const; /** Gets default action assigned to this object. If none available, returns NULL */ - Action* getDefaultAction() { return m_defaultaction; } + Action* getDefaultAction() const { return m_defaultaction; } /** Sets pather used by instances created out of this object */ @@ -93,12 +93,12 @@ /** Gets associated pather */ - AbstractPather* getPather() { return m_pather; } + AbstractPather* getPather() const { return m_pather; } /** Gets an object where this object was inherited from * @see inherited object */ - Object* getInherited() { return m_inherited; } + Object* getInherited() const { return m_inherited; } /** Sets visualization to be used. Transfers ownership. */ @@ -114,7 +114,7 @@ /** Gets if object blocks movement */ - bool isBlocking(); + bool isBlocking() const; /** Set to true, if object is such that it doesn't move */ @@ -122,8 +122,10 @@ /** Gets if object moves */ - bool isStatic(); + bool isStatic() const; + bool operator==(const Object& obj) const; + bool operator!=(const Object& obj) const; private: std::string m_id; @@ -137,12 +139,6 @@ Action* m_defaultaction; }; - class ObjectLoader : public ResourceLoader { - public: - Object* load(const ResourceLocation& location) { return dynamic_cast(load(location)); } - Object* load(const std::string& filename) { return load(ResourceLocation(filename)); } - }; - } //FIFE #endif diff -r 475f83e227e0 -r 8eec4c078223 engine/core/model/metamodel/object.i --- a/engine/core/model/metamodel/object.i Sat Jun 13 15:47:16 2009 +0000 +++ b/engine/core/model/metamodel/object.i Sat Jun 13 19:12:10 2009 +0000 @@ -37,30 +37,28 @@ Object(const std::string& identifier, const std::string& name_space, Object* inherited=NULL); ~Object(); - const std::string& getId(); - const std::string& getNamespace(); + const std::string& getId() const { return m_id; } + const std::string& getNamespace() const { return m_namespace; } Action* createAction(const std::string& identifier, bool is_default=false); - Action* getAction(const std::string& identifier); - Action* getDefaultAction(); + Action* getAction(const std::string& identifier) const; + Action* getDefaultAction() const { return m_defaultaction; } void setPather(AbstractPather* pather); - AbstractPather* getPather(); + AbstractPather* getPather() const { return m_pather; } + + Object* getInherited() const { return m_inherited; } + void adoptVisual(AbstractVisual* visual) { m_visual = visual; } + template T* getVisual() const { return reinterpret_cast(m_visual); } - Object* getInherited(); - void adoptVisual(AbstractVisual* visual); - template T* getVisual() const; - - void setBlocking(bool blocking); - bool isBlocking(); - - void setStatic(bool stat); - bool isStatic(); - }; + void setBlocking(bool blocking) { m_blocking = blocking; } + bool isBlocking() const; - class ObjectLoader : public ResourceLoader { - public: - Object* load(const ResourceLocation& location); - Object* load(const std::string& filename); + void setStatic(bool stat) { m_static = stat; } + bool isStatic() const; + + bool operator==(const Object& obj) const; + bool operator!=(const Object& obj) const; + }; }