2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "FactRequest.h"
21 using namespace ctx::trigger;
23 FactRequest::FactRequest(int type, int reqId, const char* subj, const char* desc, ContextMonitor* ctxMonitor) :
24 RequestInfo(type, reqId, subj, desc),
25 __ctxMonitor(ctxMonitor),
30 FactRequest::~FactRequest()
32 reply(ERR_OPERATION_FAILED);
35 const char* FactRequest::getClient()
40 bool FactRequest::reply(int error)
42 IF_FAIL_RETURN(!__replied && __ctxMonitor, true);
43 __ctxMonitor->replyResult(__reqId, error);
44 __replied = (error != ERR_NONE);
48 bool FactRequest::reply(int error, CtxJson1& requestResult)
50 IF_FAIL_RETURN(!__replied && __ctxMonitor, true);
51 __ctxMonitor->replyResult(__reqId, error, &requestResult);
52 __replied = (error != ERR_NONE);
56 bool FactRequest::reply(int error, CtxJson1& requestResult, CtxJson1& dataRead)
58 IF_FAIL_RETURN(!__replied && __ctxMonitor, true);
59 __ctxMonitor->replyResult(__reqId, error, __subject.c_str(), &getDescription(), &dataRead);
60 return (__replied = true);
63 bool FactRequest::publish(int error, CtxJson1& data)
65 IF_FAIL_RETURN(__ctxMonitor, true);
66 __ctxMonitor->publishFact(__reqId, error, __subject.c_str(), &getDescription(), &data);