eec28354e6aa7c4b391e74a17e925c4414528672
[platform/core/uifw/aurum.git] / bootstrap / server / src / Commands / GetAttributeCommand.cc
1 #include "GetAttributeCommand.h"
2 #include <loguru.hpp>
3
4 #include <UiDevice.h>
5 #include <UiObject.h>
6
7 GetAttributeCommand::GetAttributeCommand(
8     const ::aurum::ReqGetAttribute* request, ::aurum::RspGetAttribute* response)
9     : mRequest{request}, mResponse{response}
10 {
11 }
12
13 ::grpc::Status GetAttributeCommand::execute()
14 {
15     LOG_SCOPE_F(INFO, "GetAttribute --------------- ");
16     ObjectMapper* mObjMap = ObjectMapper::getInstance();
17     UiObject*     obj = mObjMap->getElement(mRequest->elementid());
18
19     ::aurum::ReqGetAttribute_RequestType type = mRequest->attribute();
20     AttributeGetter *getter = AttributeGetter::Creator(type);
21
22     if (getter)
23         getter->getPerform(obj, mResponse);
24
25     return grpc::Status::OK;
26 }
27
28 AttributeGetter* AttributeGetter::Creator(::aurum::ReqGetAttribute_RequestType type)
29 {
30     switch(type)
31     {
32         case ::aurum::ReqGetAttribute_RequestType::ReqGetAttribute_RequestType_VISIBLE:
33             return new VisibleGetter();
34         default:
35             return nullptr;
36     }
37 }
38
39 bool VisibleGetter::getPerform(UiObject *obj, ::aurum::RspGetAttribute* rsp)
40 {
41     bool isVisible = obj->isVisible();
42
43     rsp->set_boolvalue(isVisible);
44     rsp->set_status(aurum::RspStatus::OK);
45
46     return true;
47 }
48 AttributeGetter::~AttributeGetter(){}
49 VisibleGetter::~VisibleGetter(){}