diff options
Diffstat (limited to 'src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine')
7 files changed, 2371 insertions, 0 deletions
diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/LipiEngineModule.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/LipiEngineModule.cpp new file mode 100644 index 00000000..f5a69788 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/LipiEngineModule.cpp @@ -0,0 +1,1371 @@ +/****************************************************************************** +* Copyright (c) 2006 Hewlett-Packard Development Company, L.P. +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE +*******************************************************************************/ + +/****************************************************************************** + * SVN MACROS + * + * $LastChangedDate: 2011-02-08 11:00:11 +0530 (Tue, 08 Feb 2011) $ + * $Revision: 832 $ + * $Author: dineshm $ + * + ************************************************************************/ +/************************************************************************ + * FILE DESCR: Implementation for PCA Shape Recognition module + * + * CONTENTS: + * initializeLipiEngine + * createShapeRecognizer + * createWordRecognizer + * deleteShapeRecognizer + * deleteWordRecognizer + * createRecognitionContext + * deleteRecognitionContext + * getcurrentversion + * getLipiRootPath + * mapShapeAlgoModuleFunctions + * mapWordAlgoModuleFunctions + * resolveLogicalNameToProjectProfile + * + * AUTHOR: Thanigai Murugan K + * + * DATE: July 29, 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#include "LipiEngineModule.h" +#include "LTKConfigFileReader.h" +#include "LTKStringUtil.h" +#include "lipiengine.h" +#include "LTKException.h" +#include "LTKOSUtilFactory.h" +#include "LTKOSUtil.h" +#include "LTKLoggerUtil.h" + +extern int unloadAllModules(); +extern int deleteModule(void* RecoHandle); +extern void addModule(void* RecoHandle, void* handle); + +LTKLipiEngineModule* LTKLipiEngineModule::lipiEngineModuleInstance= NULL; + +/****************************************************************************** +* AUTHOR : Nidhi +* DATE : 06-Dec-2006 +* NAME : LTKLipiEngineModule +* DESCRIPTION : constructor +* ARGUMENTS : None +* RETURNS : None +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +LTKLipiEngineModule::LTKLipiEngineModule(): +m_LipiEngineConfigEntries(NULL), +m_logFileName(DEFAULT_LOG_FILE), +m_logLevel(DEFAULT_LOG_LEVEL), +m_OSUtilPtr(LTKOSUtilFactory::getInstance()) +{ +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : ~LTKLipiEngineModule +* DESCRIPTION : Destructor +* ARGUMENTS : None +* RETURNS : None +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +LTKLipiEngineModule::~LTKLipiEngineModule() +{ + delete m_LipiEngineConfigEntries; + delete m_OSUtilPtr; + + LTKLoggerUtil::destroyLogger(); +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : initializeLipiEngine +* DESCRIPTION : Reads the lipiengine.cfg and store the AVP map into +* the map variable "m_LipiEngineConfigEntries" +* ARGUMENTS : +* RETURNS : 0 on success other values error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::initializeLipiEngine() +{ + //Log messages after call to configureLogger() + + string temp; + int errorCode; + + if(m_strLipiRootPath == "") + { + LTKReturnError(ELIPI_ROOT_PATH_NOT_SET); // PATH not set + } + if(m_strLipiLibPath == "") + { + m_strLipiLibPath = m_strLipiRootPath + SEPARATOR + "lib"; + } + + temp = m_strLipiRootPath + SEPARATOR + "projects" + SEPARATOR + + LIPIENGINE_CFG_STRING; + + //Read the logical name mapping file from lipiengine.cfg file; + try + { + m_LipiEngineConfigEntries = new LTKConfigFileReader(temp); + + } + catch(LTKException e) + { + // display warning to the user and continue with default values + cout << " Could not open file : " << temp << endl << + "proceeding with defaults" << endl; + } + + errorCode = configureLogger(); // Configure the logger + + if(errorCode !=SUCCESS) + { + LTKReturnError(errorCode); + } + else + { + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "LTKLipiEngineModule::initializeLipiEngine()"<<endl; + } + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Nidhi sharma +* DATE : 11-Jan-2007 +* NAME : LTKLipiEngineModule::getInstance +* DESCRIPTION : Returns a pointer to the LTKLipiEngineModule instance +* ARGUMENTS : +* RETURNS : Address of the LTKLipiEngineModule instance. +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* +******************************************************************************/ +LTKLipiEngineModule* LTKLipiEngineModule::getInstance() +{ + if(lipiEngineModuleInstance == NULL) + { + lipiEngineModuleInstance = new LTKLipiEngineModule(); + } + + return lipiEngineModuleInstance; +} + +/****************************************************************************** +* AUTHOR : Nidhi sharma +* DATE : 02-Jul-2008 +* NAME : destroyLipiEngineInstance +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* +******************************************************************************/ +void LTKLipiEngineModule::destroyLipiEngineInstance() +{ + if(lipiEngineModuleInstance != NULL) + { + delete lipiEngineModuleInstance; + lipiEngineModuleInstance = NULL; + } +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : createShapeRecognizer +* DESCRIPTION : create an instance of shape recognizer object and call +* initialize function. Also loads the model data. +* ARGUMENTS : strProjectName - project name; strProfileName - profile name +* outShapeRecognizerPtr - return shape recognizer object +* RETURNS : if success returns 0 or if fails returns error code +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::createShapeRecognizer(const string& strProjName, + const string& strProfName, + LTKShapeRecognizer** outShapeRecoObj) +{ + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + int errorCode; + int iResult = 0; + void *dllHandler = NULL; + string recognizerName = ""; + string strProjectName = strProjName; + string strProfileName = strProfName; + + //Validating Project names and profile names + errorCode = validateProjectAndProfileNames(strProjectName, strProfileName, + "SHAPEREC", recognizerName); + if (errorCode != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + // Load the dlaal of the shape recognizer + errorCode = loadRecognizerDLL(recognizerName, &dllHandler); + + if( errorCode!= SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + // Map Algo DLL functions... + errorCode = mapShapeAlgoModuleFunctions(dllHandler); + + if( errorCode!= SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + // Create control Info object + char currentVersion[VERSION_STR_LEN]; + int iMajor, iMinor, iBugfix; + + getToolkitVersion(iMajor, iMinor, iBugfix); + sprintf(currentVersion, "%d.%d.%d", iMajor, iMinor, iBugfix); + + LTKControlInfo controlInfo; + controlInfo.lipiRoot = m_strLipiRootPath; + controlInfo.lipiLib = m_strLipiLibPath; + controlInfo.projectName = strProjectName; + controlInfo.profileName = strProfileName; + controlInfo.toolkitVersion = currentVersion; + + // Call recognition module's createShapeRecognizer(); + errorCode = module_createShapeRecognizer(controlInfo,outShapeRecoObj); + + if(errorCode !=SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(ECREATE_SHAPEREC) << " "<< recognizerName << + "LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + m_OSUtilPtr->unloadSharedLib(dllHandler); + + LTKReturnError(ECREATE_SHAPEREC); + } + + addModule(*outShapeRecoObj, dllHandler); + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + return SUCCESS; + +} +/****************************************************************************** +* AUTHOR : Balaji MNA +* DATE : 14-JUN-2009 +* NAME : createShapeRecognizer +* DESCRIPTION : resolves logical project name and call createWordRecognizer +* function. +* ARGUMENTS : strLogicalProjectName - logical project name; +* outShapeRecognizerPtr - return shape recognizer object +* RETURNS : if success returns 0 or if fails returns error code +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::createShapeRecognizer(string &strLogicalProjectName, LTKShapeRecognizer** outShapeRecognizerPtr) +{ + int errorCode; + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + if(strLogicalProjectName.empty()) + { + return EINVALID_PROJECT_NAME; + } + + string strProjectName = ""; + string strProfileName = ""; + + // Resolve the logical name into project name and profile name + errorCode = resolveLogicalNameToProjectProfile(strLogicalProjectName, + strProjectName, + strProfileName); + + if(errorCode !=SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + errorCode = createShapeRecognizer(strProjectName,strProfileName,outShapeRecognizerPtr); + + if(errorCode !=SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::createShapeRecognizer()"<<endl; + + return SUCCESS; + +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : createWordRecognizer +* DESCRIPTION : create an instance of word recognizer object and call initialize +* function. Also loads the model data. +* ARGUMENTS : strProjectName - project name; strProfileName - profile name +* outShapeRecognizerPtr - return shape recognizer object +* RETURNS : if success returns 0 or if fails returns error code +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::createWordRecognizer(const string& strProjName, + const string& strProfName, + LTKWordRecognizer** outWordRecoObj) +{ + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::createWordRecognizer()"<<endl; + + string recognizerName = ""; + int iResult = 0; + void *dllHandler = NULL; + string strProjectName = strProjName; + string strProfileName = strProfName; + + int errorCode; + + errorCode = validateProjectAndProfileNames(strProjectName,strProfileName, + "WORDREC", recognizerName); + if (errorCode != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createWordRecognizer()"<<endl; + + + LTKReturnError(errorCode); + } + + // Load the dll of the word recognizer + + errorCode = loadRecognizerDLL(recognizerName, &dllHandler); + + if( errorCode!= SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createWordRecognizer()"<<endl; + + + LTKReturnError(errorCode); + } + + // Get version information + char currentVersion[VERSION_STR_LEN]; + int iMajor, iMinor, iBugFix; + getToolkitVersion(iMajor, iMinor, iBugFix); + sprintf(currentVersion, "%d.%d.%d", iMajor, iMinor, iBugFix); + + // Create controlInfo object + LTKControlInfo controlInfo; + + controlInfo.lipiRoot = m_strLipiRootPath; + controlInfo.lipiLib = m_strLipiLibPath; + controlInfo.projectName = strProjectName; + controlInfo.profileName = strProfileName; + controlInfo.toolkitVersion = currentVersion; + + // Map Algo DLL functions... + errorCode = mapWordAlgoModuleFunctions(dllHandler); + if(errorCode!= SUCCESS) + { + // Unable to map the functions + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createWordRecognizer()"<<endl; + + + LTKReturnError(errorCode); + } + + // Call recognition module's createWordRecognizer(); + errorCode = module_createWordRecognizer(controlInfo,outWordRecoObj ); + if(errorCode != SUCCESS) + { + /* Error, unable to create word recognizer instance */ + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(ECREATE_WORDREC) << " "<<recognizerName<< + "LTKLipiEngineModule::createWordRecognizer()"<<endl; + + m_OSUtilPtr->unloadSharedLib(dllHandler); + + LTKReturnError(ECREATE_WORDREC); + } + + addModule(*outWordRecoObj, dllHandler); + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::createWordRecognizer()"<<endl; + + return SUCCESS; +} +/****************************************************************************** +* AUTHOR : Balaji MNA +* DATE : 14-JUN-2009 +* NAME : createWordRecognizer +* DESCRIPTION : resolves logical project name and call createWordRecognizer +* function. +* ARGUMENTS : strLogicalProjectName - logical project name; +* outShapeRecognizerPtr - return shape recognizer object +* RETURNS : if success returns 0 or if fails returns error code +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::createWordRecognizer(const string& strlogicalProjectName, + LTKWordRecognizer** outWordRecPtr) +{ + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::createWordRecognizer()"<<endl; + + int errorCode; + string strProjectName; + string strProfileName; + + errorCode = resolveLogicalNameToProjectProfile(strlogicalProjectName, + strProjectName, + strProfileName); + + if(errorCode !=SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createWordRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + errorCode = createWordRecognizer(strProjectName,strProfileName, + outWordRecPtr); + if (errorCode != SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::createWordRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::createWordRecognizer()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : deleteShapeRecognizer +* DESCRIPTION : To delete the recognizer object which is created +* using "createShapeRecognizer" call +* ARGUMENTS : obj - handle the previously created recognizer object +* RETURNS : 0 on success other values error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* Balaji MNA 18th Jan 2010 Receiving LTKShapeRecognizer as single pointer +* instead of double pointer in deleteShapeRecognizer +******************************************************************************/ +int LTKLipiEngineModule::deleteShapeRecognizer(LTKShapeRecognizer* obj) +{ + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::deleteShapeRecognizer()"<<endl; + + int errorCode; + + //Call recognition module's deleteShapeRecognizer(obj) + if(obj) + { + deleteModule(obj); + errorCode = module_deleteShapeRecognizer(obj); + if(errorCode !=SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::deleteShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + obj = NULL; + } + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::deleteShapeRecognizer()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : deleteWordRecognizer +* DESCRIPTION : To delete the recognizer object which is created +* using "createWordRecognizer" call +* ARGUMENTS : obj - handle the previously created recognizer object +* RETURNS : 0 on success other values error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::deleteWordRecognizer(LTKWordRecognizer* obj) +{ + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::deleteWordRecognizer()"<<endl; + + int errorCode; + + // Call recognition module's deleteWordRecognizer(obj) + if(obj) + { + deleteModule(obj); + errorCode = module_deleteWordRecognizer(obj); + if(errorCode !=SUCCESS) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << getErrorMessage(errorCode) << + "LTKLipiEngineModule::deleteShapeRecognizer()"<<endl; + + LTKReturnError(errorCode); + } + obj = NULL; + } + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::deleteWordRecognizer()"<<endl; + + return SUCCESS; + +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : getLipiRootPath +* DESCRIPTION : To fetch the value for the environment variable LIPI_ROOT +* ARGUMENTS : None +* RETURNS : environment string on success & NULL on error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +string LTKLipiEngineModule::getLipiRootPath() const +{ + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::getLipiRootPath()"<<endl; + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::getLipiRootPath()"<<endl; + + return m_strLipiRootPath; +} + +/****************************************************************************** +* AUTHOR : +* DATE : +* NAME : getLipiLibPath +* DESCRIPTION : To fetch the value for the environment variable LIPI_LIB +* ARGUMENTS : None +* RETURNS : environment string on success & NULL on error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +string LTKLipiEngineModule::getLipiLibPath() const +{ + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Entering: LTKLipiEngineModule::getLipiLibPath()"<<endl; + + LOG(LTKLogger::LTK_LOGLEVEL_INFO)<< + "Exiting: LTKLipiEngineModule::getLipiLibPath()"<<endl; + + return m_strLipiLibPath; +} + +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 10-JAN-2007 +* NAME : setLipiRootPath +* DESCRIPTION : To set the value of LIPI_ROOT +* ARGUMENTS : String +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void LTKLipiEngineModule::setLipiRootPath(const string& appLipiPath) +{ + + //Dont LOG messages as this may be called before configureLogger() + + if ( appLipiPath.empty()) + { + m_strLipiRootPath = m_OSUtilPtr->getEnvVariable(LIPIROOT_ENV_STRING); + } + else + { + m_strLipiRootPath = appLipiPath; + } +} + +/****************************************************************************** +* AUTHOR : +* DATE : +* NAME : setLipiLibPath +* DESCRIPTION : To set the value of LIPI_LIB +* ARGUMENTS : String +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void LTKLipiEngineModule::setLipiLibPath(const string& appLipiLibPath) +{ + + //Dont LOG messages as this may be called before configureLogger() + + if ( appLipiLibPath.empty()) + { + m_strLipiLibPath = m_OSUtilPtr->getEnvVariable(LIPILIB_ENV_STRING); + } + else + { + m_strLipiLibPath = appLipiLibPath; + } +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : mapShapeAlgoModuleFunctions +* DESCRIPTION : To map function addresses of the methods exposed by +* the shape recognition modules +* ARGUMENTS : None +* RETURNS : 0 on success and other values on error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::mapShapeAlgoModuleFunctions(void *dllHandle) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl; + + + module_createShapeRecognizer = NULL; + module_deleteShapeRecognizer = NULL; + + void* functionHandle = NULL; + + int returnVal = m_OSUtilPtr->getFunctionAddress(dllHandle, + CREATESHAPERECOGNIZER_FUNC_NAME, + &functionHandle); + + // Could not map the function from the DLL + if(returnVal != SUCCESS) + { + LOG(LTKLogger::LTK_LOGLEVEL_ERR)<< + "Error: "<< + getErrorMessage(EDLL_FUNC_ADDRESS) <<" "<<CREATESHAPERECOGNIZER_FUNC_NAME + <<" "<<"LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl; + + + m_OSUtilPtr->unloadSharedLib(dllHandle); + + LTKReturnError(EDLL_FUNC_ADDRESS); + } + + module_createShapeRecognizer = (FN_PTR_CREATESHAPERECOGNIZER)functionHandle; + + functionHandle = NULL; + + returnVal = m_OSUtilPtr->getFunctionAddress(dllHandle, + DELETESHAPERECOGNIZER_FUNC_NAME, + &functionHandle); + + // Could not map the function from the DLL + if(returnVal != SUCCESS) + { + LOG(LTKLogger::LTK_LOGLEVEL_ERR)<< + "Error: "<< + getErrorMessage(EDLL_FUNC_ADDRESS) <<" "<<DELETESHAPERECOGNIZER_FUNC_NAME + <<" "<<"LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl; + + m_OSUtilPtr->unloadSharedLib(dllHandle); + + LTKReturnError(EDLL_FUNC_ADDRESS); + } + + module_deleteShapeRecognizer = (FN_PTR_DELETESHAPERECOGNIZER)functionHandle; + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: LTKLipiEngineModule::mapShapeAlgoModuleFunctions()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : mapWordAlgoModuleFunctions +* DESCRIPTION : To map function addresses of the methods exposed by +* the word recognition modules +* ARGUMENTS : None +* RETURNS : 0 on success and other values on error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::mapWordAlgoModuleFunctions(void *dllHandle) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: LTKLipiEngineModule::mapWordAlgoModuleFunctions()"<<endl; + + module_createWordRecognizer = NULL; + module_deleteWordRecognizer = NULL; + + void* functionHandle = NULL; + + int returnVal = m_OSUtilPtr->getFunctionAddress(dllHandle, + CREATEWORDRECOGNIZER_FUNC_NAME, + &functionHandle); + + // Could not map the function from the DLL + if(returnVal != SUCCESS) + { + LOG(LTKLogger::LTK_LOGLEVEL_ERR)<< + "Error: "<< + getErrorMessage(EDLL_FUNC_ADDRESS) <<" "<<CREATEWORDRECOGNIZER_FUNC_NAME + <<" "<<"LTKLipiEngineModule::mapWordAlgoModuleFunctions()"<<endl; + + m_OSUtilPtr->unloadSharedLib(dllHandle); + + LTKReturnError(EDLL_FUNC_ADDRESS); + } + + module_createWordRecognizer = (FN_PTR_CREATEWORDRECOGNIZER)functionHandle; + + functionHandle = NULL; + + returnVal = m_OSUtilPtr->getFunctionAddress(dllHandle, + DELETEWORDRECOGNIZER_FUNC_NAME, + &functionHandle); + + // Could not map the function from the DLL + if(returnVal != SUCCESS) + { + LOG(LTKLogger::LTK_LOGLEVEL_ERR)<< + "Error: "<< + getErrorMessage(EDLL_FUNC_ADDRESS) <<" "<<DELETEWORDRECOGNIZER_FUNC_NAME + <<" "<<"LTKLipiEngineModule::mapWordAlgoModuleFunctions()"<<endl; + + m_OSUtilPtr->unloadSharedLib(dllHandle); + + LTKReturnError(EDLL_FUNC_ADDRESS); + } + + module_deleteWordRecognizer = (FN_PTR_DELETEWORDRECOGNIZER)functionHandle; + + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: LTKLipiEngineModule::mapWordAlgoModuleFunctions()"<<endl; + + return SUCCESS; +} + + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : resolveLogicalNameToProjectProfile +* DESCRIPTION : Resolves logical project name into project and profile name +* ARGUMENTS : strLogicalProjectName - logical project name +* RETURNS : 0 on success and -1 on error +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::resolveLogicalNameToProjectProfile( + const string &strLogicalName, + string &outProjectName, + string &outProfileName) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entering: LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + char strSep[] = " ()\r"; + char *strToken; + + if (m_LipiEngineConfigEntries == NULL ) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: " << EFILE_OPEN_ERROR << getErrorMessage(EFILE_OPEN_ERROR) << + " lipiengine.cfg " << + "LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + LTKReturnError(EFILE_OPEN_ERROR); + } + + if(m_LipiEngineConfigEntries->isConfigMapEmpty()) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< + getErrorMessage(ENOMAPFOUND_LIPIENGINECFG) << + "LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + LTKReturnError(ENOMAPFOUND_LIPIENGINECFG); + } + + string strLogicalProjectName ; + m_LipiEngineConfigEntries->getConfigValue(strLogicalName, + strLogicalProjectName); + + char *strSearch = (char *)strLogicalProjectName.c_str(); + + strToken = strtok(strSearch, strSep); + if(strToken) + { + strToken[strlen(strToken)] = '\0'; + outProjectName = strToken; + } + else + { + // No token found, invalid entry for project name... + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(ENO_TOKEN_FOUND) << + "LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + LTKReturnError(ENOMAPFOUND_LIPIENGINECFG); + } + + strToken = strtok(NULL, strSep); + if(strToken) + { + strToken[strlen(strToken)] = '\0'; + outProfileName = strToken; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting: LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + return SUCCESS; + } + else + { + // No token found, invalid entry for profile name... + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(ENO_TOKEN_FOUND) << + "LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + LTKReturnError(ENOMAPFOUND_LIPIENGINECFG); + } + + + // No value found, invalid logical name + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(EINVALID_LOGICAL_NAME) << + "LTKLipiEngineModule::resolveLogicalNameToProjectProfile()"<<endl; + + LTKReturnError(EINVALID_LOGICAL_NAME); +} + +/****************************************************************************** +* AUTHOR : Nidhi sharma +* DATE : 08-Feb-2007 +* NAME : LTKLipiEngineModule::validateProject +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* +*******************************************************************************/ +int LTKLipiEngineModule::validateProject(const string& strProjectName, + const string& projectType) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Enterng: LTKLipiEngineModule::validateProject()"<<endl; + + LTKConfigFileReader* projectConfigReader = NULL; + + string projectTypeCfgEntry = ""; + + if(strProjectName == "") + { + /* invalid or no entry for project name */ + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(EINVALID_PROJECT_NAME) << + "LTKLipiEngineModule::validateProject()"<<endl; + + LTKReturnError(EINVALID_PROJECT_NAME); + } + + string projectCfgPath = m_strLipiRootPath + PROJECTS_PATH_STRING + + strProjectName + PROFILE_PATH_STRING + PROJECT_CFG_STRING; + + try + { + projectConfigReader = new LTKConfigFileReader(projectCfgPath); + } + catch(LTKException e) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(e.getErrorCode()) << projectCfgPath << + " LTKLipiEngineModule::validateProject()"<<endl; + + LTKReturnError(EINVALID_PROJECT_NAME); + } + + int errorCode = projectConfigReader->getConfigValue(PROJECT_TYPE_STRING, + projectTypeCfgEntry); + + if( errorCode != SUCCESS || projectTypeCfgEntry != projectType) + { + /* Invalid configuration entry for ProjectType */ + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(EINVALID_PROJECT_TYPE) << + " LTKLipiEngineModule::validateProject()"<<endl; + + delete projectConfigReader; + //Project type in CFG is missing or an invalid value + LTKReturnError(EINVALID_PROJECT_TYPE); + } + + delete projectConfigReader; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting: LTKLipiEngineModule::validateProject()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Nidhi sharma +* DATE : 08-Feb-2007 +* NAME : LTKLipiEngineModule::validateProfile +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* +******************************************************************************/ +int LTKLipiEngineModule::validateProfile(const string& strProjectName, + const string& strProfileName, + const string& projectType, + string& outRecognizerString) +{ + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Entering: LTKLipiEngineModule::validateProfile()"<<endl; + + int errorCode; + string profileCfgPath = m_strLipiRootPath + PROJECTS_PATH_STRING + + strProjectName + PROFILE_PATH_STRING + strProfileName + + SEPARATOR + PROFILE_CFG_STRING; + + LTKConfigFileReader* profileConfigReader = NULL; + + try + { + profileConfigReader = new LTKConfigFileReader(profileCfgPath); + } + catch(LTKException e) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(e.getErrorCode()) << profileCfgPath << + " LTKLipiEngineModule::validateProfile()"<<endl; + + LTKReturnError(e.getErrorCode()); + } + + errorCode = profileConfigReader->getConfigValue(projectType, + outRecognizerString); + + if(errorCode != SUCCESS) + { + /* No recognizer specified. */ + if (projectType == SHAPE_RECOGNIZER_STRING ) + { + errorCode = ENO_SHAPE_RECOGNIZER; + } + else + { + errorCode = ENO_WORD_RECOGNIZER; + } + + LOG( LTKLogger::LTK_LOGLEVEL_ERR) << + "Error: "<< getErrorMessage(errorCode) << profileCfgPath << + " LTKLipiEngineModule::validateProfile()"<<endl; + + delete profileConfigReader; + + LTKReturnError(errorCode); + } + + delete profileConfigReader; + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Exiting: LTKLipiEngineModule::validateProfile()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Saravanan R. +* DATE : 09-Feb-2007 +* NAME : LTKLipiEngineModule::validateProjectAndProfileNames +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::validateProjectAndProfileNames( + const string& strProjectName, + const string& strProfileName, + const string& projectType, + string& outRecognizerString) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: LTKLipiEngineModule::validateProjectAndProfileNames()"<<endl; + + int errorCode; + string recognizerType = ""; + string profileName(strProfileName); + + // Validate Project + errorCode = validateProject(strProjectName, projectType); + if ( errorCode!= SUCCESS ) + { + LTKReturnError(errorCode); + } + + + if(projectType == "SHAPEREC") + { + recognizerType = SHAPE_RECOGNIZER_STRING; + } + else + { + recognizerType = WORD_RECOGNIZER_STRING; + } + + // Validate Profile + if(strProfileName == "") + { + //Assume the "default" profile + profileName = DEFAULT_PROFILE; + } + + errorCode = validateProfile(strProjectName, profileName, + recognizerType, outRecognizerString); + if ( errorCode!= SUCCESS) + { + LTKReturnError(errorCode); + } + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: LTKLipiEngineModule::validateProjectAndProfileNames()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Saravanan R. +* DATE : 09-Feb-2007 +* NAME : +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +* +******************************************************************************/ +int LTKLipiEngineModule::loadRecognizerDLL(const string& recognizerName, + void **dllHandler) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: LTKLipiEngineModule::loadRecognizerDLL()"<<endl; + + string recognizerDLLPath = ""; + int returnVal = SUCCESS; + + returnVal = m_OSUtilPtr->loadSharedLib(m_strLipiLibPath, recognizerName, dllHandler); + + + if(returnVal != SUCCESS) + { + LOG(LTKLogger::LTK_LOGLEVEL_ERR)<< + "Error: "<< getErrorMessage(ELOAD_SHAPEREC_DLL) <<" "<<recognizerDLLPath << + "LTKLipiEngineModule::loadRecognizerDLL()"<<endl; + + LTKReturnError(ELOAD_SHAPEREC_DLL); + } + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: LTKLipiEngineModule::loadRecognizerDLL()"<<endl; + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 07-May-2007 +* NAME : getLogFileName +* DESCRIPTION : To fetch the value for m_logFileName +* ARGUMENTS : None +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +string LTKLipiEngineModule::getLogFileName() const +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: LTKLipiEngineModule::getLogFileName()"<<endl; + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: LTKLipiEngineModule::getLogFileName()"<<endl; + + return m_logFileName; +} + + +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 07-May-2007 +* NAME : getLogLevel +* DESCRIPTION : To fetch the value for m_logFileName +* ARGUMENTS : None +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +LTKLogger::EDebugLevel LTKLipiEngineModule::getLogLevel() const +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: LTKLipiEngineModule::getLogLevel()"<<endl; + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: LTKLipiEngineModule::getLogLevel()"<<endl; + + return m_logLevel; +} + +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 07-May-2007 +* NAME : setLogFileName +* DESCRIPTION : To set the value of m_logFileName +* ARGUMENTS : String +* RETURNS : Nothing +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::setLipiLogFileName(const string& appLogFile) +{ + // No log messages as this function is used to configure logger + if ( appLogFile.length() != 0 ) + { + m_logFileName = appLogFile; + } + else + { + LTKReturnError(EINVALID_LOG_FILENAME); + } + + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 07-May-2007 +* NAME : setLipiLogLevel +* DESCRIPTION : To set the value of m_logLevel +* ARGUMENTS : String +* RETURNS : Nothing +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::setLipiLogLevel(const string& appLogLevel) +{ + + // No log messages as this function is used to configure logger + string strLogLevel = ""; + + if ( appLogLevel.length() != 0 ) + { + strLogLevel= appLogLevel; + } + else + { + LTKReturnError(EINVALID_LOG_LEVEL); + } + + const char * strLogLevelPtr = strLogLevel.c_str(); + // mapping m_LogLevel to Logger log levels + + if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_DEBUG) == 0) + { + m_logLevel = LTKLogger::LTK_LOGLEVEL_DEBUG; + } + else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_ALL) == 0) + { + m_logLevel = LTKLogger::LTK_LOGLEVEL_ALL; + } + else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_VERBOSE) == 0) + { + m_logLevel = LTKLogger::LTK_LOGLEVEL_VERBOSE; + } + else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_ERROR) == 0) + { + m_logLevel = LTKLogger::LTK_LOGLEVEL_ERR; + } + else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_OFF) == 0) + { + m_logLevel = LTKLogger::LTK_LOGLEVEL_OFF; + } + else if(LTKSTRCMP(strLogLevelPtr, LOG_LEVEL_INFO) == 0) + { + m_logLevel = LTKLogger::LTK_LOGLEVEL_INFO; + } + else + { + LTKReturnError(EINVALID_LOG_LEVEL); + } + + return SUCCESS; +} +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 07-May-2007 +* NAME : configureLogger +* DESCRIPTION : Configures the logger +* ARGUMENTS : None +* RETURNS : Nothing +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int LTKLipiEngineModule::configureLogger() +{ + // No log messages as this function is used to configure logger + string valueFromCFG = ""; + int errorCode ; + + if ( m_LipiEngineConfigEntries != NULL ) + { + // Read the log file name from lipiengine.cfg + errorCode = m_LipiEngineConfigEntries->getConfigValue(LOG_FILE_NAME, + valueFromCFG); + + if(errorCode ==SUCCESS) + { + setLipiLogFileName(valueFromCFG); + } + else if (errorCode == EKEY_NOT_FOUND ) + { + // Set default log file + } + else + { + LTKReturnError(ECREATE_LOGGER); + } + + // Read the log level + valueFromCFG = ""; + + errorCode = m_LipiEngineConfigEntries->getConfigValue(LOG_LEVEL, valueFromCFG); + + if(errorCode == SUCCESS) + { + setLipiLogLevel(valueFromCFG); + } + else if (errorCode == EKEY_NOT_FOUND ) + { + // Set default log file + } + else + { + LTKReturnError(ECREATE_LOGGER); + } + } + + LTKLoggerUtil::createLogger(m_strLipiLibPath); + LTKLoggerUtil::configureLogger(m_logFileName, m_logLevel); + + return SUCCESS; +}
\ No newline at end of file diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/LipiEngineModule.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/LipiEngineModule.h new file mode 100644 index 00000000..9ccffac3 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/LipiEngineModule.h @@ -0,0 +1,350 @@ +/****************************************************************************** +* Copyright (c) 2006 Hewlett-Packard Development Company, L.P. +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE +********************************************************************************/ + +/****************************************************************************** + * SVN MACROS + * + * $LastChangedDate: 2011-01-18 15:41:43 +0530 (Tue, 18 Jan 2011) $ + * $Revision: 829 $ + * $Author: mnab $ + * + ************************************************************************/ + +/************************************************************************ + * FILE DESCR: LTKLipiEngineModule implementation header derives from LipiEngineModule + * + * CONTENTS: + * + * + * AUTHOR: Thanigai Murugan K + * + * DATE: July 29 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LIPIENGINEMODULE_H_ +#define __LIPIENGINEMODULE_H_ + + +#ifndef _WIN32 +#include <dlfcn.h> +#else +#include <windows.h> +#endif + +#include "LTKLipiEngineInterface.h" +#include "LTKMacros.h" +#include "LTKErrorsList.h" +#include "LTKErrors.h" +#include "LTKLoggerUtil.h" + +class LTKConfigFileReader; +class LTKOSUtil; + +/** @defgroup LipiEngineModule LipiEngineModule +*@brief The LipiEngineModule +*/ + +/** @ingroup LipiEngineModule +* @brief Controlling class responsible for creating, + initializing and deleting the shape/word recognizers. +* @class LTKLipiEngineModule +*/ +class LTKLipiEngineModule : public LTKLipiEngineInterface +{ +private: + /** @brief + * Pointer to the createShapeRecognizer method in the respective shape recognizers + */ + typedef int (*FN_PTR_CREATESHAPERECOGNIZER)(const LTKControlInfo&, + LTKShapeRecognizer**); + FN_PTR_CREATESHAPERECOGNIZER module_createShapeRecognizer; + + /** @brief + * Pointer to the deleteShapeRecognizer method in the respective shape recognizers + */ + typedef int (*FN_PTR_DELETESHAPERECOGNIZER)(LTKShapeRecognizer*); + FN_PTR_DELETESHAPERECOGNIZER module_deleteShapeRecognizer; + + /** @brief + * Pointer to the createWordRecognizer method in the respective shape recognizers + */ + typedef int (*FN_PTR_CREATEWORDRECOGNIZER)(const LTKControlInfo&, + LTKWordRecognizer**); + FN_PTR_CREATEWORDRECOGNIZER module_createWordRecognizer; + + /** @brief + * Pointer to the deleteWordRecognizer method in the respective shape recognizers + */ + typedef int (*FN_PTR_DELETEWORDRECOGNIZER)(LTKWordRecognizer*); + FN_PTR_DELETEWORDRECOGNIZER module_deleteWordRecognizer; + + + string m_strLipiRootPath; // LIPI_ROOT environment path + string m_strLipiLibPath; // LIPI_LIB environment path + + string m_logFileName; + + LTKLogger::EDebugLevel m_logLevel; + + LTKOSUtil* m_OSUtilPtr; + + static LTKLipiEngineModule* lipiEngineModuleInstance; + + +public: + + /** @brief Stores the key-value pairs defined in lipiengine.cfg + */ + LTKConfigFileReader* m_LipiEngineConfigEntries; + + +public: + + static LTKLipiEngineModule* getInstance(); + + static void destroyLipiEngineInstance(); + + + /** @brief Returns LTKLipiEngineModule::m_strLipiRootPath + */ + string getLipiRootPath() const; + + /** @brief Returns LTKLipiEngineModule::m_strLipiLibPath + */ + string getLipiLibPath() const; + + /** @brief Sets the data member LTKLipiEngineModule::m_strLipiRootPath + */ + void setLipiRootPath(const string& appLipiPath=""); + + /** @brief Sets the data member LTKLipiEngineModule::m_strLipiLibPath + */ + void setLipiLibPath(const string& appLipiLibPath=""); + + /** @brief Returns LTKLipiEngineModule::m_logFileName + */ + string getLogFileName() const; + + /** @brief Sets the data member LTKLipiEngineModule::m_logFileName + */ + + int setLipiLogFileName(const string& appLogFile); + + /** @brief Returns LTKLipiEngineModule::m_logLevel + */ + LTKLogger::EDebugLevel getLogLevel() const; + + /** @brief Sets the data member LTKLipiEngineModule::m_logLevel + */ + int setLipiLogLevel(const string& appLogLevel); + + /** @brief Initializes the lipiengine. + * <p> + * Reads the lipiengine.cfg and intializes the data member + * LTKLipiEngineModule::m_LipiEngineConfigEntries + * + * Semantics + * - Return error LTKErrorsList::ELIPI_ROOT_PATH_NOT_SET if + * LTKLipiEngineModule::m_strLipiRootPath is empty + * + * - Read the contents of lipiengine.cfg to + * LTKLipiEngineModule::m_LipiEngineConfigEntries + *<pre> m_LipiEngineConfigEntries = new LTKConfigFileReader(temp) </pre> + * + * </p> + * @return SUCCESS/Error + * @error LTKErrorsList::ELIPI_ROOT_PATH_NOT_SET + */ + int initializeLipiEngine(); + + /* destructor */ + virtual ~LTKLipiEngineModule(); + + /** + * @brief Returns the current version of the lipiengine module + * @param iMajor, iMinor, iBugFix - integers to receive the version + * @return 0 on success + */ + int getcurrentversion(int& iMajor, int& iMinor, int& iBugFix); + + + /** + * @brief Given project and profile, returns an instance of shape recognizers + * + * Semantics + * + * - Validate project using LTKLipiEngineModule::validateProject + * + * - Validate profile using LTKLipiEngineModule::validateProfile + * + * - Load the recognizer DLL + * + * - Map the DLL functions using LTKLipiEngineModule::mapShapeAlgoModuleFunctions + * + * - Create the shape recognizers + * + * - Add the recognizer to the list of active modules using + * LTKLipiEngineModule::AddModule + * - Initialize the shape recognizers calling the recognizers initialize function + * + * @param strProjectName Type : string Project Name + * + * @param strProfileName Type : string Profile Name + * + * @return handle on success, NULL on failure + * @return NULL in following scenarios + * - Project not valid + * - Project name empty : LTKErrorsList::EINVALID_PROJECT_NAME + * - Could not open project.cfg : LTKErrorsList::ECONFIG_FILE_OPEN + * - ProjectType is not SHAPEREC : LTKErrorsList::EINVALID_CONFIG_ENTRY + * + * - Profile not valid + * - Could not open profile.cfg : LTKErrorsList::ECONFIG_FILE_OPEN + * - For shape recognizers + * - profile.cfg does not contain key ShapeRecMethod: + * LTKErrorsList::ENO_SHAPE_RECOGNIZER + * + * - Fail to load recognizer DLL + * - could not load DLL : LTKErrorsList::ELOAD_SHAPEREC_DLL + * + * - Fail to map recognizer DLL functions: LTKErrorsList::EDLL_FUNC_ADDRESS + * - Recogniser createShapeRecognizer failed + * - Recognizers initialize function failed + */ + int createShapeRecognizer(const string& strProjName, const string& strProfName, + LTKShapeRecognizer** outShapeRecoObj); + + /** + * @brief Given project and profile, returns an instance of shape recognizers + * + * Semantics + * - resolve the Logical name passed into logical + * project and profile name using + * LTKLipiEngineModule::resolveLogicalNameToProjectProfile <pre> + * + * - Calls createShapeRecognizer method by passed project name + * and profile name. + * + * @return handle on success, NULL on failure + * @return NULL in following scenarios + * - Project not valid + * - Project name empty : LTKErrorsList::EINVALID_PROJECT_NAME + * - Could not open project.cfg : LTKErrorsList::ECONFIG_FILE_OPEN + * - ProjectType is not SHAPEREC : LTKErrorsList::EINVALID_CONFIG_ENTRY + * + * - Profile not valid + * - Could not open profile.cfg : LTKErrorsList::ECONFIG_FILE_OPEN + * - For shape recognizers + * - profile.cfg does not contain key ShapeRecMethod: + * LTKErrorsList::ENO_SHAPE_RECOGNIZER + * + */ + int createShapeRecognizer(string &strLogicalProjectName, LTKShapeRecognizer** outShapeRecognizerPtr) ; + + /** + * Use this to delete the shape recognizer object created using + * createShapeRecognizer call + * @param handle to the recognizer object to delete + * @return 0 on success + */ + int deleteShapeRecognizer(LTKShapeRecognizer* obj); + + /** + * Use this to create word recognizer object, by passing the project name + * and profile name + * @param projectname + profile name + * + * @return 0 on success + */ + int createWordRecognizer(const string& strProjectName, + const string& strProfileName, + LTKWordRecognizer** outWordRecPtr); + + /** + * Use this to create word recognizer object, by passing the logical project name + * + * @return 0 on success + */ + int createWordRecognizer(const string& strlogicalProjectName, + LTKWordRecognizer** outWordRecPtr); + + /** + * Use this to delete the word recognizer object created using createWordRecognizer call + * @param handle to the recognizer object to delete + * @return 0 on success + */ + int deleteWordRecognizer(LTKWordRecognizer* obj); + + + +private : + + LTKLipiEngineModule(); + + int validateProject(const string& strProjectName, const string& projectType); + + int validateProfile(const string& strProjectName, const string& strProfileName, + const string& projectType, string& outRecognizerString); + + int validateProjectAndProfileNames(const string& strProjectName, + const string& strProfileName, + const string& projectType, + string& outRecognizerString ); + + + int loadRecognizerDLL(const string& recognizerName, void **dllHandler); + + /** + * This map functions get the function address from the DLL/SO module + * Maps the following functions + * - createShapeRecognizer + * - deleteShapeRecognizer + * + * @param DLLHandle - handle to the DLL/SO module + * @return 0 on success + * @error EDLL_FUNC_ADDRESS : Returned if the function could not be maped + */ + int mapShapeAlgoModuleFunctions(void *DLLHandle); + + /** + * This map functions get the function address from the DLL/SO module + * Maps the following functions + * - createWordRecognizer + * - deleteWordRecognizer + * + * @param DLLHandle - handle to the DLL/SO module + * @return 0 on success + * @error EDLL_FUNC_ADDRESS : Returned if the function could not be maped + */ + int mapWordAlgoModuleFunctions(void *DLLHandle); + + /* To resolve the logical name into Project + Profile name */ + int resolveLogicalNameToProjectProfile(const string& strLogicalProjectName, + string &outProjectName, string &outProfileName); + + int configureLogger(); + + +}; + +#endif //#ifndef __LIPIENGINEMODULE_H_ + diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.cpp b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.cpp new file mode 100644 index 00000000..eb55ddb4 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.cpp @@ -0,0 +1,439 @@ +/****************************************************************************** +* Copyright (c) 2006 Hewlett-Packard Development Company, L.P. +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE +********************************************************************************/ + +/****************************************************************************** + * SVN MACROS + * + * $LastChangedDate: 2008-08-01 09:48:58 +0530 (Fri, 01 Aug 2008) $ + * $Revision: 583 $ + * $Author: sharmnid $ + * + ************************************************************************/ +/*************************************************************************** + * FILE DESCR: DLL Implementation file for LipiEngine module + * + * CONTENTS: + * DllMain + * createLTKLipiEngine + * + * AUTHOR: Thanigai Murugan K + * + * DATE: July 29, 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ +// lipiengine.cpp : Defines the entry point for the DLL application. + + +#include "version.h" +#include "lipiengine.h" +#include "LipiEngineModule.h" +#include "LTKErrorsList.h" +#include "LTKErrors.h" +#include "LTKOSUtilFactory.h" +#include "LTKOSUtil.h" +#include "LTKLoggerUtil.h" + +vector<MODULEREFCOUNT> gLipiRefCount; +LTKLipiEngineModule* lipiEngineModule = LTKLipiEngineModule::getInstance(); + +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : DllMain +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +#ifdef _WIN32 +BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, + LPVOID lpReserved) +{ + switch (ul_reason_for_call) + { + case DLL_PROCESS_ATTACH: + break; + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + case DLL_PROCESS_DETACH: + unloadAllModules(); + break; + } + return TRUE; +} +#endif // #ifdef _WIN32 +/****************************************************************************** +* AUTHOR : Thanigai +* DATE : 29-JUL-2005 +* NAME : createLTKLipiEngine +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +LTKLipiEngineInterface* createLTKLipiEngine() +{ + return lipiEngineModule; +} + +/****************************************************************************** +* AUTHOR : Nidhi Sharma +* DATE : 2-JUL-2008 +* NAME : deleteLTKLipiEngine +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void deleteLTKLipiEngine() +{ + LTKLipiEngineModule::destroyLipiEngineInstance(); + lipiEngineModule = NULL; +} +/****************************************************************************** +* AUTHOR : Thanigai Murugan K +* DATE : 23-SEP-2005 +* NAME : addModule +* DESCRIPTION : For each module that is getting loaded, vector lipiRefCount +* will have an entry. For each recognizer object that is getting +* created under every module, vector "vecRecoHandles" will have +* an entry. +* If the recognizer object belongs to the existing module handle, +* then only the reference count incremented and the recognizer +* handle is added to the module's "vecRecoHandles" vector. +* ARGUMENTS : RecoHandle - handle to the recognizer object +* handle - handle to the module +* RETURNS : 0 on success, -1 on Failure. +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void addModule(void* RecoHandle, void* handle) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Entering: addModule()"<<endl; + + int iModIndex = -1; + + iModIndex = findIndexIfModuleInMemory(handle); + + if(iModIndex == EMODULE_NOT_IN_MEMORY) // New module + { + MODULEREFCOUNT mModule; + + mModule.iRefCount = 1; + mModule.modHandle = handle; + mModule.vecRecoHandles.push_back(RecoHandle); + gLipiRefCount.push_back(mModule); + } + else // Module in memory, increment the count + { + gLipiRefCount[iModIndex].iRefCount++; + gLipiRefCount[iModIndex].vecRecoHandles.push_back(RecoHandle); + } + + for(int i = 0; i < gLipiRefCount.size(); i++) + { + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Details of module :"<< i + << "[" << gLipiRefCount[i].modHandle << "]" + << "No.of.recognizers in this module = " + << gLipiRefCount[i].vecRecoHandles.size() << endl; + } + + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Exiting: addModule()"<<endl; +} + +/****************************************************************************** +* AUTHOR : Thanigai Murugan K +* DATE : 23-SEP-2005 +* NAME : deleteModule +* DESCRIPTION : Given a recognizer handle, this function look at the module to +* which this handle belongs to and decrement the reference count +* for that module. Also this recognizer object is deleted from +* the module's recognizer object vectors. +* ARGUMENTS : RecoHandle - handle to the recognizer object +* handle - handle to the module +* RETURNS : 0 on success, -1 on Failure. +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int deleteModule(void* RecoHandle) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: deleteModule()"<<endl; + + int iModIndex = -1; + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "No.of.modules = "<< gLipiRefCount.size()<<endl; + + for(int i = 0; i < gLipiRefCount.size(); i++) + { + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Details of module :"<< i + << "[" << gLipiRefCount[i].modHandle << "]" + << "No.of.recognizers in this module = " + << gLipiRefCount[i].vecRecoHandles.size() << endl; + } + + iModIndex = getAlgoModuleIndex(RecoHandle); + + if(iModIndex == EMODULE_NOT_IN_MEMORY) + { + LOG( LTKLogger::LTK_LOGLEVEL_ERR) + <<"Error: " << getErrorMessage(EMODULE_NOT_IN_MEMORY) << + " deleteModule"<<endl; + + return EMODULE_NOT_IN_MEMORY; + } + else // Module in memory, decrement the count + { + vector<void*>::iterator RecoIter; + + for(RecoIter = gLipiRefCount[iModIndex].vecRecoHandles.begin(); + RecoIter < gLipiRefCount[iModIndex].vecRecoHandles.end(); RecoIter++) + { + if((*RecoIter) == RecoHandle) + { + gLipiRefCount[iModIndex].vecRecoHandles.erase(RecoIter); + break; + } + } + + if(gLipiRefCount[iModIndex].iRefCount > 1) + { + gLipiRefCount[iModIndex].iRefCount--; + } + } + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Exiting: deleteModule()"<<endl; + return SUCCESS; +} + +/****************************************************************************** +* AUTHOR : Thanigai Murugan K +* DATE : 23-SEP-2005 +* NAME : findIndexIfModuleInMemory +* DESCRIPTION : Looks into gLipiRefCount vector for handle, if exists returns +* its index or returns -1 +* ARGUMENTS : handle - handle to the module +* RETURNS : 0 on success, -1 on Failure. +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int findIndexIfModuleInMemory(void* handle) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: findIndexIfModuleInMemory()"<<endl; + + for(int i = 0; i < gLipiRefCount.size(); i++) + { + if(handle == gLipiRefCount[i].modHandle) + { + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: findIndexIfModuleInMemory()"<<endl; + + return i; + } + } + + return EMODULE_NOT_IN_MEMORY; +} + +/****************************************************************************** +* AUTHOR : Thanigai Murugan K +* DATE : 23-SEP-2005 +* NAME : unloadAllModules +* DESCRIPTION : Unload all the modules that are loaded into memory +* ARGUMENTS : None +* RETURNS : 0 on success, -1 on Failure. +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int unloadAllModules() +{ + LTKOSUtil* utilPtr = LTKOSUtilFactory::getInstance(); + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: unloadAllModules()"<<endl; + + for(int i = 0; i < gLipiRefCount.size(); i++) + { + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Unloading module, handle = " << gLipiRefCount[i].modHandle << endl; + + if(gLipiRefCount[i].vecRecoHandles.size() > 1) + { + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"WARNING: Not all "<< + gLipiRefCount[i].vecRecoHandles.size()<< + "recognizers are deleted"<< endl; + } + + utilPtr->unloadSharedLib(gLipiRefCount[i].modHandle); + } + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<<"Exiting: unloadAllModules()"<<endl; + + delete utilPtr; + return 0; +} + +/****************************************************************************** +* AUTHOR : Thanigai Murugan K +* DATE : 23-SEP-2005 +* NAME : getAlgoModuleIndex +* DESCRIPTION : returns index in the modules vector for the recoHandle passed +* ARGUMENTS : RecoHandle - handle to the recognizer object +* RETURNS : 0 on success, -1 on Failure. +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +int getAlgoModuleIndex(void* RecoHandle) +{ + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: getAlgoModuleIndex()"<<endl; + + for(int i = 0; i < gLipiRefCount.size(); i++) + { + for (int j = 0; j < gLipiRefCount[i].vecRecoHandles.size(); j++) + { + if( gLipiRefCount[i].vecRecoHandles[j] == RecoHandle) + { + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "index : "<< i <<endl; + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: getAlgoModuleIndex()"<<endl; + + return i; + } + } + } + + LOG( LTKLogger::LTK_LOGLEVEL_DEBUG) << + "Error: "<<EMODULE_NOT_IN_MEMORY<<": "<< + getErrorMessage(EMODULE_NOT_IN_MEMORY) << + "getAlgoModuleIndex()"<<endl; + + return EMODULE_NOT_IN_MEMORY; +} + +/****************************************************************************** +* AUTHOR : +* DATE : +* NAME : +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void setLipiRootPath(const string& appLipiPath) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: setLipiRootPath()"<<endl; + + lipiEngineModule->setLipiRootPath(appLipiPath); + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: setLipiRootPath()"<<endl; +} + +/****************************************************************************** +* AUTHOR : +* DATE : +* NAME : +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void setLTKLogFileName(const string& appLogFile) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: setLTKLogFileName()"<<endl; + + lipiEngineModule->setLipiLogFileName(appLogFile); + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: setLTKLogFileName()"<<endl; +} + +/****************************************************************************** +* AUTHOR : +* DATE : +* NAME : +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void setLTKLogLevel(const string& appLogLevel) +{ + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: setLTKLogLevel()"<<endl; + + lipiEngineModule->setLipiLogLevel(appLogLevel); + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: setLTKLogLevel()"<<endl; +} + +/****************************************************************************** +* AUTHOR : +* DATE : +* NAME : +* DESCRIPTION : +* ARGUMENTS : +* RETURNS : +* NOTES : +* CHANGE HISTROY +* Author Date Description of change +******************************************************************************/ +void getToolkitVersion(int& iMajor, int& iMinor, int& iBugFix) +{ + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Entering: getToolkitVersion()"<<endl; + + getVersion(iMajor, iMinor, iBugFix); + + LOG(LTKLogger::LTK_LOGLEVEL_DEBUG)<< + "Exiting: getToolkitVersion()"<<endl; +} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.def b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.def new file mode 100644 index 00000000..96f73e12 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.def @@ -0,0 +1,7 @@ +EXPORTS + createLTKLipiEngine @1 + setLipiRootPath @2 + setLTKLogFileName @3 + setLTKLogLevel @4 + getToolkitVersion @5 + deleteLTKLipiEngine @6
\ No newline at end of file diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.h new file mode 100644 index 00000000..bc1aa408 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.h @@ -0,0 +1,126 @@ +/****************************************************************************** +* Copyright (c) 2006 Hewlett-Packard Development Company, L.P. +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE +******************************************************************************/ + +/****************************************************************************** + * SVN MACROS + * + * $LastChangedDate: 2008-07-18 15:00:39 +0530 (Fri, 18 Jul 2008) $ + * $Revision: 561 $ + * $Author: sharmnid $ + * + *****************************************************************************/ +/***************************************************************************** + * FILE DESCR: DLL header for LipiEngine DLL module + * + * CONTENTS: + * + * + * AUTHOR: Thanigai Murugan K + * + * DATE: July 29 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef __LIPIENGINE_H_ +#define __LIPIENGINE_H_ + +#include "LipiEngineModule.h" + +/* The following ifdef block is the standard way of creating macros which make + exporting from a DLL simpler. All files within this DLL are compiled with + the LIPIENGINE_EXPORTS symbol defined on the command line.This symbol should + not be defined on any project that uses this DLL. This way any other project + whose source files include this file see LIPIENGINE_API functions as being + imported from a DLL, wheras this DLL sees symbols defined with this macro + as being exported. +*/ + +#ifdef _WIN32 +#ifdef LIPIENGINE_EXPORTS +#define LIPIENGINE_API __declspec(dllexport) +#else +#define LIPIENGINE_API __declspec(dllimport) +#endif +#else +#define LIPIENGINE_API +#endif // #ifdef _WIN32 + +extern "C" LIPIENGINE_API LTKLipiEngineInterface* createLTKLipiEngine(); + +extern "C" LIPIENGINE_API void setLipiRootPath(const string& appLipiPath); + +extern "C" LIPIENGINE_API void setLTKLogFileName(const string& appLogFile); + +extern "C" LIPIENGINE_API void setLTKLogLevel(const string& appLogLevel); + +extern "C" LIPIENGINE_API void getToolkitVersion(int& iMajor, int& iMinor, + int& iBugFix); + +extern "C" LIPIENGINE_API void deleteLTKLipiEngine(); + +/** +* This function Unload all the modules that are loaded into memory +* @param none +* @return 0 on success +*/ +int unloadAllModules(); + +/** +* This function Looks into m_lipiRefCount vector for handle, if exists +* returns its index or returns -1 +* @param handle to the module +* @return 0 on success +*/ +int findIndexIfModuleInMemory(void* handle); + +/** +* Given a recognizer handle, this function look at the module to +* which this handle belongs to and decrement the reference count +* for that module. Also this recognizer object is deleted from +* the module's recognizer object vectors. +* @param recoHandle - handle to the recognizer object to delete +* @return 0 on success +*/ +int deleteModule(void* RecoHandle); + +/** +* For each module that is getting loaded, vector m_lipiRefCount +* will have an entry. For each recognizer object that is getting +* created under every module, vector "vecRecoHandles" will have +* an entry. +* If the recognizer object belongs to the existing module handle, +* then only the reference count incremented and the recognizer handle +* is added to the module's "vecRecoHandles" vector. +* @param Handle - handle to the module, +* RecoHandle - handle to the recognizer object +*/ +void addModule(void* RecoHandle, void* handle); + +/** +* This function returns the index in the modules vector for the + recoHandle passed +* @param RecoHandle - handle to the recognizer object +* @return 0 on success +*/ +int getAlgoModuleIndex(void* RecoHandle); + + +#endif //#ifndef __LIPIENGINE_H_ diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.pro b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.pro new file mode 100644 index 00000000..bfcc0bcd --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/lipiengine.pro @@ -0,0 +1,19 @@ +LIPILIBS = shaperecommon ltkcommon ltkutil wordreccommon +include(../lipiplugin.pri) + +INCLUDEPATH += \ + ../util/lib + +HEADERS += \ + lipiengine.h \ + LipiEngineModule.h + +SOURCES += \ + lipiengine.cpp \ + LipiEngineModule.cpp + +win32 { + DEFINES += LIPIENGINE_EXPORTS + LIBS += Advapi32.lib + #DEF_FILE = lipiengine.def +} diff --git a/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/version.h b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/version.h new file mode 100644 index 00000000..a31c2503 --- /dev/null +++ b/src/plugins/lipi-toolkit/3rdparty/lipi-toolkit/src/lipiengine/version.h @@ -0,0 +1,59 @@ +/****************************************************************************** +* Copyright (c) 2006 Hewlett-Packard Development Company, L.P. +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE +********************************************************************************/ + +/************************************************************************ + * FILE DESCR: Definitions for Version Info module. + * + * CONTENTS: + * + * AUTHOR: VijayaKumara M. + * + * DATE: Aug 02, 2005 + * CHANGE HISTORY: + * Author Date Description of change + ************************************************************************/ + +#ifndef _VERSION_H_ +#define _VERSION_H_ + +#define MAJOR_VERSION 4 +#define MINOR_VERSION 0 +#define BUGFIX_VERSION 0 + + +/** + * This method get the version numbers for the variable which are passed to the + * function as its arguments. + * + * @param iMajor - An integer variable for Major number. + * @param iMinor - An integer variable for Minor number. + * @param iBugFix - An integer variable for BugFix number. + * + */ + +void getVersion(int& iMajor, int& iMinor, int& iBugFix) +{ + iMajor=MAJOR_VERSION; + iMinor=MINOR_VERSION; + iBugFix=BUGFIX_VERSION; +} + +#endif //#ifndef _VERSION_H_ + |