iotivity 0.9.0
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SSMCore / src / QueryProcessor / ConditionedQueryResult.cpp
1 /******************************************************************
2 *
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
4 *
5 *
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 *      http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ******************************************************************/
20 #include "ConditionedQueryResult.h"
21
22 SSMRESULT CConditionedQueryResult::finalConstruct()
23 {
24     SSMRESULT res = SSM_E_FAIL;
25
26     res = SSM_S_OK;
27     //CLEANUP:
28     return res;
29 }
30
31 void CConditionedQueryResult::finalRelease()
32 {
33     for (std::vector<IConditionedModel *>::iterator itor = m_conditionedModels.begin();
34          itor != m_conditionedModels.end(); ++itor)
35     {
36         SAFE_RELEASE((*itor));
37     }
38 }
39
40 SSMRESULT CConditionedQueryResult::addConditionedModel(IN IConditionedModel *pConditionedModel)
41 {
42     pConditionedModel->addRef();
43     m_conditionedModels.push_back(pConditionedModel);
44
45     return SSM_S_OK;
46 }
47
48 unsigned int CConditionedQueryResult::getConditionedModelCount()
49 {
50     return m_conditionedModels.size();
51 }
52
53 SSMRESULT CConditionedQueryResult::getConditionedContextModel(IN unsigned int conditionedModelIndex,
54         OUT IConditionedModel **ppConditionedModel)
55 {
56     if (conditionedModelIndex > m_conditionedModels.size() - 1)
57     {
58         return SSM_E_FAIL;
59     }
60
61     return m_conditionedModels[conditionedModelIndex]->queryInterface(OID_IConditionedModel,
62             (IBase **)ppConditionedModel);
63 }