[SSM] Adapt astyle code formatter
authorjk13 <jihyeok13.kim@samsung.com>
Tue, 18 Nov 2014 01:44:31 +0000 (10:44 +0900)
committerjk13 <jihyeok13.kim@samsung.com>
Tue, 18 Nov 2014 01:44:31 +0000 (10:44 +0900)
Problem: Follow coding guideline

How: Adapt astyle cpp formatter

Change-Id: I58ba77542f5fb3a935e1083a076957357599bc7e
Signed-off-by: Kim Jee Hyeok <jihyeok13.kim@samsung.com>
70 files changed:
service/soft-sensor-manager/SDK/include/ISSMClientListener.h
service/soft-sensor-manager/SDK/include/SSMClient.h
service/soft-sensor-manager/SDK/src/SSMClient.cpp
service/soft-sensor-manager/SSMCore/include/SSMResourceServer.h
service/soft-sensor-manager/SSMCore/src/Common/InternalInterface.h
service/soft-sensor-manager/SSMCore/src/Common/ObjectManager.h
service/soft-sensor-manager/SSMCore/src/Common/PlatformLayer.h
service/soft-sensor-manager/SSMCore/src/Common/ThreadManager.cpp
service/soft-sensor-manager/SSMCore/src/Common/ThreadManager.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/CQLParser.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/CQLParser.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ConditionedModel.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ConditionedModel.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ConditionedQuery.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ConditionedQuery.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ConditionedQueryResult.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ConditionedQueryResult.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ContextModel.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ContextModel.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ContextQuery.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ContextQuery.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/DataReader.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/DataReader.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/EvaluationEngine.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/EvaluationEngine.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ModelData.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/ModelData.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/PropagationEngine.h
service/soft-sensor-manager/SSMCore/src/QueryProcessor/QueryEngine.cpp
service/soft-sensor-manager/SSMCore/src/QueryProcessor/QueryEngine.h
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore.h
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore_JNI.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMCore_JNI.h
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMModelDefinition.h
service/soft-sensor-manager/SSMCore/src/SSMInterface/SSMResourceServer.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.cpp
service/soft-sensor-manager/SSMCore/src/SSMInterface/SoftSensorManager.h
service/soft-sensor-manager/SSMCore/src/SSMResourceServerLauncher.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextDataReader.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextDataReader.h
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextExecutor.h
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ContextRepository.h
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceConnectivity.h
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.h
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.cpp
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResponseReactor.h
service/soft-sensor-manager/SampleApp/arduino/THSensorApp/src/thserver.cpp
service/soft-sensor-manager/SampleApp/linux/ClientApp/include/SSMTestApp.h
service/soft-sensor-manager/SampleApp/linux/ClientApp/src/SSMTestApp.cpp
service/soft-sensor-manager/SampleApp/linux/THSensorApp/include/ThingResourceServer.h
service/soft-sensor-manager/SampleApp/linux/THSensorApp/src/ThingResourceServer.cpp
service/soft-sensor-manager/SampleApp/linux/THSensorApp1/include/ThingResourceServer1.h
service/soft-sensor-manager/SampleApp/linux/THSensorApp1/src/ThingResourceServer1.cpp
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/ISSMClientListener.h
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.cpp
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/SSMClient.h
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-log.h
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.cpp
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-test.h
service/soft-sensor-manager/SampleApp/tizen/ClientApp/oic-sample/src/oicapp-utils.h
service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/include/DiscomfortIndexSensor.h
service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/include/SysTimer.h
service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/src/DiscomfortIndexSensor.cpp
service/soft-sensor-manager/SoftSensorPlugin/DiscomfortIndexSensor/src/SysTimer.cpp

index 5c5c8d6..f425b3d 100644 (file)
@@ -19,7 +19,7 @@
  ******************************************************************/
 
 /**
- * @file    ISSMClientListener.h 
+ * @file    ISSMClientListener.h
  * @brief   This file contains client listener interfaces.
  */
 
@@ -38,24 +38,24 @@ typedef enum
 
 using namespace OC;
 /**
- *     @brief  ISSMClientListener is a listener interface from which application is derived to get callback from SoftSensorManager service
+ *  @brief  ISSMClientListener is a listener interface from which application is derived to get callback from SoftSensorManager service
  */
 class ISSMClientListener
 {
-public:
-    /**
-     * @brief  onRegisterQuery is a pure virtual operation which should be implemented in applications to get callback messages.
-     * @param [in] attributeMap - A data map in which SoftSensorManager service sends sensor data with cqid.
-     * @param [in] eCode - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
-     *                          SSMClient can callback message to the appication.
-     * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
-     * @return  SSMReturn
-     
-     */
-    virtual void onRegisterQuery(const AttributeMap& attributeMap, SSMReturn& eCode) = 0;
-    virtual ~ISSMClientListener()
-    {
-    }
+    public:
+        /**
+         * @brief   onRegisterQuery is a pure virtual operation which should be implemented in applications to get callback messages.
+         * @param [in] attributeMap - A data map in which SoftSensorManager service sends sensor data with cqid.
+         * @param [in] eCode - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
+         *                          SSMClient can callback message to the appication.
+         * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
+         * @return  SSMReturn
+
+         */
+        virtual void onRegisterQuery(const AttributeMap &attributeMap, SSMReturn &eCode) = 0;
+        virtual ~ISSMClientListener()
+        {
+        }
 };
 
 #endif /* ISSMCLIENTLISTENER_H_ */
index f365826..1ee47bd 100644 (file)
@@ -19,7 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 /**
- * @file    SSMClient.h 
+ * @file    SSMClient.h
  * @brief   This file contains the declaration of classes and its members related to SSMClient.
  */
 
@@ -37,207 +37,207 @@ using namespace OC;
 #if defined(WIN32)
 class CSemaphore
 {
-private:
-    HANDLE hSemaphore;
-    int m_MaxTimeOut;
-
-public:
-    /**
-     * This is CSemaphore constructor.
-     */
-    CSemaphore()
-    {
-        m_MaxTimeOut = 0;
-    }
-    /**
-     *This is CSemaphore destructor.
-     */
-    ~CSemaphore()
-    {
-    }
-
-    /**
-     * This is a function to creat a semaphore
-     * This is syncronus call.
-     * @param maximumRequestTimeOut
-     *          [IN] Request Time out.
-     *
-     * @return  None
-     *   
-     */
-    void create(int maximumRequestTimeOut)
-    {
-        hSemaphore = CreateSemaphore(NULL, 1, 1, NULL);
-        m_MaxTimeOut = maximumRequestTimeOut;
-    }
-
-    /**
-     * This is a function to wait for semaphore
-     *
-     * @return  None
-     *   
-     */
-    void wait()
-    {
-        WaitForSingleObject(hSemaphore, m_MaxTimeOut);
-    }
-
-    /**
-     * This is a function to release  semaphore
-     *
-     * @return  None
-     *   
-     */
-    void release()
-    {
-        ReleaseSemaphore(hSemaphore, 1, NULL);
-    }
+    private:
+        HANDLE hSemaphore;
+        int m_MaxTimeOut;
+
+    public:
+        /**
+         * This is CSemaphore constructor.
+         */
+        CSemaphore()
+        {
+            m_MaxTimeOut = 0;
+        }
+        /**
+         *This is CSemaphore destructor.
+         */
+        ~CSemaphore()
+        {
+        }
+
+        /**
+         * This is a function to creat a semaphore
+         * This is syncronus call.
+         * @param maximumRequestTimeOut
+         *          [IN] Request Time out.
+         *
+         * @return  None
+         *
+         */
+        void create(int maximumRequestTimeOut)
+        {
+            hSemaphore = CreateSemaphore(NULL, 1, 1, NULL);
+            m_MaxTimeOut = maximumRequestTimeOut;
+        }
+
+        /**
+         * This is a function to wait for semaphore
+         *
+         * @return  None
+         *
+         */
+        void wait()
+        {
+            WaitForSingleObject(hSemaphore, m_MaxTimeOut);
+        }
+
+        /**
+         * This is a function to release  semaphore
+         *
+         * @return  None
+         *
+         */
+        void release()
+        {
+            ReleaseSemaphore(hSemaphore, 1, NULL);
+        }
 
 };
 
 #elif defined(LINUX)
 #include <semaphore.h>
 
-#define SEM_SUCCESS            0
+#define SEM_SUCCESS     0
 
 class CSemaphore
 {
-private:
-    sem_t hSemaphore;
-    timespec m_MaxTimeOut;
-
-public:
-    /**
-     * This is CSemaphore constructor.
-     */
-    CSemaphore()
-    {
-        m_MaxTimeOut.tv_sec = 0;
-        m_MaxTimeOut.tv_nsec = 0;
-    }
-    /**
-     *This is CSemaphore destructor.
-     */
-    ~CSemaphore()
-    {
-    }
-    /**
-     * This is a function to creat a semaphore
-     * This is syncronus call.
-     * @param maximumRequestTimeOut
-     *          [IN] Request Time out.
-     *
-     * @return  None
-     *   
-     */
-    void create(int maximumRequestTimeOut)
-    {
-        if ( sem_init(&hSemaphore, 1, 0) < SEM_SUCCESS )
+    private:
+        sem_t hSemaphore;
+        timespec m_MaxTimeOut;
+
+    public:
+        /**
+         * This is CSemaphore constructor.
+         */
+        CSemaphore()
+        {
+            m_MaxTimeOut.tv_sec = 0;
+            m_MaxTimeOut.tv_nsec = 0;
+        }
+        /**
+         *This is CSemaphore destructor.
+         */
+        ~CSemaphore()
+        {
+        }
+        /**
+         * This is a function to creat a semaphore
+         * This is syncronus call.
+         * @param maximumRequestTimeOut
+         *          [IN] Request Time out.
+         *
+         * @return  None
+         *
+         */
+        void create(int maximumRequestTimeOut)
+        {
+            if ( sem_init(&hSemaphore, 1, 0) < SEM_SUCCESS )
+            {
+                perror("Error : sem_init.");
+                exit(0);
+            }
+            m_MaxTimeOut.tv_sec = maximumRequestTimeOut;
+        }
+
+        void wait()
+        {
+            sem_wait( &hSemaphore );
+        }
+
+        /**
+         * This is a function to release  semaphore
+         *
+         * @return  None
+         *
+         */
+        void release()
         {
-            perror("Error : sem_init.");
-            exit(0);
+            sem_post(&hSemaphore);
         }
-        m_MaxTimeOut.tv_sec = maximumRequestTimeOut;
-    }
-
-    void wait()
-    {
-        sem_wait( &hSemaphore );
-    }
-
-    /**
-     * This is a function to release  semaphore
-     *
-     * @return  None
-     *   
-     */
-    void release()
-    {
-        sem_post(&hSemaphore);
-    }
 
 };
 #endif
 
 /**
- *     @brief  SSMClient is a wrapper class to provide SoftSensorManager functionality to Application.
- *                     Basically, SoftSensorManager is developed in Resource model (i.e. messaging with basic functions of put, get, and post).
- *                     SSMClient abstracts the resource based operations from client applications and provides c++ style functions.
+ *  @brief  SSMClient is a wrapper class to provide SoftSensorManager functionality to Application.
+ *          Basically, SoftSensorManager is developed in Resource model (i.e. messaging with basic functions of put, get, and post).
+ *          SSMClient abstracts the resource based operations from client applications and provides c++ style functions.
  */
 class SSMClient
 {
-private:
-    SSMReturn m_retResponse;
-    OCPlatform *m_pPlatform;
-    CSemaphore m_sem;
-    /**
-     * @brief SoftSensorManager Resource.
-     */
-    std::shared_ptr< OCResource > m_SSMResource;
-    /**
-     * @brief attribute map .
-     */
-    AttributeMap m_responseAttributeMap;
-    /**
-     * @brief query engine.
-     */
-    std::string m_queryEngineId;
-    /**
-     * @brief app listener
-     */
-    ISSMClientListener* m_appListener;
-
-    /**
-     * @brief internal find resource function
-     */
-    void _findResource(void);
-
-    /**
-     * @brief internal Query engine function
-     */
-    void _createQueryEngine(void);
-
-    /**
-     * @brief internal release query function
-     */
-    void _releaseQueryEngine(std::string queryEngineId);
-
-public:
-    /**
-     * Constructor for SSMClient. 
-     */
-    SSMClient();
-    ~SSMClient();
-
-    /**
-     * This API sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
-     * 
-     * @param [in] queryString - A conditions query statement where the caller application specifies sensors for required data and conditions when the caller wants to get the data.
-     * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
-     *                          SSMClient can callback message to the application.
-     * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
-     * @return  SSMReturn
-     
-     */
-    SSMReturn registerQuery(std::string queryString, ISSMClientListener* listener,
-            std::string &cqid);
-    /**
-     * This API is to cancel the registered sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
-     * 
-     * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
-     *                          SSMClient can callback message to the application.
-     * @param [in] cqid - A query id generated from SoftSensorManager service for the queryString request.
-     * @return  SSMReturn
-     */
-    SSMReturn unregisterQuery(std::string cqid);
-
-    // friend option. for callback from SSMResource
-    void onFoundResource(std::shared_ptr< OCResource > resource);
-    void onCreateQueryEngine(const OCRepresentation& rep, const int eCode);
-    void onReleaseQueryEngine(const OCRepresentation& rep, const int eCode);
-    void onRegisterQuery(const OCRepresentation& rep, const int eCode);
-    void onUnregisterQuery(const OCRepresentation& rep, const int eCode);
-    void onObserve(const OCRepresentation& rep, const int& eCode);
+    private:
+        SSMReturn m_retResponse;
+        OCPlatform *m_pPlatform;
+        CSemaphore m_sem;
+        /**
+         * @brief SoftSensorManager Resource.
+         */
+        std::shared_ptr< OCResource > m_SSMResource;
+        /**
+         * @brief attribute map .
+         */
+        AttributeMap m_responseAttributeMap;
+        /**
+         * @brief query engine.
+         */
+        std::string m_queryEngineId;
+        /**
+         * @brief app listener
+         */
+        ISSMClientListener *m_appListener;
+
+        /**
+         * @brief internal find resource function
+         */
+        void _findResource(void);
+
+        /**
+         * @brief internal Query engine function
+         */
+        void _createQueryEngine(void);
+
+        /**
+         * @brief internal release query function
+         */
+        void _releaseQueryEngine(std::string queryEngineId);
+
+    public:
+        /**
+         * Constructor for SSMClient.
+         */
+        SSMClient();
+        ~SSMClient();
+
+        /**
+         * This API sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
+         *
+         * @param [in] queryString - A conditions query statement where the caller application specifies sensors for required data and conditions when the caller wants to get the data.
+         * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
+         *                          SSMClient can callback message to the application.
+         * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
+         * @return  SSMReturn
+
+         */
+        SSMReturn registerQuery(std::string queryString, ISSMClientListener *listener,
+                                std::string &cqid);
+        /**
+         * This API is to cancel the registered sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
+         *
+         * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
+         *                          SSMClient can callback message to the application.
+         * @param [in] cqid - A query id generated from SoftSensorManager service for the queryString request.
+         * @return  SSMReturn
+         */
+        SSMReturn unregisterQuery(std::string cqid);
+
+        // friend option. for callback from SSMResource
+        void onFoundResource(std::shared_ptr< OCResource > resource);
+        void onCreateQueryEngine(const OCRepresentation &rep, const int eCode);
+        void onReleaseQueryEngine(const OCRepresentation &rep, const int eCode);
+        void onRegisterQuery(const OCRepresentation &rep, const int eCode);
+        void onUnregisterQuery(const OCRepresentation &rep, const int eCode);
+        void onObserve(const OCRepresentation &rep, const int &eCode);
 };
 
 #endif /* RESOURCECLIENT_H_ */
index 69ead6a..174456c 100644 (file)
 #include "OCPlatform.h"
 #include "OCApi.h"
 
-const charSSM_RESOURCE_URI = "/service/SoftSensorManager";
+const char *SSM_RESOURCE_URI = "/service/SoftSensorManager";
 
-#define SSM_RESOURCE_TYPE              = "core.SoftSensorManager"
+#define SSM_RESOURCE_TYPE       = "core.SoftSensorManager"
 
-#define COAP_IP                                        "134.134.161.33"
-#define COAP_PORT                              5683
-#define COAP_MODE                              ModeType::Client
-#define COAP_SRVTYPE                   ServiceType::InProc
+#define COAP_IP                 "134.134.161.33"
+#define COAP_PORT               5683
+#define COAP_MODE               ModeType::Client
+#define COAP_SRVTYPE            ServiceType::InProc
 
-#define COAP_SERVER_ADDR               "coap://224.0.1.187/oc/core?rt=core.SoftSensorManager"
+#define COAP_SERVER_ADDR        "coap://224.0.1.187/oc/core?rt=core.SoftSensorManager"
 
 SSMClient::SSMClient()
 {
@@ -59,7 +59,7 @@ SSMClient::~SSMClient()
 void SSMClient::_findResource()
 {
     // Create PlatformConfig object
-       PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable);
+    PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable);
 
     // Create a OCPlatform instance.
     // Note: Platform creation is synchronous call.
@@ -70,8 +70,8 @@ void SSMClient::_findResource()
         // Find all resources
         OCStackResult result;
         if ((result = m_pPlatform->findResource("", COAP_SERVER_ADDR,
-                std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1)))
-                != OC_STACK_OK)
+                                                std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1)))
+            != OC_STACK_OK)
         {
             delete m_pPlatform;
             m_pPlatform = NULL;
@@ -103,8 +103,8 @@ void SSMClient::_createQueryEngine(void)
     rep.setAttributeMap(requestAttributeMap);
 
     if (m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onCreateQueryEngine, this, std::placeholders::_1,
-                    std::placeholders::_2)) != OC_STACK_OK)
+                           std::bind(&SSMClient::onCreateQueryEngine, this, std::placeholders::_1,
+                                     std::placeholders::_2)) != OC_STACK_OK)
     {
         return;
     }
@@ -133,14 +133,14 @@ void SSMClient::_releaseQueryEngine(std::string queryEngineId)
     rep.setAttributeMap(requestAttributeMap);
 
     m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onReleaseQueryEngine, this, std::placeholders::_1,
-                    std::placeholders::_2));
+                       std::bind(&SSMClient::onReleaseQueryEngine, this, std::placeholders::_1,
+                                 std::placeholders::_2));
 
     m_sem.wait();
 }
 
-SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListenerlistener,
-        std::string &cqid)
+SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListener *listener,
+                                   std::string &cqid)
 {
     OCRepresentation rep;
 
@@ -168,8 +168,8 @@ SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListener*
     rep.setAttributeMap(requestAttributeMap);
 
     if (m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onRegisterQuery, this, std::placeholders::_1,
-                    std::placeholders::_2)) != OC_STACK_OK)
+                           std::bind(&SSMClient::onRegisterQuery, this, std::placeholders::_1,
+                                     std::placeholders::_2)) != OC_STACK_OK)
         return SSM_ERROR_NETWORK;
 
     m_sem.wait();
@@ -208,8 +208,8 @@ SSMReturn SSMClient::unregisterQuery(std::string cqid)
     rep.setAttributeMap(requestAttributeMap);
 
     if (m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onUnregisterQuery, this, std::placeholders::_1,
-                    std::placeholders::_2)) != OC_STACK_OK)
+                           std::bind(&SSMClient::onUnregisterQuery, this, std::placeholders::_1,
+                                     std::placeholders::_2)) != OC_STACK_OK)
         return SSM_ERROR_NETWORK;
 
     m_sem.wait();
@@ -238,7 +238,7 @@ void SSMClient::onFoundResource(std::shared_ptr< OCResource > resource)
             }
         }
     }
-    catch (std::exceptione)
+    catch (std::exception &e)
     {
         //log(e.what());
     }
@@ -246,7 +246,7 @@ void SSMClient::onFoundResource(std::shared_ptr< OCResource > resource)
     m_sem.release();
 }
 
-void SSMClient::onCreateQueryEngine(const OCRepresentationrep, const int eCode)
+void SSMClient::onCreateQueryEngine(const OCRepresentation &rep, const int eCode)
 {
     if (eCode != 0)
     {
@@ -259,10 +259,10 @@ void SSMClient::onCreateQueryEngine(const OCRepresentation& rep, const int eCode
     m_responseAttributeMap["queryEngineId"].pop_back();
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onRegisterQuery(const OCRepresentationrep, const int eCode)
+void SSMClient::onRegisterQuery(const OCRepresentation &rep, const int eCode)
 {
     QueryParamsMap queryParamsMap;
 
@@ -281,14 +281,14 @@ void SSMClient::onRegisterQuery(const OCRepresentation& rep, const int eCode)
     }
 
     m_SSMResource->observe(ObserveType::Observe, queryParamsMap,
-            std::bind(&SSMClient::onObserve, this, std::placeholders::_1, std::placeholders::_2));
+                           std::bind(&SSMClient::onObserve, this, std::placeholders::_1, std::placeholders::_2));
 
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onUnregisterQuery(const OCRepresentationrep, const int eCode)
+void SSMClient::onUnregisterQuery(const OCRepresentation &rep, const int eCode)
 {
     if (eCode != 0)
     {
@@ -306,10 +306,10 @@ void SSMClient::onUnregisterQuery(const OCRepresentation& rep, const int eCode)
 
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onReleaseQueryEngine(const OCRepresentationrep, const int eCode)
+void SSMClient::onReleaseQueryEngine(const OCRepresentation &rep, const int eCode)
 {
     if (eCode != 0)
     {
@@ -321,10 +321,10 @@ void SSMClient::onReleaseQueryEngine(const OCRepresentation& rep, const int eCod
 
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onObserve(const OCRepresentation& rep, const int& eCode)
+void SSMClient::onObserve(const OCRepresentation &rep, const int &eCode)
 {
     SSMReturn ret = SSM_SUCCESS;
 
index 8362c20..7643411 100644 (file)
 
 class SSMResourceServer
 {
-public:
-    SSMResourceServer();
-    ~SSMResourceServer();
+    public:
+        SSMResourceServer();
+        ~SSMResourceServer();
 
-    int initializeManager(std::string &xmlDescription);
-    int terminateManager();
+        int initializeManager(std::string &xmlDescription);
+        int terminateManager();
 
-    void entityHandler(std::shared_ptr< OC::OCResourceRequest > request,
-            std::shared_ptr< OC::OCResourceResponse > response);
+        void entityHandler(std::shared_ptr< OC::OCResourceRequest > request,
+                           std::shared_ptr< OC::OCResourceResponse > response);
 
-private:
-    OC::OCPlatform *m_pPlatform;
-    OCResourceHandle m_hSSMResource;
-    int createResource();
+    private:
+        OC::OCPlatform *m_pPlatform;
+        OCResourceHandle m_hSSMResource;
+        int createResource();
 };
 
 #endif
index 6da528e..dd9fe3e 100644 (file)
 
 class CallbackData
 {
-public:
-       TypeofEvent m_callType;
-       std::string m_name;
-       IEvent*         m_pCallbackEvent;
-       CallbackData()
-       {
-               m_callType = SSM_ONCE;
-               m_pCallbackEvent = NULL;
-       }
-
-       CallbackData(TypeofEvent type, std::string name, IEvent* pCallbackEvent)
-       {
-               m_name = name;
-               m_pCallbackEvent = pCallbackEvent;
-               m_callType = type;
-       }
+    public:
+        TypeofEvent m_callType;
+        std::string m_name;
+        IEvent     *m_pCallbackEvent;
+        CallbackData()
+        {
+            m_callType = SSM_ONCE;
+            m_pCallbackEvent = NULL;
+        }
+
+        CallbackData(TypeofEvent type, std::string name, IEvent *pCallbackEvent)
+        {
+            m_name = name;
+            m_pCallbackEvent = pCallbackEvent;
+            m_callType = type;
+        }
 };
 
 struct DictionaryData
 {
-       std::string rootName;
-       std::vector<std::map<std::string,std::string> > attributeProperty;
-       std::vector<std::map<std::string,std::string> > outputProperty;
-       std::vector<std::string> appInputs;
-       std::vector<std::string> inputs;
-       std::string attributePropertyCount;
-       std::string outputPropertyCount;
-       std::string inputCount;
-       std::string appInputCount;
-       std::vector<std::vector<std::string> > enterConditions;
+    std::string rootName;
+    std::vector<std::map<std::string, std::string> > attributeProperty;
+    std::vector<std::map<std::string, std::string> > outputProperty;
+    std::vector<std::string> appInputs;
+    std::vector<std::string> inputs;
+    std::string attributePropertyCount;
+    std::string outputPropertyCount;
+    std::string inputCount;
+    std::string appInputCount;
+    std::vector<std::vector<std::string> > enterConditions;
 };
 
-enum PARSE_TYPE{SSM_UNKNOWN, SSM_ROOT_NAME, SSM_HIGH_CONTEXT_NAME,SSM_ATTRIBUTE,SSM_OUTPUT,SSM_APP_INPUTS,SSM_INPUTS,SSM_INPUT,SSM_ENTER_CONDITIONS};
-enum DICTIONARY_TYPE {LOW,HIGH,SENSOR,USER};
+enum PARSE_TYPE {SSM_UNKNOWN, SSM_ROOT_NAME, SSM_HIGH_CONTEXT_NAME, SSM_ATTRIBUTE, SSM_OUTPUT, SSM_APP_INPUTS, SSM_INPUTS, SSM_INPUT, SSM_ENTER_CONDITIONS};
+enum DICTIONARY_TYPE {LOW, HIGH, SENSOR, USER};
 
 static const OID OID_IContextRepository = { 0x611144b0, 0xf036, 0x44a1, { 0xba, 0xe6, 0x6a, 0x92, 0xe1, 0xf0, 0xcc, 0x53 } };
 /**
@@ -70,90 +70,93 @@ static const OID OID_IContextRepository = { 0x611144b0, 0xf036, 0x44a1, { 0xba,
  */
 class IContextRepository : public IBase
 {
-public:
-       /**
-       * @fn           getSoftSensorList
-       * @brief        Get high level context resource list
-       *
-       * @param                [out] std::vector<ISSMResource*> *pSoftSensorList - High level context list
-       * @return       SSMRESULT
-       *                                       SSM_S_OK
-       *                                       , SSM_S_FALSE
-       *                                       , SSM_E_POINTER
-       *                                       , SSM_E_OUTOFMEMORY
-       *                                       , SSM_E_FAIL
-       *                                       , SSM_E_NOINTERFACE
-       *                                       , SSM_E_NOTIMPL
-       *                               
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       virtual SSMRESULT getSoftSensorList(OUT std::vector<ISSMResource*> *pSoftSensorList) = 0 ;
-
-       /**
-       * @fn           getPrimitiveSensorList
-       * @brief        Get low level context resource list
-       *
-       * @param                [out] std::vector<ISSMResource*> *pPrimitiveSensorList - Low level context list
-       * @return       SSMRESULT
-       *                                       SSM_S_OK
-       *                                       , SSM_S_FALSE
-       *                                       , SSM_E_POINTER
-       *                                       , SSM_E_OUTOFMEMORY
-       *                                       , SSM_E_FAIL
-       *                                       , SSM_E_NOINTERFACE
-       *                                       , SSM_E_NOTIMPL
-       *                               
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       virtual SSMRESULT getPrimitiveSensorList(OUT std::vector<ISSMResource*> *pPrimitiveSensorList) = 0 ;
-       
-       /**
-       * @fn           setCurrentDeviceInfo
-       * @brief        set device information
-       *
-       * @param        [in] std::string name - Device name
-       * @param        [in] std::string type - Device Type
-       * @param        [in] std::string pathSoftSensors - SoftSensors Repository path
-       * @param        [in] std::string pathDescription - SoftSensors Description path
-       * @return       void
-       *
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void setCurrentDeviceInfo(IN std::string name, IN std::string type, IN std::string pathSoftSensors, IN std::string pathDescription) = 0;
-
-       virtual SSMRESULT registerResourceFinderEvent(IN IResourceEvent *pResourceEvent) = 0;
-       virtual SSMRESULT startResourceFinder() = 0;
-       virtual SSMRESULT onResourceFound(IN ISSMResource *pSensor) = 0;
-       virtual SSMRESULT onResourceLost(IN ISSMResource *pSensor) = 0;
-
-       virtual SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent) = 0;
-       virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0;
-
-       virtual SSMRESULT loadSoftSensor(IN std::string softSensorName, IN ICtxDelegate *pDelegate, OUT void **hSoftSensor) = 0;
-       virtual SSMRESULT unloadSoftSensor(IN void *hSoftSensor) = 0;
+    public:
+        /**
+        * @fn           getSoftSensorList
+        * @brief        Get high level context resource list
+        *
+        * @param        [out] std::vector<ISSMResource*> *pSoftSensorList - High level context list
+        * @return       SSMRESULT
+        *                   SSM_S_OK
+        *                   , SSM_S_FALSE
+        *                   , SSM_E_POINTER
+        *                   , SSM_E_OUTOFMEMORY
+        *                   , SSM_E_FAIL
+        *                   , SSM_E_NOINTERFACE
+        *                   , SSM_E_NOTIMPL
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getSoftSensorList(OUT std::vector<ISSMResource *> *pSoftSensorList) = 0 ;
+
+        /**
+        * @fn           getPrimitiveSensorList
+        * @brief        Get low level context resource list
+        *
+        * @param        [out] std::vector<ISSMResource*> *pPrimitiveSensorList - Low level context list
+        * @return       SSMRESULT
+        *                   SSM_S_OK
+        *                   , SSM_S_FALSE
+        *                   , SSM_E_POINTER
+        *                   , SSM_E_OUTOFMEMORY
+        *                   , SSM_E_FAIL
+        *                   , SSM_E_NOINTERFACE
+        *                   , SSM_E_NOTIMPL
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getPrimitiveSensorList(OUT std::vector<ISSMResource *> *pPrimitiveSensorList) = 0
+                ;
+
+        /**
+        * @fn           setCurrentDeviceInfo
+        * @brief        set device information
+        *
+        * @param        [in] std::string name - Device name
+        * @param        [in] std::string type - Device Type
+        * @param        [in] std::string pathSoftSensors - SoftSensors Repository path
+        * @param        [in] std::string pathDescription - SoftSensors Description path
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void setCurrentDeviceInfo(IN std::string name, IN std::string type,
+                                          IN std::string pathSoftSensors, IN std::string pathDescription) = 0;
+
+        virtual SSMRESULT registerResourceFinderEvent(IN IResourceEvent *pResourceEvent) = 0;
+        virtual SSMRESULT startResourceFinder() = 0;
+        virtual SSMRESULT onResourceFound(IN ISSMResource *pSensor) = 0;
+        virtual SSMRESULT onResourceLost(IN ISSMResource *pSensor) = 0;
+
+        virtual SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent) = 0;
+        virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0;
+
+        virtual SSMRESULT loadSoftSensor(IN std::string softSensorName, IN ICtxDelegate *pDelegate,
+                                         OUT void **hSoftSensor) = 0;
+        virtual SSMRESULT unloadSoftSensor(IN void *hSoftSensor) = 0;
 };
 
 struct ModelProperty
 {
-       enum Type {TYPE_NUMERIC, TYPE_INTEGER, TYPE_REAL, TYPE_TEXT};
-       std::string             propertyName;
-       std::string             propertyValue;
-       Type                    propertyType;
+    enum Type {TYPE_NUMERIC, TYPE_INTEGER, TYPE_REAL, TYPE_TEXT};
+    std::string     propertyName;
+    std::string     propertyValue;
+    Type            propertyType;
 };
 
 typedef std::vector<ModelProperty> ModelPropertyVec;
 
 struct ModelCondition
 {
-       enum Predicate {PREDICATE_EQ, PREDICATE_NEQ, PREDICATE_GT, PREDICATE_LT, PREDICATE_GTE, PREDICATE_LTE};
-       ModelProperty   modelProperty;
-       Predicate               predicate;
+    enum Predicate {PREDICATE_EQ, PREDICATE_NEQ, PREDICATE_GT, PREDICATE_LT, PREDICATE_GTE, PREDICATE_LTE};
+    ModelProperty   modelProperty;
+    Predicate       predicate;
 };
 
 typedef std::vector<ModelCondition> ModelConditionVec;
@@ -161,272 +164,278 @@ typedef std::vector<ModelCondition> ModelConditionVec;
 /**
 * @class    IEvaluationEngineEvent
 * @brief    IEvaluationEngineEvent Interface
-*                       This class represents event interface that listening IEvaluationEngine's results
+*            This class represents event interface that listening IEvaluationEngine's results
 *
 * @see
 */
 class IEvaluationEngineEvent : public IBase
 {
-public:
-       /**
-       * @fn     onWatchModelData
-       * @brief Called when Model data meets given conditions.
-       *
-       * @param [in] int triggerId - Trigger id.
-       * @param [in] int dataId - Affected data's Id
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT onWatchModelData(IN int triggerId, IN int dataId) = 0;
+    public:
+        /**
+        * @fn     onWatchModelData
+        * @brief Called when Model data meets given conditions.
+        *
+        * @param [in] int triggerId - Trigger id.
+        * @param [in] int dataId - Affected data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT onWatchModelData(IN int triggerId, IN int dataId) = 0;
 };
 
 static const OID OID_IEvaluationEngine = { 0x5a59a9f3, 0x7506, 0x4a3a, { 0xb9, 0x34, 0xcb, 0x51, 0xd, 0xb4, 0xed, 0x53 } };
 /**
 * @class    IEvaluationEngine
 * @brief    IEvaluationEngine Interface
-*                       This class represents Evaluation Engine
+*            This class represents Evaluation Engine
 *
 * @see
 */
 class IEvaluationEngine : public IBase
 {
-public:
-       /**
-       * @fn     initializeEngine
-       * @brief Initialize EvaluationEngine with database
-       *
-       * @param NONE
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT initializeEngine() = 0;
-
-       /**
-       * @fn     terminateEngine
-       * @brief Terminate engine and dump to file if required
-       *
-       * @param NONE
-       * 
-       * @return void
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void terminateEngine() = 0;
-
-       /**
-       * @fn     createModel
-       * @brief Create new context model
-       *
-       * @param [in] int parentModelId - Parent Context Model id that related to Model hierarchy.
-       * @param [in] const char *newModelName - Represent model's name
-       * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
-       * @param [out] int *pModelId - Created model's id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT createModel(IN int parentModelId, IN const char *newModelName,
-               IN ModelPropertyVec *pModelDescs, OUT int *pModelId) = 0;
-       //virtual SSMRESULT GetModelSchema(IN int modelId, OUT ModelPropertyVec *pModelProperties) = 0;
-       
-       /**
-       * @fn     addModelData
-       * @brief Add model data to Context Model
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int parentModelId - parent model id that created CreateModel's execution.
-       * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
-       * @param [in] ModelPropertyVec *pData - Packed data for adding
-       * @param [out] int *pDataId - Returned dataId that newly added
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT addModelData(IN int modelId, IN int parentModelId, IN int parentDataId,
-               IN ModelPropertyVec *pModelValues, OUT int *pDataId) = 0;
-       
-       /**
-       * @fn     updateModelData
-       * @brief Update model data to Context Model 
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [in] ModelPropertyVec *pData - Packed data for updating
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT updateModelData(IN int modelId, IN int dataId, IN ModelPropertyVec *pModelValues) = 0;
-       
-       //virtual SSMRESULT DeleteModel(IN int modelId) = 0;
-       
-       /**
-       * @fn     deleteModelData
-       * @brief Delete model data using given index
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT deleteModelData(IN int modelId, IN int dataId) = 0;
-
-       //virtual SSMRESULT GetModelId(IN const char *modelName, OUT int *pModelId) = 0;
-       
-       /**
-       * @fn     getModelData
-       * @brief Get model data
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [out] ModelPropertyVec *pData - Packed data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getModelData(IN int modelId, IN int dataId, OUT ModelPropertyVec *pModelProperties) = 0;
-
-       /**
-       * @fn     getModelDataSet
-       * @brief Get model data set
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int startIndex - Starting index of model data
-       * @param [in] int count - Number of data to retrieve
-       * @param [out] vector<ModelPropertyVec> *pData - Packed data
-       * @param [out] int *pLastIndex - Index of last data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getModelDataSet(IN int modelId, IN int startIndex, IN int count, OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex) = 0;
-               
-       /**
-       * @fn     getConditionedModelData
-       * @brief Get affected data from given conditions
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
-       * @param [out] IntVec   *pDataIds - Searched dataId sets.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT getConditionedModelData(IN int modelId, IN ModelConditionVec *pModelConditions, OUT IntVec *pDataIds) = 0;
-       
-       /**
-       * @fn     watchModelData
-       * @brief Watching data from given conditions
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] ModelConditionVec *pModelConditions - Conditions for data triggering
-       * @param [in] IEvaluationEngineEvent *pEvaluationEngineEvent - Event interface where triggered event listening
-       * @param [out] int *pTriggerId - Identifier which trigger is activated
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
-               IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId) = 0;
-       
-       /**
-       * @fn     dropWatchModelData
-       * @brief Stop watching data
-       *
-       * @param [in] int triggerId - Identifier which trigger to drop
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT dropWatchModelData(IN int triggerId) = 0;
-
-       /**
-       * @fn     getParentDataId
-       * @brief Get parent dataId related to model hierarchy
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] int parentModelId - Designated parent Context Model's id
-       * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getParentDataId(IN int modelId, IN int dataId, IN int parentModelId, OUT int* pParentDataId) = 0;
-       
-       /**
-       * @fn     getChildDataId
-       * @brief Get child dataId related to model hierarchy
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] int childModelId - Designated child Context Model's id
-       * @param [out] IntVec *pChildDataIds - Designated child Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getChildDataId(IN int modelId, IN int dataId, IN int childModelId, OUT IntVec *pChildDataIds) = 0;
-       
-       //For decision tree
-       //virtual SSMRESULT GetPathToRoot(IN int currentModelId, OUT IntVec *pPath) = 0;
-       //virtual SSMRESULT GetModelHierarchy(IN int rootModelId, OUT StringVec *pPath) = 0;
-       //virtual SSMRESULT GetDataHierarchy(IN int rootModelId, IN int dataId, OUT StringVec *pPath) = 0;
+    public:
+        /**
+        * @fn     initializeEngine
+        * @brief Initialize EvaluationEngine with database
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT initializeEngine() = 0;
+
+        /**
+        * @fn     terminateEngine
+        * @brief Terminate engine and dump to file if required
+        *
+        * @param NONE
+        *
+        * @return void
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void terminateEngine() = 0;
+
+        /**
+        * @fn     createModel
+        * @brief Create new context model
+        *
+        * @param [in] int parentModelId - Parent Context Model id that related to Model hierarchy.
+        * @param [in] const char *newModelName - Represent model's name
+        * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
+        * @param [out] int *pModelId - Created model's id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT createModel(IN int parentModelId, IN const char *newModelName,
+                                      IN ModelPropertyVec *pModelDescs, OUT int *pModelId) = 0;
+        //virtual SSMRESULT GetModelSchema(IN int modelId, OUT ModelPropertyVec *pModelProperties) = 0;
+
+        /**
+        * @fn     addModelData
+        * @brief Add model data to Context Model
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int parentModelId - parent model id that created CreateModel's execution.
+        * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
+        * @param [in] ModelPropertyVec *pData - Packed data for adding
+        * @param [out] int *pDataId - Returned dataId that newly added
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT addModelData(IN int modelId, IN int parentModelId, IN int parentDataId,
+                                       IN ModelPropertyVec *pModelValues, OUT int *pDataId) = 0;
+
+        /**
+        * @fn     updateModelData
+        * @brief Update model data to Context Model
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [in] ModelPropertyVec *pData - Packed data for updating
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT updateModelData(IN int modelId, IN int dataId,
+                                          IN ModelPropertyVec *pModelValues) = 0;
+
+        //virtual SSMRESULT DeleteModel(IN int modelId) = 0;
+
+        /**
+        * @fn     deleteModelData
+        * @brief Delete model data using given index
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT deleteModelData(IN int modelId, IN int dataId) = 0;
+
+        //virtual SSMRESULT GetModelId(IN const char *modelName, OUT int *pModelId) = 0;
+
+        /**
+        * @fn     getModelData
+        * @brief Get model data
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [out] ModelPropertyVec *pData - Packed data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getModelData(IN int modelId, IN int dataId,
+                                       OUT ModelPropertyVec *pModelProperties) = 0;
+
+        /**
+        * @fn     getModelDataSet
+        * @brief Get model data set
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int startIndex - Starting index of model data
+        * @param [in] int count - Number of data to retrieve
+        * @param [out] vector<ModelPropertyVec> *pData - Packed data
+        * @param [out] int *pLastIndex - Index of last data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getModelDataSet(IN int modelId, IN int startIndex, IN int count,
+                                          OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex) = 0;
+
+        /**
+        * @fn     getConditionedModelData
+        * @brief Get affected data from given conditions
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
+        * @param [out] IntVec   *pDataIds - Searched dataId sets.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getConditionedModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
+                OUT IntVec *pDataIds) = 0;
+
+        /**
+        * @fn     watchModelData
+        * @brief Watching data from given conditions
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] ModelConditionVec *pModelConditions - Conditions for data triggering
+        * @param [in] IEvaluationEngineEvent *pEvaluationEngineEvent - Event interface where triggered event listening
+        * @param [out] int *pTriggerId - Identifier which trigger is activated
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
+                                         IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId) = 0;
+
+        /**
+        * @fn     dropWatchModelData
+        * @brief Stop watching data
+        *
+        * @param [in] int triggerId - Identifier which trigger to drop
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT dropWatchModelData(IN int triggerId) = 0;
+
+        /**
+        * @fn     getParentDataId
+        * @brief Get parent dataId related to model hierarchy
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] int parentModelId - Designated parent Context Model's id
+        * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getParentDataId(IN int modelId, IN int dataId, IN int parentModelId,
+                                          OUT int *pParentDataId) = 0;
+
+        /**
+        * @fn     getChildDataId
+        * @brief Get child dataId related to model hierarchy
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] int childModelId - Designated child Context Model's id
+        * @param [out] IntVec *pChildDataIds - Designated child Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getChildDataId(IN int modelId, IN int dataId, IN int childModelId,
+                                         OUT IntVec *pChildDataIds) = 0;
+
+        //For decision tree
+        //virtual SSMRESULT GetPathToRoot(IN int currentModelId, OUT IntVec *pPath) = 0;
+        //virtual SSMRESULT GetModelHierarchy(IN int rootModelId, OUT StringVec *pPath) = 0;
+        //virtual SSMRESULT GetDataHierarchy(IN int rootModelId, IN int dataId, OUT StringVec *pPath) = 0;
 };
 
 /**
 * @class    IConditionedModelEvent
 * @brief    IConditionedModelEvent Interface
-*                       This class represents event interface that listening IConditionedModel's results
+*            This class represents event interface that listening IConditionedModel's results
 *
 * @see
 */
 class IConditionedModelEvent
 {
-public:
-       /**
-       * @fn     onConditionedModelTriggered
-       * @brief Called when each Conditioned Model meets the conditions
-       *
-       * @param [in] int triggerId - trigger id that which Conditioned Model triggered
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT onConditionedModelTriggered(IN int triggerId) = 0;
-       virtual ~IConditionedModelEvent(){};
+    public:
+        /**
+        * @fn     onConditionedModelTriggered
+        * @brief Called when each Conditioned Model meets the conditions
+        *
+        * @param [in] int triggerId - trigger id that which Conditioned Model triggered
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT onConditionedModelTriggered(IN int triggerId) = 0;
+        virtual ~IConditionedModelEvent() {};
 };
 
 class IContextModel;
@@ -435,470 +444,479 @@ static const OID OID_IConditionedModel = { 0xdc71abc7, 0x5a02, 0x418a, { 0xad, 0
 /**
 * @class    IConditionedModel
 * @brief    IConditionedModel Interface
-*                       This class represents Context Model's data search from given conditions
+*            This class represents Context Model's data search from given conditions
 *
 * @see
 */
 class IConditionedModel : public IBase
 {
-public:
-       /**
-       * @fn     getBaseContextModel
-       * @brief Get base Context Model interface
-       *
-       * @param [out] IContextModel **ppBaseContextModel - Interface pointer for retrieving base Context Model interface.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT getBaseContextModel(OUT IContextModel **ppBaseContextModel) = 0;
-
-       /**
-       * @fn     registerConditionedModelEvent
-       * @brief Register for receiving triggered event from given conditions
-       *
-       * @param [in] IConditionedModelEvent *pConditionedModelEvent - Interface for listening events.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT registerConditionedModelEvent(IN IConditionedModelEvent *pConditionedModelEvent) = 0;
-       
-       /**
-       * @fn     activateTrigger
-       * @brief Activate trigger using given conditions
-       *
-       * @param [out] int *pTriggerId - Activated trigger id.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT activateTrigger(OUT int *pTriggerId) = 0;
-
-       /**
-       * @fn     deactivateTrigger
-       * @brief Deactivate trigger that activated
-       *
-       * @param NONE
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT deactivateTrigger() = 0;
-
-       /**
-       * @fn     hasAffectedData
-       * @brief Quries if current Conditioned Model has affected data
-       *
-       * @param NONE
-       * 
-       * @return bool
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual bool hasAffectedData() = 0;
-
-       /**
-       * @fn     getAffectedData
-       * @brief Get affected data from given conditions includes triggered data
-       *
-       * @param [out] IntVec   *pDataIds - Affected dataId sets.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT getAffectedData(OUT IntVec *pDataIds) = 0;
-
-       /**
-       * @fn     getWatchCondition
-       * @brief Get watching conditions created from Context Model
-       *
-       * @param [out] ModelConditionVec *pModelConditions - Affected dataId sets.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT getWatchCondition(OUT ModelConditionVec *pModelConditions) = 0;
+    public:
+        /**
+        * @fn     getBaseContextModel
+        * @brief Get base Context Model interface
+        *
+        * @param [out] IContextModel **ppBaseContextModel - Interface pointer for retrieving base Context Model interface.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getBaseContextModel(OUT IContextModel **ppBaseContextModel) = 0;
+
+        /**
+        * @fn     registerConditionedModelEvent
+        * @brief Register for receiving triggered event from given conditions
+        *
+        * @param [in] IConditionedModelEvent *pConditionedModelEvent - Interface for listening events.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT registerConditionedModelEvent(IN IConditionedModelEvent *pConditionedModelEvent) =
+            0;
+
+        /**
+        * @fn     activateTrigger
+        * @brief Activate trigger using given conditions
+        *
+        * @param [out] int *pTriggerId - Activated trigger id.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT activateTrigger(OUT int *pTriggerId) = 0;
+
+        /**
+        * @fn     deactivateTrigger
+        * @brief Deactivate trigger that activated
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT deactivateTrigger() = 0;
+
+        /**
+        * @fn     hasAffectedData
+        * @brief Quries if current Conditioned Model has affected data
+        *
+        * @param NONE
+        *
+        * @return bool
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual bool hasAffectedData() = 0;
+
+        /**
+        * @fn     getAffectedData
+        * @brief Get affected data from given conditions includes triggered data
+        *
+        * @param [out] IntVec   *pDataIds - Affected dataId sets.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getAffectedData(OUT IntVec *pDataIds) = 0;
+
+        /**
+        * @fn     getWatchCondition
+        * @brief Get watching conditions created from Context Model
+        *
+        * @param [out] ModelConditionVec *pModelConditions - Affected dataId sets.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getWatchCondition(OUT ModelConditionVec *pModelConditions) = 0;
 };
 
 static const OID OID_IConditionedQueryResult = { 0x4a24e85b, 0x8903, 0x4cf5, { 0x88, 0x7b, 0x65, 0xc2, 0xc3, 0x9e, 0x42, 0xfd } };
 /**
 * @class    IConditionedQueryResult
 * @brief    IConditionedQueryResult Interface
-*                       This class represents executed CQL's result data 
+*            This class represents executed CQL's result data
 *
 * @see
 */
 class IConditionedQueryResult : public IBase
 {
-public:
-       /**
-       * @fn     getConditionedModelCount
-       * @brief Get conditioned model count
-       *
-       * @param NONE
-       * 
-       * @return unsigned int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual unsigned int getConditionedModelCount() = 0;
-
-       /**
-       * @fn     getConditionedContextModel
-       * @brief Get conditioned model by index
-       *
-       * @param [in] unsigned int conditionedModelIndex - Index of Conditioned Model interface for retrieving
-       * @param [out] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT getConditionedContextModel(IN unsigned int conditionedModelIndex, OUT IConditionedModel **ppConditionedModel) = 0;
+    public:
+        /**
+        * @fn     getConditionedModelCount
+        * @brief Get conditioned model count
+        *
+        * @param NONE
+        *
+        * @return unsigned int
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual unsigned int getConditionedModelCount() = 0;
+
+        /**
+        * @fn     getConditionedContextModel
+        * @brief Get conditioned model by index
+        *
+        * @param [in] unsigned int conditionedModelIndex - Index of Conditioned Model interface for retrieving
+        * @param [out] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getConditionedContextModel(IN unsigned int conditionedModelIndex,
+                OUT IConditionedModel **ppConditionedModel) = 0;
 };
 
 /**
 * @class    IConditionedQueryEvent
 * @brief    IConditionedQueryEvent Interface
-*                       This class represents event interface that listening IConditionedQuery's results
+*            This class represents event interface that listening IConditionedQuery's results
 *
 * @see
 */
 class IConditionedQueryEvent
 {
-public:
-       /**
-       * @fn onConditionedQueryEvent
-       * @brief IConditionedQueryEvent interface's event callbacks for receiving query results
-       *
-       * @param [in] std::string ContextQuery - Entered ContetxQuery
-       * @param [out] int* cqid - ID of ContextQuery
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT onConditionedQueryEvent(IN int userTriggerId, IN IConditionedQueryResult *pConditionedQueryResult) = 0;
-       virtual ~IConditionedQueryEvent(){};
+    public:
+        /**
+        * @fn onConditionedQueryEvent
+        * @brief IConditionedQueryEvent interface's event callbacks for receiving query results
+        *
+        * @param [in] std::string ContextQuery - Entered ContetxQuery
+        * @param [out] int* cqid - ID of ContextQuery
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT onConditionedQueryEvent(IN int userTriggerId,
+                IN IConditionedQueryResult *pConditionedQueryResult) = 0;
+        virtual ~IConditionedQueryEvent() {};
 };
 
 static const OID OID_IConditionedQuery = { 0xd61373d1, 0x9727, 0x4a84, { 0x98, 0x14, 0x4c, 0xf, 0xed, 0x25, 0x52, 0xe3 } };
 /**
 * @class    IConditionedQuery
 * @brief    IConditionedQuery Interface
-*                       This class represents parsed CQL for data retrieving
+*            This class represents parsed CQL for data retrieving
 *
 * @see
 */
 class IConditionedQuery : public IBase
 {
-public:
-       /**
-       * @fn     registerConditionedModel
-       * @brief Register Conditioned Model for tracking triggers
-       *
-       * @param [in] IConditionedModel *pConditionedModel - Interface of Conditioned Model
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT registerConditionedModel(IN IConditionedModel *pConditionedModel) = 0;
-
-       /**
-       * @fn     activateTriggers
-       * @brief Activate triggers for data evaluating. This changed related ContextModel's status to running
-       *
-       * @param [in] int userTriggerId - Specify TriggerId for event listening
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT activateTriggers(IN int userTriggerId) = 0;
-
-       /**
-       * @fn     deactivateTriggers
-       * @brief Deactivate triggers for data evaluating.
-       *
-       * @param [in] int userTriggerId - Specify TriggerId for event listening
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT deactivateTriggers() = 0;
-
-       /**
-       * @fn     getConditionedQueryResult
-       * @brief Retrieves conditioned data from current cached data
-       *
-       * @param [out] IConditionedQueryResult **ppConditionedQueryResult - Interface of result reader
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getConditionedQueryResult(OUT IConditionedQueryResult **ppConditionedQueryResult) = 0;
-       
-       /**
-       * @fn     hasAllConditionedModels
-       * @brief Retrieves current conditioned query has all Conditioned ContextModels for evaluating
-       *
-       * @param NONE
-       * 
-       * @return bool
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual bool hasAllConditionedModels() = 0;
+    public:
+        /**
+        * @fn     registerConditionedModel
+        * @brief Register Conditioned Model for tracking triggers
+        *
+        * @param [in] IConditionedModel *pConditionedModel - Interface of Conditioned Model
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT registerConditionedModel(IN IConditionedModel *pConditionedModel) = 0;
+
+        /**
+        * @fn     activateTriggers
+        * @brief Activate triggers for data evaluating. This changed related ContextModel's status to running
+        *
+        * @param [in] int userTriggerId - Specify TriggerId for event listening
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT activateTriggers(IN int userTriggerId) = 0;
+
+        /**
+        * @fn     deactivateTriggers
+        * @brief Deactivate triggers for data evaluating.
+        *
+        * @param [in] int userTriggerId - Specify TriggerId for event listening
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT deactivateTriggers() = 0;
+
+        /**
+        * @fn     getConditionedQueryResult
+        * @brief Retrieves conditioned data from current cached data
+        *
+        * @param [out] IConditionedQueryResult **ppConditionedQueryResult - Interface of result reader
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getConditionedQueryResult(OUT IConditionedQueryResult **ppConditionedQueryResult)
+            = 0;
+
+        /**
+        * @fn     hasAllConditionedModels
+        * @brief Retrieves current conditioned query has all Conditioned ContextModels for evaluating
+        *
+        * @param NONE
+        *
+        * @return bool
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual bool hasAllConditionedModels() = 0;
 };
 
 static const OID OID_IContextModel = { 0xcc56003c, 0xa036, 0x4f27, { 0x9c, 0xb3, 0xdc, 0xaf, 0x1f, 0xb0, 0x81, 0x58 } };
 /**
 * @class    IContextModel
 * @brief    IContextModel Interface
-*                       This class represents Context Model
+*            This class represents Context Model
 *
 * @see
 */
 class IContextModel : public IBase
 {
-public:
-       enum Status {STATUS_ACTIVATE, STATUS_DEACTIVATE, STATUS_START_READ_VALUE, STATUS_STOP_READ_VALUE};
-       enum ActivationType {ACTIVATION_TYPE_GET, ACTIVATION_TYPE_SUBSCRIBE};
-       enum ConstructionType {CONSTRUCTION_TYPE_INTERNAL, CONSTRUCTION_TYPE_EXTERNAL, CONSTRUCTION_TYPE_REMOTE};
-
-       /**
-       * @fn     getModelId
-       * @brief Get current model's id used for Evaluation Engine
-       *
-       * @param NONE
-       * 
-       * @return int
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual int getModelId() = 0;
-
-       /**
-       * @fn     getModelName
-       * @brief Get current model's name
-       *
-       * @param NONE
-       * 
-       * @return std::string
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual std::string getModelName() = 0;
-
-       /**
-       * @fn     getConstructionType
-       * @brief Get current model's constructionType defined when created
-       *
-       * @param NONE
-       * 
-       * @return IContextModel::ConstructionType
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual ConstructionType getConstructionType() = 0;
-
-       /**
-       * @fn     getParentDataId
-       * @brief Get parent dataId related to model hierarchy
-       *
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] IContextModel *pParentModel - Designated parent Context Model
-       * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getParentDataId(IN int dataId, IN IContextModel *pParentModel, OUT int *pParentDataId) = 0;
-
-       /**
-       * @fn     getChildDataId
-       * @brief Get child dataId related to model hierarchy
-       *
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] IContextModel *pChildModel - Designated child Context Model
-       * @param [out] int *pParentDataId - Designated child Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getChildDataId(IN int dataId, IN IContextModel *pChildModel, OUT IntVec *pPath) = 0;
-
-       /**
-       * @fn     activate
-       * @brief Activate current model's working. Each call to activate will increase internal reference counter
-       *
-       * @param [in] ActivationType activationType - Specify current model's working type
-       * @param [in] int targetDeviceDataId - Specify target device's dataId
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT activate(IN ActivationType activationType, IN int targetDeviceDataId) = 0;
-
-       /**
-       * @fn     deactivate
-       * @brief Deactivate current model's working. Each call to deactivate will decrease internal reference counter\n
-       *        and finally deactivated when counter is 0
-       *
-       * @param [in] ActivationType activationType - Specify current model's working type
-       * @param [in] int targetDeviceDataId - Specify target device's dataId
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT deactivate(IN ActivationType activationType, IN int targetDeviceDataId) = 0;
-       //virtual SSMRESULT GetModelSchema(OUT ModelPropertyVec *pModelProperties) = 0;
-
-       /**
-       * @fn     addModelData
-       * @brief Add model data to Context Model
-       *
-       * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
-       * @param [in] ModelPropertyVec *pData - Packed data for adding
-       * @param [out] int *pDataId - Returned dataId that newly added
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT addModelData(IN int parentDataId, IN ModelPropertyVec *pData, OUT int *pDataId) = 0;
-
-       /**
-       * @fn     updateModelData
-       * @brief Update model data to Context Model 
-       *
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [in] ModelPropertyVec *pData - Packed data for updating
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT updateModelData(IN int dataId, IN ModelPropertyVec *pData) = 0;
-
-       /**
-       * @fn     deleteModelData
-       * @brief Delete model data using given index
-       *
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT deleteModelData(IN int dataId) = 0;
-
-       /**
-       * @fn     getModelData
-       * @brief Get model data
-       *
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [out] ModelPropertyVec *pData - Packed data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getModelData(IN int dataId, OUT ModelPropertyVec *pData) = 0;
-
-       /**
-       * @fn     getModelDataSet
-       * @brief Get model data set
-       *
-       * @param [in] int startIndex - Starting index of model data
-       * @param [in] int count - Number of data to retrieve
-       * @param [out] vector<ModelPropertyVec> *pData - Packed data
-       * @param [out] int *pLastIndex - Index of last data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getModelDataSet(IN int startIndex, IN int count, OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex) = 0;
-
-       /**
-       * @fn     createConditionedModel
-       * @brief Create Conditioned Model for data searching or triggering
-       *
-       * @param [in] ModelConditionVec *pModelConditionVec - Conditions that searching or triggering
-       * @param [out] IConditionedModel **ppConditionedModel - Created Conditioned Model interface
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT createConditionedModel(IN ModelConditionVec *pModelConditionVec, OUT IConditionedModel **ppConditionedModel) = 0;
-       //virtual SSMRESULT CleanUpModelData() = 0;
-
-       /**
-       * @fn     setLifeTime
-       * @brief Sets current model data's lifeTime
-       *
-       * @param [in] int seconds - model data's lifeTime
-       * 
-       * @return NONE
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void setLifeTime(std::string seconds) = 0;
+    public:
+        enum Status {STATUS_ACTIVATE, STATUS_DEACTIVATE, STATUS_START_READ_VALUE, STATUS_STOP_READ_VALUE};
+        enum ActivationType {ACTIVATION_TYPE_GET, ACTIVATION_TYPE_SUBSCRIBE};
+        enum ConstructionType {CONSTRUCTION_TYPE_INTERNAL, CONSTRUCTION_TYPE_EXTERNAL, CONSTRUCTION_TYPE_REMOTE};
+
+        /**
+        * @fn     getModelId
+        * @brief Get current model's id used for Evaluation Engine
+        *
+        * @param NONE
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual int getModelId() = 0;
+
+        /**
+        * @fn     getModelName
+        * @brief Get current model's name
+        *
+        * @param NONE
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual std::string getModelName() = 0;
+
+        /**
+        * @fn     getConstructionType
+        * @brief Get current model's constructionType defined when created
+        *
+        * @param NONE
+        *
+        * @return IContextModel::ConstructionType
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual ConstructionType getConstructionType() = 0;
+
+        /**
+        * @fn     getParentDataId
+        * @brief Get parent dataId related to model hierarchy
+        *
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] IContextModel *pParentModel - Designated parent Context Model
+        * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getParentDataId(IN int dataId, IN IContextModel *pParentModel,
+                                          OUT int *pParentDataId) = 0;
+
+        /**
+        * @fn     getChildDataId
+        * @brief Get child dataId related to model hierarchy
+        *
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] IContextModel *pChildModel - Designated child Context Model
+        * @param [out] int *pParentDataId - Designated child Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getChildDataId(IN int dataId, IN IContextModel *pChildModel,
+                                         OUT IntVec *pPath) = 0;
+
+        /**
+        * @fn     activate
+        * @brief Activate current model's working. Each call to activate will increase internal reference counter
+        *
+        * @param [in] ActivationType activationType - Specify current model's working type
+        * @param [in] int targetDeviceDataId - Specify target device's dataId
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT activate(IN ActivationType activationType, IN int targetDeviceDataId) = 0;
+
+        /**
+        * @fn     deactivate
+        * @brief Deactivate current model's working. Each call to deactivate will decrease internal reference counter\n
+        *        and finally deactivated when counter is 0
+        *
+        * @param [in] ActivationType activationType - Specify current model's working type
+        * @param [in] int targetDeviceDataId - Specify target device's dataId
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT deactivate(IN ActivationType activationType, IN int targetDeviceDataId) = 0;
+        //virtual SSMRESULT GetModelSchema(OUT ModelPropertyVec *pModelProperties) = 0;
+
+        /**
+        * @fn     addModelData
+        * @brief Add model data to Context Model
+        *
+        * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
+        * @param [in] ModelPropertyVec *pData - Packed data for adding
+        * @param [out] int *pDataId - Returned dataId that newly added
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT addModelData(IN int parentDataId, IN ModelPropertyVec *pData,
+                                       OUT int *pDataId) = 0;
+
+        /**
+        * @fn     updateModelData
+        * @brief Update model data to Context Model
+        *
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [in] ModelPropertyVec *pData - Packed data for updating
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT updateModelData(IN int dataId, IN ModelPropertyVec *pData) = 0;
+
+        /**
+        * @fn     deleteModelData
+        * @brief Delete model data using given index
+        *
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT deleteModelData(IN int dataId) = 0;
+
+        /**
+        * @fn     getModelData
+        * @brief Get model data
+        *
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [out] ModelPropertyVec *pData - Packed data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getModelData(IN int dataId, OUT ModelPropertyVec *pData) = 0;
+
+        /**
+        * @fn     getModelDataSet
+        * @brief Get model data set
+        *
+        * @param [in] int startIndex - Starting index of model data
+        * @param [in] int count - Number of data to retrieve
+        * @param [out] vector<ModelPropertyVec> *pData - Packed data
+        * @param [out] int *pLastIndex - Index of last data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getModelDataSet(IN int startIndex, IN int count,
+                                          OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex) = 0;
+
+        /**
+        * @fn     createConditionedModel
+        * @brief Create Conditioned Model for data searching or triggering
+        *
+        * @param [in] ModelConditionVec *pModelConditionVec - Conditions that searching or triggering
+        * @param [out] IConditionedModel **ppConditionedModel - Created Conditioned Model interface
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT createConditionedModel(IN ModelConditionVec *pModelConditionVec,
+                OUT IConditionedModel **ppConditionedModel) = 0;
+        //virtual SSMRESULT CleanUpModelData() = 0;
+
+        /**
+        * @fn     setLifeTime
+        * @brief Sets current model data's lifeTime
+        *
+        * @param [in] int seconds - model data's lifeTime
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void setLifeTime(std::string seconds) = 0;
 };
 
 /**
 * @class    IContextModelEvent
 * @brief    IContextModelEvent Interface
-*                       This class represents event interface for tracking IContextModel events
+*            This class represents event interface for tracking IContextModel events
 *
 * @see
 *
 * Copyright 2013 by Samsung Electronics, Inc.,
-* 
+*
 * This software is the confidential and proprietary information
 * of Samsung Electronics, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
@@ -907,90 +925,93 @@ public:
 */
 class IContextModelEvent
 {
-public:
-       /**
-       * @fn     onModelStatusChange
-       * @brief Called when ContextModel wants to activate or deactivate
-       *
-       * @param [in] IContextModel::Status newStatus - Context Model's new status
-       * @param [in] ISSMResource *pSSMResource - Instance of actual resource
-       * @param [in] IContextModel *pModel - Affected Context Model
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT onModelStatusChange(IN IContextModel::Status newStatus, IN ISSMResource *pSSMResource, IN IContextModel *pModel) = 0;
-       virtual ~IContextModelEvent(){}
+    public:
+        /**
+        * @fn     onModelStatusChange
+        * @brief Called when ContextModel wants to activate or deactivate
+        *
+        * @param [in] IContextModel::Status newStatus - Context Model's new status
+        * @param [in] ISSMResource *pSSMResource - Instance of actual resource
+        * @param [in] IContextModel *pModel - Affected Context Model
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT onModelStatusChange(IN IContextModel::Status newStatus,
+                                              IN ISSMResource *pSSMResource, IN IContextModel *pModel) = 0;
+        virtual ~IContextModelEvent() {}
 };
 
 /**
 * @class    IContextModelAccessor
 * @brief    IContextModelAccessor Interface
-*                       This class represents context model accessors
+*            This class represents context model accessors
 *
 * @see
 */
 class IContextModelAccessor
 {
-public:
-       /**
-       * @fn     onQueryContextModel
-       * @brief Called when ContextModelAccessor wants to query installed ContextModel
-       *
-       * @param [in] std::string modelName - ContextModel name to find out
-       * @param [out] IContextModel **ppContextModel - Interface of quried ContextModel
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT onQueryContextModel(IN std::string modelName, OUT IContextModel **ppContextModel) = 0;
-       virtual ~IContextModelAccessor(){}
+    public:
+        /**
+        * @fn     onQueryContextModel
+        * @brief Called when ContextModelAccessor wants to query installed ContextModel
+        *
+        * @param [in] std::string modelName - ContextModel name to find out
+        * @param [out] IContextModel **ppContextModel - Interface of quried ContextModel
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT onQueryContextModel(IN std::string modelName,
+                                              OUT IContextModel **ppContextModel) = 0;
+        virtual ~IContextModelAccessor() {}
 };
 
 static const OID OID_IContextDataReader = { 0x65ce481, 0xc5dd, 0x41dc, { 0xa3, 0xc1, 0xa4, 0x98, 0xc9, 0xa8, 0xcc, 0xd5 } };
 /**
 * @class    IContextDataReader
 * @brief    IContextDataReader Interface
-*                       This class represents context model database reader for context model developers
+*            This class represents context model database reader for context model developers
 *
 * @see
 */
 class IContextDataReader : public IBase
 {
-public:
-       /**
-       * @fn     registerContextModelAccessor
-       * @brief Called when ContextModelAccessor wants to query installed ContextModel
-       *
-       * @param [in] IContextModelAccessor *pContextModelAccessor - Instance of implemented IContextModelAccessor interface
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT registerContextModelAccessor(IN IContextModelAccessor *pContextModelAccessor) = 0;
-       
-       /**
-       * @fn     getContextData
-       * @brief Retrieve ContextData using given ContextModel name and dataId
-       *
-       * @param [in] std::string modelName - ContextModel name
-       * @param [in] int startIndex - Starting index of model data
-       * @param [in] int count - Number of data to retrieve
-       * @param [out] std::vector<ContextData> *data - ContextData set
-       * @param [out] int *pLastIndex - Index of last data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getContextData(IN std::string modelName, IN int startIndex, IN int count, OUT std::vector<ContextData> *data, OUT int *pLastIndex) = 0;
+    public:
+        /**
+        * @fn     registerContextModelAccessor
+        * @brief Called when ContextModelAccessor wants to query installed ContextModel
+        *
+        * @param [in] IContextModelAccessor *pContextModelAccessor - Instance of implemented IContextModelAccessor interface
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT registerContextModelAccessor(IN IContextModelAccessor *pContextModelAccessor) = 0;
+
+        /**
+        * @fn     getContextData
+        * @brief Retrieve ContextData using given ContextModel name and dataId
+        *
+        * @param [in] std::string modelName - ContextModel name
+        * @param [in] int startIndex - Starting index of model data
+        * @param [in] int count - Number of data to retrieve
+        * @param [out] std::vector<ContextData> *data - ContextData set
+        * @param [out] int *pLastIndex - Index of last data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getContextData(IN std::string modelName, IN int startIndex, IN int count,
+                                         OUT std::vector<ContextData> *data, OUT int *pLastIndex) = 0;
 };
 
 typedef std::vector<std::pair<std::string, ModelConditionVec> > QueryCondition;
@@ -999,58 +1020,60 @@ static const OID OID_IPropagationEngine = { 0xeb7e3d6c, 0x2cae, 0x43b3, { 0xb9,
 /**
 * @class    IPropagationEngine
 * @brief    IPropagationEngine Interface
-*                       This class represents propagation engine that manages ContextModel's automation
+*            This class represents propagation engine that manages ContextModel's automation
 *
 * @see
 */
 class IPropagationEngine : public IBase
 {
-public:
-       /**
-       * @fn     getContextModel
-       * @brief Retrieve ContextModel interface specified name
-       *
-       * @param [in] std::string modelName - ContextModel's name that looking for
-       * @param [out] IContextModel **ppContextModel - Interface pointer for retrieving
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT getContextModel(IN std:: string modelName, OUT IContextModel **ppContextModel) = 0;
-
-       /**
-       * @fn     createConditionedQuery
-       * @brief Create Conditioned Query using conditions
-       *
-       * @param [in] IContextModel::ActivationType activationType - ActivationType for ContextModel's working strategy
-       * @param [in] QueryCondition *pQueryCondition - Conditions for data retrieving
-       * @param [in] IConditionedQueryEvent *pEvent - Event interface for Conditioned Result listening
-       * @param [out] IConditionedQuery **ppConditionedQuery - Interface for retrieving Conditioned Query
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT createConditionedQuery(IN IContextModel::ActivationType activationType, IN QueryCondition *pQueryCondition,
-               IN IConditionedQueryEvent *pEvent, OUT IConditionedQuery **ppConditionedQuery) = 0;
+    public:
+        /**
+        * @fn     getContextModel
+        * @brief Retrieve ContextModel interface specified name
+        *
+        * @param [in] std::string modelName - ContextModel's name that looking for
+        * @param [out] IContextModel **ppContextModel - Interface pointer for retrieving
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getContextModel(IN std:: string modelName,
+                                          OUT IContextModel **ppContextModel) = 0;
+
+        /**
+        * @fn     createConditionedQuery
+        * @brief Create Conditioned Query using conditions
+        *
+        * @param [in] IContextModel::ActivationType activationType - ActivationType for ContextModel's working strategy
+        * @param [in] QueryCondition *pQueryCondition - Conditions for data retrieving
+        * @param [in] IConditionedQueryEvent *pEvent - Event interface for Conditioned Result listening
+        * @param [out] IConditionedQuery **ppConditionedQuery - Interface for retrieving Conditioned Query
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT createConditionedQuery(IN IContextModel::ActivationType activationType,
+                IN QueryCondition *pQueryCondition,
+                IN IConditionedQueryEvent *pEvent, OUT IConditionedQuery **ppConditionedQuery) = 0;
 };
 
 static const OID OID_IQueryEngineInternal = { 0x6eabf1a9, 0xe884, 0x4562, { 0x8b, 0x90, 0x1e, 0xe8, 0xba, 0xbf, 0xbe, 0x1a } };
 /**
 * @class    IQueryEngineInternal
 * @brief    IQueryEngineInternal Interface
-*                      This class manages ContextQuery at backend side.
+*           This class manages ContextQuery at backend side.
 *
-* @see      
-*                      CObject<CQueryEngine>   *pQueryEngine;
-*                      CreateInstance(OID_IQueryEngineInternal, (IBase**)&pQueryEngine);
-*                      pQeuryEngine->ExecuteContextQuery(contextquery,cqid);
+* @see
+*           CObject<CQueryEngine>   *pQueryEngine;
+*           CreateInstance(OID_IQueryEngineInternal, (IBase**)&pQueryEngine);
+*           pQeuryEngine->ExecuteContextQuery(contextquery,cqid);
 */
 class IQueryEngineInternal : public IBase
-       , public IQueryEngine
+    , public IQueryEngine
 {
 };
 
@@ -1059,239 +1082,241 @@ static const OID OID_IContextExecutor = { 0x92dcc900, 0xdc8a, 0x474b, { 0x87, 0x
  * @class    IContextExecutor
  * @brief    Interface for execute context model.
  *           Delegate requested context to lower layer.
- *                      Execute context model.
+ *           Execute context model.
  *
  * @see
  */
 class IContextExecutor : public IBase
-       , public IEvent
-       , public ICtxDelegate
+    , public IEvent
+    , public ICtxDelegate
 {
-public:
-       /**
-       * @fn     registerContext
-       * @brief  Register Context for receiving values
-       *
-       * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
-       * @param [in] ISSMResource *pSSMResouce - Requested Context model
-       * @param [in] IEvent *pEvent - Event interface for receiving data
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual void registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, IEvent *pEvent) = 0;
-
-       /**
-       * @fn     unregisterContext
-       * @brief  Unregister Context for receiving values
-       *
-       * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
-       * @param [in] ISSMResource *pSSMResouce - Requested Context model
-       * @param [in] IEvent *pEvent - Event interface for receiving data
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent) = 0;
+    public:
+        /**
+        * @fn     registerContext
+        * @brief  Register Context for receiving values
+        *
+        * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
+        * @param [in] ISSMResource *pSSMResouce - Requested Context model
+        * @param [in] IEvent *pEvent - Event interface for receiving data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, IEvent *pEvent) = 0;
+
+        /**
+        * @fn     unregisterContext
+        * @brief  Unregister Context for receiving values
+        *
+        * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
+        * @param [in] ISSMResource *pSSMResouce - Requested Context model
+        * @param [in] IEvent *pEvent - Event interface for receiving data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource,
+                                       IEvent *pEvent) = 0;
 };
 
 static const OID OID_IResponseReactor = { 0x3140a3dc, 0xf912, 0x4d88, { 0x97, 0x3c, 0x86, 0xe8, 0x35, 0x69, 0xa7, 0xf8 } };
 /**
  * @class    IResponseReactor
- * @brief    Interface for implement of reactor pattern 
+ * @brief    Interface for implement of reactor pattern
  *           Delegate requested context to context executor layer.
- *                      
+ *
  *
  * @see
  */
 class IResponseReactor : public IBase
-       , public IEvent
+    , public IEvent
 {
-public:
-       /**
-       * @fn     registerContext
-       * @brief  Register Context for receiving values
-       *
-       * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
-       * @param [in] ISSMResource *pSSMResouce - Requested Context model
-       * @param [in] IEvent *pEvent - Event interface for receiving data
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, IEvent *pEvent) = 0;
-
-       /**
-       * @fn     unregisterContext
-       * @brief  Unregister Context for receiving values
-       *
-       * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
-       * @param [in] ISSMResource *pSSMResouce - Requested Context model
-       * @param [in] IEvent *pEvent - Event interface for receiving data
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent) = 0;
-
-       /**
-       * @fn    getList
-       * @brief Get all available context models
-       *
-       * @param [out] std::vector<ISSMResource*> *pList - List of available context model
-       *
-       * @return NONE
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual void getList(std::vector<ISSMResource*> *pList) = 0;
+    public:
+        /**
+        * @fn     registerContext
+        * @brief  Register Context for receiving values
+        *
+        * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
+        * @param [in] ISSMResource *pSSMResouce - Requested Context model
+        * @param [in] IEvent *pEvent - Event interface for receiving data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void registerContext(TypeofEvent callType, ISSMResource *pSSMResouce, IEvent *pEvent) = 0;
+
+        /**
+        * @fn     unregisterContext
+        * @brief  Unregister Context for receiving values
+        *
+        * @param [in] TypeofEvent callType - Call types of Context data request, stream or current
+        * @param [in] ISSMResource *pSSMResouce - Requested Context model
+        * @param [in] IEvent *pEvent - Event interface for receiving data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource,
+                                       IEvent *pEvent) = 0;
+
+        /**
+        * @fn    getList
+        * @brief Get all available context models
+        *
+        * @param [out] std::vector<ISSMResource*> *pList - List of available context model
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void getList(std::vector<ISSMResource *> *pList) = 0;
 };
 
 class IResourceFinderEvent
 {
-public:
-       virtual SSMRESULT onResourceFound(IN ISSMResource *pSensor) = 0;
-       virtual SSMRESULT onResourceLost(IN ISSMResource *pSensor) = 0;
-       virtual ~IResourceFinderEvent(){}
+    public:
+        virtual SSMRESULT onResourceFound(IN ISSMResource *pSensor) = 0;
+        virtual SSMRESULT onResourceLost(IN ISSMResource *pSensor) = 0;
+        virtual ~IResourceFinderEvent() {}
 };
 
 static const OID OID_IResourceFinder = { 0x8f52a31f, 0x51d5, 0x462b, { 0xa9, 0x8d, 0x40, 0x70, 0xa3, 0xf6, 0xb5, 0x6f } };
 class IResourceFinder : public IBase
 {
-public:
-       virtual SSMRESULT registerResourceFinderEvent(IN IResourceFinderEvent*pEvent) = 0;
-       virtual SSMRESULT startResourceFinder() = 0;
-       virtual SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent) = 0;
-       virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0;
+    public:
+        virtual SSMRESULT registerResourceFinderEvent(IN IResourceFinderEvent *pEvent) = 0;
+        virtual SSMRESULT startResourceFinder() = 0;
+        virtual SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent) = 0;
+        virtual SSMRESULT stopObserveResource(IN ISSMResource *pSensor) = 0;
 };
 
 static const OID OID_IResourceConnectivity = { 0x8e42b098, 0x9aa5, 0x43f3, { 0x84, 0xa, 0x21, 0x44, 0xc9, 0x4c, 0xc7, 0x99 } };
 class IResourceConnectivity : public IBase
 {
-public:
-       virtual void* getPlatform() = 0;
+    public:
+        virtual void *getPlatform() = 0;
 };
 
 /**
 * @class    ISoftSensorManager
 * @brief    ISoftSensorManager Interface
-*                       This class represents main interface of SSM.
+*            This class represents main interface of SSM.
 *
-* @see      
-*                      static ISoftSensorManager               *g_pSoftSensorManager = NULL;
-*                      CreateInstance(OID_ISoftSensorManager, (IBase**)&g_pSoftSensorManager);
-*                      g_pSoftSensorManager->TerminateCore();
-*                      g_pSoftSensorManager->Release();
+* @see
+*           static ISoftSensorManager       *g_pSoftSensorManager = NULL;
+*           CreateInstance(OID_ISoftSensorManager, (IBase**)&g_pSoftSensorManager);
+*           g_pSoftSensorManager->TerminateCore();
+*           g_pSoftSensorManager->Release();
 */
 static const OID OID_ISoftSensorManager = { 0x6b9ce4cb, 0x31fe, 0x4b05, { 0xb4, 0xca, 0x10, 0x3d, 0x82, 0x59, 0x4f, 0x4d } };
 class ISoftSensorManager : public IBase
 {
-public:
-       /**
-       * @fn initializeCore
-       * @brief Initialize core using given configuration information.
-       *                       <SSMCore>
-       *                               <Device>
-       *                                       <UDN>windows7-31f8-11b4-a222-08002b34c003</UDN>
-       *                                       <Name>MyPC</Name>
-       *                                       <Type>PC</Type>
-       *                               </Device>
-       *                       </SSMCore>
-       *
-       * @param [in] std::string xmlDescription - specification described in XML
-       * @param [out] IBase** ppvObject - reference pointer to get instance pointer
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT initializeCore(IN std::string xmlDescription) = 0;
-
-       /**
-       * @fn startCore
-       * @brief Start Core.
-       *                 This enables network capability that can discover and discovered.
-       *
-       * @param None
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT startCore() = 0;
-
-       /**
-       * @fn stopCore
-       * @brief Stop Core.
-       *                 This disables network capability that can discover and discovered.
-       *
-       * @param None
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT stopCore() = 0;
-
-       /**
-       * @fn terminateCore
-       * @brief Terminates Core.
-       *                 Free all allocated resources
-       *
-       * @param None
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT terminateCore(IN bool factoryResetFlag) = 0;
-
-       /**
-       * @fn createQueryEngine
-       * @brief Create new Query Engine instance.
-       *                 Each engine instance has it's own event thread
-       *                 we recommend each application should creates only one instance.
-       *
-       * @param [out] IQueryEngine **ppQueryEngine - instance pointer of new Query Engine
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT createQueryEngine(OUT IQueryEngine **ppQueryEngine) = 0;
-
-       /**
-       * @fn releaseQueryEngine
-       * @brief Release exists Query Engine instance.
-       *
-       * @param [in] IQueryEngine *pQueryEngine - instance pointer of exists Query Engine
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual unsigned long releaseQueryEngine(IN IQueryEngine *pQueryEngine) = 0;
-
-       /**
-       * @fn getInstalledModelList
-       * @brief Gets all installed models from local and remote
-       *
-       * @param [out] std::vector<ISSMResource*> *pList - List of installed context model
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual SSMRESULT getInstalledModelList(OUT std::vector<ISSMResource*> *pList) = 0;
+    public:
+        /**
+        * @fn initializeCore
+        * @brief Initialize core using given configuration information.
+        *           <SSMCore>
+        *               <Device>
+        *                   <UDN>windows7-31f8-11b4-a222-08002b34c003</UDN>
+        *                   <Name>MyPC</Name>
+        *                   <Type>PC</Type>
+        *               </Device>
+        *           </SSMCore>
+        *
+        * @param [in] std::string xmlDescription - specification described in XML
+        * @param [out] IBase** ppvObject - reference pointer to get instance pointer
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT initializeCore(IN std::string xmlDescription) = 0;
+
+        /**
+        * @fn startCore
+        * @brief Start Core.
+        *         This enables network capability that can discover and discovered.
+        *
+        * @param None
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT startCore() = 0;
+
+        /**
+        * @fn stopCore
+        * @brief Stop Core.
+        *         This disables network capability that can discover and discovered.
+        *
+        * @param None
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT stopCore() = 0;
+
+        /**
+        * @fn terminateCore
+        * @brief Terminates Core.
+        *         Free all allocated resources
+        *
+        * @param None
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT terminateCore(IN bool factoryResetFlag) = 0;
+
+        /**
+        * @fn createQueryEngine
+        * @brief Create new Query Engine instance.
+        *         Each engine instance has it's own event thread
+        *         we recommend each application should creates only one instance.
+        *
+        * @param [out] IQueryEngine **ppQueryEngine - instance pointer of new Query Engine
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT createQueryEngine(OUT IQueryEngine **ppQueryEngine) = 0;
+
+        /**
+        * @fn releaseQueryEngine
+        * @brief Release exists Query Engine instance.
+        *
+        * @param [in] IQueryEngine *pQueryEngine - instance pointer of exists Query Engine
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual unsigned long releaseQueryEngine(IN IQueryEngine *pQueryEngine) = 0;
+
+        /**
+        * @fn getInstalledModelList
+        * @brief Gets all installed models from local and remote
+        *
+        * @param [out] std::vector<ISSMResource*> *pList - List of installed context model
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getInstalledModelList(OUT std::vector<ISSMResource *> *pList) = 0;
 };
 #endif
index 70dbc63..b2517e7 100644 (file)
 #endif
 #endif
 
-typedef struct _OID {
-       unsigned long  data1;
-       unsigned short data2;
-       unsigned short data3;
-       unsigned char  data4[8];
+typedef struct _OID
+{
+    unsigned long  data1;
+    unsigned short data2;
+    unsigned short data3;
+    unsigned char  data4[8];
 } OID;
 
 const OID OID_IBase = {0x3b465976, 0x6486, 0x4c1f, {0x84, 0xb9, 0xeb, 0x80, 0x79, 0x78, 0x2b, 0x8}};
 
 /**
-* @fn   IsEqualOID
+* @fn    IsEqualOID
 * @brief Compare both OID
 *
 * @param [in] SSMRESULT res - return code
 *
 * @return Return positive value if both equal
-* @warning      
-* @exception    
+* @warning
+* @exception
 * @see
 */
-inline int IsEqualOID(const OID& oid1, const OID& oid2)
+inline int IsEqualOID(const OID &oid1, const OID &oid2)
 {
-       return (
-               ((unsigned long *) &oid1)[0] == ((unsigned long *) &oid2)[0] &&
-               ((unsigned long *) &oid1)[1] == ((unsigned long *) &oid2)[1] &&
-               ((unsigned long *) &oid1)[2] == ((unsigned long *) &oid2)[2] &&
-               ((unsigned long *) &oid1)[3] == ((unsigned long *) &oid2)[3]);
+    return (
+               ((unsigned long *) &oid1)[0] == ((unsigned long *) &oid2)[0] &&
+               ((unsigned long *) &oid1)[1] == ((unsigned long *) &oid2)[1] &&
+               ((unsigned long *) &oid1)[2] == ((unsigned long *) &oid2)[2] &&
+               ((unsigned long *) &oid1)[3] == ((unsigned long *) &oid2)[3]);
 }
 
 /**
 * @class    IBase
 * @brief    IBase Interface
-*                       This class represents top interface of managed Object's interface\n
-*                       If any class wants to work as managed Object, must inherit this interface.
+*            This class represents top interface of managed Object's interface\n
+*            If any class wants to work as managed Object, must inherit this interface.
 *
 * @see
 */
 class IBase
 {
-public:
-       /**
-       * @fn     queryInterface
-       * @brief Query if requested interface support calling instance
-       *
-       * @param [in] const OID& interfaceID - Interface Id looking for
-       * @param [out] IBase** ppObject - Interface pointer holds the object
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT queryInterface(IN const OID& interfaceID, OUT IBase** ppObject) = 0;
-
-       /**
-       * @fn     addRef
-       * @brief Add reference counter, returns current counter value
-       *
-       * @param NONE
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual unsigned long addRef() = 0;
-
-       /**
-       * @fn     release
-       * @brief Release reference counter, returns current counter value and self destroyed if zero
-       *
-       * @param NONE
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual unsigned long release() = 0;
-       virtual ~IBase(){};
+    public:
+        /**
+        * @fn     queryInterface
+        * @brief Query if requested interface support calling instance
+        *
+        * @param [in] const OID& interfaceID - Interface Id looking for
+        * @param [out] IBase** ppObject - Interface pointer holds the object
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT queryInterface(IN const OID &interfaceID, OUT IBase **ppObject) = 0;
+
+        /**
+        * @fn     addRef
+        * @brief Add reference counter, returns current counter value
+        *
+        * @param NONE
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual unsigned long addRef() = 0;
+
+        /**
+        * @fn     release
+        * @brief Release reference counter, returns current counter value and self destroyed if zero
+        *
+        * @param NONE
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual unsigned long release() = 0;
+        virtual ~IBase() {};
 };
 
 class CObjectMultiThreadModel;
 /**
 * @class    CObjectRoot
 * @brief    CObjectRoot Interface
-*                       This class represents top class of managed Object\n
-*                       If any class wants to work as managed Object, must inherit this class.
+*            This class represents top class of managed Object\n
+*            If any class wants to work as managed Object, must inherit this class.
 *
 * @see
 */
 template <class ThreadModel = CObjectMultiThreadModel>
 class CObjectRoot
 {
-private:       
-       volatile unsigned long m_dwRef;
-
-public:
-       CObjectRoot()
-       {
-               m_dwRef = 0;
-       }
-
-       ~CObjectRoot()
-       {
-       }
-
-       /**
-       * @fn     internalAddRef
-       * @brief Add reference counter, returns current counter value
-       *
-       * @param NONE
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       unsigned long internalAddRef()
-       {
-               return ThreadModel::increment(&m_dwRef);
-       }
-
-       /**
-       * @fn     internalRelease
-       * @brief Release reference counter, returns current counter value
-       *
-       * @param NONE
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       unsigned long internalRelease()
-       {
-               return ThreadModel::decrement(&m_dwRef);
-       }
+    private:
+        volatile unsigned long m_dwRef;
+
+    public:
+        CObjectRoot()
+        {
+            m_dwRef = 0;
+        }
+
+        ~CObjectRoot()
+        {
+        }
+
+        /**
+        * @fn     internalAddRef
+        * @brief Add reference counter, returns current counter value
+        *
+        * @param NONE
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        unsigned long internalAddRef()
+        {
+            return ThreadModel::increment(&m_dwRef);
+        }
+
+        /**
+        * @fn     internalRelease
+        * @brief Release reference counter, returns current counter value
+        *
+        * @param NONE
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        unsigned long internalRelease()
+        {
+            return ThreadModel::decrement(&m_dwRef);
+        }
 };
 
 /**
 * @class    CObject
 * @brief    CObject Interface
-*                       This class provides a way to declare instance of managed Object\n
-*                       If user wants to declare instance of managed Object, must use this class.
+*            This class provides a way to declare instance of managed Object\n
+*            If user wants to declare instance of managed Object, must use this class.
 *
 * @see
 */
 template <class Base>
 class CObject :
-       public Base
+    public Base
 {
-public:
-       CObject()
-       {
-       }
-
-       virtual ~CObject()
-       {
-       }
-
-       /**
-       * @fn     addRef
-       * @brief Add reference counter, returns current counter value
-       *
-       * @param NONE
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       unsigned long addRef()
-       {
-               return this->internalAddRef();
-       }
-
-       /**
-       * @fn     release
-       * @brief Release reference counter, returns current counter value and self destroyed if zero
-       *
-       * @param NONE
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       unsigned long release()
-       {
-               unsigned long ref = this->internalRelease();
-               if(ref == 0)
-               {
-                       this->finalRelease();
-                       delete this;
-               }
-               return ref;
-       }
-
-       /**
-       * @fn createInstance
-       * @brief Create instance of current template class 
-       *
-       * @param [out] CObject<Base>** pp - reference pointer to get instance pointer
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       static SSMRESULT createInstance(CObject<Base>** pp)
-       {
-               SSMRESULT res = SSM_E_FAIL;
-
-               if(pp == NULL)
-               {
-                       return SSM_E_POINTER;
-               }
-
-               *pp = NULL;
-
-               CObject<Base> *p = new CObject<Base>();
-
-               if(p == NULL)
-               {
-                       return SSM_E_OUTOFMEMORY;
-               }
-
-               res = p->finalConstruct();
-
-               if(res != SSM_S_OK)
-               {
-                       delete p;
-                       p = NULL;
-                       return res;
-               }
-
-               *pp = p;
-
-               return SSM_S_OK;
-       }
+    public:
+        CObject()
+        {
+        }
+
+        virtual ~CObject()
+        {
+        }
+
+        /**
+        * @fn     addRef
+        * @brief Add reference counter, returns current counter value
+        *
+        * @param NONE
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        unsigned long addRef()
+        {
+            return this->internalAddRef();
+        }
+
+        /**
+        * @fn     release
+        * @brief Release reference counter, returns current counter value and self destroyed if zero
+        *
+        * @param NONE
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        unsigned long release()
+        {
+            unsigned long ref = this->internalRelease();
+            if (ref == 0)
+            {
+                this->finalRelease();
+                delete this;
+            }
+            return ref;
+        }
+
+        /**
+        * @fn createInstance
+        * @brief Create instance of current template class
+        *
+        * @param [out] CObject<Base>** pp - reference pointer to get instance pointer
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        static SSMRESULT createInstance(CObject<Base> **pp)
+        {
+            SSMRESULT res = SSM_E_FAIL;
+
+            if (pp == NULL)
+            {
+                return SSM_E_POINTER;
+            }
+
+            *pp = NULL;
+
+            CObject<Base> *p = new CObject<Base>();
+
+            if (p == NULL)
+            {
+                return SSM_E_OUTOFMEMORY;
+            }
+
+            res = p->finalConstruct();
+
+            if (res != SSM_S_OK)
+            {
+                delete p;
+                p = NULL;
+                return res;
+            }
+
+            *pp = p;
+
+            return SSM_S_OK;
+        }
 };
 
 
 /**
 * @class    _noAddRefReleaseOnCObjectPtr
 * @brief    _noAddRefReleaseOnCObjectPtr Interface
-*                       This class used for CObject's Smart pointer mechanism. Internal use only
+*            This class used for CObject's Smart pointer mechanism. Internal use only
 *
 * @see
 */
 template <class T>
 class _noAddRefReleaseOnCObjectPtr :
-       public T
+    public T
 {
-private:
-       virtual unsigned long addRef() = 0;
-       virtual unsigned long release() = 0;
+    private:
+        virtual unsigned long addRef() = 0;
+        virtual unsigned long release() = 0;
 };
 
 /**
 * @class    CObjectPtr
 * @brief    CObjectPtr Interface
-*                       This class used for declaring CObject's interface to work as Smart Pointer
+*            This class used for declaring CObject's interface to work as Smart Pointer
 *
 * @see
 */
 template <class T>
 class CObjectPtr
 {
-private:
-       T* p;
-public:
-       CObjectPtr()
-       {
-               p = NULL;
-       }
-
-       ~CObjectPtr()
-       {
-               SAFE_RELEASE(p);
-       }
-
-       _noAddRefReleaseOnCObjectPtr<T>* operator->() const
-       {
-               return (_noAddRefReleaseOnCObjectPtr<T>*)p;
-       }
-       
-       operator T*() const
-       {
-               return p;
-       }
-
-       T** operator&()
-       {
-               return &p;
-       }
-       /*
-       CObjectPtr(T* lp)
-       {
-               p = lp;
-               if(p != NULL)
-               p->AddRef();
-       }
-
-       CObjectPtr(const CObjectPtr<T>& lp)
-       :CObjectPtr(lp.p)
-       {
-       }
-
-       T& operator*() const
-       {
-               return *p;
-       }
-
-       T* operator=(T* lp)
-       {
-               return *this;
-       }
-
-       T* operator=(CObjectPtr<T>& lp)
-       {
-               return *this;
-       }
-
-       bool operator!() const
-       {
-               return (p == NULL);
-       }
-
-       bool operator<(T* pT) const
-       {
-               return !operator==(pT);
-       }
-
-       bool operator==(T* pT) const
-       {
-               return p == pT;
-       }
-       */
+    private:
+        T *p;
+    public:
+        CObjectPtr()
+        {
+            p = NULL;
+        }
+
+        ~CObjectPtr()
+        {
+            SAFE_RELEASE(p);
+        }
+
+        _noAddRefReleaseOnCObjectPtr<T> *operator->() const
+        {
+            return (_noAddRefReleaseOnCObjectPtr<T> *)p;
+        }
+
+        operator T *() const
+        {
+            return p;
+        }
+
+        T **operator&()
+        {
+            return &p;
+        }
+        /*
+        CObjectPtr(T* lp)
+        {
+            p = lp;
+            if(p != NULL)
+            p->AddRef();
+        }
+
+        CObjectPtr(const CObjectPtr<T>& lp)
+        :CObjectPtr(lp.p)
+        {
+        }
+
+        T& operator*() const
+        {
+            return *p;
+        }
+
+        T* operator=(T* lp)
+        {
+            return *this;
+        }
+
+        T* operator=(CObjectPtr<T>& lp)
+        {
+            return *this;
+        }
+
+        bool operator!() const
+        {
+            return (p == NULL);
+        }
+
+        bool operator<(T* pT) const
+        {
+            return !operator==(pT);
+        }
+
+        bool operator==(T* pT) const
+        {
+            return p == pT;
+        }
+        */
 };
 
 /**
@@ -382,35 +383,35 @@ public:
 * @param [in] const OID& interfaceID - Interface Id looking for
 * @param [out] IBase** ppObject - reference pointer to get instance pointer
 * @return SSMRESULT
-* @warning      
-* @exception    
-* @see 
+* @warning
+* @exception
+* @see
 */
 template <class T>
-SSMRESULT CreateNewObject(IN const OID& objectID, OUT IBase** ppObject)
+SSMRESULT CreateNewObject(IN const OID &objectID, OUT IBase **ppObject)
 {
-       SSMRESULT res = SSM_E_OUTOFMEMORY;
+    SSMRESULT res = SSM_E_OUTOFMEMORY;
 
-       CObject<T> *p = new CObject<T>();
+    CObject<T> *p = new CObject<T>();
 
-       if(p == NULL)
-       {
-               goto END;
-       }
+    if (p == NULL)
+    {
+        goto END;
+    }
 
-       res = p->finalConstruct();
+    res = p->finalConstruct();
 
-       if(res != SSM_S_OK)
-       {
-               delete p;
-               p = NULL;
-               goto END;
-       }
+    if (res != SSM_S_OK)
+    {
+        delete p;
+        p = NULL;
+        goto END;
+    }
 
-       res = p->queryInterface(objectID, ppObject);
+    res = p->queryInterface(objectID, ppObject);
 
 END:
-       return res;
+    return res;
 }
 
 #endif
index a102ee7..531e1be 100644 (file)
 #define REPORT_MESSAGE(tag, msg) {printf("[%s] %s\n", tag, msg);}
 
 #define SSM_VOID_ASSERT(Exp, STRErrorMsg) \
-       { \
-       if(!(Exp)) \
-               { \
-               printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, STRErrorMsg); \
-               assert(0); \
-               return; \
-               } \
-       }
+    { \
+    if(!(Exp)) \
+        { \
+        printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, STRErrorMsg); \
+        assert(0); \
+        return; \
+        } \
+    }
 
 #define SSM_RESULT_ASSERT(Exp, STRErrorMsg, Result) \
-       { \
-       if(!(Exp)) \
-               { \
-               printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, STRErrorMsg); \
-               assert(0); \
-               return Result; \
-               } \
-       }
+    { \
+    if(!(Exp)) \
+        { \
+        printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, STRErrorMsg); \
+        assert(0); \
+        return Result; \
+        } \
+    }
 
 #define SSM_CLEANUP_ASSERT(Exp) \
-       { \
-       if((res = (Exp)) != SSM_S_OK) \
-               { \
-               printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, GetSSMError(res)); \
-               assert(0); \
-               goto CLEANUP; \
-               } \
-       }
+    { \
+    if((res = (Exp)) != SSM_S_OK) \
+        { \
+        printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, GetSSMError(res)); \
+        assert(0); \
+        goto CLEANUP; \
+        } \
+    }
 
 #define SSM_CLEANUP_COND_ASSERT(Exp, Cond, STRErrorMsg) \
-       { \
-       if(Exp != Cond) \
-               { \
-               printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, STRErrorMsg); \
-               assert(0); \
-               goto CLEANUP; \
-               } \
-       }
+    { \
+    if(Exp != Cond) \
+        { \
+        printf("[SSM] %s:%d Return message: %s\n", __FUNCTION__, __LINE__, STRErrorMsg); \
+        assert(0); \
+        goto CLEANUP; \
+        } \
+    }
 
 #define SSM_CLEANUP_NULL_ASSERT(Val) \
-       { \
-       if(!(Val)) \
-               { \
-               printf("[SSM] %s:%d Return message: NULL value\n", __FUNCTION__, __LINE__); \
-               assert(Val); \
-               goto CLEANUP; \
-               } \
-       }
+    { \
+    if(!(Val)) \
+        { \
+        printf("[SSM] %s:%d Return message: NULL value\n", __FUNCTION__, __LINE__); \
+        assert(Val); \
+        goto CLEANUP; \
+        } \
+    }
 
 #elif defined(ANDROID)
 
@@ -106,107 +106,107 @@ void ReportMessage(const char *tag, const char *msg);
 #define REPORT_MESSAGE(tag, msg) {ReportMessage(tag, msg);}
 
 #define SSM_VOID_ASSERT(Exp, STRErrorMsg) \
-       { \
-               if(!(Exp)) \
-               { \
-                       __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, STRErrorMsg); \
-                       assert(0); \
-                       return; \
-               } \
-       }
+    { \
+        if(!(Exp)) \
+        { \
+            __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, STRErrorMsg); \
+            assert(0); \
+            return; \
+        } \
+    }
 
 #define SSM_RESULT_ASSERT(Exp, STRErrorMsg, Result) \
-       { \
-               if(!(Exp)) \
-               { \
-                       __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, STRErrorMsg); \
-                       assert(0); \
-                       return Result; \
-               } \
-       }
+    { \
+        if(!(Exp)) \
+        { \
+            __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, STRErrorMsg); \
+            assert(0); \
+            return Result; \
+        } \
+    }
 
 #define SSM_CLEANUP_ASSERT(Exp) \
-       { \
-               if((res = (Exp)) != SSM_S_OK) \
-               { \
-                       __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, GetSSMError(res)); \
-                       assert(0); \
-                       goto CLEANUP; \
-               } \
-       }
+    { \
+        if((res = (Exp)) != SSM_S_OK) \
+        { \
+            __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, GetSSMError(res)); \
+            assert(0); \
+            goto CLEANUP; \
+        } \
+    }
 
 #define SSM_CLEANUP_COND_ASSERT(Exp, Cond, STRErrorMsg) \
-       { \
-               if(Exp != Cond) \
-               { \
-                       __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, STRErrorMsg); \
-                       assert(0); \
-                       goto CLEANUP; \
-               } \
-       }
+    { \
+        if(Exp != Cond) \
+        { \
+            __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: %s", __PRETTY_FUNCTION__, __LINE__, STRErrorMsg); \
+            assert(0); \
+            goto CLEANUP; \
+        } \
+    }
 
 #define SSM_CLEANUP_NULL_ASSERT(Val) \
-       { \
-               if(!(Val)) \
-               { \
-                       __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: NULL value", __PRETTY_FUNCTION__, __LINE__); \
-                       assert(Val); \
-                       goto CLEANUP; \
-               } \
-       }
+    { \
+        if(!(Val)) \
+        { \
+            __android_log_print(ANDROID_LOG_ERROR, "[SSM]", "%s:%d Return message: NULL value", __PRETTY_FUNCTION__, __LINE__); \
+            assert(Val); \
+            goto CLEANUP; \
+        } \
+    }
 
 #elif defined(TIZEN)
 #define REPORT_MESSAGE(tag, msg)
 
 #define SSM_VOID_ASSERT(Exp, STRErrorMsg) \
-       { \
-       if(!(Exp)) \
-               { \
-               AppLog("%s", STRErrorMsg); \
-               assert(0); \
-               return; \
-               } \
-       }
+    { \
+    if(!(Exp)) \
+        { \
+        AppLog("%s", STRErrorMsg); \
+        assert(0); \
+        return; \
+        } \
+    }
 
 #define SSM_RESULT_ASSERT(Exp, STRErrorMsg, Result) \
-       { \
-       if(!(Exp)) \
-               { \
-               AppLog("%s", STRErrorMsg); \
-               assert(0); \
-               return Result; \
-               } \
-       }
+    { \
+    if(!(Exp)) \
+        { \
+        AppLog("%s", STRErrorMsg); \
+        assert(0); \
+        return Result; \
+        } \
+    }
 
 #define SSM_CLEANUP_ASSERT(Exp) \
-       { \
-       if((res = (Exp)) != SSM_S_OK) \
-               { \
-               AppLog("%s", GetSSMError(res)); \
-               assert(0); \
-               goto CLEANUP; \
-               } \
-       }
+    { \
+    if((res = (Exp)) != SSM_S_OK) \
+        { \
+        AppLog("%s", GetSSMError(res)); \
+        assert(0); \
+        goto CLEANUP; \
+        } \
+    }
 
 #define SSM_CLEANUP_COND_ASSERT(Exp, Cond, STRErrorMsg) \
-       { \
-       if(Exp != Cond) \
-               { \
-               AppLog("%s", STRErrorMsg); \
-               assert(0); \
-               goto CLEANUP; \
-               } \
-       }
+    { \
+    if(Exp != Cond) \
+        { \
+        AppLog("%s", STRErrorMsg); \
+        assert(0); \
+        goto CLEANUP; \
+        } \
+    }
 
 #define SSM_CLEANUP_NULL_ASSERT(Val) \
-       { \
-       if(!(Val)) \
-               { \
-               AppLog("NULL value"); \
-               assert(Val); \
-               goto CLEANUP; \
-               } \
-       }
+    { \
+    if(!(Val)) \
+        { \
+        AppLog("NULL value"); \
+        assert(Val); \
+        goto CLEANUP; \
+        } \
+    }
 
 #endif
 
@@ -225,31 +225,31 @@ typedef std::vector<int> IntVec;
 /**
 * @fn createInstance
 * @brief Create instance using given OID (Object ID).
-*                After using the IBase object, you must call Release method.
+*         After using the IBase object, you must call Release method.
 *
 * @param [in] const OID& objectID - objectID
 * @param [out] IBase** ppObject - reference pointer to get instance pointer
 * @return SSMRESULT
-* @warning      
-* @exception    
-* @see 
+* @warning
+* @exception
+* @see
 */
-INTERFACE_DECLSPEC SSMRESULT CreateInstance(IN const OID& objectID, OUT IBase** ppObject);
+INTERFACE_DECLSPEC SSMRESULT CreateInstance(IN const OID &objectID, OUT IBase **ppObject);
 
 /**
 * @fn createGlobalInstance
 * @brief Create global instance using given OID (Object ID).
 *        The instance is managed by global instance map.
-*                After using the IBase object, you must call Release method.
+*         After using the IBase object, you must call Release method.
 *
 * @param [in] const OID& objectID - objectID
 * @param [out] IBase** ppObject - reference pointer to get instance pointer
 * @return SSMRESULT
-* @warning      
-* @exception    
-* @see 
+* @warning
+* @exception
+* @see
 */
-INTERFACE_DECLSPEC SSMRESULT CreateGlobalInstance(IN const OID& objectID, OUT IBase** ppObject);
+INTERFACE_DECLSPEC SSMRESULT CreateGlobalInstance(IN const OID &objectID, OUT IBase **ppObject);
 
 INTERFACE_DECLSPEC SSMRESULT CreateGlobalInstanceRepo();
 
index 8ab9b07..bb86402 100644 (file)
@@ -3,11 +3,11 @@
 CSimpleMutex::CSimpleMutex()
 {
 #if defined(WIN32)
-       InitializeCriticalSection(&m_criticalSection);
+    InitializeCriticalSection(&m_criticalSection);
 #elif defined(LINUX)
-       pthread_mutexattr_init(&m_mutexAttribute);
-       pthread_mutexattr_settype(&m_mutexAttribute, PTHREAD_MUTEX_RECURSIVE);
-       pthread_mutex_init(&m_mutex, &m_mutexAttribute);
+    pthread_mutexattr_init(&m_mutexAttribute);
+    pthread_mutexattr_settype(&m_mutexAttribute, PTHREAD_MUTEX_RECURSIVE);
+    pthread_mutex_init(&m_mutex, &m_mutexAttribute);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
@@ -16,10 +16,10 @@ CSimpleMutex::CSimpleMutex()
 CSimpleMutex::~CSimpleMutex()
 {
 #if defined(WIN32)
-       DeleteCriticalSection(&m_criticalSection);
+    DeleteCriticalSection(&m_criticalSection);
 #elif defined(LINUX)
-       pthread_mutex_destroy(&m_mutex);
-       pthread_mutexattr_destroy(&m_mutexAttribute);
+    pthread_mutex_destroy(&m_mutex);
+    pthread_mutexattr_destroy(&m_mutexAttribute);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
@@ -28,9 +28,9 @@ CSimpleMutex::~CSimpleMutex()
 void CSimpleMutex::lock()
 {
 #if defined(WIN32)
-       EnterCriticalSection(&m_criticalSection);
+    EnterCriticalSection(&m_criticalSection);
 #elif defined(LINUX)
-       pthread_mutex_lock(&m_mutex);
+    pthread_mutex_lock(&m_mutex);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
@@ -39,9 +39,9 @@ void CSimpleMutex::lock()
 void CSimpleMutex::unlock()
 {
 #if defined(WIN32)
-       LeaveCriticalSection(&m_criticalSection);
+    LeaveCriticalSection(&m_criticalSection);
 #elif defined(LINUX)
-       pthread_mutex_unlock(&m_mutex);
+    pthread_mutex_unlock(&m_mutex);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
@@ -59,45 +59,45 @@ CSemaphore::~CSemaphore()
 SSMRESULT CSemaphore::initialize()
 {
 #if defined(WIN32)
-       hSemaphore = CreateSemaphore(NULL, 1, 1, NULL);
+    hSemaphore = CreateSemaphore(NULL, 1, 1, NULL);
 
-       if (hSemaphore == NULL)
-               return SSM_E_FAIL;
+    if (hSemaphore == NULL)
+        return SSM_E_FAIL;
 #elif defined(LINUX)
-       if (sem_init(&hSemaphore, 0, 0) == -1)
-               return SSM_E_FAIL;
+    if (sem_init(&hSemaphore, 0, 0) == -1)
+        return SSM_E_FAIL;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CSemaphore::destroy()
 {
 #if defined(WIN32)
-       if (CloseHandle(hSemaphore) == FALSE)
-               return SSM_E_FAIL;
+    if (CloseHandle(hSemaphore) == FALSE)
+        return SSM_E_FAIL;
 #elif defined(LINUX)
-       if (sem_destroy(&hSemaphore) == -1)
-               return SSM_E_FAIL;
+    if (sem_destroy(&hSemaphore) == -1)
+        return SSM_E_FAIL;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CSemaphore::take()
 {
 #if defined(WIN32)
-       if (WaitForSingleObject(hSemaphore, INFINITE) == WAIT_OBJECT_0)
-               return SSM_S_OK;
+    if (WaitForSingleObject(hSemaphore, INFINITE) == WAIT_OBJECT_0)
+        return SSM_S_OK;
 
-       return SSM_E_FAIL;
+    return SSM_E_FAIL;
 #elif defined(LINUX)
-       if (sem_wait(&hSemaphore) == -1)
-               return SSM_E_FAIL;
+    if (sem_wait(&hSemaphore) == -1)
+        return SSM_E_FAIL;
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
@@ -106,15 +106,15 @@ SSMRESULT CSemaphore::take()
 SSMRESULT CSemaphore::give()
 {
 #if defined(WIN32)
-       if (ReleaseSemaphore(hSemaphore, 1, NULL) != 0)
-               return SSM_S_OK;
+    if (ReleaseSemaphore(hSemaphore, 1, NULL) != 0)
+        return SSM_S_OK;
 
-       return SSM_E_FAIL;
+    return SSM_E_FAIL;
 #elif defined(LINUX)
-       if (sem_post(&hSemaphore) == -1)
-               return SSM_E_FAIL;
+    if (sem_post(&hSemaphore) == -1)
+        return SSM_E_FAIL;
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
@@ -123,147 +123,147 @@ SSMRESULT CSemaphore::give()
 
 bool CWorkerThread::getTask(ClientEntry *clientEntry)
 {
-       m_mtxClientEntry.lock();
-       //Check empty
-       if (m_ClientEntry.empty())
-       {
-               m_mtxClientEntry.unlock();
-               //Sleep if there are no more tasks
-               m_semTask.take();
-       }
-       else
-       {
-               m_mtxClientEntry.unlock();
-       }
-
-       //Check destroy
-       m_mtxThreadTerm.lock();
-       if (m_bThreadTerm == true)
-       {
-               m_mtxThreadTerm.unlock();
-               return false;
-       }
-       m_mtxThreadTerm.unlock();
-
-       m_mtxClientEntry.lock();
-       if (!m_ClientEntry.empty())
-       {
-               *clientEntry = m_ClientEntry.front();
-               m_ClientEntry.pop_front();
-       }
-       m_mtxClientEntry.unlock();
-
-       return true;
+    m_mtxClientEntry.lock();
+    //Check empty
+    if (m_ClientEntry.empty())
+    {
+        m_mtxClientEntry.unlock();
+        //Sleep if there are no more tasks
+        m_semTask.take();
+    }
+    else
+    {
+        m_mtxClientEntry.unlock();
+    }
+
+    //Check destroy
+    m_mtxThreadTerm.lock();
+    if (m_bThreadTerm == true)
+    {
+        m_mtxThreadTerm.unlock();
+        return false;
+    }
+    m_mtxThreadTerm.unlock();
+
+    m_mtxClientEntry.lock();
+    if (!m_ClientEntry.empty())
+    {
+        *clientEntry = m_ClientEntry.front();
+        m_ClientEntry.pop_front();
+    }
+    m_mtxClientEntry.unlock();
+
+    return true;
 }
 
 void CWorkerThread::worker()
 {
-       ClientEntry clientEntry;
-
-       m_semTask.initialize();
-
-       //Thread Creation completed
-       m_semInit.give();
-
-       //Wait for any tasks
-       while (getTask(&clientEntry))
-       {
-               if (clientEntry.pClient)
-               {
-                       clientEntry.pClient->onExecute(clientEntry.pArg);
-                       clientEntry.pClient->onTerminate(clientEntry.pArg);
-               }
-               SAFE_RELEASE(clientEntry.pClient);
-       }
-
-       //Clean all remaining tasks
-       m_mtxClientEntry.lock();
-       //Remove all tasks from queue
-       for (std::list<ClientEntry>::iterator itor = m_ClientEntry.begin();
-               itor != m_ClientEntry.end(); ++itor)
-       {
-               ClientEntry clientEntry = *itor;
-               clientEntry.pClient->onTerminate(clientEntry.pArg);
-               SAFE_RELEASE(clientEntry.pClient);
-       }
-       m_ClientEntry.clear();
-       m_mtxClientEntry.unlock();
-
-       m_semTask.destroy();
-
-       m_semTerm.give();
+    ClientEntry clientEntry;
+
+    m_semTask.initialize();
+
+    //Thread Creation completed
+    m_semInit.give();
+
+    //Wait for any tasks
+    while (getTask(&clientEntry))
+    {
+        if (clientEntry.pClient)
+        {
+            clientEntry.pClient->onExecute(clientEntry.pArg);
+            clientEntry.pClient->onTerminate(clientEntry.pArg);
+        }
+        SAFE_RELEASE(clientEntry.pClient);
+    }
+
+    //Clean all remaining tasks
+    m_mtxClientEntry.lock();
+    //Remove all tasks from queue
+    for (std::list<ClientEntry>::iterator itor = m_ClientEntry.begin();
+         itor != m_ClientEntry.end(); ++itor)
+    {
+        ClientEntry clientEntry = *itor;
+        clientEntry.pClient->onTerminate(clientEntry.pArg);
+        SAFE_RELEASE(clientEntry.pClient);
+    }
+    m_ClientEntry.clear();
+    m_mtxClientEntry.unlock();
+
+    m_semTask.destroy();
+
+    m_semTerm.give();
 }
 
 SSMRESULT CWorkerThread::initialize()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       //Create thread and wait for jobs
+    //Create thread and wait for jobs
 #if defined(WIN32)
-       m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)_worker,
-               this, 0, NULL);
+    m_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)_worker,
+                             this, 0, NULL);
 
-       if (m_hThread == NULL)
-       {
-               return SSM_E_FAIL;
-       }
+    if (m_hThread == NULL)
+    {
+        return SSM_E_FAIL;
+    }
 #elif defined(LINUX)
-       if (pthread_create(&m_hThread, NULL, (void*(*)(void*))_worker, (void*)this) != 0)
-       {
-               return SSM_E_FAIL;
-       }
+    if (pthread_create(&m_hThread, NULL, (void *(*)(void *))_worker, (void *)this) != 0)
+    {
+        return SSM_E_FAIL;
+    }
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       //Wait till thread created
-       SSM_CLEANUP_ASSERT(m_semInit.take());
-       SSM_CLEANUP_ASSERT(m_semInit.destroy());
+    //Wait till thread created
+    SSM_CLEANUP_ASSERT(m_semInit.take());
+    SSM_CLEANUP_ASSERT(m_semInit.destroy());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CWorkerThread::terminate()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       //Let worker destroyed
-       m_mtxThreadTerm.lock();
-       m_bThreadTerm = true;
-       m_mtxThreadTerm.unlock();
+    //Let worker destroyed
+    m_mtxThreadTerm.lock();
+    m_bThreadTerm = true;
+    m_mtxThreadTerm.unlock();
 
-       SSM_CLEANUP_ASSERT(m_semTask.give());
+    SSM_CLEANUP_ASSERT(m_semTask.give());
 
-       SSM_CLEANUP_ASSERT(m_semTerm.take());
-       SSM_CLEANUP_ASSERT(m_semTerm.destroy());
+    SSM_CLEANUP_ASSERT(m_semTerm.take());
+    SSM_CLEANUP_ASSERT(m_semTerm.destroy());
 
 #if defined(WIN32)
-       if (m_hThread != NULL)
-       {
-               CloseHandle(m_hThread);
-       }
+    if (m_hThread != NULL)
+    {
+        CloseHandle(m_hThread);
+    }
 #elif defined(LINUX)
-       pthread_detach(m_hThread);
+    pthread_detach(m_hThread);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CWorkerThread::finalConstruct()
 {
-       SSMRESULT       res = SSM_E_FAIL;
+    SSMRESULT   res = SSM_E_FAIL;
 
-       m_bThreadTerm = false;
+    m_bThreadTerm = false;
 
-       SSM_CLEANUP_ASSERT(m_semInit.initialize());
-       SSM_CLEANUP_ASSERT(m_semTerm.initialize());
+    SSM_CLEANUP_ASSERT(m_semInit.initialize());
+    SSM_CLEANUP_ASSERT(m_semTerm.initialize());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CWorkerThread::finalRelease()
@@ -272,35 +272,35 @@ void CWorkerThread::finalRelease()
 
 SSMRESULT CWorkerThread::addTask(IThreadClient *pThreadClient, void *param)
 {
-       ClientEntry clientEntry;
-
-       pThreadClient->addRef();
-       clientEntry.pClient = pThreadClient;
-       clientEntry.pArg = param;
-
-       m_mtxClientEntry.lock();
-       if (m_ClientEntry.empty())
-       {
-               m_semTask.give();
-       }
-       m_ClientEntry.push_back(clientEntry);
-       //Let the task worker know, we just added task
-       m_mtxClientEntry.unlock();
-
-       return SSM_S_OK;
+    ClientEntry clientEntry;
+
+    pThreadClient->addRef();
+    clientEntry.pClient = pThreadClient;
+    clientEntry.pArg = param;
+
+    m_mtxClientEntry.lock();
+    if (m_ClientEntry.empty())
+    {
+        m_semTask.give();
+    }
+    m_ClientEntry.push_back(clientEntry);
+    //Let the task worker know, we just added task
+    m_mtxClientEntry.unlock();
+
+    return SSM_S_OK;
 }
 
 
 SSMRESULT CTasker::finalConstruct()
 {
-       SSMRESULT       res = SSM_E_FAIL;
+    SSMRESULT   res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IThreadPool, (IBase**)&m_pThreadPool));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IThreadPool, (IBase **)&m_pThreadPool));
 
-       SSM_CLEANUP_ASSERT(m_pThreadPool->createWorkerThread(&m_pWorkerThread));
+    SSM_CLEANUP_ASSERT(m_pThreadPool->createWorkerThread(&m_pWorkerThread));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CTasker::finalRelease()
@@ -309,53 +309,53 @@ void CTasker::finalRelease()
 
 SSMRESULT CTasker::addTask(IThreadClient *pThreadClient, void *param)
 {
-       return m_pWorkerThread->addTask(pThreadClient, param);
+    return m_pWorkerThread->addTask(pThreadClient, param);
 }
 
 
 SSMRESULT CThreadPool::finalConstruct()
 {
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 void CThreadPool::finalRelease()
 {
-       for (std::vector<IWorkerThread*>::iterator itor = m_lstWorkerThread.begin();
-               itor != m_lstWorkerThread.end(); ++itor)
-       {
-               (*itor)->release();
-       }
+    for (std::vector<IWorkerThread *>::iterator itor = m_lstWorkerThread.begin();
+         itor != m_lstWorkerThread.end(); ++itor)
+    {
+        (*itor)->release();
+    }
 }
 
 SSMRESULT CThreadPool::createWorkerThread(OUT IWorkerThread **ppWorkerThread)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       IWorkerThread           *pWorkerThread = NULL;
+    IWorkerThread       *pWorkerThread = NULL;
 
-       SSM_CLEANUP_NULL_ASSERT(ppWorkerThread);
-       
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IWorkerThread, (IBase**)&pWorkerThread));
-       SSM_CLEANUP_ASSERT(pWorkerThread->initialize());
-       SSM_CLEANUP_ASSERT(pWorkerThread->queryInterface(OID_IWorkerThread, (IBase**)ppWorkerThread));
-       m_lstWorkerThread.push_back(pWorkerThread);
+    SSM_CLEANUP_NULL_ASSERT(ppWorkerThread);
+
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IWorkerThread, (IBase **)&pWorkerThread));
+    SSM_CLEANUP_ASSERT(pWorkerThread->initialize());
+    SSM_CLEANUP_ASSERT(pWorkerThread->queryInterface(OID_IWorkerThread, (IBase **)ppWorkerThread));
+    m_lstWorkerThread.push_back(pWorkerThread);
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CThreadPool::destroyThreadPool()
 {
-       SSMRESULT       res = SSM_E_FAIL;
+    SSMRESULT   res = SSM_E_FAIL;
 
-       for (std::vector<IWorkerThread*>::iterator itor = m_lstWorkerThread.begin();
-               itor != m_lstWorkerThread.end(); ++itor)
-       {
-               SSM_CLEANUP_ASSERT((*itor)->terminate());
-       }
+    for (std::vector<IWorkerThread *>::iterator itor = m_lstWorkerThread.begin();
+         itor != m_lstWorkerThread.end(); ++itor)
+    {
+        SSM_CLEANUP_ASSERT((*itor)->terminate());
+    }
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
\ No newline at end of file
index 710e43b..ca6b9b5 100644 (file)
@@ -26,234 +26,234 @@ static const OID OID_IThreadClient = { 0x6f379191, 0xd9f1, 0x480c, { 0xac, 0x23,
 /**
 * @class    IThreadClient
 * @brief    IThreadClient Interface
-*                       This class represents thread client that called from worker thread.\n
-*                       The application who wants to use worker thread, inherit this interface
+*            This class represents thread client that called from worker thread.\n
+*            The application who wants to use worker thread, inherit this interface
 *
 * @see
 */
 class IThreadClient : public IBase
 {
-public:
-       /**
-       * @fn     onExecute
-       * @brief Called when worker thread is ready execute message
-       *
-       * @param [in] void *pArg - Optional argument
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual void onExecute(void *pArg) = 0;
-
-       /**
-       * @fn     onTerminate
-       * @brief Called when worker thread has finished last executed message
-       *
-       * @param [in] void *pArg - Optional argument
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual void onTerminate(void *pArg) = 0;
-       virtual ~IThreadClient(){};
+    public:
+        /**
+        * @fn     onExecute
+        * @brief Called when worker thread is ready execute message
+        *
+        * @param [in] void *pArg - Optional argument
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void onExecute(void *pArg) = 0;
+
+        /**
+        * @fn     onTerminate
+        * @brief Called when worker thread has finished last executed message
+        *
+        * @param [in] void *pArg - Optional argument
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void onTerminate(void *pArg) = 0;
+        virtual ~IThreadClient() {};
 };
 
 /**
 * @class    CObjectMultiThreadModel
 * @brief    CObjectMultiThreadModel Interface
-*                       This class represents declared CObject's threading model
+*            This class represents declared CObject's threading model
 *
 * @see
 */
 class CObjectMultiThreadModel
 {
-public:
-       /**
-       * @fn     Increment
-       * @brief Called when reference counter need to increase
-       *
-       * @param [in] volatile unsigned long *p - Reference counter's pointer
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       static unsigned long increment(volatile unsigned long *p)
-       {
+    public:
+        /**
+        * @fn     Increment
+        * @brief Called when reference counter need to increase
+        *
+        * @param [in] volatile unsigned long *p - Reference counter's pointer
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        static unsigned long increment(volatile unsigned long *p)
+        {
 #if defined(WIN32)
-               return InterlockedIncrement(p);
+            return InterlockedIncrement(p);
 #elif defined(LINUX)
-               return __sync_add_and_fetch(p, 1);
+            return __sync_add_and_fetch(p, 1);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       }
-
-       /**
-       * @fn     decrement
-       * @brief Called when reference counter need to decrease
-       *
-       * @param [in] volatile unsigned long *p - Reference counter's pointer
-       * 
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       static unsigned long decrement(volatile unsigned long *p)
-       {
+        }
+
+        /**
+        * @fn     decrement
+        * @brief Called when reference counter need to decrease
+        *
+        * @param [in] volatile unsigned long *p - Reference counter's pointer
+        *
+        * @return unsigned long
+        * @warning
+        * @exception
+        * @see
+        */
+        static unsigned long decrement(volatile unsigned long *p)
+        {
 #if defined(WIN32)
-               return InterlockedDecrement(p);
+            return InterlockedDecrement(p);
 #elif defined(LINUX)
-               return __sync_add_and_fetch(p, -1);
+            return __sync_add_and_fetch(p, -1);
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       }
+        }
 };
 
 /**
 * @class    CNullMutex
 * @brief    CNullMutex Interface
-*                       This class represents mutex strategy
+*            This class represents mutex strategy
 *
 * @see
 */
 class CNullMutex
 {
-public:
-       /**
-       * @fn     lock
-       * @brief Called when current thread need to locked
-       *
-       * @param NONE
-       * 
-       * @return NONE
-       * @warning      
-       * @exception    
-       * @see
-       */
-       void lock(){}
-
-       /**
-       * @fn     unlock
-       * @brief Called when current thread need to unlocked
-       *
-       * @param NONE
-       * 
-       * @return NONE
-       * @warning      
-       * @exception    
-       * @see
-       */
-       void unlock(){}
+    public:
+        /**
+        * @fn     lock
+        * @brief Called when current thread need to locked
+        *
+        * @param NONE
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void lock() {}
+
+        /**
+        * @fn     unlock
+        * @brief Called when current thread need to unlocked
+        *
+        * @param NONE
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void unlock() {}
 };
 
 /**
 * @class    CAutoMutex
 * @brief    CAutoMutex Interface
-*                       This class represents automated mutex class
+*            This class represents automated mutex class
 *
 * @see
 */
 template<typename T>
 class CAutoMutex
 {
-public:
-       CAutoMutex(T &t) :
-         t_(t)
-         {
-                 t_.lock();
-         }
-         ~CAutoMutex()
-         {
-                 t_.unlock();
-         }
-
-private:
-       T& t_;
+    public:
+        CAutoMutex(T &t) :
+            t_(t)
+        {
+            t_.lock();
+        }
+        ~CAutoMutex()
+        {
+            t_.unlock();
+        }
+
+    private:
+        T &t_;
 };
 
 /**
 * @class    CSimpleMutex
 * @brief    CSimpleMutex Interface
-*                       This class represents basic mutex class.\n
-*                       This mutex must support recursive locking mechanism
+*            This class represents basic mutex class.\n
+*            This mutex must support recursive locking mechanism
 *
 * @see
 */
 class CSimpleMutex
 {
-private:
+    private:
 #if defined(WIN32)
-       CRITICAL_SECTION m_criticalSection;
+        CRITICAL_SECTION m_criticalSection;
 #elif defined(LINUX)
-       pthread_mutex_t                 m_mutex;
-       pthread_mutexattr_t             m_mutexAttribute;
+        pthread_mutex_t         m_mutex;
+        pthread_mutexattr_t     m_mutexAttribute;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
 
-public:
-       CSimpleMutex();
-
-       ~CSimpleMutex();
-
-       /**
-       * @fn     lock
-       * @brief Lock current thread
-       *
-       * @param NONE
-       * 
-       * @return NONE
-       * @warning      
-       * @exception    
-       * @see
-       */
-       void lock();
-
-       /**
-       * @fn     unlock
-       * @brief Unlock current thread
-       *
-       * @param NONE
-       * 
-       * @return NONE
-       * @warning      
-       * @exception    
-       * @see
-       */
-       void unlock();
+    public:
+        CSimpleMutex();
+
+        ~CSimpleMutex();
+
+        /**
+        * @fn     lock
+        * @brief Lock current thread
+        *
+        * @param NONE
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void lock();
+
+        /**
+        * @fn     unlock
+        * @brief Unlock current thread
+        *
+        * @param NONE
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void unlock();
 };
 
 class CSemaphore
 {
-private:
+    private:
 #if defined(WIN32)
-       HANDLE hSemaphore;
+        HANDLE hSemaphore;
 #elif defined(LINUX)
-       sem_t hSemaphore;
+        sem_t hSemaphore;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
 
-public:
-       CSemaphore();
+    public:
+        CSemaphore();
 
-       ~CSemaphore();
+        ~CSemaphore();
 
-       SSMRESULT initialize();
+        SSMRESULT initialize();
 
-       SSMRESULT destroy();
+        SSMRESULT destroy();
 
-       SSMRESULT take();
+        SSMRESULT take();
 
-       SSMRESULT give();
+        SSMRESULT give();
 };
 
 
@@ -261,162 +261,162 @@ static const OID OID_IWorkerThread = { 0x12a67457, 0xce97, 0x41c4, { 0x90, 0xb8,
 /**
 * @class    IWorkerThread
 * @brief    IWorkerThread Interface
-*                       This class represents worker thread utility
+*            This class represents worker thread utility
 *
 * @see
 */
 class IWorkerThread : public IBase
 {
-public:
-       /**
-       * @fn     initialize
-       * @brief Initialize current worker thread
-       *
-       * @param NONE
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT initialize() = 0;
-
-       /**
-       * @fn     terminate
-       * @brief Terminate current worker thread.\n
-       *                 All remained tasks are destroyed after IThreadClient::OnTerminate called
-       *
-       * @param NONE
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       virtual SSMRESULT terminate() = 0;
-
-       /**
-       * @fn     addTask
-       * @brief Add task to current worker thread.\n
-       *                 Each task called only once
-       *
-       * @param [in] IThreadClient *pThreadClient - Implemented thread client class instance that called from worker thread.
-       * @param [in] void *param - Optional parameter that IThreadClient::OnExecute/OnTerminate can receive
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT addTask(IThreadClient *pThreadClient, void *param) = 0;
+    public:
+        /**
+        * @fn     initialize
+        * @brief Initialize current worker thread
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT initialize() = 0;
+
+        /**
+        * @fn     terminate
+        * @brief Terminate current worker thread.\n
+        *         All remained tasks are destroyed after IThreadClient::OnTerminate called
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT terminate() = 0;
+
+        /**
+        * @fn     addTask
+        * @brief Add task to current worker thread.\n
+        *         Each task called only once
+        *
+        * @param [in] IThreadClient *pThreadClient - Implemented thread client class instance that called from worker thread.
+        * @param [in] void *param - Optional parameter that IThreadClient::OnExecute/OnTerminate can receive
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT addTask(IThreadClient *pThreadClient, void *param) = 0;
 };
 
 /**
 * @class    CWorkerThread
 * @brief    CWorkerThread Interface
-*                       This class represents worker thread utility that holds one thread
+*            This class represents worker thread utility that holds one thread
 *
 * @see
 */
 class CWorkerThread :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IWorkerThread
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IWorkerThread
 {
-private:
-       struct ClientEntry
-       {
-               IThreadClient   *pClient;
-               void                    *pArg;
-       };
+    private:
+        struct ClientEntry
+        {
+            IThreadClient   *pClient;
+            void            *pArg;
+        };
 #if defined(WIN32)
-       HANDLE m_hThread;
+        HANDLE m_hThread;
 #elif defined(LINUX)
-       pthread_t m_hThread;
+        pthread_t m_hThread;
 #else
 #error WIN32 or LINUX tag must be defined
 #endif
-       CSemaphore                      m_semInit;
-       CSemaphore                      m_semTerm;
-
-       CSimpleMutex                    m_mtxClientEntry;
-       CSimpleMutex                    m_mtxThreadTerm;        
-       CSemaphore                              m_semTask;
-
-       bool                                    m_bThreadTerm;
-
-       std::list<ClientEntry>  m_ClientEntry;
-
-       bool getTask(ClientEntry *clientEntry);
-
-       void worker();
-
-       static void _worker(void *pArg)
-       {
-               CWorkerThread *pThread = (CWorkerThread *)pArg;
-               return pThread->worker();
-       }
-
-public:
-       SSMRESULT finalConstruct();
-       void finalRelease();
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if (ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if (IsEqualOID(objectID, OID_IWorkerThread))
-               {
-                       IBase *pBase = (IWorkerThread*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn     initialize
-       * @brief Initialize current worker thread
-       *
-       * @param NONE
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT initialize();
-
-       /**
-       * @fn     terminate
-       * @brief Terminate current worker thread.\n
-       *                 All remained tasks are destroyed after IThreadClient::OnTerminate called
-       *
-       * @param NONE
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT terminate();
-
-       /**
-       * @fn     addTask
-       * @brief Add task to current worker thread.\n
-       *                 Each task called only once
-       *
-       * @param [in] IThreadClient *pThreadClient - Implemented thread client class instance that called from worker thread.
-       * @param [in] void *param - Optional parameter that IThreadClient::OnExecute/OnTerminate can receive
-       *
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT addTask(IThreadClient *pThreadClient, void *param);
+        CSemaphore              m_semInit;
+        CSemaphore              m_semTerm;
+
+        CSimpleMutex            m_mtxClientEntry;
+        CSimpleMutex            m_mtxThreadTerm;
+        CSemaphore              m_semTask;
+
+        bool                    m_bThreadTerm;
+
+        std::list<ClientEntry>  m_ClientEntry;
+
+        bool getTask(ClientEntry *clientEntry);
+
+        void worker();
+
+        static void _worker(void *pArg)
+        {
+            CWorkerThread *pThread = (CWorkerThread *)pArg;
+            return pThread->worker();
+        }
+
+    public:
+        SSMRESULT finalConstruct();
+        void finalRelease();
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IWorkerThread))
+            {
+                IBase *pBase = (IWorkerThread *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn     initialize
+        * @brief Initialize current worker thread
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT initialize();
+
+        /**
+        * @fn     terminate
+        * @brief Terminate current worker thread.\n
+        *         All remained tasks are destroyed after IThreadClient::OnTerminate called
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT terminate();
+
+        /**
+        * @fn     addTask
+        * @brief Add task to current worker thread.\n
+        *         Each task called only once
+        *
+        * @param [in] IThreadClient *pThreadClient - Implemented thread client class instance that called from worker thread.
+        * @param [in] void *param - Optional parameter that IThreadClient::OnExecute/OnTerminate can receive
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT addTask(IThreadClient *pThreadClient, void *param);
 };
 
 
@@ -424,98 +424,98 @@ static const OID OID_IThreadPool = { 0x53855605, 0xb2a0, 0x4a31, { 0xa2, 0x60, 0
 /**
 * @class    IThreadPool
 * @brief    IThreadPool Interface
-*                       This class represents worker thread utility
+*            This class represents worker thread utility
 *
 * @see
 */
 class IThreadPool : public IBase
 {
-public:
-       virtual SSMRESULT createWorkerThread(OUT IWorkerThread **ppWorkerThread) = 0;
-       virtual SSMRESULT destroyThreadPool() = 0;
+    public:
+        virtual SSMRESULT createWorkerThread(OUT IWorkerThread **ppWorkerThread) = 0;
+        virtual SSMRESULT destroyThreadPool() = 0;
 };
 
 /**
 * @class    CThreadPool
 * @brief    CThreadPool Interface
-*                       This class represents worker thread pool utility that can holds multiple thread
+*            This class represents worker thread pool utility that can holds multiple thread
 *
 * @see
 */
 class CThreadPool :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IThreadPool
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IThreadPool
 {
-private:
-       std::vector<IWorkerThread*>     m_lstWorkerThread;
+    private:
+        std::vector<IWorkerThread *> m_lstWorkerThread;
 
-public:
-       SSMRESULT finalConstruct();
-       void finalRelease();
+    public:
+        SSMRESULT finalConstruct();
+        void finalRelease();
 
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
 
-               if(IsEqualOID(objectID, OID_IThreadPool))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
+            if (IsEqualOID(objectID, OID_IThreadPool))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
 
-               return SSM_E_NOINTERFACE;
-       }
+            return SSM_E_NOINTERFACE;
+        }
 
-       SSMRESULT createWorkerThread(OUT IWorkerThread **ppWorkerThread);
+        SSMRESULT createWorkerThread(OUT IWorkerThread **ppWorkerThread);
 
-       SSMRESULT destroyThreadPool();
+        SSMRESULT destroyThreadPool();
 };
 
 static const OID OID_ITasker = { 0x8f2b0b4f, 0xaab8, 0x4cbc, { 0x99, 0x1, 0x65, 0xde, 0x89, 0x82, 0x9f, 0x7a } };
 /**
 * @class    ITasker
 * @brief    ITasker Interface
-*                       This class represents worker thread utility
+*            This class represents worker thread utility
 *
 * @see
 */
 class ITasker : public IBase
 {
-public:
-       virtual SSMRESULT addTask(IThreadClient *pThreadClient, void *param) = 0;
+    public:
+        virtual SSMRESULT addTask(IThreadClient *pThreadClient, void *param) = 0;
 };
 
 class CTasker :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public ITasker
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public ITasker
 {
-private:
-       CObjectPtr<IThreadPool>         m_pThreadPool;
-       CObjectPtr<IWorkerThread>       m_pWorkerThread;
-
-public:
-       SSMRESULT finalConstruct();
-       void finalRelease();
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if (ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if (IsEqualOID(objectID, OID_ITasker))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       SSMRESULT addTask(IThreadClient *pThreadClient, void *param);
+    private:
+        CObjectPtr<IThreadPool>     m_pThreadPool;
+        CObjectPtr<IWorkerThread>   m_pWorkerThread;
+
+    public:
+        SSMRESULT finalConstruct();
+        void finalRelease();
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_ITasker))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        SSMRESULT addTask(IThreadClient *pThreadClient, void *param);
 };
 #endif
index 3cfc9ce..7ba46e7 100644 (file)
 
 Token::Token()
 {
-       number = -1;
-       name = "";
-       type = Command;
-       condition = ModelCondition::PREDICATE_EQ;
+    number = -1;
+    name = "";
+    type = Command;
+    condition = ModelCondition::PREDICATE_EQ;
 }
 
-std::vector<std::string> CCQLParser::tokenize(IN const std::stringinput)
+std::vector<std::string> CCQLParser::tokenize(IN const std::string &input)
 {
-       std::vector<std::string> temp;
-       temp.push_back(",");
-       temp.push_back(" ");
-
-       std::vector<std::string> tokens_temp;
-       std::string arrage_query = input;
-       arrage_query = check_Predicate(arrage_query);
-       for(unsigned int i = 0 ; i < temp.size(); i++)
-       {
-
-               tokens_temp.clear();
-               tokens_temp = getTokens(arrage_query,temp.at(i));
-               arrage_query= "";
-               for(unsigned int j =0  ; j < tokens_temp.size() ; j++)
-               {
-                       arrage_query += tokens_temp.at(j)+" ";
-                       //cout << "element = " << tokens_temp.at(j) << endl;
-               }
-       }
-       return tokens_temp;
+    std::vector<std::string> temp;
+    temp.push_back(",");
+    temp.push_back(" ");
+
+    std::vector<std::string> tokens_temp;
+    std::string arrage_query = input;
+    arrage_query = check_Predicate(arrage_query);
+    for (unsigned int i = 0 ; i < temp.size(); i++)
+    {
+
+        tokens_temp.clear();
+        tokens_temp = getTokens(arrage_query, temp.at(i));
+        arrage_query = "";
+        for (unsigned int j = 0  ; j < tokens_temp.size() ; j++)
+        {
+            arrage_query += tokens_temp.at(j) + " ";
+            //cout << "element = " << tokens_temp.at(j) << endl;
+        }
+    }
+    return tokens_temp;
 }
 
-void CCQLParser::parse(IN std::string input, OUT Tokenroot)
+void CCQLParser::parse(IN std::string input, OUT Token *root)
 {
-       std::vector<std::string> tokens = tokenize(input);
-       bool flag;//get,sub,if
-       bool value_flag = false;
-
-       for(unsigned int i = 0 ; i < tokens.size() ; i++)
-       {
-               if( tolower(tokens.at(i)) == "get" || tolower(tokens.at(i)) == "subscribe" || tolower(tokens.at(i)) == "if")
-               {
-                       Token temp;
-
-                       if(i != tokens.size()-1 && tolower(tokens.at(i)) == "subscribe" && tolower(tokens.at(i+1)) == "if")
-                       {
-                               temp.type = Command;
-                               temp.name = tokens.at(i);
-                               root->child_token.push_back(temp);
-                               temp.name = tokens.at(i+1);
-                               
-                               //Token temp1;
-                               //temp1.type = Command;
-                               //temp1.name = tokens.at(i+1);
-                               
-                               
-                               
-                               
-                               i++;
-                               //temp1 = temp;
-                               flag = false;
-                       }
-                       else
-                       {
-                               /*
-                               temp.type = Command;
-                               temp.name = tokens.at(i);
-                               root->child_token.push_back(temp);
-                               */
-                               temp.type = Command;
-                               temp.name = tokens.at(i);
-                               if(tokens.at(i) == "if")
-                               {
-                                       flag = false;
-                               }
-                               else 
-                               {
-                                       flag =true;
-                               }       
-                       }
-
-                       while(1)
-                       {
-                               //int count = 0;
-                               i++;
-
-                               if(value_flag == true)
-                               {
-                                       value_flag =false;
-                                       i++;
-                               }
-
-                               if( i >= tokens.size() || tolower(tokens.at(i) )== "if")
-                               {
-                                       i--;
-                                       break;
-                               }
-
-                               //enum condition {EQ,GTE,GT,LT,LTE,NEQ};
-                               Token temp1;
-                               temp1.name = tokens.at(i);
-
-
-                               if(tokens.at(i) == "=" || tokens.at(i) == "==")
-                               {
-                                       temp1.condition = ModelCondition::PREDICATE_EQ;
-                                       temp1.type = Condi;
-                                       value_flag = true;
-
-                               }
-                               else if(tokens.at(i) == ">=")
-                               {
-                                       temp1.condition = ModelCondition::PREDICATE_GTE;
-                                       temp1.type = Condi;
-                                       value_flag = true;
-                               }
-                               else if(tokens.at(i) == ">")
-                               {
-                                       temp1.condition =  ModelCondition::PREDICATE_GT;
-                                       temp1.type = Condi;
-                                       value_flag = true;
-                               }
-                               else if(tokens.at(i) == "<")
-                               {
-                                       temp1.condition = ModelCondition::PREDICATE_LT;
-                                       temp1.type = Condi;
-                                       value_flag = true;
-                               }
-                               else if(tokens.at(i) == "<=")
-                               {
-                                       temp1.condition = ModelCondition::PREDICATE_LTE;
-                                       temp1.type = Condi;
-                                       value_flag = true;
-                               }       
-                               else if(tokens.at(i) == "!=")
-                               {
-                                       temp1.condition = ModelCondition::PREDICATE_NEQ;
-                                       temp1.type = Condi;
-                                       value_flag = true;
-                               }
-                               else
-                               {
-                                       temp1.type = Context;
-                               }
-                               
-
-                               if(flag == true){
-
-                                       if(tolower(tokens.at(i)) == "and" || tolower(tokens.at(i)) == "or")
-                                       {
-                                               temp1.type = And_or;
-                                               flag =false;
-                                       }
-                                       split(tokens.at(i), &temp1, flag );//false -> Property
-                                       temp.child_token.push_back(temp1);
-                               }
-                               else
-                               {
-                                       split(tokens.at(i), &temp1, flag ,tokens.at(i+1),tokens.at(i+2));//false -> Property
-                                       flag = true;
-                                       temp.child_token.push_back(temp1);
-                               }
-
-                       }
-                       root->child_token.push_back(temp);
-               }
-       }       
+    std::vector<std::string> tokens = tokenize(input);
+    bool flag;//get,sub,if
+    bool value_flag = false;
+
+    for (unsigned int i = 0 ; i < tokens.size() ; i++)
+    {
+        if ( tolower(tokens.at(i)) == "get" || tolower(tokens.at(i)) == "subscribe"
+             || tolower(tokens.at(i)) == "if")
+        {
+            Token temp;
+
+            if (i != tokens.size() - 1 && tolower(tokens.at(i)) == "subscribe"
+                && tolower(tokens.at(i + 1)) == "if")
+            {
+                temp.type = Command;
+                temp.name = tokens.at(i);
+                root->child_token.push_back(temp);
+                temp.name = tokens.at(i + 1);
+
+                //Token temp1;
+                //temp1.type = Command;
+                //temp1.name = tokens.at(i+1);
+
+
+
+
+                i++;
+                //temp1 = temp;
+                flag = false;
+            }
+            else
+            {
+                /*
+                temp.type = Command;
+                temp.name = tokens.at(i);
+                root->child_token.push_back(temp);
+                */
+                temp.type = Command;
+                temp.name = tokens.at(i);
+                if (tokens.at(i) == "if")
+                {
+                    flag = false;
+                }
+                else
+                {
+                    flag = true;
+                }
+            }
+
+            while (1)
+            {
+                //int count = 0;
+                i++;
+
+                if (value_flag == true)
+                {
+                    value_flag = false;
+                    i++;
+                }
+
+                if ( i >= tokens.size() || tolower(tokens.at(i) ) == "if")
+                {
+                    i--;
+                    break;
+                }
+
+                //enum condition {EQ,GTE,GT,LT,LTE,NEQ};
+                Token temp1;
+                temp1.name = tokens.at(i);
+
+
+                if (tokens.at(i) == "=" || tokens.at(i) == "==")
+                {
+                    temp1.condition = ModelCondition::PREDICATE_EQ;
+                    temp1.type = Condi;
+                    value_flag = true;
+
+                }
+                else if (tokens.at(i) == ">=")
+                {
+                    temp1.condition = ModelCondition::PREDICATE_GTE;
+                    temp1.type = Condi;
+                    value_flag = true;
+                }
+                else if (tokens.at(i) == ">")
+                {
+                    temp1.condition =  ModelCondition::PREDICATE_GT;
+                    temp1.type = Condi;
+                    value_flag = true;
+                }
+                else if (tokens.at(i) == "<")
+                {
+                    temp1.condition = ModelCondition::PREDICATE_LT;
+                    temp1.type = Condi;
+                    value_flag = true;
+                }
+                else if (tokens.at(i) == "<=")
+                {
+                    temp1.condition = ModelCondition::PREDICATE_LTE;
+                    temp1.type = Condi;
+                    value_flag = true;
+                }
+                else if (tokens.at(i) == "!=")
+                {
+                    temp1.condition = ModelCondition::PREDICATE_NEQ;
+                    temp1.type = Condi;
+                    value_flag = true;
+                }
+                else
+                {
+                    temp1.type = Context;
+                }
+
+
+                if (flag == true)
+                {
+
+                    if (tolower(tokens.at(i)) == "and" || tolower(tokens.at(i)) == "or")
+                    {
+                        temp1.type = And_or;
+                        flag = false;
+                    }
+                    split(tokens.at(i), &temp1, flag );//false -> Property
+                    temp.child_token.push_back(temp1);
+                }
+                else
+                {
+                    split(tokens.at(i), &temp1, flag , tokens.at(i + 1), tokens.at(i + 2)); //false -> Property
+                    flag = true;
+                    temp.child_token.push_back(temp1);
+                }
+
+            }
+            root->child_token.push_back(temp);
+        }
+    }
 }
 
 std::string CCQLParser::tolower(IN std::string str)
 {
-       for(unsigned int i = 0 ; i < str.size() ; i++)
-       {
-               if(str[i] <= 'Z' && str[i] >= 'A')
-               {
-                       str[i] += 32;
-               }
-       }
-
-       return str;
+    for (unsigned int i = 0 ; i < str.size() ; i++)
+    {
+        if (str[i] <= 'Z' && str[i] >= 'A')
+        {
+            str[i] += 32;
+        }
+    }
+
+    return str;
 }
 
-std::vector<std::string> CCQLParser::getTokens(IN const std::string& str, IN const std::string& delimiters)
+std::vector<std::string> CCQLParser::getTokens(IN const std::string &str,
+        IN const std::string &delimiters)
 {
-       std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
-       std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
-       std::vector<std::string> tokens;
-
-       while (std::string::npos != pos || std::string::npos != lastPos)
-       {
-               tokens.push_back(str.substr(lastPos, pos - lastPos));
-               lastPos = str.find_first_not_of(delimiters, pos);
-               pos = str.find_first_of(delimiters, lastPos);
-       }
-
-       return tokens;
+    std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
+    std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
+    std::vector<std::string> tokens;
+
+    while (std::string::npos != pos || std::string::npos != lastPos)
+    {
+        tokens.push_back(str.substr(lastPos, pos - lastPos));
+        lastPos = str.find_first_not_of(delimiters, pos);
+        pos = str.find_first_of(delimiters, lastPos);
+    }
+
+    return tokens;
 }
 
-void CCQLParser::check_index(IN std::string input, OUT Tokentoken)
+void CCQLParser::check_index(IN std::string input, OUT Token *token)
 {
-       std::vector<std::string> tokens = getTokens(input,"[");
-
-       if(tokens.size() == 2)
-       {
-               if(tolower(tokens.at(1)) == "all]")
-               {
-                       token->name = tokens.at(0);
-                       token->number = INDEX_ALL;
-
-               }
-               else if(tolower(tokens.at(1)) == "this]")
-               {
-                       token->name = tokens.at(0);
-                       token->number = INDEX_THIS;
-
-               }
-               else
-               {
-                       int num = atoi(tokens.at(1).c_str());
-                       token->name = tokens.at(0);
-                       token->number = num;
-               }
-       }
+    std::vector<std::string> tokens = getTokens(input, "[");
+
+    if (tokens.size() == 2)
+    {
+        if (tolower(tokens.at(1)) == "all]")
+        {
+            token->name = tokens.at(0);
+            token->number = INDEX_ALL;
+
+        }
+        else if (tolower(tokens.at(1)) == "this]")
+        {
+            token->name = tokens.at(0);
+            token->number = INDEX_THIS;
+
+        }
+        else
+        {
+            int num = atoi(tokens.at(1).c_str());
+            token->name = tokens.at(0);
+            token->number = num;
+        }
+    }
 }
 
-void CCQLParser::split(IN std::string input, IN Token* root, bool flag, IN std::string arg1, IN std::string arg2)
+void CCQLParser::split(IN std::string input, IN Token *root, bool flag, IN std::string arg1,
+                       IN std::string arg2)
 {
-       std::vector<std::string> tokens = getTokens(input,".");
-       Token *temp_token = root;
-       
-       for(unsigned int j = 0 ; j < tokens.size() ; j++)
-       {
-               if(j ==0 )
-               {
-                       temp_token->name = tokens.at(j);
-                       check_index(tokens.at(j),temp_token);
-               }
-               else
-               {
-                       if(j == tokens.size()-1 && flag == false)
-                       {
-                               ModelProperty property;
-                               property.propertyName = tokens.at(j);
-
-                               if(arg2[0] == '\"')
-                               {
-                                       std::vector<std::string> tokens_temp = getTokens(arg2,"\"");
-
-                                       property.propertyValue = tokens_temp.at(0);
-                                       property.propertyType = ModelProperty::TYPE_TEXT;
-                                       
-                                       temp_token->model_property = property;
-                                       
-                                       //root->child_token.push_back(temp1);
-                               }
-
-                               else if(check_number(arg2)) 
-                               {
-                                       //temp1->number = atof(arg2.c_str());
-
-                                       // 0 text /1 integer /2 real
-                                       if(check_number(arg2) == TYPEINTEGER)
-                                       {
-                                               property.propertyType =  ModelProperty::TYPE_INTEGER;
-                                       }       
-                                       else if(check_number(arg2) == TYPEREAL)
-                                       {
-                                               property.propertyType = ModelProperty::TYPE_REAL;
-                                       }
-                                       property.propertyValue = arg2;
-
-                                       temp_token->model_property= property;
-                               }
-                       }
-                       else
-                       {
-                               Token temp1;
-                               temp1.type= Context;
-                               temp1.name = tokens.at(j);
-                               check_index(tokens.at(j),&temp1);
-                               temp_token->child_token.push_back(temp1);       
-                               temp_token= &(temp_token->child_token.back());
-                       }
-
-               }
-       }
+    std::vector<std::string> tokens = getTokens(input, ".");
+    Token *temp_token = root;
+
+    for (unsigned int j = 0 ; j < tokens.size() ; j++)
+    {
+        if (j == 0 )
+        {
+            temp_token->name = tokens.at(j);
+            check_index(tokens.at(j), temp_token);
+        }
+        else
+        {
+            if (j == tokens.size() - 1 && flag == false)
+            {
+                ModelProperty property;
+                property.propertyName = tokens.at(j);
+
+                if (arg2[0] == '\"')
+                {
+                    std::vector<std::string> tokens_temp = getTokens(arg2, "\"");
+
+                    property.propertyValue = tokens_temp.at(0);
+                    property.propertyType = ModelProperty::TYPE_TEXT;
+
+                    temp_token->model_property = property;
+
+                    //root->child_token.push_back(temp1);
+                }
+
+                else if (check_number(arg2))
+                {
+                    //temp1->number = atof(arg2.c_str());
+
+                    // 0 text /1 integer /2 real
+                    if (check_number(arg2) == TYPEINTEGER)
+                    {
+                        property.propertyType =  ModelProperty::TYPE_INTEGER;
+                    }
+                    else if (check_number(arg2) == TYPEREAL)
+                    {
+                        property.propertyType = ModelProperty::TYPE_REAL;
+                    }
+                    property.propertyValue = arg2;
+
+                    temp_token->model_property = property;
+                }
+            }
+            else
+            {
+                Token temp1;
+                temp1.type = Context;
+                temp1.name = tokens.at(j);
+                check_index(tokens.at(j), &temp1);
+                temp_token->child_token.push_back(temp1);
+                temp_token = &(temp_token->child_token.back());
+            }
+
+        }
+    }
 }
 
-int CCQLParser::check_number(IN std::string & str)
+int CCQLParser::check_number(IN std::string &str)
 {
-       //int flag = 0; // 0 text /1 integer /2 real
-
-       int flag = 0;
-       for(unsigned int i =0 ; i < str.size(); i++)
-       {
-               if(str[i] == '.')
-               {
-                       flag++;
-               }
-               else if(isdigit(str[i]))
-               {
-
-               }
-               else {
-                       return TYPETEXT;
-               }
-       }
-
-       if(flag == 1)
-       {
-               return TYPEREAL;
-       }
-       else if(flag > 1)
-       {
-               return TYPETEXT;
-       }
-       else
-       {
-               return TYPEINTEGER;
-       }
+    //int flag = 0; // 0 text /1 integer /2 real
+
+    int flag = 0;
+    for (unsigned int i = 0 ; i < str.size(); i++)
+    {
+        if (str[i] == '.')
+        {
+            flag++;
+        }
+        else if (isdigit(str[i]))
+        {
+
+        }
+        else
+        {
+            return TYPETEXT;
+        }
+    }
+
+    if (flag == 1)
+    {
+        return TYPEREAL;
+    }
+    else if (flag > 1)
+    {
+        return TYPETEXT;
+    }
+    else
+    {
+        return TYPEINTEGER;
+    }
 }
 
 std::string CCQLParser::check_Predicate(IN std::string input)
 {
-       std::string temp="";
-       for(unsigned int i =0 ;i < input.size() ; i++)
-       {
-               if(i==0)
-               {
-                       temp += input[0];
-                       continue;
-               }
-
-               switch(input[i])
-               {
-               case '=':
-                       if(input[i-1] != '=' && input[i-1] != '!' && input[i-1] != '>' && input[i-1] != '<' && input[i-1] != ' ')
-                       {
-                               temp += ' ';
-                       }
-                       temp += input[i];
-                       break;
-               case '!':
-               case '<':
-               case '>':
-                       if(input[i-1] != ' ')
-                       {
-                               temp += ' ';
-                       }
-                       temp += input[i];
-                       break;
-               case ' ':
-                       temp += input[i];
-                       break;
-               default:
-                       if(input[i-1] == '=' || input[i-1] == '<' || input[i-1] == '>')
-                       {
-                               temp += ' ';
-                       }
-                       temp += input[i];
-                       break;
-               }
-       }
-
-       return temp;
+    std::string temp = "";
+    for (unsigned int i = 0 ; i < input.size() ; i++)
+    {
+        if (i == 0)
+        {
+            temp += input[0];
+            continue;
+        }
+
+        switch (input[i])
+        {
+            case '=':
+                if (input[i - 1] != '=' && input[i - 1] != '!' && input[i - 1] != '>' && input[i - 1] != '<'
+                    && input[i - 1] != ' ')
+                {
+                    temp += ' ';
+                }
+                temp += input[i];
+                break;
+            case '!':
+            case '<':
+            case '>':
+                if (input[i - 1] != ' ')
+                {
+                    temp += ' ';
+                }
+                temp += input[i];
+                break;
+            case ' ':
+                temp += input[i];
+                break;
+            default:
+                if (input[i - 1] == '=' || input[i - 1] == '<' || input[i - 1] == '>')
+                {
+                    temp += ' ';
+                }
+                temp += input[i];
+                break;
+        }
+    }
+
+    return temp;
 }
 
-bool CCQLParser::check_grammer(IN Tokentoken)
+bool CCQLParser::check_grammer(IN Token *token)
 {
-       if(token->child_token.size() == 1 && tolower(token->child_token.at(0).name) == "get")
-       {
-               if(token->child_token.at(0).child_token.size() > 0)
-               {
-                       return true;
-               }
-               else
-               {
-                       return false;
-               }
-
-       }
-       else if(token->child_token.size() == 2)
-       {
-               if(token->child_token.at(1).child_token.size() > 0)
-               {
-                       if(tolower(token->child_token.at(0).name) == "subscribe")
-                       {
-                               return true;
-                       }
-                       else if(tolower(token->child_token.at(0).name) == "get")
-                       {
-                               if(token->child_token.at(0).child_token.size() > 0)
-                               {
-                                       return true;
-                               }
-                               else
-                               {
-                                       return false;
-                               }
-                       }
-                       else
-                       {
-                               return false;
-                       }
-
-               }
-               else
-               {
-                       return false;
-               }
-       }
-       else
-       {
-               return false;
-       }
+    if (token->child_token.size() == 1 && tolower(token->child_token.at(0).name) == "get")
+    {
+        if (token->child_token.at(0).child_token.size() > 0)
+        {
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+
+    }
+    else if (token->child_token.size() == 2)
+    {
+        if (token->child_token.at(1).child_token.size() > 0)
+        {
+            if (tolower(token->child_token.at(0).name) == "subscribe")
+            {
+                return true;
+            }
+            else if (tolower(token->child_token.at(0).name) == "get")
+            {
+                if (token->child_token.at(0).child_token.size() > 0)
+                {
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+            else
+            {
+                return false;
+            }
+
+        }
+        else
+        {
+            return false;
+        }
+    }
+    else
+    {
+        return false;
+    }
 }
index 01c45be..609cec7 100644 (file)
 #define INDEX_ALL 9999
 #define INDEX_THIS -2
 
-enum SORT {Command, Context, Property, And_or,Condi, Value};
+enum SORT {Command, Context, Property, And_or, Condi, Value};
 
 class Token
 {
-public:
-       Token();
-
-       enum SORT type;
-       enum ModelCondition::Predicate condition;
-       std::string name;
-       int number;
-       std::vector<Token> child_token;
-       ModelProperty model_property;
+    public:
+        Token();
+
+        enum SORT type;
+        enum ModelCondition::Predicate condition;
+        std::string name;
+        int number;
+        std::vector<Token> child_token;
+        ModelProperty model_property;
 };
 
 /**
 * @class    CCQLParser
 * @brief    CQLParser Interface
-*                       This class parses ContextQuery Language.
+*            This class parses ContextQuery Language.
 *
-* @see      
-*                      string contextQuery;
-*                      CQLParser tokenizer;
-*                      tokenizer.Parser(contextQuery, &token);
+* @see
+*           string contextQuery;
+*           CQLParser tokenizer;
+*           tokenizer.Parser(contextQuery, &token);
 *
 * Copyright 2013 by Samsung Electronics, Inc.,
-* 
+*
 * This software is the confidential and proprietary information
 * of Samsung Electronics, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
@@ -66,122 +66,124 @@ public:
 class CCQLParser
 {
 
-public:
-       /**
-       * @fn parse
-       * @brief parse ContextQuery
-       *
-       * @param [in] std::string input - Entered ContetxQuery
-       * @param [out] Token* root - parsed result
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void parse(IN std::string input, OUT Token* root);
-
-       /**
-       * @fn tolower
-       * @brief convert lowercase
-       * 
-       * @param [in] std::string str - Entered string
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       static std::string tolower(IN std::string str);
-
-       /**
-       * @fn check_Query_grammer
-       * @brief check grammer
-       * 
-       * @param [in] Token* token - parsed token
-       * @return boolean
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       bool check_grammer(IN Token* token);
-
-private:
-       /**
-       * @fn tokenize
-       * @brief split sentence
-       *
-       * @param [in] const std::string& input - Entered ContetxQuery
-       * @return std::vector<std::string>
-       * @warning
-       * @exception
-       * @see
-       */
-       std::vector<std::string> tokenize(IN const std::string& input);
-
-       /**
-       * @fn getTokens
-       * @brief this function divides string into tokens based on a delimiter
-       * 
-       * @param [in] const std::string& str - entered string
-       * @param [in] const std::string& delimiters = " " - token delimiter , default = " "
-       * @return std::vector<std::string>
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       static std::vector<std::string> getTokens(IN const std::string& str,IN const std::string& delimiters = " ");
-
-       /**
-       * @fn check_index
-       * @brief this function checks the index.
-       * 
-       * @param [in] const std::string input - entered string
-       * @param [out] Token* token - if index exists, The index has been entered into the token.
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void check_index(IN std::string input, OUT Token* token);
-
-       /**
-       * @fn split
-       * @brief this function splits the token to the smaller elements.
-       * 
-       * @param [in] std::string input - entered string
-       * @param [in] Token* root - root token
-       * @param [in] bool flag - flag to distinguish token
-       * @param [in] std::string arg1 - next token, default = ""
-       * @param [in] std::string arg2 - next two token, default = ""
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void split(IN std::string input, IN Token* root, IN bool flag,IN std::string arg1="",IN std::string arg2="");
-
-       /**
-       * @fn check_number
-       * @brief this function distinguishes string type
-       * 
-       * @param [in] std::string & str - entered string
-       * @return int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       int check_number(IN std::string & str);
-
-       /**
-       * @fn check_Predicate
-       * @brief this function checks predicate
-       * 
-       * @param [in] std::string input - entered string
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       std::string check_Predicate(IN std::string input);
+    public:
+        /**
+        * @fn parse
+        * @brief parse ContextQuery
+        *
+        * @param [in] std::string input - Entered ContetxQuery
+        * @param [out] Token* root - parsed result
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void parse(IN std::string input, OUT Token *root);
+
+        /**
+        * @fn tolower
+        * @brief convert lowercase
+        *
+        * @param [in] std::string str - Entered string
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        static std::string tolower(IN std::string str);
+
+        /**
+        * @fn check_Query_grammer
+        * @brief check grammer
+        *
+        * @param [in] Token* token - parsed token
+        * @return boolean
+        * @warning
+        * @exception
+        * @see
+        */
+        bool check_grammer(IN Token *token);
+
+    private:
+        /**
+        * @fn tokenize
+        * @brief split sentence
+        *
+        * @param [in] const std::string& input - Entered ContetxQuery
+        * @return std::vector<std::string>
+        * @warning
+        * @exception
+        * @see
+        */
+        std::vector<std::string> tokenize(IN const std::string &input);
+
+        /**
+        * @fn getTokens
+        * @brief this function divides string into tokens based on a delimiter
+        *
+        * @param [in] const std::string& str - entered string
+        * @param [in] const std::string& delimiters = " " - token delimiter , default = " "
+        * @return std::vector<std::string>
+        * @warning
+        * @exception
+        * @see
+        */
+        static std::vector<std::string> getTokens(IN const std::string &str,
+                IN const std::string &delimiters = " ");
+
+        /**
+        * @fn check_index
+        * @brief this function checks the index.
+        *
+        * @param [in] const std::string input - entered string
+        * @param [out] Token* token - if index exists, The index has been entered into the token.
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void check_index(IN std::string input, OUT Token *token);
+
+        /**
+        * @fn split
+        * @brief this function splits the token to the smaller elements.
+        *
+        * @param [in] std::string input - entered string
+        * @param [in] Token* root - root token
+        * @param [in] bool flag - flag to distinguish token
+        * @param [in] std::string arg1 - next token, default = ""
+        * @param [in] std::string arg2 - next two token, default = ""
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void split(IN std::string input, IN Token *root, IN bool flag, IN std::string arg1 = "",
+                   IN std::string arg2 = "");
+
+        /**
+        * @fn check_number
+        * @brief this function distinguishes string type
+        *
+        * @param [in] std::string & str - entered string
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        int check_number(IN std::string &str);
+
+        /**
+        * @fn check_Predicate
+        * @brief this function checks predicate
+        *
+        * @param [in] std::string input - entered string
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        std::string check_Predicate(IN std::string input);
 };
 
 #endif /*_CQLParser_H_*/
index 0c96c12..33e8ebc 100644 (file)
 
 SSMRESULT CConditionedModel::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       m_triggerId = -1;
+    m_triggerId = -1;
 
-       m_pConditionedModelEvent = NULL;
+    m_pConditionedModelEvent = NULL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase**)&m_pEvaluationEngine));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase **)&m_pEvaluationEngine));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CConditionedModel::finalRelease()
 {
-       m_pConditionedModelEvent = NULL;
+    m_pConditionedModelEvent = NULL;
 
-       if(m_triggerId > -1)
-       {
-               deactivateTrigger();
-       }
+    if (m_triggerId > -1)
+    {
+        deactivateTrigger();
+    }
 
-       m_triggerId = -1;
+    m_triggerId = -1;
 }
 
-SSMRESULT CConditionedModel::create(IN IContextModel *pBaseModel, IN ModelConditionVec *pModelConditions)
+SSMRESULT CConditionedModel::create(IN IContextModel *pBaseModel,
+                                    IN ModelConditionVec *pModelConditions)
 {
-       m_watchCondition = *pModelConditions;
-       return pBaseModel->queryInterface(OID_IContextModel, (IBase**)&m_pBaseModel);
+    m_watchCondition = *pModelConditions;
+    return pBaseModel->queryInterface(OID_IContextModel, (IBase **)&m_pBaseModel);
 }
 
 SSMRESULT CConditionedModel::getBaseContextModel(OUT IContextModel **ppBaseContextModel)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(m_pBaseModel->queryInterface(OID_IContextModel, (IBase**)ppBaseContextModel));
+    SSM_CLEANUP_ASSERT(m_pBaseModel->queryInterface(OID_IContextModel, (IBase **)ppBaseContextModel));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CConditionedModel::registerConditionedModelEvent(IN IConditionedModelEvent *pConditionedModelEvent)
+SSMRESULT CConditionedModel::registerConditionedModelEvent(IN IConditionedModelEvent
+        *pConditionedModelEvent)
 {
-       m_pConditionedModelEvent = pConditionedModelEvent;
-       return SSM_S_OK;
+    m_pConditionedModelEvent = pConditionedModelEvent;
+    return SSM_S_OK;
 }
 
 SSMRESULT CConditionedModel::onWatchModelData(IN int triggerId, IN int dataId)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       m_mtxConditionedData.lock();
-       m_triggeredDataIds.push_back(dataId);
-       m_mtxConditionedData.unlock();
+    m_mtxConditionedData.lock();
+    m_triggeredDataIds.push_back(dataId);
+    m_mtxConditionedData.unlock();
 
-       if(m_pConditionedModelEvent)
-       {
-               res = m_pConditionedModelEvent->onConditionedModelTriggered(triggerId);
-       }
+    if (m_pConditionedModelEvent)
+    {
+        res = m_pConditionedModelEvent->onConditionedModelTriggered(triggerId);
+    }
 
-       return res;
+    return res;
 }
 
 SSMRESULT CConditionedModel::activateTrigger(OUT int *pTriggerId)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(m_pEvaluationEngine->watchModelData(m_pBaseModel->getModelId(),
-               &m_watchCondition, this, &m_triggerId));
+    SSM_CLEANUP_ASSERT(m_pEvaluationEngine->watchModelData(m_pBaseModel->getModelId(),
+                       &m_watchCondition, this, &m_triggerId));
 
-       *pTriggerId = m_triggerId;
+    *pTriggerId = m_triggerId;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CConditionedModel::deactivateTrigger()
 {
-       SSMRESULT res = SSM_S_OK;
+    SSMRESULT res = SSM_S_OK;
 
-       if(m_triggerId > -1)
-       {
-               SSM_CLEANUP_ASSERT(m_pEvaluationEngine->dropWatchModelData(m_triggerId));
-       }
+    if (m_triggerId > -1)
+    {
+        SSM_CLEANUP_ASSERT(m_pEvaluationEngine->dropWatchModelData(m_triggerId));
+    }
 
-       m_triggerId = -1;
+    m_triggerId = -1;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 bool CConditionedModel::hasAffectedData()
 {
-       bool ret = false;
-
-       m_mtxConditionedData.lock();
-
-       if(m_triggeredDataIds.size() > 0 || m_affectedDataIds.size() > 0)
-       {
-               ret = true;
-               goto CLEANUP;
-       }
-
-       if(m_pEvaluationEngine->getConditionedModelData(m_pBaseModel->getModelId(),
-               &m_watchCondition, &m_affectedDataIds) != SSM_S_OK)
-       {
-               ret = false;
-               goto CLEANUP;
-       }
-
-       if(m_affectedDataIds.size() > 0)
-       {
-               ret = true;
-               goto CLEANUP;
-       }
-       
+    bool ret = false;
+
+    m_mtxConditionedData.lock();
+
+    if (m_triggeredDataIds.size() > 0 || m_affectedDataIds.size() > 0)
+    {
+        ret = true;
+        goto CLEANUP;
+    }
+
+    if (m_pEvaluationEngine->getConditionedModelData(m_pBaseModel->getModelId(),
+            &m_watchCondition, &m_affectedDataIds) != SSM_S_OK)
+    {
+        ret = false;
+        goto CLEANUP;
+    }
+
+    if (m_affectedDataIds.size() > 0)
+    {
+        ret = true;
+        goto CLEANUP;
+    }
+
 CLEANUP:
-       m_mtxConditionedData.unlock();
-       return ret;
+    m_mtxConditionedData.unlock();
+    return ret;
 }
 
-SSMRESULT CConditionedModel::getAffectedData(OUT IntVec        *pDataIds)
+SSMRESULT CConditionedModel::getAffectedData(OUT IntVec *pDataIds)
 {
-       SSMRESULT res = SSM_E_FAIL;
-
-       m_mtxConditionedData.lock();
-
-       if(m_triggeredDataIds.size() > 0)
-       {
-               pDataIds->push_back(m_triggeredDataIds.front());
-               m_triggeredDataIds.pop_front();
-               SSM_CLEANUP_ASSERT(SSM_S_OK);
-       }
-       else
-       {
-               m_affectedDataIds.clear();
-               SSM_CLEANUP_ASSERT(m_pEvaluationEngine->getConditionedModelData(m_pBaseModel->getModelId(),
-                       &m_watchCondition, &m_affectedDataIds));
-               *pDataIds = m_affectedDataIds;
-       }
+    SSMRESULT res = SSM_E_FAIL;
+
+    m_mtxConditionedData.lock();
+
+    if (m_triggeredDataIds.size() > 0)
+    {
+        pDataIds->push_back(m_triggeredDataIds.front());
+        m_triggeredDataIds.pop_front();
+        SSM_CLEANUP_ASSERT(SSM_S_OK);
+    }
+    else
+    {
+        m_affectedDataIds.clear();
+        SSM_CLEANUP_ASSERT(m_pEvaluationEngine->getConditionedModelData(m_pBaseModel->getModelId(),
+                           &m_watchCondition, &m_affectedDataIds));
+        *pDataIds = m_affectedDataIds;
+    }
 
 CLEANUP:
-       m_mtxConditionedData.unlock();
-       return res;
+    m_mtxConditionedData.unlock();
+    return res;
 }
 
 SSMRESULT CConditionedModel::getWatchCondition(OUT ModelConditionVec *pModelConditions)
 {
-       *pModelConditions = m_watchCondition;
-       return SSM_S_OK;
+    *pModelConditions = m_watchCondition;
+    return SSM_S_OK;
 }
index 2c07e38..1d63c00 100644 (file)
 /**
 * @class    CConditionedModel
 * @brief    CConditionedModel Interface
-*                       This class represents Context Model's data search from given conditions
+*            This class represents Context Model's data search from given conditions
 *
 * @see
 */
-class CConditionedModel : 
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IConditionedModel
-       , public IEvaluationEngineEvent
+class CConditionedModel :
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IConditionedModel
+    , public IEvaluationEngineEvent
 {
-private:
-       CObjectPtr<IEvaluationEngine>                   m_pEvaluationEngine;
-       CObjectPtr<IContextModel>                               m_pBaseModel;
-       ModelConditionVec                                               m_watchCondition;
-       IConditionedModelEvent                                  *m_pConditionedModelEvent;
-       int                                                                             m_triggerId;
-       CSimpleMutex                                                    m_mtxConditionedData;
-       std::list<int>                                                  m_triggeredDataIds;
-       IntVec                                                                  m_affectedDataIds;
-
-public:
-       SSMRESULT finalConstruct();
-
-       void finalRelease();
-
-       /**
-       * @fn     create
-       * @brief Create Conditioned Model class using conditions.
-       *
-       * @param [in] IContextModel *pBaseModel - Base Context Model interface for Conditioned data reading
-       * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT create(IN IContextModel *pBaseModel, IN ModelConditionVec *pModelConditions);
-               
-       /**
-       * @fn     onWatchModelData
-       * @brief Called when Model data meets given conditions.
-       *
-       * @param [in] int triggerId - Trigger id.
-       * @param [in] int dataId - Affected data's Id
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT onWatchModelData(IN int triggerId, IN int dataId);
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IConditionedModel))
-               {
-                       IBase *pBase = (IConditionedModel*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn     getBaseContextModel
-       * @brief Get base Context Model interface
-       *
-       * @param [out] IContextModel **ppBaseContextModel - Interface pointer for retrieving base Context Model interface.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT getBaseContextModel(OUT IContextModel **ppBaseContextModel);
-
-       /**
-       * @fn     registerConditionedModelEvent
-       * @brief Register for receiving triggered event from given conditions
-       *
-       * @param [in] IConditionedModelEvent *pConditionedModelEvent - Interface for listening events.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT registerConditionedModelEvent(IN IConditionedModelEvent *pConditionedModelEvent);
-
-       /**
-       * @fn     activateTrigger
-       * @brief Activate trigger using given conditions
-       *
-       * @param [out] int *pTriggerId - Activated trigger id.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT activateTrigger(OUT int *pTriggerId);
-
-       /**
-       * @fn     deactivateTrigger
-       * @brief Deactivate trigger that activated
-       *
-       * @param NONE
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT deactivateTrigger();
-       
-       /**
-       * @fn     hasAffectedData
-       * @brief Quries if current Conditioned Model has affected data
-       *
-       * @param NONE
-       * 
-       * @return bool
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       bool hasAffectedData();
-
-       /**
-       * @fn     getAffectedData
-       * @brief Get affected data from given conditions includes triggered data
-       *
-       * @param [out] IntVec   *pDataIds - Affected dataId sets.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT getAffectedData(OUT IntVec *pDataIds);
-
-       /**
-       * @fn     getWatchCondition
-       * @brief Get watching conditions created from Context Model
-       *
-       * @param [out] ModelConditionVec *pModelConditions - Affected dataId sets.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT getWatchCondition(OUT ModelConditionVec *pModelConditions);
+    private:
+        CObjectPtr<IEvaluationEngine>           m_pEvaluationEngine;
+        CObjectPtr<IContextModel>               m_pBaseModel;
+        ModelConditionVec                       m_watchCondition;
+        IConditionedModelEvent                  *m_pConditionedModelEvent;
+        int                                     m_triggerId;
+        CSimpleMutex                            m_mtxConditionedData;
+        std::list<int>                          m_triggeredDataIds;
+        IntVec                                  m_affectedDataIds;
+
+    public:
+        SSMRESULT finalConstruct();
+
+        void finalRelease();
+
+        /**
+        * @fn     create
+        * @brief Create Conditioned Model class using conditions.
+        *
+        * @param [in] IContextModel *pBaseModel - Base Context Model interface for Conditioned data reading
+        * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT create(IN IContextModel *pBaseModel, IN ModelConditionVec *pModelConditions);
+
+        /**
+        * @fn     onWatchModelData
+        * @brief Called when Model data meets given conditions.
+        *
+        * @param [in] int triggerId - Trigger id.
+        * @param [in] int dataId - Affected data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT onWatchModelData(IN int triggerId, IN int dataId);
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IConditionedModel))
+            {
+                IBase *pBase = (IConditionedModel *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn     getBaseContextModel
+        * @brief Get base Context Model interface
+        *
+        * @param [out] IContextModel **ppBaseContextModel - Interface pointer for retrieving base Context Model interface.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getBaseContextModel(OUT IContextModel **ppBaseContextModel);
+
+        /**
+        * @fn     registerConditionedModelEvent
+        * @brief Register for receiving triggered event from given conditions
+        *
+        * @param [in] IConditionedModelEvent *pConditionedModelEvent - Interface for listening events.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT registerConditionedModelEvent(IN IConditionedModelEvent *pConditionedModelEvent);
+
+        /**
+        * @fn     activateTrigger
+        * @brief Activate trigger using given conditions
+        *
+        * @param [out] int *pTriggerId - Activated trigger id.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT activateTrigger(OUT int *pTriggerId);
+
+        /**
+        * @fn     deactivateTrigger
+        * @brief Deactivate trigger that activated
+        *
+        * @param NONE
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT deactivateTrigger();
+
+        /**
+        * @fn     hasAffectedData
+        * @brief Quries if current Conditioned Model has affected data
+        *
+        * @param NONE
+        *
+        * @return bool
+        * @warning
+        * @exception
+        * @see
+        */
+        bool hasAffectedData();
+
+        /**
+        * @fn     getAffectedData
+        * @brief Get affected data from given conditions includes triggered data
+        *
+        * @param [out] IntVec   *pDataIds - Affected dataId sets.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getAffectedData(OUT IntVec *pDataIds);
+
+        /**
+        * @fn     getWatchCondition
+        * @brief Get watching conditions created from Context Model
+        *
+        * @param [out] ModelConditionVec *pModelConditions - Affected dataId sets.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getWatchCondition(OUT ModelConditionVec *pModelConditions);
 };
 
 #endif
index 1d45a9b..f7de567 100644 (file)
 
 SSMRESULT CConditionedQuery::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase**)&m_pTasker));
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IConditionedQueryResult, (IBase**)&m_pConditionedQueryResult));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IConditionedQueryResult,
+                                      (IBase **)&m_pConditionedQueryResult));
 
-       m_conditionedQueryEvent = NULL;
+    m_conditionedQueryEvent = NULL;
 
-       m_untrackedConditionsCount = 0;
-       
-       m_reservedForActivate = false;
+    m_untrackedConditionsCount = 0;
 
-       m_userTriggerId = 0;
+    m_reservedForActivate = false;
 
-       m_targetDeviceDataId = -1;
+    m_userTriggerId = 0;
+
+    m_targetDeviceDataId = -1;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CConditionedQuery::finalRelease()
 {
-       m_conditionedQueryEvent = NULL;
+    m_conditionedQueryEvent = NULL;
 
-       SAFE_RELEASE(m_pConditionedQueryResult);
+    SAFE_RELEASE(m_pConditionedQueryResult);
 
-       for(std::vector<IConditionedModel*>::iterator itor = m_conditionedModels.begin();
-               itor != m_conditionedModels.end(); ++itor)
-       {
-               (*itor)->registerConditionedModelEvent(NULL);
-               SAFE_RELEASE((*itor));
-       }
+    for (std::vector<IConditionedModel *>::iterator itor = m_conditionedModels.begin();
+         itor != m_conditionedModels.end(); ++itor)
+    {
+        (*itor)->registerConditionedModelEvent(NULL);
+        SAFE_RELEASE((*itor));
+    }
 }
 
-SSMRESULT CConditionedQuery::create(IN IContextModel::ActivationType activationType, IN int totalConditionsCount)
+SSMRESULT CConditionedQuery::create(IN IContextModel::ActivationType activationType,
+                                    IN int totalConditionsCount)
 {
-       m_activationType = activationType;
-       m_untrackedConditionsCount = totalConditionsCount;
-       return SSM_S_OK;
+    m_activationType = activationType;
+    m_untrackedConditionsCount = totalConditionsCount;
+    return SSM_S_OK;
 }
 
-SSMRESULT CConditionedQuery::registerQueryConditionEvent(IN IConditionedQueryEvent *pConditionedQueryEvent)
+SSMRESULT CConditionedQuery::registerQueryConditionEvent(IN IConditionedQueryEvent
+        *pConditionedQueryEvent)
 {
-       m_conditionedQueryEvent = pConditionedQueryEvent;
-       return SSM_S_OK;
+    m_conditionedQueryEvent = pConditionedQueryEvent;
+    return SSM_S_OK;
 }
 
 SSMRESULT CConditionedQuery::onConditionedModelTriggered(IN int triggerId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       int                     evaluatedConditions = m_conditionedModels.size();
+    SSMRESULT res = SSM_E_FAIL;
+    int         evaluatedConditions = m_conditionedModels.size();
 
-       for(unsigned int i=0; i < m_conditionedModels.size(); i++)
-       {
-               if(m_conditionedModels[i]->hasAffectedData())
-               {
-                       evaluatedConditions--;
-               }
-       }
+    for (unsigned int i = 0; i < m_conditionedModels.size(); i++)
+    {
+        if (m_conditionedModels[i]->hasAffectedData())
+        {
+            evaluatedConditions--;
+        }
+    }
 
-       if(evaluatedConditions == 0)
-       {
-               m_pConditionedQueryResult->addRef();
-               SSM_CLEANUP_ASSERT(m_pTasker->addTask(this, (IConditionedQueryResult*)m_pConditionedQueryResult));
-       }
+    if (evaluatedConditions == 0)
+    {
+        m_pConditionedQueryResult->addRef();
+        SSM_CLEANUP_ASSERT(m_pTasker->addTask(this, (IConditionedQueryResult *)m_pConditionedQueryResult));
+    }
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-void CConditionedQuery::onExecute(IN voidpArg)
+void CConditionedQuery::onExecute(IN void *pArg)
 {
-       if(m_conditionedQueryEvent)
-       {
-               m_conditionedQueryEvent->onConditionedQueryEvent(m_userTriggerId, (IConditionedQueryResult*)pArg);
-       }
+    if (m_conditionedQueryEvent)
+    {
+        m_conditionedQueryEvent->onConditionedQueryEvent(m_userTriggerId, (IConditionedQueryResult *)pArg);
+    }
 }
 
-void CConditionedQuery::onTerminate(IN voidpArg)
+void CConditionedQuery::onTerminate(IN void *pArg)
 {
-       IConditionedQueryResult *pResult = (IConditionedQueryResult*)pArg;
-       SAFE_RELEASE(pResult);
+    IConditionedQueryResult *pResult = (IConditionedQueryResult *)pArg;
+    SAFE_RELEASE(pResult);
 }
 
 SSMRESULT CConditionedQuery::registerConditionedModel(IN IConditionedModel *pConditionedModel)
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       IContextModel           *pContextModel = NULL;
-
-       SSM_CLEANUP_ASSERT(pConditionedModel->registerConditionedModelEvent(this));
-       SSM_CLEANUP_ASSERT(m_pConditionedQueryResult->addConditionedModel(pConditionedModel));
-       pConditionedModel->addRef();
-       m_conditionedModels.push_back(pConditionedModel);
-
-       m_untrackedConditionsCount--;
-
-       SSM_CLEANUP_ASSERT(pConditionedModel->getBaseContextModel(&pContextModel));
-
-       //Some special cases, we use device::dataId property to efficient request
-       if(pContextModel->getModelName() == "Device")
-       {
-               ModelConditionVec       modelConditionVec;
-               SSM_CLEANUP_ASSERT(pConditionedModel->getWatchCondition(&modelConditionVec));
-               for(ModelConditionVec::iterator itor = modelConditionVec.begin(); 
-                       itor != modelConditionVec.end(); ++itor)
-               {
-                       if(itor->modelProperty.propertyName == "dataId" &&
-                               itor->predicate == ModelCondition::PREDICATE_EQ)
-                       {
-                               m_targetDeviceDataId = atoi(itor->modelProperty.propertyValue.c_str());
-                               break;
-                       }
-               }
-       }
-
-       if(hasAllConditionedModels() == true && m_reservedForActivate)
-       {
-               SSM_CLEANUP_ASSERT(activateTriggers(m_userTriggerId));
-       }
+    SSMRESULT           res = SSM_E_FAIL;
+    IContextModel       *pContextModel = NULL;
+
+    SSM_CLEANUP_ASSERT(pConditionedModel->registerConditionedModelEvent(this));
+    SSM_CLEANUP_ASSERT(m_pConditionedQueryResult->addConditionedModel(pConditionedModel));
+    pConditionedModel->addRef();
+    m_conditionedModels.push_back(pConditionedModel);
+
+    m_untrackedConditionsCount--;
+
+    SSM_CLEANUP_ASSERT(pConditionedModel->getBaseContextModel(&pContextModel));
+
+    //Some special cases, we use device::dataId property to efficient request
+    if (pContextModel->getModelName() == "Device")
+    {
+        ModelConditionVec   modelConditionVec;
+        SSM_CLEANUP_ASSERT(pConditionedModel->getWatchCondition(&modelConditionVec));
+        for (ModelConditionVec::iterator itor = modelConditionVec.begin();
+             itor != modelConditionVec.end(); ++itor)
+        {
+            if (itor->modelProperty.propertyName == "dataId" &&
+                itor->predicate == ModelCondition::PREDICATE_EQ)
+            {
+                m_targetDeviceDataId = atoi(itor->modelProperty.propertyValue.c_str());
+                break;
+            }
+        }
+    }
+
+    if (hasAllConditionedModels() == true && m_reservedForActivate)
+    {
+        SSM_CLEANUP_ASSERT(activateTriggers(m_userTriggerId));
+    }
 
 CLEANUP:
-       SAFE_RELEASE(pContextModel);
-       return res;
+    SAFE_RELEASE(pContextModel);
+    return res;
 }
 
 SSMRESULT CConditionedQuery::activateTriggers(IN int userTriggerId)
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       int                                     triggerId = 0;
-       IContextModel           *pBaseContextModel = NULL;
-
-       m_userTriggerId = userTriggerId;
-
-       if(hasAllConditionedModels() == false)
-       {
-               m_reservedForActivate = true;
-               return SSM_S_OK;
-       }
-
-       for(std::vector<IConditionedModel*>::iterator itor = m_conditionedModels.begin();
-               itor != m_conditionedModels.end(); ++itor)
-       {
-               SSM_CLEANUP_ASSERT((*itor)->activateTrigger(&triggerId));
-               SSM_CLEANUP_ASSERT((*itor)->getBaseContextModel(&pBaseContextModel));
-
-               switch(pBaseContextModel->getConstructionType())
-               {
-               case IContextModel::CONSTRUCTION_TYPE_EXTERNAL:
-               case IContextModel::CONSTRUCTION_TYPE_REMOTE:
-                       SSM_CLEANUP_ASSERT(pBaseContextModel->activate(m_activationType, m_targetDeviceDataId));
-                       break;
-
-               default:
-                       break;
-               }
-               SAFE_RELEASE(pBaseContextModel);
-       }
+    SSMRESULT           res = SSM_E_FAIL;
+    int                 triggerId = 0;
+    IContextModel       *pBaseContextModel = NULL;
+
+    m_userTriggerId = userTriggerId;
+
+    if (hasAllConditionedModels() == false)
+    {
+        m_reservedForActivate = true;
+        return SSM_S_OK;
+    }
+
+    for (std::vector<IConditionedModel *>::iterator itor = m_conditionedModels.begin();
+         itor != m_conditionedModels.end(); ++itor)
+    {
+        SSM_CLEANUP_ASSERT((*itor)->activateTrigger(&triggerId));
+        SSM_CLEANUP_ASSERT((*itor)->getBaseContextModel(&pBaseContextModel));
+
+        switch (pBaseContextModel->getConstructionType())
+        {
+            case IContextModel::CONSTRUCTION_TYPE_EXTERNAL:
+            case IContextModel::CONSTRUCTION_TYPE_REMOTE:
+                SSM_CLEANUP_ASSERT(pBaseContextModel->activate(m_activationType, m_targetDeviceDataId));
+                break;
+
+            default:
+                break;
+        }
+        SAFE_RELEASE(pBaseContextModel);
+    }
 
 CLEANUP:
-       SAFE_RELEASE(pBaseContextModel);
-       return res;
+    SAFE_RELEASE(pBaseContextModel);
+    return res;
 }
 
 SSMRESULT CConditionedQuery::deactivateTriggers()
 {
-       SSMRESULT res = SSM_E_FAIL;
-       IContextModel           *pBaseContextModel = NULL;
-
-       for(std::vector<IConditionedModel*>::iterator itor = m_conditionedModels.begin();
-               itor != m_conditionedModels.end(); ++itor)
-       {
-               SSM_CLEANUP_ASSERT((*itor)->deactivateTrigger());
-               SSM_CLEANUP_ASSERT((*itor)->getBaseContextModel(&pBaseContextModel));
-
-               switch(pBaseContextModel->getConstructionType())
-               {
-               case IContextModel::CONSTRUCTION_TYPE_EXTERNAL:
-               case IContextModel::CONSTRUCTION_TYPE_REMOTE:
-                       SSM_CLEANUP_ASSERT(pBaseContextModel->deactivate(m_activationType, m_targetDeviceDataId));
-                       break;
-
-               default:
-                       break;
-               }
-               SAFE_RELEASE(pBaseContextModel);
-       }
+    SSMRESULT res = SSM_E_FAIL;
+    IContextModel       *pBaseContextModel = NULL;
+
+    for (std::vector<IConditionedModel *>::iterator itor = m_conditionedModels.begin();
+         itor != m_conditionedModels.end(); ++itor)
+    {
+        SSM_CLEANUP_ASSERT((*itor)->deactivateTrigger());
+        SSM_CLEANUP_ASSERT((*itor)->getBaseContextModel(&pBaseContextModel));
+
+        switch (pBaseContextModel->getConstructionType())
+        {
+            case IContextModel::CONSTRUCTION_TYPE_EXTERNAL:
+            case IContextModel::CONSTRUCTION_TYPE_REMOTE:
+                SSM_CLEANUP_ASSERT(pBaseContextModel->deactivate(m_activationType, m_targetDeviceDataId));
+                break;
+
+            default:
+                break;
+        }
+        SAFE_RELEASE(pBaseContextModel);
+    }
 
 CLEANUP:
-       SAFE_RELEASE(pBaseContextModel);
-       return res;
+    SAFE_RELEASE(pBaseContextModel);
+    return res;
 }
 
-SSMRESULT CConditionedQuery::getConditionedQueryResult(OUT IConditionedQueryResult **ppConditionedQueryResult)
+SSMRESULT CConditionedQuery::getConditionedQueryResult(OUT IConditionedQueryResult
+        **ppConditionedQueryResult)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(m_pConditionedQueryResult->queryInterface(OID_IConditionedQueryResult,
-               (IBase**)ppConditionedQueryResult));
+    SSM_CLEANUP_ASSERT(m_pConditionedQueryResult->queryInterface(OID_IConditionedQueryResult,
+                       (IBase **)ppConditionedQueryResult));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 bool CConditionedQuery::hasAllConditionedModels()
 {
-       return m_untrackedConditionsCount == 0 ? true : false;
+    return m_untrackedConditionsCount == 0 ? true : false;
 }
index c85a086..ef53d0c 100644 (file)
 /**
 * @class    CConditionedQuery
 * @brief    CConditionedQuery Interface
-*                       This class represents parsed CQL for data retrieving
+*            This class represents parsed CQL for data retrieving
 *
 * @see
 */
-class CConditionedQuery : 
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IConditionedQuery
-       , public IThreadClient
-       , public IConditionedModelEvent
+class CConditionedQuery :
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IConditionedQuery
+    , public IThreadClient
+    , public IConditionedModelEvent
 {
-private:
-       CObjectPtr<ITasker>                                             m_pTasker;
-       //CObjectPtr<IPropagationEngine>                        m_PropagationEngine;
-       CObject<CConditionedQueryResult>                *m_pConditionedQueryResult;
-       std::vector<IConditionedModel*>                 m_conditionedModels;
-       CSimpleMutex                                                    m_mtxConditionCount;
-       IConditionedQueryEvent                                  *m_conditionedQueryEvent;
-       int                                                                             m_untrackedConditionsCount;
-       bool                                                                    m_reservedForActivate;
-       int                                                                             m_userTriggerId;
-       IContextModel::ActivationType                   m_activationType;
-       int                                                                             m_targetDeviceDataId;
-
-public:
-       SSMRESULT finalConstruct();
-
-       void finalRelease();
-
-       /**
-       * @fn     create
-       * @brief Create Conditioned Query for multiple data searching or triggering
-       *
-       * @param [in] IContextModel::ActivationType activationType - Specify ContextModel's working type
-       * @param [in] int totalConditionsCount - Specify total condition's count each condition is related to each ContextModel
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT create(IN IContextModel::ActivationType activationType, IN int totalConditionsCount);
-
-       /**
-       * @fn     registerQueryConditionEvent
-       * @brief Register IConditionedQueryEvent interface for listening events
-       *
-       * @param [in] IConditionedQueryEvent *pConditionedQueryEvent - Interface pointer for listening
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT registerQueryConditionEvent(IN IConditionedQueryEvent *pConditionedQueryEvent);
-
-       /**
-       * @fn     onConditionedModelTriggered
-       * @brief Called when each Conditioned Model meets the conditions
-       *
-       * @param [in] int triggerId - trigger id that which Conditioned Model triggered
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT onConditionedModelTriggered(IN int triggerId);
-
-       void onExecute(IN void* pArg);
-
-       void onTerminate(IN void* pArg);
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IConditionedQuery))
-               {
-                       IBase *pBase = (IConditionedQuery*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn     registerConditionedModel
-       * @brief Register Conditioned Model for tracking triggers
-       *
-       * @param [in] IConditionedModel *pConditionedModel - Interface of Conditioned Model
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT registerConditionedModel(IN IConditionedModel *pConditionedModel);
-
-       /**
-       * @fn     activateTriggers
-       * @brief Activate triggers for data evaluating. This changed related ContextModel's status to running
-       *
-       * @param [in] int userTriggerId - Specify TriggerId for event listening
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT activateTriggers(IN int userTriggerId);
-
-       /**
-       * @fn     deactivateTriggers
-       * @brief Deactivate triggers for data evaluating.
-       *
-       * @param [in] int userTriggerId - Specify TriggerId for event listening
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT deactivateTriggers();
-
-       /**
-       * @fn     getConditionedQueryResult
-       * @brief Retrieves conditioned data from current cached data
-       *
-       * @param [out] IConditionedQueryResult **ppConditionedQueryResult - Interface of result reader
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getConditionedQueryResult(OUT IConditionedQueryResult **ppConditionedQueryResult);
-
-       /**
-       * @fn     hasAllConditionedModels
-       * @brief Retrieves current conditioned query has all Conditioned ContextModels for evaluating
-       *
-       * @param NONE
-       * 
-       * @return bool
-       * @warning
-       * @exception
-       * @see
-       */
-       bool hasAllConditionedModels();
+    private:
+        CObjectPtr<ITasker>                     m_pTasker;
+        //CObjectPtr<IPropagationEngine>            m_PropagationEngine;
+        CObject<CConditionedQueryResult>        *m_pConditionedQueryResult;
+        std::vector<IConditionedModel *>         m_conditionedModels;
+        CSimpleMutex                            m_mtxConditionCount;
+        IConditionedQueryEvent                  *m_conditionedQueryEvent;
+        int                                     m_untrackedConditionsCount;
+        bool                                    m_reservedForActivate;
+        int                                     m_userTriggerId;
+        IContextModel::ActivationType           m_activationType;
+        int                                     m_targetDeviceDataId;
+
+    public:
+        SSMRESULT finalConstruct();
+
+        void finalRelease();
+
+        /**
+        * @fn     create
+        * @brief Create Conditioned Query for multiple data searching or triggering
+        *
+        * @param [in] IContextModel::ActivationType activationType - Specify ContextModel's working type
+        * @param [in] int totalConditionsCount - Specify total condition's count each condition is related to each ContextModel
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT create(IN IContextModel::ActivationType activationType, IN int totalConditionsCount);
+
+        /**
+        * @fn     registerQueryConditionEvent
+        * @brief Register IConditionedQueryEvent interface for listening events
+        *
+        * @param [in] IConditionedQueryEvent *pConditionedQueryEvent - Interface pointer for listening
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT registerQueryConditionEvent(IN IConditionedQueryEvent *pConditionedQueryEvent);
+
+        /**
+        * @fn     onConditionedModelTriggered
+        * @brief Called when each Conditioned Model meets the conditions
+        *
+        * @param [in] int triggerId - trigger id that which Conditioned Model triggered
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT onConditionedModelTriggered(IN int triggerId);
+
+        void onExecute(IN void *pArg);
+
+        void onTerminate(IN void *pArg);
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IConditionedQuery))
+            {
+                IBase *pBase = (IConditionedQuery *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn     registerConditionedModel
+        * @brief Register Conditioned Model for tracking triggers
+        *
+        * @param [in] IConditionedModel *pConditionedModel - Interface of Conditioned Model
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT registerConditionedModel(IN IConditionedModel *pConditionedModel);
+
+        /**
+        * @fn     activateTriggers
+        * @brief Activate triggers for data evaluating. This changed related ContextModel's status to running
+        *
+        * @param [in] int userTriggerId - Specify TriggerId for event listening
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT activateTriggers(IN int userTriggerId);
+
+        /**
+        * @fn     deactivateTriggers
+        * @brief Deactivate triggers for data evaluating.
+        *
+        * @param [in] int userTriggerId - Specify TriggerId for event listening
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT deactivateTriggers();
+
+        /**
+        * @fn     getConditionedQueryResult
+        * @brief Retrieves conditioned data from current cached data
+        *
+        * @param [out] IConditionedQueryResult **ppConditionedQueryResult - Interface of result reader
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getConditionedQueryResult(OUT IConditionedQueryResult **ppConditionedQueryResult);
+
+        /**
+        * @fn     hasAllConditionedModels
+        * @brief Retrieves current conditioned query has all Conditioned ContextModels for evaluating
+        *
+        * @param NONE
+        *
+        * @return bool
+        * @warning
+        * @exception
+        * @see
+        */
+        bool hasAllConditionedModels();
 };
 
 #endif
index 2f3c997..1396dec 100644 (file)
 
 SSMRESULT CConditionedQueryResult::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       res = SSM_S_OK;
-       //CLEANUP:
-       return res;
+    res = SSM_S_OK;
+    //CLEANUP:
+    return res;
 }
 
 void CConditionedQueryResult::finalRelease()
 {
-       for(std::vector<IConditionedModel*>::iterator itor = m_conditionedModels.begin();
-               itor != m_conditionedModels.end(); ++itor)
-       {
-               SAFE_RELEASE((*itor));
-       }
+    for (std::vector<IConditionedModel *>::iterator itor = m_conditionedModels.begin();
+         itor != m_conditionedModels.end(); ++itor)
+    {
+        SAFE_RELEASE((*itor));
+    }
 }
 
 SSMRESULT CConditionedQueryResult::addConditionedModel(IN IConditionedModel *pConditionedModel)
 {
-       pConditionedModel->addRef();
-       m_conditionedModels.push_back(pConditionedModel);
+    pConditionedModel->addRef();
+    m_conditionedModels.push_back(pConditionedModel);
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 unsigned int CConditionedQueryResult::getConditionedModelCount()
 {
-       return m_conditionedModels.size();
+    return m_conditionedModels.size();
 }
 
-SSMRESULT CConditionedQueryResult::getConditionedContextModel(IN unsigned int conditionedModelIndex, OUT IConditionedModel **ppConditionedModel)
+SSMRESULT CConditionedQueryResult::getConditionedContextModel(IN unsigned int conditionedModelIndex,
+        OUT IConditionedModel **ppConditionedModel)
 {
-       if(conditionedModelIndex > m_conditionedModels.size() - 1)
-       {
-               return SSM_E_FAIL;
-       }
+    if (conditionedModelIndex > m_conditionedModels.size() - 1)
+    {
+        return SSM_E_FAIL;
+    }
 
-       return m_conditionedModels[conditionedModelIndex]->queryInterface(OID_IConditionedModel, (IBase**)ppConditionedModel);
+    return m_conditionedModels[conditionedModelIndex]->queryInterface(OID_IConditionedModel,
+            (IBase **)ppConditionedModel);
 }
index d04b56d..92b649d 100644 (file)
 /**
 * @class    CConditionedQueryResult
 * @brief    CConditionedQueryResult Interface
-*                       This class represents executed CQL's result data 
+*            This class represents executed CQL's result data
 *
 * @see
 */
 class CConditionedQueryResult :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IConditionedQueryResult
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IConditionedQueryResult
 {
-private:
-       std::vector<IConditionedModel*>                 m_conditionedModels;
+    private:
+        std::vector<IConditionedModel *>         m_conditionedModels;
 
-public:
-       SSMRESULT finalConstruct();
+    public:
+        SSMRESULT finalConstruct();
 
-       void finalRelease();
+        void finalRelease();
 
-       /**
-       * @fn     addConditionedModel
-       * @brief Add conditioned model interface for tracking trigger
-       *
-       * @param [in] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT addConditionedModel(IN IConditionedModel *pConditionedModel);
+        /**
+        * @fn     addConditionedModel
+        * @brief Add conditioned model interface for tracking trigger
+        *
+        * @param [in] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT addConditionedModel(IN IConditionedModel *pConditionedModel);
 
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
 
-               if(IsEqualOID(objectID, OID_IConditionedQueryResult))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
+            if (IsEqualOID(objectID, OID_IConditionedQueryResult))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
 
-               return SSM_E_NOINTERFACE;
-       }
+            return SSM_E_NOINTERFACE;
+        }
 
-       /**
-       * @fn     getConditionedModelCount
-       * @brief Get conditioned model count
-       *
-       * @param NONE
-       * 
-       * @return unsigned int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       unsigned int getConditionedModelCount();
+        /**
+        * @fn     getConditionedModelCount
+        * @brief Get conditioned model count
+        *
+        * @param NONE
+        *
+        * @return unsigned int
+        * @warning
+        * @exception
+        * @see
+        */
+        unsigned int getConditionedModelCount();
 
-       /**
-       * @fn     getConditionedContextModel
-       * @brief Get conditioned model by index
-       *
-       * @param [in] unsigned int conditionedModelIndex - Index of Conditioned Model interface for retrieving
-       * @param [out] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT getConditionedContextModel(IN unsigned int conditionedModelIndex, OUT IConditionedModel **ppConditionedModel);
+        /**
+        * @fn     getConditionedContextModel
+        * @brief Get conditioned model by index
+        *
+        * @param [in] unsigned int conditionedModelIndex - Index of Conditioned Model interface for retrieving
+        * @param [out] IConditionedModel *pConditionedModel - Conditioned Model interface that contains results
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getConditionedContextModel(IN unsigned int conditionedModelIndex,
+                                             OUT IConditionedModel **ppConditionedModel);
 };
 
 #endif
index 1bb8eb1..93502c2 100644 (file)
 
 SSMRESULT CContextModel::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
-       ModelProperty           defaultModelProperty;
+    SSMRESULT res = SSM_E_FAIL;
+    ModelProperty       defaultModelProperty;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase**)&m_pTasker));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase**)&m_pEvaluationEngine));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase **)&m_pEvaluationEngine));
 
-       m_modelId = 0;
+    m_modelId = 0;
 
-       m_pContextModelEvent = NULL;
+    m_pContextModelEvent = NULL;
 
-       m_activationCount = 0;
+    m_activationCount = 0;
 
-       m_constructionType = CONSTRUCTION_TYPE_INTERNAL;
+    m_constructionType = CONSTRUCTION_TYPE_INTERNAL;
 
-       m_secLifeTime = "2147483647";
+    m_secLifeTime = "2147483647";
 
-       defaultModelProperty.propertyName = "dataId";
-       defaultModelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-       m_modelProperties.push_back(defaultModelProperty);
+    defaultModelProperty.propertyName = "dataId";
+    defaultModelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+    m_modelProperties.push_back(defaultModelProperty);
 
-       defaultModelProperty.propertyName = "lastTime";
-       defaultModelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-       m_modelProperties.push_back(defaultModelProperty);
+    defaultModelProperty.propertyName = "lastTime";
+    defaultModelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+    m_modelProperties.push_back(defaultModelProperty);
 
-       defaultModelProperty.propertyName = "lifetime";
-       defaultModelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-       m_modelProperties.push_back(defaultModelProperty);
+    defaultModelProperty.propertyName = "lifetime";
+    defaultModelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+    m_modelProperties.push_back(defaultModelProperty);
 
-       defaultModelProperty.propertyName = "available";
-       defaultModelProperty.propertyType = ModelProperty::TYPE_TEXT;
-       m_modelProperties.push_back(defaultModelProperty);
+    defaultModelProperty.propertyName = "available";
+    defaultModelProperty.propertyType = ModelProperty::TYPE_TEXT;
+    m_modelProperties.push_back(defaultModelProperty);
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CContextModel::finalRelease()
 {
-       SSMRESULT               res = SSM_E_FAIL;
-       std::map<int, IntVec>::iterator         itorDeviceId = m_mapDeviceDataIds.begin();
-       m_pContextModelEvent = NULL;
-
-       for(unsigned int i=0; i < m_mapDeviceDataIds.size(); i++)
-       {
-               //Other Device
-               if(itorDeviceId->first > 1)
-               {
-                       for(unsigned int j=0; j < itorDeviceId->second.size(); j++)
-                       {
-                               SSM_CLEANUP_ASSERT(deleteModelData(itorDeviceId->second[j]));
-                       }
-               }
-
-               itorDeviceId++;
-       }
-
-       //for(std::vector<IConditionedModel*>::iterator itor = m_ConditionedModels.begin();
-       //      itor != m_ConditionedModels.end(); ++itor)
-       //{
-       //      (*itor)->Release();
-       //}
+    SSMRESULT       res = SSM_E_FAIL;
+    std::map<int, IntVec>::iterator     itorDeviceId = m_mapDeviceDataIds.begin();
+    m_pContextModelEvent = NULL;
+
+    for (unsigned int i = 0; i < m_mapDeviceDataIds.size(); i++)
+    {
+        //Other Device
+        if (itorDeviceId->first > 1)
+        {
+            for (unsigned int j = 0; j < itorDeviceId->second.size(); j++)
+            {
+                SSM_CLEANUP_ASSERT(deleteModelData(itorDeviceId->second[j]));
+            }
+        }
+
+        itorDeviceId++;
+    }
+
+    //for(std::vector<IConditionedModel*>::iterator itor = m_ConditionedModels.begin();
+    //  itor != m_ConditionedModels.end(); ++itor)
+    //{
+    //  (*itor)->Release();
+    //}
 
 CLEANUP:
-       return;
+    return;
 }
 
-void CContextModel::registerSSMResource(IN ActivationType activationType, IN int targetDeviceDataId, IN ISSMResource* pSSMResource)
+void CContextModel::registerSSMResource(IN ActivationType activationType, IN int targetDeviceDataId,
+                                        IN ISSMResource *pSSMResource)
 {
-       int             *pData = NULL;
-
-       m_mtxActivationCount.lock();
-       switch(activationType)
-       {
-       case ACTIVATION_TYPE_SUBSCRIBE:
-               if(m_mapSubscribedDevice.find(targetDeviceDataId) == m_mapSubscribedDevice.end())
-               {
-                       pData = new int[2];
-                       pData[0] = STATUS_ACTIVATE;
-                       pData[1] = (int)pSSMResource;
-                       m_pTasker->addTask(this, (void*)pData);
-                       m_mapSubscribedDevice[targetDeviceDataId] = 1;
-               }
-               else
-               {
-                       m_mapSubscribedDevice[targetDeviceDataId]++;
-               }
-               break;
-
-       case ACTIVATION_TYPE_GET:
-               if(m_mapSubscribedDevice.find(targetDeviceDataId) == m_mapSubscribedDevice.end())
-               {
-                       if(m_mapGetDevice.find(targetDeviceDataId) == m_mapGetDevice.end())
-                       {
-                               pData = new int[2];
-                               pData[0] = STATUS_START_READ_VALUE;
-                               pData[1] = (int)pSSMResource;
-                               m_pTasker->addTask(this, (void*)pData);
-                               m_mapGetDevice[targetDeviceDataId] = 1;
-                       }
-                       else
-                       {
-                               m_mapGetDevice[targetDeviceDataId]++;
-                       }
-               }
-               break;
-
-       default:
-               break;
-       }
-       m_mtxActivationCount.unlock();
+    int     *pData = NULL;
+
+    m_mtxActivationCount.lock();
+    switch (activationType)
+    {
+        case ACTIVATION_TYPE_SUBSCRIBE:
+            if (m_mapSubscribedDevice.find(targetDeviceDataId) == m_mapSubscribedDevice.end())
+            {
+                pData = new int[2];
+                pData[0] = STATUS_ACTIVATE;
+                pData[1] = (int)pSSMResource;
+                m_pTasker->addTask(this, (void *)pData);
+                m_mapSubscribedDevice[targetDeviceDataId] = 1;
+            }
+            else
+            {
+                m_mapSubscribedDevice[targetDeviceDataId]++;
+            }
+            break;
+
+        case ACTIVATION_TYPE_GET:
+            if (m_mapSubscribedDevice.find(targetDeviceDataId) == m_mapSubscribedDevice.end())
+            {
+                if (m_mapGetDevice.find(targetDeviceDataId) == m_mapGetDevice.end())
+                {
+                    pData = new int[2];
+                    pData[0] = STATUS_START_READ_VALUE;
+                    pData[1] = (int)pSSMResource;
+                    m_pTasker->addTask(this, (void *)pData);
+                    m_mapGetDevice[targetDeviceDataId] = 1;
+                }
+                else
+                {
+                    m_mapGetDevice[targetDeviceDataId]++;
+                }
+            }
+            break;
+
+        default:
+            break;
+    }
+    m_mtxActivationCount.unlock();
 }
 
-void CContextModel::unregisterSSMResource(IN ActivationType activationType, IN int targetDeviceDataId, IN ISSMResource* pSSMResource)
+void CContextModel::unregisterSSMResource(IN ActivationType activationType,
+        IN int targetDeviceDataId, IN ISSMResource *pSSMResource)
 {
-       int             *pData = NULL;
-
-       m_mtxActivationCount.lock();
-       switch(activationType)
-       {
-       case ACTIVATION_TYPE_SUBSCRIBE:
-               if(m_mapSubscribedDevice.find(targetDeviceDataId) != m_mapSubscribedDevice.end())
-               {
-                       if(--m_mapSubscribedDevice[targetDeviceDataId] == 0)
-                       {
-                               pData = new int[2];
-                               pData[0] = STATUS_DEACTIVATE;
-                               pData[1] = (int)pSSMResource;
-                               m_pTasker->addTask(this, (void*)pData);
-                               m_mapSubscribedDevice.erase(targetDeviceDataId);
-                       }
-               }
-               break;
-
-       case ACTIVATION_TYPE_GET:
-               if(m_mapGetDevice.find(targetDeviceDataId) != m_mapGetDevice.end())
-               {
-                       if(--m_mapGetDevice[targetDeviceDataId] == 0)
-                       {
-                               pData = new int[2];
-                               pData[0] = STATUS_STOP_READ_VALUE;
-                               pData[1] = (int)pSSMResource;
-                               m_pTasker->addTask(this, (void*)pData);
-                       }
-               }
-               break;
-
-       default:
-               break;
-       }
-       m_mtxActivationCount.unlock();
+    int     *pData = NULL;
+
+    m_mtxActivationCount.lock();
+    switch (activationType)
+    {
+        case ACTIVATION_TYPE_SUBSCRIBE:
+            if (m_mapSubscribedDevice.find(targetDeviceDataId) != m_mapSubscribedDevice.end())
+            {
+                if (--m_mapSubscribedDevice[targetDeviceDataId] == 0)
+                {
+                    pData = new int[2];
+                    pData[0] = STATUS_DEACTIVATE;
+                    pData[1] = (int)pSSMResource;
+                    m_pTasker->addTask(this, (void *)pData);
+                    m_mapSubscribedDevice.erase(targetDeviceDataId);
+                }
+            }
+            break;
+
+        case ACTIVATION_TYPE_GET:
+            if (m_mapGetDevice.find(targetDeviceDataId) != m_mapGetDevice.end())
+            {
+                if (--m_mapGetDevice[targetDeviceDataId] == 0)
+                {
+                    pData = new int[2];
+                    pData[0] = STATUS_STOP_READ_VALUE;
+                    pData[1] = (int)pSSMResource;
+                    m_pTasker->addTask(this, (void *)pData);
+                }
+            }
+            break;
+
+        default:
+            break;
+    }
+    m_mtxActivationCount.unlock();
 }
 
-SSMRESULT CContextModel::create(IN ConstructionType constructionType, IN IContextModel *pParentModel, IN std::string modelName, IN ModelPropertyVec *pModelProperties)
+SSMRESULT CContextModel::create(IN ConstructionType constructionType,
+                                IN IContextModel *pParentModel, IN std::string modelName, IN ModelPropertyVec *pModelProperties)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       int         modelId = 1;
+    SSMRESULT res = SSM_E_FAIL;
+    int         modelId = 1;
 
-       if(pParentModel)
-       {
-               SSM_CLEANUP_ASSERT(pParentModel->queryInterface(OID_IContextModel, (IBase**)&m_pParentModel));
-               modelId = pParentModel->getModelId();
-       }
+    if (pParentModel)
+    {
+        SSM_CLEANUP_ASSERT(pParentModel->queryInterface(OID_IContextModel, (IBase **)&m_pParentModel));
+        modelId = pParentModel->getModelId();
+    }
 
-       m_constructionType = constructionType;
-       m_modelName = modelName;
+    m_constructionType = constructionType;
+    m_modelName = modelName;
 
-       SSM_CLEANUP_ASSERT(m_pEvaluationEngine->createModel(modelId, modelName.c_str(), pModelProperties, &m_modelId));
+    SSM_CLEANUP_ASSERT(m_pEvaluationEngine->createModel(modelId, modelName.c_str(), pModelProperties,
+                       &m_modelId));
 
-       for(ModelPropertyVec::iterator itor = pModelProperties->begin(); 
-               itor != pModelProperties->end(); ++itor)
-       {
-               m_modelProperties.push_back(*itor);
-       }
+    for (ModelPropertyVec::iterator itor = pModelProperties->begin();
+         itor != pModelProperties->end(); ++itor)
+    {
+        m_modelProperties.push_back(*itor);
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CContextModel::registerContextModelEvent(IN IContextModelEvent *pContextModelEvent)
 {
-       m_pContextModelEvent = pContextModelEvent;
-       return SSM_S_OK;
+    m_pContextModelEvent = pContextModelEvent;
+    return SSM_S_OK;
 }
 
-void CContextModel::onExecute(IN voidpArg)
+void CContextModel::onExecute(IN void *pArg)
 {
-       int     *pData = (int*)pArg;
+    int *pData = (int *)pArg;
 
-       if(m_pContextModelEvent)
-       {
-               m_pContextModelEvent->onModelStatusChange((Status)pData[0], (ISSMResource*)pData[1], this);
-       }
+    if (m_pContextModelEvent)
+    {
+        m_pContextModelEvent->onModelStatusChange((Status)pData[0], (ISSMResource *)pData[1], this);
+    }
 }
 
-void CContextModel::onTerminate(IN voidpArg)
+void CContextModel::onTerminate(IN void *pArg)
 {
-       int     *pData = (int*)pArg;
-       SAFE_ARRAY_DELETE(pData);
+    int *pData = (int *)pArg;
+    SAFE_ARRAY_DELETE(pData);
 }
 
 //TODO: called when new data arrived
-int CContextModel::onEvent(IN std::string deviceID, IN TypeofEvent callType, IN std::vector<ContextData> ctxData)
+int CContextModel::onEvent(IN std::string deviceID, IN TypeofEvent callType,
+                           IN std::vector<ContextData> ctxData)
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       int                                     dataId = 0;
-       ModelProperty           modelProperty;
-       ModelPropertyVec        modelProperties;
-       IntVec                          *deviceDataIds = NULL;
-       std::map<int, IntVec>::iterator         itorDeviceDataIds;
-       int                                     idxUpdate = 0;
-
-       if(m_modelName != ctxData[0].rootName)
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_POINTER);
-       }
-
-       if(m_mapSSM.find(deviceID) == m_mapSSM.end())
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_POINTER);
-       }
-
-       itorDeviceDataIds = m_mapDeviceDataIds.find(m_mapSSM[deviceID].first);
-       
-       if(itorDeviceDataIds != m_mapDeviceDataIds.end())
-       {
-               deviceDataIds = &(itorDeviceDataIds->second);
-       }
-
-       for(std::vector<ContextData>::iterator itorContextData = 
-               ctxData.begin(); itorContextData != ctxData.end(); ++itorContextData)
-       {
-               for(std::vector<std::map<std::string, std::string> >::iterator itor = 
-                       (*itorContextData).outputProperty.begin(); itor != (*itorContextData).outputProperty.end();
-                       ++itor)
-               {
-                       if(itor->find("error") != itor->end())
-                       {
-                               modelProperty.propertyName = "available";
-                               modelProperty.propertyValue = "false";
-                               modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-                               modelProperties.push_back(modelProperty);
-                               break;
-                       }
-
-                       modelProperty.propertyName = (*itor)["name"];
-                       modelProperty.propertyValue = (*itor)["value"];
-                       if((*itor)["type"] == "string")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-                       }
-                       else if((*itor)["type"] == "int")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-                       }
-                       else if((*itor)["type"] == "double")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_REAL;
-                       }
-                       else if((*itor)["type"] == "float")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_REAL;
-                       }
-                       else
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-                       }
-                       modelProperties.push_back(modelProperty);
-               }
-
-               //Add lifetime to field
-               modelProperty.propertyName = "lifetime";
-               modelProperty.propertyValue = m_secLifeTime;
-               modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-
-               modelProperties.push_back(modelProperty);
-               
-               if(deviceDataIds == NULL)
-               {
-                       SSM_CLEANUP_ASSERT(addModelData(m_mapSSM[deviceID].first, &modelProperties, &dataId));
-                       m_mapDeviceDataIds[m_mapSSM[deviceID].first].push_back(dataId);
-               }
-               else
-               {
-                       SSM_CLEANUP_ASSERT(updateModelData(m_mapDeviceDataIds[m_mapSSM[deviceID].first][idxUpdate++], &modelProperties));
-               }
-
-               modelProperties.clear();
-       }
+    SSMRESULT           res = SSM_E_FAIL;
+    int                 dataId = 0;
+    ModelProperty       modelProperty;
+    ModelPropertyVec    modelProperties;
+    IntVec              *deviceDataIds = NULL;
+    std::map<int, IntVec>::iterator     itorDeviceDataIds;
+    int                 idxUpdate = 0;
+
+    if (m_modelName != ctxData[0].rootName)
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_POINTER);
+    }
+
+    if (m_mapSSM.find(deviceID) == m_mapSSM.end())
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_POINTER);
+    }
+
+    itorDeviceDataIds = m_mapDeviceDataIds.find(m_mapSSM[deviceID].first);
+
+    if (itorDeviceDataIds != m_mapDeviceDataIds.end())
+    {
+        deviceDataIds = &(itorDeviceDataIds->second);
+    }
+
+    for (std::vector<ContextData>::iterator itorContextData =
+             ctxData.begin(); itorContextData != ctxData.end(); ++itorContextData)
+    {
+        for (std::vector<std::map<std::string, std::string> >::iterator itor =
+                 (*itorContextData).outputProperty.begin(); itor != (*itorContextData).outputProperty.end();
+             ++itor)
+        {
+            if (itor->find("error") != itor->end())
+            {
+                modelProperty.propertyName = "available";
+                modelProperty.propertyValue = "false";
+                modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+                modelProperties.push_back(modelProperty);
+                break;
+            }
+
+            modelProperty.propertyName = (*itor)["name"];
+            modelProperty.propertyValue = (*itor)["value"];
+            if ((*itor)["type"] == "string")
+            {
+                modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+            }
+            else if ((*itor)["type"] == "int")
+            {
+                modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+            }
+            else if ((*itor)["type"] == "double")
+            {
+                modelProperty.propertyType = ModelProperty::TYPE_REAL;
+            }
+            else if ((*itor)["type"] == "float")
+            {
+                modelProperty.propertyType = ModelProperty::TYPE_REAL;
+            }
+            else
+            {
+                modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+            }
+            modelProperties.push_back(modelProperty);
+        }
+
+        //Add lifetime to field
+        modelProperty.propertyName = "lifetime";
+        modelProperty.propertyValue = m_secLifeTime;
+        modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+
+        modelProperties.push_back(modelProperty);
+
+        if (deviceDataIds == NULL)
+        {
+            SSM_CLEANUP_ASSERT(addModelData(m_mapSSM[deviceID].first, &modelProperties, &dataId));
+            m_mapDeviceDataIds[m_mapSSM[deviceID].first].push_back(dataId);
+        }
+        else
+        {
+            SSM_CLEANUP_ASSERT(updateModelData(m_mapDeviceDataIds[m_mapSSM[deviceID].first][idxUpdate++],
+                                               &modelProperties));
+        }
+
+        modelProperties.clear();
+    }
 
 CLEANUP:
-       return 0;
+    return 0;
 }
 
 int CContextModel::getModelId()
 {
-       return m_modelId;
+    return m_modelId;
 }
 
 std::string CContextModel::getModelName()
 {
-       return m_modelName;
+    return m_modelName;
 }
 
 IContextModel::ConstructionType CContextModel::getConstructionType()
 {
-       return m_constructionType;
+    return m_constructionType;
 }
 
-SSMRESULT CContextModel::getParentDataId(IN int dataId, IN IContextModel *pParentModel, OUT int *pParentDataId)
+SSMRESULT CContextModel::getParentDataId(IN int dataId, IN IContextModel *pParentModel,
+        OUT int *pParentDataId)
 {
-       return m_pEvaluationEngine->getParentDataId(m_modelId, dataId, pParentModel->getModelId(), pParentDataId);
+    return m_pEvaluationEngine->getParentDataId(m_modelId, dataId, pParentModel->getModelId(),
+            pParentDataId);
 }
 
-SSMRESULT CContextModel::getChildDataId(IN int dataId, IN IContextModel *pChildModel, OUT IntVec *pChildDataIds)
+SSMRESULT CContextModel::getChildDataId(IN int dataId, IN IContextModel *pChildModel,
+                                        OUT IntVec *pChildDataIds)
 {
-       return m_pEvaluationEngine->getChildDataId(m_modelId, dataId, pChildModel->getModelId(), pChildDataIds);
+    return m_pEvaluationEngine->getChildDataId(m_modelId, dataId, pChildModel->getModelId(),
+            pChildDataIds);
 }
 
 SSMRESULT CContextModel::activate(IN ActivationType activationType, IN int targetDeviceDataId)
 {
-       if(targetDeviceDataId < 0 && activationType == ACTIVATION_TYPE_SUBSCRIBE)
-       {
-               m_mtxActivationCount.lock();
-               m_activationCount++;
-               m_mtxActivationCount.unlock();
-       }
-
-       for(std::map<std::string, std::pair<int, ISSMResource> >::iterator itor = m_mapSSM.begin();
-               itor != m_mapSSM.end(); ++itor)
-       {
-               if(targetDeviceDataId < 0)
-               {
-                       registerSSMResource(activationType, itor->second.first, &itor->second.second);
-               }
-               else if(itor->second.first == targetDeviceDataId)
-               {
-                       registerSSMResource(activationType, itor->second.first, &itor->second.second);
-                       break;
-               }
-       }
-
-       return SSM_S_OK;
+    if (targetDeviceDataId < 0 && activationType == ACTIVATION_TYPE_SUBSCRIBE)
+    {
+        m_mtxActivationCount.lock();
+        m_activationCount++;
+        m_mtxActivationCount.unlock();
+    }
+
+    for (std::map<std::string, std::pair<int, ISSMResource> >::iterator itor = m_mapSSM.begin();
+         itor != m_mapSSM.end(); ++itor)
+    {
+        if (targetDeviceDataId < 0)
+        {
+            registerSSMResource(activationType, itor->second.first, &itor->second.second);
+        }
+        else if (itor->second.first == targetDeviceDataId)
+        {
+            registerSSMResource(activationType, itor->second.first, &itor->second.second);
+            break;
+        }
+    }
+
+    return SSM_S_OK;
 }
 
 SSMRESULT CContextModel::deactivate(IN ActivationType activationType, IN int targetDeviceDataId)
 {
-       if(targetDeviceDataId < 0 && activationType == ACTIVATION_TYPE_SUBSCRIBE)
-       {
-               m_mtxActivationCount.lock();
-               m_activationCount--;
-               m_mtxActivationCount.unlock();
-       }
-
-       for(std::map<std::string, std::pair<int, ISSMResource> >::iterator itor = m_mapSSM.begin();
-               itor != m_mapSSM.end(); ++itor)
-       {
-               if(targetDeviceDataId < 0)
-               {
-                       unregisterSSMResource(activationType, itor->second.first, &itor->second.second);
-               }
-               else if(itor->second.first == targetDeviceDataId)
-               {
-                       unregisterSSMResource(activationType, itor->second.first, &itor->second.second);
-                       break;
-               }
-       }
-
-       return SSM_S_OK;
+    if (targetDeviceDataId < 0 && activationType == ACTIVATION_TYPE_SUBSCRIBE)
+    {
+        m_mtxActivationCount.lock();
+        m_activationCount--;
+        m_mtxActivationCount.unlock();
+    }
+
+    for (std::map<std::string, std::pair<int, ISSMResource> >::iterator itor = m_mapSSM.begin();
+         itor != m_mapSSM.end(); ++itor)
+    {
+        if (targetDeviceDataId < 0)
+        {
+            unregisterSSMResource(activationType, itor->second.first, &itor->second.second);
+        }
+        else if (itor->second.first == targetDeviceDataId)
+        {
+            unregisterSSMResource(activationType, itor->second.first, &itor->second.second);
+            break;
+        }
+    }
+
+    return SSM_S_OK;
 }
 /*
 SSMRESULT CContextModel::GetModelSchema(OUT ModelPropertyVec *pModelProperties)
 {
-       return m_pEvaluationEngine->GetModelSchema(m_ModelId, pModelProperties);
+    return m_pEvaluationEngine->GetModelSchema(m_ModelId, pModelProperties);
 }
 */
-SSMRESULT CContextModel::addModelData(IN int parentDataId, IN ModelPropertyVec *pData, OUT int *pDataId)
+SSMRESULT CContextModel::addModelData(IN int parentDataId, IN ModelPropertyVec *pData,
+                                      OUT int *pDataId)
 {
-       return m_pEvaluationEngine->addModelData(m_modelId, m_pParentModel->getModelId(), parentDataId, pData, pDataId);
+    return m_pEvaluationEngine->addModelData(m_modelId, m_pParentModel->getModelId(), parentDataId,
+            pData, pDataId);
 }
 
 SSMRESULT CContextModel::updateModelData(IN int dataId, IN ModelPropertyVec *pData)
 {
-       return m_pEvaluationEngine->updateModelData(m_modelId, dataId, pData);
+    return m_pEvaluationEngine->updateModelData(m_modelId, dataId, pData);
 }
 
 SSMRESULT CContextModel::deleteModelData(IN int dataId)
 {
-       return m_pEvaluationEngine->deleteModelData(m_modelId, dataId);
+    return m_pEvaluationEngine->deleteModelData(m_modelId, dataId);
 }
 
 SSMRESULT CContextModel::getModelData(IN int dataId, OUT ModelPropertyVec *pData)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       int             i = 0;
+    SSMRESULT res = SSM_E_FAIL;
+    int     i = 0;
 
-       SSM_CLEANUP_ASSERT(m_pEvaluationEngine->getModelData(m_modelId, dataId, pData));
-       for(ModelPropertyVec::iterator itor = pData->begin(); itor != pData->end(); ++itor)
-       {
-               itor->propertyName = m_modelProperties[i++].propertyName;
-       }
+    SSM_CLEANUP_ASSERT(m_pEvaluationEngine->getModelData(m_modelId, dataId, pData));
+    for (ModelPropertyVec::iterator itor = pData->begin(); itor != pData->end(); ++itor)
+    {
+        itor->propertyName = m_modelProperties[i++].propertyName;
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CContextModel::getModelDataSet(IN int startIndex, IN int count, OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex)
+SSMRESULT CContextModel::getModelDataSet(IN int startIndex, IN int count,
+        OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       int             i;
-
-       SSM_CLEANUP_ASSERT(m_pEvaluationEngine->getModelDataSet(m_modelId, startIndex, count, pDataSet, pLastIndex));
-
-       for(std::vector<ModelPropertyVec>::iterator itorModelProperty = pDataSet->begin();
-               itorModelProperty != pDataSet->end(); ++itorModelProperty)
-       {
-               i = 0;
-               for(ModelPropertyVec::iterator itor = itorModelProperty->begin(); itor != itorModelProperty->end(); ++itor)
-               {
-                       itor->propertyName = m_modelProperties[i++].propertyName;
-               }
-       }
+    SSMRESULT res = SSM_E_FAIL;
+    int     i;
+
+    SSM_CLEANUP_ASSERT(m_pEvaluationEngine->getModelDataSet(m_modelId, startIndex, count, pDataSet,
+                       pLastIndex));
+
+    for (std::vector<ModelPropertyVec>::iterator itorModelProperty = pDataSet->begin();
+         itorModelProperty != pDataSet->end(); ++itorModelProperty)
+    {
+        i = 0;
+        for (ModelPropertyVec::iterator itor = itorModelProperty->begin(); itor != itorModelProperty->end();
+             ++itor)
+        {
+            itor->propertyName = m_modelProperties[i++].propertyName;
+        }
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CContextModel::createConditionedModel(IN ModelConditionVec *pModelConditionVec, OUT IConditionedModel **ppConditionedModel)
+SSMRESULT CContextModel::createConditionedModel(IN ModelConditionVec *pModelConditionVec,
+        OUT IConditionedModel **ppConditionedModel)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       CObject<CConditionedModel>                                      *pConditionedModel;
+    SSMRESULT res = SSM_E_FAIL;
+    CObject<CConditionedModel>                  *pConditionedModel;
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IConditionedModel, (IBase**)&pConditionedModel));
-       SSM_CLEANUP_ASSERT(pConditionedModel->create(this, pModelConditionVec));
-       SSM_CLEANUP_ASSERT(pConditionedModel->queryInterface(OID_IConditionedModel, (IBase**)ppConditionedModel));
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IConditionedModel, (IBase **)&pConditionedModel));
+    SSM_CLEANUP_ASSERT(pConditionedModel->create(this, pModelConditionVec));
+    SSM_CLEANUP_ASSERT(pConditionedModel->queryInterface(OID_IConditionedModel,
+                       (IBase **)ppConditionedModel));
 
-       //(*ppConditionedModel)->AddRef();
-       //m_ConditionedModels.push_back(*ppConditionedModel);
+    //(*ppConditionedModel)->AddRef();
+    //m_ConditionedModels.push_back(*ppConditionedModel);
 
 CLEANUP:
-       SAFE_RELEASE(pConditionedModel);
-       return res;
+    SAFE_RELEASE(pConditionedModel);
+    return res;
 }
 /*
 SSMRESULT CContextModel::CleanUpModelData()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       for(std::map<int,int>::iterator itor = m_mapDataId.begin();
-               itor != m_mapDataId.end(); ++itor)
-       {
-               CHK_SSMRESULT(DeleteModelData(itor->second));
-       }
+    for(std::map<int,int>::iterator itor = m_mapDataId.begin();
+        itor != m_mapDataId.end(); ++itor)
+    {
+        CHK_SSMRESULT(DeleteModelData(itor->second));
+    }
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 */
 
 //Called new install or re install
-void CContextModel::addSSMResourceAndDeviceDataId(IN std::string deviceId, IN int deviceDataId, IN ISSMResource *pSSMResource)
+void CContextModel::addSSMResourceAndDeviceDataId(IN std::string deviceId, IN int deviceDataId,
+        IN ISSMResource *pSSMResource)
 {
-       if(deviceDataId == 1)
-       {
-               IntVec dataId;
-               m_pParentModel->getChildDataId(deviceDataId, this, &dataId);
-               if(dataId.size() > 0)
-               {
-                       m_mapDeviceDataIds[deviceDataId] = dataId;
-               }
-       }
-
-       if(m_mapSSM.find(deviceId) != m_mapSSM.end())
-       {
-               m_mtxActivationCount.lock();
-               if(m_activationCount > 0)
-               {
-                       unregisterSSMResource(ACTIVATION_TYPE_SUBSCRIBE, deviceDataId, &m_mapSSM[deviceId].second);
-               }
-               m_mtxActivationCount.unlock();
-       }
-       else
-       {
-               m_mapSSM[deviceId] = std::pair<int, ISSMResource>(deviceDataId, *pSSMResource);
-       }
-
-       m_mtxActivationCount.lock();
-       if(m_activationCount > 0)
-       {
-               registerSSMResource(ACTIVATION_TYPE_SUBSCRIBE, deviceDataId, &m_mapSSM[deviceId].second);
-       }
-       m_mtxActivationCount.unlock();
+    if (deviceDataId == 1)
+    {
+        IntVec dataId;
+        m_pParentModel->getChildDataId(deviceDataId, this, &dataId);
+        if (dataId.size() > 0)
+        {
+            m_mapDeviceDataIds[deviceDataId] = dataId;
+        }
+    }
+
+    if (m_mapSSM.find(deviceId) != m_mapSSM.end())
+    {
+        m_mtxActivationCount.lock();
+        if (m_activationCount > 0)
+        {
+            unregisterSSMResource(ACTIVATION_TYPE_SUBSCRIBE, deviceDataId, &m_mapSSM[deviceId].second);
+        }
+        m_mtxActivationCount.unlock();
+    }
+    else
+    {
+        m_mapSSM[deviceId] = std::pair<int, ISSMResource>(deviceDataId, *pSSMResource);
+    }
+
+    m_mtxActivationCount.lock();
+    if (m_activationCount > 0)
+    {
+        registerSSMResource(ACTIVATION_TYPE_SUBSCRIBE, deviceDataId, &m_mapSSM[deviceId].second);
+    }
+    m_mtxActivationCount.unlock();
 }
 
 void CContextModel::setLifeTime(std::string seconds)
 {
-       if(atoi(seconds.c_str()) > 0)
-       {
-               m_secLifeTime = seconds;
-       }
+    if (atoi(seconds.c_str()) > 0)
+    {
+        m_secLifeTime = seconds;
+    }
 }
index 2956213..0fa0b8d 100644 (file)
 /**
 * @class    CContextModel
 * @brief    CContextModel Interface
-*                       This class represents Context Model
+*            This class represents Context Model
 *
 * @see
 */
-class CContextModel : 
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IContextModel
-       , public IThreadClient
-       , public IEvent
+class CContextModel :
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IContextModel
+    , public IThreadClient
+    , public IEvent
 {
-private:
-       CObjectPtr<ITasker>                                             m_pTasker;
-       CObjectPtr<IEvaluationEngine>                   m_pEvaluationEngine;
-       CObjectPtr<IContextModel>                               m_pParentModel;
-       ModelPropertyVec                                                m_modelProperties;
-       //std::vector<IConditionedModel*>                       m_ConditionedModels;
-       int                                                                             m_modelId;
-       std::string                                                             m_modelName;
-       IContextModelEvent                                              *m_pContextModelEvent;
-       CSimpleMutex                                                    m_mtxActivationCount;
-       int                                                                             m_activationCount;
-
-       std::map<std::string, std::pair<int, ISSMResource> >    m_mapSSM;
-       std::map<int,IntVec>                                    m_mapDeviceDataIds;
-
-       //DeviceDataId, RefCount
-       std::map<int, int>                                              m_mapSubscribedDevice;
-       std::map<int, int>                                              m_mapGetDevice;
-
-       ConstructionType                                                m_constructionType;
-
-       std::string                                                             m_secLifeTime;
-
-       void registerSSMResource(IN ActivationType activationType, IN int targetDeviceDataId, IN ISSMResource* pSSMResource);
-       
-       void unregisterSSMResource(IN ActivationType activationType, IN int targetDeviceDataId, IN ISSMResource* pSSMResource);
-
-public:
-       SSMRESULT finalConstruct();
-
-       void finalRelease();
-
-       /**
-       * @fn     create
-       * @brief Create new Context Model 
-       *
-       * @param [in] ConstructionType constructionType - Construction Type that current model is created from external modules or internally created.
-       * @param [in] IContextModel *pParentModel - Parent Context Model that related to Model hierarchy.
-       * @param [in] std::string modelName - Represent model's name
-       * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT create(IN ConstructionType constructionType, IN IContextModel *pParentModel, 
-               IN std::string modelName, IN ModelPropertyVec *pModelProperties);
-
-       /**
-       * @fn     registerContextModelEvent
-       * @brief Register ContextModel's events like Activate or Deactivate
-       *
-       * @param [in] IContextModelEvent *pContextModelEvent - Event interface.
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT registerContextModelEvent(IN IContextModelEvent *pContextModelEvent);
-
-       void onExecute(IN void* pArg);
-
-       void onTerminate(IN void* pArg);
-
-       /**
-       * @fn     onEvent
-       * @brief Called when new context model data arrived
-       *
-       * @param [in] std::string deviceID - DeviceID that represents where the data comes.
-       * @param [in] TypeofEvent callType - Represent received data's type, streamed or single
-       * @param [in] std::vector<ContextData> ctxData - Context data
-       * 
-       * @return int
-       * @warning
-       * @exception
-       * @see
-       */
-       int onEvent(IN std::string deviceID, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IContextModel))
-               {
-                       IBase *pBase = (IContextModel*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn     getModelId
-       * @brief Get current model's id used for Evaluation Engine
-       *
-       * @param NONE
-       * 
-       * @return int
-       * @warning
-       * @exception
-       * @see
-       */
-       int getModelId();
-
-       /**
-       * @fn     getModelName
-       * @brief Get current model's name
-       *
-       * @param NONE
-       * 
-       * @return std::string
-       * @warning
-       * @exception
-       * @see
-       */
-       std::string getModelName();
-
-       /**
-       * @fn     getConstructionType
-       * @brief Get current model's constructionType defined when created
-       *
-       * @param NONE
-       * 
-       * @return IContextModel::ConstructionType
-       * @warning
-       * @exception
-       * @see
-       */
-       ConstructionType getConstructionType();
-
-       /**
-       * @fn     getParentDataId
-       * @brief Get parent dataId related to model hierarchy
-       *
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] IContextModel *pParentModel - Designated parent Context Model
-       * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getParentDataId(IN int dataId, IN IContextModel *pParentModel, OUT int *pParentDataId);
-
-       /**
-       * @fn     getChildDataId
-       * @brief Get child dataId related to model hierarchy
-       *
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] IContextModel *pChildModel - Designated child Context Model
-       * @param [out] int *pParentDataId - Designated child Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getChildDataId(IN int dataId, IN IContextModel *pChildModel, OUT IntVec *pChildDataIds);
-
-       /**
-       * @fn     activate
-       * @brief Activate current model's working. Each call to activate will increase internal reference counter
-       *
-       * @param [in] ActivationType activationType - Specify current model's working type
-       * @param [in] int targetDeviceDataId - Specify target device's dataId
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT activate(IN ActivationType activationType, IN int targetDeviceDataId);
-
-       /**
-       * @fn     deactivate
-       * @brief Deactivate current model's working. Each call to deactivate will decrease internal reference counter\n
-       *        and finally deactivated when counter is 0
-       *
-       * @param [in] ActivationType activationType - Specify current model's working type
-       * @param [in] int targetDeviceDataId - Specify target device's dataId
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT deactivate(IN ActivationType activationType, IN int targetDeviceDataId);
-
-       //SSMRESULT GetModelSchema(OUT ModelPropertyVec *pModelProperties);
-
-       /**
-       * @fn     addModelData
-       * @brief Add model data to Context Model
-       *
-       * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
-       * @param [in] ModelPropertyVec *pData - Packed data for adding
-       * @param [out] int *pDataId - Returned dataId that newly added
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT addModelData(IN int parentDataId, IN ModelPropertyVec *pData, OUT int *pDataId);
-
-       /**
-       * @fn     updateModelData
-       * @brief Update model data to Context Model 
-       *
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [in] ModelPropertyVec *pData - Packed data for updating
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT updateModelData(IN int dataId, IN ModelPropertyVec *pData);
-
-       /**
-       * @fn     deleteModelData
-       * @brief Delete model data using given index
-       *
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT deleteModelData(IN int dataId);
-
-       /**
-       * @fn     getModelData
-       * @brief Get model data
-       *
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [out] ModelPropertyVec *pData - Packed data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getModelData(IN int dataId, OUT ModelPropertyVec *pData);
-
-       /**
-       * @fn     getModelDataSet
-       * @brief Get model data set
-       *
-       * @param [in] int startIndex - Starting index of model data
-       * @param [in] int count - Number of data to retrieve
-       * @param [out] vector<ModelPropertyVec> *pData - Packed data
-       * @param [out] int *pLastIndex - Index of last data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getModelDataSet(IN int startIndex, IN int count, OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex);
-
-       /**
-       * @fn     createConditionedModel
-       * @brief Create Conditioned Model for data searching or triggering
-       *
-       * @param [in] ModelConditionVec *pModelConditionVec - Conditions that searching or triggering
-       * @param [out] IConditionedModel **ppConditionedModel - Created Conditioned Model interface
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT createConditionedModel(IN ModelConditionVec *pModelConditionVec, OUT IConditionedModel **ppConditionedModel);
-
-       //SSMRESULT CleanUpModelData();
-
-       /**
-       * @fn     addSSMResourceAndDeviceDataId
-       * @brief Add SSM resources with other informations - Internal use only
-       *
-       * @param [in] std::string deviceId - deviceId that used D2D communication
-       * @param [in] int deviceDataId - Device's dataId that where SSMResource come from
-       * @param [in] ISSMResource *pSSMResource - SSMResource for adding
-       * 
-       * @return NONE
-       * @warning
-       * @exception
-       * @see
-       */
-       void addSSMResourceAndDeviceDataId(IN std::string deviceId, IN int deviceDataId, IN ISSMResource *pSSMResource);
-
-       /**
-       * @fn     SetLifeTime
-       * @brief Sets current model data's lifeTime
-       *
-       * @param [in] int seconds - model data's lifeTime
-       * 
-       * @return NONE
-       * @warning
-       * @exception
-       * @see
-       */
-       void setLifeTime(std::string seconds);
+    private:
+        CObjectPtr<ITasker>                     m_pTasker;
+        CObjectPtr<IEvaluationEngine>           m_pEvaluationEngine;
+        CObjectPtr<IContextModel>               m_pParentModel;
+        ModelPropertyVec                        m_modelProperties;
+        //std::vector<IConditionedModel*>           m_ConditionedModels;
+        int                                     m_modelId;
+        std::string                             m_modelName;
+        IContextModelEvent                      *m_pContextModelEvent;
+        CSimpleMutex                            m_mtxActivationCount;
+        int                                     m_activationCount;
+
+        std::map<std::string, std::pair<int, ISSMResource> >    m_mapSSM;
+        std::map<int, IntVec>                    m_mapDeviceDataIds;
+
+        //DeviceDataId, RefCount
+        std::map<int, int>                      m_mapSubscribedDevice;
+        std::map<int, int>                      m_mapGetDevice;
+
+        ConstructionType                        m_constructionType;
+
+        std::string                             m_secLifeTime;
+
+        void registerSSMResource(IN ActivationType activationType, IN int targetDeviceDataId,
+                                 IN ISSMResource *pSSMResource);
+
+        void unregisterSSMResource(IN ActivationType activationType, IN int targetDeviceDataId,
+                                   IN ISSMResource *pSSMResource);
+
+    public:
+        SSMRESULT finalConstruct();
+
+        void finalRelease();
+
+        /**
+        * @fn     create
+        * @brief Create new Context Model
+        *
+        * @param [in] ConstructionType constructionType - Construction Type that current model is created from external modules or internally created.
+        * @param [in] IContextModel *pParentModel - Parent Context Model that related to Model hierarchy.
+        * @param [in] std::string modelName - Represent model's name
+        * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT create(IN ConstructionType constructionType, IN IContextModel *pParentModel,
+                         IN std::string modelName, IN ModelPropertyVec *pModelProperties);
+
+        /**
+        * @fn     registerContextModelEvent
+        * @brief Register ContextModel's events like Activate or Deactivate
+        *
+        * @param [in] IContextModelEvent *pContextModelEvent - Event interface.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT registerContextModelEvent(IN IContextModelEvent *pContextModelEvent);
+
+        void onExecute(IN void *pArg);
+
+        void onTerminate(IN void *pArg);
+
+        /**
+        * @fn     onEvent
+        * @brief Called when new context model data arrived
+        *
+        * @param [in] std::string deviceID - DeviceID that represents where the data comes.
+        * @param [in] TypeofEvent callType - Represent received data's type, streamed or single
+        * @param [in] std::vector<ContextData> ctxData - Context data
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        int onEvent(IN std::string deviceID, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IContextModel))
+            {
+                IBase *pBase = (IContextModel *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn     getModelId
+        * @brief Get current model's id used for Evaluation Engine
+        *
+        * @param NONE
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        int getModelId();
+
+        /**
+        * @fn     getModelName
+        * @brief Get current model's name
+        *
+        * @param NONE
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        std::string getModelName();
+
+        /**
+        * @fn     getConstructionType
+        * @brief Get current model's constructionType defined when created
+        *
+        * @param NONE
+        *
+        * @return IContextModel::ConstructionType
+        * @warning
+        * @exception
+        * @see
+        */
+        ConstructionType getConstructionType();
+
+        /**
+        * @fn     getParentDataId
+        * @brief Get parent dataId related to model hierarchy
+        *
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] IContextModel *pParentModel - Designated parent Context Model
+        * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getParentDataId(IN int dataId, IN IContextModel *pParentModel, OUT int *pParentDataId);
+
+        /**
+        * @fn     getChildDataId
+        * @brief Get child dataId related to model hierarchy
+        *
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] IContextModel *pChildModel - Designated child Context Model
+        * @param [out] int *pParentDataId - Designated child Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getChildDataId(IN int dataId, IN IContextModel *pChildModel, OUT IntVec *pChildDataIds);
+
+        /**
+        * @fn     activate
+        * @brief Activate current model's working. Each call to activate will increase internal reference counter
+        *
+        * @param [in] ActivationType activationType - Specify current model's working type
+        * @param [in] int targetDeviceDataId - Specify target device's dataId
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT activate(IN ActivationType activationType, IN int targetDeviceDataId);
+
+        /**
+        * @fn     deactivate
+        * @brief Deactivate current model's working. Each call to deactivate will decrease internal reference counter\n
+        *        and finally deactivated when counter is 0
+        *
+        * @param [in] ActivationType activationType - Specify current model's working type
+        * @param [in] int targetDeviceDataId - Specify target device's dataId
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT deactivate(IN ActivationType activationType, IN int targetDeviceDataId);
+
+        //SSMRESULT GetModelSchema(OUT ModelPropertyVec *pModelProperties);
+
+        /**
+        * @fn     addModelData
+        * @brief Add model data to Context Model
+        *
+        * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
+        * @param [in] ModelPropertyVec *pData - Packed data for adding
+        * @param [out] int *pDataId - Returned dataId that newly added
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT addModelData(IN int parentDataId, IN ModelPropertyVec *pData, OUT int *pDataId);
+
+        /**
+        * @fn     updateModelData
+        * @brief Update model data to Context Model
+        *
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [in] ModelPropertyVec *pData - Packed data for updating
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT updateModelData(IN int dataId, IN ModelPropertyVec *pData);
+
+        /**
+        * @fn     deleteModelData
+        * @brief Delete model data using given index
+        *
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT deleteModelData(IN int dataId);
+
+        /**
+        * @fn     getModelData
+        * @brief Get model data
+        *
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [out] ModelPropertyVec *pData - Packed data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getModelData(IN int dataId, OUT ModelPropertyVec *pData);
+
+        /**
+        * @fn     getModelDataSet
+        * @brief Get model data set
+        *
+        * @param [in] int startIndex - Starting index of model data
+        * @param [in] int count - Number of data to retrieve
+        * @param [out] vector<ModelPropertyVec> *pData - Packed data
+        * @param [out] int *pLastIndex - Index of last data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getModelDataSet(IN int startIndex, IN int count,
+                                  OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex);
+
+        /**
+        * @fn     createConditionedModel
+        * @brief Create Conditioned Model for data searching or triggering
+        *
+        * @param [in] ModelConditionVec *pModelConditionVec - Conditions that searching or triggering
+        * @param [out] IConditionedModel **ppConditionedModel - Created Conditioned Model interface
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT createConditionedModel(IN ModelConditionVec *pModelConditionVec,
+                                         OUT IConditionedModel **ppConditionedModel);
+
+        //SSMRESULT CleanUpModelData();
+
+        /**
+        * @fn     addSSMResourceAndDeviceDataId
+        * @brief Add SSM resources with other informations - Internal use only
+        *
+        * @param [in] std::string deviceId - deviceId that used D2D communication
+        * @param [in] int deviceDataId - Device's dataId that where SSMResource come from
+        * @param [in] ISSMResource *pSSMResource - SSMResource for adding
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void addSSMResourceAndDeviceDataId(IN std::string deviceId, IN int deviceDataId,
+                                           IN ISSMResource *pSSMResource);
+
+        /**
+        * @fn     SetLifeTime
+        * @brief Sets current model data's lifeTime
+        *
+        * @param [in] int seconds - model data's lifeTime
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void setLifeTime(std::string seconds);
 };
 #endif
index 855f159..dbf42c8 100644 (file)
@@ -19,9 +19,9 @@
 ******************************************************************/
 #include "ContextQuery.h"
 
-result_model::result_model() 
+result_model::result_model()
 {
-       modelID = 0;
+    modelID = 0;
 }
 
 CContextQuery::CContextQuery()
@@ -30,296 +30,297 @@ CContextQuery::CContextQuery()
 
 SSMRESULT CContextQuery::initialize(IN Token &input_root)
 {
-       m_root = input_root;
-       return CreateGlobalInstance(OID_IPropagationEngine, (IBase**)&m_pPropagationEngine);
+    m_root = input_root;
+    return CreateGlobalInstance(OID_IPropagationEngine, (IBase **)&m_pPropagationEngine);
 }
 
-std::string CContextQuery::search_last_modelName(IN Token * temp)
+std::string CContextQuery::search_last_modelName(IN Token *temp)
 {
-       while(true) 
-       {
-               if(temp->child_token.size()>0)
-               {
-                       temp = &(temp->child_token.at(0));
-               }
-               else
-               {
-                       return temp->name;
-               }
-       }
+    while (true)
+    {
+        if (temp->child_token.size() > 0)
+        {
+            temp = &(temp->child_token.at(0));
+        }
+        else
+        {
+            return temp->name;
+        }
+    }
 }
 
-void CContextQuery::integrate_result(OUT std::vector<result_model> *result, IN int modelId, IN std::vector<int> *dataid, IN std::string modelName)
+void CContextQuery::integrate_result(OUT std::vector<result_model> *result, IN int modelId,
+                                     IN std::vector<int> *dataid, IN std::string modelName)
 {
-       bool flag = false;
-
-       for(unsigned int i =0 ; i < result->size() ; i++)
-       {
-               if(result->at(i).modelID == modelId)
-               {
-                       flag = true;
-                       for(unsigned int k = 0 ; k < result->at(i).dataId.size() ; k++)
-                       {
-                               bool flag1 = false;
-                               for(unsigned int l = 0 ; l < dataid->size() ; l++)
-                               {
-                                       if(result->at(i).dataId.at(k) == dataid->at(l))
-                                       {
-                                               flag1 = true;
-                                               break;
-                                       }
-                               }
-                               if(flag1== false)
-                               {
-                                       result->at(i).dataId.erase(result->at(i).dataId.begin()+k);
-                                       k--;
-                               }
-                       }
-               }
-       }
-
-       if(flag == false)
-       {
-               result_model temp;
-               temp.modelID = modelId;
-               temp.dataId = *dataid;
-               temp.modelName = modelName;
-               result->push_back(temp);
-       }
+    bool flag = false;
+
+    for (unsigned int i = 0 ; i < result->size() ; i++)
+    {
+        if (result->at(i).modelID == modelId)
+        {
+            flag = true;
+            for (unsigned int k = 0 ; k < result->at(i).dataId.size() ; k++)
+            {
+                bool flag1 = false;
+                for (unsigned int l = 0 ; l < dataid->size() ; l++)
+                {
+                    if (result->at(i).dataId.at(k) == dataid->at(l))
+                    {
+                        flag1 = true;
+                        break;
+                    }
+                }
+                if (flag1 == false)
+                {
+                    result->at(i).dataId.erase(result->at(i).dataId.begin() + k);
+                    k--;
+                }
+            }
+        }
+    }
+
+    if (flag == false)
+    {
+        result_model temp;
+        temp.modelID = modelId;
+        temp.dataId = *dataid;
+        temp.modelName = modelName;
+        result->push_back(temp);
+    }
 }
 
 
 
-void CContextQuery::return_contextName(OUT std::vector<std::string>contextName)
+void CContextQuery::return_contextName(OUT std::vector<std::string> *contextName)
 {
-       int k = m_root.child_token.at(0).child_token.size();
+    int k = m_root.child_token.at(0).child_token.size();
 
-       for(int i =0; i < k; i++)
-       {
-               Token *temp = &(m_root.child_token.at(0).child_token.at(i));
-               contextName->push_back(search_last_modelName(temp));
-       }       
+    for (int i = 0; i < k; i++)
+    {
+        Token *temp = &(m_root.child_token.at(0).child_token.at(i));
+        contextName->push_back(search_last_modelName(temp));
+    }
 
 }
 
 void CContextQuery::check_result_model()
 {
-       if(m_root.child_token.at(0).child_token.size() <= 0)
-       {
-               int k = m_root.child_token.at(1).child_token.size();
-               std::vector<std::string> compare_string;
-               bool compare_flag = true;
-               std::string ModelName ="";
-               unsigned int min_cnt= MIN_NUM;
-
-               for(int i =0 ;i < k; i++)
-               {       
-                       Token* temp = &(m_root.child_token.at(1).child_token.at(i));
-                       std::string model_name;
-
-                       if(temp->type == Context)
-                       {
-                               while(true) 
-                               {
-                                       if(temp->child_token.size()>0)
-                                       {
-                                               model_name += temp->name + ".";
-                                               temp = &(temp->child_token.at(0));
-                                       }
-                                       else
-                                       {
-                                               model_name += temp->name;
-                                               break;
-                                       }
-                               }
-
-                               compare_string.push_back(model_name);
-                               if(min_cnt > model_name.size())
-                               {
-                                       min_cnt = model_name.size();
-                               }
-                       }
-
-               }
-
-               while(true)
-               {
-                       unsigned int cnt=0;
-                       if((unsigned int)cnt > min_cnt-1)
-                       {
-                               break;
-                       }
-
-                       char char_temp = 0;                     
-
-                       for(unsigned int i = 0 ; i < compare_string.size(); i++)
-                       {
-                               if( i == 0)
-                               {
-                                       char_temp = compare_string.at(i)[cnt];
-                                       compare_flag = true;
-                               }
-                               else
-                               {
-                                       if(char_temp != compare_string.at(i)[cnt])
-                                       {
-                                               compare_flag =false;
-                                               break;
-                                       }
-                               }
-                       }
-
-                       if(compare_flag == true)
-                       {
-                               ModelName += char_temp;
-                               cnt++;
-                       }
-                       else if(compare_flag == false)
-                       {
-                               break;
-                       }
-
-               }
-
-
-               std::string result_modelname ="";
-
-               for(int i = (int)ModelName.size()-1 ; i > -1 ; i--)
-               {
-                       if(ModelName[i] != '.' || (unsigned int)i != ModelName.size()-1)
-                       {
-                               result_modelname.insert(0,1,ModelName[i]);
-                       }
-               }
-
-               if(result_modelname.size() > 0)
-               {
-                       Token temp_token;
-                       temp_token.name = result_modelname;
-                       m_root.child_token.at(0).child_token.push_back(temp_token);
-               }
-       }
+    if (m_root.child_token.at(0).child_token.size() <= 0)
+    {
+        int k = m_root.child_token.at(1).child_token.size();
+        std::vector<std::string> compare_string;
+        bool compare_flag = true;
+        std::string ModelName = "";
+        unsigned int min_cnt = MIN_NUM;
+
+        for (int i = 0 ; i < k; i++)
+        {
+            Token *temp = &(m_root.child_token.at(1).child_token.at(i));
+            std::string model_name;
+
+            if (temp->type == Context)
+            {
+                while (true)
+                {
+                    if (temp->child_token.size() > 0)
+                    {
+                        model_name += temp->name + ".";
+                        temp = &(temp->child_token.at(0));
+                    }
+                    else
+                    {
+                        model_name += temp->name;
+                        break;
+                    }
+                }
+
+                compare_string.push_back(model_name);
+                if (min_cnt > model_name.size())
+                {
+                    min_cnt = model_name.size();
+                }
+            }
+
+        }
+
+        while (true)
+        {
+            unsigned int cnt = 0;
+            if ((unsigned int)cnt > min_cnt - 1)
+            {
+                break;
+            }
+
+            char char_temp = 0;
+
+            for (unsigned int i = 0 ; i < compare_string.size(); i++)
+            {
+                if ( i == 0)
+                {
+                    char_temp = compare_string.at(i)[cnt];
+                    compare_flag = true;
+                }
+                else
+                {
+                    if (char_temp != compare_string.at(i)[cnt])
+                    {
+                        compare_flag = false;
+                        break;
+                    }
+                }
+            }
+
+            if (compare_flag == true)
+            {
+                ModelName += char_temp;
+                cnt++;
+            }
+            else if (compare_flag == false)
+            {
+                break;
+            }
+
+        }
+
+
+        std::string result_modelname = "";
+
+        for (int i = (int)ModelName.size() - 1 ; i > -1 ; i--)
+        {
+            if (ModelName[i] != '.' || (unsigned int)i != ModelName.size() - 1)
+            {
+                result_modelname.insert(0, 1, ModelName[i]);
+            }
+        }
+
+        if (result_modelname.size() > 0)
+        {
+            Token temp_token;
+            temp_token.name = result_modelname;
+            m_root.child_token.at(0).child_token.push_back(temp_token);
+        }
+    }
 }
 
-void CContextQuery::return_modelID(OUT std::vector<int>vector_int)
+void CContextQuery::return_modelID(OUT std::vector<int> *vector_int)
 {
-       int k = m_root.child_token.at(0).child_token.size();
-       
-       for(int i =0; i < k; i++)
-       {
-               
-               Token *temp = &(m_root.child_token.at(0).child_token.at(i));
-
-               int pModel=0;
-               IContextModel *contextmodel;
-
-               m_pPropagationEngine->getContextModel(search_last_modelName(temp),&contextmodel);
-               pModel = contextmodel->getModelId();
-               vector_int->push_back(pModel);
-               SAFE_RELEASE(contextmodel);
-       }
+    int k = m_root.child_token.at(0).child_token.size();
+
+    for (int i = 0; i < k; i++)
+    {
+
+        Token *temp = &(m_root.child_token.at(0).child_token.at(i));
+
+        int pModel = 0;
+        IContextModel *contextmodel;
+
+        m_pPropagationEngine->getContextModel(search_last_modelName(temp), &contextmodel);
+        pModel = contextmodel->getModelId();
+        vector_int->push_back(pModel);
+        SAFE_RELEASE(contextmodel);
+    }
 }
 
 void CContextQuery::make_QueryCondition(OUT QueryCondition *result)
 {
 
-       if(m_root.child_token.size() < 2)
-       {
-               ModelConditionVec modelcondition;
-               ModelCondition model_data;
-               int dataId = 0;
-               
-               for(unsigned int i =0 ;i < m_root.child_token.at(0).child_token.size(); i++)
-               {
-                       Token* temp_token = &(m_root.child_token.at(0).child_token.at(i));
-                       std::string temp_name;
-
-                       while(true)
-                       {
-                               if(temp_token->child_token.size() > 0)
-                               {
-                                       temp_token = &(temp_token->child_token.at(0));
-                                       continue;
-                               } 
-                               else
-                               {
-                                       dataId = temp_token->number;
-                                       temp_name = temp_token->name;
-                               }
-                               
-                               modelcondition.clear();
-
-                               if(dataId == INDEX_ALL)
-                               {
-                                       ///m_pPropagationEngine->GetContextModel(temp_name,&contextmodel);
-                                       //contextmodel->GetModelSchema(modelpropertyVec);
-                                       model_data.modelProperty.propertyName = "dataId";
-                                       model_data.predicate = ModelCondition::PREDICATE_NEQ;
-                                       model_data.modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-                                       model_data.modelProperty.propertyValue = "0";
-                                       modelcondition.push_back(model_data);
-                                       result->push_back(std::pair<std::string, ModelConditionVec>(temp_name, modelcondition));
-                               }
-                               else if(dataId == INDEX_THIS)
-                               {
-
-                               }
-                               else
-                               {
-                                       std::stringstream sstream;
-                                       model_data.modelProperty.propertyName = "dataId";
-                                       model_data.predicate = ModelCondition::PREDICATE_EQ;
-                                       model_data.modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-                                       sstream << dataId << std::ends;
-                                       model_data.modelProperty.propertyValue = sstream.str();
-                                       modelcondition.push_back(model_data);
-                                       result->push_back(std::pair<std::string, ModelConditionVec>(temp_name, modelcondition));
-                                       
-                               }
-
-                               break;
-                       }// end while
-               }//end for
-       }//end if
-       else
-       {       
-               int k = m_root.child_token.at(1).child_token.size();
-               std::string model_name = "";
-               ModelConditionVec modelcondition;
-               ModelCondition model_data;
-               
-               for(int i = 0 ; i < k ; i++)
-               {
-                       modelcondition.clear();
-                       Token* temp = &(m_root.child_token.at(1).child_token.at(i));
-
-
-                       if(temp->type == Context)
-                       {
-                               while(1) 
-                               {
-                                       if(temp->child_token.size()>0)
-                                       {
-                                               //      model_name[i/3] = temp->name + ".";
-                                               temp = &(temp->child_token.at(0));
-                                       }
-                                       else
-                                       {
-                                               model_name = temp->name;
-                                               break;
-                                       }
-                               }
-                               
-
-
-                               model_data.predicate = m_root.child_token.at(1).child_token.at(i+1).condition;
-                               model_data.modelProperty.propertyName = temp->model_property.propertyName;
-                               model_data.modelProperty.propertyType = temp->model_property.propertyType;
-                               model_data.modelProperty.propertyValue = temp->model_property.propertyValue;
-                               modelcondition.push_back(model_data);
-                               result->push_back(std::pair<std::string, ModelConditionVec>(model_name, modelcondition));
-                               ///result->push_back(model_name[i],modelcondition);
-                       }
-               }
-       }
+    if (m_root.child_token.size() < 2)
+    {
+        ModelConditionVec modelcondition;
+        ModelCondition model_data;
+        int dataId = 0;
+
+        for (unsigned int i = 0 ; i < m_root.child_token.at(0).child_token.size(); i++)
+        {
+            Token *temp_token = &(m_root.child_token.at(0).child_token.at(i));
+            std::string temp_name;
+
+            while (true)
+            {
+                if (temp_token->child_token.size() > 0)
+                {
+                    temp_token = &(temp_token->child_token.at(0));
+                    continue;
+                }
+                else
+                {
+                    dataId = temp_token->number;
+                    temp_name = temp_token->name;
+                }
+
+                modelcondition.clear();
+
+                if (dataId == INDEX_ALL)
+                {
+                    ///m_pPropagationEngine->GetContextModel(temp_name,&contextmodel);
+                    //contextmodel->GetModelSchema(modelpropertyVec);
+                    model_data.modelProperty.propertyName = "dataId";
+                    model_data.predicate = ModelCondition::PREDICATE_NEQ;
+                    model_data.modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+                    model_data.modelProperty.propertyValue = "0";
+                    modelcondition.push_back(model_data);
+                    result->push_back(std::pair<std::string, ModelConditionVec>(temp_name, modelcondition));
+                }
+                else if (dataId == INDEX_THIS)
+                {
+
+                }
+                else
+                {
+                    std::stringstream sstream;
+                    model_data.modelProperty.propertyName = "dataId";
+                    model_data.predicate = ModelCondition::PREDICATE_EQ;
+                    model_data.modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+                    sstream << dataId << std::ends;
+                    model_data.modelProperty.propertyValue = sstream.str();
+                    modelcondition.push_back(model_data);
+                    result->push_back(std::pair<std::string, ModelConditionVec>(temp_name, modelcondition));
+
+                }
+
+                break;
+            }// end while
+        }//end for
+    }//end if
+    else
+    {
+        int k = m_root.child_token.at(1).child_token.size();
+        std::string model_name = "";
+        ModelConditionVec modelcondition;
+        ModelCondition model_data;
+
+        for (int i = 0 ; i < k ; i++)
+        {
+            modelcondition.clear();
+            Token *temp = &(m_root.child_token.at(1).child_token.at(i));
+
+
+            if (temp->type == Context)
+            {
+                while (1)
+                {
+                    if (temp->child_token.size() > 0)
+                    {
+                        //  model_name[i/3] = temp->name + ".";
+                        temp = &(temp->child_token.at(0));
+                    }
+                    else
+                    {
+                        model_name = temp->name;
+                        break;
+                    }
+                }
+
+
+
+                model_data.predicate = m_root.child_token.at(1).child_token.at(i + 1).condition;
+                model_data.modelProperty.propertyName = temp->model_property.propertyName;
+                model_data.modelProperty.propertyType = temp->model_property.propertyType;
+                model_data.modelProperty.propertyValue = temp->model_property.propertyValue;
+                modelcondition.push_back(model_data);
+                result->push_back(std::pair<std::string, ModelConditionVec>(model_name, modelcondition));
+                ///result->push_back(model_name[i],modelcondition);
+            }
+        }
+    }
 }
index de679c1..8b42ce5 100644 (file)
 #define MIN_NUM 10000
 
 
-class result_model 
+class result_model
 {
-public:
-    result_model();
-       int modelID;
-       std::vector<int> dataId;
-       std::string modelName;
+    public:
+        result_model();
+        int modelID;
+        std::vector<int> dataId;
+        std::string modelName;
 };
 
 class sub_modelId
 {
-public:
-       std::vector<int> modelId;
+    public:
+        std::vector<int> modelId;
 };
 
 
 /**
 * @class    ContextQuery
 * @brief    ContextQuery Interface
-*                       This class provides functions for parsing.
+*            This class provides functions for parsing.
 *
-* @see      
-*                      CContextQuery contextquery;
-*                      contextquery->check_result_model();
+* @see
+*           CContextQuery contextquery;
+*           contextquery->check_result_model();
 */
 class CContextQuery
 {
 
-public:
-       /**
-       * @fn CContextQuery
-       * @brief initializer
-       *
-       * @param none
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       CContextQuery();
-
-       /**
-       * @fn initialize
-       * @brief input Token
-       *
-       * @param [in] Token input_root - root Token
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT initialize(IN Token &input_root);
-
-       /**
-       * @fn integrate_result
-       * @brief This function checks for duplicate results.
-       *
-       * @param [out] std::vector<result_model>* result - result
-       * @param [in] int modelId - entered modelID
-       * @param [in] std::vector<int> *dataid - dataID according to modelID
-       * @param [in] std::string modelName - modelName according to modelID
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void integrate_result(OUT std::vector<result_model> *result,IN int modelId,IN std::vector<int> *dataid, IN std::string modelName);
-
-       /**
-       * @fn return_contextName
-       * @brief This function outputs ModelName of result clause
-       *
-       * @param [out] std::vector<std::string>* contextName - ModelName of result clause
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void return_contextName(OUT std::vector<std::string>* contextName);
-
-       /**
-       * @fn check_result_model
-       * @brief This function checks the existence of ContextModel from result clause
-       *
-       * @param none
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void check_result_model();
-
-       /**
-       * @fn return_modelID
-       * @brief This function returns ContextModelID of result clause
-       *
-       * @param [out] std::vector<int>* vector_int - ContextModelID
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void return_modelID(OUT std::vector<int>* vector_int);
-
-       /**
-       * @fn make_QueryCondition
-       * @brief This function makes QueryCondition using tokens.
-       *
-       * @param [out] QueryCondition* result - QueryCondition
-       * @return none
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void make_QueryCondition(OUT QueryCondition *result);
-
-private:
-       /**
-       * @fn search_last_modelName
-       * @brief return last child name
-       *
-       * @param [in] Token* temp - entered token
-       * @return std::string
-       * @warning
-       * @exception
-       * @see
-       */
-       std::string search_last_modelName(IN Token * temp);
-
-       Token m_root;
-       CObjectPtr<IPropagationEngine>          m_pPropagationEngine;
+    public:
+        /**
+        * @fn CContextQuery
+        * @brief initializer
+        *
+        * @param none
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        CContextQuery();
+
+        /**
+        * @fn initialize
+        * @brief input Token
+        *
+        * @param [in] Token input_root - root Token
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT initialize(IN Token &input_root);
+
+        /**
+        * @fn integrate_result
+        * @brief This function checks for duplicate results.
+        *
+        * @param [out] std::vector<result_model>* result - result
+        * @param [in] int modelId - entered modelID
+        * @param [in] std::vector<int> *dataid - dataID according to modelID
+        * @param [in] std::string modelName - modelName according to modelID
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void integrate_result(OUT std::vector<result_model> *result, IN int modelId,
+                              IN std::vector<int> *dataid, IN std::string modelName);
+
+        /**
+        * @fn return_contextName
+        * @brief This function outputs ModelName of result clause
+        *
+        * @param [out] std::vector<std::string>* contextName - ModelName of result clause
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void return_contextName(OUT std::vector<std::string> *contextName);
+
+        /**
+        * @fn check_result_model
+        * @brief This function checks the existence of ContextModel from result clause
+        *
+        * @param none
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void check_result_model();
+
+        /**
+        * @fn return_modelID
+        * @brief This function returns ContextModelID of result clause
+        *
+        * @param [out] std::vector<int>* vector_int - ContextModelID
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void return_modelID(OUT std::vector<int> *vector_int);
+
+        /**
+        * @fn make_QueryCondition
+        * @brief This function makes QueryCondition using tokens.
+        *
+        * @param [out] QueryCondition* result - QueryCondition
+        * @return none
+        * @warning
+        * @exception
+        * @see
+        */
+        void make_QueryCondition(OUT QueryCondition *result);
+
+    private:
+        /**
+        * @fn search_last_modelName
+        * @brief return last child name
+        *
+        * @param [in] Token* temp - entered token
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        std::string search_last_modelName(IN Token *temp);
+
+        Token m_root;
+        CObjectPtr<IPropagationEngine>      m_pPropagationEngine;
 };
 
 #endif /*_ContextQuery_H_*/
index 52f91a1..0779c14 100644 (file)
@@ -25,68 +25,72 @@ CDataReader::CDataReader()
 
 CDataReader::~CDataReader()
 {
-       for(std::map<std::string, std::vector<CModelData*> >::iterator itorModel = m_modelDataList.begin();
-               itorModel != m_modelDataList.end(); ++itorModel)
-       {
-               for(std::vector<CModelData*>::iterator itorData = itorModel->second.begin();
-                       itorData != itorModel->second.end(); ++itorData)
-               {
-                       SAFE_DELETE(*itorData);
-               }
-       }
+    for (std::map<std::string, std::vector<CModelData *> >::iterator itorModel =
+             m_modelDataList.begin();
+         itorModel != m_modelDataList.end(); ++itorModel)
+    {
+        for (std::vector<CModelData *>::iterator itorData = itorModel->second.begin();
+             itorData != itorModel->second.end(); ++itorData)
+        {
+            SAFE_DELETE(*itorData);
+        }
+    }
 }
 
-SSMRESULT CDataReader::addModelData(IN std::string modelName, IN std::vector<CModelData*> *pModelData)
+SSMRESULT CDataReader::addModelData(IN std::string modelName,
+                                    IN std::vector<CModelData *> *pModelData)
 {
-       m_modelDataList[modelName] = *pModelData;
+    m_modelDataList[modelName] = *pModelData;
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CDataReader::getAffectedModels(OUT std::vector<std::string> *pAffectedModels)
 {
-       for(std::map<std::string, std::vector<CModelData*> >::iterator itorModel = m_modelDataList.begin();
-               itorModel != m_modelDataList.end(); ++itorModel)
-       {
-               pAffectedModels->push_back(itorModel->first);
-       }
-
-       return SSM_S_OK;
+    for (std::map<std::string, std::vector<CModelData *> >::iterator itorModel =
+             m_modelDataList.begin();
+         itorModel != m_modelDataList.end(); ++itorModel)
+    {
+        pAffectedModels->push_back(itorModel->first);
+    }
+
+    return SSM_S_OK;
 }
 
 SSMRESULT CDataReader::getModelDataCount(IN std::string modelName, OUT int *pDataCount)
 {
-       std::map<std::string, std::vector<CModelData*> >::iterator itor;
+    std::map<std::string, std::vector<CModelData *> >::iterator itor;
 
-       itor = m_modelDataList.find(modelName);
+    itor = m_modelDataList.find(modelName);
 
-       if(itor == m_modelDataList.end())
-       {
-               return SSM_E_FAIL;
-       }
+    if (itor == m_modelDataList.end())
+    {
+        return SSM_E_FAIL;
+    }
 
-       *pDataCount = itor->second.size();
+    *pDataCount = itor->second.size();
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
-SSMRESULT CDataReader::getModelData(IN std::string modelName, IN int dataIndex, OUT IModelData **ppModelData)
+SSMRESULT CDataReader::getModelData(IN std::string modelName, IN int dataIndex,
+                                    OUT IModelData **ppModelData)
 {
-       std::map<std::string, std::vector<CModelData*> >::iterator itor;
+    std::map<std::string, std::vector<CModelData *> >::iterator itor;
 
-       itor = m_modelDataList.find(modelName);
+    itor = m_modelDataList.find(modelName);
 
-       if(itor == m_modelDataList.end())
-       {
-               return SSM_E_FAIL;
-       }
+    if (itor == m_modelDataList.end())
+    {
+        return SSM_E_FAIL;
+    }
 
-       if(dataIndex > (int)itor->second.size() - 1)
-       {
-               return SSM_E_FAIL;
-       }
+    if (dataIndex > (int)itor->second.size() - 1)
+    {
+        return SSM_E_FAIL;
+    }
 
-       *ppModelData = itor->second[dataIndex];
+    *ppModelData = itor->second[dataIndex];
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
index 2a0768a..79e7828 100644 (file)
 /**
 * @class    CDataReader
 * @brief    CDataReader Interface
-*                       This class represents context model data package's reader
+*            This class represents context model data package's reader
 *
 * @see
 */
 class CDataReader : public IDataReader
 {
-private:
-       std::map<std::string, std::vector<CModelData*> >        m_modelDataList;
+    private:
+        std::map<std::string, std::vector<CModelData *> >    m_modelDataList;
 
-public:
-       CDataReader();
+    public:
+        CDataReader();
 
-       ~CDataReader();
+        ~CDataReader();
 
-       /**
-       * @fn     addModelData
-       * @brief Add affected model data. This method is only for constructing data.
-       *
-       * @param [in] std::string modelName - affected model name to add
-       * @param [in] std::vector<CModelData*> *pModelData - affected model data list to add
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       SSMRESULT addModelData(IN std::string modelName, IN std::vector<CModelData*> *pModelData);
+        /**
+        * @fn     addModelData
+        * @brief Add affected model data. This method is only for constructing data.
+        *
+        * @param [in] std::string modelName - affected model name to add
+        * @param [in] std::vector<CModelData*> *pModelData - affected model data list to add
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT addModelData(IN std::string modelName, IN std::vector<CModelData *> *pModelData);
 
-       /**
-       * @fn     getAffectedModels
-       * @brief Get affected ContextModels. The CQL can specify multiple ContextModels for retrieving data.
-       *
-       * @param [out] std::vector<std::string> *pAffectedModels - affected ContextModel list
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       SSMRESULT getAffectedModels(OUT std::vector<std::string> *pAffectedModels);
+        /**
+        * @fn     getAffectedModels
+        * @brief Get affected ContextModels. The CQL can specify multiple ContextModels for retrieving data.
+        *
+        * @param [out] std::vector<std::string> *pAffectedModels - affected ContextModel list
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getAffectedModels(OUT std::vector<std::string> *pAffectedModels);
 
-       /**
-       * @fn     getModelDataCount
-       * @brief Get affected data count. There are multiple data can exist from given condition.
-       *
-       * @param [in] std::string modelName - affected ContextModel name
-       *
-       * @param [out] int *pDataCount - affected dataId count
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       SSMRESULT getModelDataCount(IN std::string modelName, OUT int *pDataCount);
+        /**
+        * @fn     getModelDataCount
+        * @brief Get affected data count. There are multiple data can exist from given condition.
+        *
+        * @param [in] std::string modelName - affected ContextModel name
+        *
+        * @param [out] int *pDataCount - affected dataId count
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getModelDataCount(IN std::string modelName, OUT int *pDataCount);
 
-       /**
-       * @fn     getModelData
-       * @brief Get actual Context Model data
-       *
-       * @param [in] std::string modelName - affected ContextModel name
-       *                               
-       *
-       * @param [in] int dataIndex - affected dataId index
-       *                               
-       * 
-       * @param [out] IModelData **ppModelData - affected ContextModel data reader
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       SSMRESULT getModelData(IN std::string modelName, IN int dataIndex, OUT IModelData **ppModelData);
+        /**
+        * @fn     getModelData
+        * @brief Get actual Context Model data
+        *
+        * @param [in] std::string modelName - affected ContextModel name
+        *
+        *
+        * @param [in] int dataIndex - affected dataId index
+        *
+        *
+        * @param [out] IModelData **ppModelData - affected ContextModel data reader
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getModelData(IN std::string modelName, IN int dataIndex, OUT IModelData **ppModelData);
 };
 
 #endif
index 165c42e..55238ba 100644 (file)
 
 SSMRESULT CEvaluationEngine::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       m_pSQLite3 = NULL;
+    m_pSQLite3 = NULL;
 
-       m_mtxTriggerId.lock();
-       m_iTriggerId = 0;
-       m_mtxTriggerId.unlock();
+    m_mtxTriggerId.lock();
+    m_iTriggerId = 0;
+    m_mtxTriggerId.unlock();
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, (IBase**)&m_pTasker));
-       SSM_CLEANUP_ASSERT(initializeEngine());
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, (IBase **)&m_pTasker));
+    SSM_CLEANUP_ASSERT(initializeEngine());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CEvaluationEngine::finalRelease()
 {
-       terminateEngine();
+    terminateEngine();
 }
 
 SSMRESULT CEvaluationEngine::executeSQL_NoReturn(IN std::string strSQL)
 {
-       SSMRESULT               res = SSM_E_FAIL;
-       sqlite3_stmt    *stmt = NULL;
+    SSMRESULT       res = SSM_E_FAIL;
+    sqlite3_stmt    *stmt = NULL;
 
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       CHK_SQLITE(sqlite3_step(stmt), SQLITE_DONE);
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    CHK_SQLITE(sqlite3_step(stmt), SQLITE_DONE);
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CEvaluationEngine::executeSQL_IntReturn(IN std::string strSQL, OUT int *pResult)
 {
-       SSMRESULT               res = SSM_E_FAIL;
-       sqlite3_stmt    *stmt = NULL;
+    SSMRESULT       res = SSM_E_FAIL;
+    sqlite3_stmt    *stmt = NULL;
 
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       CHK_SQLITE(sqlite3_step(stmt), SQLITE_ROW);
-       *pResult = sqlite3_column_int(stmt, 0);
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    CHK_SQLITE(sqlite3_step(stmt), SQLITE_ROW);
+    *pResult = sqlite3_column_int(stmt, 0);
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 
-void CEvaluationEngine::onSQLTrigger(IN sqlite3_context *context, IN int argc, IN sqlite3_value **argv)
+void CEvaluationEngine::onSQLTrigger(IN sqlite3_context *context, IN int argc,
+                                     IN sqlite3_value **argv)
 {
-       CEvaluationEngine *pEvaluationEngine = (CEvaluationEngine*)sqlite3_value_int(argv[0]);
+    CEvaluationEngine *pEvaluationEngine = (CEvaluationEngine *)sqlite3_value_int(argv[0]);
 
-       pEvaluationEngine->onWatcherTriggered(sqlite3_value_int(argv[1]), sqlite3_value_int(argv[2]));
+    pEvaluationEngine->onWatcherTriggered(sqlite3_value_int(argv[1]), sqlite3_value_int(argv[2]));
 }
 
-void CEvaluationEngine::onExecute(IN voidpArg)
+void CEvaluationEngine::onExecute(IN void *pArg)
 {
-       std::map<int, IEvaluationEngineEvent*>::iterator itor;
-       int             *pData = (int*)pArg;
-
-       m_mtxTriggerId.lock();
-       itor = m_mapTriggers.find(pData[0]);
-       if(itor != m_mapTriggers.end())
-       {
-               IEvaluationEngineEvent          *pEvent = itor->second;
-               pEvent->onWatchModelData(pData[0], pData[1]);
-       }
-       m_mtxTriggerId.unlock();
+    std::map<int, IEvaluationEngineEvent *>::iterator itor;
+    int     *pData = (int *)pArg;
+
+    m_mtxTriggerId.lock();
+    itor = m_mapTriggers.find(pData[0]);
+    if (itor != m_mapTriggers.end())
+    {
+        IEvaluationEngineEvent      *pEvent = itor->second;
+        pEvent->onWatchModelData(pData[0], pData[1]);
+    }
+    m_mtxTriggerId.unlock();
 }
 
-void CEvaluationEngine::onTerminate(IN voidpArg)
+void CEvaluationEngine::onTerminate(IN void *pArg)
 {
-       int *pData = (int*)pArg;
-       SAFE_ARRAY_DELETE(pData);
+    int *pData = (int *)pArg;
+    SAFE_ARRAY_DELETE(pData);
 }
 
 SSMRESULT CEvaluationEngine::onWatcherTriggered(IN int triggerId, IN int dataId)
 {
-       int             *pData = new int[2];
-       pData[0] = triggerId;
-       pData[1] = dataId;
-       m_pTasker->addTask(this, (void*)pData);
-       return SSM_S_OK;
+    int     *pData = new int[2];
+    pData[0] = triggerId;
+    pData[1] = dataId;
+    m_pTasker->addTask(this, (void *)pData);
+    return SSM_S_OK;
 }
 
 SSMRESULT CEvaluationEngine::initializeEngine()
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       sqlite3                         *pBackupFile = NULL;
-       sqlite3_backup          *pBackup = NULL;
+    SSMRESULT           res = SSM_E_FAIL;
+    sqlite3             *pBackupFile = NULL;
+    sqlite3_backup      *pBackup = NULL;
 
-       const char *strCreate_ModelRelationTable = 
-               "create table [ModelRelation]\
+    const char *strCreate_ModelRelationTable =
+        "create table [ModelRelation]\
                (\
                modelId integer primary key autoincrement,\
                modelName text NOT NULL,\
@@ -124,8 +125,8 @@ SSMRESULT CEvaluationEngine::initializeEngine()
                rPos int NOT NULL\
                );";
 
-       const char *strCreate_DataRelationTable = 
-               "create table [DataRelation]\
+    const char *strCreate_DataRelationTable =
+        "create table [DataRelation]\
                (\
                id integer primary key autoincrement,\
                modelId int NOT NULL,\
@@ -134,982 +135,1013 @@ SSMRESULT CEvaluationEngine::initializeEngine()
                dataId int NOT NULL\
                );";
 
-       //Create rootModel
-       const char *strRootModel = "insert into [ModelRelation] values (null, 'root', 1, 2);";
-
-       const char *tblRoot = "create table [ModelData1](dataId integer primary key autoincrement, name text);";
-
-       const char *rootData = "insert into [ModelData1] values (null, 'root');";
-
-       const char *rootRelation = "insert into [DataRelation] values (null, 1, 1, 2, 1);";
-
-       CHK_SQLITE(sqlite3_open_v2(LOCATION_SSM_DB, &m_pSQLite3, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL), SQLITE_OK);
-
-       CHK_SQLITE(sqlite3_create_function_v2(m_pSQLite3, "OnSQLTrigger", 3, SQLITE_UTF8, NULL, onSQLTrigger, NULL, NULL, NULL),
-               SQLITE_OK);
-
-       if(strlen(LOCATION_SSM_DB_DUMP) > 0 && 
-               sqlite3_open_v2(LOCATION_SSM_DB_DUMP, &pBackupFile, SQLITE_OPEN_READWRITE, NULL) == SQLITE_OK)
-       {
-               pBackup = sqlite3_backup_init(m_pSQLite3, "main", pBackupFile, "main");
-               CHK_SQLITE(sqlite3_errcode(pBackupFile), SQLITE_OK);
-               SSM_CLEANUP_NULL_ASSERT(pBackup);       
-               CHK_SQLITE(sqlite3_backup_step(pBackup, -1), SQLITE_DONE);      
-               CHK_SQLITE(sqlite3_backup_finish(pBackup), SQLITE_OK);
-               CHK_SQLITE(sqlite3_close(pBackupFile), SQLITE_OK);
-               res = SSM_S_OK;
-       }
-       else
-       {
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strCreate_ModelRelationTable));
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strCreate_DataRelationTable));
-
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strRootModel));
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(tblRoot));
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(rootData));
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(rootRelation));
-       }
+    //Create rootModel
+    const char *strRootModel = "insert into [ModelRelation] values (null, 'root', 1, 2);";
+
+    const char *tblRoot =
+        "create table [ModelData1](dataId integer primary key autoincrement, name text);";
+
+    const char *rootData = "insert into [ModelData1] values (null, 'root');";
+
+    const char *rootRelation = "insert into [DataRelation] values (null, 1, 1, 2, 1);";
+
+    CHK_SQLITE(sqlite3_open_v2(LOCATION_SSM_DB, &m_pSQLite3,
+                               SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL), SQLITE_OK);
+
+    CHK_SQLITE(sqlite3_create_function_v2(m_pSQLite3, "OnSQLTrigger", 3, SQLITE_UTF8, NULL,
+                                          onSQLTrigger, NULL, NULL, NULL),
+               SQLITE_OK);
+
+    if (strlen(LOCATION_SSM_DB_DUMP) > 0 &&
+        sqlite3_open_v2(LOCATION_SSM_DB_DUMP, &pBackupFile, SQLITE_OPEN_READWRITE, NULL) == SQLITE_OK)
+    {
+        pBackup = sqlite3_backup_init(m_pSQLite3, "main", pBackupFile, "main");
+        CHK_SQLITE(sqlite3_errcode(pBackupFile), SQLITE_OK);
+        SSM_CLEANUP_NULL_ASSERT(pBackup);
+        CHK_SQLITE(sqlite3_backup_step(pBackup, -1), SQLITE_DONE);
+        CHK_SQLITE(sqlite3_backup_finish(pBackup), SQLITE_OK);
+        CHK_SQLITE(sqlite3_close(pBackupFile), SQLITE_OK);
+        res = SSM_S_OK;
+    }
+    else
+    {
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strCreate_ModelRelationTable));
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strCreate_DataRelationTable));
+
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(strRootModel));
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(tblRoot));
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(rootData));
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(rootRelation));
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CEvaluationEngine::terminateEngine()
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       sqlite3                         *pBackupFile = NULL;
-       sqlite3_backup          *pBackup = NULL;
-       std::stringstream       sstream;
-
-       //Remove all triggers on db side
-       m_mtxTriggerId.lock();
-       for(std::map<int, IEvaluationEngineEvent*>::iterator itor = m_mapTriggers.begin();
-               itor != m_mapTriggers.end(); ++itor)
-       {
-               sstream << "drop trigger WatchInsertModel" << itor->first << ";" << std::ends;
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-               sstream.str("");
-
-               sstream << "drop trigger WatchUpdateModel" << itor->first << ";" << std::ends;
-               SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-               sstream.str("");
-       }
-       m_mtxTriggerId.unlock();
-
-       if(strlen(LOCATION_SSM_DB_DUMP) > 0)
-       {
-               CHK_SQLITE(sqlite3_open(LOCATION_SSM_DB_DUMP, &pBackupFile), SQLITE_OK);
-               pBackup = sqlite3_backup_init(pBackupFile, "main", m_pSQLite3, "main");
-               CHK_SQLITE(sqlite3_errcode(pBackupFile), SQLITE_OK);
-               SSM_CLEANUP_NULL_ASSERT(pBackup);       
-               CHK_SQLITE(sqlite3_backup_step(pBackup, -1), SQLITE_DONE);      
-               CHK_SQLITE(sqlite3_backup_finish(pBackup), SQLITE_OK);
-               CHK_SQLITE(sqlite3_close(pBackupFile), SQLITE_OK);
-       }       
-
-       CHK_SQLITE(sqlite3_close(m_pSQLite3), SQLITE_OK);
-
-       m_pSQLite3 = NULL;
-
-       res = SSM_S_OK;
+    SSMRESULT           res = SSM_E_FAIL;
+    sqlite3             *pBackupFile = NULL;
+    sqlite3_backup      *pBackup = NULL;
+    std::stringstream   sstream;
+
+    //Remove all triggers on db side
+    m_mtxTriggerId.lock();
+    for (std::map<int, IEvaluationEngineEvent *>::iterator itor = m_mapTriggers.begin();
+         itor != m_mapTriggers.end(); ++itor)
+    {
+        sstream << "drop trigger WatchInsertModel" << itor->first << ";" << std::ends;
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+        sstream.str("");
+
+        sstream << "drop trigger WatchUpdateModel" << itor->first << ";" << std::ends;
+        SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+        sstream.str("");
+    }
+    m_mtxTriggerId.unlock();
+
+    if (strlen(LOCATION_SSM_DB_DUMP) > 0)
+    {
+        CHK_SQLITE(sqlite3_open(LOCATION_SSM_DB_DUMP, &pBackupFile), SQLITE_OK);
+        pBackup = sqlite3_backup_init(pBackupFile, "main", m_pSQLite3, "main");
+        CHK_SQLITE(sqlite3_errcode(pBackupFile), SQLITE_OK);
+        SSM_CLEANUP_NULL_ASSERT(pBackup);
+        CHK_SQLITE(sqlite3_backup_step(pBackup, -1), SQLITE_DONE);
+        CHK_SQLITE(sqlite3_backup_finish(pBackup), SQLITE_OK);
+        CHK_SQLITE(sqlite3_close(pBackupFile), SQLITE_OK);
+    }
+
+    CHK_SQLITE(sqlite3_close(m_pSQLite3), SQLITE_OK);
+
+    m_pSQLite3 = NULL;
+
+    res = SSM_S_OK;
 CLEANUP:
-       return;
+    return;
 }
 
-SSMRESULT CEvaluationEngine::createModel(IN int parentModelId, IN const char *newModelName, IN ModelPropertyVec *pModelDescs, OUT int *pModelId)
+SSMRESULT CEvaluationEngine::createModel(IN int parentModelId, IN const char *newModelName,
+        IN ModelPropertyVec *pModelDescs, OUT int *pModelId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string                     strSQL;
-       sqlite3_stmt            *stmt = NULL;
-       int                     lPos = 0;
-
-       //Check if same name exists 
-       sstream << "select modelId from [ModelRelation] where modelName='" << newModelName << "';" << std::ends;
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       if(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               *pModelId = sqlite3_column_int(stmt, 0);
-               CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-               res = SSM_S_OK;
-               goto CLEANUP;
-       }
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-       sstream.str("");
-
-       sstream << "select lPos from [ModelRelation] where modelId = '" << parentModelId << "';" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_IntReturn(sstream.str(), &lPos));
-       sstream.str("");
-
-       sstream << "update [ModelRelation] set rPos = rPos + 2 where rPos > " << lPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "update [ModelRelation] set lPos = lPos + 2 where lPos > " << lPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "insert into [ModelRelation] values (null, '" << newModelName << "', " << lPos + 1 << ", " << lPos + 2 << 
-               ");" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       SSM_CLEANUP_ASSERT(executeSQL_IntReturn("select last_insert_rowid();", pModelId));
-
-       sstream << "create table [ModelData" << *pModelId << 
-               "](dataId integer primary key autoincrement, lastTime NOT NULL DEFAULT CURRENT_TIMESTAMP, lifetime integer NOT NULL DEFAULT 2147483647, available text DEFAULT 'true'";
-
-       for(ModelPropertyVec::iterator itor = 
-               pModelDescs->begin(); itor != pModelDescs->end(); ++itor)
-       {
-               sstream << "," << itor->propertyName;
-               switch(itor->propertyType)
-               {
-               case ModelProperty::TYPE_NUMERIC:
-                       sstream << " numeric";
-                       break;
-
-               case ModelProperty::TYPE_INTEGER:
-                       sstream << " integer";
-                       break;
-
-               case ModelProperty::TYPE_REAL:
-                       sstream << " real";
-                       break;
-
-               case ModelProperty::TYPE_TEXT:
-                       sstream << " text";
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-       }
-
-       sstream << ");" << std::ends;
-
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string         strSQL;
+    sqlite3_stmt        *stmt = NULL;
+    int         lPos = 0;
+
+    //Check if same name exists
+    sstream << "select modelId from [ModelRelation] where modelName='" << newModelName << "';" <<
+            std::ends;
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    if (sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        *pModelId = sqlite3_column_int(stmt, 0);
+        CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+        res = SSM_S_OK;
+        goto CLEANUP;
+    }
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    sstream.str("");
+
+    sstream << "select lPos from [ModelRelation] where modelId = '" << parentModelId << "';" <<
+            std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_IntReturn(sstream.str(), &lPos));
+    sstream.str("");
+
+    sstream << "update [ModelRelation] set rPos = rPos + 2 where rPos > " << lPos << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "update [ModelRelation] set lPos = lPos + 2 where lPos > " << lPos << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "insert into [ModelRelation] values (null, '" << newModelName << "', " << lPos + 1 <<
+            ", " << lPos + 2 <<
+            ");" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    SSM_CLEANUP_ASSERT(executeSQL_IntReturn("select last_insert_rowid();", pModelId));
+
+    sstream << "create table [ModelData" << *pModelId <<
+            "](dataId integer primary key autoincrement, lastTime NOT NULL DEFAULT CURRENT_TIMESTAMP, lifetime integer NOT NULL DEFAULT 2147483647, available text DEFAULT 'true'";
+
+    for (ModelPropertyVec::iterator itor =
+             pModelDescs->begin(); itor != pModelDescs->end(); ++itor)
+    {
+        sstream << "," << itor->propertyName;
+        switch (itor->propertyType)
+        {
+            case ModelProperty::TYPE_NUMERIC:
+                sstream << " numeric";
+                break;
+
+            case ModelProperty::TYPE_INTEGER:
+                sstream << " integer";
+                break;
+
+            case ModelProperty::TYPE_REAL:
+                sstream << " real";
+                break;
+
+            case ModelProperty::TYPE_TEXT:
+                sstream << " text";
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+    }
+
+    sstream << ");" << std::ends;
+
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::addModelData(IN int modelId, IN int parentModelId, IN int parentDataId, IN ModelPropertyVec *pModelValues, OUT int *pDataId)
+SSMRESULT CEvaluationEngine::addModelData(IN int modelId, IN int parentModelId, IN int parentDataId,
+        IN ModelPropertyVec *pModelValues, OUT int *pDataId)
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       std::stringstream       sstream;
-       std::string                     strSQL;
-       sqlite3_stmt            *stmt = NULL;
-       int                                     lPos = 0;
-       unsigned int            i;
-
-       sstream << "insert into [ModelData" << modelId << "] (";
-
-       for(ModelPropertyVec::iterator itor = pModelValues->begin();
-               itor != pModelValues->end(); ++itor)
-       {
-               sstream << itor->propertyName;
-
-               if(itor < pModelValues->end() - 1)
-               {
-                       sstream << ",";
-               }
-       }
-
-       sstream << ") values (";
-
-       for(i = 0; i < pModelValues->size(); i++)
-       {
-               sstream << "?";
-
-               if(i < pModelValues->size() - 1)
-               {
-                       sstream << ",";
-               }
-       }
-
-       sstream << ");" << std::ends;
-
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       sstream.str("");
-
-       i = 1;
-       for(ModelPropertyVec::iterator itor = pModelValues->begin();
-               itor != pModelValues->end(); ++itor)
-       {
-               switch(itor->propertyType)
-               {
-               case ModelProperty::TYPE_NUMERIC:
-               case ModelProperty::TYPE_INTEGER:
-                       CHK_SQLITE(sqlite3_bind_int(stmt, i, atoi(itor->propertyValue.c_str())), SQLITE_OK);
-                       break;
-
-               case ModelProperty::TYPE_REAL:
-                       CHK_SQLITE(sqlite3_bind_double(stmt, i, atof(itor->propertyValue.c_str())), SQLITE_OK);
-                       break;
-
-               case ModelProperty::TYPE_TEXT:
-                       CHK_SQLITE(sqlite3_bind_text(stmt, i, itor->propertyValue.c_str(), itor->propertyValue.size(), SQLITE_STATIC), SQLITE_OK);
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-
-               i++;
-       }
-
-       m_mtxDataRelation.lock();
-
-       CHK_SQLITE(sqlite3_step(stmt), SQLITE_DONE);
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       SSM_CLEANUP_ASSERT(executeSQL_IntReturn("select last_insert_rowid();", pDataId));
-
-       sstream << "select lPos from [DataRelation] where modelId = " << parentModelId << " and dataId = " << parentDataId << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_IntReturn(sstream.str(), &lPos));
-       sstream.str("");
-
-       sstream << "update [DataRelation] set rPos = rPos + 2 where rPos > " << lPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "update [DataRelation] set lPos = lPos + 2 where lPos > " << lPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "insert into [DataRelation] values (null, " << modelId << ", " << lPos + 1 << ", " << lPos + 2 << 
-               ", " << *pDataId << ");" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    SSMRESULT           res = SSM_E_FAIL;
+    std::stringstream   sstream;
+    std::string         strSQL;
+    sqlite3_stmt        *stmt = NULL;
+    int                 lPos = 0;
+    unsigned int        i;
+
+    sstream << "insert into [ModelData" << modelId << "] (";
+
+    for (ModelPropertyVec::iterator itor = pModelValues->begin();
+         itor != pModelValues->end(); ++itor)
+    {
+        sstream << itor->propertyName;
+
+        if (itor < pModelValues->end() - 1)
+        {
+            sstream << ",";
+        }
+    }
+
+    sstream << ") values (";
+
+    for (i = 0; i < pModelValues->size(); i++)
+    {
+        sstream << "?";
+
+        if (i < pModelValues->size() - 1)
+        {
+            sstream << ",";
+        }
+    }
+
+    sstream << ");" << std::ends;
+
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    sstream.str("");
+
+    i = 1;
+    for (ModelPropertyVec::iterator itor = pModelValues->begin();
+         itor != pModelValues->end(); ++itor)
+    {
+        switch (itor->propertyType)
+        {
+            case ModelProperty::TYPE_NUMERIC:
+            case ModelProperty::TYPE_INTEGER:
+                CHK_SQLITE(sqlite3_bind_int(stmt, i, atoi(itor->propertyValue.c_str())), SQLITE_OK);
+                break;
+
+            case ModelProperty::TYPE_REAL:
+                CHK_SQLITE(sqlite3_bind_double(stmt, i, atof(itor->propertyValue.c_str())), SQLITE_OK);
+                break;
+
+            case ModelProperty::TYPE_TEXT:
+                CHK_SQLITE(sqlite3_bind_text(stmt, i, itor->propertyValue.c_str(), itor->propertyValue.size(),
+                                             SQLITE_STATIC), SQLITE_OK);
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+
+        i++;
+    }
+
+    m_mtxDataRelation.lock();
+
+    CHK_SQLITE(sqlite3_step(stmt), SQLITE_DONE);
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    SSM_CLEANUP_ASSERT(executeSQL_IntReturn("select last_insert_rowid();", pDataId));
+
+    sstream << "select lPos from [DataRelation] where modelId = " << parentModelId << " and dataId = "
+            << parentDataId << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_IntReturn(sstream.str(), &lPos));
+    sstream.str("");
+
+    sstream << "update [DataRelation] set rPos = rPos + 2 where rPos > " << lPos << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "update [DataRelation] set lPos = lPos + 2 where lPos > " << lPos << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "insert into [DataRelation] values (null, " << modelId << ", " << lPos + 1 << ", " <<
+            lPos + 2 <<
+            ", " << *pDataId << ");" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
 
 CLEANUP:
-       m_mtxDataRelation.unlock();
-       return res;
+    m_mtxDataRelation.unlock();
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::updateModelData(IN int modelId, IN int dataId, IN ModelPropertyVec *pModelValues)
+SSMRESULT CEvaluationEngine::updateModelData(IN int modelId, IN int dataId,
+        IN ModelPropertyVec *pModelValues)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string                     strSQL;
-       sqlite3_stmt            *stmt = NULL;
-       unsigned int            i = 1;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string         strSQL;
+    sqlite3_stmt        *stmt = NULL;
+    unsigned int        i = 1;
 
-       sstream << "update [ModelData" << modelId << "] set lastTime=CURRENT_TIMESTAMP, ";
+    sstream << "update [ModelData" << modelId << "] set lastTime=CURRENT_TIMESTAMP, ";
 
-       for(ModelPropertyVec::iterator itor = pModelValues->begin(); 
-               itor != pModelValues->end(); ++itor)
-       {
-               sstream << itor->propertyName << "=?";
+    for (ModelPropertyVec::iterator itor = pModelValues->begin();
+         itor != pModelValues->end(); ++itor)
+    {
+        sstream << itor->propertyName << "=?";
 
-               if(itor < pModelValues->end() - 1)
-               {
-                       sstream << ",";
-               }
-       }
+        if (itor < pModelValues->end() - 1)
+        {
+            sstream << ",";
+        }
+    }
 
-       sstream << " where dataId = " << dataId << ";" << std::ends;
+    sstream << " where dataId = " << dataId << ";" << std::ends;
 
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
 
-       for(ModelPropertyVec::iterator itor = pModelValues->begin();
-               itor != pModelValues->end(); ++itor)
-       {
-               switch(itor->propertyType)
-               {
-               case ModelProperty::TYPE_NUMERIC:
-               case ModelProperty::TYPE_INTEGER:
-                       CHK_SQLITE(sqlite3_bind_int(stmt, i, atoi(itor->propertyValue.c_str())), SQLITE_OK);
-                       break;
+    for (ModelPropertyVec::iterator itor = pModelValues->begin();
+         itor != pModelValues->end(); ++itor)
+    {
+        switch (itor->propertyType)
+        {
+            case ModelProperty::TYPE_NUMERIC:
+            case ModelProperty::TYPE_INTEGER:
+                CHK_SQLITE(sqlite3_bind_int(stmt, i, atoi(itor->propertyValue.c_str())), SQLITE_OK);
+                break;
 
-               case ModelProperty::TYPE_REAL:
-                       CHK_SQLITE(sqlite3_bind_double(stmt, i, atof(itor->propertyValue.c_str())), SQLITE_OK);
-                       break;
+            case ModelProperty::TYPE_REAL:
+                CHK_SQLITE(sqlite3_bind_double(stmt, i, atof(itor->propertyValue.c_str())), SQLITE_OK);
+                break;
 
-               case ModelProperty::TYPE_TEXT:
-                       CHK_SQLITE(sqlite3_bind_text(stmt, i, itor->propertyValue.c_str(), itor->propertyValue.size(), SQLITE_STATIC), SQLITE_OK);
-                       break;
+            case ModelProperty::TYPE_TEXT:
+                CHK_SQLITE(sqlite3_bind_text(stmt, i, itor->propertyValue.c_str(), itor->propertyValue.size(),
+                                             SQLITE_STATIC), SQLITE_OK);
+                break;
 
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
 
-               i++;
-       }
+        i++;
+    }
 
-       CHK_SQLITE(sqlite3_step(stmt), SQLITE_DONE);
+    CHK_SQLITE(sqlite3_step(stmt), SQLITE_DONE);
 
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 /*
 SSMRESULT CEvaluationEngine::DeleteModel(IN int modelId)
 {
-       SSMRESULT               res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string             strSQL;
-       sqlite3_stmt    *stmt = NULL;
-       int                             lPos = 0;
-       int                             rPos = 0;
-       int                             width = 0;
-       IntVec                  dataIds;
-
-       sstream << "select lPos, rPos from [ModelRelation] where modelId = " << modelId << ";" << std::ends;
-
-       strSQL = sstream.str();
-       sstream.str("");
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       CHK_SQLITE(sqlite3_step(stmt), SQLITE_ROW);
-       lPos = sqlite3_column_int(stmt, 0);
-       rPos = sqlite3_column_int(stmt, 1);
-       width = rPos - lPos + 1;
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       sstream << "delete from [ModelRelation] where lPos between " << lPos << " and " << rPos << 
-               ";update [ModelRelation] set rPos = rPos - " << width << " where rPos > " << rPos << 
-               ";update [ModelRelation] set lPos = lPos - " << width << " where lPos > " << lPos << std::ends;
-       CHK_SSMRESULT(ExecuteSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "select dataId from [DataRelation] where modelId = " << modelId << ";" << std::ends;
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               dataIds.push_back(sqlite3_column_int(stmt, 0));
-       }
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       for(std::vector<int>::iterator itor = dataIds.begin();
-               itor != dataIds.end(); ++itor)
-       {
-               CHK_SSMRESULT(DeleteModelData(modelId, *itor));
-       }               
+    SSMRESULT       res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string     strSQL;
+    sqlite3_stmt    *stmt = NULL;
+    int             lPos = 0;
+    int             rPos = 0;
+    int             width = 0;
+    IntVec          dataIds;
+
+    sstream << "select lPos, rPos from [ModelRelation] where modelId = " << modelId << ";" << std::ends;
+
+    strSQL = sstream.str();
+    sstream.str("");
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    CHK_SQLITE(sqlite3_step(stmt), SQLITE_ROW);
+    lPos = sqlite3_column_int(stmt, 0);
+    rPos = sqlite3_column_int(stmt, 1);
+    width = rPos - lPos + 1;
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    sstream << "delete from [ModelRelation] where lPos between " << lPos << " and " << rPos <<
+        ";update [ModelRelation] set rPos = rPos - " << width << " where rPos > " << rPos <<
+        ";update [ModelRelation] set lPos = lPos - " << width << " where lPos > " << lPos << std::ends;
+    CHK_SSMRESULT(ExecuteSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "select dataId from [DataRelation] where modelId = " << modelId << ";" << std::ends;
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    while(sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        dataIds.push_back(sqlite3_column_int(stmt, 0));
+    }
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    for(std::vector<int>::iterator itor = dataIds.begin();
+        itor != dataIds.end(); ++itor)
+    {
+        CHK_SSMRESULT(DeleteModelData(modelId, *itor));
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 */
 SSMRESULT CEvaluationEngine::deleteModelData(IN int modelId, IN int dataId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string strSQL;
-       sqlite3_stmt *stmt = NULL;
-       int                             lPos = 0;
-       int                             rPos = 0;
-       int                             width = 0;
-
-       m_mtxDataRelation.lock();
-
-       sstream << "select lPos, rPos from [DataRelation] where modelId = " << modelId << " and dataId = " << dataId << ";" << std::ends;
-
-       strSQL = sstream.str();
-       sstream.str("");
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-       CHK_SQLITE(sqlite3_step(stmt), SQLITE_ROW);
-       lPos = sqlite3_column_int(stmt, 0);
-       rPos = sqlite3_column_int(stmt, 1);
-       width = rPos - lPos + 1;
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       sstream << "delete from [DataRelation] where lPos between " << lPos << " and " << rPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "update [DataRelation] set rPos = rPos - " << width << " where rPos > " << rPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "update [DataRelation] set lPos = lPos - " << width << " where lPos > " << lPos << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "delete from [ModelData" << modelId << "] where dataId = " << dataId << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string strSQL;
+    sqlite3_stmt *stmt = NULL;
+    int             lPos = 0;
+    int             rPos = 0;
+    int             width = 0;
+
+    m_mtxDataRelation.lock();
+
+    sstream << "select lPos, rPos from [DataRelation] where modelId = " << modelId << " and dataId = "
+            << dataId << ";" << std::ends;
+
+    strSQL = sstream.str();
+    sstream.str("");
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    CHK_SQLITE(sqlite3_step(stmt), SQLITE_ROW);
+    lPos = sqlite3_column_int(stmt, 0);
+    rPos = sqlite3_column_int(stmt, 1);
+    width = rPos - lPos + 1;
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    sstream << "delete from [DataRelation] where lPos between " << lPos << " and " << rPos << ";" <<
+            std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "update [DataRelation] set rPos = rPos - " << width << " where rPos > " << rPos << ";" <<
+            std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "update [DataRelation] set lPos = lPos - " << width << " where lPos > " << lPos << ";" <<
+            std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "delete from [ModelData" << modelId << "] where dataId = " << dataId << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
 
 CLEANUP:
-       m_mtxDataRelation.unlock();
-       return res;
+    m_mtxDataRelation.unlock();
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::getModelDataSet(IN int modelId, IN int startIndex, IN int count, OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex)
+SSMRESULT CEvaluationEngine::getModelDataSet(IN int modelId, IN int startIndex, IN int count,
+        OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string             strSQL;
-       int                             columnCount = 0;
-       sqlite3_stmt    *stmt = NULL;
-       const char              *textData = NULL;
-
-       sstream << "select * from [ModelData" << modelId << "] where dataId > " << startIndex << " limit " << count << ";"<< std::ends;
-
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-
-       *pLastIndex = 0;
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               ModelPropertyVec modelProperties;
-
-               columnCount = sqlite3_column_count(stmt);
-               for(int i=0; i < columnCount; i++)
-               {
-                       ModelProperty modelData;
-                       switch(sqlite3_column_type(stmt, i))
-                       {
-                       case SQLITE_INTEGER:
-                               modelData.propertyType = ModelProperty::TYPE_INTEGER;
-                               sstream.str("");
-                               sstream << sqlite3_column_int(stmt, i) << std::ends;
-                               modelData.propertyValue = sstream.str();
-                               break;
-
-                       case SQLITE_FLOAT:
-                               modelData.propertyType = ModelProperty::TYPE_REAL;
-                               sstream.str("");
-                               sstream << sqlite3_column_double(stmt, i) << std::ends;
-                               modelData.propertyValue = sstream.str();
-                               break;
-
-                       case SQLITE_BLOB:
-                       case SQLITE_TEXT:
-                               modelData.propertyType = ModelProperty::TYPE_TEXT;
-                               textData = (const char*)sqlite3_column_text(stmt, i);
-                               if(textData != NULL)
-                               {
-                                       modelData.propertyValue = textData;
-                               }
-                               break;
-
-                       default:
-                               modelData.propertyType = ModelProperty::TYPE_TEXT;
-                               textData = (const char*)sqlite3_column_text(stmt, i);
-                               if(textData != NULL)
-                               {
-                                       modelData.propertyValue = textData;
-                               }
-                               break;
-                       };
-                       modelProperties.push_back(modelData);
-               }
-
-               pDataSet->push_back(modelProperties);
-               *pLastIndex = sqlite3_column_int(stmt, 0);
-       }
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       res = SSM_S_OK;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string     strSQL;
+    int             columnCount = 0;
+    sqlite3_stmt    *stmt = NULL;
+    const char      *textData = NULL;
+
+    sstream << "select * from [ModelData" << modelId << "] where dataId > " << startIndex << " limit "
+            << count << ";" << std::ends;
+
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+
+    *pLastIndex = 0;
+    while (sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        ModelPropertyVec modelProperties;
+
+        columnCount = sqlite3_column_count(stmt);
+        for (int i = 0; i < columnCount; i++)
+        {
+            ModelProperty modelData;
+            switch (sqlite3_column_type(stmt, i))
+            {
+                case SQLITE_INTEGER:
+                    modelData.propertyType = ModelProperty::TYPE_INTEGER;
+                    sstream.str("");
+                    sstream << sqlite3_column_int(stmt, i) << std::ends;
+                    modelData.propertyValue = sstream.str();
+                    break;
+
+                case SQLITE_FLOAT:
+                    modelData.propertyType = ModelProperty::TYPE_REAL;
+                    sstream.str("");
+                    sstream << sqlite3_column_double(stmt, i) << std::ends;
+                    modelData.propertyValue = sstream.str();
+                    break;
+
+                case SQLITE_BLOB:
+                case SQLITE_TEXT:
+                    modelData.propertyType = ModelProperty::TYPE_TEXT;
+                    textData = (const char *)sqlite3_column_text(stmt, i);
+                    if (textData != NULL)
+                    {
+                        modelData.propertyValue = textData;
+                    }
+                    break;
+
+                default:
+                    modelData.propertyType = ModelProperty::TYPE_TEXT;
+                    textData = (const char *)sqlite3_column_text(stmt, i);
+                    if (textData != NULL)
+                    {
+                        modelData.propertyValue = textData;
+                    }
+                    break;
+            };
+            modelProperties.push_back(modelData);
+        }
+
+        pDataSet->push_back(modelProperties);
+        *pLastIndex = sqlite3_column_int(stmt, 0);
+    }
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::getModelData(IN int modelId, IN int dataId, OUT ModelPropertyVec *pModelProperties)
+SSMRESULT CEvaluationEngine::getModelData(IN int modelId, IN int dataId,
+        OUT ModelPropertyVec *pModelProperties)
 {
-       SSMRESULT               res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string             strSQL;
-       int                             columnCount = 0;
-       sqlite3_stmt    *stmt = NULL;
-       const char              *textData = NULL;
-
-       sstream << "select * from [ModelData" << modelId << "] where dataId=" << dataId << ";" << std::ends;
-
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               columnCount = sqlite3_column_count(stmt);
-               for(int i=0; i < columnCount; i++)
-               {
-                       ModelProperty modelData;
-                       switch(sqlite3_column_type(stmt, i))
-                       {
-                       case SQLITE_INTEGER:
-                               modelData.propertyType = ModelProperty::TYPE_INTEGER;
-                               sstream.str("");
-                               sstream << sqlite3_column_int(stmt, i) << std::ends;
-                               modelData.propertyValue = sstream.str();
-                               break;
-
-                       case SQLITE_FLOAT:
-                               modelData.propertyType = ModelProperty::TYPE_REAL;
-                               sstream.str("");
-                               sstream << sqlite3_column_double(stmt, i) << std::ends;
-                               modelData.propertyValue = sstream.str();
-                               break;
-
-                       case SQLITE_BLOB:
-                       case SQLITE_TEXT:
-                               modelData.propertyType = ModelProperty::TYPE_TEXT;
-                               textData = (const char*)sqlite3_column_text(stmt, i);
-                               if(textData != NULL)
-                               {
-                                       modelData.propertyValue = textData;
-                               }
-                               break;
-
-                       default:
-                               modelData.propertyType = ModelProperty::TYPE_TEXT;
-                               textData = (const char*)sqlite3_column_text(stmt, i);
-                               if(textData != NULL)
-                               {
-                                       modelData.propertyValue = textData;
-                               }
-                               break;
-                       };
-                       pModelProperties->push_back(modelData);
-               }
-       }
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       res = SSM_S_OK;
+    SSMRESULT       res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string     strSQL;
+    int             columnCount = 0;
+    sqlite3_stmt    *stmt = NULL;
+    const char      *textData = NULL;
+
+    sstream << "select * from [ModelData" << modelId << "] where dataId=" << dataId << ";" << std::ends;
+
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+
+    while (sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        columnCount = sqlite3_column_count(stmt);
+        for (int i = 0; i < columnCount; i++)
+        {
+            ModelProperty modelData;
+            switch (sqlite3_column_type(stmt, i))
+            {
+                case SQLITE_INTEGER:
+                    modelData.propertyType = ModelProperty::TYPE_INTEGER;
+                    sstream.str("");
+                    sstream << sqlite3_column_int(stmt, i) << std::ends;
+                    modelData.propertyValue = sstream.str();
+                    break;
+
+                case SQLITE_FLOAT:
+                    modelData.propertyType = ModelProperty::TYPE_REAL;
+                    sstream.str("");
+                    sstream << sqlite3_column_double(stmt, i) << std::ends;
+                    modelData.propertyValue = sstream.str();
+                    break;
+
+                case SQLITE_BLOB:
+                case SQLITE_TEXT:
+                    modelData.propertyType = ModelProperty::TYPE_TEXT;
+                    textData = (const char *)sqlite3_column_text(stmt, i);
+                    if (textData != NULL)
+                    {
+                        modelData.propertyValue = textData;
+                    }
+                    break;
+
+                default:
+                    modelData.propertyType = ModelProperty::TYPE_TEXT;
+                    textData = (const char *)sqlite3_column_text(stmt, i);
+                    if (textData != NULL)
+                    {
+                        modelData.propertyValue = textData;
+                    }
+                    break;
+            };
+            pModelProperties->push_back(modelData);
+        }
+    }
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 /*
 SSMRESULT CEvaluationEngine::GetModelSchema(IN int modelId, OUT ModelPropertyVec *pModelProperties)
 {
-       SSMRESULT               res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string             strSQL;
-       sqlite3_stmt    *stmt = NULL;
-       std::string             propertyType;
-
-       sstream << "pragma table_info('ModelData" << modelId << "');" << std::ends;
-
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               ModelProperty modelData;
-               modelData.propertyName = (const char*)sqlite3_column_text(stmt, 1);
-               propertyType = (const char*)sqlite3_column_text(stmt, 2);
-
-               if(propertyType == "integer")
-               {
-                       modelData.propertyType = ModelProperty::Type_INTEGER;
-               }
-               else if(propertyType == "int")
-               {
-                       modelData.propertyType = ModelProperty::Type_INTEGER;
-               }
-               else if(propertyType == "real")
-               {
-                       modelData.propertyType = ModelProperty::Type_REAL;
-               }
-               else if(propertyType == "text")
-               {
-                       modelData.propertyType = ModelProperty::Type_TEXT;
-               }
-               else
-               {
-                       modelData.propertyType = ModelProperty::Type_TEXT;
-               }
-               pModelProperties->push_back(modelData);
-       }
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       res = SSM_S_OK;
+    SSMRESULT       res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string     strSQL;
+    sqlite3_stmt    *stmt = NULL;
+    std::string     propertyType;
+
+    sstream << "pragma table_info('ModelData" << modelId << "');" << std::ends;
+
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+
+    while(sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        ModelProperty modelData;
+        modelData.propertyName = (const char*)sqlite3_column_text(stmt, 1);
+        propertyType = (const char*)sqlite3_column_text(stmt, 2);
+
+        if(propertyType == "integer")
+        {
+            modelData.propertyType = ModelProperty::Type_INTEGER;
+        }
+        else if(propertyType == "int")
+        {
+            modelData.propertyType = ModelProperty::Type_INTEGER;
+        }
+        else if(propertyType == "real")
+        {
+            modelData.propertyType = ModelProperty::Type_REAL;
+        }
+        else if(propertyType == "text")
+        {
+            modelData.propertyType = ModelProperty::Type_TEXT;
+        }
+        else
+        {
+            modelData.propertyType = ModelProperty::Type_TEXT;
+        }
+        pModelProperties->push_back(modelData);
+    }
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 */
-SSMRESULT CEvaluationEngine::getConditionedModelData(IN int modelId, IN ModelConditionVec *pModelConditions, OUT IntVec *pDataIds)
+SSMRESULT CEvaluationEngine::getConditionedModelData(IN int modelId,
+        IN ModelConditionVec *pModelConditions, OUT IntVec *pDataIds)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string strSQL;
-       sqlite3_stmt *stmt = NULL;
-
-       sstream << "select dataId from [ModelData" << modelId << 
-               "] where CURRENT_TIMESTAMP < datetime( strftime('%s', lastTime) + lifetime, 'unixepoch') and ";
-
-       for(ModelConditionVec::iterator itor = pModelConditions->begin();
-               itor != pModelConditions->end(); ++itor)
-       {
-               sstream << itor->modelProperty.propertyName;
-               switch(itor->predicate)
-               {
-               case ModelCondition::PREDICATE_EQ:
-                       sstream << "=";
-                       break;
-
-               case ModelCondition::PREDICATE_NEQ:
-                       sstream << "!=";
-                       break;
-
-               case ModelCondition::PREDICATE_GT:
-                       sstream << ">";
-                       break;
-
-               case ModelCondition::PREDICATE_LT:
-                       sstream << "<";
-                       break;
-
-               case ModelCondition::PREDICATE_GTE:
-                       sstream << ">=";
-                       break;
-
-               case ModelCondition::PREDICATE_LTE:
-                       sstream << "<=";
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-
-               switch(itor->modelProperty.propertyType)
-               {
-               case ModelProperty::TYPE_NUMERIC:
-               case ModelProperty::TYPE_INTEGER:
-               case ModelProperty::TYPE_REAL:
-                       sstream << itor->modelProperty.propertyValue;
-                       break;
-
-               case ModelProperty::TYPE_TEXT:
-                       sstream << "'" << itor->modelProperty.propertyValue << "'";
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-
-               if(itor < pModelConditions->end() - 1)
-               {
-                       sstream << " and ";
-               }
-       }
-
-       sstream << ";" << std::ends;
-
-       strSQL = sstream.str();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               pDataIds->push_back(sqlite3_column_int(stmt, 0));
-       }
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       res = SSM_S_OK;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string strSQL;
+    sqlite3_stmt *stmt = NULL;
+
+    sstream << "select dataId from [ModelData" << modelId <<
+            "] where CURRENT_TIMESTAMP < datetime( strftime('%s', lastTime) + lifetime, 'unixepoch') and ";
+
+    for (ModelConditionVec::iterator itor = pModelConditions->begin();
+         itor != pModelConditions->end(); ++itor)
+    {
+        sstream << itor->modelProperty.propertyName;
+        switch (itor->predicate)
+        {
+            case ModelCondition::PREDICATE_EQ:
+                sstream << "=";
+                break;
+
+            case ModelCondition::PREDICATE_NEQ:
+                sstream << "!=";
+                break;
+
+            case ModelCondition::PREDICATE_GT:
+                sstream << ">";
+                break;
+
+            case ModelCondition::PREDICATE_LT:
+                sstream << "<";
+                break;
+
+            case ModelCondition::PREDICATE_GTE:
+                sstream << ">=";
+                break;
+
+            case ModelCondition::PREDICATE_LTE:
+                sstream << "<=";
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+
+        switch (itor->modelProperty.propertyType)
+        {
+            case ModelProperty::TYPE_NUMERIC:
+            case ModelProperty::TYPE_INTEGER:
+            case ModelProperty::TYPE_REAL:
+                sstream << itor->modelProperty.propertyValue;
+                break;
+
+            case ModelProperty::TYPE_TEXT:
+                sstream << "'" << itor->modelProperty.propertyValue << "'";
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+
+        if (itor < pModelConditions->end() - 1)
+        {
+            sstream << " and ";
+        }
+    }
+
+    sstream << ";" << std::ends;
+
+    strSQL = sstream.str();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+
+    while (sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        pDataIds->push_back(sqlite3_column_int(stmt, 0));
+    }
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions, IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId)
+SSMRESULT CEvaluationEngine::watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
+        IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::stringstream sstreamCondition;
-
-       for(ModelConditionVec::iterator itor = pModelConditions->begin();
-               itor != pModelConditions->end(); ++itor)
-       {                       
-               sstreamCondition << "NEW." << itor->modelProperty.propertyName;
-               switch(itor->predicate)
-               {
-               case ModelCondition::PREDICATE_EQ:
-                       sstreamCondition << "=";
-                       break;
-
-               case ModelCondition::PREDICATE_NEQ:
-                       sstreamCondition << "!=";
-                       break;
-
-               case ModelCondition::PREDICATE_GT:
-                       sstreamCondition << ">";
-                       break;
-
-               case ModelCondition::PREDICATE_LT:
-                       sstreamCondition << "<";
-                       break;
-
-               case ModelCondition::PREDICATE_GTE:
-                       sstreamCondition << ">=";
-                       break;
-
-               case ModelCondition::PREDICATE_LTE:
-                       sstreamCondition << "<=";
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-
-               switch(itor->modelProperty.propertyType)
-               {
-               case ModelProperty::TYPE_NUMERIC:
-               case ModelProperty::TYPE_INTEGER:
-               case ModelProperty::TYPE_REAL:
-                       sstreamCondition << itor->modelProperty.propertyValue;
-                       break;
-
-               case ModelProperty::TYPE_TEXT:
-                       sstreamCondition << "'" << itor->modelProperty.propertyValue << "'";
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-
-               if(itor < pModelConditions->end() - 1)
-               {
-                       sstreamCondition << " and ";
-               }
-       }
-
-       sstreamCondition << std::ends;
-
-       m_mtxDataRelation.lock();
-
-       sstream << "CREATE TRIGGER WatchInsertModel" << m_iTriggerId << " AFTER INSERT ON [ModelData" << modelId << "] WHEN ";
-       sstream << sstreamCondition.str().c_str() << " BEGIN SELECT OnSQLTrigger("<< (int)this << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;           
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
-
-       sstream << "CREATE TRIGGER WatchUpdateModel" << m_iTriggerId << " AFTER UPDATE ON [ModelData" << modelId << "] WHEN ";
-       sstream << sstreamCondition.str().c_str() << " BEGIN SELECT OnSQLTrigger("<< (int)this << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;           
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-
-       m_mtxTriggerId.lock();
-       pEvaluationEngineEvent->addRef();
-       m_mapTriggers[m_iTriggerId] = pEvaluationEngineEvent;
-       *pTriggerId = m_iTriggerId++;   
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::stringstream sstreamCondition;
+
+    for (ModelConditionVec::iterator itor = pModelConditions->begin();
+         itor != pModelConditions->end(); ++itor)
+    {
+        sstreamCondition << "NEW." << itor->modelProperty.propertyName;
+        switch (itor->predicate)
+        {
+            case ModelCondition::PREDICATE_EQ:
+                sstreamCondition << "=";
+                break;
+
+            case ModelCondition::PREDICATE_NEQ:
+                sstreamCondition << "!=";
+                break;
+
+            case ModelCondition::PREDICATE_GT:
+                sstreamCondition << ">";
+                break;
+
+            case ModelCondition::PREDICATE_LT:
+                sstreamCondition << "<";
+                break;
+
+            case ModelCondition::PREDICATE_GTE:
+                sstreamCondition << ">=";
+                break;
+
+            case ModelCondition::PREDICATE_LTE:
+                sstreamCondition << "<=";
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+
+        switch (itor->modelProperty.propertyType)
+        {
+            case ModelProperty::TYPE_NUMERIC:
+            case ModelProperty::TYPE_INTEGER:
+            case ModelProperty::TYPE_REAL:
+                sstreamCondition << itor->modelProperty.propertyValue;
+                break;
+
+            case ModelProperty::TYPE_TEXT:
+                sstreamCondition << "'" << itor->modelProperty.propertyValue << "'";
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+
+        if (itor < pModelConditions->end() - 1)
+        {
+            sstreamCondition << " and ";
+        }
+    }
+
+    sstreamCondition << std::ends;
+
+    m_mtxDataRelation.lock();
+
+    sstream << "CREATE TRIGGER WatchInsertModel" << m_iTriggerId << " AFTER INSERT ON [ModelData" <<
+            modelId << "] WHEN ";
+    sstream << sstreamCondition.str().c_str() << " BEGIN SELECT OnSQLTrigger(" <<
+            (int)this << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
+
+    sstream << "CREATE TRIGGER WatchUpdateModel" << m_iTriggerId << " AFTER UPDATE ON [ModelData" <<
+            modelId << "] WHEN ";
+    sstream << sstreamCondition.str().c_str() << " BEGIN SELECT OnSQLTrigger(" <<
+            (int)this << ", " << m_iTriggerId << ", NEW.dataId); END;" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+
+    m_mtxTriggerId.lock();
+    pEvaluationEngineEvent->addRef();
+    m_mapTriggers[m_iTriggerId] = pEvaluationEngineEvent;
+    *pTriggerId = m_iTriggerId++;
 
 CLEANUP:
-       m_mtxTriggerId.unlock();
-       m_mtxDataRelation.unlock();
-       return res;
+    m_mtxTriggerId.unlock();
+    m_mtxDataRelation.unlock();
+    return res;
 }
 
 SSMRESULT CEvaluationEngine::dropWatchModelData(IN int triggerId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
 
-       m_mtxDataRelation.lock();
+    m_mtxDataRelation.lock();
 
-       sstream << "drop trigger WatchInsertModel" << triggerId << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
-       sstream.str("");
+    sstream << "drop trigger WatchInsertModel" << triggerId << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream.str("");
 
-       sstream << "drop trigger WatchUpdateModel" << triggerId << ";" << std::ends;
-       SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
+    sstream << "drop trigger WatchUpdateModel" << triggerId << ";" << std::ends;
+    SSM_CLEANUP_ASSERT(executeSQL_NoReturn(sstream.str()));
 
-       m_mtxTriggerId.lock();
-       m_mapTriggers[triggerId]->release();
-       m_mapTriggers.erase(triggerId);
+    m_mtxTriggerId.lock();
+    m_mapTriggers[triggerId]->release();
+    m_mapTriggers.erase(triggerId);
 
 CLEANUP:
-       m_mtxTriggerId.unlock();
-       m_mtxDataRelation.unlock();
-       return res;
+    m_mtxTriggerId.unlock();
+    m_mtxDataRelation.unlock();
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::getParentDataId(IN int modelId, IN int dataId, IN int parentModelId, OUT int *pParentDataId)
+SSMRESULT CEvaluationEngine::getParentDataId(IN int modelId, IN int dataId, IN int parentModelId,
+        OUT int *pParentDataId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       
-       sstream << "select parent.dataId from [DataRelation] as node, [DataRelation] as parent where parent.modelId=" <<
-               parentModelId << " and node.modelId=" << modelId << " and node.dataId=" << 
-               dataId <<" and node.lPos between parent.lPos and parent.rPos;" << std::ends;
-       
-       m_mtxDataRelation.lock();
-       SSM_CLEANUP_ASSERT(executeSQL_IntReturn(sstream.str(), pParentDataId));
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+
+    sstream <<
+            "select parent.dataId from [DataRelation] as node, [DataRelation] as parent where parent.modelId="
+            <<
+            parentModelId << " and node.modelId=" << modelId << " and node.dataId=" <<
+            dataId << " and node.lPos between parent.lPos and parent.rPos;" << std::ends;
+
+    m_mtxDataRelation.lock();
+    SSM_CLEANUP_ASSERT(executeSQL_IntReturn(sstream.str(), pParentDataId));
 
 CLEANUP:
-       m_mtxDataRelation.unlock();
-       return res;
+    m_mtxDataRelation.unlock();
+    return res;
 }
 
-SSMRESULT CEvaluationEngine::getChildDataId(IN int modelId, IN int dataId, IN int ChildModelId, OUT IntVec *pChildDataIds)
+SSMRESULT CEvaluationEngine::getChildDataId(IN int modelId, IN int dataId, IN int ChildModelId,
+        OUT IntVec *pChildDataIds)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string strSQL;
-       sqlite3_stmt *stmt = NULL;
-
-       sstream << "select child.dataId from [DataRelation] as node, [DataRelation] as child where child.modelId=" <<
-               ChildModelId << " and node.modelId=" << modelId << " and node.dataId=" << 
-               dataId <<" and child.lPos between node.lPos and node.rPos order by child.dataId;" << std::ends;
-       
-       strSQL = sstream.str();
-       sstream.str("");
-
-       m_mtxDataRelation.lock();
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               pChildDataIds->push_back(sqlite3_column_int(stmt, 0));
-       }
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-       res = SSM_S_OK;
-       
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string strSQL;
+    sqlite3_stmt *stmt = NULL;
+
+    sstream <<
+            "select child.dataId from [DataRelation] as node, [DataRelation] as child where child.modelId=" <<
+            ChildModelId << " and node.modelId=" << modelId << " and node.dataId=" <<
+            dataId << " and child.lPos between node.lPos and node.rPos order by child.dataId;" << std::ends;
+
+    strSQL = sstream.str();
+    sstream.str("");
+
+    m_mtxDataRelation.lock();
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+
+    while (sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        pChildDataIds->push_back(sqlite3_column_int(stmt, 0));
+    }
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    res = SSM_S_OK;
+
 CLEANUP:
-       m_mtxDataRelation.unlock();
-       return res;
+    m_mtxDataRelation.unlock();
+    return res;
 }
 /*
 SSMRESULT CEvaluationEngine::GetPathToRoot(IN int currentModelId, OUT IntVec *pPath)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string strSQL;
-       sqlite3_stmt *stmt = NULL;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string strSQL;
+    sqlite3_stmt *stmt = NULL;
 
-       sstream << "select parent.modelId from [ModelRelation] as node, [ModelRelation] as parent where " << 
-               "node.lPos between parent.lPos and parent.rPos and node.modelId = " << currentModelId << " order by node.lPos;" << std::ends;
+    sstream << "select parent.modelId from [ModelRelation] as node, [ModelRelation] as parent where " <<
+        "node.lPos between parent.lPos and parent.rPos and node.modelId = " << currentModelId << " order by node.lPos;" << std::ends;
 
-       strSQL = sstream.str();
-       sstream.str("");
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    strSQL = sstream.str();
+    sstream.str("");
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
 
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               pPath->push_back(sqlite3_column_int(stmt, 0));
-       }
+    while(sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        pPath->push_back(sqlite3_column_int(stmt, 0));
+    }
 
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CEvaluationEngine::GetModelId(IN const char *modelName, OUT int *pModelId)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
 
-       sstream << "select modelId from [ModelRelation] where modelName = '" << modelName << "';" << std::ends;
+    sstream << "select modelId from [ModelRelation] where modelName = '" << modelName << "';" << std::ends;
 
-       CHK_SSMRESULT(ExecuteSQL_IntReturn(sstream.str(), pModelId));
+    CHK_SSMRESULT(ExecuteSQL_IntReturn(sstream.str(), pModelId));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CEvaluationEngine::GetModelHierarchy(IN int rootModelId, OUT StringVec *pPath)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string strSQL;
-       sqlite3_stmt *stmt = NULL;
-       StringVec       lastModels;
-       int                     currIndex = 0;
-       int                     lastIndex = 0;          
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string strSQL;
+    sqlite3_stmt *stmt = NULL;
+    StringVec   lastModels;
+    int         currIndex = 0;
+    int         lastIndex = 0;
 
-       sstream << "select node.modelName, (COUNT(parent.modelName) - (sub_tree.depth + 1)) as depth from [ModelRelation] as node, "\
-               "[ModelRelation] as parent, [ModelRelation] as sub_parent, (select node.modelName, (count(parent.modelName) - 1) as depth from "\
-               "[ModelRelation] as node, [ModelRelation] as parent where node.lPos between parent.lPos and parent.rPos and node.modelId = " << rootModelId << 
-               " group by node.lPos, node.modelName) as sub_tree where node.lPos between parent.lPos and parent.rPos and node.lPos between "<<
-               "sub_parent.lPos and sub_parent.rPos and sub_parent.modelName = sub_tree.modelName group by node.lPos, node.modelName, sub_tree.depth " << 
-               "order by node.lPos;" << std::ends;
+    sstream << "select node.modelName, (COUNT(parent.modelName) - (sub_tree.depth + 1)) as depth from [ModelRelation] as node, "\
+        "[ModelRelation] as parent, [ModelRelation] as sub_parent, (select node.modelName, (count(parent.modelName) - 1) as depth from "\
+        "[ModelRelation] as node, [ModelRelation] as parent where node.lPos between parent.lPos and parent.rPos and node.modelId = " << rootModelId <<
+        " group by node.lPos, node.modelName) as sub_tree where node.lPos between parent.lPos and parent.rPos and node.lPos between "<<
+        "sub_parent.lPos and sub_parent.rPos and sub_parent.modelName = sub_tree.modelName group by node.lPos, node.modelName, sub_tree.depth " <<
+        "order by node.lPos;" << std::ends;
 
-       strSQL = sstream.str();
-       sstream.str("");
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+    strSQL = sstream.str();
+    sstream.str("");
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
 
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               currIndex = sqlite3_column_int(stmt, 1);
+    while(sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        currIndex = sqlite3_column_int(stmt, 1);
 
-               if(currIndex < lastIndex)
+        if(currIndex < lastIndex)
 
-               {
-                       for(int i=0; i < lastIndex - currIndex + 1; i++)
-                       {
-                               lastModels.pop_back();
-                       }
-               }
+        {
+            for(int i=0; i < lastIndex - currIndex + 1; i++)
+            {
+                lastModels.pop_back();
+            }
+        }
 
-               lastModels.push_back((const char*)sqlite3_column_text(stmt, 0));
+        lastModels.push_back((const char*)sqlite3_column_text(stmt, 0));
 
-               for(StringVec::iterator itor = lastModels.begin();
-                       itor != lastModels.end(); ++itor)
-               {
-                       sstream << *itor;
+        for(StringVec::iterator itor = lastModels.begin();
+            itor != lastModels.end(); ++itor)
+        {
+            sstream << *itor;
 
-                       if(itor < lastModels.end() - 1)
-                       {
-                               sstream << ".";
-                       }
-               }
+            if(itor < lastModels.end() - 1)
+            {
+                sstream << ".";
+            }
+        }
 
-               sstream << std::ends;
+        sstream << std::ends;
 
-               pPath->push_back(sstream.str());
+        pPath->push_back(sstream.str());
 
-               sstream.str("");
+        sstream.str("");
 
-               lastIndex = currIndex;
-       }
+        lastIndex = currIndex;
+    }
 
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CEvaluationEngine::GetDataHierarchy(IN int rootModelId, IN int dataId, OUT StringVec *pPath)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::stringstream sstream;
-       std::string strSQL;
-       sqlite3_stmt *stmt = NULL;
-
-       sstream << "select [ModelRelation].modelName, node.dataId, (COUNT(parent.modelId) - (sub_tree.depth + 1)) as depth "\
-               "from [ModelRelation], [DataRelation] as node, [DataRelation] as parent, [DataRelation] as sub_parent, "\
-               "(select node.modelId, (count(parent.modelId) - 1) as depth from [DataRelation] as node, [DataRelation] as parent "\
-               "where node.lPos between parent.lPos and parent.rPos and node.modelId = " << rootModelId << 
-               " and node.dataId = " << dataId << " group by node.lPos, node.modelId) as sub_tree "\
-               "where node.lPos between parent.lPos and parent.rPos and node.lPos between sub_parent.lPos and sub_parent.rPos and "\
-               "sub_parent.modelId = sub_tree.modelId and [ModelRelation].modelId = node.modelId "\
-               "group by node.lPos, [ModelRelation].modelName, node.dataId, sub_tree.depth order by node.lPos;" << std::ends;
-
-       strSQL = sstream.str();
-       sstream.str("");
-       CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
-
-       while(sqlite3_step(stmt) == SQLITE_ROW)
-       {
-               sstream << sqlite3_column_text(stmt, 0) << " " << sqlite3_column_int(stmt, 1) << " " << sqlite3_column_int(stmt, 2) << std::ends;
-               pPath->push_back(sstream.str());
-               sstream.str("");
-       }
-
-       CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
-
-       res = SSM_S_OK;
+    SSMRESULT res = SSM_E_FAIL;
+    std::stringstream sstream;
+    std::string strSQL;
+    sqlite3_stmt *stmt = NULL;
+
+    sstream << "select [ModelRelation].modelName, node.dataId, (COUNT(parent.modelId) - (sub_tree.depth + 1)) as depth "\
+        "from [ModelRelation], [DataRelation] as node, [DataRelation] as parent, [DataRelation] as sub_parent, "\
+        "(select node.modelId, (count(parent.modelId) - 1) as depth from [DataRelation] as node, [DataRelation] as parent "\
+        "where node.lPos between parent.lPos and parent.rPos and node.modelId = " << rootModelId <<
+        " and node.dataId = " << dataId << " group by node.lPos, node.modelId) as sub_tree "\
+        "where node.lPos between parent.lPos and parent.rPos and node.lPos between sub_parent.lPos and sub_parent.rPos and "\
+        "sub_parent.modelId = sub_tree.modelId and [ModelRelation].modelId = node.modelId "\
+        "group by node.lPos, [ModelRelation].modelName, node.dataId, sub_tree.depth order by node.lPos;" << std::ends;
+
+    strSQL = sstream.str();
+    sstream.str("");
+    CHK_SQLITE(sqlite3_prepare_v2(m_pSQLite3, strSQL.c_str(), strSQL.length(), &stmt, NULL), SQLITE_OK);
+
+    while(sqlite3_step(stmt) == SQLITE_ROW)
+    {
+        sstream << sqlite3_column_text(stmt, 0) << " " << sqlite3_column_int(stmt, 1) << " " << sqlite3_column_int(stmt, 2) << std::ends;
+        pPath->push_back(sstream.str());
+        sstream.str("");
+    }
+
+    CHK_SQLITE(sqlite3_finalize(stmt), SQLITE_OK);
+
+    res = SSM_S_OK;
 CLEANUP:
-       return res;
+    return res;
 }
 */
index 768010a..03da0bf 100644 (file)
 /**
 * @class    CEvaluationEngine
 * @brief    CEvaluationEngine Interface
-*                       This class represents Evaluation Engine
+*            This class represents Evaluation Engine
 *
 * @see
 */
 class CEvaluationEngine :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IEvaluationEngine
-       , public IThreadClient
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IEvaluationEngine
+    , public IThreadClient
 {
-private:
-       sqlite3                         *m_pSQLite3;
-       int                                     m_iTriggerId;
-       CSimpleMutex            m_mtxTriggerId;
-       std::map<int, IEvaluationEngineEvent*>  m_mapTriggers;
-       CSimpleMutex            m_mtxDataRelation;
-       CObjectPtr<ITasker>     m_pTasker;
-
-       SSMRESULT executeSQL_NoReturn(IN std::string strSQL);
-
-       SSMRESULT executeSQL_IntReturn(IN std::string strSQL, OUT int *pResult);
-
-       static void onSQLTrigger(IN sqlite3_context *context, IN int argc, IN sqlite3_value **argv);
-
-       SSMRESULT initializeEngine();
-
-       void terminateEngine();
-
-public:
-       SSMRESULT finalConstruct();
-
-       void finalRelease();
-
-       void onExecute(IN void* pArg);
-
-       void onTerminate(IN void* pArg);
-
-       /**
-       * @fn     onWatcherTriggered
-       * @brief Called when newly added data meets the conditions 
-       *
-       * @param [in] int triggerId - Trigger id, which condition is triggered
-       * @param [in] int dataId - Data id, which data meets the conditions
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT onWatcherTriggered(IN int triggerId, IN int dataId);
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IEvaluationEngine))
-               {
-                       IBase *pBase = (IEvaluationEngine*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn     createModel
-       * @brief Create new context model
-       *
-       * @param [in] int parentModelId - Parent Context Model id that related to Model hierarchy.
-       * @param [in] const char *newModelName - Represent model's name
-       * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
-       * @param [out] int *pModelId - Created model's id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT createModel(IN int parentModelId, IN const char *newModelName, IN ModelPropertyVec *pModelDescs, OUT int *pModelId);
-
-       /**
-       * @fn     addModelData
-       * @brief Add model data to Context Model
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int parentModelId - parent model id that created CreateModel's execution.
-       * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
-       * @param [in] ModelPropertyVec *pData - Packed data for adding
-       * @param [out] int *pDataId - Returned dataId that newly added
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT addModelData(IN int modelId, IN int parentModelId, IN int parentDataId, IN ModelPropertyVec *pModelValues, OUT int *pDataId);
-
-       /**
-       * @fn     updateModelData
-       * @brief Update model data to Context Model 
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [in] ModelPropertyVec *pData - Packed data for updating
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT updateModelData(IN int modelId, IN int dataId, IN ModelPropertyVec *pModelValues);
-
-       //SSMRESULT DeleteModel(IN int modelId);
-
-       /**
-       * @fn     deleteModelData
-       * @brief Delete model data using given index
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT deleteModelData(IN int modelId, IN int dataId);
-
-       /**
-       * @fn     getModelData
-       * @brief Get model data
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that provided AddModelData's execution
-       * @param [out] ModelPropertyVec *pData - Packed data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getModelData(IN int modelId, IN int dataId, OUT ModelPropertyVec *pModelProperties);
-
-       /**
-       * @fn     getModelDataSet
-       * @brief Get model data set
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int startIndex - Starting index of model data
-       * @param [in] int count - Number of data to retrieve
-       * @param [out] vector<ModelPropertyVec> *pDataSet - Packed data
-       * @param [out] int *pLastIndex - Index of last data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getModelDataSet(IN int modelId, IN int startIndex, IN int count, OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex);
-
-       //SSMRESULT GetModelSchema(IN int modelId, OUT ModelPropertyVec *pModelProperties);
-
-       /**
-       * @fn     getConditionedModelData
-       * @brief Get affected data from given conditions
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
-       * @param [out] IntVec   *pDataIds - Searched dataId sets.
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT getConditionedModelData(IN int modelId, IN ModelConditionVec *pModelConditions, OUT IntVec *pDataIds);
-
-       /**
-       * @fn     watchModelData
-       * @brief Watching data from given conditions
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] ModelConditionVec *pModelConditions - Conditions for data triggering
-       * @param [in] IEvaluationEngineEvent *pEvaluationEngineEvent - Event interface where triggered event listening
-       * @param [out] int *pTriggerId - Identifier which trigger is activated
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions, IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId);
-
-       /**
-       * @fn     dropWatchModelData
-       * @brief Stop watching data
-       *
-       * @param [in] int triggerId - Identifier which trigger to drop
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT dropWatchModelData(IN int triggerId);
-
-       /**
-       * @fn     getParentDataId
-       * @brief Get parent dataId related to model hierarchy
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] int parentModelId - Designated parent Context Model's id
-       * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getParentDataId(IN int modelId, IN int dataId, IN int parentModelId, OUT int *pParentDataId);
-
-       /**
-       * @fn     getChildDataId
-       * @brief Get child dataId related to model hierarchy
-       *
-       * @param [in] int modelId - model id that created CreateModel's execution.
-       * @param [in] int dataId - DataId that current model's
-       * @param [in] int childModelId - Designated child Context Model's id
-       * @param [out] IntVec *pChildDataIds - Designated child Context Model's data's Id
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getChildDataId(IN int modelId, IN int dataId, IN int childModelId, OUT IntVec *pChildDataIds);
-
-       //SSMRESULT GetPathToRoot(IN int currentModelId, OUT IntVec *pPath);
-
-       //SSMRESULT GetModelId(IN const char *modelName, OUT int *pModelId);
-
-       //SSMRESULT GetModelHierarchy(IN int rootModelId, OUT StringVec *pPath);
-
-       //SSMRESULT GetDataHierarchy(IN int rootModelId, IN int dataId, OUT StringVec *pPath);
+    private:
+        sqlite3             *m_pSQLite3;
+        int                 m_iTriggerId;
+        CSimpleMutex        m_mtxTriggerId;
+        std::map<int, IEvaluationEngineEvent *>  m_mapTriggers;
+        CSimpleMutex        m_mtxDataRelation;
+        CObjectPtr<ITasker> m_pTasker;
+
+        SSMRESULT executeSQL_NoReturn(IN std::string strSQL);
+
+        SSMRESULT executeSQL_IntReturn(IN std::string strSQL, OUT int *pResult);
+
+        static void onSQLTrigger(IN sqlite3_context *context, IN int argc, IN sqlite3_value **argv);
+
+        SSMRESULT initializeEngine();
+
+        void terminateEngine();
+
+    public:
+        SSMRESULT finalConstruct();
+
+        void finalRelease();
+
+        void onExecute(IN void *pArg);
+
+        void onTerminate(IN void *pArg);
+
+        /**
+        * @fn     onWatcherTriggered
+        * @brief Called when newly added data meets the conditions
+        *
+        * @param [in] int triggerId - Trigger id, which condition is triggered
+        * @param [in] int dataId - Data id, which data meets the conditions
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT onWatcherTriggered(IN int triggerId, IN int dataId);
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IEvaluationEngine))
+            {
+                IBase *pBase = (IEvaluationEngine *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn     createModel
+        * @brief Create new context model
+        *
+        * @param [in] int parentModelId - Parent Context Model id that related to Model hierarchy.
+        * @param [in] const char *newModelName - Represent model's name
+        * @param [in] ModelPropertyVec *pModelProperties - Represent model's properties that exposed to CQL
+        * @param [out] int *pModelId - Created model's id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT createModel(IN int parentModelId, IN const char *newModelName,
+                              IN ModelPropertyVec *pModelDescs, OUT int *pModelId);
+
+        /**
+        * @fn     addModelData
+        * @brief Add model data to Context Model
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int parentModelId - parent model id that created CreateModel's execution.
+        * @param [in] int parentDataId - Specify current model's parent Context Model's dataId
+        * @param [in] ModelPropertyVec *pData - Packed data for adding
+        * @param [out] int *pDataId - Returned dataId that newly added
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT addModelData(IN int modelId, IN int parentModelId, IN int parentDataId,
+                               IN ModelPropertyVec *pModelValues, OUT int *pDataId);
+
+        /**
+        * @fn     updateModelData
+        * @brief Update model data to Context Model
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [in] ModelPropertyVec *pData - Packed data for updating
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT updateModelData(IN int modelId, IN int dataId, IN ModelPropertyVec *pModelValues);
+
+        //SSMRESULT DeleteModel(IN int modelId);
+
+        /**
+        * @fn     deleteModelData
+        * @brief Delete model data using given index
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT deleteModelData(IN int modelId, IN int dataId);
+
+        /**
+        * @fn     getModelData
+        * @brief Get model data
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that provided AddModelData's execution
+        * @param [out] ModelPropertyVec *pData - Packed data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getModelData(IN int modelId, IN int dataId, OUT ModelPropertyVec *pModelProperties);
+
+        /**
+        * @fn     getModelDataSet
+        * @brief Get model data set
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int startIndex - Starting index of model data
+        * @param [in] int count - Number of data to retrieve
+        * @param [out] vector<ModelPropertyVec> *pDataSet - Packed data
+        * @param [out] int *pLastIndex - Index of last data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getModelDataSet(IN int modelId, IN int startIndex, IN int count,
+                                  OUT std::vector<ModelPropertyVec> *pDataSet, OUT int *pLastIndex);
+
+        //SSMRESULT GetModelSchema(IN int modelId, OUT ModelPropertyVec *pModelProperties);
+
+        /**
+        * @fn     getConditionedModelData
+        * @brief Get affected data from given conditions
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] ModelConditionVec *pModelConditions - Conditions for data retrieving
+        * @param [out] IntVec   *pDataIds - Searched dataId sets.
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getConditionedModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
+                                          OUT IntVec *pDataIds);
+
+        /**
+        * @fn     watchModelData
+        * @brief Watching data from given conditions
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] ModelConditionVec *pModelConditions - Conditions for data triggering
+        * @param [in] IEvaluationEngineEvent *pEvaluationEngineEvent - Event interface where triggered event listening
+        * @param [out] int *pTriggerId - Identifier which trigger is activated
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT watchModelData(IN int modelId, IN ModelConditionVec *pModelConditions,
+                                 IN IEvaluationEngineEvent *pEvaluationEngineEvent, OUT int *pTriggerId);
+
+        /**
+        * @fn     dropWatchModelData
+        * @brief Stop watching data
+        *
+        * @param [in] int triggerId - Identifier which trigger to drop
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT dropWatchModelData(IN int triggerId);
+
+        /**
+        * @fn     getParentDataId
+        * @brief Get parent dataId related to model hierarchy
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] int parentModelId - Designated parent Context Model's id
+        * @param [out] int *pParentDataId - Designated parent Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getParentDataId(IN int modelId, IN int dataId, IN int parentModelId,
+                                  OUT int *pParentDataId);
+
+        /**
+        * @fn     getChildDataId
+        * @brief Get child dataId related to model hierarchy
+        *
+        * @param [in] int modelId - model id that created CreateModel's execution.
+        * @param [in] int dataId - DataId that current model's
+        * @param [in] int childModelId - Designated child Context Model's id
+        * @param [out] IntVec *pChildDataIds - Designated child Context Model's data's Id
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getChildDataId(IN int modelId, IN int dataId, IN int childModelId,
+                                 OUT IntVec *pChildDataIds);
+
+        //SSMRESULT GetPathToRoot(IN int currentModelId, OUT IntVec *pPath);
+
+        //SSMRESULT GetModelId(IN const char *modelName, OUT int *pModelId);
+
+        //SSMRESULT GetModelHierarchy(IN int rootModelId, OUT StringVec *pPath);
+
+        //SSMRESULT GetDataHierarchy(IN int rootModelId, IN int dataId, OUT StringVec *pPath);
 };
 
 #endif
index b71184b..450970c 100644 (file)
@@ -21,7 +21,7 @@
 
 CModelData::CModelData()
 {
-       m_dataId = 0;
+    m_dataId = 0;
 }
 
 CModelData::~CModelData()
@@ -31,45 +31,45 @@ CModelData::~CModelData()
 
 void CModelData::setDataId(IN int dataId)
 {
-       m_dataId = dataId;
+    m_dataId = dataId;
 }
 
 void CModelData::addModelData(IN std::string propertyName, IN std::string propertyValue)
 {
-       m_properties[propertyName] = propertyValue;
+    m_properties[propertyName] = propertyValue;
 }
 
 int CModelData::getDataId()
 {
-       return m_dataId;
+    return m_dataId;
 }
 
 int CModelData::getPropertyCount()
 {
-       return m_properties.size();
+    return m_properties.size();
 }
 
 std::string CModelData::getPropertyName(IN int propertyIndex)
 {
-       std::map<std::string, std::string>::iterator idxProperty = m_properties.begin();
-       for(int i=0; i < propertyIndex; i++)
-       {
-               idxProperty++;
-       }
-       return idxProperty->first;
+    std::map<std::string, std::string>::iterator idxProperty = m_properties.begin();
+    for (int i = 0; i < propertyIndex; i++)
+    {
+        idxProperty++;
+    }
+    return idxProperty->first;
 }
 
 std::string CModelData::getPropertyValue(IN int propertyIndex)
 {
-       std::map<std::string, std::string>::iterator idxProperty = m_properties.begin();
-       for(int i=0; i < propertyIndex; i++)
-       {
-               idxProperty++;
-       }
-       return idxProperty->second;
+    std::map<std::string, std::string>::iterator idxProperty = m_properties.begin();
+    for (int i = 0; i < propertyIndex; i++)
+    {
+        idxProperty++;
+    }
+    return idxProperty->second;
 }
 
 std::string CModelData::getPropertyValueByName(IN std::string propertyName)
 {
-       return m_properties[propertyName];
+    return m_properties[propertyName];
 }
index aad6da6..643af67 100644 (file)
 /**
 * @class    CModelData
 * @brief    CModelData Interface
-*                       This class represents context model data package
+*            This class represents context model data package
 *
 * @see
 */
 class CModelData : public IModelData
 {
-private:
-       int m_dataId;
-       std::map<std::string, std::string> m_properties;
+    private:
+        int m_dataId;
+        std::map<std::string, std::string> m_properties;
 
-public:
-       CModelData();
+    public:
+        CModelData();
 
-       ~CModelData();
+        ~CModelData();
 
-       /**
-       * @fn     setDataId
-       * @brief Set affected DataId. This method is only for constructing data.
-       *
-       * @param [in] int dataId - Represent data Id
-       * 
-       * @return NONE
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void setDataId(IN int dataId);
+        /**
+        * @fn     setDataId
+        * @brief Set affected DataId. This method is only for constructing data.
+        *
+        * @param [in] int dataId - Represent data Id
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void setDataId(IN int dataId);
 
-       /**
-       * @fn     addModelData
-       * @brief Add affected model data. This method is only for constructing data.
-       *
-       * @param [in] std::string propertyName - Represent property name
-       * @param [in] std::string propertyValue - Represent property value
-       * 
-       * @return NONE
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       void addModelData(IN std::string propertyName, IN std::string propertyValue);
+        /**
+        * @fn     addModelData
+        * @brief Add affected model data. This method is only for constructing data.
+        *
+        * @param [in] std::string propertyName - Represent property name
+        * @param [in] std::string propertyValue - Represent property value
+        *
+        * @return NONE
+        * @warning
+        * @exception
+        * @see
+        */
+        void addModelData(IN std::string propertyName, IN std::string propertyValue);
 
-       /**
-       * @fn     getDataId
-       * @brief Get affected DataId. ContextModel has plenty of data so \n
-       *                 returned data is matched from given condition
-       *
-       * @param None
-       * 
-       * @return int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       int getDataId();
+        /**
+        * @fn     getDataId
+        * @brief Get affected DataId. ContextModel has plenty of data so \n
+        *         returned data is matched from given condition
+        *
+        * @param None
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        int getDataId();
 
-       /**
-       * @fn     getPropertyCount
-       * @brief ContextModel has at least one property that contains data \n
-       *                 property is described from its specification.
-       *
-       * @param None
-       * 
-       * @return int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       int getPropertyCount();
+        /**
+        * @fn     getPropertyCount
+        * @brief ContextModel has at least one property that contains data \n
+        *         property is described from its specification.
+        *
+        * @param None
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        int getPropertyCount();
 
-       /**
-       * @fn     getPropertyName
-       * @brief Retrieve propertyName
-       *
-       * @param [in] int propertyIndex - index of property to read
-       * 
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       std::string getPropertyName(IN int propertyIndex);
+        /**
+        * @fn     getPropertyName
+        * @brief Retrieve propertyName
+        *
+        * @param [in] int propertyIndex - index of property to read
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        std::string getPropertyName(IN int propertyIndex);
 
-       /**
-       * @fn     getPropertyValue
-       * @brief Retrieve propertyValue
-       *
-       * @param [in] int propertyIndex - index of property to read
-       * 
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see
-       */
-       std::string getPropertyValue(IN int propertyIndex);
+        /**
+        * @fn     getPropertyValue
+        * @brief Retrieve propertyValue
+        *
+        * @param [in] int propertyIndex - index of property to read
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        std::string getPropertyValue(IN int propertyIndex);
 
-       /**
-       * @fn     getPropertyValueByName
-       * @brief Retrieve propertyValue using given name
-       *
-       * @param [in] std::string propertyName - property name looking for
-       * 
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see
-       */
-       std::string getPropertyValueByName(IN std::string propertyName);
+        /**
+        * @fn     getPropertyValueByName
+        * @brief Retrieve propertyValue using given name
+        *
+        * @param [in] std::string propertyName - property name looking for
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        std::string getPropertyValueByName(IN std::string propertyName);
 };
 
 #endif
index 770a0ca..bab1e7c 100644 (file)
 
 SSMRESULT CPropagationEngine::finalConstruct()
 {
-       SSMRESULT                               res = SSM_E_FAIL;
+    SSMRESULT               res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase**)&m_pTasker));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextDataReader, (IBase**)&m_pContextDataReader));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextDataReader, (IBase **)&m_pContextDataReader));
 
-       SSM_CLEANUP_ASSERT(m_pContextDataReader->registerContextModelAccessor(this));
+    SSM_CLEANUP_ASSERT(m_pContextDataReader->registerContextModelAccessor(this));
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase**)&m_pEvaluationEngine));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IEvaluationEngine, (IBase **)&m_pEvaluationEngine));
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase**)&m_pContextRepository));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository));
 
-       SSM_CLEANUP_ASSERT(m_pContextRepository->registerResourceFinderEvent(this));
+    SSM_CLEANUP_ASSERT(m_pContextRepository->registerResourceFinderEvent(this));
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResponseReactor, (IBase**)&m_pResponseReactor));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResponseReactor, (IBase **)&m_pResponseReactor));
 
-       SSM_CLEANUP_ASSERT(initializeEngine());
+    SSM_CLEANUP_ASSERT(initializeEngine());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CPropagationEngine::finalRelease()
 {
-       terminateEngine();
-
-       for(std::map<std::string, IContextModel*>::iterator itor = m_installedContextModel.begin();
-               itor != m_installedContextModel.end(); ++itor)
-       {
-               ((CContextModel*)itor->second)->registerContextModelEvent(NULL);
-               SAFE_RELEASE(itor->second);
-       }
-
-       for(VirtualModelMap::iterator itor = m_lookUpContextModel.begin();
-               itor != m_lookUpContextModel.end(); ++itor)
-       {
-               for(std::vector< std::pair<ModelConditionVec, IConditionedQuery*> >::iterator inneritor = 
-                       itor->second.begin(); inneritor != itor->second.end(); ++inneritor)
-               {
-                       SAFE_RELEASE(inneritor->second);
-               }
-       }
+    terminateEngine();
+
+    for (std::map<std::string, IContextModel *>::iterator itor = m_installedContextModel.begin();
+         itor != m_installedContextModel.end(); ++itor)
+    {
+        ((CContextModel *)itor->second)->registerContextModelEvent(NULL);
+        SAFE_RELEASE(itor->second);
+    }
+
+    for (VirtualModelMap::iterator itor = m_lookUpContextModel.begin();
+         itor != m_lookUpContextModel.end(); ++itor)
+    {
+        for (std::vector< std::pair<ModelConditionVec, IConditionedQuery *> >::iterator inneritor =
+                 itor->second.begin(); inneritor != itor->second.end(); ++inneritor)
+        {
+            SAFE_RELEASE(inneritor->second);
+        }
+    }
 }
 
-SSMRESULT CPropagationEngine::findContextModel(IN std::string modelName, OUT IContextModel     **ppContextModel)
+SSMRESULT CPropagationEngine::findContextModel(IN std::string modelName,
+        OUT IContextModel  **ppContextModel)
 {
-       SSMRESULT res = SSM_S_FALSE;
-       std::map<std::string, IContextModel*>::iterator idxContextModel;
+    SSMRESULT res = SSM_S_FALSE;
+    std::map<std::string, IContextModel *>::iterator idxContextModel;
 
-       m_mtxContextModelList.lock();
-       idxContextModel = m_installedContextModel.find(modelName);
+    m_mtxContextModelList.lock();
+    idxContextModel = m_installedContextModel.find(modelName);
 
-       if(idxContextModel != m_installedContextModel.end())
-       {
-               SSM_CLEANUP_ASSERT(idxContextModel->second->queryInterface(OID_IContextModel, (IBase**)ppContextModel));
-       }
+    if (idxContextModel != m_installedContextModel.end())
+    {
+        SSM_CLEANUP_ASSERT(idxContextModel->second->queryInterface(OID_IContextModel,
+                           (IBase **)ppContextModel));
+    }
 
 CLEANUP:
-       m_mtxContextModelList.unlock();
-       return res;
+    m_mtxContextModelList.unlock();
+    return res;
 }
 
-SSMRESULT CPropagationEngine::registerCondition(IN IContextModel *pContextModel, IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery)
+SSMRESULT CPropagationEngine::registerCondition(IN IContextModel *pContextModel,
+        IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       IConditionedModel                       *pConditionedModel = NULL;              
+    SSMRESULT res = SSM_E_FAIL;
+    IConditionedModel           *pConditionedModel = NULL;
 
-       SSM_CLEANUP_ASSERT(pContextModel->createConditionedModel(pConditions, &pConditionedModel));
-       SSM_CLEANUP_ASSERT(pConditionedQuery->registerConditionedModel(pConditionedModel));
+    SSM_CLEANUP_ASSERT(pContextModel->createConditionedModel(pConditions, &pConditionedModel));
+    SSM_CLEANUP_ASSERT(pConditionedQuery->registerConditionedModel(pConditionedModel));
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       SAFE_RELEASE(pConditionedModel);
-       return res;
+    SAFE_RELEASE(pConditionedModel);
+    return res;
 }
 
-SSMRESULT CPropagationEngine::registerVirtualCondition(IN std::string virtualContextModelName, IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery)
+SSMRESULT CPropagationEngine::registerVirtualCondition(IN std::string virtualContextModelName,
+        IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery)
 {
-       pConditionedQuery->addRef();
-       m_mtxLookUpList.lock();
-       m_lookUpContextModel[virtualContextModelName].push_back(std::make_pair(*pConditions, pConditionedQuery));
-       m_mtxLookUpList.unlock();
-       return SSM_S_OK;
+    pConditionedQuery->addRef();
+    m_mtxLookUpList.lock();
+    m_lookUpContextModel[virtualContextModelName].push_back(std::make_pair(*pConditions,
+            pConditionedQuery));
+    m_mtxLookUpList.unlock();
+    return SSM_S_OK;
 }
 
-SSMRESULT CPropagationEngine::propagateNewModel(IN std::string newModelName, IN IContextModel *pContextModel)
+SSMRESULT CPropagationEngine::propagateNewModel(IN std::string newModelName,
+        IN IContextModel *pContextModel)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       VirtualModelMap::iterator       itorVModels;
+    SSMRESULT res = SSM_E_FAIL;
+    VirtualModelMap::iterator   itorVModels;
 
-       m_mtxLookUpList.lock();
-       itorVModels = m_lookUpContextModel.find(newModelName);
+    m_mtxLookUpList.lock();
+    itorVModels = m_lookUpContextModel.find(newModelName);
 
-       if(itorVModels != m_lookUpContextModel.end())
-       {
-               for(std::vector< std::pair<ModelConditionVec, IConditionedQuery*> >::iterator itor = 
-                       itorVModels->second.begin(); itor != itorVModels->second.end(); ++itor)
-               {
-                       SSM_CLEANUP_ASSERT(registerCondition(pContextModel, &itor->first, itor->second));
+    if (itorVModels != m_lookUpContextModel.end())
+    {
+        for (std::vector< std::pair<ModelConditionVec, IConditionedQuery *> >::iterator itor =
+                 itorVModels->second.begin(); itor != itorVModels->second.end(); ++itor)
+        {
+            SSM_CLEANUP_ASSERT(registerCondition(pContextModel, &itor->first, itor->second));
 
-                       SAFE_RELEASE(itor->second);
-               }
+            SAFE_RELEASE(itor->second);
+        }
 
-               m_lookUpContextModel.erase(itorVModels);
-       }
+        m_lookUpContextModel.erase(itorVModels);
+    }
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       m_mtxLookUpList.unlock();
-       return res;
+    m_mtxLookUpList.unlock();
+    return res;
 }
 
 SSMRESULT CPropagationEngine::addResourceFromGetList()
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::vector<ISSMResource*>              contextModelList;
-       std::stringstream                               sstream;
-       
-       m_pResponseReactor->getList(&contextModelList);
-       for(std::vector<ISSMResource*>::iterator itor = contextModelList.begin(); 
-               itor != contextModelList.end(); ++itor)
-       {
-               SSM_CLEANUP_ASSERT(installContextModelFromISSMResource(*itor));
-       }
-       
-       res = SSM_S_OK;
+    SSMRESULT res = SSM_E_FAIL;
+    std::vector<ISSMResource *>      contextModelList;
+    std::stringstream               sstream;
+
+    m_pResponseReactor->getList(&contextModelList);
+    for (std::vector<ISSMResource *>::iterator itor = contextModelList.begin();
+         itor != contextModelList.end(); ++itor)
+    {
+        SSM_CLEANUP_ASSERT(installContextModelFromISSMResource(*itor));
+    }
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 //Install new resource and update Device table
 SSMRESULT CPropagationEngine::installContextModelFromISSMResource(IN ISSMResource *pSSMResource)
 {
-       SSMRESULT res = SSM_E_FAIL;
-
-       ModelProperty                           modelProperty;
-       ModelPropertyVec                        modelProperties;
-       CObject<CContextModel>          *pContextModel;
-       int                                                     deviceId = 0;
-       std::string                                     lifeTime;
-
-       switch((res = findContextModel(pSSMResource->type.c_str(), (IContextModel**)&pContextModel)))
-       {
-               //we found model
-       case SSM_S_OK:
-               break;
-
-               //no models using that name, create new one
-       case SSM_S_FALSE:
-               for(std::vector<std::map<std::string, std::string> >::iterator itor = 
-                       pSSMResource->outputProperty.begin(); itor != pSSMResource->outputProperty.end();
-                       ++itor)
-               {
-                       if ((*itor)["name"] == "lifetime")
-                       {
-                               lifeTime = (*itor)["value"];
-                               continue;
-                       }
-
-                       modelProperty.propertyName = (*itor)["name"];
-                       if((*itor)["type"] == "string")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-                       }
-                       else if((*itor)["type"] == "int")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
-                       }
-                       else if((*itor)["type"] == "double")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_REAL;
-                       }
-                       else if((*itor)["type"] == "float")
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_REAL;
-                       }
-                       else
-                       {
-                               modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-                       }
-                       modelProperties.push_back(modelProperty);
-               }
-
-               //Install new resource
-               SSM_CLEANUP_ASSERT(installContextModel(m_pDeviceModel, IContextModel::CONSTRUCTION_TYPE_EXTERNAL,
-                       pSSMResource->type.c_str(), &modelProperties, (IContextModel**)&pContextModel));
-
-               if(lifeTime.length() > 0)
-               {
-                       pContextModel->setLifeTime(lifeTime);
-               }               
-
-               modelProperties.clear();
-               break;
-
-       default:
-               goto CLEANUP; 
-       }               
-       
-       //Update Device data to DB
-       SSM_CLEANUP_ASSERT(updateDeviceInfo(pSSMResource, &deviceId));
-
-       //TODO: Must be modified for restructuring
-       pContextModel->addSSMResourceAndDeviceDataId(pSSMResource->type, deviceId, pSSMResource);
-
-       res = SSM_S_OK;
+    SSMRESULT res = SSM_E_FAIL;
+
+    ModelProperty               modelProperty;
+    ModelPropertyVec            modelProperties;
+    CObject<CContextModel>      *pContextModel;
+    int                         deviceId = 0;
+    std::string                 lifeTime;
+
+    switch ((res = findContextModel(pSSMResource->type.c_str(), (IContextModel **)&pContextModel)))
+    {
+        //we found model
+        case SSM_S_OK:
+            break;
+
+        //no models using that name, create new one
+        case SSM_S_FALSE:
+            for (std::vector<std::map<std::string, std::string> >::iterator itor =
+                     pSSMResource->outputProperty.begin(); itor != pSSMResource->outputProperty.end();
+                 ++itor)
+            {
+                if ((*itor)["name"] == "lifetime")
+                {
+                    lifeTime = (*itor)["value"];
+                    continue;
+                }
+
+                modelProperty.propertyName = (*itor)["name"];
+                if ((*itor)["type"] == "string")
+                {
+                    modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+                }
+                else if ((*itor)["type"] == "int")
+                {
+                    modelProperty.propertyType = ModelProperty::TYPE_INTEGER;
+                }
+                else if ((*itor)["type"] == "double")
+                {
+                    modelProperty.propertyType = ModelProperty::TYPE_REAL;
+                }
+                else if ((*itor)["type"] == "float")
+                {
+                    modelProperty.propertyType = ModelProperty::TYPE_REAL;
+                }
+                else
+                {
+                    modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+                }
+                modelProperties.push_back(modelProperty);
+            }
+
+            //Install new resource
+            SSM_CLEANUP_ASSERT(installContextModel(m_pDeviceModel, IContextModel::CONSTRUCTION_TYPE_EXTERNAL,
+                                                   pSSMResource->type.c_str(), &modelProperties, (IContextModel **)&pContextModel));
+
+            if (lifeTime.length() > 0)
+            {
+                pContextModel->setLifeTime(lifeTime);
+            }
+
+            modelProperties.clear();
+            break;
+
+        default:
+            goto CLEANUP;
+    }
+
+    //Update Device data to DB
+    SSM_CLEANUP_ASSERT(updateDeviceInfo(pSSMResource, &deviceId));
+
+    //TODO: Must be modified for restructuring
+    pContextModel->addSSMResourceAndDeviceDataId(pSSMResource->type, deviceId, pSSMResource);
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       SAFE_RELEASE(pContextModel);
-       return res;
+    SAFE_RELEASE(pContextModel);
+    return res;
 }
 
 SSMRESULT CPropagationEngine::updateDeviceInfo(IN ISSMResource *pSSMResource, OUT int *deviceId)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       ModelProperty                           modelProperty;
-       ModelPropertyVec                        modelProperties;
-       std::map<std::string, int>::iterator    itorSearchedDeviceId;
-       int                                                     deviceDataId;
+    ModelProperty               modelProperty;
+    ModelPropertyVec            modelProperties;
+    std::map<std::string, int>::iterator    itorSearchedDeviceId;
+    int                         deviceDataId;
 
-       modelProperty.propertyName = "fname";
-       modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-       modelProperty.propertyValue = pSSMResource->friendlyName;
-       modelProperties.push_back(modelProperty);
+    modelProperty.propertyName = "fname";
+    modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+    modelProperty.propertyValue = pSSMResource->friendlyName;
+    modelProperties.push_back(modelProperty);
 
-       modelProperty.propertyName = "ip";
-       modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-       modelProperty.propertyValue = pSSMResource->ip;
-       modelProperties.push_back(modelProperty);
+    modelProperty.propertyName = "ip";
+    modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+    modelProperty.propertyValue = pSSMResource->ip;
+    modelProperties.push_back(modelProperty);
 
-       modelProperty.propertyName = "version";
-       modelProperty.propertyType = ModelProperty::TYPE_TEXT;
-       modelProperty.propertyValue = "1.0";
-       modelProperties.push_back(modelProperty);
+    modelProperty.propertyName = "version";
+    modelProperty.propertyType = ModelProperty::TYPE_TEXT;
+    modelProperty.propertyValue = "1.0";
+    modelProperties.push_back(modelProperty);
 
-       itorSearchedDeviceId = m_searchedSensorDataId.find(pSSMResource->ip);
+    itorSearchedDeviceId = m_searchedSensorDataId.find(pSSMResource->ip);
 
-       if (itorSearchedDeviceId == m_searchedSensorDataId.end())
-       {
-               SSM_CLEANUP_ASSERT(m_pDeviceModel->addModelData(1, &modelProperties, &deviceDataId));
-               m_searchedSensorDataId[pSSMResource->ip] = deviceDataId;
-       }
-       else
-       {
-               deviceDataId = m_searchedSensorDataId[pSSMResource->ip];
-       }
+    if (itorSearchedDeviceId == m_searchedSensorDataId.end())
+    {
+        SSM_CLEANUP_ASSERT(m_pDeviceModel->addModelData(1, &modelProperties, &deviceDataId));
+        m_searchedSensorDataId[pSSMResource->ip] = deviceDataId;
+    }
+    else
+    {
+        deviceDataId = m_searchedSensorDataId[pSSMResource->ip];
+    }
 
-       if (deviceId != NULL)
-               *deviceId = deviceDataId;
+    if (deviceId != NULL)
+        *deviceId = deviceDataId;
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CPropagationEngine::installResponseReactor(IN IResponseReactor *pResponseReactor)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::vector<ISSMResource*>              contextModelList;
+    SSMRESULT res = SSM_E_FAIL;
+    std::vector<ISSMResource *>      contextModelList;
 
-       pResponseReactor->getList(&contextModelList);
+    pResponseReactor->getList(&contextModelList);
 
-       for(std::vector<ISSMResource*>::iterator itor = contextModelList.begin(); 
-               itor != contextModelList.end(); ++itor)
-       {
-               SSM_CLEANUP_ASSERT(installContextModelFromISSMResource(*itor));
-       }
+    for (std::vector<ISSMResource *>::iterator itor = contextModelList.begin();
+         itor != contextModelList.end(); ++itor)
+    {
+        SSM_CLEANUP_ASSERT(installContextModelFromISSMResource(*itor));
+    }
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CPropagationEngine::installContextModel(IN IContextModel *pParentModel, IN IContextModel::ConstructionType constructionType, IN const char *modelName, IN ModelPropertyVec *pModelDescs, OUT IContextModel **ppContextModel)
+SSMRESULT CPropagationEngine::installContextModel(IN IContextModel *pParentModel,
+        IN IContextModel::ConstructionType constructionType, IN const char *modelName,
+        IN ModelPropertyVec *pModelDescs, OUT IContextModel **ppContextModel)
 {
-       SSMRESULT                                       res = SSM_E_FAIL;
-       CObject<CContextModel>          *pNewModel;
+    SSMRESULT                   res = SSM_E_FAIL;
+    CObject<CContextModel>      *pNewModel;
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextModel, (IBase**)&pNewModel));
-       SSM_CLEANUP_ASSERT(pNewModel->create(constructionType, pParentModel, modelName, pModelDescs));
-       SSM_CLEANUP_ASSERT(pNewModel->registerContextModelEvent(this));
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextModel, (IBase **)&pNewModel));
+    SSM_CLEANUP_ASSERT(pNewModel->create(constructionType, pParentModel, modelName, pModelDescs));
+    SSM_CLEANUP_ASSERT(pNewModel->registerContextModelEvent(this));
 
-       pNewModel->addRef();
-       m_mtxContextModelList.lock();
-       m_installedContextModel[modelName] = pNewModel;
-       m_mtxContextModelList.unlock();
+    pNewModel->addRef();
+    m_mtxContextModelList.lock();
+    m_installedContextModel[modelName] = pNewModel;
+    m_mtxContextModelList.unlock();
 
-       SSM_CLEANUP_ASSERT(propagateNewModel(modelName, pNewModel));
+    SSM_CLEANUP_ASSERT(propagateNewModel(modelName, pNewModel));
 
-       if(ppContextModel)
-       {
-               SSM_CLEANUP_ASSERT(pNewModel->queryInterface(OID_IContextModel, (IBase**)ppContextModel));
-       }
+    if (ppContextModel)
+    {
+        SSM_CLEANUP_ASSERT(pNewModel->queryInterface(OID_IContextModel, (IBase **)ppContextModel));
+    }
 
 CLEANUP:
-       SAFE_RELEASE(pNewModel);
-       return res;
+    SAFE_RELEASE(pNewModel);
+    return res;
 }
 
 SSMRESULT CPropagationEngine::cleanUpRemoteDeviceInfo()
 {
-       SSMRESULT                               res = SSM_E_FAIL;
-       ModelConditionVec               deviceCondition(1);
-       IConditionedModel               *pRemoteDeviceInformation = NULL;
-       IntVec                                  deviceDataIds;
-
-       deviceCondition[0].modelProperty.propertyName = "dataId";
-       deviceCondition[0].modelProperty.propertyValue = "1";
-       deviceCondition[0].modelProperty.propertyType = ModelProperty::TYPE_NUMERIC;
-       deviceCondition[0].predicate = ModelCondition::PREDICATE_GT;
-       SSM_CLEANUP_ASSERT(m_pDeviceModel->createConditionedModel(&deviceCondition, &pRemoteDeviceInformation));
-       SSM_CLEANUP_ASSERT(pRemoteDeviceInformation->getAffectedData(&deviceDataIds));
-
-       for(unsigned int i=0; i < deviceDataIds.size(); i++)
-       {
-               SSM_CLEANUP_ASSERT(m_pDeviceModel->deleteModelData(deviceDataIds[i]));
-       }
+    SSMRESULT               res = SSM_E_FAIL;
+    ModelConditionVec       deviceCondition(1);
+    IConditionedModel       *pRemoteDeviceInformation = NULL;
+    IntVec                  deviceDataIds;
+
+    deviceCondition[0].modelProperty.propertyName = "dataId";
+    deviceCondition[0].modelProperty.propertyValue = "1";
+    deviceCondition[0].modelProperty.propertyType = ModelProperty::TYPE_NUMERIC;
+    deviceCondition[0].predicate = ModelCondition::PREDICATE_GT;
+    SSM_CLEANUP_ASSERT(m_pDeviceModel->createConditionedModel(&deviceCondition,
+                       &pRemoteDeviceInformation));
+    SSM_CLEANUP_ASSERT(pRemoteDeviceInformation->getAffectedData(&deviceDataIds));
+
+    for (unsigned int i = 0; i < deviceDataIds.size(); i++)
+    {
+        SSM_CLEANUP_ASSERT(m_pDeviceModel->deleteModelData(deviceDataIds[i]));
+    }
 
 CLEANUP:
-       SAFE_RELEASE(pRemoteDeviceInformation);
-       return res;
+    SAFE_RELEASE(pRemoteDeviceInformation);
+    return res;
 }
 
-void CPropagationEngine::onExecute(IN voidpArg)
+void CPropagationEngine::onExecute(IN void *pArg)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       int                     *pMessage = (int*)pArg;
+    int         *pMessage = (int *)pArg;
 
-       RESOURCE_EVENT_TYPE eventType = (RESOURCE_EVENT_TYPE)pMessage[0];
-       ISSMResource                    *pResource = (ISSMResource*)pMessage[1];
+    RESOURCE_EVENT_TYPE eventType = (RESOURCE_EVENT_TYPE)pMessage[0];
+    ISSMResource            *pResource = (ISSMResource *)pMessage[1];
 
-       switch(eventType)
-       {
-       case SSM_EVENT_NORMAL:
-               SSM_CLEANUP_ASSERT(addResourceFromGetList());
-               break;
+    switch (eventType)
+    {
+        case SSM_EVENT_NORMAL:
+            SSM_CLEANUP_ASSERT(addResourceFromGetList());
+            break;
 
-       case SSM_EVENT_ADDED:
-               SSM_CLEANUP_ASSERT(installContextModelFromISSMResource(pResource));
-               break;
+        case SSM_EVENT_ADDED:
+            SSM_CLEANUP_ASSERT(installContextModelFromISSMResource(pResource));
+            break;
 
-       case SSM_REMOVED:
-               break;
+        case SSM_REMOVED:
+            break;
 
-       case SSM_UPDATED:
-               break;
+        case SSM_UPDATED:
+            break;
 
-       default:
-               break;
-       }
+        default:
+            break;
+    }
 
 CLEANUP:
-       ;
+    ;
 }
 
-void CPropagationEngine::onTerminate(IN voidpArg)
+void CPropagationEngine::onTerminate(IN void *pArg)
 {
-       int                     *pMessage = (int*)pArg;
+    int         *pMessage = (int *)pArg;
 
-       delete[] pMessage;
+    delete[] pMessage;
 }
 
-int CPropagationEngine::onResourceEvent(IN RESOURCE_EVENT_TYPE eventType, IN ISSMResource *pSSMResource, IN std::string info)
+int CPropagationEngine::onResourceEvent(IN RESOURCE_EVENT_TYPE eventType,
+                                        IN ISSMResource *pSSMResource, IN std::string info)
 {
-       int                     *pMessage = new int[2];
+    int         *pMessage = new int[2];
 
-       pMessage[0] = eventType;
-       pMessage[1] = (int)pSSMResource;
-       return (int)m_pTasker->addTask(this, (void*)pMessage);
+    pMessage[0] = eventType;
+    pMessage[1] = (int)pSSMResource;
+    return (int)m_pTasker->addTask(this, (void *)pMessage);
 }
 
 SSMRESULT CPropagationEngine::initializeEngine()
 {
-       SSMRESULT                               res = SSM_E_FAIL;
-       CObject<CContextModel>  *pRootModel = NULL;
-       ModelPropertyVec                rootModelProperties(1);
+    SSMRESULT               res = SSM_E_FAIL;
+    CObject<CContextModel>  *pRootModel = NULL;
+    ModelPropertyVec        rootModelProperties(1);
 
-       ModelPropertyVec                deviceModelProperties(3);
+    ModelPropertyVec        deviceModelProperties(3);
 
-       ISSMResource                    ssmResource;
+    ISSMResource            ssmResource;
 
-       SSM_CLEANUP_ASSERT(m_pEvaluationEngine->initializeEngine());
+    SSM_CLEANUP_ASSERT(m_pEvaluationEngine->initializeEngine());
 
-       //Create root model (Root)
-       rootModelProperties[0].propertyName = "name";
-       rootModelProperties[0].propertyType = ModelProperty::TYPE_TEXT;
+    //Create root model (Root)
+    rootModelProperties[0].propertyName = "name";
+    rootModelProperties[0].propertyType = ModelProperty::TYPE_TEXT;
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextModel, (IBase**)&pRootModel));
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextModel, (IBase **)&pRootModel));
 
-       SSM_CLEANUP_ASSERT(pRootModel->create(IContextModel::CONSTRUCTION_TYPE_INTERNAL, NULL,
-               "root", &rootModelProperties));
-       SSM_CLEANUP_ASSERT(pRootModel->queryInterface(OID_IContextModel, (IBase**)&m_pRootModel));
+    SSM_CLEANUP_ASSERT(pRootModel->create(IContextModel::CONSTRUCTION_TYPE_INTERNAL, NULL,
+                                          "root", &rootModelProperties));
+    SSM_CLEANUP_ASSERT(pRootModel->queryInterface(OID_IContextModel, (IBase **)&m_pRootModel));
 
-       //Create basic model (Device)
-       deviceModelProperties[0].propertyName = "fname"; 
-       deviceModelProperties[0].propertyType = ModelProperty::TYPE_TEXT;
-       deviceModelProperties[1].propertyName = "ip"; 
-       deviceModelProperties[1].propertyType = ModelProperty::TYPE_TEXT;
-       deviceModelProperties[2].propertyName = "version"; 
-       deviceModelProperties[2].propertyType = ModelProperty::TYPE_TEXT;
+    //Create basic model (Device)
+    deviceModelProperties[0].propertyName = "fname";
+    deviceModelProperties[0].propertyType = ModelProperty::TYPE_TEXT;
+    deviceModelProperties[1].propertyName = "ip";
+    deviceModelProperties[1].propertyType = ModelProperty::TYPE_TEXT;
+    deviceModelProperties[2].propertyName = "version";
+    deviceModelProperties[2].propertyType = ModelProperty::TYPE_TEXT;
 
-       SSM_CLEANUP_ASSERT(installContextModel(m_pRootModel, IContextModel::CONSTRUCTION_TYPE_INTERNAL, "Device",
-               &deviceModelProperties, &m_pDeviceModel));
+    SSM_CLEANUP_ASSERT(installContextModel(m_pRootModel, IContextModel::CONSTRUCTION_TYPE_INTERNAL,
+                                           "Device",
+                                           &deviceModelProperties, &m_pDeviceModel));
 
-       ssmResource.ip = "coap://127.0.0.1/";
-       ssmResource.friendlyName = "MyDevice";
+    ssmResource.ip = "coap://127.0.0.1/";
+    ssmResource.friendlyName = "MyDevice";
 
-       SSM_CLEANUP_ASSERT(updateDeviceInfo(&ssmResource, NULL));
+    SSM_CLEANUP_ASSERT(updateDeviceInfo(&ssmResource, NULL));
 
-       SSM_CLEANUP_ASSERT(installResponseReactor(m_pResponseReactor));
+    SSM_CLEANUP_ASSERT(installResponseReactor(m_pResponseReactor));
 
 CLEANUP:
-       SAFE_RELEASE(pRootModel);
-       return res;
+    SAFE_RELEASE(pRootModel);
+    return res;
 }
 
 void CPropagationEngine::terminateEngine()
 {
-       SSMRESULT                               res = SSM_E_FAIL;
+    SSMRESULT               res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(cleanUpRemoteDeviceInfo());
+    SSM_CLEANUP_ASSERT(cleanUpRemoteDeviceInfo());
 
 CLEANUP:
-       return;
+    return;
 }
 
-SSMRESULT CPropagationEngine::getContextModel(IN std:: string modelName, OUT IContextModel **ppContextModel)
+SSMRESULT CPropagationEngine::getContextModel(IN std:: string modelName,
+        OUT IContextModel **ppContextModel)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       res = findContextModel(modelName, ppContextModel);
+    res = findContextModel(modelName, ppContextModel);
 
-       return res == SSM_S_OK ? SSM_S_OK : SSM_E_FAIL;
+    return res == SSM_S_OK ? SSM_S_OK : SSM_E_FAIL;
 }
 
-SSMRESULT CPropagationEngine::createConditionedQuery(IN IContextModel::ActivationType activationType, IN QueryCondition *pQueryCondition, IN IConditionedQueryEvent *pEvent, OUT IConditionedQuery **ppConditionedQuery)
+SSMRESULT CPropagationEngine::createConditionedQuery(IN IContextModel::ActivationType
+        activationType, IN QueryCondition *pQueryCondition, IN IConditionedQueryEvent *pEvent,
+        OUT IConditionedQuery **ppConditionedQuery)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       CObject<CConditionedQuery>      *pConditionedQuery;
-       IContextModel                           *pContextModel = NULL;
-
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IConditionedQuery, (IBase**)&pConditionedQuery));
-
-       SSM_CLEANUP_ASSERT(pConditionedQuery->create(activationType, pQueryCondition->size()));
-       for(QueryCondition::iterator itor = pQueryCondition->begin(); 
-               itor != pQueryCondition->end(); ++itor)
-       {
-               switch(findContextModel(itor->first, &pContextModel))
-               {
-               case SSM_S_OK:
-                       SSM_CLEANUP_ASSERT(registerCondition(pContextModel, &itor->second, pConditionedQuery));
-                       break;
-
-               case SSM_S_FALSE:
-                       SSM_CLEANUP_ASSERT(registerVirtualCondition(itor->first, &itor->second, pConditionedQuery));
-                       break;
-
-               default:
-                       res = SSM_E_FAIL;
-                       goto CLEANUP;
-               }
-               SAFE_RELEASE(pContextModel);
-       }
-
-       SSM_CLEANUP_ASSERT(pConditionedQuery->registerQueryConditionEvent(pEvent));
-
-       SSM_CLEANUP_ASSERT(pConditionedQuery->queryInterface(OID_IConditionedQuery, (IBase**)ppConditionedQuery));
+    SSMRESULT res = SSM_E_FAIL;
+    CObject<CConditionedQuery>  *pConditionedQuery;
+    IContextModel               *pContextModel = NULL;
+
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IConditionedQuery, (IBase **)&pConditionedQuery));
+
+    SSM_CLEANUP_ASSERT(pConditionedQuery->create(activationType, pQueryCondition->size()));
+    for (QueryCondition::iterator itor = pQueryCondition->begin();
+         itor != pQueryCondition->end(); ++itor)
+    {
+        switch (findContextModel(itor->first, &pContextModel))
+        {
+            case SSM_S_OK:
+                SSM_CLEANUP_ASSERT(registerCondition(pContextModel, &itor->second, pConditionedQuery));
+                break;
+
+            case SSM_S_FALSE:
+                SSM_CLEANUP_ASSERT(registerVirtualCondition(itor->first, &itor->second, pConditionedQuery));
+                break;
+
+            default:
+                res = SSM_E_FAIL;
+                goto CLEANUP;
+        }
+        SAFE_RELEASE(pContextModel);
+    }
+
+    SSM_CLEANUP_ASSERT(pConditionedQuery->registerQueryConditionEvent(pEvent));
+
+    SSM_CLEANUP_ASSERT(pConditionedQuery->queryInterface(OID_IConditionedQuery,
+                       (IBase **)ppConditionedQuery));
 
 CLEANUP:
-       SAFE_RELEASE(pConditionedQuery);
-       SAFE_RELEASE(pContextModel);
-       return res;
+    SAFE_RELEASE(pConditionedQuery);
+    SAFE_RELEASE(pContextModel);
+    return res;
 }
 
-SSMRESULT CPropagationEngine::onModelStatusChange(IN IContextModel::Status newStatus, IN ISSMResource *pSSMResource, IN IContextModel *pModel)
+SSMRESULT CPropagationEngine::onModelStatusChange(IN IContextModel::Status newStatus,
+        IN ISSMResource *pSSMResource, IN IContextModel *pModel)
 {
-       switch(newStatus)
-       {
-       case IContextModel::STATUS_ACTIVATE:
-               pModel->addRef();
-               m_pResponseReactor->registerContext(SSM_REPEAT, pSSMResource, (CContextModel*)pModel);
-               break;
-
-       case IContextModel::STATUS_DEACTIVATE:
-               m_pResponseReactor->unregisterContext(SSM_REPEAT, pSSMResource, (CContextModel*)pModel);
-               //pModel->CleanUpModelData();
-               pModel->release();
-               break;
-
-       case IContextModel::STATUS_START_READ_VALUE:
-               //Model must be released from OnEvent callType
-               pModel->addRef();
-               m_pResponseReactor->registerContext(SSM_ONCE, pSSMResource, (CContextModel*)pModel);
-               break;
-
-       case IContextModel::STATUS_STOP_READ_VALUE:
-               pModel->release();
-               break;
-
-       default:
-               break;
-       }
-
-       return SSM_S_OK;
+    switch (newStatus)
+    {
+        case IContextModel::STATUS_ACTIVATE:
+            pModel->addRef();
+            m_pResponseReactor->registerContext(SSM_REPEAT, pSSMResource, (CContextModel *)pModel);
+            break;
+
+        case IContextModel::STATUS_DEACTIVATE:
+            m_pResponseReactor->unregisterContext(SSM_REPEAT, pSSMResource, (CContextModel *)pModel);
+            //pModel->CleanUpModelData();
+            pModel->release();
+            break;
+
+        case IContextModel::STATUS_START_READ_VALUE:
+            //Model must be released from OnEvent callType
+            pModel->addRef();
+            m_pResponseReactor->registerContext(SSM_ONCE, pSSMResource, (CContextModel *)pModel);
+            break;
+
+        case IContextModel::STATUS_STOP_READ_VALUE:
+            pModel->release();
+            break;
+
+        default:
+            break;
+    }
+
+    return SSM_S_OK;
 }
 
-SSMRESULT CPropagationEngine::onQueryContextModel(IN std::string modelName, OUT IContextModel **ppContextModel)
+SSMRESULT CPropagationEngine::onQueryContextModel(IN std::string modelName,
+        OUT IContextModel **ppContextModel)
 {
-       std::map<std::string, IContextModel*>::iterator         itorContextModel;
+    std::map<std::string, IContextModel *>::iterator     itorContextModel;
 
-       itorContextModel = m_installedContextModel.find(modelName);
+    itorContextModel = m_installedContextModel.find(modelName);
 
-       if(itorContextModel == m_installedContextModel.end())
-       {
-               return SSM_E_FAIL;
-       }
+    if (itorContextModel == m_installedContextModel.end())
+    {
+        return SSM_E_FAIL;
+    }
 
-       return itorContextModel->second->queryInterface(OID_IContextModel, (IBase**)ppContextModel);
+    return itorContextModel->second->queryInterface(OID_IContextModel, (IBase **)ppContextModel);
 }
index 9a3fd14..45eca05 100644 (file)
 #include "Common/InternalInterface.h"
 #include "ConditionedQuery.h"
 
-typedef std::map< std::string, std::vector< std::pair<ModelConditionVec, IConditionedQuery*> > > VirtualModelMap;
+typedef std::map< std::string, std::vector< std::pair<ModelConditionVec, IConditionedQuery *> > >
+VirtualModelMap;
 
 /**
 * @class    CPropagationEngine
 * @brief    CPropagationEngine Interface
-*                       This class represents propagation engine that manages ContextModel's automation
+*            This class represents propagation engine that manages ContextModel's automation
 *
 * @see
 */
-class CPropagationEngine : 
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IPropagationEngine
-       , public IContextModelAccessor
-       , public IThreadClient
-       , public IContextModelEvent
-       , public IResourceEvent
+class CPropagationEngine :
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IPropagationEngine
+    , public IContextModelAccessor
+    , public IThreadClient
+    , public IContextModelEvent
+    , public IResourceEvent
 {
-private:
-       CObjectPtr<ITasker>                                                     m_pTasker;
-       CObjectPtr<IEvaluationEngine>                           m_pEvaluationEngine;
-       CObjectPtr<IContextModel>                                       m_pRootModel;
+    private:
+        CObjectPtr<ITasker>                         m_pTasker;
+        CObjectPtr<IEvaluationEngine>               m_pEvaluationEngine;
+        CObjectPtr<IContextModel>                   m_pRootModel;
 
-       CObjectPtr<IContextDataReader>                          m_pContextDataReader;
-       CObjectPtr<IContextRepository>                          m_pContextRepository;
+        CObjectPtr<IContextDataReader>              m_pContextDataReader;
+        CObjectPtr<IContextRepository>              m_pContextRepository;
 
-       std::map<std::string, IContextModel*>           m_installedContextModel;
-       VirtualModelMap                                                         m_lookUpContextModel;
-       CSimpleMutex                                                            m_mtxContextModelList;
-       CSimpleMutex                                                            m_mtxLookUpList;
+        std::map<std::string, IContextModel *>       m_installedContextModel;
+        VirtualModelMap                             m_lookUpContextModel;
+        CSimpleMutex                                m_mtxContextModelList;
+        CSimpleMutex                                m_mtxLookUpList;
 
-       CObjectPtr<IResponseReactor>                            m_pResponseReactor;
+        CObjectPtr<IResponseReactor>                m_pResponseReactor;
 
-       CObjectPtr<IContextModel>                                       m_pDeviceModel;
-
-       std::map<std::string, int>                                      m_searchedSensorDataId;
-
-       SSMRESULT findContextModel(IN std::string modelName, OUT IContextModel  **ppContextModel);
-
-       SSMRESULT registerCondition(IN IContextModel *pContextModel, IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery);
-
-       SSMRESULT registerVirtualCondition(IN std::string virtualContextModelName, IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery);
-
-       SSMRESULT propagateNewModel(IN std::string newModelName, IN IContextModel *pContextModel);
-
-       SSMRESULT addResourceFromGetList();
-
-       //TODO: Install Context model from SSMResource
-       SSMRESULT installContextModelFromISSMResource(IN ISSMResource *pSSMResource);
-
-       SSMRESULT installResponseReactor(IN IResponseReactor *pResponseReactor);
-
-       SSMRESULT installContextModel(IN IContextModel *pParentModel, IN IContextModel::ConstructionType constructionType,
-               IN const char *modelName, IN ModelPropertyVec *pModelDescs, OUT IContextModel **ppContextModel);
-
-       SSMRESULT recoverEngineFromDatabase();
-
-       SSMRESULT cleanUpRemoteDeviceInfo();
-
-       SSMRESULT initializeEngine();
-
-       void terminateEngine();
-
-       SSMRESULT updateDeviceInfo(IN ISSMResource *pSSMResource, OUT int *deviceId);
-
-public:
-       SSMRESULT finalConstruct();
-
-       void finalRelease();
-
-       void onExecute(IN void* pArg);
-
-       void onTerminate(IN void* pArg);
-
-       /**
-       * @fn     onResourceEvent
-       * @brief Called when new device has discovered
-       *
-       * @param [in] RESOURCE_EVENT_TYPE eventType - Enumerator that represents Device's status
-       * @param [in] ISSMResource *pSSMResouce - NULL
-       * @param [in] std::string info - NULL
-       * 
-       * @return int
-       * @warning
-       * @exception
-       * @see
-       */
-       int onResourceEvent(IN RESOURCE_EVENT_TYPE eventType, IN ISSMResource *pSSMResource, IN std::string info);
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IPropagationEngine))
-               {
-                       IBase *pBase = (IPropagationEngine*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn     getContextModel
-       * @brief Retrieve ContextModel interface specified name
-       *
-       * @param [in] std::string modelName - ContextModel's name that looking for
-       * @param [out] IContextModel **ppContextModel - Interface pointer for retrieving
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getContextModel(IN std::string modelName, OUT IContextModel **ppContextModel);
-
-       /**
-       * @fn     createConditionedQuery
-       * @brief Create Conditioned Query using conditions
-       *
-       * @param [in] IContextModel::ActivationType activationType - ActivationType for ContextModel's working strategy
-       * @param [in] QueryCondition *pQueryCondition - Conditions for data retrieving
-       * @param [in] IConditionedQueryEvent *pEvent - Event interface for Conditioned Result listening
-       * @param [out] IConditionedQuery **ppConditionedQuery - Interface for retrieving Conditioned Query
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT createConditionedQuery(IN IContextModel::ActivationType activationType, IN QueryCondition *pQueryCondition,
-               IN IConditionedQueryEvent *pEvent, OUT IConditionedQuery **ppConditionedQuery);
-
-       /**
-       * @fn     onModelStatusChange
-       * @brief Called when ContextModel wants to activate or deactivate
-       *
-       * @param [in] IContextModel::Status newStatus - Context Model's new status
-       * @param [in] ISSMResource *pSSMResource - Instance of actual resource
-       * @param [in] IContextModel *pModel - Affected Context Model
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT onModelStatusChange(IN IContextModel::Status newStatus, IN ISSMResource *pSSMResource, IN IContextModel *pModel);
-
-       /**
-       * @fn     onQueryContextModel
-       * @brief Called when ContextModelAccessor wants to query installed ContextModel
-       *
-       * @param [in] std::string modelName - ContextModel name to find out
-       * @param [out] IContextModel **ppContextModel - Interface of quried ContextModel
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT onQueryContextModel(IN std::string modelName, OUT IContextModel **ppContextModel);
+        CObjectPtr<IContextModel>                   m_pDeviceModel;
+
+        std::map<std::string, int>                  m_searchedSensorDataId;
+
+        SSMRESULT findContextModel(IN std::string modelName, OUT IContextModel  **ppContextModel);
+
+        SSMRESULT registerCondition(IN IContextModel *pContextModel, IN ModelConditionVec *pConditions,
+                                    IN IConditionedQuery *pConditionedQuery);
+
+        SSMRESULT registerVirtualCondition(IN std::string virtualContextModelName,
+                                           IN ModelConditionVec *pConditions, IN IConditionedQuery *pConditionedQuery);
+
+        SSMRESULT propagateNewModel(IN std::string newModelName, IN IContextModel *pContextModel);
+
+        SSMRESULT addResourceFromGetList();
+
+        //TODO: Install Context model from SSMResource
+        SSMRESULT installContextModelFromISSMResource(IN ISSMResource *pSSMResource);
+
+        SSMRESULT installResponseReactor(IN IResponseReactor *pResponseReactor);
+
+        SSMRESULT installContextModel(IN IContextModel *pParentModel,
+                                      IN IContextModel::ConstructionType constructionType,
+                                      IN const char *modelName, IN ModelPropertyVec *pModelDescs, OUT IContextModel **ppContextModel);
+
+        SSMRESULT recoverEngineFromDatabase();
+
+        SSMRESULT cleanUpRemoteDeviceInfo();
+
+        SSMRESULT initializeEngine();
+
+        void terminateEngine();
+
+        SSMRESULT updateDeviceInfo(IN ISSMResource *pSSMResource, OUT int *deviceId);
+
+    public:
+        SSMRESULT finalConstruct();
+
+        void finalRelease();
+
+        void onExecute(IN void *pArg);
+
+        void onTerminate(IN void *pArg);
+
+        /**
+        * @fn     onResourceEvent
+        * @brief Called when new device has discovered
+        *
+        * @param [in] RESOURCE_EVENT_TYPE eventType - Enumerator that represents Device's status
+        * @param [in] ISSMResource *pSSMResouce - NULL
+        * @param [in] std::string info - NULL
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        int onResourceEvent(IN RESOURCE_EVENT_TYPE eventType, IN ISSMResource *pSSMResource,
+                            IN std::string info);
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IPropagationEngine))
+            {
+                IBase *pBase = (IPropagationEngine *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn     getContextModel
+        * @brief Retrieve ContextModel interface specified name
+        *
+        * @param [in] std::string modelName - ContextModel's name that looking for
+        * @param [out] IContextModel **ppContextModel - Interface pointer for retrieving
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getContextModel(IN std::string modelName, OUT IContextModel **ppContextModel);
+
+        /**
+        * @fn     createConditionedQuery
+        * @brief Create Conditioned Query using conditions
+        *
+        * @param [in] IContextModel::ActivationType activationType - ActivationType for ContextModel's working strategy
+        * @param [in] QueryCondition *pQueryCondition - Conditions for data retrieving
+        * @param [in] IConditionedQueryEvent *pEvent - Event interface for Conditioned Result listening
+        * @param [out] IConditionedQuery **ppConditionedQuery - Interface for retrieving Conditioned Query
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT createConditionedQuery(IN IContextModel::ActivationType activationType,
+                                         IN QueryCondition *pQueryCondition,
+                                         IN IConditionedQueryEvent *pEvent, OUT IConditionedQuery **ppConditionedQuery);
+
+        /**
+        * @fn     onModelStatusChange
+        * @brief Called when ContextModel wants to activate or deactivate
+        *
+        * @param [in] IContextModel::Status newStatus - Context Model's new status
+        * @param [in] ISSMResource *pSSMResource - Instance of actual resource
+        * @param [in] IContextModel *pModel - Affected Context Model
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT onModelStatusChange(IN IContextModel::Status newStatus, IN ISSMResource *pSSMResource,
+                                      IN IContextModel *pModel);
+
+        /**
+        * @fn     onQueryContextModel
+        * @brief Called when ContextModelAccessor wants to query installed ContextModel
+        *
+        * @param [in] std::string modelName - ContextModel name to find out
+        * @param [out] IContextModel **ppContextModel - Interface of quried ContextModel
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT onQueryContextModel(IN std::string modelName, OUT IContextModel **ppContextModel);
 };
 #endif
index fb1e1ef..62d8eca 100644 (file)
 
 SSMRESULT CQueryEngine::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       m_cqid = 0;
+    m_cqid = 0;
 
-       m_pQueryEngineEvent = NULL;
+    m_pQueryEngineEvent = NULL;
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, (IBase**)&m_pTasker));
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, (IBase **)&m_pTasker));
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IPropagationEngine, (IBase**)&m_pPropagationEngine));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IPropagationEngine, (IBase **)&m_pPropagationEngine));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CQueryEngine::finalRelease()
 {
-       m_pQueryEngineEvent = NULL;
-
-       m_mtxQueries.lock();
-       
-       for(std::map<int, IConditionedQuery*>::iterator itor = m_conditionedQueries.begin();
-               itor != m_conditionedQueries.end(); ++itor)
-       {
-               itor->second->deactivateTriggers();
-               SAFE_RELEASE(itor->second);
-       }
-
-       for (std::map<int, CContextQuery*>::iterator itor = m_contextQueries.begin();
-               itor != m_contextQueries.end(); ++itor)
-       {
-               //Token *root = itor->second->getRoot();
-               //SAFE_DELETE(root);
-               SAFE_DELETE(itor->second);
-       }
-
-       m_mtxQueries.unlock();
+    m_pQueryEngineEvent = NULL;
+
+    m_mtxQueries.lock();
+
+    for (std::map<int, IConditionedQuery *>::iterator itor = m_conditionedQueries.begin();
+         itor != m_conditionedQueries.end(); ++itor)
+    {
+        itor->second->deactivateTriggers();
+        SAFE_RELEASE(itor->second);
+    }
+
+    for (std::map<int, CContextQuery *>::iterator itor = m_contextQueries.begin();
+         itor != m_contextQueries.end(); ++itor)
+    {
+        //Token *root = itor->second->getRoot();
+        //SAFE_DELETE(root);
+        SAFE_DELETE(itor->second);
+    }
+
+    m_mtxQueries.unlock();
 }
 
-SSMRESULT CQueryEngine::processQueryResult(IN int userTriggerId, IN std::vector<result_model> *result)
+SSMRESULT CQueryEngine::processQueryResult(IN int userTriggerId,
+        IN std::vector<result_model> *result)
 {
-       SSMRESULT                       res = SSM_E_FAIL;
-       ModelPropertyVec        modelData;
-       std::vector<result_model> result_model_data_id;
-       IntVec                                  modelID;
-       std::vector<std::string> contextName;
-       IContextModel                   *temp_contextmodel = NULL;
-       IContextModel                   *temp_contextmodel2 = NULL;
-
-       int                             *pData = NULL;
-
-       CDataReader *pDataReader = NULL;
-
-       m_mtxQueries.lock();
-       
-       if(m_contextQueries.find(userTriggerId) == m_contextQueries.end())
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
-
-       m_contextQueries[userTriggerId]->check_result_model();
-       m_contextQueries[userTriggerId]->return_modelID(&modelID);
-
-
-       m_contextQueries[userTriggerId]->return_contextName(&contextName);
-
-       for (unsigned int i = 0; i < modelID.size(); i++) 
-       {
-               SSM_CLEANUP_ASSERT(m_pPropagationEngine->getContextModel(contextName.at(i),&temp_contextmodel2));
-
-               for(unsigned int j = 0 ; j < result->size() ;j++)
-               {
-                       int data;
-                       if (result->at(j).dataId.size() <= 0)
-                       {
-                               continue;
-                       }
-
-                       int modelid = modelID.at(i);
-                       std::vector<int> dataid;
-                       for(unsigned int k =0 ; k < result->at(j).dataId.size() ; k++)
-                       {
-                               SSM_CLEANUP_ASSERT(m_pPropagationEngine->getContextModel(result->at(j).modelName,&temp_contextmodel));
-                               data = result->at(j).dataId.at(k);
-
-                               if(modelID.at(i) < result->at(j).modelID )
-                               {
-                                       SSM_CLEANUP_ASSERT(temp_contextmodel->getParentDataId(data,temp_contextmodel2,&data));
-                                       dataid.push_back(data);
-                               }
-                               else if(modelID.at(i) > result->at(j).modelID )
-                               {
-                                       SSM_CLEANUP_ASSERT(temp_contextmodel->getChildDataId(data,temp_contextmodel2,&dataid));
-                               }
-                               else
-                               {
-                                       dataid.push_back(data);
-                               }
-                               SAFE_RELEASE(temp_contextmodel);
-                       }
-
-                       m_contextQueries[userTriggerId]->integrate_result(&result_model_data_id, modelid, &dataid, temp_contextmodel2->getModelName());
-               }
-
-               SAFE_RELEASE(temp_contextmodel2);
-       }
-
-       pDataReader = new CDataReader();
-       
-       for (unsigned int i = 0; i < result_model_data_id.size(); i++) 
-       {
-               std::vector<CModelData*>        modelDataSet;
-
-               for (unsigned int j = 0; j < (result_model_data_id)[i].dataId.size();j++) 
-               {
-                       CModelData* pModelData = new CModelData();
-                       IContextModel           *pCM = NULL;
-                       ModelPropertyVec        modelPropertyVec;
-
-                       SSM_CLEANUP_ASSERT(m_pPropagationEngine->getContextModel((result_model_data_id)[i].modelName, &pCM));
-                       SSM_CLEANUP_ASSERT(pCM->getModelData((result_model_data_id)[i].dataId[j], &modelPropertyVec));
-                       pModelData->setDataId((result_model_data_id)[i].dataId[j]);
-                       for(ModelPropertyVec::iterator itor = modelPropertyVec.begin();
-                               itor != modelPropertyVec.end(); ++itor)
-                       {
-                               pModelData->addModelData(itor->propertyName, itor->propertyValue);
-                       }
-
-                       modelDataSet.push_back(pModelData);
-
-                       SAFE_RELEASE(pCM);
-               }
-
-               SSM_CLEANUP_ASSERT(pDataReader->addModelData((result_model_data_id)[i].modelName, &modelDataSet));
-       }
-       pData = new int[3];
-       pData[0] = EVENT_TYPE_OUTER;
-       pData[1] = userTriggerId;
-       pData[2] = (int)pDataReader;
-
-       m_pTasker->addTask(this, (void*)pData);
-
-       res = SSM_S_OK;
+    SSMRESULT           res = SSM_E_FAIL;
+    ModelPropertyVec    modelData;
+    std::vector<result_model> result_model_data_id;
+    IntVec                  modelID;
+    std::vector<std::string> contextName;
+    IContextModel           *temp_contextmodel = NULL;
+    IContextModel           *temp_contextmodel2 = NULL;
+
+    int             *pData = NULL;
+
+    CDataReader *pDataReader = NULL;
+
+    m_mtxQueries.lock();
+
+    if (m_contextQueries.find(userTriggerId) == m_contextQueries.end())
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
+
+    m_contextQueries[userTriggerId]->check_result_model();
+    m_contextQueries[userTriggerId]->return_modelID(&modelID);
+
+
+    m_contextQueries[userTriggerId]->return_contextName(&contextName);
+
+    for (unsigned int i = 0; i < modelID.size(); i++)
+    {
+        SSM_CLEANUP_ASSERT(m_pPropagationEngine->getContextModel(contextName.at(i), &temp_contextmodel2));
+
+        for (unsigned int j = 0 ; j < result->size() ; j++)
+        {
+            int data;
+            if (result->at(j).dataId.size() <= 0)
+            {
+                continue;
+            }
+
+            int modelid = modelID.at(i);
+            std::vector<int> dataid;
+            for (unsigned int k = 0 ; k < result->at(j).dataId.size() ; k++)
+            {
+                SSM_CLEANUP_ASSERT(m_pPropagationEngine->getContextModel(result->at(j).modelName,
+                                   &temp_contextmodel));
+                data = result->at(j).dataId.at(k);
+
+                if (modelID.at(i) < result->at(j).modelID )
+                {
+                    SSM_CLEANUP_ASSERT(temp_contextmodel->getParentDataId(data, temp_contextmodel2, &data));
+                    dataid.push_back(data);
+                }
+                else if (modelID.at(i) > result->at(j).modelID )
+                {
+                    SSM_CLEANUP_ASSERT(temp_contextmodel->getChildDataId(data, temp_contextmodel2, &dataid));
+                }
+                else
+                {
+                    dataid.push_back(data);
+                }
+                SAFE_RELEASE(temp_contextmodel);
+            }
+
+            m_contextQueries[userTriggerId]->integrate_result(&result_model_data_id, modelid, &dataid,
+                    temp_contextmodel2->getModelName());
+        }
+
+        SAFE_RELEASE(temp_contextmodel2);
+    }
+
+    pDataReader = new CDataReader();
+
+    for (unsigned int i = 0; i < result_model_data_id.size(); i++)
+    {
+        std::vector<CModelData *>    modelDataSet;
+
+        for (unsigned int j = 0; j < (result_model_data_id)[i].dataId.size(); j++)
+        {
+            CModelData *pModelData = new CModelData();
+            IContextModel       *pCM = NULL;
+            ModelPropertyVec    modelPropertyVec;
+
+            SSM_CLEANUP_ASSERT(m_pPropagationEngine->getContextModel((result_model_data_id)[i].modelName,
+                               &pCM));
+            SSM_CLEANUP_ASSERT(pCM->getModelData((result_model_data_id)[i].dataId[j], &modelPropertyVec));
+            pModelData->setDataId((result_model_data_id)[i].dataId[j]);
+            for (ModelPropertyVec::iterator itor = modelPropertyVec.begin();
+                 itor != modelPropertyVec.end(); ++itor)
+            {
+                pModelData->addModelData(itor->propertyName, itor->propertyValue);
+            }
+
+            modelDataSet.push_back(pModelData);
+
+            SAFE_RELEASE(pCM);
+        }
+
+        SSM_CLEANUP_ASSERT(pDataReader->addModelData((result_model_data_id)[i].modelName, &modelDataSet));
+    }
+    pData = new int[3];
+    pData[0] = EVENT_TYPE_OUTER;
+    pData[1] = userTriggerId;
+    pData[2] = (int)pDataReader;
+
+    m_pTasker->addTask(this, (void *)pData);
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       m_mtxQueries.unlock();
-       SAFE_RELEASE(temp_contextmodel);
-       SAFE_RELEASE(temp_contextmodel2);
-       return res;
+    m_mtxQueries.unlock();
+    SAFE_RELEASE(temp_contextmodel);
+    SAFE_RELEASE(temp_contextmodel2);
+    return res;
 }
 
-SSMRESULT CQueryEngine::validateQueryResult(IN IConditionedQueryResult *pConditionedQueryResult, OUT std::vector<result_model> *resultData)
+SSMRESULT CQueryEngine::validateQueryResult(IN IConditionedQueryResult *pConditionedQueryResult,
+        OUT std::vector<result_model> *resultData)
 {
-       SSMRESULT                               res = SSM_E_FAIL;
-       IContextModel                   *pContextModel = NULL;
-       IConditionedModel               *pConditionedModel = NULL;
-
-       for(unsigned int i =0 ; i< pConditionedQueryResult->getConditionedModelCount() ; i++)
-       {
-               std::vector<int>        temp_dataID;
-               result_model            temp_result; 
-               SSM_CLEANUP_ASSERT(pConditionedQueryResult->getConditionedContextModel(i, &pConditionedModel));
-               SSM_CLEANUP_ASSERT(pConditionedModel->getAffectedData(&temp_dataID));
-
-               if(temp_dataID.size() == 0)
-               {
-                       break;
-               }
-
-               SSM_CLEANUP_ASSERT(pConditionedModel->getBaseContextModel(&pContextModel));
-               temp_result.modelID = pContextModel->getModelId();
-               temp_result.dataId = temp_dataID;
-               temp_result.modelName = pContextModel->getModelName();
-               resultData->push_back(temp_result);
-               SAFE_RELEASE(pConditionedModel);
-               SAFE_RELEASE(pContextModel);
-       }
-
-       if(resultData->size() == pConditionedQueryResult->getConditionedModelCount())
-       {
-               res = SSM_S_OK;
-       }
-       else
-       {
-               res = SSM_S_FALSE;
-       }
+    SSMRESULT               res = SSM_E_FAIL;
+    IContextModel           *pContextModel = NULL;
+    IConditionedModel       *pConditionedModel = NULL;
+
+    for (unsigned int i = 0 ; i < pConditionedQueryResult->getConditionedModelCount() ; i++)
+    {
+        std::vector<int>    temp_dataID;
+        result_model        temp_result;
+        SSM_CLEANUP_ASSERT(pConditionedQueryResult->getConditionedContextModel(i, &pConditionedModel));
+        SSM_CLEANUP_ASSERT(pConditionedModel->getAffectedData(&temp_dataID));
+
+        if (temp_dataID.size() == 0)
+        {
+            break;
+        }
+
+        SSM_CLEANUP_ASSERT(pConditionedModel->getBaseContextModel(&pContextModel));
+        temp_result.modelID = pContextModel->getModelId();
+        temp_result.dataId = temp_dataID;
+        temp_result.modelName = pContextModel->getModelName();
+        resultData->push_back(temp_result);
+        SAFE_RELEASE(pConditionedModel);
+        SAFE_RELEASE(pContextModel);
+    }
+
+    if (resultData->size() == pConditionedQueryResult->getConditionedModelCount())
+    {
+        res = SSM_S_OK;
+    }
+    else
+    {
+        res = SSM_S_FALSE;
+    }
 
 CLEANUP:
-       SAFE_RELEASE(pConditionedModel);
-       SAFE_RELEASE(pContextModel);
-       return res;
+    SAFE_RELEASE(pConditionedModel);
+    SAFE_RELEASE(pContextModel);
+    return res;
 }
 
-SSMRESULT CQueryEngine::onConditionedQueryEvent(IN int userTriggerId, IN IConditionedQueryResult *pConditionedQueryResult)
+SSMRESULT CQueryEngine::onConditionedQueryEvent(IN int userTriggerId,
+        IN IConditionedQueryResult *pConditionedQueryResult)
 {
-       SSMRESULT                                       res = SSM_E_FAIL;
-       std::vector<result_model>       result;
+    SSMRESULT                   res = SSM_E_FAIL;
+    std::vector<result_model>   result;
 
-       SSM_CLEANUP_ASSERT(validateQueryResult(pConditionedQueryResult, &result));
-       SSM_CLEANUP_ASSERT(processQueryResult(userTriggerId, &result));
+    SSM_CLEANUP_ASSERT(validateQueryResult(pConditionedQueryResult, &result));
+    SSM_CLEANUP_ASSERT(processQueryResult(userTriggerId, &result));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-void CQueryEngine::onExecute(voidpArg)
+void CQueryEngine::onExecute(void *pArg)
 {
-       int *pData = (int*)pArg;
-
-       switch(pData[0])
-       {
-       case EVENT_TYPE_INNER:
-               processQueryResult(pData[1], (std::vector<result_model> *)pData[2]);
-               break;
-
-       case EVENT_TYPE_OUTER:
-               if(m_pQueryEngineEvent != NULL)
-               {
-                       m_pQueryEngineEvent->onQueryEngineEvent(pData[1], (IDataReader *)pData[2]);
-               }               
-               break;
-
-       default:
-               break;
-       }
+    int *pData = (int *)pArg;
+
+    switch (pData[0])
+    {
+        case EVENT_TYPE_INNER:
+            processQueryResult(pData[1], (std::vector<result_model> *)pData[2]);
+            break;
+
+        case EVENT_TYPE_OUTER:
+            if (m_pQueryEngineEvent != NULL)
+            {
+                m_pQueryEngineEvent->onQueryEngineEvent(pData[1], (IDataReader *)pData[2]);
+            }
+            break;
+
+        default:
+            break;
+    }
 }
 
-void CQueryEngine::onTerminate(voidpArg)
+void CQueryEngine::onTerminate(void *pArg)
 {
-       int *pData = (int*)pArg;
-       std::vector<result_model>       *pResult = NULL;
-       CDataReader                                     *pDataReader = NULL;
-
-       switch(pData[0])
-       {
-       case EVENT_TYPE_INNER:
-               pResult = (std::vector<result_model> *)(((int*)pArg)[2]);
-               SAFE_DELETE(pResult);
-               break;
-
-       case EVENT_TYPE_OUTER:
-               pDataReader = (CDataReader*)(((int*)pArg)[2]);
-               SAFE_DELETE(pDataReader);
-               break;
-
-       default:
-               break;
-       }
-       SAFE_ARRAY_DELETE(pData);
+    int *pData = (int *)pArg;
+    std::vector<result_model>   *pResult = NULL;
+    CDataReader                 *pDataReader = NULL;
+
+    switch (pData[0])
+    {
+        case EVENT_TYPE_INNER:
+            pResult = (std::vector<result_model> *)(((int *)pArg)[2]);
+            SAFE_DELETE(pResult);
+            break;
+
+        case EVENT_TYPE_OUTER:
+            pDataReader = (CDataReader *)(((int *)pArg)[2]);
+            SAFE_DELETE(pDataReader);
+            break;
+
+        default:
+            break;
+    }
+    SAFE_ARRAY_DELETE(pData);
 }
 
 SSMRESULT CQueryEngine::executeContextQuery(IN std::string contextQuery, OUT int *cqid)
 {
-       SSMRESULT                               res = SSM_E_FAIL;
-       IConditionedQuery               *pConditionedQuery = NULL;
-       IConditionedQueryResult *pConditionedQueryResult = NULL;
-       QueryCondition                  queryConditions;
-       CContextQuery                   *clsContextQuery = NULL;
-       Token                                   token;
-       CCQLParser                              cqlParser;
-       IContextModel::ActivationType   queryCommandType;
-
-       cqlParser.parse(contextQuery, &token);
-       
-       if (!cqlParser.check_grammer(&token))
-       {
-               res = SSM_E_FAIL;
-               goto CLEANUP;
-       }
-
-       clsContextQuery = new CContextQuery();
-       SSM_CLEANUP_NULL_ASSERT(clsContextQuery);
-       SSM_CLEANUP_ASSERT(clsContextQuery->initialize(token));
-       clsContextQuery->make_QueryCondition(&queryConditions);
-       
-       if (CCQLParser::tolower(token.child_token[0].name) == "subscribe")
-       {
-               queryCommandType = IContextModel::ACTIVATION_TYPE_SUBSCRIBE;
-       }
-       else
-       {
-               queryCommandType = IContextModel::ACTIVATION_TYPE_GET;
-       }
-
-       SSM_CLEANUP_ASSERT(m_pPropagationEngine->createConditionedQuery(queryCommandType,
-               &queryConditions, this, &pConditionedQuery));
-
-       m_mtxQueries.lock();
-       pConditionedQuery->addRef();
-       m_conditionedQueries[m_cqid] = pConditionedQuery;
-       m_contextQueries[m_cqid] = clsContextQuery;
-       m_mtxQueries.unlock();
-
-       if(pConditionedQuery->hasAllConditionedModels() == true)
-       {
-               std::vector<result_model>       *pResult = NULL;
-
-               SSM_CLEANUP_ASSERT(pConditionedQuery->getConditionedQueryResult(&pConditionedQueryResult));
-               pResult = new std::vector<result_model>();
-               if(validateQueryResult(pConditionedQueryResult, pResult) == SSM_S_OK)
-               {
-                       //We have valid data, let's deliver to application.
-                       int *pData = new int[3];
-                       pData[0] = EVENT_TYPE_INNER;
-                       pData[1] = m_cqid;
-                       pData[2] = (int)pResult;
-
-                       m_pTasker->addTask(this, (void*)pData);
-               }
-               else
-               {
-                       SAFE_DELETE(pResult);
-                       if(queryCommandType == IContextModel::ACTIVATION_TYPE_GET)
-                       {
-                               //There is no valid data. let's request new one
-                               SSM_CLEANUP_ASSERT(pConditionedQuery->activateTriggers(m_cqid));
-                       }
-               }
-       }
-       else
-       {
-               if(queryCommandType == IContextModel::ACTIVATION_TYPE_GET)
-               {
-                       //There is no models such name
-                       SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-               }
-       }
-
-       //Every subscribe command must request new data to models
-       if(queryCommandType == IContextModel::ACTIVATION_TYPE_SUBSCRIBE)
-       {
-               SSM_CLEANUP_ASSERT(pConditionedQuery->activateTriggers(m_cqid));
-       }
-
-       *cqid = m_cqid++;
+    SSMRESULT               res = SSM_E_FAIL;
+    IConditionedQuery       *pConditionedQuery = NULL;
+    IConditionedQueryResult *pConditionedQueryResult = NULL;
+    QueryCondition          queryConditions;
+    CContextQuery           *clsContextQuery = NULL;
+    Token                   token;
+    CCQLParser              cqlParser;
+    IContextModel::ActivationType   queryCommandType;
+
+    cqlParser.parse(contextQuery, &token);
+
+    if (!cqlParser.check_grammer(&token))
+    {
+        res = SSM_E_FAIL;
+        goto CLEANUP;
+    }
+
+    clsContextQuery = new CContextQuery();
+    SSM_CLEANUP_NULL_ASSERT(clsContextQuery);
+    SSM_CLEANUP_ASSERT(clsContextQuery->initialize(token));
+    clsContextQuery->make_QueryCondition(&queryConditions);
+
+    if (CCQLParser::tolower(token.child_token[0].name) == "subscribe")
+    {
+        queryCommandType = IContextModel::ACTIVATION_TYPE_SUBSCRIBE;
+    }
+    else
+    {
+        queryCommandType = IContextModel::ACTIVATION_TYPE_GET;
+    }
+
+    SSM_CLEANUP_ASSERT(m_pPropagationEngine->createConditionedQuery(queryCommandType,
+                       &queryConditions, this, &pConditionedQuery));
+
+    m_mtxQueries.lock();
+    pConditionedQuery->addRef();
+    m_conditionedQueries[m_cqid] = pConditionedQuery;
+    m_contextQueries[m_cqid] = clsContextQuery;
+    m_mtxQueries.unlock();
+
+    if (pConditionedQuery->hasAllConditionedModels() == true)
+    {
+        std::vector<result_model>   *pResult = NULL;
+
+        SSM_CLEANUP_ASSERT(pConditionedQuery->getConditionedQueryResult(&pConditionedQueryResult));
+        pResult = new std::vector<result_model>();
+        if (validateQueryResult(pConditionedQueryResult, pResult) == SSM_S_OK)
+        {
+            //We have valid data, let's deliver to application.
+            int *pData = new int[3];
+            pData[0] = EVENT_TYPE_INNER;
+            pData[1] = m_cqid;
+            pData[2] = (int)pResult;
+
+            m_pTasker->addTask(this, (void *)pData);
+        }
+        else
+        {
+            SAFE_DELETE(pResult);
+            if (queryCommandType == IContextModel::ACTIVATION_TYPE_GET)
+            {
+                //There is no valid data. let's request new one
+                SSM_CLEANUP_ASSERT(pConditionedQuery->activateTriggers(m_cqid));
+            }
+        }
+    }
+    else
+    {
+        if (queryCommandType == IContextModel::ACTIVATION_TYPE_GET)
+        {
+            //There is no models such name
+            SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+        }
+    }
+
+    //Every subscribe command must request new data to models
+    if (queryCommandType == IContextModel::ACTIVATION_TYPE_SUBSCRIBE)
+    {
+        SSM_CLEANUP_ASSERT(pConditionedQuery->activateTriggers(m_cqid));
+    }
+
+    *cqid = m_cqid++;
 
 CLEANUP:
-       SAFE_RELEASE(pConditionedQuery);
-       SAFE_RELEASE(pConditionedQueryResult);
-       return res;
+    SAFE_RELEASE(pConditionedQuery);
+    SAFE_RELEASE(pConditionedQueryResult);
+    return res;
 }
 
 //TODO: Registration with multiple instance support
 SSMRESULT CQueryEngine::registerQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent)
 {
-       m_pQueryEngineEvent = pQueryEngineEvent;
-       return SSM_S_OK;
+    m_pQueryEngineEvent = pQueryEngineEvent;
+    return SSM_S_OK;
 }
 
 SSMRESULT CQueryEngine::unregisterQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent)
 {
-       if(m_pQueryEngineEvent == pQueryEngineEvent)
-       {
-               m_pQueryEngineEvent = NULL;
-               return SSM_S_OK;
-       }
+    if (m_pQueryEngineEvent == pQueryEngineEvent)
+    {
+        m_pQueryEngineEvent = NULL;
+        return SSM_S_OK;
+    }
 
-       return SSM_E_FAIL;
+    return SSM_E_FAIL;
 }
 
 SSMRESULT CQueryEngine::killContextQuery(IN int cqid)
 {
-       SSMRESULT res = SSM_E_FAIL;
-
-       std::map<int, IConditionedQuery*>::iterator itorConditionedQueries;
-       std::map<int, CContextQuery*>::iterator itorContextQuries;
-
-       m_mtxQueries.lock();
-       itorConditionedQueries = m_conditionedQueries.find(cqid);
-       itorContextQuries = m_contextQueries.find(cqid);
-
-       if(itorConditionedQueries != m_conditionedQueries.end())
-       {
-               SSM_CLEANUP_ASSERT(itorConditionedQueries->second->deactivateTriggers());
-               itorConditionedQueries->second->release();
-               m_conditionedQueries.erase(itorConditionedQueries);
-       }
-       
-       if(itorContextQuries != m_contextQueries.end())
-       {
-               SAFE_DELETE(itorContextQuries->second);
-               m_contextQueries.erase(itorContextQuries);
-       }
+    SSMRESULT res = SSM_E_FAIL;
+
+    std::map<int, IConditionedQuery *>::iterator itorConditionedQueries;
+    std::map<int, CContextQuery *>::iterator itorContextQuries;
+
+    m_mtxQueries.lock();
+    itorConditionedQueries = m_conditionedQueries.find(cqid);
+    itorContextQuries = m_contextQueries.find(cqid);
+
+    if (itorConditionedQueries != m_conditionedQueries.end())
+    {
+        SSM_CLEANUP_ASSERT(itorConditionedQueries->second->deactivateTriggers());
+        itorConditionedQueries->second->release();
+        m_conditionedQueries.erase(itorConditionedQueries);
+    }
+
+    if (itorContextQuries != m_contextQueries.end())
+    {
+        SAFE_DELETE(itorContextQuries->second);
+        m_contextQueries.erase(itorContextQuries);
+    }
 
 CLEANUP:
-       m_mtxQueries.unlock();
-       return res;
+    m_mtxQueries.unlock();
+    return res;
 }
index 31f4ed5..a1d96c3 100644 (file)
 /**
 * @class    CQueryEngine
 * @brief    CQueryEngine Interface
-*                       This class manages ContextQuery.
+*            This class manages ContextQuery.
 *
-* @see      
-*                      CObject<CQueryEngine>   *pQueryEngine;
-*                      CreateInstance(OID_IQueryEngineInternal, (IBase**)&pQueryEngine);
-*                      pQeuryEngine->ExecuteContextQuery(contextquery,cqid);
+* @see
+*           CObject<CQueryEngine>   *pQueryEngine;
+*           CreateInstance(OID_IQueryEngineInternal, (IBase**)&pQueryEngine);
+*           pQeuryEngine->ExecuteContextQuery(contextquery,cqid);
 */
 class CQueryEngine :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IQueryEngineInternal
-       , public IThreadClient
-       , public IConditionedQueryEvent
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IQueryEngineInternal
+    , public IThreadClient
+    , public IConditionedQueryEvent
 {
-private:
-       CObjectPtr<IPropagationEngine>          m_pPropagationEngine;
-       std::map<int, IConditionedQuery*>       m_conditionedQueries;
-       CSimpleMutex                                            m_mtxQueries;
-       int                                                                     m_cqid;
-       IQueryEngineEvent                                       *m_pQueryEngineEvent;
-       std::map<int, CContextQuery*>           m_contextQueries;
-       CObjectPtr<ITasker>                                     m_pTasker;
+    private:
+        CObjectPtr<IPropagationEngine>      m_pPropagationEngine;
+        std::map<int, IConditionedQuery *>   m_conditionedQueries;
+        CSimpleMutex                        m_mtxQueries;
+        int                                 m_cqid;
+        IQueryEngineEvent                   *m_pQueryEngineEvent;
+        std::map<int, CContextQuery *>       m_contextQueries;
+        CObjectPtr<ITasker>                 m_pTasker;
 
-private:
-       SSMRESULT processQueryResult(IN int userTriggerId, IN std::vector<result_model> *result);
-       SSMRESULT validateQueryResult(IN IConditionedQueryResult *pConditionedQueryResult, OUT std::vector<result_model> *resultData);
+    private:
+        SSMRESULT processQueryResult(IN int userTriggerId, IN std::vector<result_model> *result);
+        SSMRESULT validateQueryResult(IN IConditionedQueryResult *pConditionedQueryResult,
+                                      OUT std::vector<result_model> *resultData);
 
-public:
-       enum EventType {EVENT_TYPE_INNER, EVENT_TYPE_OUTER};
-       SSMRESULT finalConstruct();
-       void finalRelease();
-       void onExecute(void* pArg);
-       void onTerminate(void* pArg);
-       
-       /**
-       * @fn onConditionedQueryEvent
-       * @brief IConditionedQueryEvent interface's event callbacks for receiving query results
-       *
-       * @param [in] std::string ContextQuery - Entered ContetxQuery
-       * @param [out] int* cqid - ID of ContextQuery
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT onConditionedQueryEvent(IN int userTriggerId, IN IConditionedQueryResult *pConditionedQueryResult);
+    public:
+        enum EventType {EVENT_TYPE_INNER, EVENT_TYPE_OUTER};
+        SSMRESULT finalConstruct();
+        void finalRelease();
+        void onExecute(void *pArg);
+        void onTerminate(void *pArg);
 
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
+        /**
+        * @fn onConditionedQueryEvent
+        * @brief IConditionedQueryEvent interface's event callbacks for receiving query results
+        *
+        * @param [in] std::string ContextQuery - Entered ContetxQuery
+        * @param [out] int* cqid - ID of ContextQuery
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT onConditionedQueryEvent(IN int userTriggerId,
+                                          IN IConditionedQueryResult *pConditionedQueryResult);
 
-               if(IsEqualOID(objectID, OID_IQueryEngineInternal))
-               {
-                       IBase *pBase = (IQueryEngineInternal*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
 
-               return SSM_E_NOINTERFACE;
-       }
+            if (IsEqualOID(objectID, OID_IQueryEngineInternal))
+            {
+                IBase *pBase = (IQueryEngineInternal *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
 
-       /**
-       * @fn executeContextQuery
-       * @brief Execute ContextQuery and return ContextQuery ID
-       *
-       * @param [in] std::string ContextQuery - Entered ContetxQuery
-       * @param [out] int* cqid - ID of ContextQuery
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT executeContextQuery(IN std::string contextQuery, OUT int *cqid);
+            return SSM_E_NOINTERFACE;
+        }
 
-       //TODO: Registration with multiple instance support
-       /**
-       * @fn registerQueryEvent
-       * @brief Register QueryEngineEvent to QueryEngine.
-       *
-       * @param [in] IQueryEngineEvent* pQueryEngineEvent - register QueryEngineEvent
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT registerQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent);
+        /**
+        * @fn executeContextQuery
+        * @brief Execute ContextQuery and return ContextQuery ID
+        *
+        * @param [in] std::string ContextQuery - Entered ContetxQuery
+        * @param [out] int* cqid - ID of ContextQuery
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT executeContextQuery(IN std::string contextQuery, OUT int *cqid);
 
+        //TODO: Registration with multiple instance support
+        /**
+        * @fn registerQueryEvent
+        * @brief Register QueryEngineEvent to QueryEngine.
+        *
+        * @param [in] IQueryEngineEvent* pQueryEngineEvent - register QueryEngineEvent
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT registerQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent);
 
-       /**
-       * @fn unregisterQueryEvent
-       * @brief Unregister QueryEngineEvent to QueryEngine.
-       *
-       * @param [in] IQueryEngineEvent* pQueryEngineEvent - unregister QueryEngineEvent
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT unregisterQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent);
 
-       /**
-       * @fn killContextQuery
-       * @brief Kill registered ContextQuery according to cqid
-       *
-       * @param [in] int cqid - Context Query corresponding to the cqid will be terminated
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT killContextQuery(IN int cqid);
+        /**
+        * @fn unregisterQueryEvent
+        * @brief Unregister QueryEngineEvent to QueryEngine.
+        *
+        * @param [in] IQueryEngineEvent* pQueryEngineEvent - unregister QueryEngineEvent
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT unregisterQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent);
+
+        /**
+        * @fn killContextQuery
+        * @brief Kill registered ContextQuery according to cqid
+        *
+        * @param [in] int cqid - Context Query corresponding to the cqid will be terminated
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT killContextQuery(IN int cqid);
 };
 
 #endif /*_QueryEngine_H_*/
index cab19c9..5b1340f 100644 (file)
 #include "SSMInterface/SoftSensorManager.h"
 #include "Common/InternalInterface.h"
 
-static ISoftSensorManager              *g_pSoftSensorManager = NULL;
+static ISoftSensorManager       *g_pSoftSensorManager = NULL;
 
 SSMRESULT CreateQueryEngine(OUT IQueryEngine **ppQueryEngine)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
-       SSM_CLEANUP_ASSERT(g_pSoftSensorManager->createQueryEngine(ppQueryEngine));
+    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
+    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->createQueryEngine(ppQueryEngine));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 unsigned long ReleaseQueryEngine(IN IQueryEngine *pQueryEngine)
 {
-       if(pQueryEngine == NULL)
-       {
-               return -1;
-       }
-
-       if (g_pSoftSensorManager == NULL)
-       {
-               return -1;
-       }
-       
-       return g_pSoftSensorManager->releaseQueryEngine(pQueryEngine);
+    if (pQueryEngine == NULL)
+    {
+        return -1;
+    }
+
+    if (g_pSoftSensorManager == NULL)
+    {
+        return -1;
+    }
+
+    return g_pSoftSensorManager->releaseQueryEngine(pQueryEngine);
 }
 
 SSMRESULT InitializeSSMCore(IN std::string xmlDescription)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstanceRepo());
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_ISoftSensorManager, (IBase**)&g_pSoftSensorManager));
-       SSM_CLEANUP_ASSERT(g_pSoftSensorManager->initializeCore(xmlDescription));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstanceRepo());
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_ISoftSensorManager, (IBase **)&g_pSoftSensorManager));
+    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->initializeCore(xmlDescription));
 
 CLEANUP:
-       if(res != SSM_S_OK)
-       {
-               SAFE_RELEASE(g_pSoftSensorManager);
-       }
-       return res;
+    if (res != SSM_S_OK)
+    {
+        SAFE_RELEASE(g_pSoftSensorManager);
+    }
+    return res;
 }
 
 SSMRESULT StartSSMCore()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
-       SSM_CLEANUP_ASSERT(g_pSoftSensorManager->startCore());
+    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
+    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->startCore());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT StopSSMCore()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
-       SSM_CLEANUP_ASSERT(g_pSoftSensorManager->stopCore());
+    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
+    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->stopCore());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT TerminateSSMCore(bool factoryResetFlag)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
+
+    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
+    SSM_CLEANUP_ASSERT(g_pSoftSensorManager->terminateCore(factoryResetFlag));
 
-       SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
-       SSM_CLEANUP_ASSERT(g_pSoftSensorManager->terminateCore(factoryResetFlag));
-       
 CLEANUP:
-       SAFE_RELEASE(g_pSoftSensorManager);
-       DestroyGlobalInstanceRepo();
-       return res;
+    SAFE_RELEASE(g_pSoftSensorManager);
+    DestroyGlobalInstanceRepo();
+    return res;
 }
 
 const char *GetSSMError(SSMRESULT res)
 {
-       const char *msg = NULL;
+    const char *msg = NULL;
 
-       switch(res)
-       {
-       case SSM_S_OK:
-               msg = "Success";
-               break;
+    switch (res)
+    {
+        case SSM_S_OK:
+            msg = "Success";
+            break;
 
-       case SSM_E_POINTER:
-               msg = "SSM_E_POINTER";
-               break;
+        case SSM_E_POINTER:
+            msg = "SSM_E_POINTER";
+            break;
 
-       case SSM_E_OUTOFMEMORY:
-               msg = "SSM_E_OUTOFMEMORY";
-               break;
+        case SSM_E_OUTOFMEMORY:
+            msg = "SSM_E_OUTOFMEMORY";
+            break;
 
-       case SSM_E_FAIL:
-               msg = "SSM_E_FAIL";
-               break;
+        case SSM_E_FAIL:
+            msg = "SSM_E_FAIL";
+            break;
 
-       case SSM_E_NOINTERFACE:
-               msg = "SSM_E_NOINTERFACE";
-               break;
+        case SSM_E_NOINTERFACE:
+            msg = "SSM_E_NOINTERFACE";
+            break;
 
-       case SSM_E_NOTIMPL:
-               msg = "SSM_E_NOTIMPL";
-               break;
+        case SSM_E_NOTIMPL:
+            msg = "SSM_E_NOTIMPL";
+            break;
 
-       default:
-               msg = "Not defined";
-               break;
-       }
+        default:
+            msg = "Not defined";
+            break;
+    }
 
-       return msg;
+    return msg;
 }
 
-SSMRESULT GetInstalledModelList(OUT std::vector<ISSMResource*> *pList)
+SSMRESULT GetInstalledModelList(OUT std::vector<ISSMResource *> *pList)
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
-       g_pSoftSensorManager->getInstalledModelList(pList);
+    SSM_CLEANUP_NULL_ASSERT(g_pSoftSensorManager);
+    g_pSoftSensorManager->getInstalledModelList(pList);
 
 CLEANUP:
-       return res;
+    return res;
 }
index 3650551..f109cfb 100644 (file)
 
 enum SSMRESULT
 {
-       SSM_S_OK
-       , SSM_S_FALSE
-       , SSM_E_POINTER
-       , SSM_E_OUTOFMEMORY
-       , SSM_E_FAIL
-       , SSM_E_NOINTERFACE
-       , SSM_E_NOTIMPL
+    SSM_S_OK
+    , SSM_S_FALSE
+    , SSM_E_POINTER
+    , SSM_E_OUTOFMEMORY
+    , SSM_E_FAIL
+    , SSM_E_NOINTERFACE
+    , SSM_E_NOTIMPL
 };
 
 /**
 * @class    IModelData
 * @brief    IModelData Interface
-*                       This class represents context model data package
+*            This class represents context model data package
 *
 * @see
 */
 class IModelData
 {
-public:
-       /**
-       * @fn     getDataId
-       * @brief Get affected DataId. ContextModel has plenty of data so \n
-       *                 returned data is matched from given condition
-       *
-       * @param None
-       * 
-       * @return int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual int getDataId() = 0;
+    public:
+        /**
+        * @fn     getDataId
+        * @brief Get affected DataId. ContextModel has plenty of data so \n
+        *         returned data is matched from given condition
+        *
+        * @param None
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual int getDataId() = 0;
 
-       /**
-       * @fn     GetPropertyCount
-       * @brief ContextModel has at least one property that contains data \n
-       *                 property is described from its specification.
-       *
-       * @param None
-       * 
-       * @return int
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual int getPropertyCount() = 0;
+        /**
+        * @fn     GetPropertyCount
+        * @brief ContextModel has at least one property that contains data \n
+        *         property is described from its specification.
+        *
+        * @param None
+        *
+        * @return int
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual int getPropertyCount() = 0;
 
-       /**
-       * @fn     getPropertyName
-       * @brief Retrieve propertyName
-       *
-       * @param [in] int propertyIndex - index of property to read
-       * 
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       virtual std::string getPropertyName(IN int propertyIndex) = 0;
+        /**
+        * @fn     getPropertyName
+        * @brief Retrieve propertyName
+        *
+        * @param [in] int propertyIndex - index of property to read
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual std::string getPropertyName(IN int propertyIndex) = 0;
 
-       /**
-       * @fn     getPropertyValue
-       * @brief Retrieve propertyValue
-       *
-       * @param [in] int propertyIndex - index of property to read
-       * 
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual std::string getPropertyValue(IN int propertyIndex) = 0;
+        /**
+        * @fn     getPropertyValue
+        * @brief Retrieve propertyValue
+        *
+        * @param [in] int propertyIndex - index of property to read
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual std::string getPropertyValue(IN int propertyIndex) = 0;
 
-       /**
-       * @fn     getPropertyValueByName
-       * @brief Retrieve propertyValue using given name
-       *
-       * @param [in] std::string propertyName - property name looking for
-       * 
-       * @return std::string
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual std::string getPropertyValueByName(IN std::string propertyName) = 0;
-protected:
-       virtual ~IModelData(){};
+        /**
+        * @fn     getPropertyValueByName
+        * @brief Retrieve propertyValue using given name
+        *
+        * @param [in] std::string propertyName - property name looking for
+        *
+        * @return std::string
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual std::string getPropertyValueByName(IN std::string propertyName) = 0;
+    protected:
+        virtual ~IModelData() {};
 };
 
 /**
 * @class    IDataReader
 * @brief    IDataReader Interface
-*                       This class represents context model data package's reader
+*            This class represents context model data package's reader
 *
 * @see
 */
 class IDataReader
 {
-public:
-       /**
-       * @fn     getAffectedModels
-       * @brief Get affected ContextModels. The CQL can specify multiple ContextModels for retrieving data.
-       *
-       * @param [out] std::vector<std::string> *pAffectedModels - affected ContextModel list
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT getAffectedModels(OUT std::vector<std::string> *pAffectedModels) = 0;
+    public:
+        /**
+        * @fn     getAffectedModels
+        * @brief Get affected ContextModels. The CQL can specify multiple ContextModels for retrieving data.
+        *
+        * @param [out] std::vector<std::string> *pAffectedModels - affected ContextModel list
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getAffectedModels(OUT std::vector<std::string> *pAffectedModels) = 0;
 
-       /**
-       * @fn     getModelDataCount
-       * @brief Get affected data count. There are multiple data can exist from given condition.
-       *
-       * @param [in] std::string modelName - affected ContextModel name
-       *
-       * @param [out] int *pDataCount - affected dataId count
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT getModelDataCount(IN std::string modelName, OUT int *pDataCount) = 0;
+        /**
+        * @fn     getModelDataCount
+        * @brief Get affected data count. There are multiple data can exist from given condition.
+        *
+        * @param [in] std::string modelName - affected ContextModel name
+        *
+        * @param [out] int *pDataCount - affected dataId count
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getModelDataCount(IN std::string modelName, OUT int *pDataCount) = 0;
 
-       /**
-       * @fn     getModelData
-       * @brief Get actual Context Model data
-       *
-       * @param [in] std::string modelName - affected ContextModel name
-       *                               
-       *
-       * @param [in] int dataIndex - affected dataId index
-       *                               
-       * 
-       * @param [out] IModelData **ppModelData - affected ContextModel data reader
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT getModelData(IN std::string modelName, IN int dataIndex, OUT IModelData **ppModelData) = 0;
-protected:
-       virtual ~IDataReader(){};
+        /**
+        * @fn     getModelData
+        * @brief Get actual Context Model data
+        *
+        * @param [in] std::string modelName - affected ContextModel name
+        *
+        *
+        * @param [in] int dataIndex - affected dataId index
+        *
+        *
+        * @param [out] IModelData **ppModelData - affected ContextModel data reader
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT getModelData(IN std::string modelName, IN int dataIndex,
+                                       OUT IModelData **ppModelData) = 0;
+    protected:
+        virtual ~IDataReader() {};
 };
 
 /**
 * @class    IQueryEngineEvent
 * @brief    IQueryEngineEvent Interface
-*                       This class represents Query Engine's event that contains results
+*            This class represents Query Engine's event that contains results
 *
 * @see
 */
 class IQueryEngineEvent
 {
-public:
-       /**
-       * @fn     onQueryEngineEvent
-       * @brief Transmit result of SSMCore to Application layer
-       *
-       * @param [in] int cqid - entered ContextQuery ID
-       *            
-       * @param [in] IDataReader *pResult - result of SSMCore
-       *            
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult) = 0;
-protected:
-       virtual ~IQueryEngineEvent(){};
+    public:
+        /**
+        * @fn     onQueryEngineEvent
+        * @brief Transmit result of SSMCore to Application layer
+        *
+        * @param [in] int cqid - entered ContextQuery ID
+        *
+        * @param [in] IDataReader *pResult - result of SSMCore
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult) = 0;
+    protected:
+        virtual ~IQueryEngineEvent() {};
 };
 
 /**
 * @class    IQueryEngine
 * @brief    IQueryEngine Interface
-*                       This class represents main interface of Query Engine
+*            This class represents main interface of Query Engine
 *
 * @see
 */
 class IQueryEngine
 {
-public:
-       /**
-       * @fn     executeContextQuery
-       * @brief Execute ContextQuery and return ContextQuery ID
-       *
-       * @param [in] std::string ContextQuery - Entered ContetxQuery
-       *
-       * @param [out] int *cqid - ID of ContextQuery
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT executeContextQuery(IN std::string contextQuery, OUT int *cqid) = 0;
+    public:
+        /**
+        * @fn     executeContextQuery
+        * @brief Execute ContextQuery and return ContextQuery ID
+        *
+        * @param [in] std::string ContextQuery - Entered ContetxQuery
+        *
+        * @param [out] int *cqid - ID of ContextQuery
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT executeContextQuery(IN std::string contextQuery, OUT int *cqid) = 0;
 
-       /**
-       * @fn     registerQueryEvent
-       * @brief Register QueryEngineEvent to QueryEngine.
-       *
-       * @param [in] IQueryEngineEvent *pQueryEngineEvent - Register QueryEngineEvent
-       *            
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT registerQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent) = 0;
+        /**
+        * @fn     registerQueryEvent
+        * @brief Register QueryEngineEvent to QueryEngine.
+        *
+        * @param [in] IQueryEngineEvent *pQueryEngineEvent - Register QueryEngineEvent
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT registerQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent) = 0;
 
-       /**
-       * @fn     unregisterQueryEvent
-       * @brief Unregister QueryEngineEvent to QueryEngine.
-       *
-       * @param [in] IQueryEngineEvent *pQueryEngineEvent - Unregister QueryEngineEvent
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT unregisterQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent) = 0;
+        /**
+        * @fn     unregisterQueryEvent
+        * @brief Unregister QueryEngineEvent to QueryEngine.
+        *
+        * @param [in] IQueryEngineEvent *pQueryEngineEvent - Unregister QueryEngineEvent
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT unregisterQueryEvent(IN IQueryEngineEvent *pQueryEngineEvent) = 0;
 
-       /**
-       * @fn    killContextQuery
-       * @brief Kill registered ContextQuery according to cqid
-       *
-       * @param [in] int cqid - Context query corresponding to the cqid will be terminated
-       *           
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       virtual SSMRESULT killContextQuery(IN int cqid) = 0;
-protected:
-       virtual ~IQueryEngine(){};
+        /**
+        * @fn    killContextQuery
+        * @brief Kill registered ContextQuery according to cqid
+        *
+        * @param [in] int cqid - Context query corresponding to the cqid will be terminated
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual SSMRESULT killContextQuery(IN int cqid) = 0;
+    protected:
+        virtual ~IQueryEngine() {};
 };
 
 #ifdef __cplusplus
@@ -290,111 +291,111 @@ extern "C"
 {
 #endif // __cplusplus
 
-       /**
-       * @fn    CreateQueryEngine
-       * @brief Create QueryEngine instance.
-       *
-       * @param [out] IQueryEngine **ppQueryEngine - address of QueryEngine
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC SSMRESULT CreateQueryEngine(OUT IQueryEngine **ppQueryEngine);
+/**
+* @fn    CreateQueryEngine
+* @brief Create QueryEngine instance.
+*
+* @param [out] IQueryEngine **ppQueryEngine - address of QueryEngine
+*
+* @return SSMRESULT
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC SSMRESULT CreateQueryEngine(OUT IQueryEngine **ppQueryEngine);
 
-       /**
-       * @fn    ReleaseQueryEngine
-       * @brief Release QueryEngine instance.
-       *
-       * @param [in] IQueryEngine *pQueryEngine - Address of QueryEngine
-       *
-       * @return unsigned long
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC unsigned long ReleaseQueryEngine(IN IQueryEngine *pQueryEngine);
+/**
+* @fn    ReleaseQueryEngine
+* @brief Release QueryEngine instance.
+*
+* @param [in] IQueryEngine *pQueryEngine - Address of QueryEngine
+*
+* @return unsigned long
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC unsigned long ReleaseQueryEngine(IN IQueryEngine *pQueryEngine);
 
 
-       /**
-       * @fn    InitializeSSMCore
-       * @brief Initialize framework using given configuration
-       *
-       * @param [in] std::string xmlDescription - Framework specification described in XML
-       *           
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC SSMRESULT InitializeSSMCore(IN std::string xmlDescription);
+/**
+* @fn    InitializeSSMCore
+* @brief Initialize framework using given configuration
+*
+* @param [in] std::string xmlDescription - Framework specification described in XML
+*
+*
+* @return SSMRESULT
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC SSMRESULT InitializeSSMCore(IN std::string xmlDescription);
 
-       /**
-       * @fn    StartSSMCore
-       * @brief Start framework that allows other devices discover and communication
-       *
-       * @param None
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC SSMRESULT StartSSMCore();
+/**
+* @fn    StartSSMCore
+* @brief Start framework that allows other devices discover and communication
+*
+* @param None
+*
+* @return SSMRESULT
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC SSMRESULT StartSSMCore();
 
-       /**
-       * @fn    StopSSMCore
-       * @brief Stop framework
-       *
-       * @param None
-       * 
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC SSMRESULT StopSSMCore();
+/**
+* @fn    StopSSMCore
+* @brief Stop framework
+*
+* @param None
+*
+* @return SSMRESULT
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC SSMRESULT StopSSMCore();
 
-       /**
-       * @fn    TerminateSSMCore
-       * @brief Terminate framework, return all allocated resources
-       *
-       * @param [in] bool factoryResetFlag - Set true if framework needs to reset
-       *            
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC SSMRESULT TerminateSSMCore(IN bool factoryResetFlag = false);
+/**
+* @fn    TerminateSSMCore
+* @brief Terminate framework, return all allocated resources
+*
+* @param [in] bool factoryResetFlag - Set true if framework needs to reset
+*
+* @return SSMRESULT
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC SSMRESULT TerminateSSMCore(IN bool factoryResetFlag = false);
 
-       /**
-       * @fn    GetErrorMessage
-       * @brief Prints Error message from SSMRESULT error code
-       *
-       * @param [in] SSMRESULT res - return code
-       *
-       * @return const char *
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC const char *GetSSMError(IN SSMRESULT res);
+/**
+* @fn    GetErrorMessage
+* @brief Prints Error message from SSMRESULT error code
+*
+* @param [in] SSMRESULT res - return code
+*
+* @return const char *
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC const char *GetSSMError(IN SSMRESULT res);
 
-       /**
-       * @fn    GetInstalledModelList
-       * @brief Gets all installed models from local and remote
-       *
-       * @param [out] std::vector<ISSMResource> *pList - List of installed context model
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see
-       */
-       INTERFACE_DECLSPEC SSMRESULT GetInstalledModelList(OUT std::vector<ISSMResource*> *pList);
+/**
+* @fn    GetInstalledModelList
+* @brief Gets all installed models from local and remote
+*
+* @param [out] std::vector<ISSMResource> *pList - List of installed context model
+*
+* @return SSMRESULT
+* @warning
+* @exception
+* @see
+*/
+INTERFACE_DECLSPEC SSMRESULT GetInstalledModelList(OUT std::vector<ISSMResource *> *pList);
 
 #ifdef __cplusplus
 }
index d66096f..23aabed 100644 (file)
@@ -32,371 +32,380 @@ JavaVM *g_JVM = NULL;
 #endif
 #define DETACH_CURRENT_THREAD(javaVM) javaVM->DetachCurrentThread()
 
-jclass                                         g_ClassQueryEngine = NULL;
-jclass                                         g_ClassDataReader = NULL;
-jclass                                         g_ClassModelData = NULL;
-jclass                                         g_ClassQueryEngineEvent = NULL;
+jclass                      g_ClassQueryEngine = NULL;
+jclass                      g_ClassDataReader = NULL;
+jclass                      g_ClassModelData = NULL;
+jclass                      g_ClassQueryEngineEvent = NULL;
 
-jclass                                         g_ClassReportReceiver = NULL;
-jobject                                                g_objReportReceiver = NULL;
+jclass                      g_ClassReportReceiver = NULL;
+jobject                     g_objReportReceiver = NULL;
 
 void ReportMessage(const char *tag, const char *msg)
 {
-       JNIEnv *env;
+    JNIEnv *env;
 
-       if(g_objReportReceiver == NULL)
-               return;
+    if (g_objReportReceiver == NULL)
+        return;
 
-       g_JVM->GetEnv((void**) &env, JNI_VERSION_1_6);
+    g_JVM->GetEnv((void **) &env, JNI_VERSION_1_6);
 
-       ATTACH_CURRENT_THREAD(g_JVM, env);
+    ATTACH_CURRENT_THREAD(g_JVM, env);
 
-       jmethodID midReportReceiver = 
-               env->GetMethodID(g_ClassReportReceiver, "OnMessageReceived", "(Ljava/lang/String;Ljava/lang/String;)V");
+    jmethodID midReportReceiver =
+        env->GetMethodID(g_ClassReportReceiver, "OnMessageReceived",
+                         "(Ljava/lang/String;Ljava/lang/String;)V");
 
-       jclass nonVIrtualObject = env->GetObjectClass(g_objReportReceiver);
+    jclass nonVIrtualObject = env->GetObjectClass(g_objReportReceiver);
 
-       env->CallNonvirtualVoidMethod(g_objReportReceiver, nonVIrtualObject, midReportReceiver, env->NewStringUTF(tag), env->NewStringUTF(msg));
-       
-       DETACH_CURRENT_THREAD(g_JVM);
+    env->CallNonvirtualVoidMethod(g_objReportReceiver, nonVIrtualObject, midReportReceiver,
+                                  env->NewStringUTF(tag), env->NewStringUTF(msg));
 
-       return;
+    DETACH_CURRENT_THREAD(g_JVM);
+
+    return;
 }
 
-class QueryEngineEventReceiver 
-       : public IQueryEngineEvent
+class QueryEngineEventReceiver
+    : public IQueryEngineEvent
 {
-private:
-       jobject                 m_objQueryEngineEvent;
-
-public:
-       QueryEngineEventReceiver()
-       {
-               m_objQueryEngineEvent = NULL;
-       }
-
-       ~QueryEngineEventReceiver()
-       {
-               if(m_objQueryEngineEvent != NULL)
-               {
-                       JNIEnv *env;
-                       g_JVM->GetEnv((void**) &env, JNI_VERSION_1_6);
-                       env->DeleteGlobalRef(m_objQueryEngineEvent);
-               }
-       }
-
-       void SetQueryEngineEventObj(jobject objQueryEngineEvent)
-       {
-               if(m_objQueryEngineEvent != NULL)
-               {
-                       JNIEnv *env;
-                       g_JVM->GetEnv((void**) &env, JNI_VERSION_1_6);
-                       env->DeleteGlobalRef(m_objQueryEngineEvent);
-               }
-
-               m_objQueryEngineEvent = objQueryEngineEvent;
-       }
-
-       SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult)
-       {
-               JNIEnv *env;
-               g_JVM->GetEnv((void**) &env, JNI_VERSION_1_6);
-
-               ATTACH_CURRENT_THREAD(g_JVM, env);
-
-               jmethodID midQueryEngineEvent = 
-                       env->GetMethodID(g_ClassQueryEngineEvent, "OnQueryEngineEvent", "(ILcom/sec/android/ssmcore/DataReader;)V");
-
-               jclass nonVIrtualObject = env->GetObjectClass(m_objQueryEngineEvent);
-
-               jmethodID cid_DataReader = env->GetMethodID(g_ClassDataReader, "<init>", "(I)V");
-
-               if(cid_DataReader == NULL)
-                       return SSM_E_FAIL;
-
-               env->CallNonvirtualVoidMethod(m_objQueryEngineEvent, nonVIrtualObject, midQueryEngineEvent, (jint)cqid, 
-                       env->NewObject(g_ClassDataReader, cid_DataReader, (jint)pResult));
-
-               DETACH_CURRENT_THREAD(g_JVM);
-
-               return SSM_S_OK;
-       }
+    private:
+        jobject         m_objQueryEngineEvent;
+
+    public:
+        QueryEngineEventReceiver()
+        {
+            m_objQueryEngineEvent = NULL;
+        }
+
+        ~QueryEngineEventReceiver()
+        {
+            if (m_objQueryEngineEvent != NULL)
+            {
+                JNIEnv *env;
+                g_JVM->GetEnv((void **) &env, JNI_VERSION_1_6);
+                env->DeleteGlobalRef(m_objQueryEngineEvent);
+            }
+        }
+
+        void SetQueryEngineEventObj(jobject objQueryEngineEvent)
+        {
+            if (m_objQueryEngineEvent != NULL)
+            {
+                JNIEnv *env;
+                g_JVM->GetEnv((void **) &env, JNI_VERSION_1_6);
+                env->DeleteGlobalRef(m_objQueryEngineEvent);
+            }
+
+            m_objQueryEngineEvent = objQueryEngineEvent;
+        }
+
+        SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult)
+        {
+            JNIEnv *env;
+            g_JVM->GetEnv((void **) &env, JNI_VERSION_1_6);
+
+            ATTACH_CURRENT_THREAD(g_JVM, env);
+
+            jmethodID midQueryEngineEvent =
+                env->GetMethodID(g_ClassQueryEngineEvent, "OnQueryEngineEvent",
+                                 "(ILcom/sec/android/ssmcore/DataReader;)V");
+
+            jclass nonVIrtualObject = env->GetObjectClass(m_objQueryEngineEvent);
+
+            jmethodID cid_DataReader = env->GetMethodID(g_ClassDataReader, "<init>", "(I)V");
+
+            if (cid_DataReader == NULL)
+                return SSM_E_FAIL;
+
+            env->CallNonvirtualVoidMethod(m_objQueryEngineEvent, nonVIrtualObject, midQueryEngineEvent,
+                                          (jint)cqid,
+                                          env->NewObject(g_ClassDataReader, cid_DataReader, (jint)pResult));
+
+            DETACH_CURRENT_THREAD(g_JVM);
+
+            return SSM_S_OK;
+        }
 };
 
-QueryEngineEventReceiver       *g_QueryEngineEventReceiver = NULL;
+QueryEngineEventReceiver    *g_QueryEngineEventReceiver = NULL;
 
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* jvm, void* reserved)
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved)
 {
-       JNIEnv *env;
-       if (jvm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK)
-               return JNI_ERR;
-               
-       g_ClassQueryEngine = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/QueryEngine"));
+    JNIEnv *env;
+    if (jvm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK)
+        return JNI_ERR;
+
+    g_ClassQueryEngine = (jclass) env->NewGlobalRef(
+                             env->FindClass("com/sec/android/ssmcore/QueryEngine"));
 
-       g_ClassDataReader = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/DataReader"));
+    g_ClassDataReader = (jclass) env->NewGlobalRef(
+                            env->FindClass("com/sec/android/ssmcore/DataReader"));
 
-       g_ClassModelData = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/ModelData"));
+    g_ClassModelData = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/ModelData"));
 
-       g_ClassQueryEngineEvent = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/IQueryEngineEvent"));
+    g_ClassQueryEngineEvent = (jclass) env->NewGlobalRef(
+                                  env->FindClass("com/sec/android/ssmcore/IQueryEngineEvent"));
 
 
-       g_ClassReportReceiver = (jclass) env->NewGlobalRef(env->FindClass("com/sec/android/ssmcore/IReportReceiver"));
+    g_ClassReportReceiver = (jclass) env->NewGlobalRef(
+                                env->FindClass("com/sec/android/ssmcore/IReportReceiver"));
 
 
-       g_JVM = jvm;
+    g_JVM = jvm;
 
-       g_QueryEngineEventReceiver = new QueryEngineEventReceiver();
+    g_QueryEngineEventReceiver = new QueryEngineEventReceiver();
 
-       return JNI_VERSION_1_6;
+    return JNI_VERSION_1_6;
 }
 
-JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* jvm, void* reserved) 
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *jvm, void *reserved)
 {
-       JNIEnv *env;
-       if (jvm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK)
-               return;
+    JNIEnv *env;
+    if (jvm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK)
+        return;
 
-       if(g_ClassQueryEngine != NULL)
-               env->DeleteGlobalRef(g_ClassQueryEngine);
+    if (g_ClassQueryEngine != NULL)
+        env->DeleteGlobalRef(g_ClassQueryEngine);
 
-       if(g_ClassDataReader != NULL)
-               env->DeleteGlobalRef(g_ClassDataReader);
+    if (g_ClassDataReader != NULL)
+        env->DeleteGlobalRef(g_ClassDataReader);
 
-       if(g_ClassModelData != NULL)
-               env->DeleteGlobalRef(g_ClassModelData);
+    if (g_ClassModelData != NULL)
+        env->DeleteGlobalRef(g_ClassModelData);
 
-       if(g_ClassQueryEngineEvent != NULL)
-               env->DeleteGlobalRef(g_ClassQueryEngineEvent);
+    if (g_ClassQueryEngineEvent != NULL)
+        env->DeleteGlobalRef(g_ClassQueryEngineEvent);
 
 
-       if(g_ClassReportReceiver != NULL)
-               env->DeleteGlobalRef(g_ClassReportReceiver);
+    if (g_ClassReportReceiver != NULL)
+        env->DeleteGlobalRef(g_ClassReportReceiver);
 
-       if(g_objReportReceiver != NULL)
-               env->DeleteGlobalRef(g_objReportReceiver);
-       
+    if (g_objReportReceiver != NULL)
+        env->DeleteGlobalRef(g_objReportReceiver);
 
-       g_JVM = NULL;
 
-       if(g_QueryEngineEventReceiver != NULL)
-               delete g_QueryEngineEventReceiver;
+    g_JVM = NULL;
+
+    if (g_QueryEngineEventReceiver != NULL)
+        delete g_QueryEngineEventReceiver;
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_InitializeSSMCore
-       (JNIEnv *env, jclass clz, jstring jstrXmlDescription)
+(JNIEnv *env, jclass clz, jstring jstrXmlDescription)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       const char *xmlDescription = env->GetStringUTFChars(jstrXmlDescription, NULL);
+    SSMRESULT res = SSM_E_FAIL;
+    const char *xmlDescription = env->GetStringUTFChars(jstrXmlDescription, NULL);
 
-       res = InitializeSSMCore(xmlDescription);
+    res = InitializeSSMCore(xmlDescription);
 
-       env->ReleaseStringUTFChars(jstrXmlDescription, xmlDescription);
+    env->ReleaseStringUTFChars(jstrXmlDescription, xmlDescription);
 
-       if(res != SSM_S_OK)
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "InitializeSSMCore failed");
+    if (res != SSM_S_OK)
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "InitializeSSMCore failed");
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StartSSMCore
-       (JNIEnv *env, jclass clz)
+(JNIEnv *env, jclass clz)
 {
-       if(StartSSMCore() != SSM_S_OK)
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "StartSSMCore failed");
+    if (StartSSMCore() != SSM_S_OK)
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "StartSSMCore failed");
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StopSSMCore
-       (JNIEnv *env, jclass clz)
+(JNIEnv *env, jclass clz)
 {
-       if(StopSSMCore() != SSM_S_OK)
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "StopSSMCore failed");
+    if (StopSSMCore() != SSM_S_OK)
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "StopSSMCore failed");
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_TerminateSSMCore
-       (JNIEnv *env, jclass clz)
+(JNIEnv *env, jclass clz)
 {
-       if(TerminateSSMCore() != SSM_S_OK)
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "TerminateSSMCore failed");
+    if (TerminateSSMCore() != SSM_S_OK)
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "TerminateSSMCore failed");
 }
 
 JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_CreateQueryEngine
-       (JNIEnv *env, jclass clz)
+(JNIEnv *env, jclass clz)
 {
-       IQueryEngine            *pQueryEngine = NULL;
+    IQueryEngine        *pQueryEngine = NULL;
 
-       if(CreateQueryEngine(&pQueryEngine) != SSM_S_OK)        
-       {
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "CreateQueryEngine failed");
-               return NULL;
-       }
+    if (CreateQueryEngine(&pQueryEngine) != SSM_S_OK)
+    {
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "CreateQueryEngine failed");
+        return NULL;
+    }
 
-       jmethodID cid_QueryEngine = env->GetMethodID(g_ClassQueryEngine, "<init>", "(I)V");
+    jmethodID cid_QueryEngine = env->GetMethodID(g_ClassQueryEngine, "<init>", "(I)V");
 
-       if(cid_QueryEngine == NULL)
-               return NULL;
+    if (cid_QueryEngine == NULL)
+        return NULL;
 
-       return env->NewObject(g_ClassQueryEngine, cid_QueryEngine, (jint)pQueryEngine);
+    return env->NewObject(g_ClassQueryEngine, cid_QueryEngine, (jint)pQueryEngine);
 }
 
 JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ReleaseQueryEngine
-       (JNIEnv *env, jclass clz, jobject queryEngine)
+(JNIEnv *env, jclass clz, jobject queryEngine)
 {
-       IQueryEngine            *pQueryEngine = NULL;
+    IQueryEngine        *pQueryEngine = NULL;
 
-       jmethodID mid_GetQueryEngineInstance = env->GetMethodID(g_ClassQueryEngine, "GetQueryEngineInstance", "()I");
+    jmethodID mid_GetQueryEngineInstance = env->GetMethodID(g_ClassQueryEngine,
+                                           "GetQueryEngineInstance", "()I");
 
-       if(mid_GetQueryEngineInstance == NULL)
-               return JNI_E_METHODID;
+    if (mid_GetQueryEngineInstance == NULL)
+        return JNI_E_METHODID;
 
-       pQueryEngine = (IQueryEngine*)env->CallIntMethod(queryEngine, mid_GetQueryEngineInstance);
+    pQueryEngine = (IQueryEngine *)env->CallIntMethod(queryEngine, mid_GetQueryEngineInstance);
 
-       return ReleaseQueryEngine(pQueryEngine);
+    return ReleaseQueryEngine(pQueryEngine);
 }
 
 JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ExecuteContextQuery
-       (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery)
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery)
 {
-       int                                     cqid = 0;
-       IQueryEngine            *pQueryEngine = (IQueryEngine*)pQueryEngineInstance;
+    int                 cqid = 0;
+    IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
 
-       const char *contextQuery = env->GetStringUTFChars(jstrContextQuery, NULL);
+    const char *contextQuery = env->GetStringUTFChars(jstrContextQuery, NULL);
 
-       if(pQueryEngine->executeContextQuery(contextQuery, &cqid) != SSM_S_OK)
-       {
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "ExecuteContextQuery failed");
-       }
+    if (pQueryEngine->executeContextQuery(contextQuery, &cqid) != SSM_S_OK)
+    {
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "ExecuteContextQuery failed");
+    }
 
-       env->ReleaseStringUTFChars(jstrContextQuery, contextQuery);
-       return cqid;
+    env->ReleaseStringUTFChars(jstrContextQuery, contextQuery);
+    return cqid;
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterQueryEvent
-       (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent)
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent)
 {
-       IQueryEngine            *pQueryEngine = (IQueryEngine*)pQueryEngineInstance;
+    IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
 
-       if(queryEngineEvent == NULL)
-       {
-               pQueryEngine->unregisterQueryEvent(g_QueryEngineEventReceiver);
-               return;
-       }
+    if (queryEngineEvent == NULL)
+    {
+        pQueryEngine->unregisterQueryEvent(g_QueryEngineEventReceiver);
+        return;
+    }
 
-       g_QueryEngineEventReceiver->SetQueryEngineEventObj(env->NewGlobalRef(queryEngineEvent));
-       pQueryEngine->registerQueryEvent(g_QueryEngineEventReceiver);
+    g_QueryEngineEventReceiver->SetQueryEngineEventObj(env->NewGlobalRef(queryEngineEvent));
+    pQueryEngine->registerQueryEvent(g_QueryEngineEventReceiver);
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_KillContextQuery
-       (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid)
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid)
 {
-       IQueryEngine            *pQueryEngine = (IQueryEngine*)pQueryEngineInstance;
+    IQueryEngine        *pQueryEngine = (IQueryEngine *)pQueryEngineInstance;
 
-       if(pQueryEngine->killContextQuery(cqid) != SSM_S_OK)
-       {
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "KillContextQuery failed");
-       }
+    if (pQueryEngine->killContextQuery(cqid) != SSM_S_OK)
+    {
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "KillContextQuery failed");
+    }
 }
 
 JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetDataId
-       (JNIEnv *env, jclass clz, jint pDataReaderInstance)
+(JNIEnv *env, jclass clz, jint pDataReaderInstance)
 {
-       IModelData *pDataReader = (IModelData *)pDataReaderInstance;
+    IModelData *pDataReader = (IModelData *)pDataReaderInstance;
 
-       return pDataReader->getDataId();
+    return pDataReader->getDataId();
 }
 
 JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyCount
-       (JNIEnv *env, jclass clz, jint pIModelDataInstance )
+(JNIEnv *env, jclass clz, jint pIModelDataInstance )
 {
-       IModelData *pModelData = (IModelData *)pIModelDataInstance;
+    IModelData *pModelData = (IModelData *)pIModelDataInstance;
 
-       return pModelData->getPropertyCount();
+    return pModelData->getPropertyCount();
 }
 
 JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyName
-       (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
+(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
 {
-       IModelData *pModelData = (IModelData *)pIModelDataInstance;
+    IModelData *pModelData = (IModelData *)pIModelDataInstance;
 
-       return env->NewStringUTF(pModelData->getPropertyName(propertyIndex).c_str());
+    return env->NewStringUTF(pModelData->getPropertyName(propertyIndex).c_str());
 }
 
 JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyValue
-       (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
+(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex )
 {
-       IModelData *pModelData = (IModelData *)pIModelDataInstance;
+    IModelData *pModelData = (IModelData *)pIModelDataInstance;
 
-       return env->NewStringUTF(pModelData->getPropertyValue(propertyIndex).c_str());
+    return env->NewStringUTF(pModelData->getPropertyValue(propertyIndex).c_str());
 }
 
 JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetAffectedModels
-       (JNIEnv *env, jclass clz, jint pDataReaderInstance)
+(JNIEnv *env, jclass clz, jint pDataReaderInstance)
 {
-       IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
-       std::vector<std::string>        affectedModels;
+    IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
+    std::vector<std::string>    affectedModels;
 
-       jclass listClass = env->FindClass("java/util/ArrayList");
+    jclass listClass = env->FindClass("java/util/ArrayList");
 
-       jmethodID add_mid = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z");
+    jmethodID add_mid = env->GetMethodID(listClass, "add", "(Ljava/lang/Object;)Z");
 
-       jmethodID list_cid = env->GetMethodID(listClass, "<init>", "()V");
+    jmethodID list_cid = env->GetMethodID(listClass, "<init>", "()V");
 
-       jobject objAffectedModels = env->NewObject(listClass, list_cid);
+    jobject objAffectedModels = env->NewObject(listClass, list_cid);
 
-       pDataReader->getAffectedModels(&affectedModels);
+    pDataReader->getAffectedModels(&affectedModels);
 
-       for(std::vector<std::string>::iterator itor = affectedModels.begin();
-               itor != affectedModels.end(); ++itor)
-       {
-               env->CallBooleanMethod(objAffectedModels, add_mid, env->NewStringUTF((*itor).c_str()));
-       }
+    for (std::vector<std::string>::iterator itor = affectedModels.begin();
+         itor != affectedModels.end(); ++itor)
+    {
+        env->CallBooleanMethod(objAffectedModels, add_mid, env->NewStringUTF((*itor).c_str()));
+    }
 
-       return objAffectedModels;
+    return objAffectedModels;
 }
 
 JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDataCount
-       (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName)
+(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName)
 {
-       IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
-       int modelCount = 0;
-       const char *modelName = env->GetStringUTFChars(jstrModelName, NULL);
-       
-       if(pDataReader->getModelDataCount(modelName,&modelCount) != SSM_S_OK)
-       {
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "GetModelDataCount failed");
-       }
-
-       env->ReleaseStringUTFChars(jstrModelName, modelName);
-
-       return modelCount;
+    IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
+    int modelCount = 0;
+    const char *modelName = env->GetStringUTFChars(jstrModelName, NULL);
+
+    if (pDataReader->getModelDataCount(modelName, &modelCount) != SSM_S_OK)
+    {
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "GetModelDataCount failed");
+    }
+
+    env->ReleaseStringUTFChars(jstrModelName, modelName);
+
+    return modelCount;
 }
 //return IModelData
 JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelData
-       (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex )
+(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex )
 {
-       IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
-       IModelData *pModelData = NULL;
-       const char *modelName = env->GetStringUTFChars(jstrModelName, NULL);
-
-       if(pDataReader->getModelData(modelName,jintDataIndex,&pModelData) != SSM_S_OK)
-       {
-               env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "GetModelData failed");
-               return NULL;
-       }
-       
-       jmethodID cid_ModelData = env->GetMethodID(g_ClassModelData, "<init>", "(I)V");
-
-       if(cid_ModelData == NULL)
-               return NULL;
-
-       return env->NewObject(g_ClassModelData, cid_ModelData, (jint)pModelData);
+    IDataReader *pDataReader = (IDataReader *)pDataReaderInstance;
+    IModelData *pModelData = NULL;
+    const char *modelName = env->GetStringUTFChars(jstrModelName, NULL);
+
+    if (pDataReader->getModelData(modelName, jintDataIndex, &pModelData) != SSM_S_OK)
+    {
+        env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"), "GetModelData failed");
+        return NULL;
+    }
+
+    jmethodID cid_ModelData = env->GetMethodID(g_ClassModelData, "<init>", "(I)V");
+
+    if (cid_ModelData == NULL)
+        return NULL;
+
+    return env->NewObject(g_ClassModelData, cid_ModelData, (jint)pModelData);
 }
 
 JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterReportReceiver
-       (JNIEnv *env, jclass clz, jobject reportReceiver)
+(JNIEnv *env, jclass clz, jobject reportReceiver)
 {
-       if(g_objReportReceiver != NULL)
-               env->DeleteGlobalRef(g_objReportReceiver);
+    if (g_objReportReceiver != NULL)
+        env->DeleteGlobalRef(g_objReportReceiver);
 
-       g_objReportReceiver = NULL;
+    g_objReportReceiver = NULL;
 
-       if(reportReceiver != NULL)
-               g_objReportReceiver = env->NewGlobalRef(reportReceiver);
+    if (reportReceiver != NULL)
+        g_objReportReceiver = env->NewGlobalRef(reportReceiver);
 }
index 02bfb77..48ffdb7 100644 (file)
 extern "C" {
 #endif
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_InitializeSSMCore
-               (JNIEnv *env, jclass clz, jstring jstrXmlDescription);
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_InitializeSSMCore
+(JNIEnv *env, jclass clz, jstring jstrXmlDescription);
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StartSSMCore
-               (JNIEnv *env, jclass clz);
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StartSSMCore
+(JNIEnv *env, jclass clz);
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StopSSMCore
-               (JNIEnv *env, jclass clz);
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_StopSSMCore
+(JNIEnv *env, jclass clz);
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_TerminateSSMCore
-               (JNIEnv *env, jclass clz);
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_TerminateSSMCore
+(JNIEnv *env, jclass clz);
 
-       JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_CreateQueryEngine
-               (JNIEnv *env, jclass clz);
+JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_CreateQueryEngine
+(JNIEnv *env, jclass clz);
 
-       JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ReleaseQueryEngine
-               (JNIEnv *env, jclass clz, jobject queryEngine);
+JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ReleaseQueryEngine
+(JNIEnv *env, jclass clz, jobject queryEngine);
 
-       JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ExecuteContextQuery
-               (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery);
+JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_ExecuteContextQuery
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jstring jstrContextQuery);
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterQueryEvent
-               (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent);
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterQueryEvent
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jobject queryEngineEvent);
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_KillContextQuery
-               (JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid);
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_KillContextQuery
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance, jint cqid);
 
-       JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_Release
-               (JNIEnv *env, jclass clz, jint pQueryEngineInstance);
+JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_Release
+(JNIEnv *env, jclass clz, jint pQueryEngineInstance);
 
-       JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetDataId
-               (JNIEnv *env, jclass clz, jint pDataReaderInstance);
+JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetDataId
+(JNIEnv *env, jclass clz, jint pDataReaderInstance);
 
-       JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetAffectedModels
-               (JNIEnv *env, jclass clz, jint pDataReaderInstance);
+JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetAffectedModels
+(JNIEnv *env, jclass clz, jint pDataReaderInstance);
 
-       JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDataCount
-               (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName);
+JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelDataCount
+(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName);
 
-       JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelData
-               (JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex );
+JNIEXPORT jobject JNICALL Java_com_sec_android_ssmcore_CoreController_GetModelData
+(JNIEnv *env, jclass clz, jint pDataReaderInstance, jstring jstrModelName, jint jintDataIndex );
 
-       JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyCount
-               (JNIEnv *env, jclass clz, jint pIModelDataInstance );
+JNIEXPORT jint JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyCount
+(JNIEnv *env, jclass clz, jint pIModelDataInstance );
 
-       JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyName
-               (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
+JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyName
+(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
 
-       JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyValue
-               (JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
+JNIEXPORT jstring JNICALL Java_com_sec_android_ssmcore_CoreController_GetPropertyValue
+(JNIEnv *env, jclass clz, jint pIModelDataInstance, jint propertyIndex );
 
-       JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterReportReceiver
-               (JNIEnv *env, jclass clz, jobject reportReceiver );
+JNIEXPORT void JNICALL Java_com_sec_android_ssmcore_CoreController_RegisterReportReceiver
+(JNIEnv *env, jclass clz, jobject reportReceiver );
 
 #ifdef __cplusplus
 }
index 3b41d33..c670db3 100644 (file)
@@ -29,70 +29,73 @@ typedef enum {SSM_EVENT_NORMAL, SSM_EVENT_ADDED, SSM_REMOVED, SSM_UPDATED} RESOU
 typedef enum {SENSOR_LOCATION_REMOTE, SENSOR_LOCATION_LOCAL} SENSOR_LOCATION;
 class ISSMResource
 {
-public:
-       ISSMResource()
-       {
-               location = SENSOR_LOCATION_LOCAL;
-       }
-       ISSMResource(const std::string& n, const std::string& t) :
-       name(n), type(t)
-       {
-       }
-       SENSOR_LOCATION location;
-       std::string name;
-       std::string type;
-       std::string friendlyName;
-       std::string ip;
-       std::vector<std::string> inputList;
-       std::vector<std::map<std::string,std::string> > outputProperty;
+    public:
+        ISSMResource()
+        {
+            location = SENSOR_LOCATION_LOCAL;
+        }
+        ISSMResource(const std::string &n, const std::string &t) :
+            name(n), type(t)
+        {
+        }
+        SENSOR_LOCATION location;
+        std::string name;
+        std::string type;
+        std::string friendlyName;
+        std::string ip;
+        std::vector<std::string> inputList;
+        std::vector<std::map<std::string, std::string> > outputProperty;
 };
 
 class ContextData
 {
-public:
-       std::string rootName;
-       int outputPropertyCount;
-       std::vector< std::map<std::string,std::string> > outputProperty;
+    public:
+        std::string rootName;
+        int outputPropertyCount;
+        std::vector< std::map<std::string, std::string> > outputProperty;
 };
 
 struct ResourceResult
 {
-       std::string deviceID;
-       TypeofEvent callType;
-       ContextData ctxData;
+    std::string deviceID;
+    TypeofEvent callType;
+    ContextData ctxData;
 };
 
-enum CTX_EVENT_TYPE{SPF_START, SPF_UPDATE, SPF_END};
+enum CTX_EVENT_TYPE {SPF_START, SPF_UPDATE, SPF_END};
 
 class ICtxEvent
 {
-public:
-       virtual void onCtxEvent(enum CTX_EVENT_TYPE, std::vector<ContextData>) = 0 ;
-       virtual ~ICtxEvent(){};
+    public:
+        virtual void onCtxEvent(enum CTX_EVENT_TYPE, std::vector<ContextData>) = 0 ;
+        virtual ~ICtxEvent() {};
 };
 
 class IEvent
 {
-public:
-       virtual int onEvent(std::string deviceID, TypeofEvent callType, std::vector<ContextData> ctxData) = 0;
-       std::string appId;
-       virtual ~IEvent(){};
+    public:
+        virtual int onEvent(std::string deviceID, TypeofEvent callType,
+                            std::vector<ContextData> ctxData) = 0;
+        std::string appId;
+        virtual ~IEvent() {};
 };
 
 class IResourceEvent
 {
-public:
-       virtual int onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource, std::string info) = 0;
-       virtual ~IResourceEvent(){};
+    public:
+        virtual int onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource,
+                                    std::string info) = 0;
+        virtual ~IResourceEvent() {};
 };
 
 class ICtxDelegate
 {
-public:
-       virtual void registerCallback(ICtxEvent *pEvent) = 0;
-       virtual void addOutput(std::vector<ContextData>) = 0;
-       virtual void getDataFromDatabase(std::string modelName, int startIndex, int count, std::vector<ContextData> *data, int *pLastIndex) = 0;
-       virtual ~ICtxDelegate(){};
+    public:
+        virtual void registerCallback(ICtxEvent *pEvent) = 0;
+        virtual void addOutput(std::vector<ContextData>) = 0;
+        virtual void getDataFromDatabase(std::string modelName, int startIndex, int count,
+                                         std::vector<ContextData> *data, int *pLastIndex) = 0;
+        virtual ~ICtxDelegate() {};
 };
 
 #endif
index 18da039..51a13db 100644 (file)
@@ -28,89 +28,89 @@ static std::vector< OC::AttributeMap > g_vecQueryEventResults;
 
 class CQueryEngineEvent: public IQueryEngineEvent
 {
-private:
-    std::string m_queryEngineId;
-    OCResourceHandle m_hSSMResource;
+    private:
+        std::string m_queryEngineId;
+        OCResourceHandle m_hSSMResource;
 
-public:
-    /* Constructor */
-    CQueryEngineEvent(std::string queryEngineId, OCResourceHandle resourceHandle)
-    {
-        m_queryEngineId = queryEngineId;
-        m_hSSMResource = resourceHandle;
-    }
-
-    SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult)
-    {
-        int dataCount = 0;
-        IModelData *pModelData = NULL;
-        std::vector < std::string > affectedModels;
-
-        AttributeMap queryEventResult;
-
-        std::stringstream sstream;
+    public:
+        /* Constructor */
+        CQueryEngineEvent(std::string queryEngineId, OCResourceHandle resourceHandle)
+        {
+            m_queryEngineId = queryEngineId;
+            m_hSSMResource = resourceHandle;
+        }
 
-        // QueryEngine Id
-        queryEventResult["queryEngineId"].push_back(m_queryEngineId);
+        SSMRESULT onQueryEngineEvent(IN int cqid, IN IDataReader *pResult)
+        {
+            int dataCount = 0;
+            IModelData *pModelData = NULL;
+            std::vector < std::string > affectedModels;
 
-        // CQID
-        sstream << cqid;
-        queryEventResult["CQID"].push_back(sstream.str());
-        sstream.str("");
+            AttributeMap queryEventResult;
 
-        pResult->getAffectedModels(&affectedModels);
+            std::stringstream sstream;
 
-        // Affected Model Count
-        sstream << affectedModels.size();
-        queryEventResult["modelCount"].push_back(sstream.str());
-        sstream.str("");
+            // QueryEngine Id
+            queryEventResult["queryEngineId"].push_back(m_queryEngineId);
 
-        //TODO: we assume that contains only one model at time
-        for (std::vector< std::string >::iterator itor = affectedModels.begin();
-                itor != affectedModels.end(); ++itor)
-        {
-            // Model Name
-            sstream << (*itor);
-            queryEventResult["modelName"].push_back(sstream.str());
+            // CQID
+            sstream << cqid;
+            queryEventResult["CQID"].push_back(sstream.str());
             sstream.str("");
 
-            pResult->getModelDataCount(*itor, &dataCount);
+            pResult->getAffectedModels(&affectedModels);
 
-            // Data Count
-            sstream << dataCount;
-            queryEventResult["dataCount"].push_back(sstream.str());
+            // Affected Model Count
+            sstream << affectedModels.size();
+            queryEventResult["modelCount"].push_back(sstream.str());
             sstream.str("");
 
-            //FixME: we have to support multiple data count
-            for (int i = 0; i < dataCount; i++)
+            //TODO: we assume that contains only one model at time
+            for (std::vector< std::string >::iterator itor = affectedModels.begin();
+                 itor != affectedModels.end(); ++itor)
             {
-                pResult->getModelData(*itor, i, &pModelData);
-
-                // Data Id
-                sstream << pModelData->getDataId();
-                queryEventResult["dataId"].push_back(sstream.str());
+                // Model Name
+                sstream << (*itor);
+                queryEventResult["modelName"].push_back(sstream.str());
                 sstream.str("");
 
-                // Property Count
-                sstream << pModelData->getPropertyCount();
-                queryEventResult["propertyCount"].push_back(sstream.str());
+                pResult->getModelDataCount(*itor, &dataCount);
+
+                // Data Count
+                sstream << dataCount;
+                queryEventResult["dataCount"].push_back(sstream.str());
                 sstream.str("");
 
-                for (int j = 0; j < pModelData->getPropertyCount(); j++)
+                //FixME: we have to support multiple data count
+                for (int i = 0; i < dataCount; i++)
                 {
-                    // Property Name & Value
-                    sstream << pModelData->getPropertyValue(j).c_str();
-                    queryEventResult[pModelData->getPropertyName(j).c_str()].push_back(sstream.str());
+                    pResult->getModelData(*itor, i, &pModelData);
+
+                    // Data Id
+                    sstream << pModelData->getDataId();
+                    queryEventResult["dataId"].push_back(sstream.str());
+                    sstream.str("");
+
+                    // Property Count
+                    sstream << pModelData->getPropertyCount();
+                    queryEventResult["propertyCount"].push_back(sstream.str());
                     sstream.str("");
+
+                    for (int j = 0; j < pModelData->getPropertyCount(); j++)
+                    {
+                        // Property Name & Value
+                        sstream << pModelData->getPropertyValue(j).c_str();
+                        queryEventResult[pModelData->getPropertyName(j).c_str()].push_back(sstream.str());
+                        sstream.str("");
+                    }
                 }
             }
-        }
 
-        g_vecQueryEventResults.push_back(queryEventResult);
-        OCPlatform::notifyObservers(m_hSSMResource);
+            g_vecQueryEventResults.push_back(queryEventResult);
+            OCPlatform::notifyObservers(m_hSSMResource);
 
-        return SSM_S_OK;
-    }
+            return SSM_S_OK;
+        }
 };
 
 SSMResourceServer::SSMResourceServer()
@@ -132,16 +132,17 @@ int SSMResourceServer::initializeManager(std::string &xmlDescription)
     SSM_CLEANUP_ASSERT(StartSSMCore());
 
     SSM_CLEANUP_ASSERT(
-            CreateGlobalInstance(OID_IResourceConnectivity, (IBase**) &pResourceConnectivity));
+        CreateGlobalInstance(OID_IResourceConnectivity, (IBase **) &pResourceConnectivity));
 
-    m_pPlatform = (OC::OCPlatform*) pResourceConnectivity->getPlatform();
+    m_pPlatform = (OC::OCPlatform *) pResourceConnectivity->getPlatform();
 
     if (createResource() != 0)
     {
         SSM_CLEANUP_ASSERT (SSM_E_FAIL);
     }
 
-    CLEANUP: if (res != SSM_S_OK)
+CLEANUP:
+    if (res != SSM_S_OK)
         return -1;
 
     return 0;
@@ -154,7 +155,8 @@ int SSMResourceServer::terminateManager()
     SSM_CLEANUP_ASSERT(StopSSMCore());
     SSM_CLEANUP_ASSERT(TerminateSSMCore());
 
-    CLEANUP: if (res != SSM_S_OK)
+CLEANUP:
+    if (res != SSM_S_OK)
         return -1;
 
     return 0;
@@ -163,7 +165,8 @@ int SSMResourceServer::terminateManager()
 int SSMResourceServer::createResource()
 {
     std::string resourceURI = "/service/SoftSensorManager"; // URI of the resource
-    std::string resourceTypeName = "core.SoftSensorManager"; // resource type name. In this case, it is light
+    std::string resourceTypeName =
+        "core.SoftSensorManager"; // resource type name. In this case, it is light
     std::string resourceInterface = DEFAULT_INTERFACE; // resource interface.
 
     // OCResourceProperty is defined ocstack.h
@@ -171,9 +174,9 @@ int SSMResourceServer::createResource()
 
     // This will internally create and register the resource.
     OCStackResult result = m_pPlatform->registerResource(m_hSSMResource, resourceURI,
-            resourceTypeName, resourceInterface,
-            std::bind(&SSMResourceServer::entityHandler, this, std::placeholders::_1,
-                    std::placeholders::_2), resourceProperty);
+                           resourceTypeName, resourceInterface,
+                           std::bind(&SSMResourceServer::entityHandler, this, std::placeholders::_1,
+                                     std::placeholders::_2), resourceProperty);
 
     if (OC_STACK_OK != result)
     {
@@ -184,7 +187,7 @@ int SSMResourceServer::createResource()
 }
 
 void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > request,
-        std::shared_ptr< OCResourceResponse > response)
+                                      std::shared_ptr< OCResourceResponse > response)
 {
     SSMRESULT res = SSM_E_FAIL;
 
@@ -254,7 +257,7 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque
                     if (queryEngineEvent == NULL)
                     {
                         responseAttributeMap["error"].push_back(
-                                "QueryEngineEvent create failed");
+                            "QueryEngineEvent create failed");
                         goto CLEANUP;
                     }
 
@@ -270,8 +273,8 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque
                 }
                 else if (requestAttributeMap["command"].back() == "ReleaseQueryEngine")
                 {
-                    pQueryEngine = (IQueryEngine*) stoi(
-                            requestAttributeMap["queryEngineId"].back());
+                    pQueryEngine = (IQueryEngine *) stoi(
+                                       requestAttributeMap["queryEngineId"].back());
 
                     ReleaseQueryEngine(pQueryEngine);
                 }
@@ -279,11 +282,11 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque
                 {
                     int CQID = 0;
 
-                    pQueryEngine = (IQueryEngine*) stoi(
-                            requestAttributeMap["queryEngineId"].back());
+                    pQueryEngine = (IQueryEngine *) stoi(
+                                       requestAttributeMap["queryEngineId"].back());
 
                     res = pQueryEngine->executeContextQuery(
-                            requestAttributeMap["contextQuery"].back(), &CQID);
+                              requestAttributeMap["contextQuery"].back(), &CQID);
 
                     if (res != SSM_S_OK)
                     {
@@ -297,8 +300,8 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque
                 }
                 else if (requestAttributeMap["command"].back() == "KillContextQuery")
                 {
-                    pQueryEngine = (IQueryEngine*) stoi(
-                            requestAttributeMap["queryEngineId"].back());
+                    pQueryEngine = (IQueryEngine *) stoi(
+                                       requestAttributeMap["queryEngineId"].back());
 
                     res = pQueryEngine->killContextQuery(stoi(requestAttributeMap["CQID"].back()));
 
@@ -309,7 +312,8 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque
                     }
                 }
 
-                CLEANUP: if (response)
+CLEANUP:
+                if (response)
                 {
                     rep.setAttributeMap(responseAttributeMap);
 
@@ -328,7 +332,7 @@ void SSMResourceServer::entityHandler(std::shared_ptr< OCResourceRequest > reque
         }
         else if (requestFlag == RequestHandlerFlag::ObserverFlag)
         {
-            // perform observe related operations on the resource. 
+            // perform observe related operations on the resource.
         }
     }
     else
index c78c29b..5eed956 100644 (file)
 #include "SensorProcessor/ResourceFinder.h"
 #include "SensorProcessor/ResourceConnectivity.h"
 
-inline bool operator<( const OID & lhs, const OID & rhs )
+inline bool operator<( const OID &lhs, const OID &rhs )
 {
-       int ret = memcmp( &lhs, &rhs, sizeof(OID));
-       return (ret < 0 ? true : false );
+    int ret = memcmp( &lhs, &rhs, sizeof(OID));
+    return (ret < 0 ? true : false );
 }
 
 SSMRESULT CSoftSensorManager::finalConstruct()
 {
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 void CSoftSensorManager::finalRelease()
@@ -46,353 +46,353 @@ void CSoftSensorManager::finalRelease()
 
 SSMRESULT CSoftSensorManager::initializeCore(IN std::string xmlDescription)
 {
-       SSMRESULT                                       res = SSM_E_FAIL;
-       rapidxml::xml_document<>        xmlDoc;
-       std::string                                     strKey;
-       std::string                                     strValue;
-       rapidxml::xml_node<>            *root = NULL;
-       rapidxml::xml_node<>            *itemSSMCore = NULL;
-       rapidxml::xml_node<>            *itemDevice = NULL;
-
-       std::string                                     name;
-       std::string                                     type;
-       std::string                                     pathSoftSensors;
-       std::string                                     pathDescription;
-
-       xmlDoc.parse<0>((char *)xmlDescription.c_str());
-
-       root = xmlDoc.first_node();
-
-       strKey = root->name();
-
-       if(strKey != "SSMCore")
-       {
-               return SSM_E_FAIL;
-       }
-
-       for(itemSSMCore = root->first_node(); itemSSMCore; itemSSMCore = itemSSMCore->next_sibling())
-       {
-               strKey = itemSSMCore->name();
-
-               if(strKey == "Device")
-               {
-                       for(itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
-                       {
-                               strKey = itemDevice->name();
-
-                               if(strKey == "Name")
-                               {
-                                       name = itemDevice->value();
-                               }
-                               else if(strKey == "Type")
-                               {
-                                       type = itemDevice->value();
-                               }
-                               else
-                               {
-                                       ;/*NULL*/
-                               }
-                       }
-               }
-               else if (strKey == "Config")
-               {
-                       for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
-                       {
-                               strKey = itemDevice->name();
-
-                               if (strKey == "SoftSensorRepository")
-                               {
-                                       pathSoftSensors = itemDevice->value();
-                               }
-                               else if (strKey == "SoftSensorDescription")
-                               {
-                                       pathDescription = itemDevice->value();
-                               }
-                               else
-                               {
-                                       ;/*NULL*/
-                               }
-                       }
-               }
-               else
-               {
-                       ;/*NULL*/
-               }
-       }
-
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase**)&m_pContextRepository));
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResponseReactor, (IBase**)&m_pResponseReactor));
-       m_pContextRepository->setCurrentDeviceInfo(name, type, pathSoftSensors, pathDescription);
-
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IPropagationEngine, (IBase**)&m_pPropagationEngine));
+    SSMRESULT                   res = SSM_E_FAIL;
+    rapidxml::xml_document<>    xmlDoc;
+    std::string                 strKey;
+    std::string                 strValue;
+    rapidxml::xml_node<>        *root = NULL;
+    rapidxml::xml_node<>        *itemSSMCore = NULL;
+    rapidxml::xml_node<>        *itemDevice = NULL;
+
+    std::string                 name;
+    std::string                 type;
+    std::string                 pathSoftSensors;
+    std::string                 pathDescription;
+
+    xmlDoc.parse<0>((char *)xmlDescription.c_str());
+
+    root = xmlDoc.first_node();
+
+    strKey = root->name();
+
+    if (strKey != "SSMCore")
+    {
+        return SSM_E_FAIL;
+    }
+
+    for (itemSSMCore = root->first_node(); itemSSMCore; itemSSMCore = itemSSMCore->next_sibling())
+    {
+        strKey = itemSSMCore->name();
+
+        if (strKey == "Device")
+        {
+            for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
+            {
+                strKey = itemDevice->name();
+
+                if (strKey == "Name")
+                {
+                    name = itemDevice->value();
+                }
+                else if (strKey == "Type")
+                {
+                    type = itemDevice->value();
+                }
+                else
+                {
+                    ;/*NULL*/
+                }
+            }
+        }
+        else if (strKey == "Config")
+        {
+            for (itemDevice = itemSSMCore->first_node(); itemDevice; itemDevice = itemDevice->next_sibling())
+            {
+                strKey = itemDevice->name();
+
+                if (strKey == "SoftSensorRepository")
+                {
+                    pathSoftSensors = itemDevice->value();
+                }
+                else if (strKey == "SoftSensorDescription")
+                {
+                    pathDescription = itemDevice->value();
+                }
+                else
+                {
+                    ;/*NULL*/
+                }
+            }
+        }
+        else
+        {
+            ;/*NULL*/
+        }
+    }
+
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResponseReactor, (IBase **)&m_pResponseReactor));
+    m_pContextRepository->setCurrentDeviceInfo(name, type, pathSoftSensors, pathDescription);
+
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IPropagationEngine, (IBase **)&m_pPropagationEngine));
 
 CLEANUP:
-       if(res != SSM_S_OK)
-       {
-               terminateCore(false);
-       }
+    if (res != SSM_S_OK)
+    {
+        terminateCore(false);
+    }
 
-       return res;
+    return res;
 }
 
 SSMRESULT CSoftSensorManager::startCore()
 {
-       //m_pSharingLayer->Start();
-       return SSM_S_OK;
+    //m_pSharingLayer->Start();
+    return SSM_S_OK;
 }
 
 SSMRESULT CSoftSensorManager::stopCore()
 {
-       //m_pSharingLayer->Stop();
-       return SSM_S_OK;
+    //m_pSharingLayer->Stop();
+    return SSM_S_OK;
 }
 
 SSMRESULT CSoftSensorManager::terminateCore(bool factoryResetFlag)
 {
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CSoftSensorManager::createQueryEngine(OUT IQueryEngine **ppQueryEngine)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       IQueryEngineInternal    *pQueryEngineInternal = NULL;
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IQueryEngineInternal, (IBase**)&pQueryEngineInternal));
-       *ppQueryEngine = (IQueryEngine *)pQueryEngineInternal;
+    SSMRESULT res = SSM_E_FAIL;
+    IQueryEngineInternal    *pQueryEngineInternal = NULL;
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IQueryEngineInternal, (IBase **)&pQueryEngineInternal));
+    *ppQueryEngine = (IQueryEngine *)pQueryEngineInternal;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 unsigned long CSoftSensorManager::releaseQueryEngine(IN IQueryEngine *pQueryEngine)
 {
-       IQueryEngineInternal    *pQueryEngineInternal = NULL;
-       pQueryEngineInternal = (IQueryEngineInternal *)(CQueryEngine*)pQueryEngine;
+    IQueryEngineInternal    *pQueryEngineInternal = NULL;
+    pQueryEngineInternal = (IQueryEngineInternal *)(CQueryEngine *)pQueryEngine;
 
-       return pQueryEngineInternal->release();
+    return pQueryEngineInternal->release();
 }
 
-SSMRESULT CSoftSensorManager::getInstalledModelList(OUT std::vector<ISSMResource*> *pList)
+SSMRESULT CSoftSensorManager::getInstalledModelList(OUT std::vector<ISSMResource *> *pList)
 {
-       m_pResponseReactor->getList(pList);
+    m_pResponseReactor->getList(pList);
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
-CSimpleMutex                           *g_mtxGlobalInstance = NULL;
-std::map<OID, IBase*>          *g_globalInstance = NULL;
-IThreadPool                                    *g_pThreadPool = NULL;
+CSimpleMutex                *g_mtxGlobalInstance = NULL;
+std::map<OID, IBase *>       *g_globalInstance = NULL;
+IThreadPool                 *g_pThreadPool = NULL;
 
-SSMRESULT CreateGlobalInstance(IN const OID& objectID, OUT IBase** ppvObject)
+SSMRESULT CreateGlobalInstance(IN const OID &objectID, OUT IBase **ppvObject)
 {
-       SSMRESULT res = SSM_E_NOINTERFACE;
-
-       if(ppvObject == NULL)
-       {
-               return SSM_E_POINTER;
-       }
-
-       *ppvObject = NULL;
-
-       g_mtxGlobalInstance->lock();
-       res = SSM_S_FALSE;
-
-       if (IsEqualOID(OID_ITasker, objectID))
-       {
-               if (g_globalInstance->find(OID_ITasker) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, ppvObject));
-               }
-       }
-       else if(IsEqualOID(OID_IThreadPool, objectID))
-       {
-               if (g_globalInstance->find(OID_IThreadPool) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IThreadPool, ppvObject));
-               }
-       }
-       else if(IsEqualOID(OID_IEvaluationEngine, objectID))
-       {
-               if (g_globalInstance->find(OID_IEvaluationEngine) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IEvaluationEngine, ppvObject));
-               }
-       }
-       else if(IsEqualOID(OID_IPropagationEngine, objectID))
-       {
-               if (g_globalInstance->find(OID_IPropagationEngine) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IPropagationEngine, ppvObject));
-               }
-       }
-       else if(IsEqualOID(OID_IContextRepository, objectID))
-       {
-               if (g_globalInstance->find(OID_IContextRepository) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextRepository, ppvObject));
-               }
-       }
-       else if(IsEqualOID(OID_IContextDataReader, objectID))
-       {
-               if (g_globalInstance->find(OID_IContextDataReader) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextDataReader, ppvObject));
-               }
-       }
-       else if (IsEqualOID(OID_IResponseReactor, objectID))
-       {
-               if (g_globalInstance->find(OID_IResponseReactor) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IResponseReactor, ppvObject));
-               }
-       }
-       else if (IsEqualOID(OID_IResourceConnectivity, objectID))
-       {
-               if (g_globalInstance->find(OID_IResourceConnectivity) == g_globalInstance->end())
-               {
-                       SSM_CLEANUP_ASSERT(CreateInstance(OID_IResourceConnectivity, ppvObject));
-               }
-       }
-       else
-       {
-               res = SSM_E_NOINTERFACE;
-       }       
-
-       switch(res)
-       {
-       case SSM_S_OK:
-               (*g_globalInstance)[objectID] = *ppvObject;
-               break;
-
-       case SSM_S_FALSE:
-               (*g_globalInstance)[objectID]->addRef();
-               *ppvObject = (*g_globalInstance)[objectID];
-               res = SSM_S_OK;
-               break;
-
-       default:
-               goto CLEANUP;
-       }
+    SSMRESULT res = SSM_E_NOINTERFACE;
+
+    if (ppvObject == NULL)
+    {
+        return SSM_E_POINTER;
+    }
+
+    *ppvObject = NULL;
+
+    g_mtxGlobalInstance->lock();
+    res = SSM_S_FALSE;
+
+    if (IsEqualOID(OID_ITasker, objectID))
+    {
+        if (g_globalInstance->find(OID_ITasker) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_ITasker, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IThreadPool, objectID))
+    {
+        if (g_globalInstance->find(OID_IThreadPool) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IThreadPool, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IEvaluationEngine, objectID))
+    {
+        if (g_globalInstance->find(OID_IEvaluationEngine) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IEvaluationEngine, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IPropagationEngine, objectID))
+    {
+        if (g_globalInstance->find(OID_IPropagationEngine) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IPropagationEngine, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IContextRepository, objectID))
+    {
+        if (g_globalInstance->find(OID_IContextRepository) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextRepository, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IContextDataReader, objectID))
+    {
+        if (g_globalInstance->find(OID_IContextDataReader) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextDataReader, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IResponseReactor, objectID))
+    {
+        if (g_globalInstance->find(OID_IResponseReactor) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IResponseReactor, ppvObject));
+        }
+    }
+    else if (IsEqualOID(OID_IResourceConnectivity, objectID))
+    {
+        if (g_globalInstance->find(OID_IResourceConnectivity) == g_globalInstance->end())
+        {
+            SSM_CLEANUP_ASSERT(CreateInstance(OID_IResourceConnectivity, ppvObject));
+        }
+    }
+    else
+    {
+        res = SSM_E_NOINTERFACE;
+    }
+
+    switch (res)
+    {
+        case SSM_S_OK:
+            (*g_globalInstance)[objectID] = *ppvObject;
+            break;
+
+        case SSM_S_FALSE:
+            (*g_globalInstance)[objectID]->addRef();
+            *ppvObject = (*g_globalInstance)[objectID];
+            res = SSM_S_OK;
+            break;
+
+        default:
+            goto CLEANUP;
+    }
 
 CLEANUP:
-       g_mtxGlobalInstance->unlock();
-       return res;
+    g_mtxGlobalInstance->unlock();
+    return res;
 }
 
-SSMRESULT CreateInstance(IN const OID& objectID, OUT IBase** ppObject)
+SSMRESULT CreateInstance(IN const OID &objectID, OUT IBase **ppObject)
 {
-       SSMRESULT res = SSM_E_NOINTERFACE;
-
-       if(ppObject == NULL)
-       {
-               return SSM_E_POINTER;
-       }
-
-       *ppObject = NULL;
-
-       if (IsEqualOID(OID_ITasker, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CTasker>(objectID, ppObject));
-       }
-       else if (IsEqualOID(OID_IWorkerThread, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CWorkerThread>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IThreadPool, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CThreadPool>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IEvaluationEngine, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CEvaluationEngine>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IPropagationEngine, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CPropagationEngine>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IContextRepository, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CContextRepository>(objectID, ppObject));
-       }
-       else if (IsEqualOID(OID_IResponseReactor, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CResponseReactor>(objectID, ppObject));
-       }
-       else if (IsEqualOID(OID_IContextExecutor, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CContextExecutor>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IContextModel, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CContextModel>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IConditionedModel, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CConditionedModel>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IConditionedQueryResult, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CConditionedQueryResult>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IConditionedQuery, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CConditionedQuery>(objectID, ppObject));
-       }
-       else if (IsEqualOID(OID_IResourceFinder, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CResourceFinder>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IQueryEngineInternal, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CQueryEngine>(objectID, ppObject));
-       }
-       else if (IsEqualOID(OID_ISoftSensorManager, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CSoftSensorManager>(objectID, ppObject));
-       }
-       else if(IsEqualOID(OID_IContextDataReader, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CContextDataReader>(objectID, ppObject));
-       }
-       else if (IsEqualOID(OID_IResourceConnectivity, objectID))
-       {
-               SSM_CLEANUP_ASSERT(CreateNewObject<CResourceConnectivity>(objectID, ppObject));
-       }
+    SSMRESULT res = SSM_E_NOINTERFACE;
+
+    if (ppObject == NULL)
+    {
+        return SSM_E_POINTER;
+    }
+
+    *ppObject = NULL;
+
+    if (IsEqualOID(OID_ITasker, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CTasker>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IWorkerThread, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CWorkerThread>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IThreadPool, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CThreadPool>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IEvaluationEngine, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CEvaluationEngine>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IPropagationEngine, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CPropagationEngine>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IContextRepository, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CContextRepository>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IResponseReactor, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CResponseReactor>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IContextExecutor, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CContextExecutor>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IContextModel, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CContextModel>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IConditionedModel, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CConditionedModel>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IConditionedQueryResult, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CConditionedQueryResult>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IConditionedQuery, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CConditionedQuery>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IResourceFinder, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CResourceFinder>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IQueryEngineInternal, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CQueryEngine>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_ISoftSensorManager, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CSoftSensorManager>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IContextDataReader, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CContextDataReader>(objectID, ppObject));
+    }
+    else if (IsEqualOID(OID_IResourceConnectivity, objectID))
+    {
+        SSM_CLEANUP_ASSERT(CreateNewObject<CResourceConnectivity>(objectID, ppObject));
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CreateGlobalInstanceRepo()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       if (g_mtxGlobalInstance != NULL)
-               SSM_CLEANUP_ASSERT(SSM_E_OUTOFMEMORY);
+    if (g_mtxGlobalInstance != NULL)
+        SSM_CLEANUP_ASSERT(SSM_E_OUTOFMEMORY);
 
-       if (g_globalInstance != NULL)
-               SSM_CLEANUP_ASSERT(SSM_E_OUTOFMEMORY);
+    if (g_globalInstance != NULL)
+        SSM_CLEANUP_ASSERT(SSM_E_OUTOFMEMORY);
 
-       g_mtxGlobalInstance = new CSimpleMutex();
-       SSM_CLEANUP_NULL_ASSERT(g_mtxGlobalInstance);
-       g_globalInstance = new std::map<OID, IBase*>();
-       SSM_CLEANUP_NULL_ASSERT(g_globalInstance);
-       
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IThreadPool, (IBase**)&g_pThreadPool));
+    g_mtxGlobalInstance = new CSimpleMutex();
+    SSM_CLEANUP_NULL_ASSERT(g_mtxGlobalInstance);
+    g_globalInstance = new std::map<OID, IBase *>();
+    SSM_CLEANUP_NULL_ASSERT(g_globalInstance);
+
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IThreadPool, (IBase **)&g_pThreadPool));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT DestroyGlobalInstanceRepo()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
+
+    SSM_CLEANUP_ASSERT(g_pThreadPool->destroyThreadPool());
 
-       SSM_CLEANUP_ASSERT(g_pThreadPool->destroyThreadPool());
+    SAFE_RELEASE(g_pThreadPool);
+    SAFE_DELETE(g_mtxGlobalInstance);
+    SAFE_DELETE(g_globalInstance);
 
-       SAFE_RELEASE(g_pThreadPool);
-       SAFE_DELETE(g_mtxGlobalInstance);
-       SAFE_DELETE(g_globalInstance);
-       
 CLEANUP:
-       return res;
+    return res;
 }
index 989bc4a..1718097 100644 (file)
 /**
 * @class    CSoftSensorManager
 * @brief    CSoftSensorManager Interface
-*                       This class represents main class of SSM.
+*            This class represents main class of SSM.
 *
-* @see      
-*                      static ISoftSensorManager               *g_pSoftSensorManager = NULL;
-*                      CreateInstance(OID_ISoftSensorManager, (IBase**)&g_pSoftSensorManager);
-*                      g_pSoftSensorManager->TerminateCore();
-*                      g_pSoftSensorManager->Release();
+* @see
+*           static ISoftSensorManager       *g_pSoftSensorManager = NULL;
+*           CreateInstance(OID_ISoftSensorManager, (IBase**)&g_pSoftSensorManager);
+*           g_pSoftSensorManager->TerminateCore();
+*           g_pSoftSensorManager->Release();
 */
 
 class CSoftSensorManager :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public ISoftSensorManager
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public ISoftSensorManager
 {
-private:
-       CObjectPtr<IContextRepository>          m_pContextRepository;
-       CObjectPtr<IPropagationEngine>          m_pPropagationEngine;
-       CObjectPtr<IResponseReactor>            m_pResponseReactor;
-
-public:
-       SSMRESULT finalConstruct();
-
-       void finalRelease();
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if (IsEqualOID(objectID, OID_ISoftSensorManager))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn initializeCore
-       * @brief Initialize core using given configuration information.
-       *                       <SSMCore>
-       *                               <Device>
-       *                                       <UDN>windows7-31f8-11b4-a222-08002b34c003</UDN>
-       *                                       <Name>MyPC</Name>
-       *                                       <Type>PC</Type>
-       *                               </Device>
-       *                       </SSMCore>
-       *
-       * @param [in] std::string xmlDescription - specification described in XML
-       * @param [out] IBase** ppvObject - reference pointer to get instance pointer
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT initializeCore(IN std::string xmlDescription);
-
-       /**
-       * @fn startCore
-       * @brief Start Core.
-       *                 This enables network capability that can discover and discovered.
-       *
-       * @param None
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT startCore();
-
-       /**
-       * @fn stopCore
-       * @brief Stop Core.
-       *                 This disables network capability that can discover and discovered.
-       *
-       * @param None
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT stopCore();
-
-       /**
-       * @fn TerminateCore
-       * @brief Terminates Core.
-       *                 Free all allocated resources
-       *
-       * @param None
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT terminateCore(IN bool factoryResetFlag);
-
-       /**
-       * @fn createQueryEngine
-       * @brief Create new Query Engine instance.
-       *                 Each engine instance has it's own event thread
-       *                 we recommend each application should creates only one instance.
-       *
-       * @param [out] IQueryEngine **ppQueryEngine - instance pointer of new Query Engine
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT createQueryEngine(OUT IQueryEngine **ppQueryEngine);
-
-       /**
-       * @fn releaseQueryEngine
-       * @brief Release exists Query Engine instance.
-       *
-       * @param [in] IQueryEngine *pQueryEngine - instance pointer of exists Query Engine
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       unsigned long releaseQueryEngine(IN IQueryEngine *pQueryEngine);
-
-       /**
-       * @fn getInstalledModelList
-       * @brief Gets all installed models from local and remote
-       *
-       * @param [out] std::vector<ISSMResource*> *pList - List of installed context model
-       *
-       * @return SSMRESULT
-       * @warning      
-       * @exception    
-       * @see 
-       */
-       SSMRESULT getInstalledModelList(OUT std::vector<ISSMResource*> *pList);
+    private:
+        CObjectPtr<IContextRepository>      m_pContextRepository;
+        CObjectPtr<IPropagationEngine>      m_pPropagationEngine;
+        CObjectPtr<IResponseReactor>        m_pResponseReactor;
+
+    public:
+        SSMRESULT finalConstruct();
+
+        void finalRelease();
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_ISoftSensorManager))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn initializeCore
+        * @brief Initialize core using given configuration information.
+        *           <SSMCore>
+        *               <Device>
+        *                   <UDN>windows7-31f8-11b4-a222-08002b34c003</UDN>
+        *                   <Name>MyPC</Name>
+        *                   <Type>PC</Type>
+        *               </Device>
+        *           </SSMCore>
+        *
+        * @param [in] std::string xmlDescription - specification described in XML
+        * @param [out] IBase** ppvObject - reference pointer to get instance pointer
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT initializeCore(IN std::string xmlDescription);
+
+        /**
+        * @fn startCore
+        * @brief Start Core.
+        *         This enables network capability that can discover and discovered.
+        *
+        * @param None
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT startCore();
+
+        /**
+        * @fn stopCore
+        * @brief Stop Core.
+        *         This disables network capability that can discover and discovered.
+        *
+        * @param None
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT stopCore();
+
+        /**
+        * @fn TerminateCore
+        * @brief Terminates Core.
+        *         Free all allocated resources
+        *
+        * @param None
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT terminateCore(IN bool factoryResetFlag);
+
+        /**
+        * @fn createQueryEngine
+        * @brief Create new Query Engine instance.
+        *         Each engine instance has it's own event thread
+        *         we recommend each application should creates only one instance.
+        *
+        * @param [out] IQueryEngine **ppQueryEngine - instance pointer of new Query Engine
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT createQueryEngine(OUT IQueryEngine **ppQueryEngine);
+
+        /**
+        * @fn releaseQueryEngine
+        * @brief Release exists Query Engine instance.
+        *
+        * @param [in] IQueryEngine *pQueryEngine - instance pointer of exists Query Engine
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        unsigned long releaseQueryEngine(IN IQueryEngine *pQueryEngine);
+
+        /**
+        * @fn getInstalledModelList
+        * @brief Gets all installed models from local and remote
+        *
+        * @param [out] std::vector<ISSMResource*> *pList - List of installed context model
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getInstalledModelList(OUT std::vector<ISSMResource *> *pList);
 };
 
 #endif
index d75cfd2..bf96c57 100644 (file)
 #include "SSMResourceServer.h"
 
 string xmlDescription = "<SSMCore>"
-        "<Device>"
-        "<UDN>abcde123-31f8-11b4-a222-08002b34c003</UDN>"
-        "<Name>MyPC</Name>"
-        "<Type>PC</Type>"
-        "</Device>"
-        "</SSMCore>";
+                        "<Device>"
+                        "<UDN>abcde123-31f8-11b4-a222-08002b34c003</UDN>"
+                        "<Name>MyPC</Name>"
+                        "<Type>PC</Type>"
+                        "</Device>"
+                        "</SSMCore>";
 
 using namespace std;
 
-int main(int argc, charargv[])
+int main(int argc, char *argv[])
 {
     int inputKey = 0;
 
index 0f5976e..d043a43 100644 (file)
 
 SSMRESULT CContextDataReader::finalConstruct()
 {
-       m_pContextModelAccessor = NULL;
-       return SSM_S_OK;
+    m_pContextModelAccessor = NULL;
+    return SSM_S_OK;
 }
 
 void CContextDataReader::finalRelease()
 {
-       m_pContextModelAccessor = NULL;
+    m_pContextModelAccessor = NULL;
 }
 
-SSMRESULT CContextDataReader::registerContextModelAccessor(IN IContextModelAccessor *pContextModelAccessor)
+SSMRESULT CContextDataReader::registerContextModelAccessor(IN IContextModelAccessor
+        *pContextModelAccessor)
 {
-       m_pContextModelAccessor = pContextModelAccessor;
-       
-       return SSM_S_OK;
+    m_pContextModelAccessor = pContextModelAccessor;
+
+    return SSM_S_OK;
 }
 
-SSMRESULT CContextDataReader::getContextData(IN std::string modelName, IN int startIndex, IN int count, OUT std::vector<ContextData> *data, OUT int *pLastIndex)
+SSMRESULT CContextDataReader::getContextData(IN std::string modelName, IN int startIndex,
+        IN int count, OUT std::vector<ContextData> *data, OUT int *pLastIndex)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::vector<ModelPropertyVec>   modelDataSet;
-       CObjectPtr<IContextModel>       pContextModel;
+    SSMRESULT res = SSM_E_FAIL;
+    std::vector<ModelPropertyVec>   modelDataSet;
+    CObjectPtr<IContextModel>   pContextModel;
 
-       SSM_CLEANUP_ASSERT(m_pContextModelAccessor->onQueryContextModel(modelName, &pContextModel));
+    SSM_CLEANUP_ASSERT(m_pContextModelAccessor->onQueryContextModel(modelName, &pContextModel));
 
-       SSM_CLEANUP_ASSERT(pContextModel->getModelDataSet(startIndex, count, &modelDataSet, pLastIndex));
+    SSM_CLEANUP_ASSERT(pContextModel->getModelDataSet(startIndex, count, &modelDataSet, pLastIndex));
 
-       for(std::vector<ModelPropertyVec>::iterator itorModelPropertyVec = modelDataSet.begin();
-               itorModelPropertyVec != modelDataSet.end(); ++itorModelPropertyVec)
-       {
-               ContextData contextData;
+    for (std::vector<ModelPropertyVec>::iterator itorModelPropertyVec = modelDataSet.begin();
+         itorModelPropertyVec != modelDataSet.end(); ++itorModelPropertyVec)
+    {
+        ContextData contextData;
 
-               contextData.rootName = pContextModel->getModelName();
-               contextData.outputPropertyCount = (int)itorModelPropertyVec->size();
+        contextData.rootName = pContextModel->getModelName();
+        contextData.outputPropertyCount = (int)itorModelPropertyVec->size();
 
-               for(ModelPropertyVec::iterator itor = itorModelPropertyVec->begin(); 
-                       itor != itorModelPropertyVec->end(); ++itor)
-               {
-                       std::map<std::string, std::string> propertySet;
+        for (ModelPropertyVec::iterator itor = itorModelPropertyVec->begin();
+             itor != itorModelPropertyVec->end(); ++itor)
+        {
+            std::map<std::string, std::string> propertySet;
 
-                       switch(itor->propertyType)
-                       {
-                       case ModelProperty::TYPE_INTEGER:
-                       case ModelProperty::TYPE_NUMERIC:
-                               propertySet["type"] = "int";
-                               break;
+            switch (itor->propertyType)
+            {
+                case ModelProperty::TYPE_INTEGER:
+                case ModelProperty::TYPE_NUMERIC:
+                    propertySet["type"] = "int";
+                    break;
 
-                       case ModelProperty::TYPE_REAL:
-                               propertySet["type"] = "double";
-                               break;
+                case ModelProperty::TYPE_REAL:
+                    propertySet["type"] = "double";
+                    break;
 
-                       case ModelProperty::TYPE_TEXT:
-                               propertySet["type"] = "string";
-                               break;
+                case ModelProperty::TYPE_TEXT:
+                    propertySet["type"] = "string";
+                    break;
 
-                       default:
-                               propertySet["type"] = "string";
-                       }
+                default:
+                    propertySet["type"] = "string";
+            }
 
-                       propertySet["name"] = itor->propertyName;
-                       propertySet["value"] = itor->propertyValue;
+            propertySet["name"] = itor->propertyName;
+            propertySet["value"] = itor->propertyValue;
 
-                       contextData.outputProperty.push_back(propertySet);
-               }
+            contextData.outputProperty.push_back(propertySet);
+        }
 
-               data->push_back(contextData);
-       }
+        data->push_back(contextData);
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
index 27ade21..97026d8 100644 (file)
 /**
 * @class    CContextDataReader
 * @brief    CContextDataReader Interface
-*                       This class represents ContextData reader
+*            This class represents ContextData reader
 *
 * @see
 */
-class CContextDataReader : 
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IContextDataReader
+class CContextDataReader :
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IContextDataReader
 {
-private:
-       IContextModelAccessor           *m_pContextModelAccessor;
+    private:
+        IContextModelAccessor       *m_pContextModelAccessor;
 
-public:
-       SSMRESULT finalConstruct();
+    public:
+        SSMRESULT finalConstruct();
 
-       void finalRelease();
+        void finalRelease();
 
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-               
-               if(IsEqualOID(objectID, OID_IContextDataReader))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
 
-               return SSM_E_NOINTERFACE;
-       }
+            if (IsEqualOID(objectID, OID_IContextDataReader))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
 
-       /**
-       * @fn     registerContextModelAccessor
-       * @brief Called when ContextModelAccessor wants to query installed ContextModel
-       *
-       * @param [in] IContextModelAccessor *pContextModelAccessor - Instance of implemented IContextModelAccessor interface
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT registerContextModelAccessor(IN IContextModelAccessor *pContextModelAccessor);
+            return SSM_E_NOINTERFACE;
+        }
 
-       /**
-       * @fn     getContextData
-       * @brief Retrieve ContextData using given ContextModel name and dataId
-       *
-       * @param [in] std::string modelName - ContextModel name
-       * @param [in] int startIndex - Starting index of model data
-       * @param [in] int count - Number of data to retrieve
-       * @param [out] std::vector<ContextData> *data - ContextData set
-       * @param [out] int *pLastIndex - Index of last data
-       * 
-       * @return SSMRESULT
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getContextData(IN std::string modelName, IN int startIndex, IN int count, OUT std::vector<ContextData> *data, OUT int *pLastIndex);
+        /**
+        * @fn     registerContextModelAccessor
+        * @brief Called when ContextModelAccessor wants to query installed ContextModel
+        *
+        * @param [in] IContextModelAccessor *pContextModelAccessor - Instance of implemented IContextModelAccessor interface
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT registerContextModelAccessor(IN IContextModelAccessor *pContextModelAccessor);
+
+        /**
+        * @fn     getContextData
+        * @brief Retrieve ContextData using given ContextModel name and dataId
+        *
+        * @param [in] std::string modelName - ContextModel name
+        * @param [in] int startIndex - Starting index of model data
+        * @param [in] int count - Number of data to retrieve
+        * @param [out] std::vector<ContextData> *data - ContextData set
+        * @param [out] int *pLastIndex - Index of last data
+        *
+        * @return SSMRESULT
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getContextData(IN std::string modelName, IN int startIndex, IN int count,
+                                 OUT std::vector<ContextData> *data, OUT int *pLastIndex);
 };
 #endif
index 648be81..9f26e55 100644 (file)
 
 SSMRESULT CContextExecutor::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       ctxEvent = NULL;
+    ctxEvent = NULL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase**)&m_pTasker));
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase**)&m_pContextRepository));
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextDataReader, (IBase**)&m_pContextDataReader));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextDataReader, (IBase **)&m_pContextDataReader));
 
-       SSM_CLEANUP_ASSERT(m_pContextRepository->registerResourceFinderEvent(this));
-       
-       SSM_CLEANUP_ASSERT(m_pContextRepository->startResourceFinder());
+    SSM_CLEANUP_ASSERT(m_pContextRepository->registerResourceFinderEvent(this));
+
+    SSM_CLEANUP_ASSERT(m_pContextRepository->startResourceFinder());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CContextExecutor::finalRelease()
@@ -43,387 +43,396 @@ void CContextExecutor::finalRelease()
 
 void CContextExecutor::registerCallback(ICtxEvent *pEvent)
 {
-       ctxEvent = pEvent;
+    ctxEvent = pEvent;
 }
 
 //Data from soft sensors
 void CContextExecutor::addOutput(std::vector<ContextData> contextData)
 {
-       //LOGE("ADDOUTPUT");
-       std::map<std::string, CallbackData>::iterator   itor;
-       std::string type = contextData[0].rootName;
-
-       //TODO: name must be a this soft sensors identifier
-       //m_mtxRequestedContextCallback.Lock();
-       itor = m_requestedContextCallback.find(type);
-       if(itor != m_requestedContextCallback.end())
-       {
-               TypeofEvent callType = itor->second.m_callType;
-               itor->second.m_pCallbackEvent->onEvent(type, callType, contextData);
-               if(callType == SSM_ONCE)
-               {
-                       unregisterContext(callType, m_registeredResources[type], this);
-               }
-
-       }
-       //m_mtxRequestedContextCallback.Unlock();
+    //LOGE("ADDOUTPUT");
+    std::map<std::string, CallbackData>::iterator   itor;
+    std::string type = contextData[0].rootName;
+
+    //TODO: name must be a this soft sensors identifier
+    //m_mtxRequestedContextCallback.Lock();
+    itor = m_requestedContextCallback.find(type);
+    if (itor != m_requestedContextCallback.end())
+    {
+        TypeofEvent callType = itor->second.m_callType;
+        itor->second.m_pCallbackEvent->onEvent(type, callType, contextData);
+        if (callType == SSM_ONCE)
+        {
+            unregisterContext(callType, m_registeredResources[type], this);
+        }
+
+    }
+    //m_mtxRequestedContextCallback.Unlock();
 }
 
-void CContextExecutor::getDataFromDatabase(std::string modelName, int startIndex, int count, std::vector<ContextData> *data, int *pLastIndex)
+void CContextExecutor::getDataFromDatabase(std::string modelName, int startIndex, int count,
+        std::vector<ContextData> *data, int *pLastIndex)
 {
-       m_pContextDataReader->getContextData(modelName, startIndex, count, data, pLastIndex);
+    m_pContextDataReader->getContextData(modelName, startIndex, count, data, pLastIndex);
 }
 
 std::string CContextExecutor::checkError(std::vector<ContextData> data)
 {
-       std::string errorMsg = "OK";
-
-       for(unsigned int i = 0 ; i < data.size() ; ++i)
-       {
-               if(data[i].outputProperty[0].find("error") != data[i].outputProperty[0].end())
-               {
-                       errorMsg = data[i].outputProperty[0].find("error")->second ;
-                       break;
-               }
-       }
-
-       return errorMsg;
+    std::string errorMsg = "OK";
+
+    for (unsigned int i = 0 ; i < data.size() ; ++i)
+    {
+        if (data[i].outputProperty[0].find("error") != data[i].outputProperty[0].end())
+        {
+            errorMsg = data[i].outputProperty[0].find("error")->second ;
+            break;
+        }
+    }
+
+    return errorMsg;
 }
 
-void CContextExecutor::registerContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent)
-{  
-       //will make check routine for One resource has callbacks.
-       std::vector<ISSMResource*>      baseList;
-
-       CallbackData callbackData(callType, pSSMResource->name, pEvent);
-       
-       //m_mtxRequestedContextCallback.Lock();
-       m_registeredResources[pSSMResource->type] = pSSMResource;
-       m_requestedContextCallback[pSSMResource->type] = callbackData;
-       //m_mtxRequestedContextCallback.Unlock();
-
-       //This is stand-alone sensor
-       if (pSSMResource->inputList.size() == 0)
-       {
-               //Let sensors work
-               std::vector<ContextData> inputData;
-               switch (pSSMResource->location)
-               {
-               case SENSOR_LOCATION_LOCAL:
-                       runLogic(inputData, pSSMResource->type);
-                       break;
-
-               case SENSOR_LOCATION_REMOTE:
-                       //Let observer work!
-                       m_pContextRepository->startObserveResource(pSSMResource, this);
-                       break;
-               }
-       }
-
-       m_pContextRepository->getPrimitiveSensorList(&baseList);
-       m_pContextRepository->getSoftSensorList(&baseList);
-
-       for (unsigned int i = 0; i < pSSMResource->inputList.size(); ++i)
-       {
-               ISSMResource *pKeyResource = NULL;
-               if (findString(&baseList, pSSMResource->inputList[i], &pKeyResource) != SSM_E_FAIL) //if element of inputList is in the primitive resources.
-               {
-                       if (m_relatedSoftSensor.find(pKeyResource->type) != m_relatedSoftSensor.end()) //already exists
-                       {
-                               //EXIST!!!!
-                               //check related Context needs insert or not. if softSensor resource is not a member of related context then insert.
-                               std::vector<std::string> softSensorList = m_relatedSoftSensor[pKeyResource->type];
-
-                               for (unsigned int j = 0; j < softSensorList.size(); ++j)
-                               {
-                                       if (softSensorList[j].compare(pSSMResource->type) != 0)
-                                       {
-                                               m_relatedSoftSensor[pKeyResource->type].push_back(pSSMResource->type);
-                                               break;
-                                       }
-                               }
-                       }
-                       else // If first time
-                       {
-                               //NO EXIST!!!!
-                               //insert resource in the all map and vector
-                               m_relatedSoftSensor[pKeyResource->type].push_back(pSSMResource->type);
-
-                               //Recursive call
-                               registerContext(callType, pKeyResource, this);
-                       }
-               }
-               else //unable to find installed sensors. take it to keep list
-               {
-                       m_mapResourceLookup[pSSMResource->inputList[i]].push_back(CallbackData(callType, pSSMResource->type, this));
-               }
-       }
+void CContextExecutor::registerContext(TypeofEvent callType, ISSMResource *pSSMResource,
+                                       IEvent *pEvent)
+{
+    //will make check routine for One resource has callbacks.
+    std::vector<ISSMResource *>  baseList;
+
+    CallbackData callbackData(callType, pSSMResource->name, pEvent);
+
+    //m_mtxRequestedContextCallback.Lock();
+    m_registeredResources[pSSMResource->type] = pSSMResource;
+    m_requestedContextCallback[pSSMResource->type] = callbackData;
+    //m_mtxRequestedContextCallback.Unlock();
+
+    //This is stand-alone sensor
+    if (pSSMResource->inputList.size() == 0)
+    {
+        //Let sensors work
+        std::vector<ContextData> inputData;
+        switch (pSSMResource->location)
+        {
+            case SENSOR_LOCATION_LOCAL:
+                runLogic(inputData, pSSMResource->type);
+                break;
+
+            case SENSOR_LOCATION_REMOTE:
+                //Let observer work!
+                m_pContextRepository->startObserveResource(pSSMResource, this);
+                break;
+        }
+    }
+
+    m_pContextRepository->getPrimitiveSensorList(&baseList);
+    m_pContextRepository->getSoftSensorList(&baseList);
+
+    for (unsigned int i = 0; i < pSSMResource->inputList.size(); ++i)
+    {
+        ISSMResource *pKeyResource = NULL;
+        if (findString(&baseList, pSSMResource->inputList[i],
+                       &pKeyResource) != SSM_E_FAIL) //if element of inputList is in the primitive resources.
+        {
+            if (m_relatedSoftSensor.find(pKeyResource->type) != m_relatedSoftSensor.end()) //already exists
+            {
+                //EXIST!!!!
+                //check related Context needs insert or not. if softSensor resource is not a member of related context then insert.
+                std::vector<std::string> softSensorList = m_relatedSoftSensor[pKeyResource->type];
+
+                for (unsigned int j = 0; j < softSensorList.size(); ++j)
+                {
+                    if (softSensorList[j].compare(pSSMResource->type) != 0)
+                    {
+                        m_relatedSoftSensor[pKeyResource->type].push_back(pSSMResource->type);
+                        break;
+                    }
+                }
+            }
+            else // If first time
+            {
+                //NO EXIST!!!!
+                //insert resource in the all map and vector
+                m_relatedSoftSensor[pKeyResource->type].push_back(pSSMResource->type);
+
+                //Recursive call
+                registerContext(callType, pKeyResource, this);
+            }
+        }
+        else //unable to find installed sensors. take it to keep list
+        {
+            m_mapResourceLookup[pSSMResource->inputList[i]].push_back(CallbackData(callType, pSSMResource->type,
+                    this));
+        }
+    }
 }
 
-void CContextExecutor::onExecute(IN voidpArg)
+void CContextExecutor::onExecute(IN void *pArg)
 {
-       int                     *pMessage = (int*)pArg;
+    int         *pMessage = (int *)pArg;
 
-       RESOURCE_EVENT_TYPE             eventType = (RESOURCE_EVENT_TYPE)pMessage[0];
-       ISSMResource                    *pResource = (ISSMResource*)pMessage[1];
+    RESOURCE_EVENT_TYPE     eventType = (RESOURCE_EVENT_TYPE)pMessage[0];
+    ISSMResource            *pResource = (ISSMResource *)pMessage[1];
 
-       switch (eventType)
-       {
-       case SSM_EVENT_NORMAL:
-               break;
+    switch (eventType)
+    {
+        case SSM_EVENT_NORMAL:
+            break;
 
-       case SSM_EVENT_ADDED:
-               if (m_mapResourceLookup.find(pResource->type) != m_mapResourceLookup.end())
-               {
-                       CallbackData            *callBack = NULL;
+        case SSM_EVENT_ADDED:
+            if (m_mapResourceLookup.find(pResource->type) != m_mapResourceLookup.end())
+            {
+                CallbackData        *callBack = NULL;
 
-                       for (size_t i = 0; i < m_mapResourceLookup[pResource->type].size(); i++)
-                       {
-                               callBack = &m_mapResourceLookup[pResource->type][i];
+                for (size_t i = 0; i < m_mapResourceLookup[pResource->type].size(); i++)
+                {
+                    callBack = &m_mapResourceLookup[pResource->type][i];
 
-                               m_relatedSoftSensor[pResource->type].push_back(callBack->m_name);
+                    m_relatedSoftSensor[pResource->type].push_back(callBack->m_name);
 
-                               registerContext(callBack->m_callType, pResource, callBack->m_pCallbackEvent);
-                       }
+                    registerContext(callBack->m_callType, pResource, callBack->m_pCallbackEvent);
+                }
 
-                       m_mapResourceLookup.erase(m_mapResourceLookup.find(pResource->type));
-               }
-               break;
+                m_mapResourceLookup.erase(m_mapResourceLookup.find(pResource->type));
+            }
+            break;
 
-       case SSM_REMOVED:
-               break;
+        case SSM_REMOVED:
+            break;
 
-       case SSM_UPDATED:
-               break;
+        case SSM_UPDATED:
+            break;
 
-       default:
-               break;
-       }
+        default:
+            break;
+    }
 }
 
-void CContextExecutor::onTerminate(IN voidpArg)
+void CContextExecutor::onTerminate(IN void *pArg)
 {
-       int                     *pMessage = (int*)pArg;
+    int         *pMessage = (int *)pArg;
 
-       delete[] pMessage;
+    delete[] pMessage;
 }
 
-int CContextExecutor::onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource, std::string info)
+int CContextExecutor::onResourceEvent(RESOURCE_EVENT_TYPE eventType, ISSMResource *pSSMResource,
+                                      std::string info)
 {
-       int                     *pMessage = new int[2];
+    int         *pMessage = new int[2];
 
-       pMessage[0] = eventType;
-       pMessage[1] = (int)pSSMResource;
-       return (int)m_pTasker->addTask(this, (void*)pMessage);
+    pMessage[0] = eventType;
+    pMessage[1] = (int)pSSMResource;
+    return (int)m_pTasker->addTask(this, (void *)pMessage);
 }
 
-SSMRESULT CContextExecutor::findString(std::vector<ISSMResource*> *sList, const std::string str, ISSMResource **ppResource)
-{      
-       SSMRESULT ret = SSM_E_FAIL;
-       for(unsigned int i = 0 ; i < sList->size() ; ++i)
-       {
-               if((*sList)[i]->type == str)
-               {
-                       *ppResource = (*sList)[i];
-                       ret = SSM_S_OK;
-                       break;
-               }
-       }
-       return ret;
+SSMRESULT CContextExecutor::findString(std::vector<ISSMResource *> *sList, const std::string str,
+                                       ISSMResource **ppResource)
+{
+    SSMRESULT ret = SSM_E_FAIL;
+    for (unsigned int i = 0 ; i < sList->size() ; ++i)
+    {
+        if ((*sList)[i]->type == str)
+        {
+            *ppResource = (*sList)[i];
+            ret = SSM_S_OK;
+            break;
+        }
+    }
+    return ret;
 }
 
-std::map<std::string, std::vector<ContextData> >  CContextExecutor::getPreparedContextList(std::string primitiveSensor)
+std::map<std::string, std::vector<ContextData> >  CContextExecutor::getPreparedContextList(
+    std::string primitiveSensor)
 {
-       //check m_relatedSoftSensor / apply timestamp
-       std::map<std::string, std::vector<ContextData> > returnData;
-
-       SSMRESULT ret = SSM_E_FAIL;
-
-       for (unsigned int i = 0; i < m_relatedSoftSensor[primitiveSensor].size(); ++i)
-       {
-               std::string softSensorName = m_relatedSoftSensor[primitiveSensor][i];
-               if (m_registeredResources.find(softSensorName) != m_registeredResources.end())
-               {
-                       ret = SSM_S_OK;
-                       std::vector<std::string> inputList = m_registeredResources[softSensorName]->inputList;
-                       std::vector<ContextData> contextDataList;
-                       for (unsigned int j = 0; j < inputList.size(); j++) //check all "inputlist" arrived or not
-                       {
-                               if (m_storedPrimitiveSensorData.find(inputList[j]) == m_storedPrimitiveSensorData.end())
-                               {
-                                       ret = SSM_E_FAIL;
-                                       break;
-                               }
-                               else
-                               {
-                                       std::vector<ContextData> primitiveSensorData = m_storedPrimitiveSensorData[inputList[j]];
-                                       for (unsigned k = 0; k < primitiveSensorData.size(); k++)
-                                       {
-                                               contextDataList.push_back(primitiveSensorData[k]);
-                                       }
-                               }
-                       }
-
-                       if (ret == SSM_S_OK)
-                       {
-                               returnData.insert(std::make_pair(softSensorName, contextDataList));
-                       }
-                       contextDataList.clear();
-               }
-       }
-
-       return returnData;
+    //check m_relatedSoftSensor / apply timestamp
+    std::map<std::string, std::vector<ContextData> > returnData;
+
+    SSMRESULT ret = SSM_E_FAIL;
+
+    for (unsigned int i = 0; i < m_relatedSoftSensor[primitiveSensor].size(); ++i)
+    {
+        std::string softSensorName = m_relatedSoftSensor[primitiveSensor][i];
+        if (m_registeredResources.find(softSensorName) != m_registeredResources.end())
+        {
+            ret = SSM_S_OK;
+            std::vector<std::string> inputList = m_registeredResources[softSensorName]->inputList;
+            std::vector<ContextData> contextDataList;
+            for (unsigned int j = 0; j < inputList.size(); j++) //check all "inputlist" arrived or not
+            {
+                if (m_storedPrimitiveSensorData.find(inputList[j]) == m_storedPrimitiveSensorData.end())
+                {
+                    ret = SSM_E_FAIL;
+                    break;
+                }
+                else
+                {
+                    std::vector<ContextData> primitiveSensorData = m_storedPrimitiveSensorData[inputList[j]];
+                    for (unsigned k = 0; k < primitiveSensorData.size(); k++)
+                    {
+                        contextDataList.push_back(primitiveSensorData[k]);
+                    }
+                }
+            }
+
+            if (ret == SSM_S_OK)
+            {
+                returnData.insert(std::make_pair(softSensorName, contextDataList));
+            }
+            contextDataList.clear();
+        }
+    }
+
+    return returnData;
 }
 
 //Data from every primitive sensors
-int CContextExecutor::onEvent(std::string type, TypeofEvent callType, std::vector<ContextData> ctxData)
+int CContextExecutor::onEvent(std::string type, TypeofEvent callType,
+                              std::vector<ContextData> ctxData)
 {
-       //std::string root_name = ctxData.at(0).root_name; //-> deviceId+ctxData.root_name
-
-       if (m_relatedSoftSensor.find(type) != m_relatedSoftSensor.end()) //already registered?
-       {
-               //update recent values(overwrite)               
-               m_storedPrimitiveSensorData[type] = ctxData;
-
-               //find soft sensor
-               std::map<std::string, std::vector<ContextData> > readyContextList = getPreparedContextList(type);
-
-               if (readyContextList.size() > 0)
-               {
-                       //Run SoftSensor!  readyContextList has all data for run
-                       std::map<std::string, std::vector<ContextData> >::iterator iter = readyContextList.begin();
-                       for (; iter != readyContextList.end(); ++iter)
-                       {
-                               std::string softSensorName = iter->first;
-                               std::vector<ContextData> inputData = iter->second;
-                               std::string errorMsg = checkError(inputData);
-
-                               if (!errorMsg.compare("OK"))
-                               {
-                                       runLogic(inputData, softSensorName);
-                               }
-                               else
-                               {
-                                       inputData.clear();
-                                       inputData.push_back(makeErrorContextData(softSensorName, errorMsg));
-                                       addOutput(inputData);
-                               }
-                       }
-               }
-       }
-       else //This data is primitive
-       {
-               //TODO: Temporally added for primitive data testing
-               addOutput(ctxData);
-       }
-
-       return SSM_S_OK;
+    //std::string root_name = ctxData.at(0).root_name; //-> deviceId+ctxData.root_name
+
+    if (m_relatedSoftSensor.find(type) != m_relatedSoftSensor.end()) //already registered?
+    {
+        //update recent values(overwrite)
+        m_storedPrimitiveSensorData[type] = ctxData;
+
+        //find soft sensor
+        std::map<std::string, std::vector<ContextData> > readyContextList = getPreparedContextList(type);
+
+        if (readyContextList.size() > 0)
+        {
+            //Run SoftSensor!  readyContextList has all data for run
+            std::map<std::string, std::vector<ContextData> >::iterator iter = readyContextList.begin();
+            for (; iter != readyContextList.end(); ++iter)
+            {
+                std::string softSensorName = iter->first;
+                std::vector<ContextData> inputData = iter->second;
+                std::string errorMsg = checkError(inputData);
+
+                if (!errorMsg.compare("OK"))
+                {
+                    runLogic(inputData, softSensorName);
+                }
+                else
+                {
+                    inputData.clear();
+                    inputData.push_back(makeErrorContextData(softSensorName, errorMsg));
+                    addOutput(inputData);
+                }
+            }
+        }
+    }
+    else //This data is primitive
+    {
+        //TODO: Temporally added for primitive data testing
+        addOutput(ctxData);
+    }
+
+    return SSM_S_OK;
 }
 
-void  CContextExecutor::unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent)
+void  CContextExecutor::unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource,
+        IEvent *pEvent)
 {
-       std::vector<ISSMResource*> baseList;    
-
-       //This is primitive sensor
-       if (pSSMResource->inputList.size() == 0)
-       {
-               //Let sensors work
-               std::vector<ContextData> inputData;
-               switch (pSSMResource->location)
-               {
-               case SENSOR_LOCATION_LOCAL:
-                       //TODO: Must free soft sensor
-                       if (m_libraryList.find(pSSMResource->type) != m_libraryList.end() && callType != SSM_ONCE)
-                       {
-                               m_pContextRepository->unloadSoftSensor(m_libraryList[pSSMResource->type]);
-                               m_libraryList.erase(m_libraryList.find(pSSMResource->type));
-                       }
-
-                       if (m_ctxEventList.find(pSSMResource->type) != m_ctxEventList.end())
-                       {
-                               m_ctxEventList.erase(m_ctxEventList.find(pSSMResource->type));
-                       }
-                       break;
-
-               case SENSOR_LOCATION_REMOTE:
-                       //Let observer stop work!
-                       m_pContextRepository->stopObserveResource(pSSMResource);
-                       break;
-               }
-       }
-
-       //m_mtxRequestedContextCallback.Lock();
-       if (m_requestedContextCallback.find(pSSMResource->type) != m_requestedContextCallback.end())
-       {
-               m_requestedContextCallback.erase(m_requestedContextCallback.find(pSSMResource->type));
-       }
-       if (m_registeredResources.find(pSSMResource->type) != m_registeredResources.end())
-       {
-               m_registeredResources.erase(m_registeredResources.find(pSSMResource->type));
-       }
-       //m_mtxRequestedContextCallback.Unlock();
-
-       //TODO: support multiple concurrent query reference
-       m_pContextRepository->getPrimitiveSensorList(&baseList);
-       m_pContextRepository->getSoftSensorList(&baseList);
-
-       for(unsigned int i = 0 ;i < pSSMResource->inputList.size() ; ++i)
-       {
-               ISSMResource *pPrimitiveSensor = NULL;
-               if (findString(&baseList, pSSMResource->inputList[i], &pPrimitiveSensor) != SSM_E_FAIL)
-               {
-                       std::vector<std::string> *softSensorList = &m_relatedSoftSensor[pPrimitiveSensor->type];
-                       for (unsigned int j = 0; j < softSensorList->size(); ++j)
-                       {
-                               if (!(*softSensorList)[j].compare(pSSMResource->type))
-                               {
-                                       softSensorList->erase(softSensorList->begin() + j);
-
-                                       if (softSensorList->size() == 0) //no more related context.
-                                       {
-                                               m_relatedSoftSensor.erase(m_relatedSoftSensor.find(pPrimitiveSensor->type));
-
-                                               //Recursive call
-                                               unregisterContext(callType, pPrimitiveSensor, this);
-                                               break;
-                                       }
-                               }
-                       }
-               }
-       }
+    std::vector<ISSMResource *> baseList;
+
+    //This is primitive sensor
+    if (pSSMResource->inputList.size() == 0)
+    {
+        //Let sensors work
+        std::vector<ContextData> inputData;
+        switch (pSSMResource->location)
+        {
+            case SENSOR_LOCATION_LOCAL:
+                //TODO: Must free soft sensor
+                if (m_libraryList.find(pSSMResource->type) != m_libraryList.end() && callType != SSM_ONCE)
+                {
+                    m_pContextRepository->unloadSoftSensor(m_libraryList[pSSMResource->type]);
+                    m_libraryList.erase(m_libraryList.find(pSSMResource->type));
+                }
+
+                if (m_ctxEventList.find(pSSMResource->type) != m_ctxEventList.end())
+                {
+                    m_ctxEventList.erase(m_ctxEventList.find(pSSMResource->type));
+                }
+                break;
+
+            case SENSOR_LOCATION_REMOTE:
+                //Let observer stop work!
+                m_pContextRepository->stopObserveResource(pSSMResource);
+                break;
+        }
+    }
+
+    //m_mtxRequestedContextCallback.Lock();
+    if (m_requestedContextCallback.find(pSSMResource->type) != m_requestedContextCallback.end())
+    {
+        m_requestedContextCallback.erase(m_requestedContextCallback.find(pSSMResource->type));
+    }
+    if (m_registeredResources.find(pSSMResource->type) != m_registeredResources.end())
+    {
+        m_registeredResources.erase(m_registeredResources.find(pSSMResource->type));
+    }
+    //m_mtxRequestedContextCallback.Unlock();
+
+    //TODO: support multiple concurrent query reference
+    m_pContextRepository->getPrimitiveSensorList(&baseList);
+    m_pContextRepository->getSoftSensorList(&baseList);
+
+    for (unsigned int i = 0 ; i < pSSMResource->inputList.size() ; ++i)
+    {
+        ISSMResource *pPrimitiveSensor = NULL;
+        if (findString(&baseList, pSSMResource->inputList[i], &pPrimitiveSensor) != SSM_E_FAIL)
+        {
+            std::vector<std::string> *softSensorList = &m_relatedSoftSensor[pPrimitiveSensor->type];
+            for (unsigned int j = 0; j < softSensorList->size(); ++j)
+            {
+                if (!(*softSensorList)[j].compare(pSSMResource->type))
+                {
+                    softSensorList->erase(softSensorList->begin() + j);
+
+                    if (softSensorList->size() == 0) //no more related context.
+                    {
+                        m_relatedSoftSensor.erase(m_relatedSoftSensor.find(pPrimitiveSensor->type));
+
+                        //Recursive call
+                        unregisterContext(callType, pPrimitiveSensor, this);
+                        break;
+                    }
+                }
+            }
+        }
+    }
 }
 
 //Called when soft sensor try to work
 void CContextExecutor::runLogic(std::vector<ContextData> inputData, std::string softSensor)
-{      
-       m_mtxLibraryIO.lock();
-       if (m_ctxEventList.find(softSensor) == m_ctxEventList.end())
-       {
-               void *hSoftSensor = NULL;
-               if (m_pContextRepository->loadSoftSensor(softSensor, this, &hSoftSensor) == SSM_S_OK)
-               {
-                       m_libraryList[softSensor] = hSoftSensor;
-                       m_ctxEventList[softSensor] = ctxEvent;
-                       m_ctxEventList[softSensor]->onCtxEvent(SPF_START, inputData);
-               }
-       }
-       else
-       {
-               m_ctxEventList[softSensor]->onCtxEvent(SPF_START, inputData);
-       }
-       m_mtxLibraryIO.unlock();
+{
+    m_mtxLibraryIO.lock();
+    if (m_ctxEventList.find(softSensor) == m_ctxEventList.end())
+    {
+        void *hSoftSensor = NULL;
+        if (m_pContextRepository->loadSoftSensor(softSensor, this, &hSoftSensor) == SSM_S_OK)
+        {
+            m_libraryList[softSensor] = hSoftSensor;
+            m_ctxEventList[softSensor] = ctxEvent;
+            m_ctxEventList[softSensor]->onCtxEvent(SPF_START, inputData);
+        }
+    }
+    else
+    {
+        m_ctxEventList[softSensor]->onCtxEvent(SPF_START, inputData);
+    }
+    m_mtxLibraryIO.unlock();
 }
 
 ContextData CContextExecutor::makeErrorContextData(std::string rootName, std::string errMsg)
 {
-       std::map<std::string,std::string> errorMap;
-       ContextData errorContextData;
-                                       
-       errorMap.insert(std::make_pair("error",errMsg));
-       errorMap.insert(std::make_pair("available","false"));
-       errorContextData.rootName = rootName;
-       errorContextData.outputPropertyCount = 2;
-       errorContextData.outputProperty.push_back(errorMap);
-                                       
-       return errorContextData;
+    std::map<std::string, std::string> errorMap;
+    ContextData errorContextData;
+
+    errorMap.insert(std::make_pair("error", errMsg));
+    errorMap.insert(std::make_pair("available", "false"));
+    errorContextData.rootName = rootName;
+    errorContextData.outputPropertyCount = 2;
+    errorContextData.outputProperty.push_back(errorMap);
+
+    return errorContextData;
 }
\ No newline at end of file
index 5626442..c8f88a9 100644 (file)
  * @class    CContextExecutor
  * @brief    Class for execute context model.
  *           Delegate requested context to lower layer.
- *                      Execute context model.
+ *           Execute context model.
  *
  * @see
  */
 class CContextExecutor :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IContextExecutor
-       , public IResourceEvent
-       , public IThreadClient
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IContextExecutor
+    , public IResourceEvent
+    , public IThreadClient
 {
-private:
-       CObjectPtr<ITasker>                             m_pTasker;
-
-       CObjectPtr<IContextRepository>  m_pContextRepository;
-
-       CObjectPtr<IContextDataReader>  m_pContextDataReader;
-
-       /**
-       * @brief Sensor data from primitive sensors
-       */
-       std::map<std::string, std::vector<ContextData> >                m_storedPrimitiveSensorData;
-       
-       /**
-       * @brief key = primitive, soft sensor / values = soft sensors that has key in the input list
-       */
-       std::map<std::string, std::vector<std::string> >                m_relatedSoftSensor;
-
-       /**
-       * @brief requested high layer's callback data.(IEvent instance, deviceId, call type)
-       */
-       std::map<std::string, CallbackData>                                     m_requestedContextCallback;
-
-       /**
-       * @brief registered high layer's context resource data.
-       */
-       std::map<std::string, ISSMResource *>                           m_registeredResources;
-       
-       /**
-       * @brief context model event of context model library
-       */
-       std::map<std::string, ICtxEvent*>                                       m_ctxEventList;
-       
-       /**
-       * @brief context model library list
-       */
-       std::map<std::string, void*>                                            m_libraryList;
-       
-       ICtxEvent                                                                                       *ctxEvent;
-       //CSimpleMutex                                                                          m_mtxRequestedContextCallback;
-
-       CSimpleMutex                                                                            m_mtxLibraryIO,m_mtxUserDataIO;
-
-       std::map<std::string, std::vector<CallbackData> >       m_mapResourceLookup;
-
-public:
-
-       SSMRESULT finalConstruct();
-       void finalRelease();
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IContextExecutor))
-               {
-                       IBase *pBase = (IContextExecutor*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn           registerCallback
-       * @brief        ICtxDelegate Interface. 
-       *                               If context model call this function, then get model's instance
-       *
-       * @param                [in]  ICtxEvent *pEvent -  context model's ICtxEvent instance.
-       *
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void registerCallback(IN ICtxEvent *pEvent);
-
-       /**
-       * @fn           addOutput
-       * @brief        ICtxDelegate Interface. 
-       *                               Get context model's result and delegate to upper layer.
-       *
-       * @param                [in]  std::vector<ContextData> contextData -  context model's result
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void addOutput(IN std::vector<ContextData> contextData);
-
-       /**
-       * @fn           getDataFromDatabase
-       * @brief        ICtxDelegate Interface. 
-       *                               Get context model's historical data
-       *
-       * @param                [in] std::string modelName - Model name that looking for
-       * @param                [in] int startIndex - Starting index of model data
-       * @param                [in] int count - Number of data to retrieve
-       * @param                [out] std::vector<ContextData> *data   -  data from database
-       * @param                [out] int *pLastIndex - Index of last data
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void getDataFromDatabase(IN std::string modelName, IN int startIndex, IN int count, OUT std::vector<ContextData> *data, OUT int *pLastIndex);
-       
-       /**
-       * @fn           onEvent
-       * @brief        IEvent Interface. 
-       *                               Call from lower layer when lower context data generated.
-       *
-       * @param                [in]  std::string deviceID -  caller device UUID.
-       * @param                [in]  TypeofEvent callType -  context event type.
-       * @param                [in]  std::vector<ContextData> ctxData -  context data
-       *
-       * @return       int - function result status
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       int onEvent(IN std::string deviceID, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
-       
-       /**
-       * @fn           registerContext
-       * @brief        Register context model request.
-       *
-       * @param                [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
-       * @param                [in]  ISSMResource *pSSMResource -  Requested context model resource.
-       * @param                [in]  IEvent *pEvent -  IEvent class for callback.
-       *
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResouce, IN IEvent *pEvent);
-
-       /**
-       * @fn           unregisterContext
-       * @brief        Unregister context model request.
-       *
-       * @param                [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
-       * @param                [in]  ISSMResource *pSSMResource -  Requested context model resource.
-       * @param                [in]  IEvent *pEvent -  IEvent class for callback.
-       *
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void  unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent);
-
-       void onExecute(void* pArg);
-       void onTerminate(void* pArg);
-       int onResourceEvent(IN RESOURCE_EVENT_TYPE eventType, IN ISSMResource *pSSMResource, IN std::string info);
-
-private:
-       SSMRESULT findString(IN std::vector<ISSMResource*> *sList, IN const std::string str, OUT ISSMResource **ppResource);
-       std::map<std::string, std::vector<ContextData> >  getPreparedContextList(IN std::string primitiveSensor);
-       void runLogic(IN std::vector<ContextData> inputData, IN std::string softSensor);
-       ContextData makeErrorContextData(IN std::string rootName, IN std::string errMsg);
-       std::string checkError(IN std::vector<ContextData> data);
+    private:
+        CObjectPtr<ITasker>             m_pTasker;
+
+        CObjectPtr<IContextRepository>  m_pContextRepository;
+
+        CObjectPtr<IContextDataReader>  m_pContextDataReader;
+
+        /**
+        * @brief Sensor data from primitive sensors
+        */
+        std::map<std::string, std::vector<ContextData> >        m_storedPrimitiveSensorData;
+
+        /**
+        * @brief key = primitive, soft sensor / values = soft sensors that has key in the input list
+        */
+        std::map<std::string, std::vector<std::string> >        m_relatedSoftSensor;
+
+        /**
+        * @brief requested high layer's callback data.(IEvent instance, deviceId, call type)
+        */
+        std::map<std::string, CallbackData>                 m_requestedContextCallback;
+
+        /**
+        * @brief registered high layer's context resource data.
+        */
+        std::map<std::string, ISSMResource *>               m_registeredResources;
+
+        /**
+        * @brief context model event of context model library
+        */
+        std::map<std::string, ICtxEvent *>                   m_ctxEventList;
+
+        /**
+        * @brief context model library list
+        */
+        std::map<std::string, void *>                        m_libraryList;
+
+        ICtxEvent                                           *ctxEvent;
+        //CSimpleMutex                                      m_mtxRequestedContextCallback;
+
+        CSimpleMutex                                        m_mtxLibraryIO, m_mtxUserDataIO;
+
+        std::map<std::string, std::vector<CallbackData> >   m_mapResourceLookup;
+
+    public:
+
+        SSMRESULT finalConstruct();
+        void finalRelease();
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IContextExecutor))
+            {
+                IBase *pBase = (IContextExecutor *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn           registerCallback
+        * @brief        ICtxDelegate Interface.
+        *               If context model call this function, then get model's instance
+        *
+        * @param        [in]  ICtxEvent *pEvent -  context model's ICtxEvent instance.
+        *
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void registerCallback(IN ICtxEvent *pEvent);
+
+        /**
+        * @fn           addOutput
+        * @brief        ICtxDelegate Interface.
+        *               Get context model's result and delegate to upper layer.
+        *
+        * @param        [in]  std::vector<ContextData> contextData -  context model's result
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void addOutput(IN std::vector<ContextData> contextData);
+
+        /**
+        * @fn           getDataFromDatabase
+        * @brief        ICtxDelegate Interface.
+        *               Get context model's historical data
+        *
+        * @param        [in] std::string modelName - Model name that looking for
+        * @param        [in] int startIndex - Starting index of model data
+        * @param        [in] int count - Number of data to retrieve
+        * @param        [out] std::vector<ContextData> *data   -  data from database
+        * @param        [out] int *pLastIndex - Index of last data
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void getDataFromDatabase(IN std::string modelName, IN int startIndex, IN int count,
+                                 OUT std::vector<ContextData> *data, OUT int *pLastIndex);
+
+        /**
+        * @fn           onEvent
+        * @brief        IEvent Interface.
+        *               Call from lower layer when lower context data generated.
+        *
+        * @param        [in]  std::string deviceID -  caller device UUID.
+        * @param        [in]  TypeofEvent callType -  context event type.
+        * @param        [in]  std::vector<ContextData> ctxData -  context data
+        *
+        * @return       int - function result status
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        int onEvent(IN std::string deviceID, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
+
+        /**
+        * @fn           registerContext
+        * @brief        Register context model request.
+        *
+        * @param        [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
+        * @param        [in]  ISSMResource *pSSMResource -  Requested context model resource.
+        * @param        [in]  IEvent *pEvent -  IEvent class for callback.
+        *
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResouce, IN IEvent *pEvent);
+
+        /**
+        * @fn           unregisterContext
+        * @brief        Unregister context model request.
+        *
+        * @param        [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
+        * @param        [in]  ISSMResource *pSSMResource -  Requested context model resource.
+        * @param        [in]  IEvent *pEvent -  IEvent class for callback.
+        *
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void  unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent);
+
+        void onExecute(void *pArg);
+        void onTerminate(void *pArg);
+        int onResourceEvent(IN RESOURCE_EVENT_TYPE eventType, IN ISSMResource *pSSMResource,
+                            IN std::string info);
+
+    private:
+        SSMRESULT findString(IN std::vector<ISSMResource *> *sList, IN const std::string str,
+                             OUT ISSMResource **ppResource);
+        std::map<std::string, std::vector<ContextData> >  getPreparedContextList(
+            IN std::string primitiveSensor);
+        void runLogic(IN std::vector<ContextData> inputData, IN std::string softSensor);
+        ContextData makeErrorContextData(IN std::string rootName, IN std::string errMsg);
+        std::string checkError(IN std::vector<ContextData> data);
 
 };
 
index e8a2fdf..f6c6423 100644 (file)
 ******************************************************************/
 #include "ContextRepository.h"
 
-static inline std::string trim_both(const std::stringstr)
+static inline std::string trim_both(const std::string &str)
 {
 
-       int npos = str.find_first_not_of(" \t\v\n");
-       if (npos == -1)
-       {
-               return "";
-       }
-       unsigned int n = (unsigned int)npos;
-       std::string tempString = n == std::string::npos ? str : str.substr(n, str.length());
+    int npos = str.find_first_not_of(" \t\v\n");
+    if (npos == -1)
+    {
+        return "";
+    }
+    unsigned int n = (unsigned int)npos;
+    std::string tempString = n == std::string::npos ? str : str.substr(n, str.length());
 
-       n = tempString.find_last_not_of(" \t\v\n");
-       return n == std::string::npos ? tempString : tempString.substr(0, n + 1);
+    n = tempString.find_last_not_of(" \t\v\n");
+    return n == std::string::npos ? tempString : tempString.substr(0, n + 1);
 }
 
 SSMRESULT CContextRepository::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IResourceFinder, (IBase**)&m_resourceFinder));
-       SSM_CLEANUP_ASSERT(m_resourceFinder->registerResourceFinderEvent(this));
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IResourceFinder, (IBase **)&m_resourceFinder));
+    SSM_CLEANUP_ASSERT(m_resourceFinder->registerResourceFinderEvent(this));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CContextRepository::startResourceFinder()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(m_resourceFinder->startResourceFinder());
+    SSM_CLEANUP_ASSERT(m_resourceFinder->startResourceFinder());
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CContextRepository::registerResourceFinderEvent(IN IResourceEvent *pResourceEvent)
 {
-       m_resourceEvents.push_back(pResourceEvent);
-       return SSM_S_OK;
+    m_resourceEvents.push_back(pResourceEvent);
+    return SSM_S_OK;
 }
 
 void CContextRepository::finalRelease()
 {
 }
 
-void CContextRepository::setCurrentDeviceInfo(IN std::string name, IN std::string type, IN std::string pathSoftSensors, IN std::string pathDescription)
+void CContextRepository::setCurrentDeviceInfo(IN std::string name, IN std::string type,
+        IN std::string pathSoftSensors, IN std::string pathDescription)
 {
-       //TODO: Someone need to provides a way to generate permanent uuid function
-       /*
-       m_currentDeviceInfo.friendlyName = name;
-       //m_currentDeviceInfo.ID="2fac1234-31f8-11b4-a222-08002b34c003";
-       m_currentDeviceInfo.ID = udn;
-       m_currentDeviceInfo.IPAddress = "127.0.0.1";
-       m_currentDeviceInfo.tp = tp;
-       //m_currentDeviceInfo.type = SSM_DEVICE_MOBILE;
-       m_currentDeviceInfo.type = td;
-       */
-       m_name = name;
-       m_type = type;
-       m_pathSoftSensors = pathSoftSensors;
-       m_pathSoftSensorsDescription = pathDescription;
+    //TODO: Someone need to provides a way to generate permanent uuid function
+    /*
+    m_currentDeviceInfo.friendlyName = name;
+    //m_currentDeviceInfo.ID="2fac1234-31f8-11b4-a222-08002b34c003";
+    m_currentDeviceInfo.ID = udn;
+    m_currentDeviceInfo.IPAddress = "127.0.0.1";
+    m_currentDeviceInfo.tp = tp;
+    //m_currentDeviceInfo.type = SSM_DEVICE_MOBILE;
+    m_currentDeviceInfo.type = td;
+    */
+    m_name = name;
+    m_type = type;
+    m_pathSoftSensors = pathSoftSensors;
+    m_pathSoftSensorsDescription = pathDescription;
 }
 
-SSMRESULT CContextRepository::loadXMLFromString(char *xmlData, std::vector<DictionaryData> *dataList)
+SSMRESULT CContextRepository::loadXMLFromString(char *xmlData,
+        std::vector<DictionaryData> *dataList)
 {
-       // use  rapidxml-----------------------
-       SSMRESULT res = SSM_E_FAIL;
-       rapidxml::xml_document< char > xmlDoc;
-       //xmlDoc.parse< 0 >( &xmlData.front() );
-       xmlDoc.parse< 0 >(xmlData);
-
-       std::string keyStr;
-       std::string valueStr;
-
-       rapidxml::xml_node< char > *item;
-       rapidxml::xml_node< char > *subItem;
-       rapidxml::xml_node< char > *subItem2;
-       rapidxml::xml_node< char > *subItem3;
-
-       // get value
-       rapidxml::xml_node< char > *root = xmlDoc.first_node();
-
-       if(!root)
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
-
-       for( item = root->first_node(); item; item = item->next_sibling() )
-       {
-               DictionaryData dictionaryData;
-               for( subItem = item->first_node(); subItem ; subItem = subItem->next_sibling() )
-               {
-                       //root name
-                       keyStr = subItem->name();  // key
-                       valueStr = subItem->value();   // value
-
-                       if(!keyStr.compare("root_name"))
-                       {
-                               dictionaryData.rootName = trim_both(valueStr);
-                       }
-                       ////std::cout<<keyStr << " : " << subItem->value() <<std::endl<<std::endl; //root_name
-                       for(subItem2 = subItem->first_node(); subItem2 ; subItem2 = subItem2->next_sibling())
-                       {
-                               std::map<std::string,std::string> propertyMap;
-                               std::vector<std::string> enterconditionVector;
-
-                               keyStr = subItem2->name();  // key
-                               valueStr = subItem2->value();   // value
-
-                               if(!keyStr.compare("attribute_property_count"))
-                               {
-                                       dictionaryData.attributePropertyCount = trim_both(valueStr);
-                               }
-                               else if(!keyStr.compare("output_property_count"))
-                               {
-                                       dictionaryData.outputPropertyCount  = trim_both(valueStr);
-                               }
-                               if(!keyStr.compare("inputs_count"))
-                               {
-                                       dictionaryData.inputCount = trim_both(valueStr);
-                               }
-                               else if(!keyStr.compare("app_inputs_count"))
-                               {
-                                       dictionaryData.appInputCount  = trim_both(valueStr);
-                               }
-                               else if(!keyStr.compare("app_input"))
-                               {
-                                       dictionaryData.appInputs.push_back(trim_both(valueStr));
-                               }
-                               else if(!keyStr.compare("input"))
-                               {
-                                       dictionaryData.inputs.push_back(trim_both(valueStr));
-                               }
-                               ////std::cout<<name << " :: " << subItem2->value() <<std::endl<<std::endl;
-                               for(subItem3 = subItem2->first_node(); subItem3 ; subItem3 = subItem3->next_sibling())
-                               { 
-
-                                       std::string newKeyStr = subItem3->name();  // key
-                                       valueStr = subItem3->value();   // value
-
-                                       if(!keyStr.compare("attribute_property") || !keyStr.compare("output_property") )
-                                       {
-                                               propertyMap.insert(std::make_pair(trim_both(newKeyStr),trim_both(valueStr)))    ;
-                                       }
-                                       else if(!keyStr.compare("enter_condition"))
-                                       {
-                                               enterconditionVector.push_back(trim_both(valueStr));
-                                       }
-                               }
-                               if(!keyStr.compare("attribute_property"))
-                               {
-                                       dictionaryData.attributeProperty.push_back(propertyMap);
-                               }
-                               else if(!keyStr.compare("output_property"))
-                               {
-                                       dictionaryData.outputProperty.push_back(propertyMap);
-                               }
-                               else if(!keyStr.compare("enter_condition"))
-                               {
-                                       dictionaryData.enterConditions.push_back(enterconditionVector);
-                               }
-                       }
-               }
-               //for accurate data.
-               /*
-               dictionaryData.app_input_count = std::to_string((long long)dictionaryData.app_inputs.size());
-               dictionaryData.input_count = std::to_string((long long)dictionaryData.inputs.size());
-               dictionaryData.attribute_property_count = std::to_string((long long)dictionaryData.attribute_property.size());
-               dictionaryData.output_property_count = std::to_string((long long)dictionaryData.output_property.size());
-               */
-
-               dataList->push_back(dictionaryData);
-       }
-
-       res = SSM_S_OK;
+    // use  rapidxml-----------------------
+    SSMRESULT res = SSM_E_FAIL;
+    rapidxml::xml_document< char > xmlDoc;
+    //xmlDoc.parse< 0 >( &xmlData.front() );
+    xmlDoc.parse< 0 >(xmlData);
+
+    std::string keyStr;
+    std::string valueStr;
+
+    rapidxml::xml_node< char > *item;
+    rapidxml::xml_node< char > *subItem;
+    rapidxml::xml_node< char > *subItem2;
+    rapidxml::xml_node< char > *subItem3;
+
+    // get value
+    rapidxml::xml_node< char > *root = xmlDoc.first_node();
+
+    if (!root)
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
+
+    for ( item = root->first_node(); item; item = item->next_sibling() )
+    {
+        DictionaryData dictionaryData;
+        for ( subItem = item->first_node(); subItem ; subItem = subItem->next_sibling() )
+        {
+            //root name
+            keyStr = subItem->name();  // key
+            valueStr = subItem->value();   // value
+
+            if (!keyStr.compare("root_name"))
+            {
+                dictionaryData.rootName = trim_both(valueStr);
+            }
+            ////std::cout<<keyStr << " : " << subItem->value() <<std::endl<<std::endl; //root_name
+            for (subItem2 = subItem->first_node(); subItem2 ; subItem2 = subItem2->next_sibling())
+            {
+                std::map<std::string, std::string> propertyMap;
+                std::vector<std::string> enterconditionVector;
+
+                keyStr = subItem2->name();  // key
+                valueStr = subItem2->value();   // value
+
+                if (!keyStr.compare("attribute_property_count"))
+                {
+                    dictionaryData.attributePropertyCount = trim_both(valueStr);
+                }
+                else if (!keyStr.compare("output_property_count"))
+                {
+                    dictionaryData.outputPropertyCount  = trim_both(valueStr);
+                }
+                if (!keyStr.compare("inputs_count"))
+                {
+                    dictionaryData.inputCount = trim_both(valueStr);
+                }
+                else if (!keyStr.compare("app_inputs_count"))
+                {
+                    dictionaryData.appInputCount  = trim_both(valueStr);
+                }
+                else if (!keyStr.compare("app_input"))
+                {
+                    dictionaryData.appInputs.push_back(trim_both(valueStr));
+                }
+                else if (!keyStr.compare("input"))
+                {
+                    dictionaryData.inputs.push_back(trim_both(valueStr));
+                }
+                ////std::cout<<name << " :: " << subItem2->value() <<std::endl<<std::endl;
+                for (subItem3 = subItem2->first_node(); subItem3 ; subItem3 = subItem3->next_sibling())
+                {
+
+                    std::string newKeyStr = subItem3->name();  // key
+                    valueStr = subItem3->value();   // value
+
+                    if (!keyStr.compare("attribute_property") || !keyStr.compare("output_property") )
+                    {
+                        propertyMap.insert(std::make_pair(trim_both(newKeyStr), trim_both(valueStr)))    ;
+                    }
+                    else if (!keyStr.compare("enter_condition"))
+                    {
+                        enterconditionVector.push_back(trim_both(valueStr));
+                    }
+                }
+                if (!keyStr.compare("attribute_property"))
+                {
+                    dictionaryData.attributeProperty.push_back(propertyMap);
+                }
+                else if (!keyStr.compare("output_property"))
+                {
+                    dictionaryData.outputProperty.push_back(propertyMap);
+                }
+                else if (!keyStr.compare("enter_condition"))
+                {
+                    dictionaryData.enterConditions.push_back(enterconditionVector);
+                }
+            }
+        }
+        //for accurate data.
+        /*
+        dictionaryData.app_input_count = std::to_string((long long)dictionaryData.app_inputs.size());
+        dictionaryData.input_count = std::to_string((long long)dictionaryData.inputs.size());
+        dictionaryData.attribute_property_count = std::to_string((long long)dictionaryData.attribute_property.size());
+        dictionaryData.output_property_count = std::to_string((long long)dictionaryData.output_property.size());
+        */
+
+        dataList->push_back(dictionaryData);
+    }
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CContextRepository::loadXMLFromFile(std::string descriptionFilePath, std::vector<DictionaryData> *dataList)
+SSMRESULT CContextRepository::loadXMLFromFile(std::string descriptionFilePath,
+        std::vector<DictionaryData> *dataList)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::basic_ifstream< char > xmlFile(descriptionFilePath.c_str());
-
-       if (descriptionFilePath.length() > 0 && xmlFile.fail())
-       {
-               //error while opening given path, return error
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
-
-       if (descriptionFilePath.length() == 0)
-       {
-               //No given path, try to open local Path
-               std::string path;
-               SSM_CLEANUP_ASSERT(GetCurrentPath(&path));
-               path.append("/");
-               path.append(DEFAULT_PATH_SOFT_SENSORS);
-               xmlFile.open(path);
-       }
-
-       //path loaded
-       if (!xmlFile.fail())
-       {
-               xmlFile.seekg(0, std::ios::end);
-               unsigned int size = (unsigned int)xmlFile.tellg();
-               xmlFile.seekg(0);
-
-               std::vector< char > xmlData(size + 1);
-               xmlData[size] = 0;
-
-               xmlFile.read(&xmlData.front(), (std::streamsize)size);
-               xmlFile.close();
-               SSM_CLEANUP_ASSERT(loadXMLFromString(&xmlData.front(), dataList));
-       }
-       else
-       {
-               //let work with no soft sensor manager
-               res = SSM_S_OK;
-       }
+    SSMRESULT res = SSM_E_FAIL;
+    std::basic_ifstream< char > xmlFile(descriptionFilePath.c_str());
+
+    if (descriptionFilePath.length() > 0 && xmlFile.fail())
+    {
+        //error while opening given path, return error
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
+
+    if (descriptionFilePath.length() == 0)
+    {
+        //No given path, try to open local Path
+        std::string path;
+        SSM_CLEANUP_ASSERT(GetCurrentPath(&path));
+        path.append("/");
+        path.append(DEFAULT_PATH_SOFT_SENSORS);
+        xmlFile.open(path);
+    }
+
+    //path loaded
+    if (!xmlFile.fail())
+    {
+        xmlFile.seekg(0, std::ios::end);
+        unsigned int size = (unsigned int)xmlFile.tellg();
+        xmlFile.seekg(0);
+
+        std::vector< char > xmlData(size + 1);
+        xmlData[size] = 0;
+
+        xmlFile.read(&xmlData.front(), (std::streamsize)size);
+        xmlFile.close();
+        SSM_CLEANUP_ASSERT(loadXMLFromString(&xmlData.front(), dataList));
+    }
+    else
+    {
+        //let work with no soft sensor manager
+        res = SSM_S_OK;
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CContextRepository::getSoftSensorList(OUT std::vector<ISSMResource*> *pSoftSensorList)
+SSMRESULT CContextRepository::getSoftSensorList(OUT std::vector<ISSMResource *> *pSoftSensorList)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       std::vector<DictionaryData> dict;
-       
-       SSM_CLEANUP_ASSERT(loadXMLFromFile(m_pathSoftSensorsDescription.c_str(), &dict));
+    SSMRESULT res = SSM_E_FAIL;
+    std::vector<DictionaryData> dict;
 
-       SSM_CLEANUP_ASSERT(makeSSMResourceListForDictionaryData(dict, pSoftSensorList));
+    SSM_CLEANUP_ASSERT(loadXMLFromFile(m_pathSoftSensorsDescription.c_str(), &dict));
+
+    SSM_CLEANUP_ASSERT(makeSSMResourceListForDictionaryData(dict, pSoftSensorList));
 
 CLEANUP:
-       return res;
+    return res;
 }
 
-SSMRESULT CContextRepository::getPrimitiveSensorList(OUT std::vector<ISSMResource*> *pPrimitiveSensorList)
+SSMRESULT CContextRepository::getPrimitiveSensorList(OUT std::vector<ISSMResource *>
+        *pPrimitiveSensorList)
 {
-       for (size_t i = 0; i < m_lstSensor.size(); i++)
-       {
-               pPrimitiveSensorList->push_back(m_lstSensor.at(i));
-       }
+    for (size_t i = 0; i < m_lstSensor.size(); i++)
+    {
+        pPrimitiveSensorList->push_back(m_lstSensor.at(i));
+    }
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CContextRepository::onResourceFound(IN ISSMResource *pSensor)
 {
-       m_lstSensor.push_back(pSensor);
+    m_lstSensor.push_back(pSensor);
 
-       for (size_t i = 0; i < m_resourceEvents.size(); i++)
-       {
-               m_resourceEvents.at(i)->onResourceEvent(SSM_EVENT_ADDED, pSensor, "");
-       }
+    for (size_t i = 0; i < m_resourceEvents.size(); i++)
+    {
+        m_resourceEvents.at(i)->onResourceEvent(SSM_EVENT_ADDED, pSensor, "");
+    }
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CContextRepository::onResourceLost(IN ISSMResource *pSensor)
 {
-       std::vector<ISSMResource*>::iterator    itor;
-       itor = std::find(m_lstSensor.begin(), m_lstSensor.end(), pSensor);
-
-       if (itor != m_lstSensor.end())
-       {
-               m_lstSensor.erase(itor);
-               return SSM_S_OK;
-       }
-       
-       return SSM_E_FAIL;
+    std::vector<ISSMResource *>::iterator    itor;
+    itor = std::find(m_lstSensor.begin(), m_lstSensor.end(), pSensor);
+
+    if (itor != m_lstSensor.end())
+    {
+        m_lstSensor.erase(itor);
+        return SSM_S_OK;
+    }
+
+    return SSM_E_FAIL;
 }
 
 SSMRESULT CContextRepository::startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent)
 {
-       return m_resourceFinder->startObserveResource(pSensor, pEvent);
+    return m_resourceFinder->startObserveResource(pSensor, pEvent);
 }
 
 SSMRESULT CContextRepository::stopObserveResource(IN ISSMResource *pSensor)
 {
-       return m_resourceFinder->stopObserveResource(pSensor);
+    return m_resourceFinder->stopObserveResource(pSensor);
 }
 
 //TODO: Need to fix
-SSMRESULT CContextRepository::makeSSMResourceListForDictionaryData(std::vector<DictionaryData> dataList, std::vector<ISSMResource*> *pList)
+SSMRESULT CContextRepository::makeSSMResourceListForDictionaryData(std::vector<DictionaryData>
+        dataList, std::vector<ISSMResource *> *pList)
 {
-       SSMRESULT res = SSM_E_FAIL;
-
-       for(unsigned int i = 0 ; i < dataList.size() ; ++i)
-       {
-               ISSMResource *pResource = new ISSMResource();
-               pResource->location = SENSOR_LOCATION_LOCAL;
-               pResource->type = dataList[i].rootName;
-               pResource->name = std::string("coap://127.0.0.1/") + dataList[i].rootName;
-               pResource->ip = "coap://127.0.0.1/";
-
-               pResource->inputList = dataList[i].inputs;
-               
-               for (unsigned int j = 0; j < dataList[i].outputProperty.size(); ++j)
-               {
-                       pResource->outputProperty.push_back(dataList[i].outputProperty[j]);
-               }
-               for (unsigned int j = 0; j < dataList[i].attributeProperty.size(); ++j)
-               {
-                       pResource->outputProperty.push_back(dataList[i].attributeProperty[j]);
-               }
-               pList->push_back(pResource);
-       }
-
-       res = SSM_S_OK;
-
-       return res;
+    SSMRESULT res = SSM_E_FAIL;
+
+    for (unsigned int i = 0 ; i < dataList.size() ; ++i)
+    {
+        ISSMResource *pResource = new ISSMResource();
+        pResource->location = SENSOR_LOCATION_LOCAL;
+        pResource->type = dataList[i].rootName;
+        pResource->name = std::string("coap://127.0.0.1/") + dataList[i].rootName;
+        pResource->ip = "coap://127.0.0.1/";
+
+        pResource->inputList = dataList[i].inputs;
+
+        for (unsigned int j = 0; j < dataList[i].outputProperty.size(); ++j)
+        {
+            pResource->outputProperty.push_back(dataList[i].outputProperty[j]);
+        }
+        for (unsigned int j = 0; j < dataList[i].attributeProperty.size(); ++j)
+        {
+            pResource->outputProperty.push_back(dataList[i].attributeProperty[j]);
+        }
+        pList->push_back(pResource);
+    }
+
+    res = SSM_S_OK;
+
+    return res;
 }
 
-SSMRESULT CContextRepository::loadSoftSensor(std::string softSensorName, ICtxDelegate *pDelegate, void **hSoftSensor)
+SSMRESULT CContextRepository::loadSoftSensor(std::string softSensorName, ICtxDelegate *pDelegate,
+        void **hSoftSensor)
 {
-       std::stringstream       sstream;
-       SSMRESULT                       res = SSM_E_FAIL;
+    std::stringstream   sstream;
+    SSMRESULT           res = SSM_E_FAIL;
 
-       typedef void(*InitContext)(IN ICtxDelegate *);
-       InitContext InitializeContextFunction = NULL;
+    typedef void(*InitContext)(IN ICtxDelegate *);
+    InitContext InitializeContextFunction = NULL;
 
-       if (m_pathSoftSensors.length() == 0)
-       {
-               SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensors));
-       }
+    if (m_pathSoftSensors.length() == 0)
+    {
+        SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensors));
+    }
 
-       m_pathSoftSensors.append("/");
+    m_pathSoftSensors.append("/");
 
-       // load dll(so)
-       res = SSM_E_FAIL;
-       for (unsigned int i = 1; i <= SSM_MODEL_RETRY; ++i)
-       {
-               sstream.str("");
+    // load dll(so)
+    res = SSM_E_FAIL;
+    for (unsigned int i = 1; i <= SSM_MODEL_RETRY; ++i)
+    {
+        sstream.str("");
 
 #ifdef WIN32
-               sstream << m_pathSoftSensors << softSensorName.c_str() << ".dll" << std::ends;
+        sstream << m_pathSoftSensors << softSensorName.c_str() << ".dll" << std::ends;
 
-               HINSTANCE hModule = NULL;
-               hModule = LoadLibraryA(sstream.str().c_str());
+        HINSTANCE hModule = NULL;
+        hModule = LoadLibraryA(sstream.str().c_str());
 
-               if (hModule != NULL)
-               {
-                       InitializeContextFunction = (InitContext)GetProcAddress(hModule, "InitializeContext");
-               }
+        if (hModule != NULL)
+        {
+            InitializeContextFunction = (InitContext)GetProcAddress(hModule, "InitializeContext");
+        }
 #else
-               //sstream << "/data/data/com.example.javaproject/lib/lib" << modelName <<".so" << std::ends;
-               sstream << m_pathSoftSensors << "lib" << softSensorName.c_str() << ".so" << std::ends;
+        //sstream << "/data/data/com.example.javaproject/lib/lib" << modelName <<".so" << std::ends;
+        sstream << m_pathSoftSensors << "lib" << softSensorName.c_str() << ".so" << std::ends;
 
-               void* hModule = NULL;
-               hModule = dlopen(sstream.str().c_str(), RTLD_LOCAL | RTLD_LAZY);
+        void *hModule = NULL;
+        hModule = dlopen(sstream.str().c_str(), RTLD_LOCAL | RTLD_LAZY);
 
-               if (hModule != NULL)
-               {
-                       InitializeContextFunction = (InitContext)dlsym(hModule, "InitializeContext");
-               }
+        if (hModule != NULL)
+        {
+            InitializeContextFunction = (InitContext)dlsym(hModule, "InitializeContext");
+        }
 #endif
-               if (hModule == NULL)
-               {
-                       InitializeContextFunction = NULL;
-                       continue;
-               }
-
-               if (InitializeContextFunction != NULL)
-               {
-                       InitializeContextFunction(pDelegate);
-                       *hSoftSensor = hModule;
-                       res = SSM_S_OK;
-               }
-               else
-               {
-                       //Unload module and return error
-                       SSM_CLEANUP_ASSERT(unloadSoftSensor(hModule));
-                       SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-               }
-
-               break;
-       }
+        if (hModule == NULL)
+        {
+            InitializeContextFunction = NULL;
+            continue;
+        }
+
+        if (InitializeContextFunction != NULL)
+        {
+            InitializeContextFunction(pDelegate);
+            *hSoftSensor = hModule;
+            res = SSM_S_OK;
+        }
+        else
+        {
+            //Unload module and return error
+            SSM_CLEANUP_ASSERT(unloadSoftSensor(hModule));
+            SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+        }
+
+        break;
+    }
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CContextRepository::unloadSoftSensor(void *hSoftSensor)
 {
-       SSMRESULT                       res = SSM_E_FAIL;
+    SSMRESULT           res = SSM_E_FAIL;
 
 #ifdef WIN32
-       SSM_CLEANUP_COND_ASSERT(FreeLibrary((HINSTANCE)hSoftSensor), TRUE, "FreeLibrary failed");
+    SSM_CLEANUP_COND_ASSERT(FreeLibrary((HINSTANCE)hSoftSensor), TRUE, "FreeLibrary failed");
 #else
-       SSM_CLEANUP_COND_ASSERT(dlclose(hSoftSensor), 0, "dlclose failed");
+    SSM_CLEANUP_COND_ASSERT(dlclose(hSoftSensor), 0, "dlclose failed");
 #endif
 
-       res = SSM_S_OK;
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 SSMRESULT CContextRepository::GetCurrentPath(std::string *path)
 {
-       char            buffer[2048];
-       SSMRESULT       res = SSM_E_FAIL;
+    char        buffer[2048];
+    SSMRESULT   res = SSM_E_FAIL;
 #if defined(WIN32)
-       DWORD length = GetModuleFileNameA(NULL, buffer, 2047);
+    DWORD length = GetModuleFileNameA(NULL, buffer, 2047);
 
-       if (length == 0)
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
+    if (length == 0)
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
 
-       buffer[length] = '\0';
-       if (PathRemoveFileSpecA(buffer) == 0)
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
+    buffer[length] = '\0';
+    if (PathRemoveFileSpecA(buffer) == 0)
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
 
 #elif defined(LINUX)
-       char    *strPath = NULL;
-       int length = ::readlink("/proc/self/exe", buffer, 2047);
+    char    *strPath = NULL;
+    int length = ::readlink("/proc/self/exe", buffer, 2047);
 
-       if (length == -1)
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
+    if (length == -1)
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
 
-       strPath = strrchr(buffer, '/');
+    strPath = strrchr(buffer, '/');
 
-       if (strPath == NULL)
-       {
-               SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-       }
+    if (strPath == NULL)
+    {
+        SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+    }
 
-       *strPath = '\0';
+    *strPath = '\0';
 #endif
 
-       path->append(buffer);
-       res = SSM_S_OK;
+    path->append(buffer);
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
\ No newline at end of file
index f1e9aa1..314408f 100644 (file)
  * @brief    Class for context manifest
  *           parse, get, set context manifest. provide device information
  *
- * @see      
+ * @see
  */
 
 class CContextRepository :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IContextRepository
-       , public IResourceFinderEvent
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IContextRepository
+    , public IResourceFinderEvent
 {
-private:
-   CSimpleMutex                                        m_mtxFileIO;
-   std::vector<ISSMResource*>  m_lstSensor;
-   CObjectPtr<IResourceFinder> m_resourceFinder;
-   std::string                                 m_name;
-   std::string                                 m_type;
-   std::vector<IResourceEvent*>        m_resourceEvents;
-   std::string                                 m_pathSoftSensors;
-   std::string                                 m_pathSoftSensorsDescription;
+    private:
+        CSimpleMutex                 m_mtxFileIO;
+        std::vector<ISSMResource *>   m_lstSensor;
+        CObjectPtr<IResourceFinder>  m_resourceFinder;
+        std::string                  m_name;
+        std::string                  m_type;
+        std::vector<IResourceEvent *> m_resourceEvents;
+        std::string                  m_pathSoftSensors;
+        std::string                  m_pathSoftSensorsDescription;
 
-public:
-       SSMRESULT finalConstruct();
-       void finalRelease();
+    public:
+        SSMRESULT finalConstruct();
+        void finalRelease();
 
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
 
-               if(IsEqualOID(objectID, OID_IContextRepository))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
+            if (IsEqualOID(objectID, OID_IContextRepository))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
 
-               return SSM_E_NOINTERFACE;
-       }
+            return SSM_E_NOINTERFACE;
+        }
 
 
-       /**
-       * @fn           setCurrentDeviceInfo
-       * @brief        set device information
-       *
-       * @param        [in] std::string name - Device name
-       * @param        [in] std::string type - Device Type
-       * @param        [in] std::string pathSoftSensors - SoftSensors Repository path
-       * @param        [in] std::string pathDescription - SoftSensors Description path
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void setCurrentDeviceInfo(IN std::string name, IN std::string type, IN std::string pathSoftSensors, IN std::string pathDescription);
-       
-       /**
-       * @fn           getSoftSensorList
-       * @brief        Get soft sensor list
-       *
-       * @param                [out] std::vector<ISSMResource*> *pSoftSensorList - List of soft sensors
-       * @return       SSMRESULT
-       *                                       SSM_S_OK
-       *                                       , SSM_S_FALSE
-       *                                       , SSM_E_POINTER
-       *                                       , SSM_E_OUTOFMEMORY
-       *                                       , SSM_E_FAIL
-       *                                       , SSM_E_NOINTERFACE
-       *                                       , SSM_E_NOTIMPL
-       *
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getSoftSensorList(OUT std::vector<ISSMResource*> *pSoftSensorList);
+        /**
+        * @fn           setCurrentDeviceInfo
+        * @brief        set device information
+        *
+        * @param        [in] std::string name - Device name
+        * @param        [in] std::string type - Device Type
+        * @param        [in] std::string pathSoftSensors - SoftSensors Repository path
+        * @param        [in] std::string pathDescription - SoftSensors Description path
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void setCurrentDeviceInfo(IN std::string name, IN std::string type, IN std::string pathSoftSensors,
+                                  IN std::string pathDescription);
 
-       /**
-       * @fn           getPrimitiveSensorList
-       * @brief        Get primitive sensor list
-       *
-       * @param                [out] std::vector<ISSMResource*> *pPrimitiveSensorList - List of primitive sensors
-       * @return       SSMRESULT
-       *                                       SSM_S_OK
-       *                                       , SSM_S_FALSE
-       *                                       , SSM_E_POINTER
-       *                                       , SSM_E_OUTOFMEMORY
-       *                                       , SSM_E_FAIL
-       *                                       , SSM_E_NOINTERFACE
-       *                                       , SSM_E_NOTIMPL
-       *
-       * @warning
-       * @exception
-       * @see
-       */
-       SSMRESULT getPrimitiveSensorList(OUT std::vector<ISSMResource*> *pPrimitiveSensorList);
-       
-       SSMRESULT registerResourceFinderEvent(IN IResourceEvent *pResourceEvent);
-       SSMRESULT startResourceFinder();
-       SSMRESULT onResourceFound(IN ISSMResource *pSensor);
-       SSMRESULT onResourceLost(IN ISSMResource *pSensor);
+        /**
+        * @fn           getSoftSensorList
+        * @brief        Get soft sensor list
+        *
+        * @param        [out] std::vector<ISSMResource*> *pSoftSensorList - List of soft sensors
+        * @return       SSMRESULT
+        *                   SSM_S_OK
+        *                   , SSM_S_FALSE
+        *                   , SSM_E_POINTER
+        *                   , SSM_E_OUTOFMEMORY
+        *                   , SSM_E_FAIL
+        *                   , SSM_E_NOINTERFACE
+        *                   , SSM_E_NOTIMPL
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getSoftSensorList(OUT std::vector<ISSMResource *> *pSoftSensorList);
 
-       SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent);
-       SSMRESULT stopObserveResource(IN ISSMResource *pSensor);
+        /**
+        * @fn           getPrimitiveSensorList
+        * @brief        Get primitive sensor list
+        *
+        * @param        [out] std::vector<ISSMResource*> *pPrimitiveSensorList - List of primitive sensors
+        * @return       SSMRESULT
+        *                   SSM_S_OK
+        *                   , SSM_S_FALSE
+        *                   , SSM_E_POINTER
+        *                   , SSM_E_OUTOFMEMORY
+        *                   , SSM_E_FAIL
+        *                   , SSM_E_NOINTERFACE
+        *                   , SSM_E_NOTIMPL
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        SSMRESULT getPrimitiveSensorList(OUT std::vector<ISSMResource *> *pPrimitiveSensorList);
 
-       SSMRESULT loadSoftSensor(IN std::string softSensorName, IN ICtxDelegate *pDelegate, OUT void **hSoftSensor);
-       SSMRESULT unloadSoftSensor(IN void *hSoftSensor);
+        SSMRESULT registerResourceFinderEvent(IN IResourceEvent *pResourceEvent);
+        SSMRESULT startResourceFinder();
+        SSMRESULT onResourceFound(IN ISSMResource *pSensor);
+        SSMRESULT onResourceLost(IN ISSMResource *pSensor);
 
-private:
-       SSMRESULT makeSSMResourceListForDictionaryData(IN std::vector<DictionaryData> dataList, OUT std::vector<ISSMResource*> *pList) ;
-       SSMRESULT loadXMLFromFile(IN std::string descriptionFilePath, IN std::vector<DictionaryData> *dataList);
-       SSMRESULT loadXMLFromString(IN char *xmlData, IN std::vector<DictionaryData> *dataList);
-       SSMRESULT GetCurrentPath(OUT std::string *path);
+        SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent);
+        SSMRESULT stopObserveResource(IN ISSMResource *pSensor);
+
+        SSMRESULT loadSoftSensor(IN std::string softSensorName, IN ICtxDelegate *pDelegate,
+                                 OUT void **hSoftSensor);
+        SSMRESULT unloadSoftSensor(IN void *hSoftSensor);
+
+    private:
+        SSMRESULT makeSSMResourceListForDictionaryData(IN std::vector<DictionaryData> dataList,
+                OUT std::vector<ISSMResource *> *pList) ;
+        SSMRESULT loadXMLFromFile(IN std::string descriptionFilePath,
+                                  IN std::vector<DictionaryData> *dataList);
+        SSMRESULT loadXMLFromString(IN char *xmlData, IN std::vector<DictionaryData> *dataList);
+        SSMRESULT GetCurrentPath(OUT std::string *path);
 };
 #endif
\ No newline at end of file
index a735c13..67214c8 100644 (file)
 
 SSMRESULT CResourceConnectivity::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
     OC::PlatformConfig cfg(OC::ServiceType::InProc, OC::ModeType::Both,
-            "134.134.161.33", 56831, OC::QualityOfService::NonConfirmable);
-       
-       m_pPlatform = new OC::OCPlatform(cfg);
-       
-       SSM_CLEANUP_NULL_ASSERT(m_pPlatform);
+                           "134.134.161.33", 56831, OC::QualityOfService::NonConfirmable);
 
-       res = SSM_S_OK;
+    m_pPlatform = new OC::OCPlatform(cfg);
+
+    SSM_CLEANUP_NULL_ASSERT(m_pPlatform);
+
+    res = SSM_S_OK;
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CResourceConnectivity::finalRelease()
 {
-       SAFE_DELETE(m_pPlatform);
+    SAFE_DELETE(m_pPlatform);
 }
 
-voidCResourceConnectivity::getPlatform()
+void *CResourceConnectivity::getPlatform()
 {
-       return m_pPlatform;
+    return m_pPlatform;
 }
index 3a6f08a..ec28c81 100644 (file)
 #include "OCPlatform.h"
 
 class CResourceConnectivity :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IResourceConnectivity
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IResourceConnectivity
 {
-public:
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if (ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if (IsEqualOID(objectID, OID_IResourceConnectivity))
-               {
-                       IBase *pBase = (IResourceConnectivity*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       SSMRESULT finalConstruct();
-       void finalRelease();
-
-       void* getPlatform();
-
-private:
-       OC::OCPlatform          *m_pPlatform;
+    public:
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IResourceConnectivity))
+            {
+                IBase *pBase = (IResourceConnectivity *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        SSMRESULT finalConstruct();
+        void finalRelease();
+
+        void *getPlatform();
+
+    private:
+        OC::OCPlatform      *m_pPlatform;
 };
 
 #endif
index 278937e..dcf1f1c 100644 (file)
 
 SSMRESULT CResourceFinder::finalConstruct()
 {
-       SSMRESULT res = SSM_E_FAIL;
+    SSMRESULT res = SSM_E_FAIL;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase**)&m_pTasker));
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResourceConnectivity, (IBase**)&m_pResourceConnectivity));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IResourceConnectivity,
+                                            (IBase **)&m_pResourceConnectivity));
 
-       m_pResourceFinderEvent = NULL;
-       m_pPlatform = (OC::OCPlatform*)m_pResourceConnectivity->getPlatform();
+    m_pResourceFinderEvent = NULL;
+    m_pPlatform = (OC::OCPlatform *)m_pResourceConnectivity->getPlatform();
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CResourceFinder::finalRelease()
@@ -39,84 +40,84 @@ void CResourceFinder::finalRelease()
 
 SSMRESULT CResourceFinder::registerResourceFinderEvent(IN IResourceFinderEvent *pEvent)
 {
-       m_pResourceFinderEvent = pEvent;
-       return SSM_S_OK;
+    m_pResourceFinderEvent = pEvent;
+    return SSM_S_OK;
 }
 
 void CResourceFinder::onResourceFound(std::shared_ptr<OC::OCResource> resource)
 {
-       if (resource)
-       {
-               int             *pMessage = new int[2];
-               pMessage[0] = RESOURCE_DISCOVER_REQUESTPROFILE;
-               pMessage[1] = (int)new std::shared_ptr<OC::OCResource>(resource);
-
-               m_pTasker->addTask(this, pMessage);
-       }
+    if (resource)
+    {
+        int     *pMessage = new int[2];
+        pMessage[0] = RESOURCE_DISCOVER_REQUESTPROFILE;
+        pMessage[1] = (int)new std::shared_ptr<OC::OCResource>(resource);
+
+        m_pTasker->addTask(this, pMessage);
+    }
 }
 
 SSMRESULT CResourceFinder::startResourceFinder()
 {
-       //m_pPlatform->findResource("", "oc/core/service/SoftSensorManager/SoftSensor",
-       m_pPlatform->findResource("", "coap://224.0.1.187/oc/core?rt=SoftSensorManager.Sensor",
-               std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
+    //m_pPlatform->findResource("", "oc/core/service/SoftSensorManager/SoftSensor",
+    m_pPlatform->findResource("", "coap://224.0.1.187/oc/core?rt=SoftSensorManager.Sensor",
+                              std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
 
-       return SSM_S_OK;
+    return SSM_S_OK;
 }
 
 SSMRESULT CResourceFinder::startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent)
 {
-       return m_mapResourceHandler[pSensor->name]->startObserve(pEvent);
+    return m_mapResourceHandler[pSensor->name]->startObserve(pEvent);
 }
 
 SSMRESULT CResourceFinder::stopObserveResource(IN ISSMResource *pSensor)
 {
-       return m_mapResourceHandler[pSensor->name]->stopObserve();
+    return m_mapResourceHandler[pSensor->name]->stopObserve();
 }
 
-void CResourceFinder::onExecute(IN voidpArg)
+void CResourceFinder::onExecute(IN void *pArg)
 {
-       SSMRESULT res = SSM_E_FAIL;
-       OC::QueryParamsMap      queryParams;
-       OICResourceHandler      *pResourceHandler = NULL;
-       int                                     *pMessage = (int*)pArg;
-       std::shared_ptr<OC::OCResource> *pResource = NULL;
-
-       switch (pMessage[0])
-       {
-       case RESOURCE_DISCOVER_REQUESTPROFILE:
-               pResource = (std::shared_ptr<OC::OCResource>*)pMessage[1];
-               pResourceHandler = new OICResourceHandler();
-               SSM_CLEANUP_ASSERT(pResourceHandler->initHandler(*pResource, this));
-               m_mapResourceHandler[pResource->get()->host() + pResource->get()->uri()] = pResourceHandler;
-               pResource->get()->get(queryParams, std::bind(&OICResourceHandler::onGetResourceProfile,
-                       pResourceHandler, std::placeholders::_1, std::placeholders::_2));
-               break;
-
-       case RESOURCE_DISCOVER_SETUP_RESOURCE:
-               m_pResourceFinderEvent->onResourceFound((ISSMResource*)pMessage[1]);
-               break;
-       }
+    SSMRESULT res = SSM_E_FAIL;
+    OC::QueryParamsMap  queryParams;
+    OICResourceHandler  *pResourceHandler = NULL;
+    int                 *pMessage = (int *)pArg;
+    std::shared_ptr<OC::OCResource> *pResource = NULL;
+
+    switch (pMessage[0])
+    {
+        case RESOURCE_DISCOVER_REQUESTPROFILE:
+            pResource = (std::shared_ptr<OC::OCResource> *)pMessage[1];
+            pResourceHandler = new OICResourceHandler();
+            SSM_CLEANUP_ASSERT(pResourceHandler->initHandler(*pResource, this));
+            m_mapResourceHandler[pResource->get()->host() + pResource->get()->uri()] = pResourceHandler;
+            pResource->get()->get(queryParams, std::bind(&OICResourceHandler::onGetResourceProfile,
+                                  pResourceHandler, std::placeholders::_1, std::placeholders::_2));
+            break;
+
+        case RESOURCE_DISCOVER_SETUP_RESOURCE:
+            m_pResourceFinderEvent->onResourceFound((ISSMResource *)pMessage[1]);
+            break;
+    }
 
 CLEANUP:
-       ;
+    ;
 }
 
-void CResourceFinder::onTerminate(IN voidpArg)
+void CResourceFinder::onTerminate(IN void *pArg)
 {
-       std::shared_ptr<OC::OCResource>         *pResource = NULL;
-       int                                     *pMessage = (int*)pArg;
+    std::shared_ptr<OC::OCResource>     *pResource = NULL;
+    int                 *pMessage = (int *)pArg;
 
-       switch (pMessage[0])
-       {
-       case RESOURCE_DISCOVER_REQUESTPROFILE:
-               pResource = (std::shared_ptr<OC::OCResource>*)pMessage[1];
-               delete pResource;
-               break;
+    switch (pMessage[0])
+    {
+        case RESOURCE_DISCOVER_REQUESTPROFILE:
+            pResource = (std::shared_ptr<OC::OCResource> *)pMessage[1];
+            delete pResource;
+            break;
 
-       case RESOURCE_DISCOVER_SETUP_RESOURCE:
-               break;
-       }
+        case RESOURCE_DISCOVER_SETUP_RESOURCE:
+            break;
+    }
 
-       delete[] pMessage;
+    delete[] pMessage;
 }
index 6638ca3..dc1b524 100644 (file)
 #include "OCPlatform.h"
 
 class CResourceFinder :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IResourceFinder
-       , public IThreadClient
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IResourceFinder
+    , public IThreadClient
 {
-public:
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if (ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if (IsEqualOID(objectID, OID_IResourceFinder))
-               {
-                       IBase *pBase = (IResourceFinder*)this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       SSMRESULT finalConstruct();
-       void finalRelease();
-
-       SSMRESULT registerResourceFinderEvent(IN IResourceFinderEvent *pEvent);
-       void onResourceFound(std::shared_ptr<OC::OCResource> resource);
-       SSMRESULT startResourceFinder();
-
-       SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent);
-       SSMRESULT stopObserveResource(IN ISSMResource *pSensor);
-
-       void onExecute(IN void* pArg);
-       void onTerminate(IN void* pArg);
-
-private:
-       class OICResourceHandler
-       {
-       public:
-               OICResourceHandler()
-               {
-                       m_pEvent = NULL;
-                       m_pResourceFinderClient = NULL;
-               }
-
-               SSMRESULT initHandler(std::shared_ptr<OC::OCResource> resource, IN IThreadClient        *pThreadClient)
-               {
-                       SSMRESULT       res = SSM_E_FAIL;
-
-                       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase**)&m_pTasker));
-                       m_pResource = resource;
-                       m_pResourceFinderClient = pThreadClient;
-
-               CLEANUP:
-                       return res;
-               }
-
-               SSMRESULT startObserve(IEvent *pEvent)
-               {
-                       OC::QueryParamsMap queryParams;
-
-                       m_pEvent = pEvent;
-
-                       m_pResource.get()->observe(OC::ObserveType::Observe, queryParams, std::bind(&OICResourceHandler::onResourceDataReceived,
-                               this, std::placeholders::_1, std::placeholders::_2));
-
-                       return SSM_S_OK;
-               }
-
-               SSMRESULT stopObserve()
-               {
-                       m_pResource.get()->cancelObserve();
-
-                       return SSM_S_OK;
-               }
-
-               void onResourceDataReceived(const OC::OCRepresentation& representation, const int& eCode)
-               {
-                       if (eCode == 0)
-                       {
-                               std::vector<ContextData>                lstCtxData;
-                               ContextData                             ctxData;
-                               std::map<std::string, std::string>      outputProperty;
-                               OC::AttributeMap                        attributeMap = representation.getAttributeMap();
-
-                               //Bind data
-                               ctxData.rootName = m_pResource->uri().substr(1);
-
-                               //TODO: Temporally used for json parsing limitation
-                               ctxData.outputPropertyCount = attributeMap.size() / 3;
-
-                               if(ctxData.outputPropertyCount > 0)
-                               {
-                                       for (size_t i = 0; i < attributeMap.size() / 3; i++)
-                                       {
-                                               outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second.front();
-                                               outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second.front();
-                                               outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second.front();
-                                               ctxData.outputProperty.push_back(outputProperty);
-                                       }
-
-                                       /////////////////////////////////////////////////////
-                                       lstCtxData.push_back(ctxData);
-                                       m_pEvent->onEvent(m_pResource->uri().substr(1), SSM_REPEAT, lstCtxData);
-                               }
-                               else
-                               {
-                                       ;//Payload is empty!!
-                               }
-                       }
-               }
-
-               void onGetResourceProfile(const OC::OCRepresentation& representation, const int& eCode)
-               {
-                       //unpack attributeMap
-
-                       //Create SSMResource using OCResource attributeMap
-                       std::map<std::string, std::string>              outputProperty;
-                       OC::AttributeMap                                        attributeMap = representation.getAttributeMap();
-                       ISSMResource            *pSSMResource = new ISSMResource();
-                       pSSMResource->location = SENSOR_LOCATION_REMOTE;
-                       pSSMResource->name = m_pResource->host() + m_pResource->uri();
-                       pSSMResource->type = m_pResource->uri().substr(1);
-                       pSSMResource->ip = m_pResource->host();
-
-                       //bind default properties
-                       outputProperty["name"] = "lifetime";
-                       outputProperty["type"] = "int";
-                       outputProperty["value"] = "0";
-                       pSSMResource->outputProperty.push_back(outputProperty);
-
-                       //bind default primitive sensor property, value to resource class for schema creating
-                       
-                       //TODO: Temporally used for json parsing limitation
-                       for (size_t i = 0; i < attributeMap.size() / 3; i++)
-                       {
-                               outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second.front();
-                               outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second.front();
-                               outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second.front();
-                               pSSMResource->outputProperty.push_back(outputProperty);
-                       }
-                       /////////////////////////////////////////////////////
-                       //
-                       int             *pMessage = new int[2];
-                       pMessage[0] = RESOURCE_DISCOVER_SETUP_RESOURCE;
-                       pMessage[1] = (int)pSSMResource;
-
-                       m_pTasker->addTask(m_pResourceFinderClient, (void*)pMessage);
-               }
-
-       private:
-               CObjectPtr<ITasker>                                     m_pTasker;
-               std::shared_ptr<OC::OCResource>         m_pResource;
-               IThreadClient                                           *m_pResourceFinderClient;
-               IEvent                                                          *m_pEvent;
-       };
-
-       enum RESOURCE_DISCOVER_STATE{RESOURCE_DISCOVER_REQUESTPROFILE, RESOURCE_DISCOVER_SETUP_RESOURCE};
-       OC::OCPlatform                                          *m_pPlatform;
-       CObjectPtr<IResourceConnectivity>       m_pResourceConnectivity;
-       IResourceFinderEvent                            *m_pResourceFinderEvent;
-       CObjectPtr<ITasker>                             m_pTasker;
-       std::map<std::string , OICResourceHandler*>     m_mapResourceHandler;
+    public:
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IResourceFinder))
+            {
+                IBase *pBase = (IResourceFinder *)this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        SSMRESULT finalConstruct();
+        void finalRelease();
+
+        SSMRESULT registerResourceFinderEvent(IN IResourceFinderEvent *pEvent);
+        void onResourceFound(std::shared_ptr<OC::OCResource> resource);
+        SSMRESULT startResourceFinder();
+
+        SSMRESULT startObserveResource(IN ISSMResource *pSensor, IN IEvent *pEvent);
+        SSMRESULT stopObserveResource(IN ISSMResource *pSensor);
+
+        void onExecute(IN void *pArg);
+        void onTerminate(IN void *pArg);
+
+    private:
+        class OICResourceHandler
+        {
+            public:
+                OICResourceHandler()
+                {
+                    m_pEvent = NULL;
+                    m_pResourceFinderClient = NULL;
+                }
+
+                SSMRESULT initHandler(std::shared_ptr<OC::OCResource> resource, IN IThreadClient    *pThreadClient)
+                {
+                    SSMRESULT   res = SSM_E_FAIL;
+
+                    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_ITasker, (IBase **)&m_pTasker));
+                    m_pResource = resource;
+                    m_pResourceFinderClient = pThreadClient;
+
+CLEANUP:
+                    return res;
+                }
+
+                SSMRESULT startObserve(IEvent *pEvent)
+                {
+                    OC::QueryParamsMap queryParams;
+
+                    m_pEvent = pEvent;
+
+                    m_pResource.get()->observe(OC::ObserveType::Observe, queryParams,
+                                               std::bind(&OICResourceHandler::onResourceDataReceived,
+                                                         this, std::placeholders::_1, std::placeholders::_2));
+
+                    return SSM_S_OK;
+                }
+
+                SSMRESULT stopObserve()
+                {
+                    m_pResource.get()->cancelObserve();
+
+                    return SSM_S_OK;
+                }
+
+                void onResourceDataReceived(const OC::OCRepresentation &representation, const int &eCode)
+                {
+                    if (eCode == 0)
+                    {
+                        std::vector<ContextData>        lstCtxData;
+                        ContextData             ctxData;
+                        std::map<std::string, std::string>  outputProperty;
+                        OC::AttributeMap            attributeMap = representation.getAttributeMap();
+
+                        //Bind data
+                        ctxData.rootName = m_pResource->uri().substr(1);
+
+                        //TODO: Temporally used for json parsing limitation
+                        ctxData.outputPropertyCount = attributeMap.size() / 3;
+
+                        if (ctxData.outputPropertyCount > 0)
+                        {
+                            for (size_t i = 0; i < attributeMap.size() / 3; i++)
+                            {
+                                outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second.front();
+                                outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second.front();
+                                outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second.front();
+                                ctxData.outputProperty.push_back(outputProperty);
+                            }
+
+                            /////////////////////////////////////////////////////
+                            lstCtxData.push_back(ctxData);
+                            m_pEvent->onEvent(m_pResource->uri().substr(1), SSM_REPEAT, lstCtxData);
+                        }
+                        else
+                        {
+                            ;//Payload is empty!!
+                        }
+                    }
+                }
+
+                void onGetResourceProfile(const OC::OCRepresentation &representation, const int &eCode)
+                {
+                    //unpack attributeMap
+
+                    //Create SSMResource using OCResource attributeMap
+                    std::map<std::string, std::string>      outputProperty;
+                    OC::AttributeMap                    attributeMap = representation.getAttributeMap();
+                    ISSMResource        *pSSMResource = new ISSMResource();
+                    pSSMResource->location = SENSOR_LOCATION_REMOTE;
+                    pSSMResource->name = m_pResource->host() + m_pResource->uri();
+                    pSSMResource->type = m_pResource->uri().substr(1);
+                    pSSMResource->ip = m_pResource->host();
+
+                    //bind default properties
+                    outputProperty["name"] = "lifetime";
+                    outputProperty["type"] = "int";
+                    outputProperty["value"] = "0";
+                    pSSMResource->outputProperty.push_back(outputProperty);
+
+                    //bind default primitive sensor property, value to resource class for schema creating
+
+                    //TODO: Temporally used for json parsing limitation
+                    for (size_t i = 0; i < attributeMap.size() / 3; i++)
+                    {
+                        outputProperty["name"] = attributeMap.find(std::to_string(i * 3))->second.front();
+                        outputProperty["type"] = attributeMap.find(std::to_string(i * 3 + 1))->second.front();
+                        outputProperty["value"] = attributeMap.find(std::to_string(i * 3 + 2))->second.front();
+                        pSSMResource->outputProperty.push_back(outputProperty);
+                    }
+                    /////////////////////////////////////////////////////
+                    //
+                    int     *pMessage = new int[2];
+                    pMessage[0] = RESOURCE_DISCOVER_SETUP_RESOURCE;
+                    pMessage[1] = (int)pSSMResource;
+
+                    m_pTasker->addTask(m_pResourceFinderClient, (void *)pMessage);
+                }
+
+            private:
+                CObjectPtr<ITasker>                 m_pTasker;
+                std::shared_ptr<OC::OCResource>     m_pResource;
+                IThreadClient                       *m_pResourceFinderClient;
+                IEvent                              *m_pEvent;
+        };
+
+        enum RESOURCE_DISCOVER_STATE {RESOURCE_DISCOVER_REQUESTPROFILE, RESOURCE_DISCOVER_SETUP_RESOURCE};
+        OC::OCPlatform                      *m_pPlatform;
+        CObjectPtr<IResourceConnectivity>   m_pResourceConnectivity;
+        IResourceFinderEvent                *m_pResourceFinderEvent;
+        CObjectPtr<ITasker>             m_pTasker;
+        std::map<std::string , OICResourceHandler *> m_mapResourceHandler;
 };
 
 #endif
index ae3e801..8363cf1 100644 (file)
 
 SSMRESULT CResponseReactor::finalConstruct()
 {
-       SSMRESULT res = SSM_S_OK;
+    SSMRESULT res = SSM_S_OK;
 
-       SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase**)&m_pContextRepository));
+    SSM_CLEANUP_ASSERT(CreateGlobalInstance(OID_IContextRepository, (IBase **)&m_pContextRepository));
 
-       SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextExecutor, (IBase**)&m_pContextExecutor));//TEMP
+    SSM_CLEANUP_ASSERT(CreateInstance(OID_IContextExecutor, (IBase **)&m_pContextExecutor)); //TEMP
 
 CLEANUP:
-       return res;
+    return res;
 }
 
 void CResponseReactor::finalRelease()
 {
 }
 
-void CResponseReactor::registerContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent)
+void CResponseReactor::registerContext(TypeofEvent callType, ISSMResource *pSSMResource,
+                                       IEvent *pEvent)
 {
-       m_mtxRequestedContextData.lock();
-       // if already exists
-       if (m_requestedCallbackData.find(pSSMResource->type) != m_requestedCallbackData.end())
-       {
-               //m_requestedCallbackData.erase(m_requestedCallbackData.find(nameString));
-               unregisterContext(callType,pSSMResource,pEvent);
-       }
-       else
-       {
-               m_requestedCallbackData[pSSMResource->type] = CallbackData(callType, pSSMResource->type, pEvent);
-       }
-       
-       m_pContextExecutor->registerContext(callType, pSSMResource, this);
-
-       m_mtxRequestedContextData.unlock();
+    m_mtxRequestedContextData.lock();
+    // if already exists
+    if (m_requestedCallbackData.find(pSSMResource->type) != m_requestedCallbackData.end())
+    {
+        //m_requestedCallbackData.erase(m_requestedCallbackData.find(nameString));
+        unregisterContext(callType, pSSMResource, pEvent);
+    }
+    else
+    {
+        m_requestedCallbackData[pSSMResource->type] = CallbackData(callType, pSSMResource->type, pEvent);
+    }
+
+    m_pContextExecutor->registerContext(callType, pSSMResource, this);
+
+    m_mtxRequestedContextData.unlock();
 }
 
-void CResponseReactor::unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource, IEvent *pEvent)
+void CResponseReactor::unregisterContext(TypeofEvent callType, ISSMResource *pSSMResource,
+        IEvent *pEvent)
 {
-       m_mtxUnregisterContext.lock();
+    m_mtxUnregisterContext.lock();
 
-       // if already exists
-       if (m_requestedCallbackData.find(pSSMResource->type) != m_requestedCallbackData.end())
-       {
-               m_requestedCallbackData.erase(m_requestedCallbackData.find(pSSMResource->type));
+    // if already exists
+    if (m_requestedCallbackData.find(pSSMResource->type) != m_requestedCallbackData.end())
+    {
+        m_requestedCallbackData.erase(m_requestedCallbackData.find(pSSMResource->type));
 
-               //and Call NextLayer
-               m_pContextExecutor->unregisterContext(callType, pSSMResource, this);
-       }
+        //and Call NextLayer
+        m_pContextExecutor->unregisterContext(callType, pSSMResource, this);
+    }
 
-       m_mtxUnregisterContext.unlock();
+    m_mtxUnregisterContext.unlock();
 }
 
-void CResponseReactor::getList(std::vector<ISSMResource*> *pList)
-{      
-       pList->clear();
+void CResponseReactor::getList(std::vector<ISSMResource *> *pList)
+{
+    pList->clear();
 
-       m_pContextRepository->getSoftSensorList(pList);
+    m_pContextRepository->getSoftSensorList(pList);
 
-       m_pContextRepository->getPrimitiveSensorList(pList);
+    m_pContextRepository->getPrimitiveSensorList(pList);
 }
 
 //Dispatch to upper layer
-int CResponseReactor::onEvent(std::string type, TypeofEvent callType, std::vector<ContextData> ctxData)
+int CResponseReactor::onEvent(std::string type, TypeofEvent callType,
+                              std::vector<ContextData> ctxData)
 {
-       std::map<std::string, CallbackData >::iterator  itor;
-
-       //m_mtxRequestedContextData.Lock();
-
-       itor = m_requestedCallbackData.find(type);
-       if (itor != m_requestedCallbackData.end())
-       {
-               itor->second.m_pCallbackEvent->onEvent(type, callType, ctxData);
-               if (callType == SSM_ONCE)
-               {
-                       m_requestedCallbackData.erase(itor);
-               }
-       }
-       //m_mtxRequestedContextData.Unlock();
-
-       return 0;
+    std::map<std::string, CallbackData >::iterator  itor;
+
+    //m_mtxRequestedContextData.Lock();
+
+    itor = m_requestedCallbackData.find(type);
+    if (itor != m_requestedCallbackData.end())
+    {
+        itor->second.m_pCallbackEvent->onEvent(type, callType, ctxData);
+        if (callType == SSM_ONCE)
+        {
+            m_requestedCallbackData.erase(itor);
+        }
+    }
+    //m_mtxRequestedContextData.Unlock();
+
+    return 0;
 }
index 88680cb..3652f18 100644 (file)
 
 /**
  * @class    CResponseReactor
- * @brief    Class for implement of reactor pattern 
+ * @brief    Class for implement of reactor pattern
  *           Delegate requested context to context executor layer.
- *                      
  *
- * @see      
+ *
+ * @see
  */
 class CResponseReactor :
-       public CObjectRoot<CObjectMultiThreadModel>
-       , public IResponseReactor
+    public CObjectRoot<CObjectMultiThreadModel>
+    , public IResponseReactor
 {
-private:
-       CObjectPtr<IContextRepository>  m_pContextRepository;
-       CObjectPtr<IContextExecutor>    m_pContextExecutor;
-
-       /**
-       * @brief requested high layer's callback data.(IEvent instance, deviceId, call type)
-       */
-       std::map<std::string, CallbackData > m_requestedCallbackData;
-
-       /**
-       * @brief Context model data from lower layer(OnEvent Callback)
-       */
-       std::map<std::string, std::vector<ContextData> > m_storedLowerContextData;
-       
-       CSimpleMutex                                            m_mtxRequestedContextData;
-       CSimpleMutex                                            m_mtxUnregisterContext;
-
-public:
-
-       SSMRESULT finalConstruct();
-       void finalRelease();
-
-       SSMRESULT queryInterface(const OID& objectID, IBase** ppObject)
-       {
-               if(ppObject == NULL)
-                       return SSM_E_POINTER;
-
-               if(IsEqualOID(objectID, OID_IResponseReactor))
-               {
-                       IBase *pBase = this;
-                       pBase->addRef();
-                       *ppObject = pBase;
-                       return SSM_S_OK;
-               }
-
-               return SSM_E_NOINTERFACE;
-       }
-
-       /**
-       * @fn           registerContext
-       * @brief        Register context model request.
-       *
-       * @param                [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
-       * @param                [in]  ISSMResource *pSSMResource -  Requested context model resource.
-       * @param                [in]  IEvent *pEvent -  IEvent class for callback.
-       *
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent);
-       
-       /**
-       * @fn           unregisterContext
-       * @brief        Unregister context model request.
-       *
-       * @param                [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
-       * @param                [in]  ISSMResource *pSSMResource -  Requested context model resource.
-       * @param                [in]  IEvent *pEvent -  IEvent class for callback.
-       *
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       void  unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent);
-       
-       /**
-       * @fn           getList
-       * @brief        Get context model list
-       *
-       * @param                [out]  std::vector<ISSMResource> *pList - ISSMResource vector of low level context models or high level context models.
-       *
-       * @return       void
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       virtual void getList(OUT std::vector<ISSMResource*> *pList);
-
-       /**
-       * @fn           onEvent
-       * @brief        IEvent Interface. 
-       *                               Call from executor when context model data generated.
-       *
-       * @param                [in]  std::string name - caller Resource name.
-       * @param                [in]  TypeofEvent callType -  context event type.
-       * @param                [in]  std::vector<ContextData> ctxData -  context data
-       *
-       * @return       int - function result status
-       *
-       * @warning      
-       * @exception    
-       * @see          
-       */
-       int onEvent(IN std::string name, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
+    private:
+        CObjectPtr<IContextRepository>  m_pContextRepository;
+        CObjectPtr<IContextExecutor>    m_pContextExecutor;
+
+        /**
+        * @brief requested high layer's callback data.(IEvent instance, deviceId, call type)
+        */
+        std::map<std::string, CallbackData > m_requestedCallbackData;
+
+        /**
+        * @brief Context model data from lower layer(OnEvent Callback)
+        */
+        std::map<std::string, std::vector<ContextData> > m_storedLowerContextData;
+
+        CSimpleMutex                        m_mtxRequestedContextData;
+        CSimpleMutex                        m_mtxUnregisterContext;
+
+    public:
+
+        SSMRESULT finalConstruct();
+        void finalRelease();
+
+        SSMRESULT queryInterface(const OID &objectID, IBase **ppObject)
+        {
+            if (ppObject == NULL)
+                return SSM_E_POINTER;
+
+            if (IsEqualOID(objectID, OID_IResponseReactor))
+            {
+                IBase *pBase = this;
+                pBase->addRef();
+                *ppObject = pBase;
+                return SSM_S_OK;
+            }
+
+            return SSM_E_NOINTERFACE;
+        }
+
+        /**
+        * @fn           registerContext
+        * @brief        Register context model request.
+        *
+        * @param        [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
+        * @param        [in]  ISSMResource *pSSMResource -  Requested context model resource.
+        * @param        [in]  IEvent *pEvent -  IEvent class for callback.
+        *
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void registerContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent);
+
+        /**
+        * @fn           unregisterContext
+        * @brief        Unregister context model request.
+        *
+        * @param        [in]  TypeofEvent callType -  Type of event. SSM_ONCE or SSM_REPEAT
+        * @param        [in]  ISSMResource *pSSMResource -  Requested context model resource.
+        * @param        [in]  IEvent *pEvent -  IEvent class for callback.
+        *
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        void  unregisterContext(IN TypeofEvent callType, IN ISSMResource *pSSMResource, IN IEvent *pEvent);
+
+        /**
+        * @fn           getList
+        * @brief        Get context model list
+        *
+        * @param        [out]  std::vector<ISSMResource> *pList - ISSMResource vector of low level context models or high level context models.
+        *
+        * @return       void
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        virtual void getList(OUT std::vector<ISSMResource *> *pList);
+
+        /**
+        * @fn           onEvent
+        * @brief        IEvent Interface.
+        *               Call from executor when context model data generated.
+        *
+        * @param        [in]  std::string name - caller Resource name.
+        * @param        [in]  TypeofEvent callType -  context event type.
+        * @param        [in]  std::vector<ContextData> ctxData -  context data
+        *
+        * @return       int - function result status
+        *
+        * @warning
+        * @exception
+        * @see
+        */
+        int onEvent(IN std::string name, IN TypeofEvent callType, IN std::vector<ContextData> ctxData);
 };
 
 
index b7d676c..572d372 100644 (file)
@@ -21,7 +21,7 @@
 // Do not remove the include below
 #include "Arduino.h"
 
-#define dht11_pin 12 
+#define dht11_pin 12
 
 #include "logger.h"
 #include "ocstack.h"
@@ -49,7 +49,8 @@ PROGMEM const char TAG[] = "ArduinoServer";
 
 int g_THUnderObservation = 0;
 void createTHResource();
-typedef struct THRESOURCE {
+typedef struct THRESOURCE
+{
     OCResourceHandle m_handle;
     int m_temp;
     int m_humid;
@@ -57,25 +58,27 @@ typedef struct THRESOURCE {
 
 static THResource TH;
 
-String g_responsePayloadPut = "{\"href\":\"\",\"rep\":{\"0\":\"temperature\",\"1\":\"int\",\"2\":\"0\",\"3\":\"humidity\",\"4\":\"int\",\"5\":\"0\"}}";
-String g_responsePayloadGet = "{\"href\":\"\",\"rep\":{\"0\":\"temperature\",\"1\":\"int\",\"2\":\"0\",\"3\":\"humidity\",\"4\":\"int\",\"5\":\"0\"}}";
+String g_responsePayloadPut =
+    "{\"href\":\"\",\"rep\":{\"0\":\"temperature\",\"1\":\"int\",\"2\":\"0\",\"3\":\"humidity\",\"4\":\"int\",\"5\":\"0\"}}";
+String g_responsePayloadGet =
+    "{\"href\":\"\",\"rep\":{\"0\":\"temperature\",\"1\":\"int\",\"2\":\"0\",\"3\":\"humidity\",\"4\":\"int\",\"5\":\"0\"}}";
 
 /// This is the port which Arduino Server will use for all unicast communication with it's peers
 static uint16_t OC_WELL_KNOWN_PORT = 5683;
 
 byte read_dht11_dat()
 {
-  byte i = 0;
-  byte result=0;
-  for(i=0; i< 8; i++)
-  {
-    while (!digitalRead(dht11_pin));
-    delayMicroseconds(30);
-    if (digitalRead(dht11_pin) != 0 )
-      bitSet(result, 7-i);
-    while (digitalRead(dht11_pin));
-  }
-  return result;
+    byte i = 0;
+    byte result = 0;
+    for (i = 0; i < 8; i++)
+    {
+        while (!digitalRead(dht11_pin));
+        delayMicroseconds(30);
+        if (digitalRead(dht11_pin) != 0 )
+            bitSet(result, 7 - i);
+        while (digitalRead(dht11_pin));
+    }
+    return result;
 }
 
 #ifdef ARDUINOWIFI
@@ -104,7 +107,7 @@ int ConnectToNetwork()
     // Verify that WiFi Shield is running the firmware with all UDP fixes
     fwVersion = WiFi.firmwareVersion();
     OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
-    if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) !=0 )
+    if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) != 0 )
     {
         OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
         return -1;
@@ -114,7 +117,7 @@ int ConnectToNetwork()
     while (status != WL_CONNECTED)
     {
         OC_LOG_V(INFO, TAG, "Attempting to connect to SSID: %s", ssid);
-        status = WiFi.begin(ssid,pass);
+        status = WiFi.begin(ssid, pass);
 
         // wait 10 seconds for connection:
         delay(10000);
@@ -131,7 +134,7 @@ int ConnectToNetwork()
 {
     // Note: ****Update the MAC address here with your shield's MAC address****
     uint8_t ETHERNET_MAC[] = {0x90, 0xA2, 0xDA, 0x0E, 0xB8, 0xAC};
-   
+
     uint8_t error = Ethernet.begin(ETHERNET_MAC);
     if (error  == 0)
     {
@@ -163,57 +166,64 @@ void PrintArduinoMemoryStats()
 
 // This is the entity handler for the registered resource.
 // This is invoked by OCStack whenever it recevies a request for this resource.
-OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest ) 
+OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag,
+                                        OCEntityHandlerRequest *entityHandlerRequest )
 {
     OCEntityHandlerResult ehRet = OC_EH_OK;
-    const char* typeOfMessage;
-
-    switch (flag) {
-    case OC_INIT_FLAG:
-        typeOfMessage = "OC_INIT_FLAG";
-        break;
-    case OC_REQUEST_FLAG:
-        typeOfMessage = "OC_REQUEST_FLAG";
-        break;
-    case OC_OBSERVE_FLAG:
-        typeOfMessage = "OC_OBSERVE_FLAG";
-        break;
-    default:
-        typeOfMessage = "UNKNOWN";
+    const char *typeOfMessage;
+
+    switch (flag)
+    {
+        case OC_INIT_FLAG:
+            typeOfMessage = "OC_INIT_FLAG";
+            break;
+        case OC_REQUEST_FLAG:
+            typeOfMessage = "OC_REQUEST_FLAG";
+            break;
+        case OC_OBSERVE_FLAG:
+            typeOfMessage = "OC_OBSERVE_FLAG";
+            break;
+        default:
+            typeOfMessage = "UNKNOWN";
     }
     OC_LOG_V(INFO, TAG, "Receiving message type: %s", typeOfMessage);
 
-    if(entityHandlerRequest && flag == OC_REQUEST_FLAG) 
-    { 
-        if(OC_REST_GET == entityHandlerRequest->method) 
+    if (entityHandlerRequest && flag == OC_REQUEST_FLAG)
+    {
+        if (OC_REST_GET == entityHandlerRequest->method)
         {
             int str_len = g_responsePayloadGet.length() + 1;
-            char charBuf[str_len+1];
+            char charBuf[str_len + 1];
 
             g_responsePayloadGet.toCharArray(charBuf, str_len);
 
-            if(strlen(charBuf) < entityHandlerRequest->resJSONPayloadLen)
+            if (strlen(charBuf) < entityHandlerRequest->resJSONPayloadLen)
             {
-            strncpy((char *)entityHandlerRequest->resJSONPayload, charBuf, entityHandlerRequest->resJSONPayloadLen);
+                strncpy((char *)entityHandlerRequest->resJSONPayload, charBuf,
+                        entityHandlerRequest->resJSONPayloadLen);
             }
             else
                 ehRet = OC_EH_ERROR;
         }
-        if(OC_REST_PUT == entityHandlerRequest->method) {
+        if (OC_REST_PUT == entityHandlerRequest->method)
+        {
 
             int str_len1 = g_responsePayloadPut.length() + 1;
             char charBuf1[str_len1];
 
             g_responsePayloadPut.toCharArray(charBuf1, str_len1);
 
-             if(strlen(charBuf1) < entityHandlerRequest->resJSONPayloadLen)
+            if (strlen(charBuf1) < entityHandlerRequest->resJSONPayloadLen)
             {
-            strncpy((char *)entityHandlerRequest->resJSONPayload, charBuf1, entityHandlerRequest->resJSONPayloadLen);
+                strncpy((char *)entityHandlerRequest->resJSONPayload, charBuf1,
+                        entityHandlerRequest->resJSONPayloadLen);
             }
-             else
-               ehRet = OC_EH_ERROR;
+            else
+                ehRet = OC_EH_ERROR;
         }
-    } else if (entityHandlerRequest && flag == OC_OBSERVE_FLAG) {
+    }
+    else if (entityHandlerRequest && flag == OC_OBSERVE_FLAG)
+    {
         g_THUnderObservation = 1;
     }
 
@@ -221,15 +231,16 @@ OCEntityHandlerResult OCEntityHandlerCb(OCEntityHandlerFlag flag, OCEntityHandle
 }
 
 /* Json Generator */
-String JsonGenerator(THResource TH){
-   String a = "{\"href\":\"\",\"rep\":{\"0\":\"temperature\",\"1\":\"int\",\"2\":\"";
-   String b = "\",\"3\":\"humidity\",\"4\":\"int\",\"5\":\"";
-   String c = "\"}}";
+String JsonGenerator(THResource TH)
+{
+    String a = "{\"href\":\"\",\"rep\":{\"0\":\"temperature\",\"1\":\"int\",\"2\":\"";
+    String b = "\",\"3\":\"humidity\",\"4\":\"int\",\"5\":\"";
+    String c = "\"}}";
 
-   String ss;
+    String ss;
 
     ss = a + TH.m_temp + b + TH.m_humid + c;
-       return ss;
+    return ss;
 }
 
 // This method is used to display 'Observe' functionality of OC Stack.
@@ -239,57 +250,58 @@ void *ChangeTHRepresentation (void *param)
     (void)param;
     OCStackResult result = OC_STACK_ERROR;
     modCounter += 1;
-    if(modCounter % 10 == 0)  // Matching the timing that the Linux Sample Server App uses for the same functionality.
+    if (modCounter % 10 ==
+        0) // Matching the timing that the Linux Sample Server App uses for the same functionality.
     {
 
-    byte dht11_dat[5];   
-    byte i;// start condition
-       
-    digitalWrite(dht11_pin, LOW);
-    delay(18);
-    digitalWrite(dht11_pin, HIGH);
-    delayMicroseconds(1);
-    pinMode(dht11_pin, INPUT);
-    delayMicroseconds(40);     
+        byte dht11_dat[5];
+        byte i;// start condition
 
-    if (digitalRead(dht11_pin))
-    {
-        Serial.println("dht11 start condition 1 not met"); // wait for DHT response signal: LOW
-        delay(1000);
-        return NULL;
-    }
-    delayMicroseconds(80);
-    if (!digitalRead(dht11_pin))
-    {
-        Serial.println("dht11 start condition 2 not met");  //wair for second response signal:HIGH
-        return NULL;
-    }
+        digitalWrite(dht11_pin, LOW);
+        delay(18);
+        digitalWrite(dht11_pin, HIGH);
+        delayMicroseconds(1);
+        pinMode(dht11_pin, INPUT);
+        delayMicroseconds(40);
 
-    delayMicroseconds(80);// now ready for data reception
-    for (i=0; i<5; i++)
-    {
-        dht11_dat[i] = read_dht11_dat();
-    }  //recieved 40 bits data. Details are described in datasheet
+        if (digitalRead(dht11_pin))
+        {
+            Serial.println("dht11 start condition 1 not met"); // wait for DHT response signal: LOW
+            delay(1000);
+            return NULL;
+        }
+        delayMicroseconds(80);
+        if (!digitalRead(dht11_pin))
+        {
+            Serial.println("dht11 start condition 2 not met");  //wair for second response signal:HIGH
+            return NULL;
+        }
 
-    pinMode(dht11_pin, OUTPUT);
-    digitalWrite(dht11_pin, HIGH);
-    byte dht11_check_sum = dht11_dat[0]+dht11_dat[2];// check check_sum
-    if(dht11_dat[4]!= dht11_check_sum)
-    {
-        Serial.println("DHT11 checksum error");
-    }
-    Serial.print("Current humdity = ");
-    Serial.print(dht11_dat[0], DEC);
-    Serial.print("%  ");
-    Serial.print("temperature = ");
-    Serial.print(dht11_dat[2], DEC);
-    Serial.println("C  ");
+        delayMicroseconds(80);// now ready for data reception
+        for (i = 0; i < 5; i++)
+        {
+            dht11_dat[i] = read_dht11_dat();
+        }  //recieved 40 bits data. Details are described in datasheet
 
- // delay(2000); //fresh time
-    TH.m_humid = dht11_dat[0];
-    TH.m_temp = dht11_dat[2];
+        pinMode(dht11_pin, OUTPUT);
+        digitalWrite(dht11_pin, HIGH);
+        byte dht11_check_sum = dht11_dat[0] + dht11_dat[2]; // check check_sum
+        if (dht11_dat[4] != dht11_check_sum)
+        {
+            Serial.println("DHT11 checksum error");
+        }
+        Serial.print("Current humdity = ");
+        Serial.print(dht11_dat[0], DEC);
+        Serial.print("%  ");
+        Serial.print("temperature = ");
+        Serial.print(dht11_dat[2], DEC);
+        Serial.println("C  ");
 
-    g_responsePayloadGet = JsonGenerator(TH);
+// delay(2000); //fresh time
+        TH.m_humid = dht11_dat[0];
+        TH.m_temp = dht11_dat[2];
+
+        g_responsePayloadGet = JsonGenerator(TH);
 
         if (g_THUnderObservation)
         {
@@ -312,7 +324,7 @@ void *ChangeTHRepresentation (void *param)
 //The setup function is called once at startup of the sketch
 void setup()
 {
-    pinMode(dht11_pin, OUTPUT);   
+    pinMode(dht11_pin, OUTPUT);
     digitalWrite(dht11_pin, HIGH);
 
     // Add your initialization code here
@@ -320,7 +332,7 @@ void setup()
 
     OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
     uint16_t port = OC_WELL_KNOWN_PORT;
+
     // Connect to Ethernet or WiFi network
     if (ConnectToNetwork() != 0)
     {
@@ -336,7 +348,7 @@ void setup()
     }
 
     // Declare and create the example resource: TH
-   createTHResource();
+    createTHResource();
 
 }
 
@@ -355,10 +367,11 @@ void loop()
         OC_LOG(ERROR, TAG, PCF("OCStack process error"));
         return;
     }
-     ChangeTHRepresentation(NULL);
+    ChangeTHRepresentation(NULL);
 }
 
-void createTHResource() {
+void createTHResource()
+{
     TH.m_humid = 0;
     TH.m_temp = 0;
 
@@ -367,45 +380,47 @@ void createTHResource() {
                                          "oc.mi.def",
                                          "/Thing_TempHumSensor1",
                                          OCEntityHandlerCb,
-                                         OC_DISCOVERABLE|OC_OBSERVABLE);
+                                         OC_DISCOVERABLE | OC_OBSERVABLE);
     OC_LOG_V(INFO, TAG, "Created TH resource with result: %s", getResult(res));
 }
 
-const char *getResult(OCStackResult result) {
-    switch (result) {
-    case OC_STACK_OK:
-        return "OC_STACK_OK";
-    case OC_STACK_INVALID_URI:
-        return "OC_STACK_INVALID_URI";
-    case OC_STACK_INVALID_QUERY:
-        return "OC_STACK_INVALID_QUERY";
-    case OC_STACK_INVALID_IP:
-        return "OC_STACK_INVALID_IP";
-    case OC_STACK_INVALID_PORT:
-        return "OC_STACK_INVALID_PORT";
-    case OC_STACK_INVALID_CALLBACK:
-        return "OC_STACK_INVALID_CALLBACK";
-    case OC_STACK_INVALID_METHOD:
-        return "OC_STACK_INVALID_METHOD";
-    case OC_STACK_NO_MEMORY:
-        return "OC_STACK_NO_MEMORY";
-    case OC_STACK_COMM_ERROR:
-        return "OC_STACK_COMM_ERROR";
-    case OC_STACK_INVALID_PARAM:
-        return "OC_STACK_INVALID_PARAM";
-    case OC_STACK_NOTIMPL:
-        return "OC_STACK_NOTIMPL";
-    case OC_STACK_NO_RESOURCE:
-        return "OC_STACK_NO_RESOURCE";
-    case OC_STACK_RESOURCE_ERROR:
-        return "OC_STACK_RESOURCE_ERROR";
-    case OC_STACK_SLOW_RESOURCE:
-        return "OC_STACK_SLOW_RESOURCE";
-    case OC_STACK_NO_OBSERVERS:
-        return "OC_STACK_NO_OBSERVERS";
-    case OC_STACK_ERROR:
-        return "OC_STACK_ERROR";
-    default:
-        return "UNKNOWN";
+const char *getResult(OCStackResult result)
+{
+    switch (result)
+    {
+        case OC_STACK_OK:
+            return "OC_STACK_OK";
+        case OC_STACK_INVALID_URI:
+            return "OC_STACK_INVALID_URI";
+        case OC_STACK_INVALID_QUERY:
+            return "OC_STACK_INVALID_QUERY";
+        case OC_STACK_INVALID_IP:
+            return "OC_STACK_INVALID_IP";
+        case OC_STACK_INVALID_PORT:
+            return "OC_STACK_INVALID_PORT";
+        case OC_STACK_INVALID_CALLBACK:
+            return "OC_STACK_INVALID_CALLBACK";
+        case OC_STACK_INVALID_METHOD:
+            return "OC_STACK_INVALID_METHOD";
+        case OC_STACK_NO_MEMORY:
+            return "OC_STACK_NO_MEMORY";
+        case OC_STACK_COMM_ERROR:
+            return "OC_STACK_COMM_ERROR";
+        case OC_STACK_INVALID_PARAM:
+            return "OC_STACK_INVALID_PARAM";
+        case OC_STACK_NOTIMPL:
+            return "OC_STACK_NOTIMPL";
+        case OC_STACK_NO_RESOURCE:
+            return "OC_STACK_NO_RESOURCE";
+        case OC_STACK_RESOURCE_ERROR:
+            return "OC_STACK_RESOURCE_ERROR";
+        case OC_STACK_SLOW_RESOURCE:
+            return "OC_STACK_SLOW_RESOURCE";
+        case OC_STACK_NO_OBSERVERS:
+            return "OC_STACK_NO_OBSERVERS";
+        case OC_STACK_ERROR:
+            return "OC_STACK_ERROR";
+        default:
+            return "UNKNOWN";
     }
 }
index 2a3145d..f564708 100644 (file)
@@ -48,19 +48,19 @@ typedef enum
 
 class SSMTestApp: public ISSMClientListener
 {
-private:
-    SSMClient m_SSMClient;
+    private:
+        SSMClient m_SSMClient;
 
-public:
+    public:
 
-    SSMTestApp();
+        SSMTestApp();
 
-    void displayMenu();
-       void registerQuery(std::string queryString);
-    void unregisterQuery();
+        void displayMenu();
+        void registerQuery(std::string queryString);
+        void unregisterQuery();
 
-    /* operations from listener interface */
-    void onRegisterQuery(const AttributeMap& attributeMap, SSMReturn& eCode);
+        /* operations from listener interface */
+        void onRegisterQuery(const AttributeMap &attributeMap, SSMReturn &eCode);
 
 };
 
index 5957d52..008a880 100644 (file)
@@ -36,7 +36,7 @@ void SSMTestApp::displayMenu()
     printf("===============================================\n");
     printf("   1. Register Query \n");
     printf("   2. Unregister Query \n");
-       printf("   3. Register DiscomfortIndexSensor sample query \n");
+    printf("   3. Register DiscomfortIndexSensor sample query \n");
     printf("   9. exit \n");
     printf("===============================================\n");
     printf("   Please Enter the NO: ");
@@ -48,12 +48,12 @@ void SSMTestApp::registerQuery(std::string queryString)
     std::string qid;
     SSMReturn rtn = SSM_ERROR;
 
-       if (queryString.size() == 0)
-       {
-               printf("   Please Enter query string: ");
-               cin.ignore();
-               getline(cin, queryString);
-       }
+    if (queryString.size() == 0)
+    {
+        printf("   Please Enter query string: ");
+        cin.ignore();
+        getline(cin, queryString);
+    }
 
     rtn = m_SSMClient.registerQuery(queryString, this, qid);
 
@@ -85,7 +85,7 @@ void SSMTestApp::unregisterQuery(void)
 }
 
 /* APP. Level Callback Function for Observer of client. */
-void SSMTestApp::onRegisterQuery(const AttributeMap& attributeMap, SSMReturn& eCode)
+void SSMTestApp::onRegisterQuery(const AttributeMap &attributeMap, SSMReturn &eCode)
 {
     if (eCode == SSM_SUCCESS)
     {
@@ -104,7 +104,7 @@ void SSMTestApp::onRegisterQuery(const AttributeMap& attributeMap, SSMReturn& eC
         printf("\n");
 
         for (AttributeMap::const_iterator itor = attributeMap.begin(); itor != attributeMap.end();
-                ++itor)
+             ++itor)
         {
             if (strcmp(itor->first.c_str(), "temperature") == 0)
             {
@@ -151,7 +151,7 @@ int main()
 {
     printf("program start.\n");
     printf("searching SSMResource\n");
-    SSMTestAppSSMApp = new SSMTestApp();
+    SSMTestApp *SSMApp = new SSMTestApp();
     APPMenu::APPMenu menu = APPMenu::NONE;
 
     while (menu != APPMenu::EXIT)
@@ -174,10 +174,10 @@ int main()
                 SSMApp->unregisterQuery();
                 break;
 
-                       case APPMenu::DISCOMFORT_SAMPLE:
-                               SSMApp->registerQuery("subscribe Device.DiscomfortIndexSensor "\
-                                       "if Device.DiscomfortIndexSensor.discomfortIndex > 0");
-                               break;
+            case APPMenu::DISCOMFORT_SAMPLE:
+                SSMApp->registerQuery("subscribe Device.DiscomfortIndexSensor "\
+                                      "if Device.DiscomfortIndexSensor.discomfortIndex > 0");
+                break;
 
             case APPMenu::EXIT:
                 std::cout << "program exit." << std::endl;
index 26b0ee3..8431ceb 100644 (file)
@@ -35,42 +35,42 @@ using namespace std;
 #include <string>
 #include <cstdlib>
 
-#define COAP_IP                                        "134.134.161.33"
-#define COAP_PORT                              56830
-#define COAP_MODE                              ModeType::Server
-#define COAP_SRVTYPE           ServiceType::InProc
+#define COAP_IP                 "134.134.161.33"
+#define COAP_PORT               56830
+#define COAP_MODE               ModeType::Server
+#define COAP_SRVTYPE        ServiceType::InProc
 
-#define COAP_TYPE_NAME                 "SoftSensorManager.Sensor"
+#define COAP_TYPE_NAME          "SoftSensorManager.Sensor"
 
 // Forward declaring the entityHandler
 
 class TemphumidResource
 {
-public:
-    /// Access this property from a TB client
-    int m_humid;
-    int m_temp;
-    string m_resourceUri;
-    OCResourceHandle m_resourceHandle;
+    public:
+        /// Access this property from a TB client
+        int m_humid;
+        int m_temp;
+        string m_resourceUri;
+        OCResourceHandle m_resourceHandle;
 
-public:
-    /// Constructor
-    TemphumidResource() :
+    public:
+        /// Constructor
+        TemphumidResource() :
             m_humid(0), m_temp(0), m_resourceUri("/Thing_TempHumSensor"), m_resourceHandle(NULL)
-    {
-    }
+        {
+        }
 
-    ~TemphumidResource()
-    {
-    }
+        ~TemphumidResource()
+        {
+        }
 
-    void registerResource(OC::OCPlatform& platform);
+        void registerResource(OC::OCPlatform &platform);
 
-    OCResourceHandle getHandle();
+        OCResourceHandle getHandle();
 
-    void setRepresentation(AttributeMap& attributeMap);
+        void setRepresentation(AttributeMap &attributeMap);
 
-    void getRepresentation(AttributeMap& attributeMap);
+        void getRepresentation(AttributeMap &attributeMap);
 };
 
 #endif /* THINGRESOURCESERVER_H_ */
index 51a0376..8c32639 100644 (file)
 int g_Observation = 0;
 
 void entityHandler(std::shared_ptr< OCResourceRequest > request,
-        std::shared_ptr< OCResourceResponse > response);
+                   std::shared_ptr< OCResourceResponse > response);
 
 /*
  * TempResourceFunctions
  */
 
-void TemphumidResource::registerResource(OC::OCPlatformplatform)
+void TemphumidResource::registerResource(OC::OCPlatform &platform)
 {
     string resourceURI = m_resourceUri; // URI of the resource
     string resourceTypeName = COAP_TYPE_NAME; // resource type name.
@@ -39,7 +39,7 @@ void TemphumidResource::registerResource(OC::OCPlatform& platform)
 
     // This will internally create and register the resource.
     OCStackResult result = platform.registerResource(m_resourceHandle, resourceURI,
-            resourceTypeName, resourceInterface, &entityHandler, resourceProperty);
+                           resourceTypeName, resourceInterface, &entityHandler, resourceProperty);
 
     if (OC_STACK_OK != result)
     {
@@ -52,7 +52,7 @@ OCResourceHandle TemphumidResource::getHandle()
     return m_resourceHandle;
 }
 
-void TemphumidResource::setRepresentation(AttributeMapattributeMap)
+void TemphumidResource::setRepresentation(AttributeMap &attributeMap)
 {
     cout << "\t\t\t" << "Received representation: " << endl;
     cout << "\t\t\t\t" << "temp: " << attributeMap["temp"][0] << endl;
@@ -62,7 +62,7 @@ void TemphumidResource::setRepresentation(AttributeMap& attributeMap)
     m_humid = std::stoi(attributeMap["humid"][0]);
 }
 
-void TemphumidResource::getRepresentation(AttributeMapattributeMap)
+void TemphumidResource::getRepresentation(AttributeMap &attributeMap)
 {
     attributeMap["0"].push_back("temperature");
     attributeMap["1"].push_back("int");
@@ -77,7 +77,7 @@ void TemphumidResource::getRepresentation(AttributeMap& attributeMap)
 
 TemphumidResource g_myResource;
 
-void * TestSensorVal(void *param)
+void *TestSensorVal(void *param)
 {
     g_myResource.m_temp = 27;
     g_myResource.m_humid = 48;
@@ -95,7 +95,7 @@ void * TestSensorVal(void *param)
             cout << "\ntemp updated to : " << g_myResource.m_temp << endl;
             cout << "\nhumid updated to : " << g_myResource.m_humid << endl;
             cout << "Notifying observers with resource handle: " << g_myResource.getHandle()
-                    << endl;
+                 << endl;
 
             OCStackResult result = OCPlatform::notifyObservers(g_myResource.getHandle());
 
@@ -110,7 +110,7 @@ void * TestSensorVal(void *param)
 }
 
 void entityHandler(std::shared_ptr< OCResourceRequest > request,
-        std::shared_ptr< OCResourceResponse > response)
+                   std::shared_ptr< OCResourceResponse > response)
 {
     cout << "\tIn Server CPP entity handler:\n";
 
@@ -192,7 +192,7 @@ void entityHandler(std::shared_ptr< OCResourceRequest > request,
 int main()
 {
     // Create PlatformConfig object
-       PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable);
+    PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable);
 
     try
     {
index 16af452..eada4e6 100644 (file)
@@ -35,42 +35,42 @@ using namespace std;
 #include <string>
 #include <cstdlib>
 
-#define COAP_IP                                        "134.134.161.33"
-#define COAP_PORT                              56838
-#define COAP_MODE                              ModeType::Server
-#define COAP_SRVTYPE           ServiceType::InProc
+#define COAP_IP                 "134.134.161.33"
+#define COAP_PORT               56838
+#define COAP_MODE               ModeType::Server
+#define COAP_SRVTYPE        ServiceType::InProc
 
-#define COAP_TYPE_NAME                 "SoftSensorManager.Sensor"
+#define COAP_TYPE_NAME          "SoftSensorManager.Sensor"
 
 // Forward declaring the entityHandler
 
 class TemphumidResource
 {
-public:
-    /// Access this property from a TB client
-    int m_humid;
-    int m_temp;
-    string m_resourceUri;
-    OCResourceHandle m_resourceHandle;
+    public:
+        /// Access this property from a TB client
+        int m_humid;
+        int m_temp;
+        string m_resourceUri;
+        OCResourceHandle m_resourceHandle;
 
-public:
-    /// Constructor
-    TemphumidResource() :
+    public:
+        /// Constructor
+        TemphumidResource() :
             m_humid(0), m_temp(0), m_resourceUri("/Thing_TempHumSensor1"), m_resourceHandle(NULL)
-    {
-    }
+        {
+        }
 
-    ~TemphumidResource()
-    {
-    }
+        ~TemphumidResource()
+        {
+        }
 
-    void registerResource(OC::OCPlatform& platform);
+        void registerResource(OC::OCPlatform &platform);
 
-    OCResourceHandle getHandle();
+        OCResourceHandle getHandle();
 
-    void setRepresentation(AttributeMap& attributeMap);
+        void setRepresentation(AttributeMap &attributeMap);
 
-    void getRepresentation(AttributeMap& attributeMap);
+        void getRepresentation(AttributeMap &attributeMap);
 };
 
 #endif /* THINGRESOURCESERVER_H_ */
index c3523f5..b1d3857 100644 (file)
 int g_Observation = 0;
 
 void entityHandler(std::shared_ptr< OCResourceRequest > request,
-        std::shared_ptr< OCResourceResponse > response);
+                   std::shared_ptr< OCResourceResponse > response);
 
 /*
  * TempResourceFunctions
  */
 
-void TemphumidResource::registerResource(OC::OCPlatformplatform)
+void TemphumidResource::registerResource(OC::OCPlatform &platform)
 {
     string resourceURI = m_resourceUri; // URI of the resource
     string resourceTypeName = COAP_TYPE_NAME; // resource type name.
@@ -39,7 +39,7 @@ void TemphumidResource::registerResource(OC::OCPlatform& platform)
 
     // This will internally create and register the resource.
     OCStackResult result = platform.registerResource(m_resourceHandle, resourceURI,
-            resourceTypeName, resourceInterface, &entityHandler, resourceProperty);
+                           resourceTypeName, resourceInterface, &entityHandler, resourceProperty);
 
     if (OC_STACK_OK != result)
     {
@@ -52,7 +52,7 @@ OCResourceHandle TemphumidResource::getHandle()
     return m_resourceHandle;
 }
 
-void TemphumidResource::setRepresentation(AttributeMapattributeMap)
+void TemphumidResource::setRepresentation(AttributeMap &attributeMap)
 {
     cout << "\t\t\t" << "Received representation: " << endl;
     cout << "\t\t\t\t" << "temp: " << attributeMap["temp"][0] << endl;
@@ -62,7 +62,7 @@ void TemphumidResource::setRepresentation(AttributeMap& attributeMap)
     m_humid = std::stoi(attributeMap["humid"][0]);
 }
 
-void TemphumidResource::getRepresentation(AttributeMapattributeMap)
+void TemphumidResource::getRepresentation(AttributeMap &attributeMap)
 {
     attributeMap["0"].push_back("temperature");
     attributeMap["1"].push_back("int");
@@ -77,7 +77,7 @@ void TemphumidResource::getRepresentation(AttributeMap& attributeMap)
 
 TemphumidResource g_myResource;
 
-void * TestSensorVal(void *param)
+void *TestSensorVal(void *param)
 {
     g_myResource.m_temp = 27;
     g_myResource.m_humid = 48;
@@ -95,7 +95,7 @@ void * TestSensorVal(void *param)
             cout << "\ntemp updated to : " << g_myResource.m_temp << endl;
             cout << "\nhumid updated to : " << g_myResource.m_humid << endl;
             cout << "Notifying observers with resource handle: " << g_myResource.getHandle()
-                    << endl;
+                 << endl;
 
             OCStackResult result = OCPlatform::notifyObservers(g_myResource.getHandle());
 
@@ -110,7 +110,7 @@ void * TestSensorVal(void *param)
 }
 
 void entityHandler(std::shared_ptr< OCResourceRequest > request,
-        std::shared_ptr< OCResourceResponse > response)
+                   std::shared_ptr< OCResourceResponse > response)
 {
     cout << "\tIn Server CPP entity handler:\n";
 
@@ -193,7 +193,7 @@ int main()
 {
     // Create PlatformConfig object
 
-       PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable);
+    PlatformConfig cfg(COAP_SRVTYPE, COAP_MODE, COAP_IP, COAP_PORT, QualityOfService::NonConfirmable);
 
     try
     {
index 5c5c8d6..f425b3d 100644 (file)
@@ -19,7 +19,7 @@
  ******************************************************************/
 
 /**
- * @file    ISSMClientListener.h 
+ * @file    ISSMClientListener.h
  * @brief   This file contains client listener interfaces.
  */
 
@@ -38,24 +38,24 @@ typedef enum
 
 using namespace OC;
 /**
- *     @brief  ISSMClientListener is a listener interface from which application is derived to get callback from SoftSensorManager service
+ *  @brief  ISSMClientListener is a listener interface from which application is derived to get callback from SoftSensorManager service
  */
 class ISSMClientListener
 {
-public:
-    /**
-     * @brief  onRegisterQuery is a pure virtual operation which should be implemented in applications to get callback messages.
-     * @param [in] attributeMap - A data map in which SoftSensorManager service sends sensor data with cqid.
-     * @param [in] eCode - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
-     *                          SSMClient can callback message to the appication.
-     * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
-     * @return  SSMReturn
-     
-     */
-    virtual void onRegisterQuery(const AttributeMap& attributeMap, SSMReturn& eCode) = 0;
-    virtual ~ISSMClientListener()
-    {
-    }
+    public:
+        /**
+         * @brief   onRegisterQuery is a pure virtual operation which should be implemented in applications to get callback messages.
+         * @param [in] attributeMap - A data map in which SoftSensorManager service sends sensor data with cqid.
+         * @param [in] eCode - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
+         *                          SSMClient can callback message to the appication.
+         * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
+         * @return  SSMReturn
+
+         */
+        virtual void onRegisterQuery(const AttributeMap &attributeMap, SSMReturn &eCode) = 0;
+        virtual ~ISSMClientListener()
+        {
+        }
 };
 
 #endif /* ISSMCLIENTLISTENER_H_ */
index 62a6884..e3375f2 100644 (file)
 #include "OCPlatform.h"
 #include "OCApi.h"
 
-const charSSM_RESOURCE_URI = "/service/SoftSensorManager";
+const char *SSM_RESOURCE_URI = "/service/SoftSensorManager";
 
-#define SSM_RESOURCE_TYPE              = "core.SoftSensorManager"
+#define SSM_RESOURCE_TYPE       = "core.SoftSensorManager"
 
-#define COAP_IP                                        "134.134.161.33"
-#define COAP_PORT                              5683
-#define COAP_MODE                              ModeType::Client
-#define COAP_SRVTYPE                   ServiceType::InProc
+#define COAP_IP                 "134.134.161.33"
+#define COAP_PORT               5683
+#define COAP_MODE               ModeType::Client
+#define COAP_SRVTYPE            ServiceType::InProc
 
-#define COAP_SERVER_ADDR               "coap://224.0.1.187/oc/core?rt=core.SoftSensorManager"
+#define COAP_SERVER_ADDR        "coap://224.0.1.187/oc/core?rt=core.SoftSensorManager"
 
 SSMClient::SSMClient()
 {
@@ -70,8 +70,8 @@ void SSMClient::_findResource()
         // Find all resources
         OCStackResult result;
         if ((result = m_pPlatform->findResource("", COAP_SERVER_ADDR,
-                std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1)))
-                != OC_STACK_OK)
+                                                std::bind(&SSMClient::onFoundResource, this, std::placeholders::_1)))
+            != OC_STACK_OK)
         {
             delete m_pPlatform;
             m_pPlatform = NULL;
@@ -103,8 +103,8 @@ void SSMClient::_createQueryEngine(void)
     rep.setAttributeMap(requestAttributeMap);
 
     if (m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onCreateQueryEngine, this, std::placeholders::_1,
-                    std::placeholders::_2)) != OC_STACK_OK)
+                           std::bind(&SSMClient::onCreateQueryEngine, this, std::placeholders::_1,
+                                     std::placeholders::_2)) != OC_STACK_OK)
     {
         return;
     }
@@ -133,14 +133,14 @@ void SSMClient::_releaseQueryEngine(std::string queryEngineId)
     rep.setAttributeMap(requestAttributeMap);
 
     m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onReleaseQueryEngine, this, std::placeholders::_1,
-                    std::placeholders::_2));
+                       std::bind(&SSMClient::onReleaseQueryEngine, this, std::placeholders::_1,
+                                 std::placeholders::_2));
 
     m_sem.wait();
 }
 
-SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListenerlistener,
-        std::string &cqid)
+SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListener *listener,
+                                   std::string &cqid)
 {
     OCRepresentation rep;
 
@@ -168,8 +168,8 @@ SSMReturn SSMClient::registerQuery(std::string queryString, ISSMClientListener*
     rep.setAttributeMap(requestAttributeMap);
 
     if (m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onRegisterQuery, this, std::placeholders::_1,
-                    std::placeholders::_2)) != OC_STACK_OK)
+                           std::bind(&SSMClient::onRegisterQuery, this, std::placeholders::_1,
+                                     std::placeholders::_2)) != OC_STACK_OK)
         return SSM_ERROR_NETWORK;
 
     m_sem.wait();
@@ -208,8 +208,8 @@ SSMReturn SSMClient::unregisterQuery(std::string cqid)
     rep.setAttributeMap(requestAttributeMap);
 
     if (m_SSMResource->put(rep, queryParamsMap,
-            std::bind(&SSMClient::onUnregisterQuery, this, std::placeholders::_1,
-                    std::placeholders::_2)) != OC_STACK_OK)
+                           std::bind(&SSMClient::onUnregisterQuery, this, std::placeholders::_1,
+                                     std::placeholders::_2)) != OC_STACK_OK)
         return SSM_ERROR_NETWORK;
 
     m_sem.wait();
@@ -238,7 +238,7 @@ void SSMClient::onFoundResource(std::shared_ptr< OCResource > resource)
             }
         }
     }
-    catch (std::exceptione)
+    catch (std::exception &e)
     {
         //log(e.what());
     }
@@ -246,7 +246,7 @@ void SSMClient::onFoundResource(std::shared_ptr< OCResource > resource)
     m_sem.release();
 }
 
-void SSMClient::onCreateQueryEngine(const OCRepresentationrep, const int eCode)
+void SSMClient::onCreateQueryEngine(const OCRepresentation &rep, const int eCode)
 {
     if (eCode != 0)
     {
@@ -259,10 +259,10 @@ void SSMClient::onCreateQueryEngine(const OCRepresentation& rep, const int eCode
     m_responseAttributeMap["queryEngineId"].pop_back();
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onRegisterQuery(const OCRepresentationrep, const int eCode)
+void SSMClient::onRegisterQuery(const OCRepresentation &rep, const int eCode)
 {
     QueryParamsMap queryParamsMap;
 
@@ -281,14 +281,14 @@ void SSMClient::onRegisterQuery(const OCRepresentation& rep, const int eCode)
     }
 
     m_SSMResource->observe(ObserveType::Observe, queryParamsMap,
-            std::bind(&SSMClient::onObserve, this, std::placeholders::_1, std::placeholders::_2));
+                           std::bind(&SSMClient::onObserve, this, std::placeholders::_1, std::placeholders::_2));
 
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onUnregisterQuery(const OCRepresentationrep, const int eCode)
+void SSMClient::onUnregisterQuery(const OCRepresentation &rep, const int eCode)
 {
     if (eCode != 0)
     {
@@ -306,10 +306,10 @@ void SSMClient::onUnregisterQuery(const OCRepresentation& rep, const int eCode)
 
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onReleaseQueryEngine(const OCRepresentationrep, const int eCode)
+void SSMClient::onReleaseQueryEngine(const OCRepresentation &rep, const int eCode)
 {
     if (eCode != 0)
     {
@@ -321,10 +321,10 @@ void SSMClient::onReleaseQueryEngine(const OCRepresentation& rep, const int eCod
 
     m_retResponse = SSM_SUCCESS;
 
-    CLEANUP: m_sem.release();
+CLEANUP: m_sem.release();
 }
 
-void SSMClient::onObserve(const OCRepresentation& rep, const int& eCode)
+void SSMClient::onObserve(const OCRepresentation &rep, const int &eCode)
 {
     SSMReturn ret = SSM_SUCCESS;
 
index f365826..1ee47bd 100644 (file)
@@ -19,7 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
 /**
- * @file    SSMClient.h 
+ * @file    SSMClient.h
  * @brief   This file contains the declaration of classes and its members related to SSMClient.
  */
 
@@ -37,207 +37,207 @@ using namespace OC;
 #if defined(WIN32)
 class CSemaphore
 {
-private:
-    HANDLE hSemaphore;
-    int m_MaxTimeOut;
-
-public:
-    /**
-     * This is CSemaphore constructor.
-     */
-    CSemaphore()
-    {
-        m_MaxTimeOut = 0;
-    }
-    /**
-     *This is CSemaphore destructor.
-     */
-    ~CSemaphore()
-    {
-    }
-
-    /**
-     * This is a function to creat a semaphore
-     * This is syncronus call.
-     * @param maximumRequestTimeOut
-     *          [IN] Request Time out.
-     *
-     * @return  None
-     *   
-     */
-    void create(int maximumRequestTimeOut)
-    {
-        hSemaphore = CreateSemaphore(NULL, 1, 1, NULL);
-        m_MaxTimeOut = maximumRequestTimeOut;
-    }
-
-    /**
-     * This is a function to wait for semaphore
-     *
-     * @return  None
-     *   
-     */
-    void wait()
-    {
-        WaitForSingleObject(hSemaphore, m_MaxTimeOut);
-    }
-
-    /**
-     * This is a function to release  semaphore
-     *
-     * @return  None
-     *   
-     */
-    void release()
-    {
-        ReleaseSemaphore(hSemaphore, 1, NULL);
-    }
+    private:
+        HANDLE hSemaphore;
+        int m_MaxTimeOut;
+
+    public:
+        /**
+         * This is CSemaphore constructor.
+         */
+        CSemaphore()
+        {
+            m_MaxTimeOut = 0;
+        }
+        /**
+         *This is CSemaphore destructor.
+         */
+        ~CSemaphore()
+        {
+        }
+
+        /**
+         * This is a function to creat a semaphore
+         * This is syncronus call.
+         * @param maximumRequestTimeOut
+         *          [IN] Request Time out.
+         *
+         * @return  None
+         *
+         */
+        void create(int maximumRequestTimeOut)
+        {
+            hSemaphore = CreateSemaphore(NULL, 1, 1, NULL);
+            m_MaxTimeOut = maximumRequestTimeOut;
+        }
+
+        /**
+         * This is a function to wait for semaphore
+         *
+         * @return  None
+         *
+         */
+        void wait()
+        {
+            WaitForSingleObject(hSemaphore, m_MaxTimeOut);
+        }
+
+        /**
+         * This is a function to release  semaphore
+         *
+         * @return  None
+         *
+         */
+        void release()
+        {
+            ReleaseSemaphore(hSemaphore, 1, NULL);
+        }
 
 };
 
 #elif defined(LINUX)
 #include <semaphore.h>
 
-#define SEM_SUCCESS            0
+#define SEM_SUCCESS     0
 
 class CSemaphore
 {
-private:
-    sem_t hSemaphore;
-    timespec m_MaxTimeOut;
-
-public:
-    /**
-     * This is CSemaphore constructor.
-     */
-    CSemaphore()
-    {
-        m_MaxTimeOut.tv_sec = 0;
-        m_MaxTimeOut.tv_nsec = 0;
-    }
-    /**
-     *This is CSemaphore destructor.
-     */
-    ~CSemaphore()
-    {
-    }
-    /**
-     * This is a function to creat a semaphore
-     * This is syncronus call.
-     * @param maximumRequestTimeOut
-     *          [IN] Request Time out.
-     *
-     * @return  None
-     *   
-     */
-    void create(int maximumRequestTimeOut)
-    {
-        if ( sem_init(&hSemaphore, 1, 0) < SEM_SUCCESS )
+    private:
+        sem_t hSemaphore;
+        timespec m_MaxTimeOut;
+
+    public:
+        /**
+         * This is CSemaphore constructor.
+         */
+        CSemaphore()
+        {
+            m_MaxTimeOut.tv_sec = 0;
+            m_MaxTimeOut.tv_nsec = 0;
+        }
+        /**
+         *This is CSemaphore destructor.
+         */
+        ~CSemaphore()
+        {
+        }
+        /**
+         * This is a function to creat a semaphore
+         * This is syncronus call.
+         * @param maximumRequestTimeOut
+         *          [IN] Request Time out.
+         *
+         * @return  None
+         *
+         */
+        void create(int maximumRequestTimeOut)
+        {
+            if ( sem_init(&hSemaphore, 1, 0) < SEM_SUCCESS )
+            {
+                perror("Error : sem_init.");
+                exit(0);
+            }
+            m_MaxTimeOut.tv_sec = maximumRequestTimeOut;
+        }
+
+        void wait()
+        {
+            sem_wait( &hSemaphore );
+        }
+
+        /**
+         * This is a function to release  semaphore
+         *
+         * @return  None
+         *
+         */
+        void release()
         {
-            perror("Error : sem_init.");
-            exit(0);
+            sem_post(&hSemaphore);
         }
-        m_MaxTimeOut.tv_sec = maximumRequestTimeOut;
-    }
-
-    void wait()
-    {
-        sem_wait( &hSemaphore );
-    }
-
-    /**
-     * This is a function to release  semaphore
-     *
-     * @return  None
-     *   
-     */
-    void release()
-    {
-        sem_post(&hSemaphore);
-    }
 
 };
 #endif
 
 /**
- *     @brief  SSMClient is a wrapper class to provide SoftSensorManager functionality to Application.
- *                     Basically, SoftSensorManager is developed in Resource model (i.e. messaging with basic functions of put, get, and post).
- *                     SSMClient abstracts the resource based operations from client applications and provides c++ style functions.
+ *  @brief  SSMClient is a wrapper class to provide SoftSensorManager functionality to Application.
+ *          Basically, SoftSensorManager is developed in Resource model (i.e. messaging with basic functions of put, get, and post).
+ *          SSMClient abstracts the resource based operations from client applications and provides c++ style functions.
  */
 class SSMClient
 {
-private:
-    SSMReturn m_retResponse;
-    OCPlatform *m_pPlatform;
-    CSemaphore m_sem;
-    /**
-     * @brief SoftSensorManager Resource.
-     */
-    std::shared_ptr< OCResource > m_SSMResource;
-    /**
-     * @brief attribute map .
-     */
-    AttributeMap m_responseAttributeMap;
-    /**
-     * @brief query engine.
-     */
-    std::string m_queryEngineId;
-    /**
-     * @brief app listener
-     */
-    ISSMClientListener* m_appListener;
-
-    /**
-     * @brief internal find resource function
-     */
-    void _findResource(void);
-
-    /**
-     * @brief internal Query engine function
-     */
-    void _createQueryEngine(void);
-
-    /**
-     * @brief internal release query function
-     */
-    void _releaseQueryEngine(std::string queryEngineId);
-
-public:
-    /**
-     * Constructor for SSMClient. 
-     */
-    SSMClient();
-    ~SSMClient();
-
-    /**
-     * This API sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
-     * 
-     * @param [in] queryString - A conditions query statement where the caller application specifies sensors for required data and conditions when the caller wants to get the data.
-     * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
-     *                          SSMClient can callback message to the application.
-     * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
-     * @return  SSMReturn
-     
-     */
-    SSMReturn registerQuery(std::string queryString, ISSMClientListener* listener,
-            std::string &cqid);
-    /**
-     * This API is to cancel the registered sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
-     * 
-     * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
-     *                          SSMClient can callback message to the application.
-     * @param [in] cqid - A query id generated from SoftSensorManager service for the queryString request.
-     * @return  SSMReturn
-     */
-    SSMReturn unregisterQuery(std::string cqid);
-
-    // friend option. for callback from SSMResource
-    void onFoundResource(std::shared_ptr< OCResource > resource);
-    void onCreateQueryEngine(const OCRepresentation& rep, const int eCode);
-    void onReleaseQueryEngine(const OCRepresentation& rep, const int eCode);
-    void onRegisterQuery(const OCRepresentation& rep, const int eCode);
-    void onUnregisterQuery(const OCRepresentation& rep, const int eCode);
-    void onObserve(const OCRepresentation& rep, const int& eCode);
+    private:
+        SSMReturn m_retResponse;
+        OCPlatform *m_pPlatform;
+        CSemaphore m_sem;
+        /**
+         * @brief SoftSensorManager Resource.
+         */
+        std::shared_ptr< OCResource > m_SSMResource;
+        /**
+         * @brief attribute map .
+         */
+        AttributeMap m_responseAttributeMap;
+        /**
+         * @brief query engine.
+         */
+        std::string m_queryEngineId;
+        /**
+         * @brief app listener
+         */
+        ISSMClientListener *m_appListener;
+
+        /**
+         * @brief internal find resource function
+         */
+        void _findResource(void);
+
+        /**
+         * @brief internal Query engine function
+         */
+        void _createQueryEngine(void);
+
+        /**
+         * @brief internal release query function
+         */
+        void _releaseQueryEngine(std::string queryEngineId);
+
+    public:
+        /**
+         * Constructor for SSMClient.
+         */
+        SSMClient();
+        ~SSMClient();
+
+        /**
+         * This API sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
+         *
+         * @param [in] queryString - A conditions query statement where the caller application specifies sensors for required data and conditions when the caller wants to get the data.
+         * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
+         *                          SSMClient can callback message to the application.
+         * @param [out] cqid - A query id generated from SoftSensorManager service for the queryString request.
+         * @return  SSMReturn
+
+         */
+        SSMReturn registerQuery(std::string queryString, ISSMClientListener *listener,
+                                std::string &cqid);
+        /**
+         * This API is to cancel the registered sends query strings of applications to SoftSensorManager on Iotivity Base messaging.
+         *
+         * @param [in] listener - The address of listener class.  When an application which inherits the ISSMClientListener calls this operation, it sends its address for the listener so that
+         *                          SSMClient can callback message to the application.
+         * @param [in] cqid - A query id generated from SoftSensorManager service for the queryString request.
+         * @return  SSMReturn
+         */
+        SSMReturn unregisterQuery(std::string cqid);
+
+        // friend option. for callback from SSMResource
+        void onFoundResource(std::shared_ptr< OCResource > resource);
+        void onCreateQueryEngine(const OCRepresentation &rep, const int eCode);
+        void onReleaseQueryEngine(const OCRepresentation &rep, const int eCode);
+        void onRegisterQuery(const OCRepresentation &rep, const int eCode);
+        void onUnregisterQuery(const OCRepresentation &rep, const int eCode);
+        void onObserve(const OCRepresentation &rep, const int &eCode);
 };
 
 #endif /* RESOURCECLIENT_H_ */
index 4a7fdb3..a0b3484 100644 (file)
 #define LOG_TAG "OIC_TEST"
 #include <dlog.h>
 
-#define LOG_COLOR_RED          "\033[0;31m"
-#define LOG_COLOR_BROWN                "\033[0;33m"
-#define LOG_COLOR_BLUE         "\033[0;34m"
-#define LOG_COLOR_END          "\033[0;m"
+#define LOG_COLOR_RED       "\033[0;31m"
+#define LOG_COLOR_BROWN     "\033[0;33m"
+#define LOG_COLOR_BLUE      "\033[0;34m"
+#define LOG_COLOR_END       "\033[0;m"
 
 
 #if 1
 #define _ERR(fmt, arg...) SLOGE(fmt, ##arg)
 #else
 #define _DBG(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
+    printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
 #define _INFO(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
+    printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
 #define _WARN(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
+    printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
 #define _ERR(fmt, arg...) \
-       printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
+    printf("[OIC_TEST]%s(%d):" fmt "\n", __FUNCTION__, __LINE__, ##arg)
 #endif
 
 #define DBG(fmt, arg...) _DBG(fmt, ##arg)
 #define INFO(fmt, arg...) _INFO(LOG_COLOR_BLUE fmt LOG_COLOR_END, ##arg)
 
 #define ret_if(expr) \
-       do { \
-               if (expr) { \
-                       ERR("(%s)", #expr); \
-                       return; \
-               }\
-       } while(0)
+    do { \
+        if (expr) { \
+            ERR("(%s)", #expr); \
+            return; \
+        }\
+    } while(0)
 #define retv_if(expr, val) \
-       do {\
-               if (expr) { \
-                       ERR("(%s)", #expr); \
-                       return (val); \
-               } \
-       } while(0)
+    do {\
+        if (expr) { \
+            ERR("(%s)", #expr); \
+            return (val); \
+        } \
+    } while(0)
 #define retm_if(expr, fmt, arg...) \
-       do {\
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-                       return; \
-               }\
-       } while(0)
+    do {\
+        if (expr) { \
+            ERR(fmt, ##arg); \
+            return; \
+        }\
+    } while(0)
 #define retvm_if(expr, val, fmt, arg...) \
-       do {\
-               if (expr) { \
-                       ERR(fmt, ##arg); \
-                       return (val); \
-               } \
-       } while(0)
+    do {\
+        if (expr) { \
+            ERR(fmt, ##arg); \
+            return (val); \
+        } \
+    } while(0)
 #define warn_if(expr) \
-       do { \
-               if (expr) { \
-                       WARN("(%s)", #expr); \
-               } \
-       } while (0)
+    do { \
+        if (expr) { \
+            WARN("(%s)", #expr); \
+        } \
+    } while (0)
 
 
 #endif //__OICAPP_LOG_H__
index 7a0af68..c553ba6 100644 (file)
@@ -27,408 +27,409 @@ static oicapp_data *g_ad = NULL;
 
 class CSSMClientListener: public ISSMClientListener
 {
-public:
-void onRegisterQuery(const AttributeMap& attributeMap, SSMReturn::SSMReturn& eCode)
-       {
-               //EFL UI printing
-
-               char *queryResult = "";
-               std::stringstream sstream;
-
-               for (AttributeMap::const_iterator itor = attributeMap.begin(); itor != attributeMap.end(); itor++)
-               {
-                       //if (itor->first == "queryEngineId")
-                       //{
-                       //      sstream << itor->first.c_str() << " : " << std::hex << stoi(itor->second.front().c_str()) << "\n";
-                       //}
-                       //else
-                       //{
-                               sstream << itor->first.c_str() << " : " << itor->second.front().c_str() << "\n";
-                       //}
-               }
-
-//             queryResult = const_cast<char *>(sstream .str().c_str());
-               oicapp_util_put_msg (g_ad, g_ad->input_msg);
-               
-
-       }
+    public:
+        void onRegisterQuery(const AttributeMap &attributeMap, SSMReturn::SSMReturn &eCode)
+        {
+            //EFL UI printing
+
+            char *queryResult = "";
+            std::stringstream sstream;
+
+            for (AttributeMap::const_iterator itor = attributeMap.begin(); itor != attributeMap.end(); itor++)
+            {
+                //if (itor->first == "queryEngineId")
+                //{
+                //  sstream << itor->first.c_str() << " : " << std::hex << stoi(itor->second.front().c_str()) << "\n";
+                //}
+                //else
+                //{
+                sstream << itor->first.c_str() << " : " << itor->second.front().c_str() << "\n";
+                //}
+            }
+
+//      queryResult = const_cast<char *>(sstream .str().c_str());
+            oicapp_util_put_msg (g_ad, g_ad->input_msg);
+
+
+        }
 };
 
-CSSMClientListener     *g_SSMClientListener = new CSSMClientListener();
-SSMClient                      *g_SSMClient            = NULL;
+CSSMClientListener  *g_SSMClientListener = new CSSMClientListener();
+SSMClient           *g_SSMClient        = NULL;
 
-static Elm_Object_Itemoicapp_append_separator(Evas_Object *genlist,
-               oicapp_data *ad)
+static Elm_Object_Item *oicapp_append_separator(Evas_Object *genlist,
+        oicapp_data *ad)
 {
-       Elm_Object_Item *item = NULL;
+    Elm_Object_Item *item = NULL;
 
-       item = elm_genlist_item_append(genlist, &ad->itc_seperator, NULL, NULL,
-                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
-       elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+    item = elm_genlist_item_append(genlist, &ad->itc_seperator, NULL, NULL,
+                                   ELM_GENLIST_ITEM_NONE, NULL, NULL);
+    elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-       return item;
+    return item;
 }
 
 static void _win_del(void *data, Evas_Object *obj, void *event)
 {
-       DBG("test _win_del()");
+    DBG("test _win_del()");
 
-       elm_exit();
+    elm_exit();
 }
 
-static Evas_Objectoicapp_create_win(const char *name)
+static Evas_Object *oicapp_create_win(const char *name)
 {
-       Evas_Object *eo;
-       int w, h;
-
-       eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
-       if (eo) {
-               elm_win_title_set(eo, name);
-               elm_win_borderless_set(eo, EINA_TRUE);
-               evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
-               ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
-               evas_object_resize(eo, w, h);
-               elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
-               elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE);
-       }
-
-       evas_object_show(eo);
-
-       return eo;
+    Evas_Object *eo;
+    int w, h;
+
+    eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
+    if (eo)
+    {
+        elm_win_title_set(eo, name);
+        elm_win_borderless_set(eo, EINA_TRUE);
+        evas_object_smart_callback_add(eo, "delete,request", _win_del, NULL);
+        ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
+        evas_object_resize(eo, w, h);
+        elm_win_indicator_mode_set(eo, ELM_WIN_INDICATOR_SHOW);
+        elm_win_indicator_opacity_set(eo, ELM_WIN_INDICATOR_OPAQUE);
+    }
+
+    evas_object_show(eo);
+
+    return eo;
 }
 
-static Evas_Objectoicapp_create_bg(Evas_Object *parent)
+static Evas_Object *oicapp_create_bg(Evas_Object *parent)
 {
-       Evas_Object *bg;
+    Evas_Object *bg;
 
-       bg = elm_bg_add(parent);
-       evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_win_resize_object_add(parent, bg);
-       //elm_object_part_content_set(parent, "elm.swallow.bg", bg);
-       evas_object_show(bg);
+    bg = elm_bg_add(parent);
+    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    elm_win_resize_object_add(parent, bg);
+    //elm_object_part_content_set(parent, "elm.swallow.bg", bg);
+    evas_object_show(bg);
 
-       return bg;
+    return bg;
 }
 
-static Evas_Objectoicapp_create_base_layout(Evas_Object *parent)
+static Evas_Object *oicapp_create_base_layout(Evas_Object *parent)
 {
-       Evas_Object *base;
+    Evas_Object *base;
 
-       base = elm_layout_add(parent);
-       elm_layout_theme_set(base, "layout", "application", "default");
-       evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       evas_object_show(base);
+    base = elm_layout_add(parent);
+    elm_layout_theme_set(base, "layout", "application", "default");
+    evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_show(base);
 
-       return base;
+    return base;
 }
 
 void __gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
 {
-       Elm_Object_Item *item = (Elm_Object_Item *)event_info;
-/*
-       list_item = elm_object_item_data_get(item);
-       if (NULL == list_item)
-       {
-               elm_object_item_signal_emit(item, "elm,state,center", "");
-               return;
-       }
-       if (list_item->group_style == OICAPP_GENLIST_GRP_TOP)
-               elm_object_item_signal_emit(item, "elm,state,top", "");
-       else if (list_item->group_style == OICAPP_GENLIST_GRP_CENTER)
-               elm_object_item_signal_emit(item, "elm,state,center", "");
-       else if (list_item->group_style == OICAPP_GENLIST_GRP_BOTTOM)
-               elm_object_item_signal_emit(item, "elm,state,bottom", "");
-       else
-*/
-               elm_object_item_signal_emit(item, "elm,state,normal", "");
+    Elm_Object_Item *item = (Elm_Object_Item *)event_info;
+    /*
+        list_item = elm_object_item_data_get(item);
+        if (NULL == list_item)
+        {
+            elm_object_item_signal_emit(item, "elm,state,center", "");
+            return;
+        }
+        if (list_item->group_style == OICAPP_GENLIST_GRP_TOP)
+            elm_object_item_signal_emit(item, "elm,state,top", "");
+        else if (list_item->group_style == OICAPP_GENLIST_GRP_CENTER)
+            elm_object_item_signal_emit(item, "elm,state,center", "");
+        else if (list_item->group_style == OICAPP_GENLIST_GRP_BOTTOM)
+            elm_object_item_signal_emit(item, "elm,state,bottom", "");
+        else
+    */
+    elm_object_item_signal_emit(item, "elm,state,normal", "");
 }
 
 
-static Evas_Objectoicapp_create_genlist(Evas_Object *parent)
+static Evas_Object *oicapp_create_genlist(Evas_Object *parent)
 {
-       Evas_Object *genlist;
+    Evas_Object *genlist;
 
-       genlist = elm_genlist_add(parent);
-       if (NULL == genlist)
-       {
-               ERR("elm_genlist_add() Fail");
-               return NULL;
-       }
+    genlist = elm_genlist_add(parent);
+    if (NULL == genlist)
+    {
+        ERR("elm_genlist_add() Fail");
+        return NULL;
+    }
 
-       elm_object_style_set(genlist, "dialogue");
-       elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
-       evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       evas_object_show(genlist);
+    elm_object_style_set(genlist, "dialogue");
+    elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
+    evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    evas_object_show(genlist);
 
-       evas_object_smart_callback_add(genlist, "realized", __gl_realized_cb, NULL);
+    evas_object_smart_callback_add(genlist, "realized", __gl_realized_cb, NULL);
 
-       return genlist;
+    return genlist;
 }
 
-static Elm_Object_Item_gl_append_item(oicapp_data *ad, Elm_Genlist_Item_Class *itc)
+static Elm_Object_Item *_gl_append_item(oicapp_data *ad, Elm_Genlist_Item_Class *itc)
 {
-       Elm_Object_Item *item;
+    Elm_Object_Item *item;
 
-       item = elm_genlist_item_append(ad->genlist, itc, ad, NULL,
-                       ELM_GENLIST_ITEM_NONE, NULL, NULL);
+    item = elm_genlist_item_append(ad->genlist, itc, ad, NULL,
+                                   ELM_GENLIST_ITEM_NONE, NULL, NULL);
 
-       elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
+    elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
 
-       return item;
+    return item;
 }
 
 static void oicapp_append_contents(oicapp_data *ad)
 {
-       Elm_Object_Item *item;
+    Elm_Object_Item *item;
 
-       oicapp_append_separator(ad->genlist, ad);
+    oicapp_append_separator(ad->genlist, ad);
 
-       _gl_append_item(ad, &ad->itc_edit);
+    _gl_append_item(ad, &ad->itc_edit);
 
-       oicapp_append_separator(ad->genlist, ad);
+    oicapp_append_separator(ad->genlist, ad);
 
-       _gl_append_item(ad, &ad->itc_btn);
+    _gl_append_item(ad, &ad->itc_btn);
 
-       oicapp_append_separator(ad->genlist, ad);
+    oicapp_append_separator(ad->genlist, ad);
 
-       item = _gl_append_item(ad, &ad->itc_multiline);
-       ad->item_multiline = item;
+    item = _gl_append_item(ad, &ad->itc_multiline);
+    ad->item_multiline = item;
 
-       oicapp_append_separator(ad->genlist, ad);
+    oicapp_append_separator(ad->genlist, ad);
 }
 
-static Evas_Objectoicapp_create_conform(Evas_Object *win)
+static Evas_Object *oicapp_create_conform(Evas_Object *win)
 {
-       Evas_Object *conform = NULL;
-       conform = elm_conformant_add(win);
+    Evas_Object *conform = NULL;
+    conform = elm_conformant_add(win);
 
-       evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-       elm_win_resize_object_add(win, conform);
-       evas_object_show(conform);
+    evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+    elm_win_resize_object_add(win, conform);
+    evas_object_show(conform);
 
-       Evas_Object *bg_indicator = elm_bg_add(conform);
-       elm_object_style_set(bg_indicator, "indicator/headerbg");
-       elm_object_part_content_set(conform, "elm.swallow.indicator_bg", bg_indicator);
-       evas_object_show(bg_indicator);
+    Evas_Object *bg_indicator = elm_bg_add(conform);
+    elm_object_style_set(bg_indicator, "indicator/headerbg");
+    elm_object_part_content_set(conform, "elm.swallow.indicator_bg", bg_indicator);
+    evas_object_show(bg_indicator);
 
-       return conform;
+    return conform;
 }
 
 static Eina_Bool _back_cb(void *data, Elm_Object_Item *item)
 {
-       elm_exit();
+    elm_exit();
 
-       return EINA_FALSE;
+    return EINA_FALSE;
 }
 
-static char_gl_multiline_text_get(void *data, Evas_Object *obj, const char *part)
+static char *_gl_multiline_text_get(void *data, Evas_Object *obj, const char *part)
 {
-       oicapp_data *ad = (oicapp_data *)data;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       if (ad->output_msg)
-               return strdup(ad->output_msg);
-       else
-               return strdup("");
+    if (ad->output_msg)
+        return strdup(ad->output_msg);
+    else
+        return strdup("");
 }
 
 static void _btn_clicked(void *data, Evas_Object *obj, void *event_info)
 {
-       oicapp_data *ad = (oicapp_data *)data;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       std::string cqid;
+    std::string cqid;
 
-       g_SSMClient->registerQuery(std::string(ad->input_msg), g_SSMClientListener, cqid);
+    g_SSMClient->registerQuery(std::string(ad->input_msg), g_SSMClientListener, cqid);
 
-       ERR("button clicked(%s)", ad->input_msg);
+    ERR("button clicked(%s)", ad->input_msg);
 }
 
-static Evas_Object_gl_btn_content_get(void *data, Evas_Object *obj,
-               const char *part)
+static Evas_Object *_gl_btn_content_get(void *data, Evas_Object *obj,
+                                        const char *part)
 {
-       Evas_Object *button;
-       oicapp_data *ad = (oicapp_data *)data;
+    Evas_Object *button;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       button = elm_button_add(obj);
-       //elm_object_style_set(button, "");
-       elm_object_part_text_set(button, NULL, "Send Query");
-       evas_object_propagate_events_set(button, EINA_FALSE);
-       evas_object_smart_callback_add(button, "clicked", _btn_clicked, ad);
+    button = elm_button_add(obj);
+    //elm_object_style_set(button, "");
+    elm_object_part_text_set(button, NULL, "Send Query");
+    evas_object_propagate_events_set(button, EINA_FALSE);
+    evas_object_smart_callback_add(button, "clicked", _btn_clicked, ad);
 
-       return button;
+    return button;
 }
 
 static void _edit_unfocused(void *data, Evas_Object *obj, void *event_info)
 {
-       oicapp_data *ad = (oicapp_data *)data;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       ad->input_msg = strdup(elm_entry_entry_get(obj));
+    ad->input_msg = strdup(elm_entry_entry_get(obj));
 
-//     oicapp_util_put_msg(ad, ad->input_msg);
+//  oicapp_util_put_msg(ad, ad->input_msg);
 
-       DBG("Clicked : %s", ad->input_msg);
+    DBG("Clicked : %s", ad->input_msg);
 
 }
-static Evas_Object_gl_edit_content_get(void *data, Evas_Object *obj,
-               const char *part)
+static Evas_Object *_gl_edit_content_get(void *data, Evas_Object *obj,
+        const char *part)
 {
-       oicapp_data *ad = (oicapp_data *)data;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       Evas_Object *entry = ea_editfield_add(obj, EA_EDITFIELD_MULTILINE);
-       ea_editfield_clear_button_disabled_set(entry, EINA_TRUE);
-       elm_entry_entry_set(entry, ad->input_msg);
-       evas_object_smart_callback_add(entry, "unfocused", _edit_unfocused, ad);
+    Evas_Object *entry = ea_editfield_add(obj, EA_EDITFIELD_MULTILINE);
+    ea_editfield_clear_button_disabled_set(entry, EINA_TRUE);
+    elm_entry_entry_set(entry, ad->input_msg);
+    evas_object_smart_callback_add(entry, "unfocused", _edit_unfocused, ad);
 
-       return entry;
+    return entry;
 }
 
 static inline void oicapp_init_itcs(oicapp_data *ad)
 {
-       ad->itc_seperator.item_style = "dialogue/separator";
-       ad->itc_seperator.func.text_get = NULL;
-       ad->itc_seperator.func.content_get = NULL;
-       ad->itc_seperator.func.state_get = NULL;
-       ad->itc_seperator.func.del = NULL;
-
-       ad->itc_edit.item_style = "dialogue/editfield";
-       ad->itc_edit.func.text_get = NULL;
-       ad->itc_edit.func.content_get = _gl_edit_content_get;
-       ad->itc_edit.func.state_get = NULL;
-       ad->itc_edit.func.del = NULL;
-
-       ad->itc_btn.item_style = "dialogue/1icon";
-       ad->itc_btn.func.text_get = NULL;
-       ad->itc_btn.func.content_get = _gl_btn_content_get;
-       ad->itc_btn.func.state_get = NULL;
-       ad->itc_btn.func.del = NULL;
-
-       ad->itc_multiline.item_style = "multiline/1text";
-       ad->itc_multiline.func.text_get = _gl_multiline_text_get;
-       //ad->itc_multiline.func.text_get = NULL;
-       ad->itc_multiline.func.content_get = NULL;
-       ad->itc_multiline.func.state_get = NULL;
-       ad->itc_multiline.func.del = NULL;
+    ad->itc_seperator.item_style = "dialogue/separator";
+    ad->itc_seperator.func.text_get = NULL;
+    ad->itc_seperator.func.content_get = NULL;
+    ad->itc_seperator.func.state_get = NULL;
+    ad->itc_seperator.func.del = NULL;
+
+    ad->itc_edit.item_style = "dialogue/editfield";
+    ad->itc_edit.func.text_get = NULL;
+    ad->itc_edit.func.content_get = _gl_edit_content_get;
+    ad->itc_edit.func.state_get = NULL;
+    ad->itc_edit.func.del = NULL;
+
+    ad->itc_btn.item_style = "dialogue/1icon";
+    ad->itc_btn.func.text_get = NULL;
+    ad->itc_btn.func.content_get = _gl_btn_content_get;
+    ad->itc_btn.func.state_get = NULL;
+    ad->itc_btn.func.del = NULL;
+
+    ad->itc_multiline.item_style = "multiline/1text";
+    ad->itc_multiline.func.text_get = _gl_multiline_text_get;
+    //ad->itc_multiline.func.text_get = NULL;
+    ad->itc_multiline.func.content_get = NULL;
+    ad->itc_multiline.func.state_get = NULL;
+    ad->itc_multiline.func.del = NULL;
 }
 
 static int oicapp_create(void *data)
 {
-       oicapp_data *ad = (oicapp_data *)data;
-       Elm_Object_Item *it;
+    oicapp_data *ad = (oicapp_data *)data;
+    Elm_Object_Item *it;
 
-       g_ad = (oicapp_data *)data;
+    g_ad = (oicapp_data *)data;
 
-       oicapp_init_itcs(ad);
+    oicapp_init_itcs(ad);
 
-       /* create window */
-       ad->win = oicapp_create_win(PACKAGE);
-       if (NULL == ad->win)
-               return -1;
+    /* create window */
+    ad->win = oicapp_create_win(PACKAGE);
+    if (NULL == ad->win)
+        return -1;
 
-       ad->bg = oicapp_create_bg(ad->win);
-       if (NULL == ad->bg)
-               return -1;
+    ad->bg = oicapp_create_bg(ad->win);
+    if (NULL == ad->bg)
+        return -1;
 
-       ad->conform = oicapp_create_conform(ad->win);
-       if(NULL == ad->conform)
-               return -1;
+    ad->conform = oicapp_create_conform(ad->win);
+    if (NULL == ad->conform)
+        return -1;
 
-       /* create layout */
-       ad->base = oicapp_create_base_layout(ad->conform);
-       if(NULL == ad->base)
-               return -1;
-       elm_object_content_set(ad->conform, ad->base);
+    /* create layout */
+    ad->base = oicapp_create_base_layout(ad->conform);
+    if (NULL == ad->base)
+        return -1;
+    elm_object_content_set(ad->conform, ad->base);
 
-       ad->navi = elm_naviframe_add(ad->base);
-       elm_object_part_content_set(ad->base, "elm.swallow.content", ad->navi);
-       ea_object_event_callback_add(ad->navi, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL);
+    ad->navi = elm_naviframe_add(ad->base);
+    elm_object_part_content_set(ad->base, "elm.swallow.content", ad->navi);
+    ea_object_event_callback_add(ad->navi, EA_CALLBACK_BACK, ea_naviframe_back_cb, NULL);
 
-       ad->genlist = oicapp_create_genlist(ad->navi);
+    ad->genlist = oicapp_create_genlist(ad->navi);
 
-       it = elm_naviframe_item_push(ad->navi, "OIC Tester", NULL, NULL, ad->genlist, NULL);
-       elm_naviframe_item_pop_cb_set(it, _back_cb, ad);
+    it = elm_naviframe_item_push(ad->navi, "OIC Tester", NULL, NULL, ad->genlist, NULL);
+    elm_naviframe_item_pop_cb_set(it, _back_cb, ad);
 
-       ad->ip_addr = oicapp_util_wifi();
-       if (NULL == ad->ip_addr)
-       {
-               ERR("wifi is not connected");
-               oicapp_fail_popup(ad, (char*)"Error", (char*)"No WIFI connection", 3);
-       }
-       else
-       {
-               INFO("IP Address = %s", ad->ip_addr);
-       }
+    ad->ip_addr = oicapp_util_wifi();
+    if (NULL == ad->ip_addr)
+    {
+        ERR("wifi is not connected");
+        oicapp_fail_popup(ad, (char *)"Error", (char *)"No WIFI connection", 3);
+    }
+    else
+    {
+        INFO("IP Address = %s", ad->ip_addr);
+    }
 
-       oicapp_append_contents(ad);
+    oicapp_append_contents(ad);
 
-       g_SSMClient = new SSMClient();
+    g_SSMClient = new SSMClient();
 
-       return 0;
+    return 0;
 }
 
 static int oicapp_terminate(void *data)
 {
-       oicapp_data *ad = (oicapp_data *)data;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       if (ad->win)
-               evas_object_del(ad->win);
+    if (ad->win)
+        evas_object_del(ad->win);
 
-       free(ad->ip_addr);
-       free(ad->output_msg);
-       return 0;
+    free(ad->ip_addr);
+    free(ad->output_msg);
+    return 0;
 }
 
 static int oicapp_pause(void *data)
 {
-       return 0;
+    return 0;
 }
 
 static int oicapp_resume(void *data)
 {
-       /*
-       static int tmpCnt = 0;
-       oicapp_data *ad = (oicapp_data *)data;
-       char buf[1024];
+    /*
+    static int tmpCnt = 0;
+    oicapp_data *ad = (oicapp_data *)data;
+    char buf[1024];
 
-       snprintf(buf, sizeof(buf), "Test %d", tmpCnt++);
+    snprintf(buf, sizeof(buf), "Test %d", tmpCnt++);
 
-       oicapp_util_put_msg(ad, buf);
-       */
-       return 0;
+    oicapp_util_put_msg(ad, buf);
+    */
+    return 0;
 }
 
 static int oicapp_reset(bundle *b, void *data)
 {
-       oicapp_data *ad = (oicapp_data *)data;
+    oicapp_data *ad = (oicapp_data *)data;
 
-       if (ad->win)
-               elm_win_activate(ad->win);
+    if (ad->win)
+        elm_win_activate(ad->win);
 
-       return 0;
+    return 0;
 }
 
 int main(int argc, char *argv[])
 {
-       oicapp_data ad;
+    oicapp_data ad;
 
-       /*
-       struct appcore_ops ops = {
-               .create = oicapp_create,
-               .terminate = oicapp_terminate,
-               .pause = oicapp_pause,
-               .resume = oicapp_resume,
-               .reset = oicapp_reset,
-       };*/
+    /*
+    struct appcore_ops ops = {
+        .create = oicapp_create,
+        .terminate = oicapp_terminate,
+        .pause = oicapp_pause,
+        .resume = oicapp_resume,
+        .reset = oicapp_reset,
+    };*/
 
-       appcore_ops ops;
+    appcore_ops ops;
 
-       ops.create = oicapp_create;
-       ops.terminate = oicapp_terminate;
-       ops.pause = oicapp_pause;
-       ops.resume = oicapp_resume;
-       ops.reset = oicapp_reset;
+    ops.create = oicapp_create;
+    ops.terminate = oicapp_terminate;
+    ops.pause = oicapp_pause;
+    ops.resume = oicapp_resume;
+    ops.reset = oicapp_reset;
 
-       memset(&ad, 0x0, sizeof(oicapp_data));
-       ops.data = &ad;
+    memset(&ad, 0x0, sizeof(oicapp_data));
+    ops.data = &ad;
 
-       return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+    return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
 }
 
index 0d6795e..839d164 100644 (file)
@@ -35,47 +35,49 @@ extern "C"
 
 #define GRP_MAIN "main"
 
-       typedef enum {
-               OICAPP_MODE_NONE = 0,
-               OICAPP_MODE_CLIENT,
-               OICAPP_MODE_SERVER,
-               OICAPP_MODE_MAX
-       }oicapp_mode;
-
-       enum {
-               OICAPP_GENLIST_GRP_NONE = 0,
-               OICAPP_GENLIST_GRP_TOP,
-               OICAPP_GENLIST_GRP_CENTER,
-               OICAPP_GENLIST_GRP_BOTTOM
-       };
-
-
-       typedef struct
-       {
-               Evas_Object *win;
-               Evas_Object *base;
-               Evas_Object *bg;
-               Evas_Object *navi;
-               Evas_Object *genlist;
-               Evas_Object *popup;
-               Evas_Object *conform;
-
-               Elm_Object_Item *item_multiline;
-               Elm_Object_Item *item_client_pwr;
-               Elm_Object_Item *item_client_lev;
-               Elm_Object_Item *item_server;
-               Elm_Object_Item *item_server_pwr;
-               Elm_Object_Item *item_server_lev;
-
-               Elm_Genlist_Item_Class itc_seperator;
-               Elm_Genlist_Item_Class itc_edit;
-               Elm_Genlist_Item_Class itc_btn;
-               Elm_Genlist_Item_Class itc_multiline;
-
-               char *ip_addr;
-               char *input_msg;
-               char *output_msg;
-       }oicapp_data;
+typedef enum
+{
+    OICAPP_MODE_NONE = 0,
+    OICAPP_MODE_CLIENT,
+    OICAPP_MODE_SERVER,
+    OICAPP_MODE_MAX
+} oicapp_mode;
+
+enum
+{
+    OICAPP_GENLIST_GRP_NONE = 0,
+    OICAPP_GENLIST_GRP_TOP,
+    OICAPP_GENLIST_GRP_CENTER,
+    OICAPP_GENLIST_GRP_BOTTOM
+};
+
+
+typedef struct
+{
+    Evas_Object *win;
+    Evas_Object *base;
+    Evas_Object *bg;
+    Evas_Object *navi;
+    Evas_Object *genlist;
+    Evas_Object *popup;
+    Evas_Object *conform;
+
+    Elm_Object_Item *item_multiline;
+    Elm_Object_Item *item_client_pwr;
+    Elm_Object_Item *item_client_lev;
+    Elm_Object_Item *item_server;
+    Elm_Object_Item *item_server_pwr;
+    Elm_Object_Item *item_server_lev;
+
+    Elm_Genlist_Item_Class itc_seperator;
+    Elm_Genlist_Item_Class itc_edit;
+    Elm_Genlist_Item_Class itc_btn;
+    Elm_Genlist_Item_Class itc_multiline;
+
+    char *ip_addr;
+    char *input_msg;
+    char *output_msg;
+} oicapp_data;
 #ifdef __cplusplus
 }
 #endif
index 06d0cc9..c92f77f 100644 (file)
@@ -20,7 +20,7 @@ extern "C"
 
 void oicapp_fail_popup(oicapp_data *ad, char *title, char *text, int timeout);
 void oicapp_util_put_msg(oicapp_data *ad, const char *msg);
-charoicapp_util_wifi();
+char *oicapp_util_wifi();
 
 /*
 int oicapp_client_start(oicapp_data *ad);
index bab7d39..a0145f2 100644 (file)
@@ -36,7 +36,7 @@
 extern "C"
 {
 #endif
-    void _EXPORT_ InitializeContext(ICtxDelegate *pDelegate);
+void _EXPORT_ InitializeContext(ICtxDelegate *pDelegate);
 #ifdef __cplusplus
 
 }
@@ -45,13 +45,13 @@ extern "C"
 
 namespace DiscomfortIndexSensorName
 {
-#define PHYSICAL_EA    2
+#define PHYSICAL_EA 2
 
     typedef struct _physicalInput_
     {
-        charm_thingName;
+        char *m_thingName;
         int m_inputNum;
-        voidm_pInputStruct;
+        void *m_pInputStruct;
     } physicalInput;
 
     typedef enum
@@ -61,34 +61,34 @@ namespace DiscomfortIndexSensorName
 
     class DiscomfortIndexSensor: public ICtxEvent
     {
-    private:
+        private:
 
-        static physicalInput s_PHYSICAL_SOFTSENSORs[PHYSICAL_EA];
+            static physicalInput s_PHYSICAL_SOFTSENSORs[PHYSICAL_EA];
 
-        class InValue
-        {
-        public:
-            std::string m_timestamp; // .
-            std::string m_discomfortIndex; // Discomfort Index. ( 2 ~ 5 )
-            std::string m_humidity; // relative humidity.
-            std::string m_temperature; // celsius temperature.
-        };
+            class InValue
+            {
+                public:
+                    std::string m_timestamp; // .
+                    std::string m_discomfortIndex; // Discomfort Index. ( 2 ~ 5 )
+                    std::string m_humidity; // relative humidity.
+                    std::string m_temperature; // celsius temperature.
+            };
 
-        InValue m_DI[PHYSICAL_EA];
-        InValue m_result;
+            InValue m_DI[PHYSICAL_EA];
+            InValue m_result;
 
-        int runLogic(std::vector< ContextData > &contextDataList);
+            int runLogic(std::vector< ContextData > &contextDataList);
 
-    public:
-        DiscomfortIndexSensor();
+        public:
+            DiscomfortIndexSensor();
 
-        void onCtxEvent(enum CTX_EVENT_TYPE eventType, std::vector< ContextData > contextDataList);
+            void onCtxEvent(enum CTX_EVENT_TYPE eventType, std::vector< ContextData > contextDataList);
 
-        DIResult getInput(std::vector< ContextData > &contextDataList, InValue* data);
-        DIResult makeDiscomfortIndex(InValue* data);
-        ContextData setOutput(int property_count, InValue* data);
+            DIResult getInput(std::vector< ContextData > &contextDataList, InValue *data);
+            DIResult makeDiscomfortIndex(InValue *data);
+            ContextData setOutput(int property_count, InValue *data);
 
-        friend void _EXPORT_ initializeContext(ICtxDelegate *pDelegate);
+            friend void _EXPORT_ initializeContext(ICtxDelegate *pDelegate);
     };
 }
 ;
index 12a3000..496d4a4 100644 (file)
@@ -29,9 +29,9 @@
 #include <string>
 class SysTimer
 {
-public:
-       static std::string MilliSecondAsString();
-       static std::string UTCSecondAsString();
+    public:
+        static std::string MilliSecondAsString();
+        static std::string UTCSecondAsString();
 };
 
 #endif /* SYSTIMER_H_ */
index 2df02ef..aebbf9b 100644 (file)
@@ -34,13 +34,13 @@ using namespace DiscomfortIndexSensorName;
 
 #define SENSOR_NAME "DiscomfortIndexSensor"
 
-charinputName[2] =
-{ (char*)"temperature", (char*)"humidity" };
+char *inputName[2] =
+{ (char *)"temperature", (char *)"humidity" };
 
 physicalInput DiscomfortIndexSensor::s_PHYSICAL_SOFTSENSORs[PHYSICAL_EA] =
 {
-       { (char*)"Thing_TempHumSensor", 2, (void*)&inputName },
-       { (char*)"Thing_TempHumSensor1", 2, (void*)&inputName } 
+    { (char *)"Thing_TempHumSensor", 2, (void *) &inputName },
+    { (char *)"Thing_TempHumSensor1", 2, (void *) &inputName }
 };
 
 ICtxDelegate *g_pDelegate;
@@ -49,7 +49,7 @@ void InitializeContext(ICtxDelegate *pDelegate)
 {
     std::vector < ContextData > contextData;
 
-    DiscomfortIndexSensoreventCls = new DiscomfortIndexSensor();
+    DiscomfortIndexSensor *eventCls = new DiscomfortIndexSensor();
     pDelegate->registerCallback(eventCls);
     g_pDelegate = pDelegate;
 
@@ -67,7 +67,7 @@ DiscomfortIndexSensor::DiscomfortIndexSensor()
 }
 
 void DiscomfortIndexSensor::onCtxEvent(enum CTX_EVENT_TYPE eventType,
-        std::vector< ContextData > contextDataList)
+                                       std::vector< ContextData > contextDataList)
 {
     switch (eventType)
     {
@@ -83,7 +83,7 @@ void DiscomfortIndexSensor::onCtxEvent(enum CTX_EVENT_TYPE eventType,
 int DiscomfortIndexSensor::runLogic(std::vector< ContextData > &contextDataList)
 {
     std::cout << "[DiscomfortIndexSensor] DiscomfortIndexSensor::" << __func__ << " is called."
-            << std::endl;
+              << std::endl;
 
     DIResult result;
 
@@ -110,7 +110,7 @@ int DiscomfortIndexSensor::runLogic(std::vector< ContextData > &contextDataList)
 /**
  * Get Input data (temperature, humidity) using resource Client of Iotivity base.
  */
-DIResult DiscomfortIndexSensor::getInput(std::vector< ContextData > &contextDataList, InValuedata)
+DIResult DiscomfortIndexSensor::getInput(std::vector< ContextData > &contextDataList, InValue *data)
 {
     int result_flag = 0;
     int contextSize = 0;
@@ -128,9 +128,9 @@ DIResult DiscomfortIndexSensor::getInput(std::vector< ContextData > &contextData
             if (contextDataList[i].rootName == s_PHYSICAL_SOFTSENSORs[k].m_thingName)
             {
                 std::vector < std::map< std::string, std::string > > lVector =
-                        contextDataList[i].outputProperty;
+                    contextDataList[i].outputProperty;
                 int requiredInputNum = s_PHYSICAL_SOFTSENSORs[k].m_inputNum;
-                char** pchar = (char**) (s_PHYSICAL_SOFTSENSORs[k].m_pInputStruct);
+                char **pchar = (char **) (s_PHYSICAL_SOFTSENSORs[k].m_pInputStruct);
                 if (requiredInputNum == 0)
                 {
                     std::cout << "No input List." << std::endl;
@@ -175,7 +175,7 @@ DIResult DiscomfortIndexSensor::getInput(std::vector< ContextData > &contextData
 /**
  * Calculation of DiscomfortIndex with TEMP&HUMI of InValue.
  */
-DIResult DiscomfortIndexSensor::makeDiscomfortIndex(InValuedata)
+DIResult DiscomfortIndexSensor::makeDiscomfortIndex(InValue *data)
 {
     int discomfortIndex = (int) ERROR;
     double sumDI = 0.0;
@@ -198,7 +198,7 @@ DIResult DiscomfortIndexSensor::makeDiscomfortIndex(InValue* data)
         dI = F - (F - 58.0) * (double) ((100 - h) * 55) / 10000.0;
 
         std::cout << "Discomfort level : " << dI << ", Temperature :" << t << ", Humidity :" << h
-                << std::endl;
+                  << std::endl;
 
         (data + i)->m_discomfortIndex = std::to_string(0);
         m_result.m_temperature += std::to_string(t) + ", ";
@@ -212,25 +212,25 @@ DIResult DiscomfortIndexSensor::makeDiscomfortIndex(InValue* data)
     {
         discomfortIndex = (int) ALL_DISCOMPORT;
         std::cout << "DI : " << discomfortIndex << " : All person discomfort. : " << sumDI
-                << std::endl;
+                  << std::endl;
     }
     else if (sumDI >= 75.0)
     {
         discomfortIndex = (int) HALF_DISCOMPORT;
         std::cout << "DI : " << discomfortIndex << " : Half of person discomfort. : " << sumDI
-                << std::endl;
+                  << std::endl;
     }
     else if (sumDI >= 68.0)
     {
         discomfortIndex = (int) LITTLE_DISCOMPORT;
         std::cout << "DI : " << discomfortIndex << " : A little person discomfort. : " << sumDI
-                << std::endl;
+                  << std::endl;
     }
     else
     {
         discomfortIndex = (int) ALL_COMPORT;
         std::cout << "DI : " << discomfortIndex << " : All person comfort. : " << sumDI
-                << std::endl;
+                  << std::endl;
     }
 
     m_result.m_discomfortIndex = std::to_string(discomfortIndex);
@@ -239,7 +239,7 @@ DIResult DiscomfortIndexSensor::makeDiscomfortIndex(InValue* data)
     return SUCCESS;
 }
 
-ContextData DiscomfortIndexSensor::setOutput(int property_count, InValuedata)
+ContextData DiscomfortIndexSensor::setOutput(int property_count, InValue *data)
 {
     ContextData out;
 
index 1daa652..032e0fc 100644 (file)
 #include <stdint.h>
 std::string SysTimer::MilliSecondAsString()
 {
-       std::stringstream ss;
-       struct timeval tv;
+    std::stringstream ss;
+    struct timeval tv;
 
-       gettimeofday(&tv, NULL);
-       long long val = tv.tv_sec * (long long) 1000 + tv.tv_usec / 1000;
+    gettimeofday(&tv, NULL);
+    long long val = tv.tv_sec * (long long) 1000 + tv.tv_usec / 1000;
 
-       ss << val;
-       std::string strTime = ss.str();
+    ss << val;
+    std::string strTime = ss.str();
 
-       return strTime;
+    return strTime;
 }
 
 std::string SysTimer::UTCSecondAsString()
 {
-       std::stringstream ss;
-       struct timeval tv;
+    std::stringstream ss;
+    struct timeval tv;
 
-       gettimeofday(&tv, NULL);
-       unsigned long val = tv.tv_sec;
+    gettimeofday(&tv, NULL);
+    unsigned long val = tv.tv_sec;
 
-       ss << val;
-       std::string strTime = ss.str();
+    ss << val;
+    std::string strTime = ss.str();
 
-       return strTime;
+    return strTime;
 }