From 32764c940a0759be82b2c3d096d9875a0970e730 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Thu, 19 Jul 2018 10:05:20 +0900 Subject: [PATCH] [nest] Add 'DomainContext' field to 'Module' (#711) This commit adds 'DomainContext' field and related methods to 'Module' in order to allow users to build domains through module instance. Signed-off-by: Jonghyun Park --- contrib/nest/include/nest/Module.h | 8 ++++++++ contrib/nest/src/Module.test.cpp | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/contrib/nest/include/nest/Module.h b/contrib/nest/include/nest/Module.h index fc5a6f9..59cd634 100644 --- a/contrib/nest/include/nest/Module.h +++ b/contrib/nest/include/nest/Module.h @@ -2,6 +2,7 @@ #define __NEST_MODULE_H__ #include "nest/VarContext.h" +#include "nest/DomainContext.h" namespace nest { @@ -21,6 +22,13 @@ private: public: VarContext &var(void) { return _var_ctx; } const VarContext &var(void) const { return _var_ctx; } + +private: + DomainContext _domain_ctx; + +public: + DomainContext &domain(void) { return _domain_ctx; } + const DomainContext &domain(void) const { return _domain_ctx; } }; } // namespace nest diff --git a/contrib/nest/src/Module.test.cpp b/contrib/nest/src/Module.test.cpp index cdc30f8..119c3f1 100644 --- a/contrib/nest/src/Module.test.cpp +++ b/contrib/nest/src/Module.test.cpp @@ -19,3 +19,21 @@ TEST(MODULE, create_var) create(m); check(m); } + +TEST(MODULE, create_domain) +{ + nest::Module m; + + auto create = [](nest::Module &m, std::initializer_list dims) { + // This code will invoke 'DomainContext &domain(void)' method + return m.domain().make(dims); + }; + + auto check = [](const nest::Module &m) { + // This code will invoke 'const DomainContext &domain(void) const' method + ASSERT_EQ(m.domain().count(), 1); + }; + + create(m, {1, 3, 3}); + check(m); +} -- 2.7.4