Mercurial > fife-parpg
changeset 267:8eec4c078223
* 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
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 13 Jun 2009 19:12:10 +0000 |
parents | 475f83e227e0 |
children | 281159a9672c |
files | engine/core/model/metamodel/object.cpp engine/core/model/metamodel/object.h engine/core/model/metamodel/object.i |
diffstat | 3 files changed, 38 insertions(+), 36 deletions(-) [+] |
line wrap: on
line diff
--- 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<std::string, Action*>::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(); + } }
--- 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<Object*>(load(location)); } - Object* load(const std::string& filename) { return load(ResourceLocation(filename)); } - }; - } //FIFE #endif
--- 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<typename T> T* getVisual() const { return reinterpret_cast<T*>(m_visual); } - Object* getInherited(); - void adoptVisual(AbstractVisual* visual); - template<typename T> 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; + }; }