]> code.bitgloo.com Git - clyne/entityx.git/commitdiff
Override Entity::component() to return a const ComponentHandle
authorXiang Wei <weixiang77@gmail.com>
Thu, 19 Jun 2014 12:00:39 +0000 (08:00 -0400)
committerXiang Wei <weixiang77@gmail.com>
Thu, 19 Jun 2014 12:00:39 +0000 (08:00 -0400)
entityx/Entity.h

index 3504f6f1317c37e8b3e941a43549820fee1b77d0..51ecb03d6f11f91d92ecce1588e312c75f963ed2 100644 (file)
@@ -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;
 
@@ -783,6 +786,12 @@ ComponentHandle<C> Entity::component() {
   return manager_->component<C>(id_);
 }
 
+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());