Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / soft-sensor-manager / SSMCore / src / QueryProcessor / ContextQuery.h
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 #ifndef _ContextQuery_H_
21 #define _ContextQuery_H_
22
23 #include "SSMInterface/SSMCore.h"
24 #include "Common/PlatformLayer.h"
25 #include "Common/InternalInterface.h"
26 #include "CQLParser.h"
27
28 #define SIZE 100
29 #define MIN_NUM 10000
30
31
32 class result_model
33 {
34     public:
35         result_model();
36         int modelID;
37         std::vector<int> dataId;
38         std::string modelName;
39 };
40
41 class sub_modelId
42 {
43     public:
44         std::vector<int> modelId;
45 };
46
47
48 /**
49 * @class    ContextQuery
50 * @brief    ContextQuery Interface
51 *            This class provides functions for parsing.
52 *
53 * @see
54 *           CContextQuery contextquery;
55 *           contextquery->check_result_model();
56 */
57 class CContextQuery
58 {
59
60     public:
61         /**
62         * @fn CContextQuery
63         * @brief initializer
64         *
65         * @param none
66         * @return none
67         * @warning
68         * @exception
69         * @see
70         */
71         CContextQuery();
72
73         /**
74         * @fn initialize
75         * @brief input Token
76         *
77         * @param [in] Token input_root - root Token
78         * @return SSMRESULT
79         * @warning
80         * @exception
81         * @see
82         */
83         SSMRESULT initialize(Token &input_root);
84
85         /**
86         * @fn integrate_result
87         * @brief This function checks for duplicate results.
88         *
89         * @param [out] std::vector<result_model>* result - result
90         * @param [in] int modelId - entered modelID
91         * @param [in] std::vector<int> *dataid - dataID according to modelID
92         * @param [in] std::string modelName - modelName according to modelID
93         * @return none
94         * @warning
95         * @exception
96         * @see
97         */
98         void integrate_result(std::vector<result_model> *result, int modelId,
99                               std::vector<int> *dataid, std::string modelName);
100
101         /**
102         * @fn return_contextName
103         * @brief This function outputs ModelName of result clause
104         *
105         * @param [out] std::vector<std::string>* contextName - ModelName of result clause
106         * @return none
107         * @warning
108         * @exception
109         * @see
110         */
111         void return_contextName(std::vector<std::string> *contextName);
112
113         /**
114         * @fn check_result_model
115         * @brief This function checks the existence of ContextModel from result clause
116         *
117         * @param none
118         * @return none
119         * @warning
120         * @exception
121         * @see
122         */
123         void check_result_model();
124
125         /**
126         * @fn return_modelID
127         * @brief This function returns ContextModelID of result clause
128         *
129         * @param [out] std::vector<int>* vector_int - ContextModelID
130         * @return none
131         * @warning
132         * @exception
133         * @see
134         */
135         void return_modelID(std::vector<int> *vector_int);
136
137         /**
138         * @fn make_QueryCondition
139         * @brief This function makes QueryCondition using tokens.
140         *
141         * @param [out] QueryCondition* result - QueryCondition
142         * @return none
143         * @warning
144         * @exception
145         * @see
146         */
147         void make_QueryCondition(QueryCondition *result);
148
149     private:
150         /**
151         * @fn search_last_modelName
152         * @brief return last child name
153         *
154         * @param [in] Token* temp - entered token
155         * @return std::string
156         * @warning
157         * @exception
158         * @see
159         */
160         std::string search_last_modelName(Token *temp);
161
162         Token m_root;
163         CObjectPtr<IPropagationEngine>      m_pPropagationEngine;
164 };
165
166 #endif /*_ContextQuery_H_*/