Commit 19fa2ddd authored by Jozef Legeny's avatar Jozef Legeny

core/kernel:

+ added basic folder structure for the kernel project



git-svn-id: svn://scm.gforge.inria.fr/svn/openvibe@3605 c330d7e9-fc0c-0410-a5b3-fd85c6f5aa8f
parent 52bc2a2a
PROJECT(openvibe-kernel)
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR})
SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH})
SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${source_files})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
COMPILE_FLAGS "-DOV_Exports -DOV_Shared")
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBECommon")
INCLUDE("FindOpenViBEModuleFS")
INCLUDE("FindOpenViBEModuleSystem")
INCLUDE("FindOpenViBEModuleXML")
INCLUDE("FindThirdPartyGTK")
INCLUDE("FindThirdPartyOgre3D") # OGRE + OIS included, pulls boost thread
INCLUDE("FindThirdPartyBoost") # Using Ogre headers on Win32 causes dependency to Boost thread library
INCLUDE("FindThirdPartyBoost_Thread") # Note that this is a potential issue on Windows, as the dependencies/ogre/boost and dependencies/boost are not the same at the time of writing this.
INCLUDE("FindThirdPartyX11") # Linux packaging ("lintian") complains if not linked to, NOP on Win32
# ---------------------------------
# Finds standard library dl
# Adds library to target
# Adds include path
# ---------------------------------
IF(UNIX)
FIND_LIBRARY(LIB_STANDARD_MODULE_DL dl)
IF(LIB_STANDARD_MODULE_DL)
MESSAGE(STATUS " Found dl...")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_DL})
ELSE(LIB_STANDARD_MODULE_PTHREAD)
MESSAGE(STATUS " FAILED to find dl...")
ENDIF(LIB_STANDARD_MODULE_DL)
ENDIF(UNIX)
# ---------------------------------
# Finds standard library pthread
# Adds library to target
# Adds include path
# ---------------------------------
IF(UNIX)
FIND_LIBRARY(LIB_STANDARD_MODULE_PTHREAD pthread)
IF(LIB_STANDARD_MODULE_PTHREAD)
MESSAGE(STATUS " Found pthread...")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${LIB_STANDARD_MODULE_PTHREAD})
ELSE(LIB_STANDARD_MODULE_PTHREAD)
MESSAGE(STATUS " FAILED to find pthread...")
ENDIF(LIB_STANDARD_MODULE_PTHREAD)
ENDIF(UNIX)
# ---------------------------------
# Target macros
# Defines target operating system
# Defines target architecture
# Defines target compiler
# ---------------------------------
IF(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-DTARGET_OS_Windows)
ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386)
ADD_DEFINITIONS(-DTARGET_COMPILER_VisualStudio)
ENDIF(WIN32)
IF(UNIX)
# ADD_DEFINITIONS(-fvisibility=hidden) # This flag should be present... man gcc
ADD_DEFINITIONS(-g)
ADD_DEFINITIONS(-DTARGET_OS_Linux)
ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386)
ADD_DEFINITIONS(-DTARGET_COMPILER_GCC)
ENDIF(UNIX)
# -----------------------------
# Install files
# -----------------------------
INSTALL(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
INSTALL(DIRECTORY share/ DESTINATION ${CMAKE_INSTALL_FULL_DATADIR} PATTERN ".svn" EXCLUDE)
#INSTALL(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE PATTERN "doc" EXCLUDE)
material cone_ov_material
{
technique
{
pass
{
ambient 1 1 1
diffuse 1 1 1
// specular 0 0 0 10
// emissive 0 0 0
scene_blend alpha_blend
}
}
}
Render System=OpenGL Rendering Subsystem
[OpenGL Rendering Subsystem]
FSAA=0
Full Screen=No
RTT Preferred Mode=FBO
# Stereovision=Disabled
Video Mode=800 x 600
######################################################################################
## OpenViBE delayed configuration file
##
## === This file is loaded later when a scenario execution starts ===
##
## - The file consists of a list of "token name = token value"
## - Whatever space / tabulation at the begining or end of a line is removed
## - Comments start with #
## - Lines ending with \ continue on the next line (all ending \ are removed)
## - On Windows, use \ in paths as / is reserved
## - You can use ${token name} in a token value
## - You can use $Environment{env name} in a token value to get an environment variable
######################################################################################
#
# Add some tokens here
#
#####################################################################################
# Include custom configuration (from deprecated locations, next block overrides)
#####################################################################################
CustomDelayedConfigurationPrefixWindows = ${UserHome}/openvibe-delayed
CustomDelayedConfigurationPrefixLinux = ${UserHome}/.openvibe-delayed
CustomDelayedConfigurationSuffixWindows = .conf
CustomDelayedConfigurationSuffixLinux = rc
CustomDelayedConfiguration = ${CustomDelayedConfigurationPrefix${OperatingSystem}}${CustomDelayedConfigurationSuffix${OperatingSystem}}
Include = ${CustomDelayedConfiguration}
#####################################################################################
# Include custom configuration
#####################################################################################
CustomDelayedConfigurationPrefixWindows = ${Path_UserData}/openvibe-delayed
CustomDelayedConfigurationPrefixLinux = ${Path_UserData}/openvibe-delayed
CustomDelayedConfigurationSuffixWindows = .conf
CustomDelayedConfigurationSuffixLinux = rc
CustomDelayedConfiguration = ${CustomDelayedConfigurationPrefix${OperatingSystem}}${CustomDelayedConfigurationSuffix${OperatingSystem}}
Include = ${CustomDelayedConfiguration}
This diff is collapsed.
# Resource locations to be added to the default path
[Bootstrap]
Zip=${Path_Data}/openvibe-kernel-omk/OgreCore.zip
[General]
FileSystem=${Path_Data}/openvibe-kernel-omk/
material sphere_ov_material
{
technique
{
pass
{
ambient 1 1 1
diffuse 1 1 1
// specular 0 0 0 10
// emissive 0 0 0
scene_blend alpha_blend
}
}
}
//the following cg/diffuse shader allows controlling the diffuse component from code using parameter 1
//fragment_program set_color_fp cg
//{
// source diffuse.cg
// entry_point main_ps
// profiles ps_2_0 arbfp1
// default_params
// {
// param_named myColour float4 1 1 1 1
// }
//}
//material cg/diffuse
//{
// technique
// {
// pass
// {
//// lighting off
// scene_blend alpha_blend
// fragment_program_ref set_color_fp
// {
// param_named_auto myColour custom 1
// }
// }
// }
//}
This diff is collapsed.
#ifndef __OpenViBEKernel_Kernel_CAlgorithm_H__
#define __OpenViBEKernel_Kernel_CAlgorithm_H__
#include "../ovkTKernelObject.h"
#include <map>
namespace OpenViBE
{
namespace Kernel
{
class CAlgorithm : public OpenViBE::Kernel::TKernelObject < OpenViBE::Kernel::IKernelObject >
{
public:
CAlgorithm(const OpenViBE::Kernel::IKernelContext& rKernelContext, OpenViBE::Plugins::IAlgorithm& rAlgorithm, const OpenViBE::Plugins::IAlgorithmDesc& rAlgorithmDesc);
virtual ~CAlgorithm(void);
virtual OpenViBE::Plugins::IAlgorithm& getAlgorithm(void);
virtual const OpenViBE::Plugins::IAlgorithm& getAlgorithm(void) const;
virtual const OpenViBE::Plugins::IAlgorithmDesc& getAlgorithmDesc(void) const;
virtual OpenViBE::boolean addInputParameter(
const OpenViBE::CIdentifier& rInputParameterIdentifier,
const OpenViBE::CString& sInputName,
const OpenViBE::Kernel::EParameterType eParameterType,
const OpenViBE::CIdentifier& rSubTypeIdentifier);
virtual OpenViBE::CIdentifier getNextInputParameterIdentifier(
const OpenViBE::CIdentifier& rPreviousInputParameterIdentifier) const;
virtual OpenViBE::Kernel::IParameter* getInputParameter(
const OpenViBE::CIdentifier& rInputParameterIdentifier);
virtual OpenViBE::Kernel::EParameterType getInputParameterType(
const OpenViBE::CIdentifier& rInputParameterIdentifier) const;
virtual OpenViBE::CString getInputParameterName(
const OpenViBE::CIdentifier& rInputParameterIdentifier) const;
virtual OpenViBE::boolean removeInputParameter(
const OpenViBE::CIdentifier& rInputParameterIdentifier);
virtual OpenViBE::boolean addOutputParameter(
const OpenViBE::CIdentifier& rOutputParameterIdentifier,
const OpenViBE::CString& sOutputName,
const OpenViBE::Kernel::EParameterType eParameterType,
const OpenViBE::CIdentifier& rSubTypeIdentifier);
virtual OpenViBE::CIdentifier getNextOutputParameterIdentifier(
const OpenViBE::CIdentifier& rPreviousOutputParameterIdentifier) const;
virtual OpenViBE::Kernel::IParameter* getOutputParameter(
const OpenViBE::CIdentifier& rOutputParameterIdentifier);
virtual OpenViBE::Kernel::EParameterType getOutputParameterType(
const OpenViBE::CIdentifier& rOutputParameterIdentifier) const;
virtual OpenViBE::CString getOutputParameterName(
const OpenViBE::CIdentifier& rOutputParameterIdentifier) const;
virtual OpenViBE::boolean removeOutputParameter(
const OpenViBE::CIdentifier& rOutputParameterIdentifier);
virtual OpenViBE::boolean addInputTrigger(
const OpenViBE::CIdentifier& rInputTriggerIdentifier,
const OpenViBE::CString& rInputTriggerName);
virtual OpenViBE::CIdentifier getNextInputTriggerIdentifier(
const OpenViBE::CIdentifier& rPreviousInputTriggerIdentifier) const;
virtual OpenViBE::CString getInputTriggerName(
const OpenViBE::CIdentifier& rInputTriggerIdentifier) const;
virtual OpenViBE::boolean isInputTriggerActive(
const OpenViBE::CIdentifier& rInputTriggerIdentifier) const;
virtual OpenViBE::boolean activateInputTrigger(
const OpenViBE::CIdentifier& rInputTriggerIdentifier,
const OpenViBE::boolean bTriggerState);
virtual OpenViBE::boolean removeInputTrigger(
const OpenViBE::CIdentifier& rInputTriggerIdentifier);
virtual OpenViBE::boolean addOutputTrigger(
const OpenViBE::CIdentifier& rOutputTriggerIdentifier,
const OpenViBE::CString& rOutputTriggerName);
virtual OpenViBE::CIdentifier getNextOutputTriggerIdentifier(
const OpenViBE::CIdentifier& rPreviousOutputTriggerIdentifier) const;
virtual OpenViBE::CString getOutputTriggerName(
const OpenViBE::CIdentifier& rOutputTriggerIdentifier) const;
virtual OpenViBE::boolean isOutputTriggerActive(
const OpenViBE::CIdentifier& rOutputTriggerIdentifier) const;
virtual OpenViBE::boolean activateOutputTrigger(
const OpenViBE::CIdentifier& rOutputTriggerIdentifier,
const OpenViBE::boolean bTriggerState);
virtual OpenViBE::boolean removeOutputTrigger(
const OpenViBE::CIdentifier& rOutputTriggerIdentifier);
virtual OpenViBE::boolean initialize(void);
virtual OpenViBE::boolean uninitialize(void);
virtual OpenViBE::boolean process(void);
virtual OpenViBE::boolean process(
const OpenViBE::CIdentifier& rTriggerIdentifier);
_IsDerivedFromClass_Final_(OpenViBE::Kernel::TKernelObject < OpenViBE::Kernel::IKernelObject >, OVK_ClassId_Kernel_Algorithm_Algorithm)
protected:
OpenViBE::Kernel::IConfigurable* m_pInputConfigurable;
OpenViBE::Kernel::IConfigurable* m_pOutputConfigurable;
std::map<OpenViBE::CIdentifier, OpenViBE::CString> m_vInputParameterName;
std::map<OpenViBE::CIdentifier, OpenViBE::CString> m_vOutputParameterName;
std::map<OpenViBE::CIdentifier, std::pair<OpenViBE::CString, OpenViBE::boolean> > m_vInputTrigger;
std::map<OpenViBE::CIdentifier, std::pair<OpenViBE::CString, OpenViBE::boolean> > m_vOutputTrigger;
protected:
void setAllInputTriggers(const OpenViBE::boolean bTriggerStatus);
void setAllOutputTriggers(const OpenViBE::boolean bTriggerStatus);
void handleCrash(const char* sWhere);
OpenViBE::uint32 m_ui32CrashCount;
OpenViBE::boolean m_bActive;
private:
const OpenViBE::Plugins::IAlgorithmDesc& m_rAlgorithmDesc;
OpenViBE::Plugins::IAlgorithm& m_rAlgorithm;
};
};
};
#endif // __OpenViBEKernel_Kernel_CAlgorithm_H__
#include "ovkCAlgorithmContext.h"
#include "ovkCAlgorithm.h"
#include "../../tools/ovk_bridge_bind_function.h"
using namespace OpenViBE;
using namespace Kernel;
using namespace Plugins;
namespace OpenViBE
{
namespace Kernel
{
namespace
{
class CLogManagerBridge : public TKernelObject<ILogManager>
{
public:
CLogManagerBridge(const IKernelContext& rKernelContext, const ::IPluginObjectDesc& rPluginObjectDesc) : TKernelObject<ILogManager>(rKernelContext), m_rPluginObjectDesc(rPluginObjectDesc) { }
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const time64, time64Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const uint64, ui64Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const uint32, ui32Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const uint16, ui16Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const uint8, ui8Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const int64, i64Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const int32, i32Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const int16, i16Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const int8, i8Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const float32, f32Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const float64, f64Value)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const boolean, bValue)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const CIdentifier&, rValue)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const CString&, rValue);
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const char*, rValue);
// __BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const ELogLevel, eLogLevel)
__BridgeBindFunc1__(getKernelContext().getLogManager(), void, log, , const ELogColor, eLogColor)
__BridgeBindFunc1__(getKernelContext().getLogManager(), boolean, addListener, , ILogListener*, pListener)
__BridgeBindFunc1__(getKernelContext().getLogManager(), boolean, removeListener, , ILogListener*, pListener)
__BridgeBindFunc1__(getKernelContext().getLogManager(), boolean, isActive, , ELogLevel, eLogLevel)
__BridgeBindFunc2__(getKernelContext().getLogManager(), boolean, activate, , ELogLevel, eLogLevel, boolean, bActive)
__BridgeBindFunc3__(getKernelContext().getLogManager(), boolean, activate, , ELogLevel, eStartLogLevel, ELogLevel, eEndLogLevel, boolean, bActive)
__BridgeBindFunc1__(getKernelContext().getLogManager(), boolean, activate, , boolean, bActive)
void log(const ELogLevel eLogLevel)
{
getKernelContext().getLogManager()
<< eLogLevel
<< "<"
<< LogColor_PushStateBit
<< LogColor_ForegroundBlue
<< "Algorithm"
<< LogColor_PopStateBit
<< "::"
<< m_rPluginObjectDesc.getName()
<< "> ";
}
_IsDerivedFromClass_Final_(TKernelObject<ILogManager>, OV_UndefinedIdentifier);
protected:
const ::IPluginObjectDesc& m_rPluginObjectDesc;
};
};
};
};
CAlgorithmContext::CAlgorithmContext(const IKernelContext& rKernelContext, CAlgorithm& rAlgorithm, const IPluginObjectDesc& rPluginObjectDesc)
:TKernelObject < IAlgorithmContext >(rKernelContext)
,m_pLogManager(NULL)
,m_rAlgorithm(rAlgorithm)
{
m_pLogManager=new CLogManagerBridge(rKernelContext, rPluginObjectDesc);
}
CAlgorithmContext::~CAlgorithmContext(void)
{
delete m_pLogManager;
}
IConfigurationManager& CAlgorithmContext::getConfigurationManager(void)
{
return getKernelContext().getConfigurationManager();
}
IAlgorithmManager& CAlgorithmContext::getAlgorithmManager(void)
{
return getKernelContext().getAlgorithmManager();
}
ILogManager& CAlgorithmContext::getLogManager(void)
{
return *m_pLogManager;
}
ITypeManager& CAlgorithmContext::getTypeManager(void)
{
return getKernelContext().getTypeManager();
}
CIdentifier CAlgorithmContext::getNextInputParameterIdentifier(
const CIdentifier& rPreviousInputParameterIdentifier) const
{
return m_rAlgorithm.getNextInputParameterIdentifier(rPreviousInputParameterIdentifier);
}
IParameter* CAlgorithmContext::getInputParameter(
const CIdentifier& rInputParameterIdentifier)
{
return m_rAlgorithm.getInputParameter(rInputParameterIdentifier);
}
CIdentifier CAlgorithmContext::getNextOutputParameterIdentifier(
const CIdentifier& rPreviousOutputParameterIdentifier) const
{
return m_rAlgorithm.getNextOutputParameterIdentifier(rPreviousOutputParameterIdentifier);
}
IParameter* CAlgorithmContext::getOutputParameter(
const CIdentifier& rOutputParameterIdentifier)
{
return m_rAlgorithm.getOutputParameter(rOutputParameterIdentifier);
}
boolean CAlgorithmContext::isInputTriggerActive(
const CIdentifier& rInputTriggerIdentifier) const
{
return m_rAlgorithm.isInputTriggerActive(rInputTriggerIdentifier);
}
boolean CAlgorithmContext::activateOutputTrigger(
const CIdentifier& rOutputTriggerIdentifier,
const boolean bTriggerState)
{
return m_rAlgorithm.activateOutputTrigger(rOutputTriggerIdentifier, bTriggerState);
}
#ifndef __OpenViBEKernel_Kernel_CAlgorithmContext_H__
#define __OpenViBEKernel_Kernel_CAlgorithmContext_H__
#include "../ovkTKernelObject.h"
namespace OpenViBE
{
namespace Kernel
{
class CAlgorithm;
class CAlgorithmContext : public OpenViBE::Kernel::TKernelObject < OpenViBE::Kernel::IAlgorithmContext >
{
public:
CAlgorithmContext(const OpenViBE::Kernel::IKernelContext& rKernelContext, OpenViBE::Kernel::CAlgorithm& rAlgorithm, const OpenViBE::Plugins::IPluginObjectDesc& rPluginObjectDesc);
virtual ~CAlgorithmContext(void);
virtual OpenViBE::Kernel::IConfigurationManager& getConfigurationManager(void);
virtual OpenViBE::Kernel::IAlgorithmManager& getAlgorithmManager(void);
virtual OpenViBE::Kernel::ILogManager& getLogManager(void);
virtual OpenViBE::Kernel::ITypeManager& getTypeManager(void);
virtual OpenViBE::CIdentifier getNextInputParameterIdentifier(
const OpenViBE::CIdentifier& rPreviousInputParameterIdentifier) const;
virtual OpenViBE::Kernel::IParameter* getInputParameter(
const OpenViBE::CIdentifier& rInputParameterIdentifier);
virtual OpenViBE::CIdentifier getNextOutputParameterIdentifier(
const OpenViBE::CIdentifier& rPreviousOutputParameterIdentifier) const;
virtual OpenViBE::Kernel::IParameter* getOutputParameter(
const OpenViBE::CIdentifier& rOutputParameterIdentifier);
virtual OpenViBE::boolean isInputTriggerActive(
const OpenViBE::CIdentifier& rInputTriggerIdentifier) const;
virtual OpenViBE::boolean activateOutputTrigger(
const OpenViBE::CIdentifier& rOutputTriggerIdentifier,
const OpenViBE::boolean bTriggerState);
_IsDerivedFromClass_Final_(OpenViBE::Kernel::TKernelObject < OpenViBE::Kernel::IAlgorithmContext >, OVK_ClassId_Kernel_Algorithm_AlgorithmContext)
protected:
OpenViBE::Kernel::ILogManager* m_pLogManager;
OpenViBE::Kernel::CAlgorithm& m_rAlgorithm;
};
};
};
#endif // __OpenViBEKernel_Kernel_CAlgorithmContext_H__
#include "ovkCAlgorithmManager.h"
#include "ovkCAlgorithmProxy.h"
#include "ovkCAlgorithm.h"
#include <system/Math.h>
using namespace OpenViBE;
using namespace Kernel;
using namespace Plugins;
using namespace std;
CAlgorithmManager::CAlgorithmManager(const IKernelContext& rKernelContext)
:TKernelObject<IAlgorithmManager>(rKernelContext)
{
}
CAlgorithmManager::~CAlgorithmManager(void)
{
map < CIdentifier, pair < CAlgorithm*, CAlgorithmProxy* > >::iterator itAlgorithm;
for(itAlgorithm=m_vAlgorithm.begin(); itAlgorithm!=m_vAlgorithm.end(); itAlgorithm++)
{
IAlgorithm& l_rAlgorithm=itAlgorithm->second.first->getAlgorithm();
delete itAlgorithm->second.second;
delete itAlgorithm->second.first;
getKernelContext().getPluginManager().releasePluginObject(&l_rAlgorithm);
}
}
CIdentifier CAlgorithmManager::createAlgorithm(
const CIdentifier& rAlgorithmClassIdentifier)
{
const IAlgorithmDesc* l_pAlgorithmDesc=NULL;
IAlgorithm* l_pAlgorithm=getKernelContext().getPluginManager().createAlgorithm(rAlgorithmClassIdentifier, &l_pAlgorithmDesc);
if(!l_pAlgorithm || !l_pAlgorithmDesc)
{
getLogManager() << LogLevel_Warning << "Algorithm creation failed, class identifier :" << rAlgorithmClassIdentifier << "\n";
return OV_UndefinedIdentifier;
}
getLogManager() << LogLevel_Debug << "Creating algorithm with class identifier " << rAlgorithmClassIdentifier << "\n";
CIdentifier l_oAlgorithmIdentifier=getUnusedIdentifier();
CAlgorithm* l_pTrueAlgorithm=new CAlgorithm(getKernelContext(), *l_pAlgorithm, *l_pAlgorithmDesc);
CAlgorithmProxy* l_pAlgorithmProxy=new CAlgorithmProxy(getKernelContext(), *l_pTrueAlgorithm);
m_vAlgorithm[l_oAlgorithmIdentifier]=pair < CAlgorithm*, CAlgorithmProxy* >(l_pTrueAlgorithm, l_pAlgorithmProxy);
return l_oAlgorithmIdentifier;
}
boolean CAlgorithmManager::releaseAlgorithm(
const CIdentifier& rAlgorithmIdentifier)
{
map < CIdentifier, pair < CAlgorithm*, CAlgorithmProxy* > >::iterator itAlgorithm;
itAlgorithm=m_vAlgorithm.find(rAlgorithmIdentifier);
if(itAlgorithm==m_vAlgorithm.end())
{
getLogManager() << LogLevel_Warning << "Algorithm release failed, identifier " << rAlgorithmIdentifier << "\n";
return false;
}
getLogManager() << LogLevel_Debug << "Releasing algorithm with identifier " << rAlgorithmIdentifier << "\n";
IAlgorithm& l_rAlgorithm=itAlgorithm->second.first->getAlgorithm();
if(itAlgorithm->second.second)
{
delete itAlgorithm->second.second;
itAlgorithm->second.second = NULL;
}
if(itAlgorithm->second.first)
{
delete itAlgorithm->second.first;
itAlgorithm->second.first = NULL;
}
m_vAlgorithm.erase(itAlgorithm);
getKernelContext().getPluginManager().releasePluginObject(&l_rAlgorithm);
return true;
}
boolean CAlgorithmManager::releaseAlgorithm(
IAlgorithmProxy& rAlgorithm)
{
map < CIdentifier, pair < CAlgorithm*, CAlgorithmProxy* > >::iterator itAlgorithm;
for(itAlgorithm=m_vAlgorithm.begin(); itAlgorithm!=m_vAlgorithm.end(); itAlgorithm++)
{
if((IAlgorithmProxy*)itAlgorithm->second.second==&rAlgorithm)
{
IAlgorithm& l_rAlgorithm=itAlgorithm->second.first->getAlgorithm();
getLogManager() << LogLevel_Debug << "Releasing algorithm with class id " << l_rAlgorithm.getClassIdentifier() << "\n";
if(itAlgorithm->second.second)
{
delete itAlgorithm->second.second;
itAlgorithm->second.second = NULL;
}
if(itAlgorithm->second.first)
{
delete itAlgorithm->second.first;
itAlgorithm->second.first = NULL;
}
m_vAlgorithm.erase(itAlgorithm);
getKernelContext().getPluginManager().releasePluginObject(&l_rAlgorithm);
return true;
}
}
getLogManager() << LogLevel_Warning << "Algorithm release failed\n";
return false;
}
IAlgorithmProxy& CAlgorithmManager::getAlgorithm(
const CIdentifier& rAlgorithmIdentifier)