From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Tue, 17 Jul 2018 00:36:53 +0000 (+0900) Subject: [nest] Add 'Var' class (#670) X-Git-Tag: nncc_backup~2408 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b62d3d63a0728149d62d663165ddc74c4478c31e;p=platform%2Fcore%2Fml%2Fnnfw.git [nest] Add 'Var' class (#670) This commit adds 'Var' class which users will actually use to contruct nest expression. Signed-off-by: Jonghyun Park --- diff --git a/contrib/nest/include/nest/Expr.h b/contrib/nest/include/nest/Expr.h index 8c84c06..66b2e43 100644 --- a/contrib/nest/include/nest/Expr.h +++ b/contrib/nest/include/nest/Expr.h @@ -6,4 +6,13 @@ #include "nest/expr/VarNode.h" +#include + +namespace nest +{ + +using Expr = std::shared_ptr; + +} // namespace nest + #endif // __NEST_EXPR_H__ diff --git a/contrib/nest/include/nest/Var.h b/contrib/nest/include/nest/Var.h new file mode 100644 index 0000000..6549e45 --- /dev/null +++ b/contrib/nest/include/nest/Var.h @@ -0,0 +1,33 @@ +#ifndef __NEST_VAR_H__ +#define __NEST_VAR_H__ + +#include "nest/VarID.h" +#include "nest/Expr.h" + +namespace nest +{ + +class Var +{ +public: + Var() = default; + +public: + Var(const VarID &id) : _id{id} + { + // DO NOTHING + } + +public: + const VarID &id(void) const { return _id; } + +public: + operator Expr(void) const; + +private: + VarID const _id; +}; + +} // namespace nest + +#endif // __NEST_VAR_H__ diff --git a/contrib/nest/src/Var.cpp b/contrib/nest/src/Var.cpp new file mode 100644 index 0000000..1b519ca --- /dev/null +++ b/contrib/nest/src/Var.cpp @@ -0,0 +1,8 @@ +#include "nest/Var.h" + +namespace nest +{ + +Var::operator Expr(void) const { return std::make_shared(_id); } + +} // namespace nest diff --git a/contrib/nest/src/Var.test.cpp b/contrib/nest/src/Var.test.cpp new file mode 100644 index 0000000..8e15c63 --- /dev/null +++ b/contrib/nest/src/Var.test.cpp @@ -0,0 +1,22 @@ +#include "nest/Var.h" + +#include + +TEST(VAR, ctor) +{ + nest::VarID id{0}; + nest::Var var{id}; + + ASSERT_EQ(var.id(), id); +} + +TEST(VAR, cast) +{ + nest::VarID id{0}; + nest::Var var{id}; + + nest::Expr expr = var; + + ASSERT_NE(expr->asVar(), nullptr); + ASSERT_EQ(expr->asVar()->id(), id); +}