TARGET=${SSM_LIB}
CXX=g++
-CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX
+CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX -DNDEBUG
CXX_INC=-I../../ -I${INC_PATH}/ -I${FD_SSMCORE}/include -I${FD_SSMCORE}/src -I${BOOST}
CXX_LIB=
# C++ type Compile Flag define.
CXX=g++
-CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX -ldl
+CXX_FLAGS=-std=c++0x -Wall -pthread -DLINUX -ldl -DNDEBUG
CXX_INC=-I${INC_PATH}/ -I${SRC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_LOG_DIR}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST}
CXX_LIB=-L""
# C type Compile Flag define.
GCC=gcc
-GCC_FLAGS=-Wall -pthread -DLINUX -ldl
+GCC_FLAGS=-Wall -pthread -DLINUX -ldl -DNDEBUG
GCC_INC=-I../../ -I${INC_PATH}/ -I${IOT_BASE}/include/ -I${IOT_BASE}/csdk/stack/include -I${IOT_BASE}/csdk/ocsocket/include -I${IOT_BASE}/csdk/ocrandom/include -I${IOT_BASE}/csdk/logger/include -I${BOOST} -I${SRC_PATH} -I${SRC_PATH}/Common -I${SRC_PATH}/QueryProcessor -I${SRC_PATH}/SensorProcessor -I${SRC_PATH}/SSMInterface
GCC_SRCPATH=${wildcard ${SRC_PATH}/**/*.c}
#elif defined(TIZEN)
#define REPORT_MESSAGE(tag, msg) printf("[%s] %s\n", tag, msg)
-#define PRINT_LOG(strError) printf("[SSM] %s:%d %s\n", __FUNCTION__, __LINE__, strError)
+#define PRINT_LOG(strError) printf("[SSM] %s:%d %s\n", __PRETTY_FUNCTION__, __LINE__, strError)
#else //Default linux
#define REPORT_MESSAGE(tag, msg) printf("[%s] %s\n", tag, msg)
-#define PRINT_LOG(strError) printf("[SSM] %s:%d %s\n", __FUNCTION__, __LINE__, strError)
+#define PRINT_LOG(strError) printf("[SSM] %s:%d %s\n", __PRETTY_FUNCTION__, __LINE__, strError)
#endif
return tokens_temp;
}
-void CCQLParser::parse(IN std::string input, OUT Token *root)
+bool 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;
+ bool isCondition = false;
for (unsigned int i = 0 ; i < tokens.size() ; i++)
{
i++;
//temp1 = temp;
flag = false;
+ isCondition = true;
}
else
{
if (tokens.at(i) == "if")
{
flag = false;
+ isCondition = true;
}
else
{
}
}
+ SORT lastType = Command;
while (1)
{
//int count = 0;
if (value_flag == true)
{
value_flag = false;
+ lastType = Context;
i++;
}
else
{
temp1.type = Context;
- }
+ //if current context token is reserved keyword, that return error
+ if (tolower(tokens.at(i)) == "get" || tolower(tokens.at(i)) == "subscribe")
+ {
+ return false;
+ }
+ }
if (flag == true)
{
temp1.type = And_or;
flag = false;
}
- split(tokens.at(i), &temp1, flag );//false -> Property
- temp.child_token.push_back(temp1);
+
+ if (split(tokens.at(i), &temp1, flag ) != true) //false -> Property
+ {
+ return false;
+ }
}
else
{
- split(tokens.at(i), &temp1, flag , tokens.at(i + 1), tokens.at(i + 2)); //false -> Property
+ //token count not matched, return and let grammer checker detects
+ if (tokens.size() < i + 3)
+ {
+ return false;
+ }
+
+ if (split(tokens.at(i), &temp1, flag , tokens.at(i + 1),
+ tokens.at(i + 2)) != true) //false -> Property
+ {
+ return false;
+ }
flag = true;
- temp.child_token.push_back(temp1);
}
+ if (isCondition && lastType == temp1.type)
+ {
+ return false;
+ }
+
+ lastType = temp1.type;
+
+ temp.child_token.push_back(temp1);
}
root->child_token.push_back(temp);
}
}
+
+ return true;
}
std::string CCQLParser::tolower(IN std::string str)
pos = str.find_first_of(delimiters, lastPos);
}
+ if (tokens.size() == 0)
+ tokens.push_back("\"\"");
+
return tokens;
}
}
}
-void CCQLParser::split(IN std::string input, IN Token *root, bool flag, IN std::string arg1,
+bool 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, ".");
//root->child_token.push_back(temp1);
}
- else if (check_number(arg2))
+ else
{
//temp1->number = atof(arg2.c_str());
{
property.propertyType = ModelProperty::TYPE_REAL;
}
+ else
+ {
+ //unknown type raise error
+ return false;
+ }
property.propertyValue = arg2;
temp_token->model_property = property;
temp_token->child_token.push_back(temp1);
temp_token = &(temp_token->child_token.back());
}
-
}
}
+
+ return true;
}
int CCQLParser::check_number(IN std::string &str)
{
- //int flag = 0; // 0 text /1 integer /2 real
+ int flag = 0; // 0 text /1 integer /2 real
+ int dotCount = 0;
- int flag = 0;
- for (unsigned int i = 0 ; i < str.size(); i++)
+ std::string::const_iterator it = str.begin();
+ while (it != str.end())
{
- if (str[i] == '.')
- {
- flag++;
- }
- else if (isdigit(str[i]))
+ if (*it == '.')
{
-
+ dotCount++;
}
- else
+ else if (isdigit(*it) == false)
{
- return TYPETEXT;
+ //this is text
+ dotCount = 2;
+ break;
}
- }
- if (flag == 1)
- {
- return TYPEREAL;
+ ++it;
}
- else if (flag > 1)
+
+ if (dotCount == 0)
{
- return TYPETEXT;
+ flag = 1;
}
- else
+ else if (dotCount == 1)
{
- return TYPEINTEGER;
+ flag = 2;
}
+
+ return flag;
}
std::string CCQLParser::check_Predicate(IN std::string input)
*
* @param [in] std::string input - Entered ContetxQuery
* @param [out] Token* root - parsed result
- * @return none
+ * @return bool
* @warning
* @exception
* @see
*/
- void parse(IN std::string input, OUT Token *root);
+ bool parse(IN std::string input, OUT Token *root);
/**
* @fn tolower
* @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
+ * @return bool
* @warning
* @exception
* @see
*/
- void split(IN std::string input, IN Token *root, IN bool flag, IN std::string arg1 = "",
+ bool split(IN std::string input, IN Token *root, IN bool flag, IN std::string arg1 = "",
IN std::string arg2 = "");
/**
if (hasAllConditionedModels() == true && m_reservedForActivate)
{
+ m_reservedForActivate = false;
SSM_CLEANUP_ASSERT(activateTriggers(m_userTriggerId));
}
SAFE_RELEASE(pBaseContextModel);
}
+ if (m_reservedForActivate == true)
+ {
+ res = SSM_S_OK;
+ }
+
CLEANUP:
SAFE_RELEASE(pBaseContextModel);
return res;
}
+ unsigned int cnt = 0;
+
while (true)
{
- unsigned int cnt = 0;
if ((unsigned int)cnt > min_cnt - 1)
{
break;
{
int k = m_root.child_token.at(0).child_token.size();
+ IContextModel *pContextModel = NULL;
+ int pModel = 0;
+
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);
+ if (m_pPropagationEngine->getContextModel(search_last_modelName(temp),
+ &pContextModel) == SSM_S_OK)
+ {
+ pModel = pContextModel->getModelId();
+ vector_int->push_back(pModel);
+ }
+ SAFE_RELEASE(pContextModel);
}
}
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
}
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
i++;
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
i++;
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
switch (itor->modelProperty.propertyType)
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
if (itor < pModelConditions->end() - 1)
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
switch (itor->modelProperty.propertyType)
break;
default:
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
if (itor < pModelConditions->end() - 1)
}
m_contextQueries[userTriggerId]->check_result_model();
- m_contextQueries[userTriggerId]->return_modelID(&modelID);
-
-
m_contextQueries[userTriggerId]->return_contextName(&contextName);
+ m_contextQueries[userTriggerId]->return_modelID(&modelID);
for (unsigned int i = 0; i < modelID.size(); i++)
{
CCQLParser cqlParser;
IContextModel::ActivationType queryCommandType;
- cqlParser.parse(contextQuery, &token);
+ if (!cqlParser.parse(contextQuery, &token))
+ {
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
+ }
if (!cqlParser.check_grammer(&token))
{
- res = SSM_E_FAIL;
- goto CLEANUP;
+ SSM_CLEANUP_ASSERT(SSM_E_FAIL);
}
clsContextQuery = new CContextQuery();
SSM_CLEANUP_ASSERT(m_pContextRepository->registerResourceFinderEvent(this));
- SSM_CLEANUP_ASSERT(m_pContextRepository->startResourceFinder());
-
CLEANUP:
return res;
}
runLogic(inputData, softSensorName);
}
}
- else //This data is primitive
+ else if (m_registeredResources.find(type) != m_registeredResources.end()) //This data is primitive
{
- //TODO: Temporally added for primitive data testing
addOutput(ctxData);
}
{
std::vector<ISSMResource *> baseList;
+ //////////
+ ///TODO: Need to clean up m_mapResourceLookup list
+ //////////
+
//This is primitive sensor
if (pSSMResource->inputList.size() == 0)
{
m_ctxEventList[softSensor]->onCtxEvent(SPF_START, inputData);
}
m_mtxLibraryIO.unlock();
-}
\ No newline at end of file
+}
if (pathSoftSensors.length() == 0)
{
- SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensors));
+ SSM_CLEANUP_ASSERT(getCurrentPath(&m_pathSoftSensors));
m_pathSoftSensors.append("/");
}
else
if (pathDescription.length() == 0)
{
- SSM_CLEANUP_ASSERT(GetCurrentPath(&m_pathSoftSensorsDescription));
+ SSM_CLEANUP_ASSERT(getCurrentPath(&m_pathSoftSensorsDescription));
m_pathSoftSensorsDescription.append("/");
m_pathSoftSensorsDescription.append(DEFAULT_PATH_SOFT_SENSORS);
}
return res;
}
-SSMRESULT CContextRepository::GetCurrentPath(std::string *path)
+SSMRESULT CContextRepository::getCurrentPath(std::string *path)
{
char buffer[2048];
SSMRESULT res = SSM_E_FAIL;
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 getCurrentPath(OUT std::string *path);
};
#endif
\ No newline at end of file
*ppObject = pBase;
return SSM_S_OK;
}
+ else if (IsEqualOID(objectID, OID_IContextRepository))
+ {
+ IBase *pBase = this;
+ pBase->addRef();
+ *ppObject = m_pContextRepository;
+ return SSM_S_OK;
+ }
return SSM_E_NOINTERFACE;
}
TARGET=SSMTesterApp
CXX=g++
-CXX_FLAGS=-std=c++0x -Wall -DLINUX
+CXX_FLAGS=-std=c++0x -Wall -DLINUX -DNDEBUG
CXX_INC=-I${SRC_PATH}/ -I${INC_PATH}/ -I${OUTPUTS_DIR} -I${BOOST}