summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-03-25 22:40:43 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2013-03-25 23:06:06 +0100
commit4dfc82415691fe298f21bb2f81fed5c168ee14e5 (patch)
tree1e6d15038a64a2f962e3b8a7b8a4ad4b6f7e22d9 /src
parent4e9e0ac87b4dc16f19ac4f930d52c4cc0a2c6f64 (diff)
downloadmanaserv-4dfc82415691fe298f21bb2f81fed5c168ee14e5.tar.gz
manaserv-4dfc82415691fe298f21bb2f81fed5c168ee14e5.tar.xz
manaserv-4dfc82415691fe298f21bb2f81fed5c168ee14e5.zip
Moved documentation out of class definition
Inline documentation is in general needlessly verbose and only makes it harder to read the actual class API. This change moves this kind of documentation to the function implementation for the 'Entity' class. For inline methods, the implementation is moved outside of the class using the 'inline' keyword. This provides a good place to put the documentation, but it also further cleans up the class definition. The class definition now gives a much better overview over its API. And if needed, details can be looked up at the function implementations. Reviewed-by: Erik Schilling
Diffstat (limited to 'src')
-rw-r--r--src/game-server/entity.cpp3
-rw-r--r--src/game-server/entity.h162
2 files changed, 97 insertions, 68 deletions
diff --git a/src/game-server/entity.cpp b/src/game-server/entity.cpp
index 3593d90..cbfa96f 100644
--- a/src/game-server/entity.cpp
+++ b/src/game-server/entity.cpp
@@ -35,6 +35,9 @@ Entity::~Entity()
delete mComponents[i];
}
+/**
+ * Updates the internal status. By default, calls update on all its components.
+ */
void Entity::update()
{
for (int i = 0; i < ComponentTypeCount; ++i)
diff --git a/src/game-server/entity.h b/src/game-server/entity.h
index 7aed29e..9d418df 100644
--- a/src/game-server/entity.h
+++ b/src/game-server/entity.h
@@ -48,76 +48,21 @@ class Entity : public sigc::trackable
virtual ~Entity();
- /**
- * Gets type of this entity.
- *
- * @return the type of this entity.
- */
- EntityType getType() const
- { return mType; }
-
- /**
- * Adds a component. Only one component of a given type can be added.
- * Entity takes ownership of \a component.
- */
- template <class T>
- void addComponent(T *component)
- {
- assert(!mComponents[T::type]);
- mComponents[T::type] = component;
- }
-
- /**
- * Returns the component of the given type, or 0 when no such component
- * was set.
- */
- Component *getComponent(ComponentType type) const
- { return mComponents[type]; }
-
- /**
- * Get a component by its class. Avoids the need for doing a static-
- * cast in the calling code.
- */
- template <class T>
- T *getComponent() const
- { return static_cast<T*>(getComponent(T::type)); }
-
- /**
- * Returns whether this entity is visible on the map or not. (Actor)
- */
- bool isVisible() const
- { return mType != OBJECT_OTHER; }
-
- /**
- * Returns whether this entity can move on the map or not. (Actor)
- */
- bool canMove() const
- { return mType == OBJECT_CHARACTER || mType == OBJECT_MONSTER ||
- mType == OBJECT_NPC; }
-
- /**
- * Returns whether this entity can fight or not. (Being)
- */
- bool canFight() const
- { return mType == OBJECT_CHARACTER || mType == OBJECT_MONSTER; }
-
- /**
- * Updates the internal status. By default, calls update on all its
- * components.
- */
- virtual void update();
+ EntityType getType() const;
+
+ template <class T> void addComponent(T *component);
+ template <class T> T *getComponent() const;
+
+ Component *getComponent(ComponentType type) const;
- /**
- * Gets the map this entity is located on.
- */
- MapComposite *getMap() const
- { return mMap; }
+ bool isVisible() const;
+ bool canMove() const;
+ bool canFight() const;
- /**
- * Sets the map this entity is located on.
- */
- virtual void setMap(MapComposite *map)
- { mMap = map; }
+ virtual void update();
+
+ MapComposite *getMap() const;
+ virtual void setMap(MapComposite *map);
sigc::signal<void, Entity *> signal_inserted;
sigc::signal<void, Entity *> signal_removed;
@@ -129,4 +74,85 @@ class Entity : public sigc::trackable
Component *mComponents[ComponentTypeCount];
};
+/**
+ * Gets type of this entity.
+ *
+ * @return the type of this entity.
+ */
+inline EntityType Entity::getType() const
+{
+ return mType;
+}
+
+/**
+ * Adds a component. Only one component of a given type can be added.
+ * Entity takes ownership of \a component.
+ */
+template <class T>
+inline void Entity::addComponent(T *component)
+{
+ assert(!mComponents[T::type]);
+ mComponents[T::type] = component;
+}
+
+/**
+ * Returns the component of the given type, or 0 when no such component
+ * was set.
+ */
+inline Component *Entity::getComponent(ComponentType type) const
+{
+ return mComponents[type];
+}
+
+/**
+ * Get a component by its class. Avoids the need for doing a static-
+ * cast in the calling code.
+ */
+template <class T>
+inline T *Entity::getComponent() const
+{
+ return static_cast<T*>(getComponent(T::type));
+}
+
+/**
+ * Returns whether this entity is visible on the map or not. (Actor)
+ */
+inline bool Entity::isVisible() const
+{
+ return mType != OBJECT_OTHER;
+}
+
+/**
+ * Returns whether this entity can move on the map or not. (Actor)
+ */
+inline bool Entity::canMove() const
+{
+ return mType == OBJECT_CHARACTER || mType == OBJECT_MONSTER ||
+ mType == OBJECT_NPC;
+}
+
+/**
+ * Returns whether this entity can fight or not. (Being)
+ */
+inline bool Entity::canFight() const
+{
+ return mType == OBJECT_CHARACTER || mType == OBJECT_MONSTER;
+}
+
+/**
+ * Gets the map this entity is located on.
+ */
+inline MapComposite *Entity::getMap() const
+{
+ return mMap;
+}
+
+/**
+ * Sets the map this entity is located on.
+ */
+inline void Entity::setMap(MapComposite *map)
+{
+ mMap = map;
+}
+
#endif // ENTITY_H