[coco] Add 'input' method to EntityManager (#762)
author박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 <jh1302.park@samsung.com>
Mon, 23 Jul 2018 05:33:16 +0000 (14:33 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Mon, 23 Jul 2018 05:33:16 +0000 (14:33 +0900)
This commit adds pure virtual 'input' method (which returns a pointer of
InputManager) to EntityManager, and updates the corresponding
implementation in Module.

Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
contrib/coco/core/include/coco/IR/EntityManager.h
contrib/coco/core/src/IR/Module.cpp
contrib/coco/core/src/IR/Module.test.cpp

index 82d1417..66ff8c5 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __COCO_IR_ENTITY_MANAGER_H__
 #define __COCO_IR_ENTITY_MANAGER_H__
 
+#include "coco/IR/InputManager.h"
+
 namespace coco
 {
 
@@ -13,6 +15,9 @@ namespace coco
 struct EntityManager
 {
   virtual ~EntityManager() = default;
+
+  virtual InputManager *input(void) = 0;
+  virtual const InputManager *input(void) const = 0;
 };
 
 } // namespace coco
index 35eb99e..6d21a1e 100644 (file)
@@ -7,7 +7,12 @@ namespace
 
 struct EntityManagerImpl final : public coco::EntityManager
 {
-  // TO BE FILLED
+public:
+  std::unique_ptr<coco::InputManager> _input;
+
+public:
+  coco::InputManager *input(void) override { return _input.get(); }
+  const coco::InputManager *input(void) const override { return _input.get(); }
 };
 
 } // namespace
@@ -33,8 +38,12 @@ namespace coco
 std::unique_ptr<Module> Module::create(void)
 {
   auto m = nncc::foundation::make_unique<::ModuleImpl>();
-  
-  m->_entity = nncc::foundation::make_unique<::EntityManagerImpl>();
+
+  auto mgr = nncc::foundation::make_unique<::EntityManagerImpl>();
+  {
+    mgr->_input = nncc::foundation::make_unique<coco::InputManager>();
+  }
+  m->_entity = std::move(mgr);
 
   return std::move(m);
 }
index e1edace..c104eca 100644 (file)
@@ -13,4 +13,7 @@ TEST(IR_MODULE, create)
 
   ASSERT_NE(mutable_m->entity(), nullptr);
   ASSERT_NE(immutable_m->entity(), nullptr);
+
+  ASSERT_NE(mutable_m->entity()->input(), nullptr);
+  ASSERT_EQ(immutable_m->entity()->input(), mutable_m->entity()->input());
 }