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 #include "SSMInterface/SSMCore.h"
21 #include "SSMInterface/SoftSensorManager.h"
22 #include "Common/InternalInterface.h"
24 static ISoftSensorManager *g_pSoftSensorManager = NULL;
26 SSMRESULT CreateQueryEngine(IQueryEngine **ppQueryEngine)
28 SSMRESULT res = SSM_E_FAIL;
30 SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
31 SSM_CLEANUP_ASSERT(g_pSoftSensorManager->createQueryEngine(ppQueryEngine));
37 unsigned long ReleaseQueryEngine(IQueryEngine *pQueryEngine)
39 if (pQueryEngine == NULL)
44 if (g_pSoftSensorManager == NULL)
49 return g_pSoftSensorManager->releaseQueryEngine(pQueryEngine);
52 SSMRESULT InitializeSSMCore(std::string xmlDescription)
54 SSMRESULT res = SSM_E_FAIL;
56 if (g_pSoftSensorManager != NULL)
57 SSM_CLEANUP_ASSERT(SSM_E_INITIALIZED);
59 SSM_CLEANUP_ASSERT(CreateGlobalInstanceRepo());
60 SSM_CLEANUP_ASSERT(CreateInstance(OID_ISoftSensorManager, (IBase **)&g_pSoftSensorManager));
61 SSM_CLEANUP_ASSERT(g_pSoftSensorManager->initializeCore(xmlDescription));
64 if (res != SSM_S_OK &&
65 res != SSM_E_INITIALIZED)
67 SAFE_RELEASE(g_pSoftSensorManager);
68 DestroyGlobalInstanceRepo();
74 SSMRESULT StartSSMCore()
76 SSMRESULT res = SSM_E_FAIL;
78 SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
79 SSM_CLEANUP_ASSERT(g_pSoftSensorManager->startCore());
85 SSMRESULT StopSSMCore()
87 SSMRESULT res = SSM_E_FAIL;
89 SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
90 SSM_CLEANUP_ASSERT(g_pSoftSensorManager->stopCore());
96 SSMRESULT TerminateSSMCore(bool factoryResetFlag)
98 SSMRESULT res = SSM_E_FAIL;
100 SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
101 SSM_CLEANUP_ASSERT(g_pSoftSensorManager->terminateCore(factoryResetFlag));
104 SAFE_RELEASE(g_pSoftSensorManager);
105 DestroyGlobalInstanceRepo();
109 const char *GetSSMError(SSMRESULT res)
111 const char *msg = NULL;
120 msg = "SSM_E_POINTER";
123 case SSM_E_OUTOFMEMORY:
124 msg = "SSM_E_OUTOFMEMORY";
132 msg = "SSM_E_NOTINIT";
135 case SSM_E_INITIALIZED:
136 msg = "SSM_E_INITIALIZED";
139 case SSM_E_INVALIDXML:
140 msg = "SSM_E_INVALIDXML";
143 case SSM_E_NOINTERFACE:
144 msg = "SSM_E_NOINTERFACE";
148 msg = "SSM_E_NOTIMPL";
159 SSMRESULT GetInstalledModelList(std::vector<ISSMResource *> *pList)
161 SSMRESULT res = SSM_E_FAIL;
163 SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
164 g_pSoftSensorManager->getInstalledModelList(pList);