Mercurial > fife-parpg
changeset 306:6177cdf72489
- added new method to object class: getActionIds()
- cleanup to *.i file (replaced redundant code by including header file)
FEATURES:
- objects can now provide a list of action ids of all actions they were set up with
author | chewie@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 08 Aug 2009 14:24:35 +0000 |
parents | e25cfb3fe58e |
children | 22253b2c9b14 |
files | engine/core/model/metamodel/object.cpp engine/core/model/metamodel/object.h engine/core/model/metamodel/object.i |
diffstat | 3 files changed, 21 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/model/metamodel/object.cpp Fri Aug 07 21:11:28 2009 +0000 +++ b/engine/core/model/metamodel/object.cpp Sat Aug 08 14:24:35 2009 +0000 @@ -94,6 +94,18 @@ } return i->second; } + + std::list<std::string> Object::getActionIds() const { + std::list<std::string> action_ids; + action_ids.clear(); + if (m_actions) { + std::map<std::string, Action*>::const_iterator actions_it = m_actions->begin(); + for(; actions_it != m_actions->end(); ++actions_it) { + action_ids.push_back(actions_it->first); + } + } + return action_ids; + } void Object::setPather(AbstractPather* pather) { m_pather = pather; @@ -126,4 +138,5 @@ bool Object::operator!=(const Object& obj) const { return m_id != obj.getId() || m_namespace != obj.getNamespace(); } + }
--- a/engine/core/model/metamodel/object.h Fri Aug 07 21:11:28 2009 +0000 +++ b/engine/core/model/metamodel/object.h Sat Aug 08 14:24:35 2009 +0000 @@ -25,6 +25,7 @@ // Standard C++ library includes #include <string> #include <map> +#include <list> // 3rd party library includes @@ -64,7 +65,7 @@ /** Destructor */ ~Object(); - + const std::string& getId() const { return m_id; } const std::string& getNamespace() const { return m_namespace; } @@ -83,6 +84,10 @@ */ Action* getAction(const std::string& identifier) const; + /** Gets all available action ids of the object and packs them into a list + */ + std::list<std::string> getActionIds() const; + /** Gets default action assigned to this object. If none available, returns NULL */ Action* getDefaultAction() const { return m_defaultaction; } @@ -126,7 +131,7 @@ bool operator==(const Object& obj) const; bool operator!=(const Object& obj) const; - + private: std::string m_id; std::string m_namespace;
--- a/engine/core/model/metamodel/object.i Fri Aug 07 21:11:28 2009 +0000 +++ b/engine/core/model/metamodel/object.i Sat Aug 08 14:24:35 2009 +0000 @@ -26,39 +26,4 @@ %include "util/base/utilbase.i" %include "model/metamodel/abstractvisual.i" - -namespace FIFE { - - class Action; - class AbstractPather; - - class Object : public ResourceClass { - public: - Object(const std::string& identifier, const std::string& name_space, Object* inherited=NULL); - ~Object(); - - 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) const; - Action* getDefaultAction() const { return m_defaultaction; } - - void setPather(AbstractPather* pather); - 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); } - - void setBlocking(bool blocking) { m_blocking = blocking; } - bool isBlocking() const; - - void setStatic(bool stat) { m_static = stat; } - bool isStatic() const; - - bool operator==(const Object& obj) const; - bool operator!=(const Object& obj) const; - - }; -} +%include "model/metamodel/object.h"