1 /******************************************************************
3 * Copyright 2014 Samsung Electronics All Rights Reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 ******************************************************************/
20 #ifndef _ConditionedModel_H_
21 #define _ConditionedModel_H_
23 #include "SSMInterface/SSMCore.h"
24 #include "Common/PlatformLayer.h"
25 #include "Common/InternalInterface.h"
28 * @class CConditionedModel
29 * @brief CConditionedModel Interface
30 * This class represents Context Model's data search from given conditions
34 class CConditionedModel :
35 public CObjectRoot<CObjectMultiThreadModel>
36 , public IConditionedModel
37 , public IEvaluationEngineEvent
40 CObjectPtr<IEvaluationEngine> m_pEvaluationEngine;
41 CObjectPtr<IContextModel> m_pBaseModel;
42 ModelConditionVec m_watchCondition;
43 IConditionedModelEvent *m_pConditionedModelEvent;
45 CSimpleMutex m_mtxConditionedData;
46 std::list<int> m_triggeredDataIds;
47 IntVec m_affectedDataIds;
50 SSMRESULT finalConstruct();
56 * @brief Create Conditioned Model class using conditions.
58 * @param [in] IContextModel *pBaseModel - Base Context Model interface for Conditioned data reading
59 * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
66 SSMRESULT create(IContextModel *pBaseModel, ModelConditionVec *pModelConditions);
69 * @fn onWatchModelData
70 * @brief Called when Model data meets given conditions.
72 * @param [in] int triggerId - Trigger id.
73 * @param [in] int dataId - Affected data's Id
80 SSMRESULT onWatchModelData(int triggerId, int dataId);
82 SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
87 if (IsEqualOID(objectID, OID_IConditionedModel))
89 IBase *pBase = (IConditionedModel *)this;
95 return SSM_E_NOINTERFACE;
99 * @fn getBaseContextModel
100 * @brief Get base Context Model interface
102 * @param [out] IContextModel **ppBaseContextModel - Interface pointer for retrieving base Context Model interface.
109 SSMRESULT getBaseContextModel(IContextModel **ppBaseContextModel);
112 * @fn registerConditionedModelEvent
113 * @brief Register for receiving triggered event from given conditions
115 * @param [in] IConditionedModelEvent *pConditionedModelEvent - Interface for listening events.
122 SSMRESULT registerConditionedModelEvent(IConditionedModelEvent *pConditionedModelEvent);
125 * @fn activateTrigger
126 * @brief Activate trigger using given conditions
128 * @param [out] int *pTriggerId - Activated trigger id.
135 SSMRESULT activateTrigger(int *pTriggerId);
138 * @fn deactivateTrigger
139 * @brief Deactivate trigger that activated
148 SSMRESULT deactivateTrigger();
151 * @fn hasAffectedData
152 * @brief Quries if current Conditioned Model has affected data
161 bool hasAffectedData();
164 * @fn getAffectedData
165 * @brief Get affected data from given conditions includes triggered data
167 * @param [out] IntVec *pDataIds - Affected dataId sets.
174 SSMRESULT getAffectedData(IntVec *pDataIds);
177 * @fn getWatchCondition
178 * @brief Get watching conditions created from Context Model
180 * @param [out] ModelConditionVec *pModelConditions - Affected dataId sets.
187 SSMRESULT getWatchCondition(ModelConditionVec *pModelConditions);