aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXiang Wei <weixiang77@gmail.com>2014-06-19 08:00:39 -0400
committerXiang Wei <weixiang77@gmail.com>2014-06-19 08:00:39 -0400
commit5b8e0ae73b4a5c9e19050ceb2b045dd0f5f8b54e (patch)
tree95551cf1a291cb5cf3fc64145f013f24ad8e688f
parentf7870b61d8afc76485af5fdab2599d261444db96 (diff)
Override Entity::component() to return a const ComponentHandle
-rw-r--r--entityx/Entity.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/entityx/Entity.h b/entityx/Entity.h
index 3504f6f..51ecb03 100644
--- a/entityx/Entity.h
+++ b/entityx/Entity.h
@@ -130,7 +130,10 @@ public:
template <typename C>
ComponentHandle<C> component();
-
+
+ template <typename C>
+ const ComponentHandle<const C> component() const;
+
template <typename C>
bool has_component() const;
@@ -784,6 +787,12 @@ ComponentHandle<C> Entity::component() {
}
template <typename C>
+const ComponentHandle<const C> Entity::component() const {
+ assert(valid());
+ return manager_->component<const C>(id_);
+}
+
+template <typename C>
bool Entity::has_component() const {
assert(valid());
return manager_->has_component<C>(id_);