Commit de08fb5e authored by Yann Renard's avatar Yann Renard

merged -r 720:870 branch wip-yrenard with trunc for openvibe

merged -r 721:870 branch wip-yrenard with trunc for openvibe-kernel-omk
merged -r 723:870 branch wip-yrenard with trunc for openvibe-toolkit
merged -r 738:870 branch wip-yrenard with trunc for openvibe-plugins-samples
merged -r 741:870 branch wip-yrenard with trunc for openvibe-plugins-stream-codecs
merged -r 765:870 branch wip-yrenard with trunc for openvibe-applications-designer

openvibe :
 + base      : added generic parameter and configurable interface
 + base      : added new basic objects such as stimulation sets, matrices, and memory buffers
 + plugins   : added new plugin family : algorithm
 + algorithm : added the algorithm manager and its components which takes care of algorithm plugins
 + log       : added log level none and log level important warning
 + log       : added per log listener level activation control
 + log       : added boolean log support
 + player    : added current time to the player context
 + player    : added higher level buffer access to BoxIO' input and output chunks
 + type      : added type id log level
 * base      : partially reimplemented CString
 * base      : reorganised algorithm manager API to clarify inputs/outpus and triggers
 * base      : modified *Dimmension* to *Dimension* (spelling mistake)

openvibe-kernel :
 + base      : added generic parameter and configurable interface
 + base      : added several basic parameter types
 + algorithm : added the algorithm manager and its components which takes care of algorithm plugins
 + log       : added log level none and log level important warning
 + log       : added per log listener level activation control
 + log       : added boolean log support (translates into "true" and "false" strings)
 + player    : added current time to the player context
 + player    : added higher level buffer access to BoxIO' input and output chunks
 + plugin    : added per plugin family contruction functions to make this phase easier and more readable
 + type      : added type id log level
 * base      : partially reimplemented CString
 * algorithm : reorganised algorithm manager API to clarify inputs/outpus and triggers
 * log       : enhanced several output format
 * player    : replaced CBuffer class with CMemoryBuffer and IMemoryBuffer interface so it can be easily sent to box algorithms
 * player    : slightly modified delay computation and output to provide easier reading
 * player    : now takes variable clock frequency into account
 * player    : player context now proposes an interface to the IAlgorithmManager
 * type      : added integer value assumption when enumeration name is not found
 * type      : moved basic type registration to the kernel context part better than the type manager construction
 - tools     : removed TBoxIO and TBox proxies, developpers should now use bridge functions

openvibe-toolkit :
 + added TAlgorithm
 + added stimulation duration
 + added several matrix manipulation tools (header copy, content copy and complete copy)
 * modified TBoxAlgorithm to offer direct context object interface
 * modified sex to gender
 * corrected bugs in reader / writer callbacks (most of them in the spectrum part)
 * modified *Dimmension* to *Dimension* (spelling mistake)

openvibe-plugins-samples :
 + added an addition algorithm and its test box

openvibe-plugins-stream-codecs :
 + added stream encoders and decoders in the form of algorithm
 + added test boxes

openvibe-plugins-simple-visualisation :
 * minor changes to make this plugin family compile correctly (mostly namespace changes)

openvibe-applications-designer :
 + enhanced and corrected several bugs on the filename setting type
 + added algorithm tab so to be able to view all the registered algorithms
 * modified runtime buttons order and behavior (being insensitive when needed)


git-svn-id: svn://scm.gforge.inria.fr/svn/openvibe@872 c330d7e9-fc0c-0410-a5b3-fd85c6f5aa8f
parent d275ed00
......@@ -189,6 +189,7 @@ void CDesignerVisualisation::init(std::string guiFile)
m_pDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(m_pDialog), 600, 400);
gtk_window_set_title(GTK_WINDOW(m_pDialog), "Window Manager");
gtk_signal_connect(GTK_OBJECT(m_pDialog), "configure_event", G_CALLBACK(configure_event_cb), this);
#ifdef HANDLE_MIN_MAX_EVENTS
gtk_signal_connect(GTK_OBJECT(m_pDialog), "window_state_event", G_CALLBACK(window_state_event_cb), this);
......
......@@ -51,9 +51,10 @@ static void scenario_drawing_area_drag_data_received_cb(::GtkWidget* pWidget, ::
{
static_cast<CInterfacedScenario*>(pUserData)->scenarioDrawingAreaDragDataReceivedCB(pDragContext, iX, iY, pSelectionData, uiInfo, uiT);
}
static void scenario_drawing_area_motion_notify_cb(::GtkWidget* pWidget, ::GdkEventMotion* pEvent, gpointer pUserData)
static gboolean scenario_drawing_area_motion_notify_cb(::GtkWidget* pWidget, ::GdkEventMotion* pEvent, gpointer pUserData)
{
static_cast<CInterfacedScenario*>(pUserData)->scenarioDrawingAreaMotionNotifyCB(pWidget, pEvent);
return FALSE;
}
static void scenario_drawing_area_button_pressed_cb(::GtkWidget* pWidget, ::GdkEventButton* pEvent, gpointer pUserData)
{
......@@ -84,6 +85,7 @@ void menuitem_cb(::GtkMenuItem* pMenuItem, gpointer pUserData)
,m_rKernel(rKernel)
,m_rScenario(rScenario)
,m_pPlayer(NULL)
,m_bIsPaused(false)
,m_rNotebook(rNotebook)
,m_pVisualisationTree(NULL)
,m_pDesignerVisualisation(NULL)
......@@ -143,7 +145,7 @@ void menuitem_cb(::GtkMenuItem* pMenuItem, gpointer pUserData)
CIdentifier l_oIdentifier = l_pBox->getAlgorithmClassIdentifier();
const Plugins::IPluginObjectDesc* l_pPOD = m_rKernel.getContext()->getPluginManager().getPluginObjectDescCreating(l_oIdentifier);
if(l_pPOD->hasFunctionality(OpenViBE::Plugins::PluginFunctionality_Visualization))
if(l_pPOD->hasFunctionality(OpenViBE::Kernel::PluginFunctionality_Visualization))
{
CIdentifier l_oIdentifier;
m_pVisualisationTree->addVisualisationWidget(
......@@ -393,6 +395,15 @@ void menuitem_cb(::GtkMenuItem* pMenuItem, gpointer pUserData)
}
}
/*
::GdkPixbuf* l_pPixbuf=gtk_widget_render_icon(l_pWidget, GTK_STOCK_EXECUTE, GTK_ICON_SIZE_SMALL_TOOLBAR, "openvibe");
if(l_pPixbuf)
{
gdk_draw_pixbuf(l_pWidget->window, l_pDrawGC, l_pPixbuf, 0, 0, 10, 10, 64, 64, GDK_RGB_DITHER_NONE, 0, 0);
g_object_unref(l_pPixbuf);
}
*/
::PangoContext* l_pPangoContext=NULL;
::PangoLayout* l_pPangoLayout=NULL;
l_pPangoContext=gtk_widget_get_pango_context(l_pWidget);
......@@ -625,7 +636,7 @@ void menuitem_cb(::GtkMenuItem* pMenuItem, gpointer pUserData)
const Plugins::IPluginObjectDesc* l_pPOD = m_rKernel.getContext()->getPluginManager().getPluginObjectDescCreating(l_oId);
//if a visualisation box was dropped, add it in window manager
if(l_pPOD->hasFunctionality(OpenViBE::Plugins::PluginFunctionality_Visualization))
if(l_pPOD->hasFunctionality(OpenViBE::Kernel::PluginFunctionality_Visualization))
{
//generate a unique name so that it can be identified unambiguously
CString l_oBoxName;
......@@ -681,7 +692,7 @@ void menuitem_cb(::GtkMenuItem* pMenuItem, gpointer pUserData)
l_sType=CString("[")+l_sType+CString("]");
gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(m_pGladeTooltip, "label_name_content")), l_sName);
gtk_label_set_text(GTK_LABEL(glade_xml_get_widget(m_pGladeTooltip, "label_type_content")), l_sType);
gtk_window_move(GTK_WINDOW(l_pTooltip), (gint)pEvent->x_root, (gint)pEvent->y_root+20);
gtk_window_move(GTK_WINDOW(l_pTooltip), (gint)pEvent->x_root, (gint)pEvent->y_root+40);
gtk_widget_show(l_pTooltip);
}
}
......
......@@ -62,6 +62,7 @@ namespace OpenViBEDesigner
OpenViBE::Kernel::IKernel& m_rKernel;
OpenViBE::Kernel::IScenario& m_rScenario;
OpenViBE::Kernel::IPlayer* m_pPlayer;
OpenViBE::boolean m_bIsPaused;
::GtkNotebook& m_rNotebook;
OpenViBE::Kernel::IVisualisationTree* m_pVisualisationTree;
OpenViBEDesigner::CDesignerVisualisation* m_pDesignerVisualisation;
......
......@@ -11,11 +11,48 @@ using namespace std;
// ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
static void getValueBitMaskCB(::GtkWidget* pWidget, gpointer pUserData)
static void collect_widget_cb(::GtkWidget* pWidget, gpointer pUserData)
{
static_cast< vector< ::GtkWidget* > *>(pUserData)->push_back(pWidget);
}
static void on_button_setting_filename_browse_pressed(::GtkButton* pButton, gpointer pUserData)
{
vector< ::GtkWidget* > l_vWidget;
gtk_container_foreach(GTK_CONTAINER(gtk_widget_get_parent(GTK_WIDGET(pButton))), collect_widget_cb, &l_vWidget);
::GtkEntry* l_pWidget=GTK_ENTRY(l_vWidget[0]);
::GtkWidget* l_pWidgetDialogOpen=gtk_file_chooser_dialog_new(
"Select file to open...",
NULL,
GTK_FILE_CHOOSER_ACTION_SAVE,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
const char* l_sInitialFileName=gtk_entry_get_text(l_pWidget);
if(g_path_is_absolute(l_sInitialFileName))
{
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(l_pWidgetDialogOpen), l_sInitialFileName);
}
else
{
char* l_sFullPath=g_build_filename(g_get_current_dir(), l_sInitialFileName, NULL);
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(l_pWidgetDialogOpen), l_sFullPath);
g_free(l_sFullPath);
}
gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(l_pWidgetDialogOpen), false);
if(gtk_dialog_run(GTK_DIALOG(l_pWidgetDialogOpen))==GTK_RESPONSE_ACCEPT)
{
char* l_sFileName=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(l_pWidgetDialogOpen));
gtk_entry_set_text(l_pWidget, l_sFileName);
g_free(l_sFileName);
}
gtk_widget_destroy(l_pWidgetDialogOpen);
}
// ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
CSettingEditor::CSettingEditor(IKernel& rKernel, IBox& rBox, const char* sGUIFilename)
......@@ -122,7 +159,7 @@ string CSettingEditor::getSettingWidgetName(const CIdentifier& rTypeIdentifier)
if(rTypeIdentifier==OV_TypeId_Integer) return "spin_button_setting_integer";
if(rTypeIdentifier==OV_TypeId_Float) return "spin_button_setting_float";
if(rTypeIdentifier==OV_TypeId_String) return "entry_setting_string";
if(rTypeIdentifier==OV_TypeId_Filename) return "file_chooser_button_setting_filename";
if(rTypeIdentifier==OV_TypeId_Filename) return "hbox_setting_filename";
if(m_rKernel.getContext()->getTypeManager().isEnumeration(rTypeIdentifier)) return "combobox_setting_enumeration";
if(m_rKernel.getContext()->getTypeManager().isBitMask(rTypeIdentifier)) return "table_setting_bitmask";
return "entry_setting_string";
......@@ -175,8 +212,10 @@ CString CSettingEditor::getValueString(::GtkWidget* pWidget)
CString CSettingEditor::getValueFilename(::GtkWidget* pWidget)
{
::GtkFileChooser* l_pWidget=GTK_FILE_CHOOSER(pWidget);
return CString(gtk_file_chooser_get_filename(l_pWidget));
vector< ::GtkWidget* > l_vWidget;
gtk_container_foreach(GTK_CONTAINER(pWidget), collect_widget_cb, &l_vWidget);
::GtkEntry* l_pWidget=GTK_ENTRY(l_vWidget[0]);
return CString(gtk_entry_get_text(l_pWidget));
}
CString CSettingEditor::getValueEnumeration(const CIdentifier& rTypeIdentifier, ::GtkWidget* pWidget)
......@@ -189,10 +228,9 @@ CString CSettingEditor::getValueEnumeration(const CIdentifier& rTypeIdentifier,
CString CSettingEditor::getValueBitMask(const CIdentifier& rTypeIdentifier, ::GtkWidget* pWidget)
{
::GtkTable* l_pBitMaskTable=GTK_TABLE(pWidget);
string l_sResult;
vector< ::GtkWidget* > l_vWidget;
gtk_container_foreach(GTK_CONTAINER(l_pBitMaskTable), getValueBitMaskCB, &l_vWidget);
gtk_container_foreach(GTK_CONTAINER(pWidget), collect_widget_cb, &l_vWidget);
string l_sResult;
for(unsigned int i=0; i<l_vWidget.size(); i++)
{
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(l_vWidget[i])))
......@@ -263,8 +301,13 @@ void CSettingEditor::setValueString(::GtkWidget* pWidget, const CString& rValue)
void CSettingEditor::setValueFilename(::GtkWidget* pWidget, const CString& rValue)
{
::GtkFileChooser* l_pWidget=GTK_FILE_CHOOSER(pWidget);
gtk_file_chooser_set_filename(l_pWidget, rValue);
vector< ::GtkWidget* > l_vWidget;
gtk_container_foreach(GTK_CONTAINER(pWidget), collect_widget_cb, &l_vWidget);
::GtkEntry* l_pWidget=GTK_ENTRY(l_vWidget[0]);
g_signal_connect(G_OBJECT(l_vWidget[1]), "clicked", G_CALLBACK(on_button_setting_filename_browse_pressed), NULL);
gtk_entry_set_text(l_pWidget, rValue);
}
void CSettingEditor::setValueEnumeration(const CIdentifier& rTypeIdentifier, ::GtkWidget* pWidget, const CString& rValue)
......
......@@ -24,11 +24,11 @@ namespace OpenViBEDesigner
{
enum
{
BoxAlgorithm_StringName,
BoxAlgorithm_StringShortDescription,
BoxAlgorithm_StringIdentifier,
BoxAlgorithm_StringStockIcon,
BoxAlgorithm_BooleanIsPlugin,
Resource_StringName,
Resource_StringShortDescription,
Resource_StringIdentifier,
Resource_StringStockIcon,
Resource_BooleanIsPlugin,
};
enum
......
#ifndef __OpenViBEKernel_Kernel_CAlgorithm_H__
#define __OpenViBEKernel_Kernel_CAlgorithm_H__
#include "../ovkTKernelObject.h"
#include <map>
namespace OpenViBE
{
namespace Kernel
{
class CAlgorithm : virtual 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::boolean addInputParameter(
const OpenViBE::CIdentifier& rInputParameterIdentifier,
const OpenViBE::CString& sInputName,
const OpenViBE::Kernel::EParameterType eParameterType);
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);
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::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::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 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)
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;
}
ILogManager& CAlgorithmContext::getLogManager(void)
{
return *m_pLogManager;
}
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 : virtual 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::ILogManager& getLogManager(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++)
{
delete itAlgorithm->second.second;
delete itAlgorithm->second.first;
}
}
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)
{
return OV_UndefinedIdentifier;
}
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())
{
return false;
}
delete itAlgorithm->second.second;
delete itAlgorithm->second.first;
m_vAlgorithm.erase(itAlgorithm);
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)
{
delete itAlgorithm->second.second;
delete itAlgorithm->second.first;
m_vAlgorithm.erase(itAlgorithm);
return true;
}
}
return false;
}
IAlgorithmProxy& CAlgorithmManager::getAlgorithm(
const CIdentifier& rAlgorithmIdentifier)
{
map < CIdentifier, pair < CAlgorithm*, CAlgorithmProxy* > >::const_iterator itAlgorithm;
itAlgorithm=m_vAlgorithm.find(rAlgorithmIdentifier);
if(itAlgorithm==m_vAlgorithm.end())
{
log() << LogLevel_Fatal << "Algorithm " << rAlgorithmIdentifier << " does not exist !\n";
}
return *itAlgorithm->second.second;
}
CIdentifier CAlgorithmManager::getNextAlgorithmIdentifier(
const CIdentifier& rPreviousIdentifier) const
{
map < CIdentifier, pair < CAlgorithm*, CAlgorithmProxy* > >::const_iterator itAlgorithm=m_vAlgorithm.begin();
if(rPreviousIdentifier==OV_UndefinedIdentifier)
{
itAlgorithm=m_vAlgorithm.begin();