This commit is contained in:
2021-10-14 13:47:35 +02:00
commit 6625a8dfaa
4026 changed files with 844291 additions and 0 deletions
@@ -0,0 +1,80 @@
PROJECT(openvibe-toolkit)
OV_ADD_THIS_TO_PROJECT_LIST()
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})
# Command to generate cpp compliant stimulation files from text file
# Creating output directories is mandatory as it is not handled by ADD_CUSTOM_COMMAND
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/toolkit)
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/src)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/toolkit/ovtk_stimulations.h ${CMAKE_CURRENT_BINARY_DIR}/src/ovtk_stimulations.cpp
DEPENDS openvibe-stimulation-generator ${CMAKE_CURRENT_SOURCE_DIR}/share/stimulation_list.txt
COMMAND openvibe-stimulation-generator
--cpp
${CMAKE_CURRENT_SOURCE_DIR}/share/stimulation_list.txt
${CMAKE_CURRENT_BINARY_DIR}/include/toolkit/ovtk_stimulations.h
${CMAKE_CURRENT_BINARY_DIR}/src/ovtk_stimulations.cpp
COMMENT "Generating stimulation sources..." )
# ADD_CUSTOM_TARGET will automatically trigger the command defined above
# as it depends on its outputs
ADD_CUSTOM_TARGET(openvibe-generate-stimulation-file
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/include/toolkit/ovtk_stimulations.h ${CMAKE_CURRENT_BINARY_DIR}/src/ovtk_stimulations.cpp)
FILE(GLOB_RECURSE SRC_FILES src/*.cpp src/*.h src/*.inl src/*.hpp include/*.h)
INCLUDE("FindSourceRCProperties")
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/algorithms/scenario-io)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/algorithms/classification)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/deprecated/writer)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/deprecated/reader)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/training)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/toolkit/tools)
# add binary directory to includes as it contains generated stimulation header
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include/)
ADD_LIBRARY(${PROJECT_NAME} SHARED
${SRC_FILES}
${CMAKE_CURRENT_BINARY_DIR}/include/toolkit/ovtk_stimulations.h
${CMAKE_CURRENT_BINARY_DIR}/src/ovtk_stimulations.cpp
)
ADD_DEPENDENCIES(${PROJECT_NAME} openvibe-generate-stimulation-file)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
FOLDER ${KERNEL_FOLDER}
COMPILE_FLAGS "-DOVTK_Exports -DOVTK_Shared")
# ---------------------------------
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBECommon")
INCLUDE("FindOpenViBEModuleEBML")
INCLUDE("FindOpenViBEModuleXML")
INCLUDE("FindOpenViBEModuleFS")
INCLUDE("FindThirdPartyBoost_FileSystem")
# ---------------------------------
# Target macros
# Defines target operating system, architecture and compiler
# ---------------------------------
SET_BUILD_PLATFORM()
# -----------------------------
# Install files
# -----------------------------
INSTALL(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${DIST_BINDIR}
LIBRARY DESTINATION ${DIST_LIBDIR}
ARCHIVE DESTINATION ${DIST_LIBDIR})
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION ${DIST_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
INSTALL(DIRECTORY share/ DESTINATION ${DIST_DATADIR}/openvibe/toolkit PATTERN "*-base" EXCLUDE)
@@ -0,0 +1,105 @@
#pragma once
#include <openvibe/ov_all.h>
#include "../../ovtk_defines.h"
#include "../../ovtkIVector.h"
#include "../../ovtkIFeatureVector.h"
#include "../../ovtkIFeatureVectorSet.h"
#include "../ovtkTAlgorithm.h"
#include <xml/IXMLNode.h>
#define OVTK_ClassId_Algorithm_Classifier OpenViBE::CIdentifier(0x3B910935, 0xE4DBACC4)
#define OVTK_ClassId_Algorithm_ClassifierDesc OpenViBE::CIdentifier(0xFDB84F2F, 0x2F5C510D)
#define OVTK_Algorithm_Classifier_InputParameterId_FeatureVector OpenViBE::CIdentifier(0x6D69BF98, 0x1EB9EE66) // Single vector to classify
#define OVTK_Algorithm_Classifier_InputParameterId_FeatureVectorSet OpenViBE::CIdentifier(0x27C05927, 0x5DE9103A) // Training set
#define OVTK_Algorithm_Classifier_InputParameterId_Config OpenViBE::CIdentifier(0xA705428E, 0x5BB1CADD) // The model
#define OVTK_Algorithm_Classifier_InputParameterId_NClasses OpenViBE::CIdentifier(0x1B95825A, 0x24F2E949)
#define OVTK_Algorithm_Classifier_InputParameterId_ExtraParameter OpenViBE::CIdentifier(0x42AD6BE3, 0xF483DE3F) // Params specific to classifier type
#define OVTK_Algorithm_Classifier_OutputParameterId_Class OpenViBE::CIdentifier(0x8A39A7EA, 0xF2EE45C4)
#define OVTK_Algorithm_Classifier_OutputParameterId_ClassificationValues OpenViBE::CIdentifier(0xDA77D7E4, 0x766B48EA)
#define OVTK_Algorithm_Classifier_OutputParameterId_ProbabilityValues OpenViBE::CIdentifier(0xDA77D7E4, 0x766B48EB)
#define OVTK_Algorithm_Classifier_OutputParameterId_Config OpenViBE::CIdentifier(0x30590936, 0x61CE5971)
#define OVTK_Algorithm_Classifier_InputTriggerId_Train OpenViBE::CIdentifier(0x34684752, 0x78A46DE2)
#define OVTK_Algorithm_Classifier_InputTriggerId_Classify OpenViBE::CIdentifier(0x843A87D8, 0x566E85A1)
#define OVTK_Algorithm_Classifier_InputTriggerId_SaveConfig OpenViBE::CIdentifier(0x79750528, 0x6CC85FC1)
#define OVTK_Algorithm_Classifier_InputTriggerId_LoadConfig OpenViBE::CIdentifier(0xF346BBE0, 0xADAFC735)
#define OVTK_Algorithm_Classifier_OutputTriggerId_Success OpenViBE::CIdentifier(0x24FAB755, 0x78868782)
#define OVTK_Algorithm_Classifier_OutputTriggerId_Failed OpenViBE::CIdentifier(0x6E72B255, 0x317FAA04)
namespace OpenViBE {
namespace Toolkit {
class OVTK_API CAlgorithmClassifier : public TAlgorithm<Plugins::IAlgorithm>
{
public:
bool initialize() override;
bool uninitialize() override;
void release() override { delete this; }
bool process() override;
virtual bool train(const IFeatureVectorSet& featureVectorSet) = 0;
virtual bool classify(const IFeatureVector& featureVector, double& estimatedClass, IVector& distanceValue, IVector& probabilityValue) = 0;
virtual XML::IXMLNode* saveConfig() = 0;
virtual bool loadConfig(XML::IXMLNode* configurationRoot) = 0;
virtual size_t getNProbabilities() = 0;
virtual size_t getNDistances() = 0;
_IsDerivedFromClass_(TAlgorithm<Plugins::IAlgorithm>, OVTK_ClassId_Algorithm_Classifier)
protected:
bool initializeExtraParameterMechanism();
bool uninitializeExtraParameterMechanism();
uint64_t getUInt64Parameter(const CIdentifier& parameterID);
int64_t getInt64Parameter(const CIdentifier& parameterID);
double getDoubleParameter(const CIdentifier& parameterID);
bool getBooleanParameter(const CIdentifier& parameterID);
CString* getCStringParameter(const CIdentifier& parameterID);
uint64_t getEnumerationParameter(const CIdentifier& parameterID, const CIdentifier& enumerationIdentifier);
private:
CString& getParameterValue(const CIdentifier& parameterID) const;
static void setMatrixOutputDimension(Kernel::TParameterHandler<CMatrix*>& matrix, size_t length);
Kernel::IAlgorithmProxy* m_AlgorithmProxy = nullptr;
void* m_ExtraParametersMap = nullptr;
};
class OVTK_API CAlgorithmClassifierDesc : public Plugins::IAlgorithmDesc
{
public:
bool getAlgorithmPrototype(Kernel::IAlgorithmProto& algorithmPrototype) const override
{
algorithmPrototype.addInputParameter(OVTK_Algorithm_Classifier_InputParameterId_FeatureVector, "Feature vector", Kernel::ParameterType_Matrix);
algorithmPrototype.addInputParameter(OVTK_Algorithm_Classifier_InputParameterId_FeatureVectorSet, "Feature vector set", Kernel::ParameterType_Matrix);
algorithmPrototype.addInputParameter(OVTK_Algorithm_Classifier_InputParameterId_Config, "Configuration", Kernel::ParameterType_Pointer);
algorithmPrototype.addInputParameter(OVTK_Algorithm_Classifier_InputParameterId_NClasses, "Number of classes", Kernel::ParameterType_UInteger);
algorithmPrototype.addInputParameter(OVTK_Algorithm_Classifier_InputParameterId_ExtraParameter, "Extra parameter", Kernel::ParameterType_Pointer);
algorithmPrototype.addOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_Class, "Class", Kernel::ParameterType_Float);
algorithmPrototype.addOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_ClassificationValues, "Hyperplane distance", Kernel::ParameterType_Matrix);
algorithmPrototype.addOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_ProbabilityValues, "Probability values", Kernel::ParameterType_Matrix);
algorithmPrototype.addOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_Config, "Configuration", Kernel::ParameterType_Pointer);
algorithmPrototype.addInputTrigger(OVTK_Algorithm_Classifier_InputTriggerId_Train, "Train");
algorithmPrototype.addInputTrigger(OVTK_Algorithm_Classifier_InputTriggerId_Classify, "Classify");
algorithmPrototype.addInputTrigger(OVTK_Algorithm_Classifier_InputTriggerId_LoadConfig, "Load configuration");
algorithmPrototype.addInputTrigger(OVTK_Algorithm_Classifier_InputTriggerId_SaveConfig, "Save configuration");
algorithmPrototype.addOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Success, "Success");
algorithmPrototype.addOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, "Failed");
return true;
}
_IsDerivedFromClass_(Plugins::IAlgorithmDesc, OVTK_ClassId_Algorithm_ClassifierDesc)
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,45 @@
#pragma once
#include "../ovtkTAlgorithm.h"
#include "../../ovtkIFeatureVectorSet.h"
#define OVTK_ClassId_Algorithm_ClassifierTrainer OpenViBE::CIdentifier(0x5ABC21E6, 0x3C3D349B)
#define OVTK_ClassId_Algorithm_ClassifierTrainerDesc OpenViBE::CIdentifier(0x56DD6401, 0x07033341)
#define OVTK_Algorithm_ClassifierTrainer_InputParameterId_FeatureVectorSet OpenViBE::CIdentifier(0x27C05927, 0x5DE9103A)
#define OVTK_Algorithm_ClassifierTrainer_OutputParameterId_Config OpenViBE::CIdentifier(0x30590936, 0x61CE5971)
#define OVTK_Algorithm_ClassifierTrainer_InputTriggerId_Train OpenViBE::CIdentifier(0x34684752, 0x78A46DE2)
#define OVTK_Algorithm_ClassifierTrainer_InputTriggerId_SaveConfig OpenViBE::CIdentifier(0x79750528, 0x6CC85FC1)
#define OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Success OpenViBE::CIdentifier(0x7B8C0EFF, 0x26224D6B)
#define OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Failed OpenViBE::CIdentifier(0x31B97C83, 0x59015D0E)
namespace OpenViBE {
namespace Toolkit {
class OVTK_API CAlgorithmClassifierTrainer : public TAlgorithm<Plugins::IAlgorithm>
{
public:
void release() override { delete this; }
bool process() override;
virtual bool train(const IFeatureVectorSet& dataset) = 0;
virtual bool saveConfig(IMemoryBuffer& buffer) = 0;
_IsDerivedFromClass_(TAlgorithm < Plugins::IAlgorithm >, OVTK_ClassId_Algorithm_ClassifierTrainer)
};
class OVTK_API CAlgorithmClassifierTrainerDesc : public Plugins::IAlgorithmDesc
{
public:
bool getAlgorithmPrototype(Kernel::IAlgorithmProto& prototype) const override
{
prototype.addInputParameter(OVTK_Algorithm_ClassifierTrainer_InputParameterId_FeatureVectorSet, "Feature vector set", Kernel::ParameterType_Matrix);
prototype.addOutputParameter(OVTK_Algorithm_ClassifierTrainer_OutputParameterId_Config, "Configuration", Kernel::ParameterType_MemoryBuffer);
prototype.addInputTrigger(OVTK_Algorithm_ClassifierTrainer_InputTriggerId_Train, "Train");
prototype.addInputTrigger(OVTK_Algorithm_ClassifierTrainer_InputTriggerId_SaveConfig, "Save configuration");
prototype.addOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Success, "Success");
prototype.addOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Failed, "Failed");
return true;
}
_IsDerivedFromClass_(Plugins::IAlgorithmDesc, OVTK_ClassId_Algorithm_ClassifierTrainerDesc)
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,60 @@
#pragma once
#include "../ovtkTAlgorithm.h"
#include "../../ovtkIVector.h"
#include "../../ovtkIFeatureVector.h"
#include "../../ovtkIFeatureVectorSet.h"
#include "ovtkCAlgorithmClassifier.h"
#define OVTK_ClassId_Algorithm_PairingStrategy OpenViBE::CIdentifier(0xFD3CB444, 0x58F00765)
#define OVTK_ClassId_Algorithm_PairingStrategyDesc OpenViBE::CIdentifier(0x4341B8D6, 0xC65B7BBB)
#define OVTK_Algorithm_PairingStrategy_InputParameterId_SubClassifierAlgorithm OpenViBE::CIdentifier(0xD9E60DF9, 0x20EC8FC9)
#define OVTK_Algorithm_PairingStrategy_InputTriggerId_DesignArchitecture OpenViBE::CIdentifier(0x784A9CDF, 0xA41C27F8)
typedef int (*fClassifierComparison)(OpenViBE::CMatrix&, OpenViBE::CMatrix&);
namespace OpenViBE {
namespace Toolkit {
extern OVTK_API void registerClassificationComparisonFunction(const CIdentifier& classID, fClassifierComparison comparision);
extern OVTK_API fClassifierComparison getClassificationComparisonFunction(const CIdentifier& classID);
class OVTK_API CAlgorithmPairingStrategy : public CAlgorithmClassifier
{
public:
bool process() override;
void release() override { delete this; }
virtual bool designArchitecture(const CIdentifier& id, const size_t nClass) = 0;
bool train(const IFeatureVectorSet& rFeatureVectorSet) override = 0;
bool classify(const IFeatureVector& rFeatureVector, double& classId, IVector& distance, IVector& probability) override = 0;
XML::IXMLNode* saveConfig() override = 0;
bool loadConfig(XML::IXMLNode* pConfiguratioNode) override = 0;
_IsDerivedFromClass_(CAlgorithmClassifier, OVTK_ClassId_Algorithm_PairingStrategy)
size_t getNProbabilities() override = 0;
size_t getNDistances() override = 0;
protected:
// std::vector <double> m_classes;
//The vector will be use when the user will be able to specify class label
CIdentifier m_subClassifierAlgorithmID = CIdentifier::undefined();
};
class OVTK_API CAlgorithmPairingStrategyDesc : public CAlgorithmClassifierDesc
{
public:
bool getAlgorithmPrototype(Kernel::IAlgorithmProto& prototype) const override
{
CAlgorithmClassifierDesc::getAlgorithmPrototype(prototype);
prototype.addInputParameter(
OVTK_Algorithm_PairingStrategy_InputParameterId_SubClassifierAlgorithm, "Algorithm Identifier", Kernel::ParameterType_Identifier);
prototype.addInputTrigger(OVTK_Algorithm_PairingStrategy_InputTriggerId_DesignArchitecture, "Design Architecture");
return true;
}
_IsDerivedFromClass_(CAlgorithmClassifierDesc, OVTK_ClassId_Algorithm_PairingStrategyDesc)
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,97 @@
#pragma once
#include "../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
template <class TAlgorithmParentClass>
class TAlgorithm : public TAlgorithmParentClass
{
public:
TAlgorithm() { }
bool initialize(Kernel::IAlgorithmContext& algorithmCtx) override
{
CScopedAlgorithm scopedAlgorithm(m_algorithmCtx, &algorithmCtx);
return initialize();
}
bool uninitialize(Kernel::IAlgorithmContext& algorithmCtx) override
{
CScopedAlgorithm scopedAlgorithm(m_algorithmCtx, &algorithmCtx);
return uninitialize();
}
bool process(Kernel::IAlgorithmContext& algorithmCtx) override
{
CScopedAlgorithm scopedAlgorithm(m_algorithmCtx, &algorithmCtx);
return process();
}
// ====================================================================================================================================
virtual bool initialize() { return true; }
virtual bool uninitialize() { return true; }
virtual bool process() = 0;
// ====================================================================================================================================
virtual Kernel::IAlgorithmContext& getAlgorithmContext()
{
return *m_algorithmCtx; // should never be null
}
protected:
virtual Kernel::IConfigurationManager& getConfigurationManager() { return m_algorithmCtx->getConfigurationManager(); } // should never be null
virtual Kernel::IAlgorithmManager& getAlgorithmManager() { return m_algorithmCtx->getAlgorithmManager(); } // should never be null
virtual Kernel::ILogManager& getLogManager() { return m_algorithmCtx->getLogManager(); } // should never be null
virtual Kernel::IErrorManager& getErrorManager() { return m_algorithmCtx->getErrorManager(); } // should never be null
virtual Kernel::ITypeManager& getTypeManager() { return m_algorithmCtx->getTypeManager(); } // should never be null
virtual CIdentifier getNextInputParameterIdentifier(const CIdentifier& rPreviousInputParameterIdentifier) const
{
return m_algorithmCtx->getNextInputParameterIdentifier(rPreviousInputParameterIdentifier);
}
virtual Kernel::IParameter* getInputParameter(const CIdentifier& InputParameterID) { return m_algorithmCtx->getInputParameter(InputParameterID); }
virtual CIdentifier getNextOutputParameterIdentifier(const CIdentifier& rPreviousOutputParameterIdentifier) const
{
return m_algorithmCtx->getNextOutputParameterIdentifier(rPreviousOutputParameterIdentifier);
}
virtual Kernel::IParameter* getOutputParameter(const CIdentifier& outputParameterID) { return m_algorithmCtx->getOutputParameter(outputParameterID); }
virtual bool isInputTriggerActive(const CIdentifier& inputTriggerID) const { return m_algorithmCtx->isInputTriggerActive(inputTriggerID); }
virtual bool activateOutputTrigger(const CIdentifier& outputTriggerID, const bool bTriggerState)
{
return m_algorithmCtx->activateOutputTrigger(outputTriggerID, bTriggerState);
}
// ====================================================================================================================================
_IsDerivedFromClass_(TAlgorithmParentClass, OVTK_ClassId_)
private:
class CScopedAlgorithm final
{
public:
CScopedAlgorithm(Kernel::IAlgorithmContext*& algorithmCtxRef, Kernel::IAlgorithmContext* algorithmCtx)
: m_algorithmCtx(algorithmCtxRef) { m_algorithmCtx = algorithmCtx; }
~CScopedAlgorithm() { m_algorithmCtx = nullptr; }
protected:
Kernel::IAlgorithmContext*& m_algorithmCtx;
};
Kernel::IAlgorithmContext* m_algorithmCtx = nullptr;
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,29 @@
#pragma once
#include "../ovtkTAlgorithm.h"
#include "ovtk_scenario_io.h"
#include <openvibe/kernel/scenario/ovIAlgorithmScenarioExporter.h>
#define OVTK_ClassId_Algorithm_ScenarioExporter OpenViBE::CIdentifier(0x7C281FEA, 0x40B66277)
#define OVTK_ClassId_Algorithm_ScenarioExporterDesc OpenViBE::CIdentifier(0x49A9778E, 0x7BB377F9)
namespace OpenViBE {
namespace Toolkit {
class OVTK_API CAlgorithmScenarioExporter : public TAlgorithm<Plugins::IAlgorithmScenarioExporter>
{
public:
void release() override { delete this; }
bool process() override;
_IsDerivedFromClass_Final_(TAlgorithm<Plugins::IAlgorithmScenarioExporter>, OVTK_ClassId_Algorithm_ScenarioExporter)
};
class OVTK_API CAlgorithmScenarioExporterDesc : public Plugins::IAlgorithmScenarioExporterDesc
{
public:
_IsDerivedFromClass_(Plugins::IAlgorithmScenarioExporterDesc, OVTK_ClassId_Algorithm_ScenarioExporterDesc)
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,28 @@
#pragma once
#include "../ovtkTAlgorithm.h"
#include "ovtk_scenario_io.h"
#include <openvibe/kernel/scenario/ovIAlgorithmScenarioImporter.h>
#define OVP_ClassId_Algorithm_ScenarioImporter OpenViBE::CIdentifier(0x1EE72169, 0x2BF146C1)
#define OVP_ClassId_Algorithm_ScenarioImporterDesc OpenViBE::CIdentifier(0x503C0DDE, 0x5D4C6CB2)
namespace OpenViBE {
namespace Toolkit {
class OVTK_API CAlgorithmScenarioImporter : public TAlgorithm<Plugins::IAlgorithmScenarioImporter>
{
public:
void release() override { delete this; }
bool process() override;
_IsDerivedFromClass_(TAlgorithm<Plugins::IAlgorithmScenarioImporter>, OVP_ClassId_Algorithm_ScenarioImporter)
};
class OVTK_API CAlgorithmScenarioImporterDesc : public Plugins::IAlgorithmScenarioImporterDesc
{
public:
_IsDerivedFromClass_(Plugins::IAlgorithmScenarioImporterDesc, OVP_ClassId_Algorithm_ScenarioImporterDesc)
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,99 @@
#pragma once
#define OVTK_Algorithm_ScenarioExporter_NodeId_OpenViBEScenario OpenViBE::CIdentifier(0x1CD93114, 0x6A544E8C)
#define OVTK_Algorithm_ScenarioExporter_NodeId_FormatVersion OpenViBE::CIdentifier(0xB7818440, 0x928C3366)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Creator OpenViBE::CIdentifier(0x430C9234, 0x4825E245)
#define OVTK_Algorithm_ScenarioExporter_NodeId_CreatorVersion OpenViBE::CIdentifier(0x1B01311A, 0x2405842B)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Settings OpenViBE::CIdentifier(0x1B6A0E61, 0x34BC6357)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting OpenViBE::CIdentifier(0x54312696, 0x2FC005A4)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_ID OpenViBE::CIdentifier(0x1845EA8E, 0x424AC232)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_TypeID OpenViBE::CIdentifier(0x1881283E, 0x4E361232)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_Name OpenViBE::CIdentifier(0x444114FB, 0x0B4C574A)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_Value OpenViBE::CIdentifier(0x6D2B69EA, 0x74B95C99)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_DefaultValue OpenViBE::CIdentifier(0x29C51ACB, 0x494D5778)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Inputs OpenViBE::CIdentifier(0x0D7B4C71, 0x3B6F537F)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input OpenViBE::CIdentifier(0x62275FDD, 0x1F1E57E0)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_ID OpenViBE::CIdentifier(0xFC45833A, 0xEE785EA2)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_TypeID OpenViBE::CIdentifier(0x2AFF56A1, 0x4D2D03E3)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_Name OpenViBE::CIdentifier(0x3CA137F2, 0x60CB338E)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxID OpenViBE::CIdentifier(0x30780A0D, 0x03641BCC)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxInputIdx OpenViBE::CIdentifier(0x413A5131, 0x7BFA1941)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxInputID OpenViBE::CIdentifier(0x81AF5685, 0x188FEAD2)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Outputs OpenViBE::CIdentifier(0x3A4E3424, 0x3AD22EE5)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output OpenViBE::CIdentifier(0x4C481179, 0x0B4A1D5E)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_ID OpenViBE::CIdentifier(0x5366EAD8, 0xBB57B9AE)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_TypeID OpenViBE::CIdentifier(0x157E5B37, 0x142F4D94)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_Name OpenViBE::CIdentifier(0x2C6B06FD, 0x0973253F)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxID OpenViBE::CIdentifier(0x1F790DDB, 0x2E0A002C)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxOutputIdx OpenViBE::CIdentifier(0x53A515C8, 0x0B296360)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxOutputID OpenViBE::CIdentifier(0xAC286F77, 0x18F7E33A)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Boxes OpenViBE::CIdentifier(0x4BCB7EA2, 0x49B95B54)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box OpenViBE::CIdentifier(0xF7341CA6, 0x05DBB935)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_ID OpenViBE::CIdentifier(0x388E37B5, 0x3F471DB7)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Name OpenViBE::CIdentifier(0x5472B291, 0x51F94B43)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_AlgorithmClassIdD OpenViBE::CIdentifier(0x2CBBE45B, 0xD9385308)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Inputs OpenViBE::CIdentifier(0xB07E43FA, 0x3BFB5C41)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input OpenViBE::CIdentifier(0x7B149417, 0x39F0D7BC)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_ID OpenViBE::CIdentifier(0x15FF57E3, 0xAD458EF2)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_TypeID OpenViBE::CIdentifier(0xC7D436D2, 0x7C808FAD)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_Name OpenViBE::CIdentifier(0xA65B1B6D, 0x70799D8F)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Outputs OpenViBE::CIdentifier(0xD5CBFF2C, 0x349EED80)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output OpenViBE::CIdentifier(0x8FE44764, 0xB6E9EEDE)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_ID OpenViBE::CIdentifier(0x4538EF5A, 0xFA511347)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_TypeID OpenViBE::CIdentifier(0x7C3CEAC8, 0x55E5B85F)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_Name OpenViBE::CIdentifier(0x858B86C9, 0x8FDE0A88)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Settings OpenViBE::CIdentifier(0x456F426E, 0xD5F745C0)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting OpenViBE::CIdentifier(0x6D781687, 0xEC0697F0)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_ID OpenViBE::CIdentifier(0x45AF5442, 0xA46DA56B)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_TypeID OpenViBE::CIdentifier(0x4E025442, 0xF15A306B)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Name OpenViBE::CIdentifier(0xF653238C, 0xCF13CC1E)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_DefaultValue OpenViBE::CIdentifier(0x22B803B1, 0xB99EB29C)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Value OpenViBE::CIdentifier(0x4B157087, 0xA17AC752)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Modifiability OpenViBE::CIdentifier(0x7F87A192, 0x16534D27)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attributes OpenViBE::CIdentifier(0x5A512182, 0xEA975174)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute OpenViBE::CIdentifier(0xAAE1C0BA, 0x0CCB4F6E)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute_ID OpenViBE::CIdentifier(0xFDE975E7, 0x9EE828E5)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute_Value OpenViBE::CIdentifier(0x08700489, 0x15D4C296)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comments OpenViBE::CIdentifier(0x05FFFB9C, 0x0D3F72B9)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment OpenViBE::CIdentifier(0x8A90B4C7, 0x1B1F91C8)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment_ID OpenViBE::CIdentifier(0x5D5AC202, 0x8A8A2049)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Text OpenViBE::CIdentifier(0xE1FBD2D0, 0x62644098)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attributes OpenViBE::CIdentifier(0x03A34281, 0x49A94884)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute OpenViBE::CIdentifier(0xD1BE5B9E, 0x290F273E)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute_ID OpenViBE::CIdentifier(0x4A68A79B, 0x26590AC7)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute_Value OpenViBE::CIdentifier(0x1762575C, 0x234FCEA9)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Metadata OpenViBE::CIdentifier(0x5BD6509C, 0x3F85473B)
#define OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry OpenViBE::CIdentifier(0x9C2950A7, 0x109E0B28)
#define OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_ID OpenViBE::CIdentifier(0x85811583, 0x5242A4F3)
#define OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_Type OpenViBE::CIdentifier(0x596E48C6, 0xE408F6EA)
#define OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_Data OpenViBE::CIdentifier(0x95006E45, 0xA0E3D014)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Links OpenViBE::CIdentifier(0x5B4FF75F, 0x7FB1E0DA)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link OpenViBE::CIdentifier(0x7E290F90, 0xEB62C398)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_ID OpenViBE::CIdentifier(0x51FEC159, 0x0958BF76)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source OpenViBE::CIdentifier(0xD7E0F55E, 0x576625E3)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxID OpenViBE::CIdentifier(0x49A048C0, 0x564E3FF3)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputID OpenViBE::CIdentifier(0x458FAADC, 0xEED89711)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputIdx OpenViBE::CIdentifier(0x6C4C2561, 0x0C128F04)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target OpenViBE::CIdentifier(0x231E8241, 0x89F06614)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxID OpenViBE::CIdentifier(0xDB6D995F, 0xE514B76A)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputID OpenViBE::CIdentifier(0x56899E5F, 0xA5D9C658)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputIdx OpenViBE::CIdentifier(0x2DEDF2E1, 0x76778F6B)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attributes OpenViBE::CIdentifier(0x3B3700A0, 0x51159BB0)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute OpenViBE::CIdentifier(0xA1487B45, 0x88C442B6)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute_ID OpenViBE::CIdentifier(0x03710320, 0x0A550AE0)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute_Value OpenViBE::CIdentifier(0x3831E536, 0x6E0C9282)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attributes OpenViBE::CIdentifier(0x06B858A3, 0xE3F6B199)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute OpenViBE::CIdentifier(0x195DF0C2, 0x01071746)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute_ID OpenViBE::CIdentifier(0x66A99FF0, 0x402B6F19)
#define OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute_Value OpenViBE::CIdentifier(0xA4795600, 0x31AFDFB1)
@@ -0,0 +1,363 @@
#pragma once
#include "../ovtk_base.h"
#include <limits>
namespace OpenViBE {
namespace Toolkit {
template <class TBoxAlgorithmParentClass>
class TBoxAlgorithm : public TBoxAlgorithmParentClass
{
public:
TBoxAlgorithm() { }
// ====================================================================================================================================
private:
virtual uint64_t getClockFrequency(Kernel::IBoxAlgorithmContext& ctx)
{
CScopedBoxAlgorithm scopedBoxAlgorithm(m_boxAlgorithmCtx, &ctx);
return getClockFrequency();
}
virtual bool initialize(Kernel::IBoxAlgorithmContext& ctx)
{
CScopedBoxAlgorithm scopedBoxAlgorithm(m_boxAlgorithmCtx, &ctx);
return initialize();
}
virtual bool uninitialize(Kernel::IBoxAlgorithmContext& ctx)
{
CScopedBoxAlgorithm scopedBoxAlgorithm(m_boxAlgorithmCtx, &ctx);
return uninitialize();
}
virtual bool processClock(Kernel::IBoxAlgorithmContext& ctx, Kernel::CMessageClock& msg)
{
CScopedBoxAlgorithm scopedBoxAlgorithm(m_boxAlgorithmCtx, &ctx);
return processClock(msg);
}
virtual bool processInput(Kernel::IBoxAlgorithmContext& ctx, const size_t index)
{
CScopedBoxAlgorithm scopedBoxAlgorithm(m_boxAlgorithmCtx, &ctx);
return processInput(index);
}
virtual bool process(Kernel::IBoxAlgorithmContext& ctx)
{
CScopedBoxAlgorithm oScopedBoxAlgorithm(m_boxAlgorithmCtx, &ctx);
return process();
}
// ====================================================================================================================================
public:
virtual uint64_t getClockFrequency() { return 0; }
virtual bool initialize() { return true; }
virtual bool uninitialize() { return true; }
virtual bool processClock(Kernel::CMessageClock& /*msg*/) { return false; }
virtual bool processInput(const size_t /*index*/) { return false; }
virtual bool process() = 0;
// ====================================================================================================================================
virtual Kernel::IBoxAlgorithmContext* getBoxAlgorithmContext() { return m_boxAlgorithmCtx; }
// virtual Kernel::IBoxAlgorithmContext& getBoxAlgorithmContext() { return *m_boxAlgorithmCtx; } this one should replace !
virtual const Kernel::IBox& getStaticBoxContext() { return *m_boxAlgorithmCtx->getStaticBoxContext(); }
virtual Kernel::IBoxIO& getDynamicBoxContext() { return *m_boxAlgorithmCtx->getDynamicBoxContext(); }
virtual Kernel::IPlayerContext& getPlayerContext() { return *m_boxAlgorithmCtx->getPlayerContext(); }
virtual Kernel::IAlgorithmManager& getAlgorithmManager() { return getPlayerContext().getAlgorithmManager(); }
virtual Kernel::IConfigurationManager& getConfigurationManager() { return getPlayerContext().getConfigurationManager(); }
virtual Kernel::ILogManager& getLogManager() { return getPlayerContext().getLogManager(); }
virtual Kernel::IErrorManager& getErrorManager() { return getPlayerContext().getErrorManager(); }
virtual Kernel::IScenarioManager& getScenarioManager() { return getPlayerContext().getScenarioManager(); }
virtual Kernel::ITypeManager& getTypeManager() { return getPlayerContext().getTypeManager(); }
virtual bool canCreatePluginObject(const CIdentifier& pluginID) { return getPlayerContext().canCreatePluginObject(pluginID); }
virtual Plugins::IPluginObject* createPluginObject(const CIdentifier& pluginID) { return getPlayerContext().createPluginObject(pluginID); }
virtual bool releasePluginObject(Plugins::IPluginObject* pluginObject) { return getPlayerContext().releasePluginObject(pluginObject); }
// ====================================================================================================================================
virtual void appendOutputChunkData(const size_t outputIdx, const void* buffer, const size_t size)
{
Kernel::IBoxAlgorithmContext* context = this->getBoxAlgorithmContext();
if (context)
{
Kernel::IBoxIO* boxContext = context->getDynamicBoxContext();
if (boxContext) { boxContext->appendOutputChunkData(outputIdx, static_cast<const uint8_t*>(buffer), size); }
}
}
template <size_t TOutputIdx>
void appendOutputChunkData(const void* buffer, const size_t size) { appendOutputChunkData(TOutputIdx, buffer, size); }
_IsDerivedFromClass_(TBoxAlgorithmParentClass, OVTK_ClassId_)
protected:
class FSettingValueAutoCast
{
public:
FSettingValueAutoCast(Kernel::IBoxAlgorithmContext& ctx, const size_t index)
: m_logManager(ctx.getPlayerContext()->getLogManager()),
m_errorManager(ctx.getPlayerContext()->getErrorManager()),
m_typeManager(ctx.getPlayerContext()->getTypeManager()),
m_configManager(ctx.getPlayerContext()->getConfigurationManager())
{
ctx.getStaticBoxContext()->getSettingValue(index, m_settingValue);
ctx.getStaticBoxContext()->getSettingType(index, m_settingType);
}
FSettingValueAutoCast(Kernel::IBoxAlgorithmContext& ctx, const CString& name)
: m_logManager(ctx.getPlayerContext()->getLogManager()),
m_errorManager(ctx.getPlayerContext()->getErrorManager()),
m_typeManager(ctx.getPlayerContext()->getTypeManager()),
m_configManager(ctx.getPlayerContext()->getConfigurationManager())
{
ctx.getStaticBoxContext()->getSettingValue(name, m_settingValue);
ctx.getStaticBoxContext()->getInterfacorType(Kernel::EBoxInterfacorType::Setting, name, m_settingType);
}
FSettingValueAutoCast(Kernel::IBoxAlgorithmContext& ctx, const CIdentifier& identifier)
: m_logManager(ctx.getPlayerContext()->getLogManager()),
m_errorManager(ctx.getPlayerContext()->getErrorManager()),
m_typeManager(ctx.getPlayerContext()->getTypeManager()),
m_configManager(ctx.getPlayerContext()->getConfigurationManager())
{
ctx.getStaticBoxContext()->getSettingValue(identifier, m_settingValue);
ctx.getStaticBoxContext()->getInterfacorType(Kernel::EBoxInterfacorType::Setting, identifier, m_settingType);
}
operator uint32_t() const
{
double result;
const CString value = m_configManager.expand(m_settingValue);
OV_ERROR_UNLESS(m_typeManager.evaluateSettingValue(value, result),
"Could not expand numeric expression [" << m_settingValue << "] to unsigned integer 32bits.",
Kernel::ErrorType::BadParsing, std::numeric_limits<uint32_t>::max(), m_errorManager, m_logManager);
return uint32_t(result);
}
operator uint64_t() const
{
uint64_t stimId = std::numeric_limits<uint64_t>::max();
const CString value = m_configManager.expand(m_settingValue);
double result;
if (m_typeManager.isEnumeration(m_settingType))
{
stimId = m_typeManager.getEnumerationEntryValueFromName(m_settingType, value);
OV_ERROR_UNLESS(stimId != std::numeric_limits<uint64_t>::max(),
"Did not find an enumeration value for [" << m_typeManager.getTypeName(m_settingType) << "] = [" << m_settingValue <<
"]",
Kernel::ErrorType::BadParsing, std::numeric_limits<uint64_t>::max(), m_errorManager, m_logManager);
}
else if (m_typeManager.evaluateSettingValue(value, result)) { return uint64_t(result); }
// Seems like currently some plugins use FSettingValueAutoCast without knowing then setting type.
// In this case, to avoid to pollute the console with useless messages, throw a message only if the
// setting should be an integer.
OV_ERROR_UNLESS(stimId != std::numeric_limits<uint64_t>::max() || m_settingType != OV_TypeId_Integer,
"Could not expand numeric expression [" << m_settingValue << "] to unsigned integer 64bits.",
Kernel::ErrorType::BadParsing, std::numeric_limits<uint64_t>::max(), m_errorManager, m_logManager);
return stimId;
}
operator int() const
{
double res;
const CString value = m_configManager.expand(m_settingValue);
OV_ERROR_UNLESS(m_typeManager.evaluateSettingValue(value, res),
"Could not expand numeric expression [" << m_settingValue << "] to integer 32bits.",
Kernel::ErrorType::BadParsing, std::numeric_limits<int>::max(), m_errorManager, m_logManager);
return int(res);
}
operator int64_t() const
{
double res;
const CString value = m_configManager.expand(m_settingValue);
OV_ERROR_UNLESS(m_typeManager.evaluateSettingValue(value, res),
"Could not expand numeric expression [" << m_settingValue << "] to integer 64bits.",
Kernel::ErrorType::BadParsing, std::numeric_limits<int64_t>::max(), m_errorManager, m_logManager);
return int64_t(res);
}
operator double() const
{
double res;
const CString value = m_configManager.expand(m_settingValue);
OV_ERROR_UNLESS(m_typeManager.evaluateSettingValue(value, res),
"Could not expand numeric expression [" << m_settingValue << "] to double.",
Kernel::ErrorType::BadParsing, std::numeric_limits<double>::max(), m_errorManager, m_logManager);
return double(res);
}
operator bool() const { return m_configManager.expandAsBoolean(m_settingValue); }
operator CString() const { return m_configManager.expand(m_settingValue); }
private:
Kernel::ILogManager& m_logManager;
Kernel::IErrorManager& m_errorManager;
Kernel::ITypeManager& m_typeManager;
Kernel::IConfigurationManager& m_configManager;
CString m_settingValue;
CIdentifier m_settingType = CIdentifier::undefined();
};
private:
class CScopedBoxAlgorithm final
{
public:
CScopedBoxAlgorithm(Kernel::IBoxAlgorithmContext*& ctxRef, Kernel::IBoxAlgorithmContext* ctx)
: m_boxAlgorithmCtx(ctxRef) { m_boxAlgorithmCtx = ctx; }
~CScopedBoxAlgorithm() { m_boxAlgorithmCtx = nullptr; }
protected:
Kernel::IBoxAlgorithmContext*& m_boxAlgorithmCtx;
};
Kernel::IBoxAlgorithmContext* m_boxAlgorithmCtx = nullptr;
};
template <class TBoxListenerParentClass>
class TBoxListener : public TBoxListenerParentClass
{
public:
TBoxListener() { }
private:
virtual bool initialize(Kernel::IBoxListenerContext& ctx)
{
CScopedBoxListener scopedBoxListener(m_boxListenerCtx, &ctx);
return initialize();
}
virtual bool uninitialize(Kernel::IBoxListenerContext& ctx)
{
CScopedBoxListener scopedBoxListener(m_boxListenerCtx, &ctx);
return uninitialize();
}
virtual bool process(Kernel::IBoxListenerContext& ctx, const Kernel::EBoxModification eBoxModificationType)
{
CScopedBoxListener scopedBoxListener(m_boxListenerCtx, &ctx);
switch (eBoxModificationType)
{
case Kernel::EBoxModification::Initialized: return this->onInitialized(m_boxListenerCtx->getBox());
case Kernel::EBoxModification::DefaultInitialized: return this->onDefaultInitialized(m_boxListenerCtx->getBox());
case Kernel::EBoxModification::NameChanged: return this->onNameChanged(m_boxListenerCtx->getBox());
case Kernel::EBoxModification::IdentifierChanged: return this->onIdentifierChanged(m_boxListenerCtx->getBox());
case Kernel::EBoxModification::AlgorithmClassIdentifierChanged: return this->onAlgorithmClassIdentifierChanged(m_boxListenerCtx->getBox());
case Kernel::EBoxModification::InputConnected: return this->onInputConnected(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::InputDisconnected: return this->onInputDisconnected(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::InputAdded: return this->onInputAdded(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::InputRemoved: return this->onInputRemoved(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::InputTypeChanged: return this->onInputTypeChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::InputNameChanged: return this->onInputNameChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::OutputConnected: return this->onOutputConnected(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::OutputDisconnected: return this->onOutputDisconnected(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::OutputAdded: return this->onOutputAdded(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::OutputRemoved: return this->onOutputRemoved(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::OutputTypeChanged: return this->onOutputTypeChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::OutputNameChanged: return this->onOutputNameChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::SettingAdded: return this->onSettingAdded(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::SettingRemoved: return this->onSettingRemoved(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::SettingTypeChanged: return this->onSettingTypeChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::SettingNameChanged: return this->onSettingNameChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::SettingDefaultValueChanged: return this->onSettingDefaultValueChanged(
m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
case Kernel::EBoxModification::SettingValueChanged: return this->onSettingValueChanged(m_boxListenerCtx->getBox(), m_boxListenerCtx->getIndex());
default: OV_ERROR_KRF("Unhandled box modification type " << size_t(eBoxModificationType), Kernel::ErrorType::BadArgument);
}
//return false;
}
// ====================================================================================================================================
public:
virtual bool initialize() { return true; }
virtual bool uninitialize() { return true; }
virtual bool onInitialized(Kernel::IBox& /*box*/) { return true; }
virtual bool onDefaultInitialized(Kernel::IBox& /*box*/) { return true; }
virtual bool onNameChanged(Kernel::IBox& /*box*/) { return true; }
virtual bool onIdentifierChanged(Kernel::IBox& /*box*/) { return true; }
virtual bool onAlgorithmClassIdentifierChanged(Kernel::IBox& /*box*/) { return true; }
virtual bool onInputConnected(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onInputDisconnected(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onInputAdded(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onInputRemoved(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onInputTypeChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onInputNameChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onOutputConnected(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onOutputDisconnected(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onOutputAdded(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onOutputRemoved(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onOutputTypeChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onOutputNameChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onSettingAdded(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onSettingRemoved(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onSettingTypeChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onSettingNameChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onSettingDefaultValueChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
virtual bool onSettingValueChanged(Kernel::IBox& /*box*/, const size_t /*index*/) { return true; }
// ====================================================================================================================================
virtual Kernel::IAlgorithmManager& getAlgorithmManager() const { return m_boxListenerCtx->getAlgorithmManager(); }
virtual Kernel::IPlayerManager& getPlayerManager() const { return m_boxListenerCtx->getPlayerManager(); }
virtual Kernel::IPluginManager& getPluginManager() const { return m_boxListenerCtx->getPluginManager(); }
virtual Kernel::IMetaboxManager& getMetaboxManager() const { return m_boxListenerCtx->getMetaboxManager(); }
virtual Kernel::IScenarioManager& getScenarioManager() const { return m_boxListenerCtx->getScenarioManager(); }
virtual Kernel::ITypeManager& getTypeManager() const { return m_boxListenerCtx->getTypeManager(); }
virtual Kernel::ILogManager& getLogManager() const { return m_boxListenerCtx->getLogManager(); }
virtual Kernel::IErrorManager& getErrorManager() const { return m_boxListenerCtx->getErrorManager(); }
virtual Kernel::IConfigurationManager& getConfigurationManager() const { return m_boxListenerCtx->getConfigurationManager(); }
virtual Kernel::IScenario& getScenario() const { return m_boxListenerCtx->getScenario(); }
// ====================================================================================================================================
_IsDerivedFromClass_(TBoxListenerParentClass, OVTK_ClassId_)
private:
class CScopedBoxListener final
{
public:
CScopedBoxListener(Kernel::IBoxListenerContext*& ctxRef, Kernel::IBoxListenerContext* ctx)
: m_boxListenerCtx(ctxRef) { m_boxListenerCtx = ctx; }
~CScopedBoxListener() { m_boxListenerCtx = nullptr; }
protected:
Kernel::IBoxListenerContext*& m_boxListenerCtx;
};
Kernel::IBoxListenerContext* m_boxListenerCtx = nullptr;
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,163 @@
#pragma once
#include <ebml/CReader.h>
#include <climits>
#include <vector>
#include "../training/ovtkISignalTrial.h"
#include "../training/ovtkISignalTrialSet.h"
#include "ovtkTBoxAlgorithm.h"
namespace OpenViBE {
namespace Toolkit {
template <class TBoxAlgorithmParentClass>
class TTrainingBoxAlgorithm : public TBoxAlgorithm<TBoxAlgorithmParentClass>
{
public:
TTrainingBoxAlgorithm();
virtual ~TTrainingBoxAlgorithm();
// Signal input reader callback
virtual void setChannelCount(const size_t count) { m_pendingSignal->setChannelCount(count); }
virtual void setChannelName(const size_t index, const char* name) { m_pendingSignal->setChannelName(index, name); }
virtual void setSampleCountPerBuffer(const size_t count) { m_nSamplePerBuffer = count; }
virtual void setSamplingRate(const size_t sampling) { m_pendingSignal->setSamplingRate(sampling); }
virtual void setSampleBuffer(const double* buffer);
// Stimulation input reader callback
virtual void setStimulationCount(size_t /*count*/) {}
virtual void setStimulation(const size_t index, uint64_t identifier, uint64_t date);
// What should be implemented by the derived class
virtual CIdentifier getStimulationIdentifierTrialStart() = 0;
virtual CIdentifier getStimulationIdentifierTrialEnd() = 0;
virtual CIdentifier getStimulationIdentifierTrialLabelRangeStart() = 0;
virtual CIdentifier getStimulationIdentifierTrialLabelRangeEnd() = 0;
virtual CIdentifier getStimulationIdentifierTrain() = 0;
virtual bool train(ISignalTrialSet& trialSet) = 0;
_IsDerivedFromClass_(TBoxAlgorithm<TBoxAlgorithmParentClass>, OVTK_ClassId_)
private:
ISignalTrial* m_pendingSignal = nullptr;
uint64_t m_trialStartTime = 0;
uint64_t m_trialEndTime = 0;
size_t m_nSamplePerBuffer = 0;
CIdentifier m_trialLabel = CIdentifier::undefined();
std::vector<ISignalTrial*> m_signalTrials;
};
// ________________________________________________________________________________________________________________
//
template <class TBoxAlgorithmParentClass>
TTrainingBoxAlgorithm<TBoxAlgorithmParentClass>::TTrainingBoxAlgorithm() : m_trialStartTime(ULLONG_MAX), m_trialEndTime(ULLONG_MAX)
{
m_pendingSignal = createSignalTrial();
}
template <class TBoxAlgorithmParentClass>
TTrainingBoxAlgorithm<TBoxAlgorithmParentClass>::~TTrainingBoxAlgorithm()
{
releaseSignalTrial(m_pendingSignal);
for (auto itSignalTrial = m_signalTrials.begin(); itSignalTrial != m_signalTrials.end(); ++itSignalTrial) { releaseSignalTrial(*itSignalTrial); }
}
// ________________________________________________________________________________________________________________
//
// Signal input reader callback
// ________________________________________________________________________________________________________________
//
template <class TBoxAlgorithmParentClass>
void TTrainingBoxAlgorithm<TBoxAlgorithmParentClass>::setSampleBuffer(const double* buffer)
{
insertBufferSamples(*m_pendingSignal, m_pendingSignal->getSampleCount(), m_nSamplePerBuffer, buffer, m_pendingSignal);
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Debug
<< "Appended " << m_nSamplePerBuffer << " bytes resulting in " << (m_pendingSignal->getDuration() >> 32) << " seconds of signal\n";
}
// ________________________________________________________________________________________________________________
//
// Stimulation input reader callback
// ________________________________________________________________________________________________________________
//
template <class TBoxAlgorithmParentClass>
void TTrainingBoxAlgorithm<TBoxAlgorithmParentClass>::setStimulation(const size_t /*index*/, const uint64_t identifier, const uint64_t date)
{
if (identifier == this->getStimulationIdentifierTrain())
{
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager()
<< Kernel::LogLevel_Trace
<< "Constituting a signal trial set based on previous signal trials...\n";
ISignalTrialSet* signalTrialSet = createSignalTrialSet();
for (auto it = m_signalTrials.begin(); it != m_signalTrials.end(); ++it) { signalTrialSet->addSignalTrial(**it); }
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Info << "Calling train function...\n";
this->train(*signalTrialSet);
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Trace
<< "Training done... will clear signal trials and signal trial set now...\n";
for (auto it = m_signalTrials.begin(); it != m_signalTrials.end(); ++it) { releaseSignalTrial(*it); }
releaseSignalTrialSet(signalTrialSet);
m_signalTrials.clear();
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Info << "Training phase finished !\n";
}
else if (identifier == this->getStimulationIdentifierTrialStart())
{
m_trialStartTime = date;
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Trace
<< "Saved trial start time " << CTime(m_trialStartTime) << "...\n";
}
else if (identifier == this->getStimulationIdentifierTrialEnd())
{
m_trialEndTime = date;
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Trace
<< "Saved trial end time " << CTime(m_trialEndTime) << "...\n";
}
else if (this->getStimulationIdentifierTrialLabelRangeStart() <= CIdentifier(identifier) && CIdentifier(identifier) <= this->
getStimulationIdentifierTrialLabelRangeEnd())
{
m_trialLabel = identifier;
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Trace
<< "Labeled trial " << m_trialLabel << "...\n";
}
else
{
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Debug
<< "Unhandled stimulation " << CIdentifier(identifier) << " at time " << CTime(date) << "\n";
}
if (m_trialEndTime != ULLONG_MAX && m_trialStartTime != ULLONG_MAX && m_trialEndTime > m_trialStartTime)
{
size_t nSample = size_t(((m_trialEndTime - m_trialStartTime) * m_pendingSignal->getSamplingRate()) >> 32);
this->getBoxAlgorithmContext()->getPlayerContext()->getLogManager() << Kernel::LogLevel_Trace
<< "Created trial " << CTime(m_trialStartTime) << "-" << CTime(m_trialEndTime) << " with " << nSample << " samples\n";
ISignalTrial* signalTrial = createSignalTrial();
copyHeader(*signalTrial, m_pendingSignal);
selectTime(*signalTrial, m_trialStartTime, m_trialEndTime, m_pendingSignal);
signalTrial->setLabelIdentifier(m_trialLabel);
m_signalTrials.push_back(signalTrial);
m_trialStartTime = ULLONG_MAX;
m_trialEndTime = ULLONG_MAX;
m_trialLabel = CIdentifier::undefined();
}
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,101 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TAcquisitionDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<uint64_t> op_bufferDuration;
Kernel::TParameterHandler<IMemoryBuffer*> op_experimentInfoStream;
Kernel::TParameterHandler<IMemoryBuffer*> op_signalStream;
Kernel::TParameterHandler<IMemoryBuffer*> op_stimulationStream;
Kernel::TParameterHandler<IMemoryBuffer*> op_channelLocalisationStream;
Kernel::TParameterHandler<IMemoryBuffer*> op_channelUnitsStream;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_AcquisitionDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_AcquisitionDecoder_InputParameterId_MemoryBufferToDecode));
op_bufferDuration.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_AcquisitionDecoder_OutputParameterId_BufferDuration));
op_experimentInfoStream.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_AcquisitionDecoder_OutputParameterId_ExperimentInfoStream));
op_signalStream.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_AcquisitionDecoder_OutputParameterId_SignalStream));
op_stimulationStream.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_AcquisitionDecoder_OutputParameterId_StimulationStream));
op_channelLocalisationStream.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_AcquisitionDecoder_OutputParameterId_ChannelLocalisationStream));
op_channelUnitsStream.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_AcquisitionDecoder_OutputParameterId_ChannelUnitsStream));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
op_channelUnitsStream.uninitialize();
op_channelLocalisationStream.uninitialize();
op_stimulationStream.uninitialize();
op_signalStream.uninitialize();
op_experimentInfoStream.uninitialize();
op_bufferDuration.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getBufferDuration() { return op_bufferDuration; }
Kernel::TParameterHandler<IMemoryBuffer*>& getExperimentInfoStream() { return op_experimentInfoStream; }
Kernel::TParameterHandler<IMemoryBuffer*>& getSignalStream() { return op_signalStream; }
Kernel::TParameterHandler<IMemoryBuffer*>& getStimulationStream() { return op_stimulationStream; }
Kernel::TParameterHandler<IMemoryBuffer*>& getChannelLocalisationStream() { return op_channelLocalisationStream; }
Kernel::TParameterHandler<IMemoryBuffer*>& getChannelUnitsStream() { return op_channelUnitsStream; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_AcquisitionDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_AcquisitionDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_AcquisitionDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TAcquisitionDecoder : public TAcquisitionDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>
{
using TAcquisitionDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::m_boxAlgorithm;
public:
using TAcquisitionDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::uninitialize;
TAcquisitionDecoder() { }
explicit TAcquisitionDecoder(T& boxAlgorithm)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm);
}
virtual ~TAcquisitionDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,77 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovtkTStreamedMatrixDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TChannelLocalisationDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<bool> m_oDynamic;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
using T::m_oMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_ChannelLocalisationDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ChannelLocalisationDecoder_InputParameterId_MemoryBufferToDecode));
m_oMatrix.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ChannelLocalisationDecoder_OutputParameterId_Matrix));
m_oDynamic.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ChannelLocalisationDecoder_OutputParameterId_Dynamic));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_oDynamic.uninitialize();
m_oMatrix.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<bool>& getOutputDynamic() { return m_oDynamic; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ChannelLocalisationDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ChannelLocalisationDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ChannelLocalisationDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TChannelLocalisationDecoder : public TChannelLocalisationDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>
{
using TChannelLocalisationDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::m_boxAlgorithm;
public:
using TChannelLocalisationDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::uninitialize;
TChannelLocalisationDecoder() { }
TChannelLocalisationDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TChannelLocalisationDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,78 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovtkTStreamedMatrixDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TChannelUnitsDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<bool> m_oDynamic;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
using T::m_oMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_ChannelUnitsDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ChannelUnitsDecoder_InputParameterId_MemoryBufferToDecode));
m_oMatrix.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ChannelUnitsDecoder_OutputParameterId_Matrix));
m_oDynamic.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ChannelUnitsDecoder_OutputParameterId_Dynamic));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_oDynamic.uninitialize();
m_oMatrix.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<bool>& getOutputDynamic() { return m_oDynamic; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ChannelUnitsDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ChannelUnitsDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ChannelUnitsDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TChannelUnitsDecoder : public TChannelUnitsDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>
{
using TChannelUnitsDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::m_boxAlgorithm;
public:
using TChannelUnitsDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::uninitialize;
TChannelUnitsDecoder() { }
TChannelUnitsDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TChannelUnitsDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,80 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "../ovtkTCodec.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<const IMemoryBuffer*> m_iBuffer;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_connectorIdx;
virtual void setInputChunk(const IMemoryBuffer* pInputChunkMemoryBuffer) { m_iBuffer = pInputChunkMemoryBuffer; }
virtual Kernel::TParameterHandler<const IMemoryBuffer*>& getInputMemoryBuffer() { return m_iBuffer; }
virtual bool isOutputTriggerActive(const CIdentifier oTrigger) { return m_codec->isOutputTriggerActive(oTrigger); }
virtual bool process(const CIdentifier& oTrigger) { return m_codec->process(oTrigger); }
virtual bool process() { return m_codec->process(); }
public:
// We make visible the initialize methods of the superclass (should be TCodec), in the same scope (public)
using T::initialize;
/*
This public function handles every aspects of the decoding process:
- fill the input memory buffer with a chunk
- decode it (specific for each decoder)
- mark input as deprecated
*/
virtual bool decode(const size_t chunkIdx, const bool markInputAsDeprecated = true)
{
this->setInputChunk(m_boxAlgorithm->getDynamicBoxContext().getInputChunk(m_connectorIdx, chunkIdx));
if (! m_codec->process()) return false;
if (markInputAsDeprecated) m_boxAlgorithm->getDynamicBoxContext().markInputAsDeprecated(m_connectorIdx, chunkIdx);
return true;
}
// We explicitly delete the decode function taking two integers as parameters
// in order to raise errors in plugins using the older API
#ifndef TARGET_OS_MacOS // Current clang has a bug which fails to link these
virtual bool decode(int, int) = delete;
virtual bool decode(size_t, size_t) = delete;
#endif
// The functions that need to be specified by the decoders (specific Trigger ID)
virtual bool isHeaderReceived() = 0;
virtual bool isBufferReceived() = 0;
virtual bool isEndReceived() = 0;
};
/*
This class provides an access to the superclass TDecoder.
Use case : iterating over a vector of TDecoder, calling decode() each time.
You don't need to know which type of decoder is in the vector.
*/
template <class T>
class TDecoder : public TDecoderLocal<TCodec<T>>
{
public:
virtual ~TDecoder() { }
protected:
// constructor is protected, ensuring we can't instanciate a TDecoder
TDecoder() { }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,120 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TExperimentInfoDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<uint64_t> m_experimentID;
Kernel::TParameterHandler<CString*> m_experimentDate;
Kernel::TParameterHandler<uint64_t> m_subjectID;
Kernel::TParameterHandler<CString*> m_subjectName;
Kernel::TParameterHandler<uint64_t> m_subjectAge;
Kernel::TParameterHandler<uint64_t> m_subjectGender;
Kernel::TParameterHandler<uint64_t> m_laboratoryID;
Kernel::TParameterHandler<CString*> m_laboratoryName;
Kernel::TParameterHandler<uint64_t> m_technicianID;
Kernel::TParameterHandler<CString*> m_technicianName;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_ExperimentInfoDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_InputParameterId_MemoryBufferToDecode));
m_experimentID.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_ExperimentID));
m_experimentDate.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_ExperimentDate));
m_subjectID.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_SubjectID));
m_subjectName.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_SubjectName));
m_subjectAge.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_SubjectAge));
m_subjectGender.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_SubjectGender));
m_laboratoryID.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_LaboratoryID));
m_laboratoryName.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_LaboratoryName));
m_technicianID.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_TechnicianID));
m_technicianName.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputParameterId_TechnicianName));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_experimentID.uninitialize();
m_experimentDate.uninitialize();
m_subjectID.uninitialize();
m_subjectName.uninitialize();
m_subjectAge.uninitialize();
m_subjectGender.uninitialize();
m_laboratoryID.uninitialize();
m_laboratoryName.uninitialize();
m_technicianID.uninitialize();
m_technicianName.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getOutputExperimentID() { return m_experimentID; }
Kernel::TParameterHandler<CString*>& getOutputExperimentDate() { return m_experimentDate; }
Kernel::TParameterHandler<uint64_t>& getOutputSubjectID() { return m_subjectID; }
Kernel::TParameterHandler<CString*>& getOutputSubjectName() { return m_subjectName; }
Kernel::TParameterHandler<uint64_t>& getOutputSubjectAge() { return m_subjectAge; }
Kernel::TParameterHandler<uint64_t>& getOutputSubjectGender() { return m_subjectGender; }
Kernel::TParameterHandler<uint64_t>& getOutputLaboratoryID() { return m_laboratoryID; }
Kernel::TParameterHandler<CString*>& getOutputLaboratoryName() { return m_laboratoryName; }
Kernel::TParameterHandler<uint64_t>& getOutputTechnicianID() { return m_technicianID; }
Kernel::TParameterHandler<CString*>& getOutputTechnicianName() { return m_technicianName; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_ExperimentInfoDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TExperimentInfoDecoder : public TExperimentInfoDecoderLocal<TDecoder<T>>
{
using TExperimentInfoDecoderLocal<TDecoder<T>>::m_boxAlgorithm;
public:
using TExperimentInfoDecoderLocal<TDecoder<T>>::uninitialize;
TExperimentInfoDecoder() { }
TExperimentInfoDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TExperimentInfoDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,61 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TFeatureVectorDecoderLocal : public T
{
protected:
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
using T::m_oMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_FeatureVectorDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_FeatureVectorDecoder_InputParameterId_MemoryBufferToDecode));
m_oMatrix.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_FeatureVectorDecoder_OutputParameterId_Matrix));
return true;
}
public:
using T::initialize;
using T::uninitialize;
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_FeatureVectorDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_FeatureVectorDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_FeatureVectorDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TFeatureVectorDecoder : public TFeatureVectorDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>
{
using TFeatureVectorDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::m_boxAlgorithm;
public:
using TFeatureVectorDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::uninitialize;
TFeatureVectorDecoder() { }
TFeatureVectorDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TFeatureVectorDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,79 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TSignalDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<uint64_t> m_sampling;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
using T::m_oMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SignalDecoder));
m_codec->initialize();
m_sampling.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_SignalDecoder_OutputParameterId_Sampling));
m_oMatrix.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_SignalDecoder_OutputParameterId_Matrix));
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SignalDecoder_InputParameterId_MemoryBufferToDecode));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_sampling.uninitialize();
m_oMatrix.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getOutputSamplingRate() { return m_sampling; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_SignalDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_SignalDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_SignalDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TSignalDecoder : public TSignalDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>
{
using TSignalDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::m_boxAlgorithm;
public:
using TSignalDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::uninitialize;
TSignalDecoder() { }
TSignalDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TSignalDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,84 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TSpectrumDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<CMatrix*> m_frequencyAbscissa;
Kernel::TParameterHandler<uint64_t> m_sampling;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
using T::m_oMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SpectrumDecoder));
m_codec->initialize();
m_oMatrix.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_SpectrumDecoder_OutputParameterId_Matrix));
m_frequencyAbscissa.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_SpectrumDecoder_OutputParameterId_FrequencyAbscissa));
m_sampling.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_SpectrumDecoder_OutputParameterId_Sampling));
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SpectrumDecoder_InputParameterId_MemoryBufferToDecode));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_oMatrix.uninitialize();
m_frequencyAbscissa.uninitialize();
m_sampling.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getOutputSamplingRate() { return m_sampling; }
Kernel::TParameterHandler<CMatrix*>& getOutputFrequencyAbscissa() { return m_frequencyAbscissa; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_SpectrumDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_SpectrumDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_SpectrumDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TSpectrumDecoder : public TSpectrumDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>
{
using TSpectrumDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::m_boxAlgorithm;
public:
using TSpectrumDecoderLocal<TStreamedMatrixDecoderLocal<TDecoder<T>>>::uninitialize;
TSpectrumDecoder() { }
TSpectrumDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TSpectrumDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,76 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TStimulationDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<IStimulationSet*> m_oStimulationSet;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_StimulationDecoder));
m_codec->initialize();
m_oStimulationSet.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_StimulationDecoder_OutputParameterId_StimulationSet));
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_StimulationDecoder_InputParameterId_MemoryBufferToDecode));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_oStimulationSet.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<IStimulationSet*>& getOutputStimulationSet() { return m_oStimulationSet; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StimulationDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StimulationDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StimulationDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TStimulationDecoder : public TStimulationDecoderLocal<TDecoder<T>>
{
using TStimulationDecoderLocal<TDecoder<T>>::m_boxAlgorithm;
public:
using TStimulationDecoderLocal<TDecoder<T>>::uninitialize;
TStimulationDecoder() { }
TStimulationDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TStimulationDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,68 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TStreamStructureDecoderLocal : public T
{
protected:
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_StreamStructureDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_StreamStructureDecoder_InputParameterId_MemoryBufferToDecode));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StreamStructureDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StreamStructureDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StreamStructureDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TStreamStructureDecoder : public TStreamStructureDecoderLocal<TDecoder<T>>
{
using TStreamStructureDecoderLocal<TDecoder<T>>::m_boxAlgorithm;
public:
using TStreamStructureDecoderLocal<TDecoder<T>>::uninitialize;
TStreamStructureDecoder() { }
TStreamStructureDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TStreamStructureDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,76 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTDecoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TStreamedMatrixDecoderLocal : public T
{
protected:
Kernel::TParameterHandler<CMatrix*> m_oMatrix;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_iBuffer;
virtual bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_StreamedMatrixDecoder));
m_codec->initialize();
m_iBuffer.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_StreamedMatrixDecoder_InputParameterId_MemoryBufferToDecode));
m_oMatrix.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_StreamedMatrixDecoder_OutputParameterId_Matrix));
return true;
}
public:
using T::initialize;
virtual bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_oMatrix.uninitialize();
m_iBuffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
virtual Kernel::TParameterHandler<CMatrix*>& getOutputMatrix() { return m_oMatrix; }
virtual bool isHeaderReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StreamedMatrixDecoder_OutputTriggerId_ReceivedHeader); }
virtual bool isBufferReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StreamedMatrixDecoder_OutputTriggerId_ReceivedBuffer); }
virtual bool isEndReceived() { return m_codec->isOutputTriggerActive(OVP_GD_Algorithm_StreamedMatrixDecoder_OutputTriggerId_ReceivedEnd); }
};
template <class T>
class TStreamedMatrixDecoder : public TStreamedMatrixDecoderLocal<TDecoder<T>>
{
using TStreamedMatrixDecoderLocal<TDecoder<T>>::m_boxAlgorithm;
public:
using TStreamedMatrixDecoderLocal<TDecoder<T>>::uninitialize;
TStreamedMatrixDecoder() { }
TStreamedMatrixDecoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TStreamedMatrixDecoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,78 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovtkTStreamedMatrixEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TChannelLocalisationEncoderLocal : public T
{
protected:
Kernel::TParameterHandler<bool> m_iDynamic;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
using T::m_iMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_ChannelLocalisationEncoder));
m_codec->initialize();
m_iMatrix.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ChannelLocalisationEncoder_InputParameterId_Matrix));
m_iDynamic.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ChannelLocalisationEncoder_InputParameterId_Dynamic));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ChannelLocalisationEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iMatrix.uninitialize();
m_iDynamic.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<bool>& getInputDynamic() { return m_iDynamic; }
protected:
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_ChannelLocalisationEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_ChannelLocalisationEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_ChannelLocalisationEncoder_InputTriggerId_EncodeEnd); }
};
template <class T>
class TChannelLocalisationEncoder : public TChannelLocalisationEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>
{
using TChannelLocalisationEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::m_boxAlgorithm;
public:
using TChannelLocalisationEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::uninitialize;
TChannelLocalisationEncoder() { }
TChannelLocalisationEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TChannelLocalisationEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,79 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovtkTStreamedMatrixEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TChannelUnitsEncoderLocal : public T
{
protected:
Kernel::TParameterHandler<bool> m_iDynamic;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
using T::m_iMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_ChannelUnitsEncoder));
m_codec->initialize();
m_iMatrix.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ChannelUnitsEncoder_InputParameterId_Matrix));
m_iDynamic.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ChannelUnitsEncoder_InputParameterId_Dynamic));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ChannelUnitsEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iMatrix.uninitialize();
m_iDynamic.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<bool>& getInputDynamic() { return m_iDynamic; }
protected:
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_ChannelUnitsEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_ChannelUnitsEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_ChannelUnitsEncoder_InputTriggerId_EncodeEnd); }
};
template <class T>
class TChannelUnitsEncoder : public TChannelUnitsEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>
{
using TChannelUnitsEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::m_boxAlgorithm;
public:
using TChannelUnitsEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::uninitialize;
TChannelUnitsEncoder() { }
TChannelUnitsEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TChannelUnitsEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,85 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "../ovtkTCodec.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TEncoderLocal : public T
{
protected:
Kernel::TParameterHandler<IMemoryBuffer*> m_buffer;
using T::initialize;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_connectorIdx;
virtual void setOutputChunk(IMemoryBuffer* pOutputChunkMemoryBuffer) { m_buffer = pOutputChunkMemoryBuffer; }
virtual Kernel::TParameterHandler<IMemoryBuffer*>& getOutputMemoryBuffer() { return m_buffer; }
virtual bool isOutputTriggerActive(const CIdentifier oTrigger) { return m_codec->isOutputTriggerActive(oTrigger); }
virtual bool process(const CIdentifier& oTrigger) { return m_codec->process(oTrigger); }
virtual bool process() { return m_codec->process(); }
// The functions that need to be specified by the encoders (specific Trigger ID)
virtual bool encodeHeaderImpl() = 0;
virtual bool encodeBufferImpl() = 0;
virtual bool encodeEndImpl() = 0;
public:
/*
These public methods handle every aspect of the encoding process :
- prepare the output memory buffer with a chunk
- encode (specific for each encoder)
- mark output as ready to be sent has to be done manually, for accurate timing.
*/
bool encodeHeader()
{
this->setOutputChunk(m_boxAlgorithm->getDynamicBoxContext().getOutputChunk(m_connectorIdx));
if (!this->encodeHeaderImpl()) return false;
return true;
}
bool encodeBuffer()
{
this->setOutputChunk(m_boxAlgorithm->getDynamicBoxContext().getOutputChunk(m_connectorIdx));
if (!this->encodeBufferImpl()) return false;
return true;
}
bool encodeEnd()
{
this->setOutputChunk(m_boxAlgorithm->getDynamicBoxContext().getOutputChunk(m_connectorIdx));
if (!this->encodeEndImpl()) return false;
return true;
}
};
/*
This class provides an access to the superclass TEncoder.
Use case : iterating over a vector of TEncoder, calling encodeHeader() each time.
You don't need to know which type of encoder is in the vector.
*/
template <class T>
class TEncoder : public TEncoderLocal<TCodec<T>>
{
public:
virtual ~TEncoder() { }
protected:
// constructor is protected, ensuring we can't instanciate a TEncoder
TEncoder() { }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,120 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TExperimentInfoEncoderLocal : public T
{
protected:
Kernel::TParameterHandler<uint64_t> m_experimentID;
Kernel::TParameterHandler<CString*> m_experimentDate;
Kernel::TParameterHandler<uint64_t> m_subjectID;
Kernel::TParameterHandler<CString*> m_subjectName;
Kernel::TParameterHandler<uint64_t> m_subjectAge;
Kernel::TParameterHandler<uint64_t> m_subjectGender;
Kernel::TParameterHandler<uint64_t> m_laboratoryID;
Kernel::TParameterHandler<CString*> m_laboratoryName;
Kernel::TParameterHandler<uint64_t> m_technicianID;
Kernel::TParameterHandler<CString*> m_technicianName;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_ExperimentInfoEncoder));
m_codec->initialize();
m_experimentID.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_ExperimentID));
m_experimentDate.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_ExperimentDate));
m_subjectID.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_SubjectID));
m_subjectName.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_SubjectName));
m_subjectAge.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_SubjectAge));
m_subjectGender.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_SubjectGender));
m_laboratoryID.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_LaboratoryID));
m_laboratoryName.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_LaboratoryName));
m_technicianID.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_TechnicianID));
m_technicianName.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_InputParameterId_TechnicianName));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_ExperimentInfoEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_experimentID.uninitialize();
m_experimentDate.uninitialize();
m_subjectID.uninitialize();
m_subjectName.uninitialize();
m_subjectAge.uninitialize();
m_subjectGender.uninitialize();
m_laboratoryID.uninitialize();
m_laboratoryName.uninitialize();
m_technicianID.uninitialize();
m_technicianName.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getInputExperimentID() { return m_experimentID; }
Kernel::TParameterHandler<CString*>& getInputExperimentDate() { return m_experimentDate; }
Kernel::TParameterHandler<uint64_t>& getInputSubjectID() { return m_subjectID; }
Kernel::TParameterHandler<CString*>& getInputSubjectName() { return m_subjectName; }
Kernel::TParameterHandler<uint64_t>& getInputSubjectAge() { return m_subjectAge; }
Kernel::TParameterHandler<uint64_t>& getInputSubjectGender() { return m_subjectGender; }
Kernel::TParameterHandler<uint64_t>& getInputLaboratoryID() { return m_laboratoryID; }
Kernel::TParameterHandler<CString*>& getInputLaboratoryName() { return m_laboratoryName; }
Kernel::TParameterHandler<uint64_t>& getInputTechnicianID() { return m_technicianID; }
Kernel::TParameterHandler<CString*>& getInputTechnicianName() { return m_technicianName; }
protected:
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_ExperimentInfoEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_ExperimentInfoEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_ExperimentInfoEncoder_InputTriggerId_EncodeEnd); }
};
template <class T>
class TExperimentInfoEncoder : public TExperimentInfoEncoderLocal<TEncoder<T>>
{
using TExperimentInfoEncoderLocal<TEncoder<T>>::m_boxAlgorithm;
public:
using TExperimentInfoEncoderLocal<TEncoder<T>>::uninitialize;
TExperimentInfoEncoder() { }
TExperimentInfoEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TExperimentInfoEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,63 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TFeatureVectorEncoderLocal : public T
{
protected:
// the feature vector stream is just a streamed matrix with some constraint (dimension = 2).
// no specific parameter.
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
using T::m_iMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_FeatureVectorEncoder));
m_codec->initialize();
m_iMatrix.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_FeatureVectorEncoder_InputParameterId_Matrix));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_FeatureVectorEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_FeatureVectorEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_FeatureVectorEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_FeatureVectorEncoder_InputTriggerId_EncodeEnd); }
public:
using T::initialize;
using T::uninitialize;
};
template <class T>
class TFeatureVectorEncoder : public TFeatureVectorEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>
{
using TFeatureVectorEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::m_boxAlgorithm;
public:
using TFeatureVectorEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::uninitialize;
TFeatureVectorEncoder() { }
TFeatureVectorEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TFeatureVectorEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,89 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TSignalEncoderLocal : public T
{
protected:
//The signal stream is a streamed matrix plus a sampling rate
Kernel::TParameterHandler<uint64_t> m_iSampling;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
using T::m_iMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SignalEncoder));
m_codec->initialize();
m_iMatrix.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SignalEncoder_InputParameterId_Matrix));
m_iSampling.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SignalEncoder_InputParameterId_Sampling));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_StreamedMatrixEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
//again... we propagate initialize from upperclass.
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iMatrix.uninitialize();
m_iSampling.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getInputSamplingRate() { return m_iSampling; }
protected:
/*
The methods specific to the Signal encoder (overriding the TStreamedMatrixEncoderLocal implementations):
*/
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_SignalEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_SignalEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_SignalEncoder_InputTriggerId_EncodeEnd); }
};
/*
The Signal encoder can be instanciated easily through this class.
You just need one template class : the box (T).
*/
template <class T>
class TSignalEncoder : public TSignalEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>
{
using TSignalEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::m_boxAlgorithm;
public:
using TSignalEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::uninitialize;
TSignalEncoder() { }
TSignalEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TSignalEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,87 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTStreamedMatrixEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TSpectrumEncoderLocal : public T
{
protected:
Kernel::TParameterHandler<CMatrix*> m_iFrequencyAbscissa;
Kernel::TParameterHandler<uint64_t> m_iSampling;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
using T::m_iMatrix;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_SpectrumEncoder));
m_codec->initialize();
m_iMatrix.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SpectrumEncoder_InputParameterId_Matrix));
m_iFrequencyAbscissa.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SpectrumEncoder_InputParameterId_FrequencyAbscissa));
m_iSampling.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_SpectrumEncoder_InputParameterId_Sampling));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_SpectrumEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iMatrix.uninitialize();
m_iFrequencyAbscissa.uninitialize();
m_iSampling.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<uint64_t>& getInputSamplingRate() { return m_iSampling; }
Kernel::TParameterHandler<CMatrix*>& getInputFrequencyAbscissa() { return m_iFrequencyAbscissa; }
size_t getInputFrequencyAbscissaCount() { return m_iFrequencyAbscissa->getDimensionSize(0); }
protected:
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_SpectrumEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_SpectrumEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_SpectrumEncoder_InputTriggerId_EncodeEnd); }
};
template <class T>
class TSpectrumEncoder : public TSpectrumEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>
{
using TSpectrumEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::m_boxAlgorithm;
public:
using TSpectrumEncoderLocal<TStreamedMatrixEncoderLocal<TEncoder<T>>>::uninitialize;
TSpectrumEncoder() { }
TSpectrumEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TSpectrumEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,77 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TStimulationEncoderLocal : public T
{
protected:
Kernel::TParameterHandler<IStimulationSet*> m_iStimulationSet;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_StimulationEncoder));
m_codec->initialize();
m_iStimulationSet.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_StimulationEncoder_InputParameterId_StimulationSet));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_StimulationEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iStimulationSet.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<IStimulationSet*>& getInputStimulationSet() { return m_iStimulationSet; }
protected:
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_StimulationEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_StimulationEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_StimulationEncoder_InputTriggerId_EncodeEnd); }
};
template <class T>
class TStimulationEncoder : public TStimulationEncoderLocal<TEncoder<T>>
{
using TStimulationEncoderLocal<TEncoder<T>>::m_boxAlgorithm;
public:
using TStimulationEncoderLocal<TEncoder<T>>::uninitialize;
TStimulationEncoder() { }
TStimulationEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TStimulationEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,86 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../../ovtk_base.h"
#include "ovtkTEncoder.h"
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TStreamedMatrixEncoderLocal : public T
{
protected:
//specific attribute : a matrix handler
Kernel::TParameterHandler<CMatrix*> m_iMatrix;
using T::m_codec;
using T::m_boxAlgorithm;
using T::m_buffer;
bool initializeImpl()
{
m_codec = &m_boxAlgorithm->getAlgorithmManager().getAlgorithm(
m_boxAlgorithm->getAlgorithmManager().createAlgorithm(OVP_GD_ClassId_Algorithm_StreamedMatrixEncoder));
m_codec->initialize();
m_iMatrix.initialize(m_codec->getInputParameter(OVP_GD_Algorithm_StreamedMatrixEncoder_InputParameterId_Matrix));
m_buffer.initialize(m_codec->getOutputParameter(OVP_GD_Algorithm_StreamedMatrixEncoder_OutputParameterId_EncodedMemoryBuffer));
return true;
}
public:
// we propagate the visiblity of TCodec::initialize
using T::initialize;
bool uninitialize()
{
if (m_boxAlgorithm == nullptr || m_codec == nullptr) { return false; }
m_iMatrix.uninitialize();
m_buffer.uninitialize();
m_codec->uninitialize();
m_boxAlgorithm->getAlgorithmManager().releaseAlgorithm(*m_codec);
m_boxAlgorithm = NULL;
return true;
}
Kernel::TParameterHandler<CMatrix*>& getInputMatrix() { return m_iMatrix; }
protected:
/*
The methods specific to the Streamed Matrix encoder :
*/
bool encodeHeaderImpl() { return m_codec->process(OVP_GD_Algorithm_StreamedMatrixEncoder_InputTriggerId_EncodeHeader); }
bool encodeBufferImpl() { return m_codec->process(OVP_GD_Algorithm_StreamedMatrixEncoder_InputTriggerId_EncodeBuffer); }
bool encodeEndImpl() { return m_codec->process(OVP_GD_Algorithm_StreamedMatrixEncoder_InputTriggerId_EncodeEnd); }
};
/*
This class provides an access to the Local class.
It makes a lot easier the declaration of a Streamed Matrix encoder, as you don't have to specify any more template than the Box class (T).
*/
template <class T>
class TStreamedMatrixEncoder : public TStreamedMatrixEncoderLocal<TEncoder<T>>
{
using TStreamedMatrixEncoderLocal<TEncoder<T>>::m_boxAlgorithm;
public:
using TStreamedMatrixEncoderLocal<TEncoder<T>>::uninitialize;
TStreamedMatrixEncoder() { }
TStreamedMatrixEncoder(T& boxAlgorithm, size_t index)
{
m_boxAlgorithm = NULL;
this->initialize(boxAlgorithm, index);
}
virtual ~TStreamedMatrixEncoder() { this->uninitialize(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,107 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "../ovtk_base.h"
/*
Few words about the Codec Toolkit:
----------------------------------
The Codec Toolkit gives a simple and easy way to use the Encoders and Decoders, which are the most frequently used algorithms when developing a plugin.
The Toolkit makes wide use of Templates, in a way that may seem complex for a reviewer. Complexity is not in the number of line of code, but in the architecture.
The comments will try to help, and you may find relevant information on the dedicated tutorial and online doc:
- http://openvibe.inria.fr/documentation/unstable/Doc_Tutorial_Developer_SignalProcessing_CodecToolkit.html
- http://openvibe.inria.fr/documentation/unstable/Doc_Tutorial_Developer_SignalProcessing_CodecToolkit_Ref.html
Contact :
---------
Laurent Bonnet, INRIA Rennes.
www.openvibe.inria.fr/forum
*/
/*
The Template inheritance:
-------------------------
The Codec Toolkit uses template inheritance. This means that every class in templated by its superclass, starting with the most basic class : TCodec.
This architecture allows the Toolkit developer to enhance it anywhere in the inheritance diagram.
Here is the inheritance architecture hidden behind the templates :
Level 0 : TCodec
> Purely Abstract
> Contains the box pointer and the codec algorithm
> Implements the public initialize(T&) function
Level 1 : TEncoderLocal TDecoderLocal
> Partial implementation
> Contains the input or output memory buffer, and high level public functions (to decode and encode)
> This level is accessible but not instanciable, through the TEncoder and TDecoder subclasses.
Level 2 : T_XXX_DecoderLocal T_XXX_EncoderLocal
> Implementation Level, for each stream type (except Streamed Matrix subtypes)
> These local classes contains
> - The specific parameter handlers (e.g. a matrix for the Streamed Matrix codecs)
> - the specific implementations of each functions (init, uninit, isXXXreceived, encodeXXX)
> They are instanciable through their non-local subclasses (e.g. TStreamedMatrixDecoder)
Level 3 : T_StreamedMatrixSubType_DecoderLocal T_StreamedMatrixSubType_EncoderLocal
> Implementation level of the Streamed Matrix subtypes (Feature Vector, Spectrum, Signal)
> They are instanciable through their non-local subclasses (e.g. TFeatureVectorDecoder)
Please look at TDecoder, TEncoder, TStreamedMatrixEncoder and TSignalEncoder classes for more details.
The Codec Toolkit reference page may also be useful.
GL&HF
*/
namespace OpenViBE {
namespace Toolkit {
template <class T>
class TCodec
{
protected:
// We will need the dynamic box context when trying to decode and encode, thus we keep a pointer on the underlying box.
T* m_boxAlgorithm = nullptr;
// Every codec has an algorithm
Kernel::IAlgorithmProxy* m_codec = nullptr;
size_t m_connectorIdx = 0;//one codec per connector
public:
TCodec() : m_boxAlgorithm(nullptr) { }
virtual ~TCodec() { }
//The initialization need a reference to the underlying box
//it will certainly be called in the box in such manner : m_codec.initialize(*this);
bool initialize(T& boxAlgorithm, const size_t connectorIdx)
{
if (m_boxAlgorithm == nullptr)
{
m_boxAlgorithm = &boxAlgorithm;
m_connectorIdx = connectorIdx; //TODO : can we check the box static context and verify the requested connector exist?
}
else { return false; }
// we call the initialization process specific to each codec
return initializeImpl();
}
// As we need to properly uninit parameter handlers before anything else, we can't design a common uninit behavior
virtual bool uninitialize() = 0;
protected:
// Note that this method is NOT public.
virtual bool initializeImpl() = 0;
// for easier access to algorithm functionnality, we redefine some functions:
virtual bool isOutputTriggerActive(const CIdentifier trigger) { return m_codec->isOutputTriggerActive(trigger); }
virtual bool process(const CIdentifier& trigger) { return m_codec->process(trigger); }
virtual bool process() { return m_codec->process(); }
};
} // namespace Toolkit
} // namespace OpenViBE
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
@@ -0,0 +1,318 @@
/*********************************************************************
* Software License Agreement (AGPL-3 License)
*
* OpenViBE SDK
* Based on OpenViBE V1.1.0, Copyright (C) Inria, 2006-2015
* Copyright (C) Inria, 2015-2017,V1.0
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <map>
#include <openvibe/ov_all.h>
#include "../ovtk_base.h"
#include "decoders/ovtkTStreamedMatrixDecoder.h"
#include "decoders/ovtkTSignalDecoder.h"
#include "decoders/ovtkTSpectrumDecoder.h"
#include "decoders/ovtkTFeatureVectorDecoder.h"
#include "encoders/ovtkTStreamedMatrixEncoder.h"
#include "encoders/ovtkTSignalEncoder.h"
#include "encoders/ovtkTSpectrumEncoder.h"
#include "encoders/ovtkTFeatureVectorEncoder.h"
namespace OpenViBE {
namespace Toolkit {
// ______________________________________________________________________________________________________________________________________________________________________________
// ______________________________________________________________________________________________________________________________________________________________________________
//
#define decoder_return_impl(what) \
if(m_signalDecoder) { return m_signalDecoder->what; } \
if(m_spectrumDecoder) { return m_spectrumDecoder->what; } \
if(m_featureVectorDecoder) { return m_featureVectorDecoder->what; } \
return m_streamedMatrixDecoder->what;
template <class T>
class TGenericDecoder
{
protected:
void reset()
{
m_streamedMatrixDecoder = nullptr;
m_signalDecoder = nullptr;
m_spectrumDecoder = nullptr;
m_featureVectorDecoder = nullptr;
}
public:
TGenericDecoder() : m_streamedMatrixDecoder(nullptr), m_signalDecoder(nullptr), m_spectrumDecoder(nullptr), m_featureVectorDecoder(nullptr)
{
this->reset();
}
~TGenericDecoder() { this->uninitialize(); }
TGenericDecoder<T>& operator=(TStreamedMatrixDecoder<T>* decoder)
{
this->reset();
m_streamedMatrixDecoder = decoder;
return *this;
}
TGenericDecoder<T>& operator=(TSignalDecoder<T>* decoder)
{
this->reset();
m_signalDecoder = decoder;
return *this;
}
TGenericDecoder<T>& operator=(TSpectrumDecoder<T>* decoder)
{
this->reset();
m_spectrumDecoder = decoder;
return *this;
}
TGenericDecoder<T>& operator=(TFeatureVectorDecoder<T>* decoder)
{
this->reset();
m_featureVectorDecoder = decoder;
return *this;
}
void uninitialize() { this->reset(); }
Kernel::TParameterHandler<CMatrix*>& getOutputMatrix()
{
decoder_return_impl(getOutputMatrix());
}
Kernel::TParameterHandler<uint64_t>& getOutputSamplingRate()
{
if (m_signalDecoder) { return m_signalDecoder->getOutputSamplingRate(); }
return m_spectrumDecoder->getOutputSamplingRate();
}
Kernel::TParameterHandler<CMatrix*>& getOutputFrequencyAbcissa() { return m_spectrumDecoder->getOutputFrequencyAbscissa(); }
bool decode(int, int) = delete;
bool decode(size_t, size_t) = delete;
bool decode(const size_t chunkIdx, bool bMarkInputAsDeprecated = true)
{
decoder_return_impl(decode(chunkIdx, bMarkInputAsDeprecated));
}
bool isHeaderReceived()
{
decoder_return_impl(isHeaderReceived());
}
bool isBufferReceived()
{
decoder_return_impl(isBufferReceived());
}
bool isEndReceived()
{
decoder_return_impl(isEndReceived());
}
protected:
TStreamedMatrixDecoder<T>* m_streamedMatrixDecoder = nullptr;
TSignalDecoder<T>* m_signalDecoder = nullptr;
TSpectrumDecoder<T>* m_spectrumDecoder = nullptr;
TFeatureVectorDecoder<T>* m_featureVectorDecoder = nullptr;
};
// ______________________________________________________________________________________________________________________________________________________________________________
// ______________________________________________________________________________________________________________________________________________________________________________
//
#define encoder_return_impl(what) \
if(m_signalEncoder) { return m_signalEncoder->what; } \
if(m_spectrumEncoder) { return m_spectrumEncoder->what; } \
if(m_featureVectorEncoder) { return m_featureVectorEncoder->what; } \
return m_streamedMatrixDecoder->what;
template <class T>
class TGenericEncoder
{
protected:
void reset()
{
m_streamedMatrixDecoder = nullptr;
m_signalEncoder = nullptr;
m_spectrumEncoder = nullptr;
m_featureVectorEncoder = nullptr;
}
public:
TGenericEncoder() : m_streamedMatrixDecoder(nullptr), m_signalEncoder(nullptr), m_spectrumEncoder(nullptr), m_featureVectorEncoder(nullptr)
{
this->reset();
}
~TGenericEncoder() { this->uninitialize(); }
TGenericEncoder<T>& operator=(TStreamedMatrixEncoder<T>* pEncoder)
{
this->reset();
m_streamedMatrixDecoder = pEncoder;
return *this;
}
TGenericEncoder<T>& operator=(TSignalEncoder<T>* pEncoder)
{
this->reset();
m_signalEncoder = pEncoder;
return *this;
}
TGenericEncoder<T>& operator=(TSpectrumEncoder<T>* pEncoder)
{
this->reset();
m_spectrumEncoder = pEncoder;
return *this;
}
TGenericEncoder<T>& operator=(TFeatureVectorEncoder<T>* pEncoder)
{
this->reset();
m_featureVectorEncoder = pEncoder;
return *this;
}
void uninitialize() { this->reset(); }
Kernel::TParameterHandler<CMatrix*>& getInputMatrix()
{
encoder_return_impl(getInputMatrix());
}
Kernel::TParameterHandler<uint64_t>& getInputSamplingRate()
{
if (m_signalEncoder) { return m_signalEncoder->getInputSamplingRate(); }
return m_spectrumEncoder->getInputSamplingRate();
}
Kernel::TParameterHandler<CMatrix*>& getInputFrequencyAbcissa() { return m_spectrumEncoder->getInputFrequencyAbscissa(); }
bool encodeHeader()
{
encoder_return_impl(encodeHeader());
}
bool encodeBuffer()
{
encoder_return_impl(encodeBuffer());
}
bool encodeEnd()
{
encoder_return_impl(encodeEnd());
}
protected:
TStreamedMatrixEncoder<T>* m_streamedMatrixDecoder = nullptr;
TSignalEncoder<T>* m_signalEncoder = nullptr;
TSpectrumEncoder<T>* m_spectrumEncoder = nullptr;
TFeatureVectorEncoder<T>* m_featureVectorEncoder = nullptr;
};
// ______________________________________________________________________________________________________________________________________________________________________________
// ______________________________________________________________________________________________________________________________________________________________________________
//
template <class T>
class TGenericListener final : public T
{
public:
typedef enum
{
Type_None = 0x00000000,
Type_StreamedMatrix = 0x00000001,
Type_Signal = 0x00000002,
Type_Spectrum = 0x00000004,
Type_Covariance = 0x00000008,
Type_All = 0xffffffff
} EType;
explicit TGenericListener(const size_t typeFlag = Type_All)
{
if (typeFlag & Type_StreamedMatrix) m_allowedTypeIDs[OV_TypeId_StreamedMatrix] = true;
if (typeFlag & Type_Signal) m_allowedTypeIDs[OV_TypeId_Signal] = true;
if (typeFlag & Type_Spectrum) m_allowedTypeIDs[OV_TypeId_Spectrum] = true;
if (typeFlag & Type_Covariance) m_allowedTypeIDs[OV_TypeId_CovarianceMatrix] = true;
}
bool isValidInputType(const CIdentifier& typeID, size_t /*index*/)
{
return m_allowedTypeIDs[typeID];
//return (typeID==OV_TypeId_Signal || typeID==OV_TypeId_Spectrum);
}
virtual bool onInputTypeChanged(Kernel::IBox& box, const size_t index)
{
CIdentifier typeID = CIdentifier::undefined();
box.getInputType(index, typeID);
if (this->isValidInputType(typeID, index)) { box.setOutputType(index, typeID); }
else
{
box.getOutputType(index, typeID);
box.setInputType(index, typeID);
}
return true;
}
bool isValidOutputType(const CIdentifier& typeID, size_t /*index*/)
{
return m_allowedTypeIDs[typeID];
//return (typeID==OV_TypeId_Signal || typeID==OV_TypeId_Spectrum);
}
virtual bool onOutputTypeChanged(Kernel::IBox& box, const size_t index)
{
CIdentifier typeID = CIdentifier::undefined();
box.getOutputType(index, typeID);
if (this->isValidOutputType(typeID, index)) { box.setInputType(index, typeID); }
else
{
box.getInputType(index, typeID);
box.setOutputType(index, typeID);
}
return true;
}
_IsDerivedFromClass_Final_(T, CIdentifier::undefined())
private:
std::map<CIdentifier, bool> m_allowedTypeIDs;
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,17 @@
#pragma once
#include "ovtkIVector.h"
namespace OpenViBE {
namespace Toolkit {
class OVTK_API IFeatureVector : public IVector
{
public:
virtual double getLabel() const = 0;
virtual bool setLabel(const double label) = 0;
_IsDerivedFromClass_(IVector, OVTK_ClassId_FeatureVector)
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,28 @@
#pragma once
#include "ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
class IFeatureVector;
class OVTK_API IFeatureVectorSet : public IObject
{
public:
virtual size_t getFeatureVectorCount() const = 0;
virtual bool setFeatureVectorCount(const size_t featureVector) = 0;
virtual bool addFeatureVector(const IFeatureVector& featureVector) = 0;
virtual IFeatureVector& getFeatureVector(const size_t index) = 0;
virtual const IFeatureVector& getFeatureVector(const size_t index) const = 0;
virtual size_t getLabelCount() const = 0;
_IsDerivedFromClass_(IObject, OVTK_ClassId_FeatureVectorSet)
const IFeatureVector& operator [](const size_t index) const { return this->getFeatureVector(index); }
IFeatureVector& operator [](const size_t index) { return this->getFeatureVector(index); }
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,24 @@
#pragma once
#include "ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
class OVTK_API IVector : public IObject
{
public:
virtual uint32_t getSize() const = 0;
virtual bool setSize(const uint32_t size) = 0;
virtual double* getBuffer() = 0;
virtual const double* getBuffer() const = 0;
virtual const char* getElementLabel(const uint32_t index) const = 0;
virtual bool setElementLabel(const uint32_t index, const char* sElementLabel) = 0;
_IsDerivedFromClass_(IObject, OVTK_ClassId_Vector)
const double& operator [](const uint32_t index) const { return this->getBuffer()[index]; }
double& operator [](const uint32_t index) { return this->getBuffer()[index]; }
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,97 @@
#pragma once
#ifdef TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
#include "ovp_global_defines.h"
#endif // TARGET_HAS_ThirdPartyOpenViBEPluginsGlobalDefines
//___________________________________________________________________//
// //
// Basic includes //
//___________________________________________________________________//
// //
#include "ovtk_defines.h"
//___________________________________________________________________//
// //
// Tools //
//___________________________________________________________________//
// //
#include "tools/ovtkMatrix.h"
#include "tools/ovtkStimulationSet.h"
#include "tools/ovtkString.h"
//___________________________________________________________________//
// //
// Codecs //
//___________________________________________________________________//
// //
#include "codecs/ovtkTCodec.h"
#include "codecs/ovtkTGenericCodec.h"
#include "codecs/encoders/ovtkTEncoder.h"
#include "codecs/decoders/ovtkTDecoder.h"
#include "codecs/decoders/ovtkTAcquisitionDecoder.h"
#include "codecs/decoders/ovtkTStreamStructureDecoder.h"
#include "codecs/encoders/ovtkTStimulationStreamEncoder.h"
#include "codecs/decoders/ovtkTStimulationStreamDecoder.h"
#include "codecs/encoders/ovtkTStreamedMatrixEncoder.h"
#include "codecs/decoders/ovtkTStreamedMatrixDecoder.h"
#include "codecs/encoders/ovtkTSignalEncoder.h"
#include "codecs/decoders/ovtkTSignalDecoder.h"
#include "codecs/encoders/ovtkTChannelLocalisationEncoder.h"
#include "codecs/decoders/ovtkTChannelLocalisationDecoder.h"
#include "codecs/encoders/ovtkTChannelUnitsEncoder.h"
#include "codecs/decoders/ovtkTChannelUnitsDecoder.h"
#include "codecs/encoders/ovtkTExperimentInfoEncoder.h"
#include "codecs/decoders/ovtkTExperimentInfoDecoder.h"
#include "codecs/encoders/ovtkTFeatureVectorEncoder.h"
#include "codecs/decoders/ovtkTFeatureVectorDecoder.h"
#include "codecs/encoders/ovtkTSpectrumEncoder.h"
#include "codecs/decoders/ovtkTSpectrumDecoder.h"
//___________________________________________________________________//
// //
// //
//___________________________________________________________________//
// //
#include "ovtkIVector.h"
#include "ovtkIFeatureVector.h"
#include "ovtkIFeatureVectorSet.h"
#include "box-algorithms/ovtkTBoxAlgorithm.h"
#include "algorithms/ovtkTAlgorithm.h"
#include "algorithms/classification/ovtkCAlgorithmClassifier.h"
#include "algorithms/classification/ovtkCAlgorithmPairingStrategy.h"
#include "algorithms/scenario-io/ovtkCAlgorithmScenarioImporter.h"
#include "algorithms/scenario-io/ovtkCAlgorithmScenarioExporter.h"
//___________________________________________________________________//
// //
// //
//___________________________________________________________________//
// //
namespace OpenViBE {
namespace Toolkit {
OVTK_API bool initialize(const Kernel::IKernelContext& ctx);
OVTK_API bool uninitialize(const Kernel::IKernelContext& ctx);
bool initializeStimulationList(const Kernel::IKernelContext& ctx);
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,32 @@
#pragma once
#include "ovtk_defines.h"
#include <openvibe/ov_all.h>
namespace EBML {
class IWriter;
class IWriterCallback;
class IWriterHelper;
class IReader;
class IReaderCallback;
class IReaderHelper;
} // namespace EBML
namespace OpenViBE {
namespace Toolkit {
template <class THandledType>
class TScopeHandle
{
public:
TScopeHandle(THandledType& rHandler, THandledType& rHandledValue) : m_handler(rHandler), m_lastHandledValue(rHandler) { m_handler = rHandledValue; }
~TScopeHandle() { m_handler = m_lastHandledValue; }
private:
THandledType& m_handler;
THandledType m_lastHandledValue;
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,856 @@
#pragma once
#include <toolkit/ovtk_stimulations.h>
//__________________________________________________________________//
// //
// OpenViBE toolkit input and output type identifiers //
//__________________________________________________________________//
// //
#define OVTK_TypeId_Boolean OpenViBE::CIdentifier(0x2CDB2F0B, 0x12F231EA)
#define OVTK_TypeId_Integer OpenViBE::CIdentifier(0x007DEEF9, 0x2F3E95C6)
#define OVTK_TypeId_Float OpenViBE::CIdentifier(0x512A166F, 0x5C3EF83F)
#define OVTK_TypeId_String OpenViBE::CIdentifier(0x79A9EDEB, 0x245D83FC)
#define OVTK_TypeId_Filename OpenViBE::CIdentifier(0x330306DD, 0x74A95F98)
#define OVTK_TypeId_Stimulation OpenViBE::CIdentifier(0x2C132D6E, 0x44AB0D97)
#define OVTK_TypeId_GDF_Stimulation OpenViBE::CIdentifier(0xA538DBF0, 0xBC229750)
#define OVTK_TypeId_ClassificationAlgorithm OpenViBE::CIdentifier(0xD765A736, 0xED708C65)
#define OVTK_TypeId_ClassificationStrategy OpenViBE::CIdentifier(0xBE9EBA5C, 0xA8415D37)
//__________________________________________________________________//
// //
// OpenViBE toolkit stream type identifiers //
//__________________________________________________________________//
// //
#define OVTK_TypeId_EBMLStream OpenViBE::CIdentifier(0x434F6587, 0x2EFD2B7E)
#define OVTK_TypeId_ExperimentInfo OpenViBE::CIdentifier(0x403488E7, 0x565D70B6)
#define OVTK_TypeId_ExperimentationInformation OpenViBE::CIdentifier(0x403488E7, 0x565D70B6) // deprecated token, kept for compatibility, equal to the one above
#define OVTK_TypeId_Stimulations OpenViBE::CIdentifier(0x6F752DD0, 0x082A321E)
#define OVTK_TypeId_StreamedMatrix OpenViBE::CIdentifier(0x544A003E, 0x6DCBA5F6)
#define OVTK_TypeId_FeatureVector OpenViBE::CIdentifier(0x17341935, 0x152FF448)
#define OVTK_TypeId_Signal OpenViBE::CIdentifier(0x5BA36127, 0x195FEAE1)
#define OVTK_TypeId_Spectrum OpenViBE::CIdentifier(0x1F261C0A, 0x593BF6BD)
#define OVTK_TypeId_ChannelLocalisation OpenViBE::CIdentifier(0x013DF452, 0xA3A8879A)
#define OVTK_TypeId_ChannelUnits OpenViBE::CIdentifier(0x6AB26B81, 0x0F8C02F3)
//__________________________________________________________________//
// //
// ISO 5218 conformant sex identifiers //
//__________________________________________________________________//
// //
// deprecated
#define OVTK_Value_Sex_Unknown 0
#define OVTK_Value_Sex_Male 1
#define OVTK_Value_Sex_Female 2
#define OVTK_Value_Sex_NotSpecified 9
#define OVTK_Value_Gender_Unknown 0
#define OVTK_Value_Gender_Male 1
#define OVTK_Value_Gender_Female 2
#define OVTK_Value_Gender_NotSpecified 9
//__________________________________________________________________//
// //
// OpenViBE toolkit stimulation identifiers //
//__________________________________________________________________//
// //
#define OVTK_StimulationId_Label(i) 0x00008100|((i)&0xff)
#define OVTK_StimulationId_LabelStart 0x00008100
#define OVTK_StimulationId_LabelEnd 0x000081ff
// These are low-order stimulations that may be required for some legacy communication
// channels like parallel port handling only 1 byte codes. The name and number of these stimuli exactly matches.
#define OVTK_StimulationId_NumberStart 0x00000000
#define OVTK_StimulationId_NumberEnd 0x000000ff
#define OVTK_GDF_Condition(i) (i)
#define OVTK_StimulationId_ThresholdPassed_Positive 0x00008209
#define OVTK_StimulationId_ThresholdPassed_Negative 0x00008210
#define OVTK_StimulationId_NoArtifact 0x00008301
#define OVTK_StimulationId_Artifact 0x00008302
//__________________________________________________________________//
// //
// Measurement units //
//__________________________________________________________________//
// //
// These units attempt to be compatible with those specified by Alois Schloegl in the BioSig project, see http://biosig.sf.net/
//
// See also e.g.
// ISO/IEEE 11073-10101:2004, Health informatics - Point-of-care medical device communication - Part 10101: Nomenclature
//
// @TODO it would be better to read these from a database file (along with the symbols now specified in ovtk_main.cpp),
// however we still need the defines if we wish to provide compile-time token support.
//
// Note: Since these will be stored as double when transmitted by OpenViBE, they should not exceed the floats integer precision
//
#define OVTK_UNIT_Unspecified 0
#define OVTK_UNIT_Dimensionless 512
#define OVTK_UNIT_10_2_Percent 544
#define OVTK_UNIT_10_3_Parts_Per_Thousand 576
#define OVTK_UNIT_10_6_Parts_Per_Million 608
#define OVTK_UNIT_10_9_Parts_Per_Milliard 640
#define OVTK_UNIT_10_12_Parts_Per_Billion 672
#define OVTK_UNIT_10_18_Parts_Per_Trillion 704
#define OVTK_UNIT_Angle_Degree 736
#define OVTK_UNIT_Angle_Radian 768
#define OVTK_UNIT_Grams_Per_Gram 800
#define OVTK_UNIT_Grams_Per_Kilogram 832
#define OVTK_UNIT_Moles_Per_Mole 864
#define OVTK_UNIT_Litres_Per_Litre 896
#define OVTK_UNIT_Cubic_Metres_Per_Cubic_Metre 928
#define OVTK_UNIT_Cubic_Metres_Per_Cubic_Centimetre 960
#define OVTK_UNIT_Volume_Percent 6240
#define OVTK_UNIT_Ph 992
#define OVTK_UNIT_Drop 1024
#define OVTK_UNIT_Red_Blood_Cells 1056
#define OVTK_UNIT_Beat 1088
#define OVTK_UNIT_Breath 1120
#define OVTK_UNIT_Cell 1152
#define OVTK_UNIT_Cough 1184
#define OVTK_UNIT_Sigh 1216
#define OVTK_UNIT_Percent_Of_Packed_Cell_Volume 1248
#define OVTK_UNIT_Metres 1280
#define OVTK_UNIT_Yard 1312
#define OVTK_UNIT_Foot 1344
#define OVTK_UNIT_Inch 1376
#define OVTK_UNIT_Litres_Per_Square_Metre 1408
#define OVTK_UNIT_Per_Metre 1440
#define OVTK_UNIT_Square_Metres 1472
#define OVTK_UNIT_Square_Inch 1504
#define OVTK_UNIT_Per_Square_Metre 1536
#define OVTK_UNIT_Cubic_Metres 1568
#define OVTK_UNIT_Litres 1600
#define OVTK_UNIT_Litres_Per_Breath 1632
#define OVTK_UNIT_Litres_Per_Beat 6112
#define OVTK_UNIT_Per_Cubic_Metre 1664
#define OVTK_UNIT_Per_Litre 1696
#define OVTK_UNIT_Gram 1728
#define OVTK_UNIT_Pound 1760
#define OVTK_UNIT_Ounce 1792
#define OVTK_UNIT_Per_Gram 1824
#define OVTK_UNIT_Gram_Metre 1856
#define OVTK_UNIT_Grams_Meter_Per_Square_Metre 1888
#define OVTK_UNIT_Gram_Metre_Squared 1920
#define OVTK_UNIT_Kilograms_Per_Square_Metre 1952
#define OVTK_UNIT_Grams_Per_Cubic_Metre 1984
#define OVTK_UNIT_Grams_Per_Cubic_Centimetre 2016
#define OVTK_UNIT_Grams_Per_Litre 2048
#define OVTK_UNIT_Grams_Per_Centilitre 2080
#define OVTK_UNIT_Grams_Per_Decilitre 2112
#define OVTK_UNIT_Grams_Per_Millilitre 2144
#define OVTK_UNIT_Second 2176
#define OVTK_UNIT_Minute 2208
#define OVTK_UNIT_Hour 2240
#define OVTK_UNIT_Day 2272
#define OVTK_UNIT_Weeks 2304
#define OVTK_UNIT_Months 2336
#define OVTK_UNIT_Year 2368
#define OVTK_UNIT_Time_Of_Day_Hh_Mm_Ss 2400
#define OVTK_UNIT_Date_Yyyy_Mm_Dd 2432
#define OVTK_UNIT_Per_Second 2464
#define OVTK_UNIT_Hertz 2496
#define OVTK_UNIT_Per_Minute 2528
#define OVTK_UNIT_Per_Hour 2560
#define OVTK_UNIT_Per_Day 2592
#define OVTK_UNIT_Per_Week 2624
#define OVTK_UNIT_Per_Month 2656
#define OVTK_UNIT_Per_Year 2688
#define OVTK_UNIT_Beat_Per_Minute 2720
#define OVTK_UNIT_Puls_Per_Minute 2752
#define OVTK_UNIT_Respirations_Per_Minute 2784
#define OVTK_UNIT_Metres_Per_Second 2816
#define OVTK_UNIT_Litres_Per_Minute_Per_Square_Meter 2848
#define OVTK_UNIT_Square_Metres_Per_Second 2880
#define OVTK_UNIT_Cubic_Metres_Per_Second 2912
#define OVTK_UNIT_Cubic_Metres_Per_Minute 2944
#define OVTK_UNIT_Cubic_Metres_Per_Hour 2976
#define OVTK_UNIT_Cubic_Metres_Per_Day 3008
#define OVTK_UNIT_Litres_Per_Second 3040
#define OVTK_UNIT_Litres_Per_Minute 3072
#define OVTK_UNIT_Litres_Per_Hour 3104
#define OVTK_UNIT_Litres_Per_Day 3136
#define OVTK_UNIT_Litres_Per_Kilogram 3168
#define OVTK_UNIT_Cubic_Metres_Per_Kilogram 3200
#define OVTK_UNIT_Meter_Per_Pascal_Second 3232
#define OVTK_UNIT_Litre_Per_Min_Per_Millimetre_Of_Mercury 3264
#define OVTK_UNIT_Grams_Per_Second 3296
#define OVTK_UNIT_Grams_Per_Minute 3328
#define OVTK_UNIT_Grams_Per_Hour 3360
#define OVTK_UNIT_Grams_Per_Day 3392
#define OVTK_UNIT_Grams_Per_Kilogram_Per_Second 3424
#define OVTK_UNIT_Grams_Per_Kilogram_Per_Minute 3456
#define OVTK_UNIT_Grams_Per_Kilogram_Per_Hour 3488
#define OVTK_UNIT_Grams_Per_Kilogram_Per_Day 3520
#define OVTK_UNIT_Grams_Per_Litre_Per_Second 3552
#define OVTK_UNIT_Grams_Per_Litre_Per_Minute 3584
#define OVTK_UNIT_Grams_Per_Litre_Per_Hour 3616
#define OVTK_UNIT_Grams_Per_Litre_Per_Day 3648
#define OVTK_UNIT_Grams_Per_Meter_Per_Second 3680
#define OVTK_UNIT_Gram_Metres_Per_Second 3712
#define OVTK_UNIT_Newton_Seconds 3744
#define OVTK_UNIT_Newton 3776
#define OVTK_UNIT_Dyne 3808
#define OVTK_UNIT_Pascal 3840
#define OVTK_UNIT_Millimetres_Of_Mercury 3872
#define OVTK_UNIT_Centimetre_Of_Water 3904
#define OVTK_UNIT_Bar 3936
#define OVTK_UNIT_Joules 3968
#define OVTK_UNIT_Electronvolts 4000
#define OVTK_UNIT_Watts 4032
#define OVTK_UNIT_Pascal_Second_Per_Cubic_Meter 4064
#define OVTK_UNIT_Pascal_Second_Per_Litre 4096
#define OVTK_UNIT_Dyne_Second_Per_Cm5 4128
#define OVTK_UNIT_Litre_Per_Centimetre_Of_Water 5888
#define OVTK_UNIT_Litre_Per_Millimetre_Of_Mercury 6272
#define OVTK_UNIT_Litre_Per_Pascal 6304
#define OVTK_UNIT_Centimetre_Of_Water_Per_Litre 6144
#define OVTK_UNIT_Millimetre_Of_Mercury_Per_Litre 6336
#define OVTK_UNIT_Pascal_Per_Litre 6368
#define OVTK_UNIT_Amperes 4160
#define OVTK_UNIT_Coulombs 4192
#define OVTK_UNIT_Amperes_Hour 6080
#define OVTK_UNIT_Amperes_Per_Metre 4224
#define OVTK_UNIT_Volts 4256
#define OVTK_UNIT_Ohms 4288
#define OVTK_UNIT_Ohm_Metres 4320
#define OVTK_UNIT_Farads 4352
#define OVTK_UNIT_Kelvin 4384
#define OVTK_UNIT_Degree_Celcius 6048
#define OVTK_UNIT_Degree_Fahrenheit 4416
#define OVTK_UNIT_Kelvins_Per_Watt 4448
#define OVTK_UNIT_Candelas 4480
#define OVTK_UNIT_Osmoles 4512
#define OVTK_UNIT_Moles 4544
#define OVTK_UNIT_Equivalent 4576
#define OVTK_UNIT_Osmoles_Per_Litre 4608
#define OVTK_UNIT_Moles_Per_Cubic_Centimetre 4640
#define OVTK_UNIT_Moles_Per_Cubic_Metre 4672
#define OVTK_UNIT_Moles_Per_Litre 4704
#define OVTK_UNIT_Moles_Per_Millilitre 4736
#define OVTK_UNIT_Equivalents_Per_Cubic_Centimetre 4768
#define OVTK_UNIT_Equivalents_Per_Cubic_Metre 4800
#define OVTK_UNIT_Equivalents_Per_Litre 4832
#define OVTK_UNIT_Equivalents_Per_Millilitre 4864
#define OVTK_UNIT_Osmoles_Per_Kilogram 4896
#define OVTK_UNIT_Moles_Per_Kilogram 4928
#define OVTK_UNIT_Moles_Per_Second 4960
#define OVTK_UNIT_Moles_Per_Minute 4992
#define OVTK_UNIT_Moles_Per_Hour 5024
#define OVTK_UNIT_Moles_Per_Day 5056
#define OVTK_UNIT_Equivalents_Per_Second 5088
#define OVTK_UNIT_Equivalents_Per_Minute 5120
#define OVTK_UNIT_Equivalents_Per_Hour 5152
#define OVTK_UNIT_Equivalents_Per_Day 5184
#define OVTK_UNIT_Moles_Per_Kilogram_Per_Second 5216
#define OVTK_UNIT_Moles_Per_Kilogram_Per_Minute 5248
#define OVTK_UNIT_Moles_Per_Kilogram_Per_Hour 5280
#define OVTK_UNIT_Moles_Per_Kilogram_Per_Day 5312
#define OVTK_UNIT_Equivalents_Per_Kilogram_Per_Second 5344
#define OVTK_UNIT_Equivalents_Per_Kilogram_Per_Minute 5376
#define OVTK_UNIT_Equivalents_Per_Kilogram_Per_Hour 5408
#define OVTK_UNIT_Equivalents_Per_Kilogram_Per_Day 5440
#define OVTK_UNIT_International_Unit 5472
#define OVTK_UNIT_International_Units_Per_Cubic_Centimetre 5504
#define OVTK_UNIT_International_Units_Per_Cubic_Meter 5536
#define OVTK_UNIT_International_Units_Per_Litre 5568
#define OVTK_UNIT_International_Units_Per_Millilitre 5600
#define OVTK_UNIT_International_Units_Per_Second 5632
#define OVTK_UNIT_International_Units_Per_Minute 5664
#define OVTK_UNIT_International_Units_Per_Hour 5696
#define OVTK_UNIT_International_Units_Per_Day 5728
#define OVTK_UNIT_International_Units_Per_Kilogram_Per_Second 5760
#define OVTK_UNIT_International_Units_Per_Kilogram_Per_Minute 5792
#define OVTK_UNIT_International_Units_Per_Kilogram_Per_Hour 5824
#define OVTK_UNIT_International_Units_Per_Kilogram_Per_Day 5856
#define OVTK_UNIT_Centimetre_Of_Water_Per_Litre_Per_Second 5920
#define OVTK_UNIT_Litre_Squared_Per_Second 5952
#define OVTK_UNIT_Centimetre_Of_Water_Per_Percent 5984
#define OVTK_UNIT_Dyne_Seconds_Per_Square_Meter_Per_Centimetre_To_The_Power_Of_5 6016
#define OVTK_UNIT_Millimetres_Of_Mercury_Per_Percent 6176
#define OVTK_UNIT_Pascal_Per_Percent 6208
#define OVTK_UNIT_Relative_Power_Decibel 6432
#define OVTK_UNIT_Meter_Per_Second_Squared 6624
#define OVTK_UNIT_Radians_Per_Second_Squared 6656
#define OVTK_UNIT_Foot_Per_Minute 6688
#define OVTK_UNIT_Inch_Per_Minute 6720
#define OVTK_UNIT_Step_Per_Minute 6752
#define OVTK_UNIT_Kilocalories 6784
#define OVTK_UNIT_Revolution_Per_Minute 6816
#define OVTK_UNIT_V_Per_S 65152
#define OVTK_UNIT_M_Per_M 65184
#define OVTK_UNIT_Velocity_Kilometer_Per_Hour 65216
#define OVTK_UNIT_Left_Stroke_Work_Index_Lswi 65248
#define OVTK_UNIT_Indexed_Left_Cardiac_Work_Lcwi 65280
#define OVTK_UNIT_Mhg_Per_S 65312
#define OVTK_UNIT_Millimol_Per_Liter_X_Millimeter 65344
#define OVTK_UNIT_Rotations_Per_Minute 65376
#define OVTK_UNIT_Dyne_Seconds_Square_Meter_Per_Centimetre_To_The_Power_Of_5 65440
#define OVTK_UNIT_Litres_Per_Square_Meter 65472
#define OVTK_UNIT_Tesla 65504
// OpenViBE extensions, starting from 100001
#define OVTK_UNIT_Degree_Per_Second 100001
//__________________________________________________________________//
// //
// Measurement Factors //
//__________________________________________________________________//
// //
// These are the usual metric prefixes (also known as SI prefixes)
//
// The number of each prefix encodes the exponent in the 1e00 notation.
//
// OpenViBE enums are unsigned integers. Here we use the convention of ORring with 0x00010000 to denote the negative exponents.
//
// Note: Since these will be stored as double when transmitted by OpenViBE, they should not exceed the floats integer precision
//
#define OVTK_FACTOR_Yotta 24
#define OVTK_FACTOR_Zetta 21
#define OVTK_FACTOR_Exa 18
#define OVTK_FACTOR_Peta 15
#define OVTK_FACTOR_Tera 12
#define OVTK_FACTOR_Giga 9
#define OVTK_FACTOR_Mega 6
#define OVTK_FACTOR_Kilo 3
#define OVTK_FACTOR_Hecto 2
#define OVTK_FACTOR_Deca 1
#define OVTK_FACTOR_Base 0
#define OVTK_FACTOR_Deci (1 | 0x00010000) // 65537
#define OVTK_FACTOR_Centi (2 | 0x00010000) // 65538
#define OVTK_FACTOR_Milli (3 | 0x00010000) // 65539
#define OVTK_FACTOR_Micro (6 | 0x00010000) // 65540
#define OVTK_FACTOR_Nano (9 | 0x00010000) // 65541
#define OVTK_FACTOR_Pico (12 | 0x00010000) // 65542
#define OVTK_FACTOR_Femto (15 | 0x00010000) // 65543
#define OVTK_FACTOR_Atto (18 | 0x00010000) // 65544
#define OVTK_FACTOR_Zepto (21 | 0x00010000) // 65545
#define OVTK_FACTOR_Yocto (24 | 0x00010000) // 65546
// Convert the factor code to a signer integer
#define OVTK_DECODE_FACTOR(factor) ( ((factor) & 0x00010000) ? -int((factor) & 0x0000FFFF) : int(factor) )
//__________________________________________________________________//
// //
// Acquisition stream node identifiers //
//__________________________________________________________________//
// //
/*
* Acquisition stream description
*
* v1 july 2006
* v2 march 2008
* v3 november 2014
*
* This is a multiplexed stream
*
* version 3 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Acquisition_Header_ExperimentInfo
* ... some experiment information stream header
* OVTK_NodeId_Acquisition_Header_Signal
* ... some signal stream header
* OVTK_NodeId_Acquisition_Header_Stimulation
* ... some stimulation stream header
* OVTK_NodeId_Acquisition_Header_ChannelLocalisation
* ... some channel localisation stream header
* OVTK_NodeId_Acquisition_Header_ChannelUnits
* ... some channel units stream header
* OVTK_NodeId_Buffer
* OVTK_NodeId_Acquisition_Buffer_ExperimentInfo
* ... some experiment information stream buffer
* OVTK_NodeId_Acquisition_Buffer_Signal
* ... some signal stream buffer
* OVTK_NodeId_Acquisition_Buffer_Stimulation
* ... some stimulation stream buffer
* OVTK_NodeId_Acquisition_Buffer_ChannelLocalisation
* ... some channel localisation stream buffer
* OVTK_NodeId_Acquisition_Buffer_ChannelUnits
* ... some channel units stream buffer
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer
* ...
*/
#define OVTK_NodeId_Acquisition_Header_BufferDuration EBML::CIdentifier(0x00000000, 0x00000080)
#define OVTK_NodeId_Acquisition_Header_ExperimentInfo EBML::CIdentifier(0x00000000, 0x00000081)
#define OVTK_NodeId_Acquisition_Header_Signal EBML::CIdentifier(0x00000000, 0x00000082)
#define OVTK_NodeId_Acquisition_Header_Stimulation EBML::CIdentifier(0x00000000, 0x00000083)
#define OVTK_NodeId_Acquisition_Header_ChannelLocalisation EBML::CIdentifier(0x00000000, 0x00000084)
#define OVTK_NodeId_Acquisition_Header_ChannelUnits EBML::CIdentifier(0x00000000, 0x00000085)
#define OVTK_NodeId_Acquisition_Buffer_ExperimentInfo EBML::CIdentifier(0x00000000, 0x00000041)
#define OVTK_NodeId_Acquisition_Buffer_Signal EBML::CIdentifier(0x00000000, 0x00000042)
#define OVTK_NodeId_Acquisition_Buffer_Stimulation EBML::CIdentifier(0x00000000, 0x00000043)
#define OVTK_NodeId_Acquisition_Buffer_ChannelLocalisation EBML::CIdentifier(0x00000000, 0x00000044)
#define OVTK_NodeId_Acquisition_Buffer_ChannelUnits EBML::CIdentifier(0x00000000, 0x00000045)
#define OVTK_NodeId_Acquisition_Header EBML::CIdentifier(0x00000000, 0x00004239) // deprecated
#define OVTK_NodeId_Acquisition_AcquisitionInfo EBML::CIdentifier(0x00000000, 0x00004240) // deprecated
#define OVTK_NodeId_Acquisition_ExperimentId EBML::CIdentifier(0x00000000, 0x00004241) // deprecated
#define OVTK_NodeId_Acquisition_SubjectAge EBML::CIdentifier(0x00000000, 0x00004242) // deprecated
#define OVTK_NodeId_Acquisition_SubjectGender EBML::CIdentifier(0x00000000, 0x00004243) // deprecated
#define OVTK_NodeId_Acquisition_ChannelCount EBML::CIdentifier(0x00000000, 0x00004244) // deprecated
#define OVTK_NodeId_Acquisition_Sampling EBML::CIdentifier(0x00000000, 0x00004245) // deprecated
#define OVTK_NodeId_Acquisition_ChannelNames EBML::CIdentifier(0x00000000, 0x00004246) // deprecated
#define OVTK_NodeId_Acquisition_ChannelName EBML::CIdentifier(0x00000000, 0x00004247) // deprecated
#define OVTK_NodeId_Acquisition_GainFactors EBML::CIdentifier(0x00000000, 0x00004248) // deprecated
#define OVTK_NodeId_Acquisition_GainFactor EBML::CIdentifier(0x00000000, 0x00004249) // deprecated
#define OVTK_NodeId_Acquisition_ChannelLocations EBML::CIdentifier(0x00000000, 0x00004250) // deprecated
#define OVTK_NodeId_Acquisition_ChannelLocation EBML::CIdentifier(0x00000000, 0x00004251) // deprecated
#define OVTK_NodeId_Acquisition_Buffer EBML::CIdentifier(0x00000000, 0x0000005A) // deprecated
#define OVTK_NodeId_Acquisition_Samples EBML::CIdentifier(0x00000000, 0x0000005B) // deprecated
#define OVTK_NodeId_Acquisition_SamplesPerChannelCount EBML::CIdentifier(0x00000000, 0x0000005C) // deprecated
#define OVTK_NodeId_Acquisition_SampleBlock EBML::CIdentifier(0x00000000, 0x0000005D) // deprecated
#define OVTK_NodeId_Acquisition_Stimulations EBML::CIdentifier(0x00000000, 0x00000060) // deprecated
#define OVTK_NodeId_Acquisition_StimulationsCount EBML::CIdentifier(0x00000000, 0x00000061) // deprecated
#define OVTK_NodeId_Acquisition_Stimulation EBML::CIdentifier(0x00000000, 0x00000062) // deprecated
#define OVTK_NodeId_Acquisition_StimulationSampleIndex EBML::CIdentifier(0x00000000, 0x00000063) // deprecated
#define OVTK_NodeId_Acquisition_StimulationIdentifier EBML::CIdentifier(0x00000000, 0x00000064) // deprecated
#define OVTK_NodeId_Acquisition_SubjectSex EBML::CIdentifier(0x00000000, 0x00004243) // deprecated
//__________________________________________________________________//
// //
// Protocol hierarchy //
//__________________________________________________________________//
// //
/*
* - Standard EBML stream
* - Experiment information
* - Stimulation
* - Streamed Matrix
* - Signal
* - Spectrum
* - Feature vector
* - Channel localisation
* - Channel units
*/
//__________________________________________________________________//
// //
// Standard EBML stream node identifiers //
//__________________________________________________________________//
// //
#define OVTK_NodeId_Header EBML::CIdentifier(0x002B395F, 0x108ADFAE)
#define OVTK_NodeId_Header_StreamType EBML::CIdentifier(0x00CDD0F7, 0x46B0278D)
#define OVTK_NodeId_Header_StreamVersion EBML::CIdentifier(0x006F5A08, 0x7796EBC5)
#define OVTK_NodeId_Buffer EBML::CIdentifier(0x00CF2101, 0x02375310)
#define OVTK_NodeId_End EBML::CIdentifier(0x00D9DDC3, 0x0B12873A)
//__________________________________________________________________//
// //
// Streamed matrix stream node identifiers //
//__________________________________________________________________//
// //
#define OVTK_NodeId_Header_StreamedMatrix EBML::CIdentifier(0x0072F560, 0x7ED2CBED)
#define OVTK_NodeId_Header_StreamedMatrix_DimensionCount EBML::CIdentifier(0x003FEBD4, 0x2725D428)
#define OVTK_NodeId_Header_StreamedMatrix_Dimension EBML::CIdentifier(0x0000E3C0, 0x3A7D5141)
#define OVTK_NodeId_Header_StreamedMatrix_Dimension_Size EBML::CIdentifier(0x001302F7, 0x36D8438A)
#define OVTK_NodeId_Header_StreamedMatrix_Dimension_Label EBML::CIdentifier(0x00153E40, 0x190227E0)
#define OVTK_NodeId_Buffer_StreamedMatrix EBML::CIdentifier(0x00120663, 0x08FBC165)
#define OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer EBML::CIdentifier(0x00B18C10, 0x427D098C)
//__________________________________________________________________//
// //
// Signal stream node identifiers //
//__________________________________________________________________//
// //
/*
* Signal stream description
* v1 november 6th 2006
* v2 may 24th 2007
*
* version 2 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:2)
* OVTK_NodeId_Header_Signal
* OVTK_NodeId_Header_Signal_Sampling (integer)
* OVTK_NodeId_Header_StreamedMatrix
* OVTK_NodeId_Header_StreamedMatrix_DimensionCount (integer:2)
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:channel count)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 2 name)
* ...
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:number of samples per buffer)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string)
* ...
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
#define OVTK_NodeId_Header_Signal EBML::CIdentifier(0x007855DE, 0x3748D375)
#define OVTK_NodeId_Header_Signal_Sampling EBML::CIdentifier(0x00141C43, 0x0C37006B)
//__________________________________________________________________//
// //
// Channel localisation stream node identifiers //
//__________________________________________________________________//
// //
/*
* Channel localisation description
* v1 nov 04th 2008
*
* version 1 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:2)
* OVTK_NodeId_Header_ChannelLocalisation
* OVTK_NodeId_Header_ChannelLocalisation_Dynamic (bool)
* OVTK_NodeId_Header_StreamedMatrix
* OVTK_NodeId_Header_StreamedMatrix_DimensionCount (integer:2)
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:channel count)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 2 name)
* ...
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:3)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:x)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:y)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:z)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
#define OVTK_NodeId_Header_ChannelLocalisation EBML::CIdentifier(0xF2CFE60B, 0xEFD63E3B)
#define OVTK_NodeId_Header_ChannelLocalisation_Dynamic EBML::CIdentifier(0x5338AF5C, 0x07C469C3)
/*
* Channel units description
* v1 nov 2014
*
* version 1 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:1)
* OVTK_NodeId_Header_ChannelUnits
* OVTK_NodeId_Header_ChannelUnits_Dynamic (boolean)
* OVTK_NodeId_Header_StreamedMatrix
* OVTK_NodeId_Header_StreamedMatrix_DimensionCount (integer:2)
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:channel count)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 2 name)
* ...
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:2)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:unit)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:factor)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
#define OVTK_NodeId_Header_ChannelUnits EBML::CIdentifier(0x17400C76, 0x16CF14C8)
#define OVTK_NodeId_Header_ChannelUnits_Dynamic EBML::CIdentifier(0x7307023C, 0x7F754D2E)
//__________________________________________________________________//
// //
// Stimulation stream node identifiers //
//__________________________________________________________________//
// //
/*
* Stimulation stream description
* v1 november 6th 2006
* v2 may 24th 2007
* v3 ??
*
* version 3 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:2)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_Stimulation
* OVTK_NodeId_Buffer_Stimulation_NumberOfStimulations (integer)
* OVTK_NodeId_Buffer_Stimulation_Stimulation
* OVTK_NodeId_Buffer_Stimulation_Stimulation_ID (integer)
* OVTK_NodeId_Buffer_Stimulation_Stimulation_Date (integer)
* OVTK_NodeId_Buffer_Stimulation_Stimulation_Duration (integer)
* OVTK_NodeId_Stimulation_Stimulation
* ...
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
#define OVTK_NodeId_Buffer_Stimulation EBML::CIdentifier(0x006DEABE, 0x7FC05A20)
#define OVTK_NodeId_Buffer_Stimulation_NumberOfStimulations EBML::CIdentifier(0x00BB790B, 0x2B8574D8)
#define OVTK_NodeId_Buffer_Stimulation_Stimulation EBML::CIdentifier(0x0016EAC6, 0x29FBCAA1)
#define OVTK_NodeId_Buffer_Stimulation_Stimulation_ID EBML::CIdentifier(0x006FA5DB, 0x4BAC31E9)
#define OVTK_NodeId_Buffer_Stimulation_Stimulation_Date EBML::CIdentifier(0x00B866D8, 0x14DA5374)
#define OVTK_NodeId_Buffer_Stimulation_Stimulation_Duration EBML::CIdentifier(0x14EE055F, 0x87FBCC9C)
//__________________________________________________________________//
// //
// Experiment information node identifiers //
//__________________________________________________________________//
// //
/*
* Experiment information stream description (fixed on november 6th 2006)
*
* version 1 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:1)
* OVTK_NodeId_Header_ExperimentInfo
* OVTK_NodeId_Header_ExperimentInfo_Experiment
* OVTK_NodeId_Header_ExperimentInfo_Experiment_ID (integer)
* OVTK_NodeId_Header_ExperimentInfo_Experiment_Date (date)
* OVTK_NodeId_Header_ExperimentInfo_Subject
* OVTK_NodeId_Header_ExperimentInfo_Subject_ID (integer)
* OVTK_NodeId_Header_ExperimentInfo_Subject_Name (string)
* OVTK_NodeId_Header_ExperimentInfo_Subject_Age (integer)
* OVTK_NodeId_Header_ExperimentInfo_Subject_Gender (integer)
* OVTK_NodeId_Header_ExperimentInfo_Context
* OVTK_NodeId_Header_ExperimentInfo_Context_LaboratoryID (integer)
* OVTK_NodeId_Header_ExperimentInfo_Context_LaboratoryName (string)
* OVTK_NodeId_Header_ExperimentInfo_Context_TechnicianID (integer)
* OVTK_NodeId_Header_ExperimentInfo_Context_TechnicianName (string)
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
#define OVTK_NodeId_Header_ExperimentInfo EBML::CIdentifier(0x00746BA0, 0x115AE04D)
#define OVTK_NodeId_Header_ExperimentInfo_Experiment EBML::CIdentifier(0x0011D6B7, 0x48F1AA39)
#define OVTK_NodeId_Header_ExperimentInfo_Experiment_ID EBML::CIdentifier(0x006ACD74, 0x1C960C26)
#define OVTK_NodeId_Header_ExperimentInfo_Experiment_Date EBML::CIdentifier(0x002F8FB7, 0x6DA7552D)
#define OVTK_NodeId_Header_ExperimentInfo_Subject EBML::CIdentifier(0x003EC620, 0x333E0A94)
#define OVTK_NodeId_Header_ExperimentInfo_Subject_ID EBML::CIdentifier(0x00D62974, 0x473D4AA5)
#define OVTK_NodeId_Header_ExperimentInfo_Subject_Name EBML::CIdentifier(0x0041FD0A, 0x6BCD9A99)
#define OVTK_NodeId_Header_ExperimentInfo_Subject_Age EBML::CIdentifier(0x00DF7DD9, 0x33336C51)
#define OVTK_NodeId_Header_ExperimentInfo_Subject_Sex EBML::CIdentifier(0x0069BB84, 0x3FC8E149) /* for retro compat */
#define OVTK_NodeId_Header_ExperimentInfo_Subject_Gender EBML::CIdentifier(0x0069BB84, 0x3FC8E149)
#define OVTK_NodeId_Header_ExperimentInfo_Context EBML::CIdentifier(0x0018C291, 0x7985DFDD)
#define OVTK_NodeId_Header_ExperimentInfo_Context_LaboratoryID EBML::CIdentifier(0x003F11B9, 0x26D76D9C)
#define OVTK_NodeId_Header_ExperimentInfo_Context_LaboratoryName EBML::CIdentifier(0x00EB1F23, 0x51C23B83)
#define OVTK_NodeId_Header_ExperimentInfo_Context_TechnicianID EBML::CIdentifier(0x00874A7F, 0x60DC34C2)
#define OVTK_NodeId_Header_ExperimentInfo_Context_TechnicianName EBML::CIdentifier(0x00C8C393, 0x31CE5B3E)
//__________________________________________________________________//
// //
// Feature vector stream node identifiers //
//__________________________________________________________________//
// //
/*
* Feature vector stream description
* v1 may 24th 2007
*
* version 1 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:1)
* OVTK_NodeId_Header_StreamedMatrix
* OVTK_NodeId_Header_StreamedMatrix_DimensionCount (integer:1)
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:feature count)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:feature 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:feature 2 name)
* ...
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
//__________________________________________________________________//
// //
// Spectrum stream node identifiers //
//__________________________________________________________________//
// //
/*
* Spectrum stream description
* v1 june 4th 2007
*
* version 1 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:1)
* OVTK_NodeId_Header_StreamedMatrix
* OVTK_NodeId_Header_StreamedMatrix_DimensionCount (integer:2)
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:channel count)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 2 name)
* ...
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:number of frequency band)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:frequency band 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:frequency band 2 name)
* ...
* OVTK_NodeId_Header_Spectrum
* OVTK_NodeId_Header_Spectrum_FrequencyBand
* OVTK_NodeId_Header_Spectrum_FrequencyBand_Start (double)
* OVTK_NodeId_Header_Spectrum_FrequencyBand_Stop (double)
* OVTK_NodeId_Header_Spectrum_FrequencyBand
* OVTK_NodeId_Header_Spectrum_FrequencyBand_Start (double)
* OVTK_NodeId_Header_Spectrum_FrequencyBand_Stop (double)
* ...
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
/*
* Spectrum stream description
* v2 january 27th 2017
*
* version 2 :
* ----------------------------------------------------------------- *
* OVTK_NodeId_Header
* OVTK_NodeId_Header_StreamType (integer:)
* OVTK_NodeId_Header_StreamVersion (integer:1)
* OVTK_NodeId_Header_StreamedMatrix
* OVTK_NodeId_Header_StreamedMatrix_DimensionCount (integer:2)
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:channel count)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:channel 2 name)
* ...
* OVTK_NodeId_Header_StreamedMatrix_Dimension
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Size (integer:number of frequency)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:frequency 1 name)
* OVTK_NodeId_Header_StreamedMatrix_Dimension_Label (string:frequency 2 name)
* ...
* OVTK_NodeId_Header_Spectrum
* OVTK_NodeId_Header_Spectrum_Sampling (double)
* OVTK_NodeId_Header_Spectrum_FrequencyAbscissa (double)
* OVTK_NodeId_Header_Spectrum_FrequencyAbscissa (double)
* ...
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* OVTK_NodeId_Buffer
* OVTK_NodeId_Buffer_StreamedMatrix
* OVTK_NodeId_Buffer_StreamedMatrix_RawBuffer (array of double)
* ...
* OVTK_NodeId_End
* ----------------------------------------------------------------- *
*/
#define OVTK_NodeId_Header_Spectrum EBML::CIdentifier(0x00CCFA4B, 0x14F37D4D)
#define OVTK_NodeId_Header_Spectrum_FrequencyBand_Deprecated EBML::CIdentifier(0x0010983C, 0x21F8BDE5)
#define OVTK_NodeId_Header_Spectrum_FrequencyBand_Start_Deprecated EBML::CIdentifier(0x00AA5654, 0x2403A2CB)
#define OVTK_NodeId_Header_Spectrum_FrequencyBand_Stop_Deprecated EBML::CIdentifier(0x00A44C82, 0x05BE50D5)
#define OVTK_NodeId_Header_Spectrum_FrequencyAbscissa EBML::CIdentifier(0x00D7287D, 0x622A2BF5)
#define OVTK_NodeId_Header_Spectrum_Sampling EBML::CIdentifier(0x006876E9, 0x1DCB0CA1)
//__________________________________________________________________//
// //
// //
//__________________________________________________________________//
// //
/*
#define OVTK_NodeId_ EBML::CIdentifier(0x0027615F, 0x2243F7B5)
#define OVTK_NodeId_ EBML::CIdentifier(0x00866CC6, 0x1EFE4BDC)
#define OVTK_NodeId_ EBML::CIdentifier(0x00C91900, 0x55E50FF0)
#define OVTK_NodeId_ EBML::CIdentifier(0x00E0E260, 0x646BF99E)
#define OVTK_NodeId_ EBML::CIdentifier(0x00DCE72C, 0x386A40C5)
#define OVTK_NodeId_ EBML::CIdentifier(0x00C520C6, 0x09AE98B5)
#define OVTK_NodeId_ EBML::CIdentifier(0x00F1CBCB, 0x56BD6821)
*/
#define OVTK_ClassId_ OpenViBE::CIdentifier(0x00C6D56F, 0x30890D27)
#define OVTK_ClassId_Stimulation OpenViBE::CIdentifier(0xE4E131F0, 0xC6550E9E)
#define OVTK_ClassId_BaseAlgorithms_DataImporterT OpenViBE::CIdentifier(0xA6BB8664, 0xF1B9DE96)
#define OVTK_ClassId_BaseAlgorithms_DataExporterT OpenViBE::CIdentifier(0xA432362A, 0x5CD4F227)
#define OVTK_ClassId_Vector OpenViBE::CIdentifier(0x5D113170, 0x941C8932)
#define OVTK_ClassId_FeatureVector OpenViBE::CIdentifier(0xF44A9CBD, 0x459DBA69)
#define OVTK_ClassId_FeatureVectorSet OpenViBE::CIdentifier(0x6D5FB77B, 0x5BDD0420)
//__________________________________________________________________//
// //
// API Definition //
//__________________________________________________________________//
// //
// Taken from
// - http://people.redhat.com/drepper/dsohowto.pdf
// - http://www.nedprod.com/programs/gccvisibility.html
#if defined OVTK_Shared
#if defined TARGET_OS_Windows
#define OVTK_API_Export __declspec(dllexport)
#define OVTK_API_Import __declspec(dllimport)
#elif defined TARGET_OS_Linux || defined TARGET_OS_MacOS
#define OVTK_API_Export __attribute__((visibility("default")))
#define OVTK_API_Import __attribute__((visibility("default")))
#else
#define OVTK_API_Export
#define OVTK_API_Import
#endif
#else
#define OVTK_API_Export
#define OVTK_API_Import
#endif
#if defined OVTK_Exports
#define OVTK_API OVTK_API_Export
#else
#define OVTK_API OVTK_API_Import
#endif
@@ -0,0 +1,32 @@
#pragma once
#include "../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
namespace Matrix {
// Can be used : CMatrix class behaviour is a little different but this function is never used (except in test). Avoid to used it, intended to be removed.
OVTK_API bool toString(const CMatrix& matrix, CString& str, const size_t precision = 6);
OVTK_API bool fromString(CMatrix& matrix, const CString& str);
OVTK_API bool saveToTextFile(const CMatrix& matrix, const CString& filename, const size_t precision = 6);
OVTK_API bool loadFromTextFile(CMatrix& matrix, const CString& filename);
//@todo All is useless now. Avoid to used it, intended to be removed.
OVTK_API bool copy(CMatrix& dst, const CMatrix& src);
OVTK_API bool copyDescription(CMatrix& dst, const CMatrix& src);
OVTK_API bool copyContent(CMatrix& dst, const CMatrix& src);
OVTK_API bool clearContent(CMatrix& matrix); //(resetBuffer)
OVTK_API bool isDescriptionSimilar(const CMatrix& src1, const CMatrix& src2, bool checkLabels = true); //(isDescriptionEqual)
OVTK_API bool isContentSimilar(const CMatrix& src1, const CMatrix& src2); //(isBufferEqual)
OVTK_API bool isContentValid(const CMatrix& src, const bool checkNotANumber = true, const bool checkInfinity = true); //(isBufferValid)
} // namespace Matrix
//@todo All is useless now. Avoid to used it, intended to be removed.
namespace MatrixManipulation {
inline bool copy(CMatrix& dst, const CMatrix& src) { return Matrix::copy(dst, src); }
inline bool copyDescription(CMatrix& dst, const CMatrix& src) { return Matrix::copyDescription(dst, src); }
inline bool copyContent(CMatrix& dst, const CMatrix& src) { return Matrix::copyContent(dst, src); }
inline bool clearContent(CMatrix& rMatrix) { return Matrix::clearContent(rMatrix); }
} // namespace MatrixManipulation
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,15 @@
#pragma once
#include "../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
namespace StimulationSet {
OVTK_API bool shift(IStimulationSet& stimSet, uint64_t timeShift);
OVTK_API bool copy(IStimulationSet& dst, const IStimulationSet& src, uint64_t timeShift = 0);
OVTK_API bool append(IStimulationSet& dst, const IStimulationSet& src, uint64_t timeShift = 0);
OVTK_API bool appendRange(IStimulationSet& dst, const IStimulationSet& src, uint64_t srcStartTime, uint64_t srcEndTime, uint64_t timeShift = 0);
OVTK_API bool removeRange(IStimulationSet& stimSet, uint64_t startTime, uint64_t endTime);
} // namespace StimulationSet
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,36 @@
#pragma once
#include "../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
namespace String {
class OVTK_API ISplitCallback
{
public:
virtual ~ISplitCallback() { }
virtual void beginSplit() const { }
virtual void endSplit() const { }
virtual void setToken(const char* token) const = 0;
};
template <class TContainer>
class TSplitCallback final : public ISplitCallback
{
public:
explicit TSplitCallback(TContainer& tokenContainers) : m_tokenContainer(&tokenContainers) { }
void setToken(const char* token) const override { m_tokenContainer->push_back(token); }
protected:
TContainer* m_tokenContainer = nullptr;
};
OVTK_API size_t split(const CString& str, const ISplitCallback& splitCB, uint8_t separator);
OVTK_API size_t split(const CString& str, const ISplitCallback& splitCB, uint8_t* separator, const size_t nSeparator);
OVTK_API bool isAlmostEqual(const CString& str1, const CString& str2, bool caseSensitive = true, bool removeStartSpaces = true, bool removeEndSpaces = true);
} // namespace String
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,41 @@
#pragma once
#include "../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
class OVTK_API ISignalTrial : public IObject
{
public:
virtual bool setSamplingRate(size_t sampling) = 0;
virtual bool setChannelCount(size_t count) = 0;
virtual bool setChannelName(size_t index, const char* name) = 0;
virtual bool setLabelIdentifier(const CIdentifier& labelIdentifier) = 0;
virtual bool setSampleCount(size_t count, bool preserve) = 0;
virtual size_t getSamplingRate() const = 0;
virtual size_t getChannelCount() const = 0;
virtual const char* getChannelName(const size_t index) const = 0;
virtual CIdentifier getLabelIdentifier() const = 0;
virtual size_t getSampleCount() const = 0;
virtual uint64_t getDuration() const = 0;
virtual double* getChannelSampleBuffer(size_t index) const = 0;
_IsDerivedFromClass_(IObject, OVTK_ClassId_)
};
extern OVTK_API ISignalTrial* createSignalTrial();
extern OVTK_API void releaseSignalTrial(ISignalTrial* trial);
// operations
extern OVTK_API ISignalTrial& copyHeader(ISignalTrial& trial, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& copy(ISignalTrial& trial, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& selectSamples(ISignalTrial& trial, size_t sampleStart, size_t sampleEnd, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& selectTime(ISignalTrial& trial, uint64_t timeStart, uint64_t timeEnd, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& removeSamples(ISignalTrial& trial, size_t sampleStart, size_t sampleEnd, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& removeTime(ISignalTrial& trial, uint64_t timeStart, uint64_t timeEnd, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& insertBufferSamples(ISignalTrial& trial, size_t sampleStart, size_t nSample, const double* buffer, const ISignalTrial* srcTrial = nullptr);
extern OVTK_API ISignalTrial& insertBufferTime(ISignalTrial& trial, uint64_t timeStart, size_t nSample, const double* buffer, const ISignalTrial* srcTrial = nullptr);
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,25 @@
#pragma once
#include "../ovtk_base.h"
namespace OpenViBE {
namespace Toolkit {
class ISignalTrial;
class OVTK_API ISignalTrialSet : public IObject
{
public:
virtual bool addSignalTrial(ISignalTrial& signalTrial) = 0;
virtual bool clear() = 0;
virtual size_t getSignalTrialCount() const = 0;
virtual ISignalTrial& getSignalTrial(const size_t index) const = 0;
_IsDerivedFromClass_(IObject, OVTK_ClassId_)
};
extern OVTK_API ISignalTrialSet* createSignalTrialSet();
extern OVTK_API void releaseSignalTrialSet(ISignalTrialSet* signalTrialSet);
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,431 @@
OVTK_StimulationId_ExperimentStart OVTK_StimulationId_ExperimentStart 0x00008001
OVTK_StimulationId_ExperimentStop OVTK_StimulationId_ExperimentStop 0x00008002
OVTK_StimulationId_SegmentStart OVTK_StimulationId_SegmentStart 0x00008003
OVTK_StimulationId_SegmentStop OVTK_StimulationId_SegmentStop 0x00008004
OVTK_StimulationId_TrialStart OVTK_StimulationId_TrialStart 0x00008005
OVTK_StimulationId_TrialStop OVTK_StimulationId_TrialStop 0x00008006
OVTK_StimulationId_BaselineStart OVTK_StimulationId_BaselineStart 0x00008007
OVTK_StimulationId_BaselineStop OVTK_StimulationId_BaselineStop 0x00008008
OVTK_StimulationId_RestStart OVTK_StimulationId_RestStart 0x00008009
OVTK_StimulationId_RestStop OVTK_StimulationId_RestStop 0x0000800a
OVTK_StimulationId_VisualStimulationStart OVTK_StimulationId_VisualStimulationStart 0x0000800b
OVTK_StimulationId_VisualStimulationStop OVTK_StimulationId_VisualStimulationStop 0x0000800c
OVTK_StimulationId_VisualSteadyStateStimulationStart OVTK_StimulationId_VisualSteadyStateStimulationStart 0x00008010
OVTK_StimulationId_VisualSteadyStateStimulationStop OVTK_StimulationId_VisualSteadyStateStimulationStop 0x00008011
OVTK_StimulationId_Button1_Pressed OVTK_StimulationId_Button1_Pressed 0x00008012
OVTK_StimulationId_Button1_Released OVTK_StimulationId_Button1_Released 0x00008013
OVTK_StimulationId_Button2_Pressed OVTK_StimulationId_Button2_Pressed 0x00008014
OVTK_StimulationId_Button2_Released OVTK_StimulationId_Button2_Released 0x00008015
OVTK_StimulationId_Button3_Pressed OVTK_StimulationId_Button3_Pressed 0x00008016
OVTK_StimulationId_Button3_Released OVTK_StimulationId_Button3_Released 0x00008017
OVTK_StimulationId_Button4_Pressed OVTK_StimulationId_Button4_Pressed 0x00008018
OVTK_StimulationId_Button4_Released OVTK_StimulationId_Button4_Released 0x00008019
OVTK_StimulationId_Label_00 OVTK_StimulationId_Label_00 0x00008100
OVTK_StimulationId_Label_01 OVTK_StimulationId_Label_01 0x00008101
OVTK_StimulationId_Label_02 OVTK_StimulationId_Label_02 0x00008102
OVTK_StimulationId_Label_03 OVTK_StimulationId_Label_03 0x00008103
OVTK_StimulationId_Label_04 OVTK_StimulationId_Label_04 0x00008104
OVTK_StimulationId_Label_05 OVTK_StimulationId_Label_05 0x00008105
OVTK_StimulationId_Label_06 OVTK_StimulationId_Label_06 0x00008106
OVTK_StimulationId_Label_07 OVTK_StimulationId_Label_07 0x00008107
OVTK_StimulationId_Label_08 OVTK_StimulationId_Label_08 0x00008108
OVTK_StimulationId_Label_09 OVTK_StimulationId_Label_09 0x00008109
OVTK_StimulationId_Label_0A OVTK_StimulationId_Label_0A 0x0000810a
OVTK_StimulationId_Label_0B OVTK_StimulationId_Label_0B 0x0000810b
OVTK_StimulationId_Label_0C OVTK_StimulationId_Label_0C 0x0000810c
OVTK_StimulationId_Label_0D OVTK_StimulationId_Label_0D 0x0000810d
OVTK_StimulationId_Label_0E OVTK_StimulationId_Label_0E 0x0000810e
OVTK_StimulationId_Label_0F OVTK_StimulationId_Label_0F 0x0000810f
OVTK_StimulationId_Label_10 OVTK_StimulationId_Label_10 0x00008110
OVTK_StimulationId_Label_11 OVTK_StimulationId_Label_11 0x00008111
OVTK_StimulationId_Label_12 OVTK_StimulationId_Label_12 0x00008112
OVTK_StimulationId_Label_13 OVTK_StimulationId_Label_13 0x00008113
OVTK_StimulationId_Label_14 OVTK_StimulationId_Label_14 0x00008114
OVTK_StimulationId_Label_15 OVTK_StimulationId_Label_15 0x00008115
OVTK_StimulationId_Label_16 OVTK_StimulationId_Label_16 0x00008116
OVTK_StimulationId_Label_17 OVTK_StimulationId_Label_17 0x00008117
OVTK_StimulationId_Label_18 OVTK_StimulationId_Label_18 0x00008118
OVTK_StimulationId_Label_19 OVTK_StimulationId_Label_19 0x00008119
OVTK_StimulationId_Label_1A OVTK_StimulationId_Label_1A 0x0000811a
OVTK_StimulationId_Label_1B OVTK_StimulationId_Label_1B 0x0000811b
OVTK_StimulationId_Label_1C OVTK_StimulationId_Label_1C 0x0000811c
OVTK_StimulationId_Label_1D OVTK_StimulationId_Label_1D 0x0000811d
OVTK_StimulationId_Label_1E OVTK_StimulationId_Label_1E 0x0000811e
OVTK_StimulationId_Label_1F OVTK_StimulationId_Label_1F 0x0000811f
OVTK_StimulationId_Label_20 OVTK_StimulationId_Label_20 0x00008120
OVTK_StimulationId_Label_21 OVTK_StimulationId_Label_21 0x00008121
OVTK_StimulationId_Label_22 OVTK_StimulationId_Label_22 0x00008122
OVTK_StimulationId_Label_23 OVTK_StimulationId_Label_23 0x00008123
OVTK_StimulationId_Label_24 OVTK_StimulationId_Label_24 0x00008124
OVTK_StimulationId_Label_25 OVTK_StimulationId_Label_25 0x00008125
OVTK_StimulationId_Label_26 OVTK_StimulationId_Label_26 0x00008126
OVTK_StimulationId_Label_27 OVTK_StimulationId_Label_27 0x00008127
OVTK_StimulationId_Label_28 OVTK_StimulationId_Label_28 0x00008128
OVTK_StimulationId_Label_29 OVTK_StimulationId_Label_29 0x00008129
OVTK_StimulationId_Label_2A OVTK_StimulationId_Label_2A 0x0000812a
OVTK_StimulationId_Label_2B OVTK_StimulationId_Label_2B 0x0000812b
OVTK_StimulationId_Label_2C OVTK_StimulationId_Label_2C 0x0000812c
OVTK_StimulationId_Label_2D OVTK_StimulationId_Label_2D 0x0000812d
OVTK_StimulationId_Label_2E OVTK_StimulationId_Label_2E 0x0000812e
OVTK_StimulationId_Label_2F OVTK_StimulationId_Label_2F 0x0000812f
OVTK_StimulationId_Label_30 OVTK_StimulationId_Label_30 0x00008130
OVTK_StimulationId_Label_31 OVTK_StimulationId_Label_31 0x00008131
OVTK_StimulationId_Label_32 OVTK_StimulationId_Label_32 0x00008132
OVTK_StimulationId_Label_33 OVTK_StimulationId_Label_33 0x00008133
OVTK_StimulationId_Label_34 OVTK_StimulationId_Label_34 0x00008134
OVTK_StimulationId_Label_35 OVTK_StimulationId_Label_35 0x00008135
OVTK_StimulationId_Label_36 OVTK_StimulationId_Label_36 0x00008136
OVTK_StimulationId_Label_37 OVTK_StimulationId_Label_37 0x00008137
OVTK_StimulationId_Label_38 OVTK_StimulationId_Label_38 0x00008138
OVTK_StimulationId_Label_39 OVTK_StimulationId_Label_39 0x00008139
OVTK_StimulationId_Label_3A OVTK_StimulationId_Label_3A 0x0000813a
OVTK_StimulationId_Label_3B OVTK_StimulationId_Label_3B 0x0000813b
OVTK_StimulationId_Label_3C OVTK_StimulationId_Label_3C 0x0000813c
OVTK_StimulationId_Label_3D OVTK_StimulationId_Label_3D 0x0000813d
OVTK_StimulationId_Label_3E OVTK_StimulationId_Label_3E 0x0000813e
OVTK_StimulationId_Label_3F OVTK_StimulationId_Label_3F 0x0000813f
OVTK_StimulationId_Label_40 OVTK_StimulationId_Label_40 0x00008140
OVTK_StimulationId_Label_41 OVTK_StimulationId_Label_41 0x00008141
OVTK_StimulationId_Label_42 OVTK_StimulationId_Label_42 0x00008142
OVTK_StimulationId_Label_43 OVTK_StimulationId_Label_43 0x00008143
OVTK_StimulationId_Label_44 OVTK_StimulationId_Label_44 0x00008144
OVTK_StimulationId_Label_45 OVTK_StimulationId_Label_45 0x00008145
OVTK_StimulationId_Label_46 OVTK_StimulationId_Label_46 0x00008146
OVTK_StimulationId_Label_47 OVTK_StimulationId_Label_47 0x00008147
OVTK_StimulationId_Label_48 OVTK_StimulationId_Label_48 0x00008148
OVTK_StimulationId_Label_49 OVTK_StimulationId_Label_49 0x00008149
OVTK_StimulationId_Label_4A OVTK_StimulationId_Label_4A 0x0000814a
OVTK_StimulationId_Label_4B OVTK_StimulationId_Label_4B 0x0000814b
OVTK_StimulationId_Label_4C OVTK_StimulationId_Label_4C 0x0000814c
OVTK_StimulationId_Label_4D OVTK_StimulationId_Label_4D 0x0000814d
OVTK_StimulationId_Label_4E OVTK_StimulationId_Label_4E 0x0000814e
OVTK_StimulationId_Label_4F OVTK_StimulationId_Label_4F 0x0000814f
OVTK_StimulationId_Label_50 OVTK_StimulationId_Label_50 0x00008150
OVTK_StimulationId_Label_51 OVTK_StimulationId_Label_51 0x00008151
OVTK_StimulationId_Label_52 OVTK_StimulationId_Label_52 0x00008152
OVTK_StimulationId_Label_53 OVTK_StimulationId_Label_53 0x00008153
OVTK_StimulationId_Label_54 OVTK_StimulationId_Label_54 0x00008154
OVTK_StimulationId_Label_55 OVTK_StimulationId_Label_55 0x00008155
OVTK_StimulationId_Label_56 OVTK_StimulationId_Label_56 0x00008156
OVTK_StimulationId_Label_57 OVTK_StimulationId_Label_57 0x00008157
OVTK_StimulationId_Label_58 OVTK_StimulationId_Label_58 0x00008158
OVTK_StimulationId_Label_59 OVTK_StimulationId_Label_59 0x00008159
OVTK_StimulationId_Label_5A OVTK_StimulationId_Label_5A 0x0000815a
OVTK_StimulationId_Label_5B OVTK_StimulationId_Label_5B 0x0000815b
OVTK_StimulationId_Label_5C OVTK_StimulationId_Label_5C 0x0000815c
OVTK_StimulationId_Label_5D OVTK_StimulationId_Label_5D 0x0000815d
OVTK_StimulationId_Label_5E OVTK_StimulationId_Label_5E 0x0000815e
OVTK_StimulationId_Label_5F OVTK_StimulationId_Label_5F 0x0000815f
OVTK_StimulationId_Label_60 OVTK_StimulationId_Label_60 0x00008160
OVTK_StimulationId_Label_61 OVTK_StimulationId_Label_61 0x00008161
OVTK_StimulationId_Label_62 OVTK_StimulationId_Label_62 0x00008162
OVTK_StimulationId_Label_63 OVTK_StimulationId_Label_63 0x00008163
OVTK_StimulationId_Label_64 OVTK_StimulationId_Label_64 0x00008164
OVTK_StimulationId_Label_65 OVTK_StimulationId_Label_65 0x00008165
OVTK_StimulationId_Label_66 OVTK_StimulationId_Label_66 0x00008166
OVTK_StimulationId_Label_67 OVTK_StimulationId_Label_67 0x00008167
OVTK_StimulationId_Label_68 OVTK_StimulationId_Label_68 0x00008168
OVTK_StimulationId_Label_69 OVTK_StimulationId_Label_69 0x00008169
OVTK_StimulationId_Label_6A OVTK_StimulationId_Label_6A 0x0000816a
OVTK_StimulationId_Label_6B OVTK_StimulationId_Label_6B 0x0000816b
OVTK_StimulationId_Label_6C OVTK_StimulationId_Label_6C 0x0000816c
OVTK_StimulationId_Label_6D OVTK_StimulationId_Label_6D 0x0000816d
OVTK_StimulationId_Label_6E OVTK_StimulationId_Label_6E 0x0000816e
OVTK_StimulationId_Label_6F OVTK_StimulationId_Label_6F 0x0000816f
OVTK_StimulationId_Label_70 OVTK_StimulationId_Label_70 0x00008170
OVTK_StimulationId_Label_71 OVTK_StimulationId_Label_71 0x00008171
OVTK_StimulationId_Label_72 OVTK_StimulationId_Label_72 0x00008172
OVTK_StimulationId_Label_73 OVTK_StimulationId_Label_73 0x00008173
OVTK_StimulationId_Label_74 OVTK_StimulationId_Label_74 0x00008174
OVTK_StimulationId_Label_75 OVTK_StimulationId_Label_75 0x00008175
OVTK_StimulationId_Label_76 OVTK_StimulationId_Label_76 0x00008176
OVTK_StimulationId_Label_77 OVTK_StimulationId_Label_77 0x00008177
OVTK_StimulationId_Label_78 OVTK_StimulationId_Label_78 0x00008178
OVTK_StimulationId_Label_79 OVTK_StimulationId_Label_79 0x00008179
OVTK_StimulationId_Label_7A OVTK_StimulationId_Label_7A 0x0000817a
OVTK_StimulationId_Label_7B OVTK_StimulationId_Label_7B 0x0000817b
OVTK_StimulationId_Label_7C OVTK_StimulationId_Label_7C 0x0000817c
OVTK_StimulationId_Label_7D OVTK_StimulationId_Label_7D 0x0000817d
OVTK_StimulationId_Label_7E OVTK_StimulationId_Label_7E 0x0000817e
OVTK_StimulationId_Label_7F OVTK_StimulationId_Label_7F 0x0000817f
OVTK_StimulationId_Label_80 OVTK_StimulationId_Label_80 0x00008180
OVTK_StimulationId_Label_81 OVTK_StimulationId_Label_81 0x00008181
OVTK_StimulationId_Label_82 OVTK_StimulationId_Label_82 0x00008182
OVTK_StimulationId_Label_83 OVTK_StimulationId_Label_83 0x00008183
OVTK_StimulationId_Label_84 OVTK_StimulationId_Label_84 0x00008184
OVTK_StimulationId_Label_85 OVTK_StimulationId_Label_85 0x00008185
OVTK_StimulationId_Label_86 OVTK_StimulationId_Label_86 0x00008186
OVTK_StimulationId_Label_87 OVTK_StimulationId_Label_87 0x00008187
OVTK_StimulationId_Label_88 OVTK_StimulationId_Label_88 0x00008188
OVTK_StimulationId_Label_89 OVTK_StimulationId_Label_89 0x00008189
OVTK_StimulationId_Label_8A OVTK_StimulationId_Label_8A 0x0000818a
OVTK_StimulationId_Label_8B OVTK_StimulationId_Label_8B 0x0000818b
OVTK_StimulationId_Label_8C OVTK_StimulationId_Label_8C 0x0000818c
OVTK_StimulationId_Label_8D OVTK_StimulationId_Label_8D 0x0000818d
OVTK_StimulationId_Label_8E OVTK_StimulationId_Label_8E 0x0000818e
OVTK_StimulationId_Label_8F OVTK_StimulationId_Label_8F 0x0000818f
OVTK_StimulationId_Label_90 OVTK_StimulationId_Label_90 0x00008190
OVTK_StimulationId_Label_91 OVTK_StimulationId_Label_91 0x00008191
OVTK_StimulationId_Label_92 OVTK_StimulationId_Label_92 0x00008192
OVTK_StimulationId_Label_93 OVTK_StimulationId_Label_93 0x00008193
OVTK_StimulationId_Label_94 OVTK_StimulationId_Label_94 0x00008194
OVTK_StimulationId_Label_95 OVTK_StimulationId_Label_95 0x00008195
OVTK_StimulationId_Label_96 OVTK_StimulationId_Label_96 0x00008196
OVTK_StimulationId_Label_97 OVTK_StimulationId_Label_97 0x00008197
OVTK_StimulationId_Label_98 OVTK_StimulationId_Label_98 0x00008198
OVTK_StimulationId_Label_99 OVTK_StimulationId_Label_99 0x00008199
OVTK_StimulationId_Label_9A OVTK_StimulationId_Label_9A 0x0000819a
OVTK_StimulationId_Label_9B OVTK_StimulationId_Label_9B 0x0000819b
OVTK_StimulationId_Label_9C OVTK_StimulationId_Label_9C 0x0000819c
OVTK_StimulationId_Label_9D OVTK_StimulationId_Label_9D 0x0000819d
OVTK_StimulationId_Label_9E OVTK_StimulationId_Label_9E 0x0000819e
OVTK_StimulationId_Label_9F OVTK_StimulationId_Label_9F 0x0000819f
OVTK_StimulationId_Label_A0 OVTK_StimulationId_Label_A0 0x000081a0
OVTK_StimulationId_Label_A1 OVTK_StimulationId_Label_A1 0x000081a1
OVTK_StimulationId_Label_A2 OVTK_StimulationId_Label_A2 0x000081a2
OVTK_StimulationId_Label_A3 OVTK_StimulationId_Label_A3 0x000081a3
OVTK_StimulationId_Label_A4 OVTK_StimulationId_Label_A4 0x000081a4
OVTK_StimulationId_Label_A5 OVTK_StimulationId_Label_A5 0x000081a5
OVTK_StimulationId_Label_A6 OVTK_StimulationId_Label_A6 0x000081a6
OVTK_StimulationId_Label_A7 OVTK_StimulationId_Label_A7 0x000081a7
OVTK_StimulationId_Label_A8 OVTK_StimulationId_Label_A8 0x000081a8
OVTK_StimulationId_Label_A9 OVTK_StimulationId_Label_A9 0x000081a9
OVTK_StimulationId_Label_AA OVTK_StimulationId_Label_AA 0x000081aa
OVTK_StimulationId_Label_AB OVTK_StimulationId_Label_AB 0x000081ab
OVTK_StimulationId_Label_AC OVTK_StimulationId_Label_AC 0x000081ac
OVTK_StimulationId_Label_AD OVTK_StimulationId_Label_AD 0x000081ad
OVTK_StimulationId_Label_AE OVTK_StimulationId_Label_AE 0x000081ae
OVTK_StimulationId_Label_AF OVTK_StimulationId_Label_AF 0x000081af
OVTK_StimulationId_Label_B0 OVTK_StimulationId_Label_B0 0x000081b0
OVTK_StimulationId_Label_B1 OVTK_StimulationId_Label_B1 0x000081b1
OVTK_StimulationId_Label_B2 OVTK_StimulationId_Label_B2 0x000081b2
OVTK_StimulationId_Label_B3 OVTK_StimulationId_Label_B3 0x000081b3
OVTK_StimulationId_Label_B4 OVTK_StimulationId_Label_B4 0x000081b4
OVTK_StimulationId_Label_B5 OVTK_StimulationId_Label_B5 0x000081b5
OVTK_StimulationId_Label_B6 OVTK_StimulationId_Label_B6 0x000081b6
OVTK_StimulationId_Label_B7 OVTK_StimulationId_Label_B7 0x000081b7
OVTK_StimulationId_Label_B8 OVTK_StimulationId_Label_B8 0x000081b8
OVTK_StimulationId_Label_B9 OVTK_StimulationId_Label_B9 0x000081b9
OVTK_StimulationId_Label_BA OVTK_StimulationId_Label_BA 0x000081ba
OVTK_StimulationId_Label_BB OVTK_StimulationId_Label_BB 0x000081bb
OVTK_StimulationId_Label_BC OVTK_StimulationId_Label_BC 0x000081bc
OVTK_StimulationId_Label_BD OVTK_StimulationId_Label_BD 0x000081bd
OVTK_StimulationId_Label_BE OVTK_StimulationId_Label_BE 0x000081be
OVTK_StimulationId_Label_BF OVTK_StimulationId_Label_BF 0x000081bf
OVTK_StimulationId_Label_C0 OVTK_StimulationId_Label_C0 0x000081c0
OVTK_StimulationId_Label_C1 OVTK_StimulationId_Label_C1 0x000081c1
OVTK_StimulationId_Label_C2 OVTK_StimulationId_Label_C2 0x000081c2
OVTK_StimulationId_Label_C3 OVTK_StimulationId_Label_C3 0x000081c3
OVTK_StimulationId_Label_C4 OVTK_StimulationId_Label_C4 0x000081c4
OVTK_StimulationId_Label_C5 OVTK_StimulationId_Label_C5 0x000081c5
OVTK_StimulationId_Label_C6 OVTK_StimulationId_Label_C6 0x000081c6
OVTK_StimulationId_Label_C7 OVTK_StimulationId_Label_C7 0x000081c7
OVTK_StimulationId_Label_C8 OVTK_StimulationId_Label_C8 0x000081c8
OVTK_StimulationId_Label_C9 OVTK_StimulationId_Label_C9 0x000081c9
OVTK_StimulationId_Label_CA OVTK_StimulationId_Label_CA 0x000081ca
OVTK_StimulationId_Label_CB OVTK_StimulationId_Label_CB 0x000081cb
OVTK_StimulationId_Label_CC OVTK_StimulationId_Label_CC 0x000081cc
OVTK_StimulationId_Label_CD OVTK_StimulationId_Label_CD 0x000081cd
OVTK_StimulationId_Label_CE OVTK_StimulationId_Label_CE 0x000081ce
OVTK_StimulationId_Label_CF OVTK_StimulationId_Label_CF 0x000081cf
OVTK_StimulationId_Label_D0 OVTK_StimulationId_Label_D0 0x000081d0
OVTK_StimulationId_Label_D1 OVTK_StimulationId_Label_D1 0x000081d1
OVTK_StimulationId_Label_D2 OVTK_StimulationId_Label_D2 0x000081d2
OVTK_StimulationId_Label_D3 OVTK_StimulationId_Label_D3 0x000081d3
OVTK_StimulationId_Label_D4 OVTK_StimulationId_Label_D4 0x000081d4
OVTK_StimulationId_Label_D5 OVTK_StimulationId_Label_D5 0x000081d5
OVTK_StimulationId_Label_D6 OVTK_StimulationId_Label_D6 0x000081d6
OVTK_StimulationId_Label_D7 OVTK_StimulationId_Label_D7 0x000081d7
OVTK_StimulationId_Label_D8 OVTK_StimulationId_Label_D8 0x000081d8
OVTK_StimulationId_Label_D9 OVTK_StimulationId_Label_D9 0x000081d9
OVTK_StimulationId_Label_DA OVTK_StimulationId_Label_DA 0x000081da
OVTK_StimulationId_Label_DB OVTK_StimulationId_Label_DB 0x000081db
OVTK_StimulationId_Label_DC OVTK_StimulationId_Label_DC 0x000081dc
OVTK_StimulationId_Label_DD OVTK_StimulationId_Label_DD 0x000081dd
OVTK_StimulationId_Label_DE OVTK_StimulationId_Label_DE 0x000081de
OVTK_StimulationId_Label_DF OVTK_StimulationId_Label_DF 0x000081df
OVTK_StimulationId_Label_E0 OVTK_StimulationId_Label_E0 0x000081e0
OVTK_StimulationId_Label_E1 OVTK_StimulationId_Label_E1 0x000081e1
OVTK_StimulationId_Label_E2 OVTK_StimulationId_Label_E2 0x000081e2
OVTK_StimulationId_Label_E3 OVTK_StimulationId_Label_E3 0x000081e3
OVTK_StimulationId_Label_E4 OVTK_StimulationId_Label_E4 0x000081e4
OVTK_StimulationId_Label_E5 OVTK_StimulationId_Label_E5 0x000081e5
OVTK_StimulationId_Label_E6 OVTK_StimulationId_Label_E6 0x000081e6
OVTK_StimulationId_Label_E7 OVTK_StimulationId_Label_E7 0x000081e7
OVTK_StimulationId_Label_E8 OVTK_StimulationId_Label_E8 0x000081e8
OVTK_StimulationId_Label_E9 OVTK_StimulationId_Label_E9 0x000081e9
OVTK_StimulationId_Label_EA OVTK_StimulationId_Label_EA 0x000081ea
OVTK_StimulationId_Label_EB OVTK_StimulationId_Label_EB 0x000081eb
OVTK_StimulationId_Label_EC OVTK_StimulationId_Label_EC 0x000081ec
OVTK_StimulationId_Label_ED OVTK_StimulationId_Label_ED 0x000081ed
OVTK_StimulationId_Label_EE OVTK_StimulationId_Label_EE 0x000081ee
OVTK_StimulationId_Label_EF OVTK_StimulationId_Label_EF 0x000081ef
OVTK_StimulationId_Label_F0 OVTK_StimulationId_Label_F0 0x000081f0
OVTK_StimulationId_Label_F1 OVTK_StimulationId_Label_F1 0x000081f1
OVTK_StimulationId_Label_F2 OVTK_StimulationId_Label_F2 0x000081f2
OVTK_StimulationId_Label_F3 OVTK_StimulationId_Label_F3 0x000081f3
OVTK_StimulationId_Label_F4 OVTK_StimulationId_Label_F4 0x000081f4
OVTK_StimulationId_Label_F5 OVTK_StimulationId_Label_F5 0x000081f5
OVTK_StimulationId_Label_F6 OVTK_StimulationId_Label_F6 0x000081f6
OVTK_StimulationId_Label_F7 OVTK_StimulationId_Label_F7 0x000081f7
OVTK_StimulationId_Label_F8 OVTK_StimulationId_Label_F8 0x000081f8
OVTK_StimulationId_Label_F9 OVTK_StimulationId_Label_F9 0x000081f9
OVTK_StimulationId_Label_FA OVTK_StimulationId_Label_FA 0x000081fa
OVTK_StimulationId_Label_FB OVTK_StimulationId_Label_FB 0x000081fb
OVTK_StimulationId_Label_FC OVTK_StimulationId_Label_FC 0x000081fc
OVTK_StimulationId_Label_FD OVTK_StimulationId_Label_FD 0x000081fd
OVTK_StimulationId_Label_FE OVTK_StimulationId_Label_FE 0x000081fe
OVTK_StimulationId_Label_FF OVTK_StimulationId_Label_FF 0x000081ff
OVTK_StimulationId_Number_00 OVTK_StimulationId_Number_00 0x00000000
OVTK_StimulationId_Number_01 OVTK_StimulationId_Number_01 0x00000001
OVTK_StimulationId_Number_02 OVTK_StimulationId_Number_02 0x00000002
OVTK_StimulationId_Number_03 OVTK_StimulationId_Number_03 0x00000003
OVTK_StimulationId_Number_04 OVTK_StimulationId_Number_04 0x00000004
OVTK_StimulationId_Number_05 OVTK_StimulationId_Number_05 0x00000005
OVTK_StimulationId_Number_06 OVTK_StimulationId_Number_06 0x00000006
OVTK_StimulationId_Number_07 OVTK_StimulationId_Number_07 0x00000007
OVTK_StimulationId_Number_08 OVTK_StimulationId_Number_08 0x00000008
OVTK_StimulationId_Number_09 OVTK_StimulationId_Number_09 0x00000009
OVTK_StimulationId_Number_0A OVTK_StimulationId_Number_0A 0x0000000a
OVTK_StimulationId_Number_0B OVTK_StimulationId_Number_0B 0x0000000b
OVTK_StimulationId_Number_0C OVTK_StimulationId_Number_0C 0x0000000c
OVTK_StimulationId_Number_0D OVTK_StimulationId_Number_0D 0x0000000d
OVTK_StimulationId_Number_0E OVTK_StimulationId_Number_0E 0x0000000e
OVTK_StimulationId_Number_0F OVTK_StimulationId_Number_0F 0x0000000f
OVTK_StimulationId_Number_10 OVTK_StimulationId_Number_10 0x00000010
OVTK_StimulationId_Number_11 OVTK_StimulationId_Number_11 0x00000011
OVTK_StimulationId_Number_12 OVTK_StimulationId_Number_12 0x00000012
OVTK_StimulationId_Number_13 OVTK_StimulationId_Number_13 0x00000013
OVTK_StimulationId_Number_14 OVTK_StimulationId_Number_14 0x00000014
OVTK_StimulationId_Number_15 OVTK_StimulationId_Number_15 0x00000015
OVTK_StimulationId_Number_16 OVTK_StimulationId_Number_16 0x00000016
OVTK_StimulationId_Number_17 OVTK_StimulationId_Number_17 0x00000017
OVTK_StimulationId_Number_18 OVTK_StimulationId_Number_18 0x00000018
OVTK_StimulationId_Number_19 OVTK_StimulationId_Number_19 0x00000019
OVTK_StimulationId_Number_1A OVTK_StimulationId_Number_1A 0x0000001a
OVTK_StimulationId_Number_1B OVTK_StimulationId_Number_1B 0x0000001b
OVTK_StimulationId_Number_1C OVTK_StimulationId_Number_1C 0x0000001c
OVTK_StimulationId_Number_1D OVTK_StimulationId_Number_1D 0x0000001d
OVTK_StimulationId_Number_1E OVTK_StimulationId_Number_1E 0x0000001e
OVTK_StimulationId_Number_1F OVTK_StimulationId_Number_1F 0x0000001f
OVTK_StimulationId_Train OVTK_StimulationId_Train 0x00008201
OVTK_StimulationId_Beep OVTK_StimulationId_Beep 0x00008202
OVTK_StimulationId_DoubleBeep OVTK_StimulationId_DoubleBeep 0x00008203
OVTK_StimulationId_EndOfFile OVTK_StimulationId_EndOfFile 0x00008204
OVTK_StimulationId_Target OVTK_StimulationId_Target 0x00008205
OVTK_StimulationId_NonTarget OVTK_StimulationId_NonTarget 0x00008206
OVTK_StimulationId_TrainCompleted OVTK_StimulationId_TrainCompleted 0x00008207
OVTK_StimulationId_Reset OVTK_StimulationId_Reset 0x00008208
OVTK_StimulationId_ThresholdPassed_Positive OVTK_StimulationId_ThresholdPassed_Positive 0x00008209
OVTK_StimulationId_ThresholdPassed_Negative OVTK_StimulationId_ThresholdPassed_Negative 0x00008210
OVTK_StimulationId_NoArtifact OVTK_StimulationId_NoArtifact 0x00008301
OVTK_StimulationId_Artifact OVTK_StimulationId_Artifact 0x00008302
OVTK_StimulationId_RemovedSamples OVTK_StimulationId_RemovedSamples 0x00008310
OVTK_StimulationId_AddedSamplesBegin OVTK_StimulationId_AddedSamplesBegin 0x00008311
OVTK_StimulationId_AddedSamplesEnd OVTK_StimulationId_AddedSamplesEnd 0x00008312
OVTK_GDF_Artifact_EOG_Large OVTK_GDF_Artifact_EOG_Large 0x101
OVTK_GDF_Artifact_ECG OVTK_GDF_Artifact_ECG 0x102
OVTK_GDF_Artifact_EMG OVTK_GDF_Artifact_EMG 0x103
OVTK_GDF_Artifact_Movement OVTK_GDF_Artifact_Movement 0x104
OVTK_GDF_Artifact_Failing_Electrode OVTK_GDF_Artifact_Failing_Electrode0x00008004 0x105
OVTK_GDF_Artifact_Sweat OVTK_GDF_Artifact_Sweat 0x106
OVTK_GDF_Artifact_50_60_Hz_Interference OVTK_GDF_Artifact_50_60_Hz_Interference 0x107
OVTK_GDF_Artifact_Breathing OVTK_GDF_Artifact_Breathing 0x108
OVTK_GDF_Artifact_Pulse OVTK_GDF_Artifact_Pulse 0x109
OVTK_GDF_Artifact_EOG_Small OVTK_GDF_Artifact_EOG_Small 0x10A
OVTK_GDF_Calibration OVTK_GDF_Calibration 0x10F
OVTK_GDF_EEG_Sleep_Splindles OVTK_GDF_EEG_Sleep_Splindles 0x111
OVTK_GDF_EEG_K_Complexes OVTK_GDF_EEG_K_Complexes 0x112
OVTK_GDF_EEG_Saw_Tooth_Waves OVTK_GDF_EEG_Saw_Tooth_Waves 0x113
OVTK_GDF_EEG_Idling_EEG_Eyes_Open OVTK_GDF_EEG_Idling_EEG_Eyes_Open 0x114
OVTK_GDF_EEG_Idling_EEG_Eyes_Closed OVTK_GDF_EEG_Idling_EEG_Eyes_Closed 0x115
OVTK_GDF_EEG_Spike OVTK_GDF_EEG_Spike 0x116
OVTK_GDF_EEG_Seizure OVTK_GDF_EEG_Seizure 0x117
OVTK_GDF_VEP OVTK_GDF_VEP 0x121
OVTK_GDF_AEP OVTK_GDF_AEP 0x122
OVTK_GDF_SEP OVTK_GDF_SEP 0x123
OVTK_GDF_TMS OVTK_GDF_TMS 0x12F
OVTK_GDF_SSVEP OVTK_GDF_SSVEP 0x131
OVTK_GDF_SSAEP OVTK_GDF_SSAEP 0x132
OVTK_GDF_SSSEP OVTK_GDF_SSSEP 0x133
OVTK_GDF_Start_Of_Trial OVTK_GDF_Start_Of_Trial 0x300
OVTK_GDF_Left OVTK_GDF_Left 0x301
OVTK_GDF_Right OVTK_GDF_Right 0x302
OVTK_GDF_Foot OVTK_GDF_Foot 0x303
OVTK_GDF_Tongue OVTK_GDF_Tongue 0x304
OVTK_GDF_class5 OVTK_GDF_class5 0x305
OVTK_GDF_Down OVTK_GDF_Down 0x306
OVTK_GDF_class7 OVTK_GDF_class7 0x307
OVTK_GDF_class8 OVTK_GDF_class8 0x308
OVTK_GDF_class9 OVTK_GDF_class9 0x309
OVTK_GDF_class10 OVTK_GDF_class10 0x30A
OVTK_GDF_class11 OVTK_GDF_class11 0x30B
OVTK_GDF_Up OVTK_GDF_Up 0x30C
OVTK_GDF_Feedback_Continuous OVTK_GDF_Feedback_Continuous 0x30D
OVTK_GDF_Feedback_Discrete OVTK_GDF_Feedback_Discrete 0x30E
OVTK_GDF_Cue_Unknown_Undefined OVTK_GDF_Cue_Unknown_Undefined 0x30F
OVTK_GDF_Beep OVTK_GDF_Beep 0x311
OVTK_GDF_Cross_On_Screen OVTK_GDF_Cross_On_Screen 0x312
OVTK_GDF_Flashing_Light OVTK_GDF_Flashing_Light 0x313
OVTK_GDF_End_Of_Trial OVTK_GDF_End_Of_Trial 0x320
OVTK_GDF_Correct OVTK_GDF_Correct 0x381
OVTK_GDF_Incorrect OVTK_GDF_Incorrect 0x382
OVTK_GDF_End_Of_Session OVTK_GDF_End_Of_Session 0x3F2
OVTK_GDF_Rejection OVTK_GDF_Rejection 0x3FF
OVTK_GDF_OAHE OVTK_GDF_OAHE 0x401
OVTK_GDF_RERA OVTK_GDF_RERA 0x402
OVTK_GDF_CAHE OVTK_GDF_CAHE 0x403
OVTK_GDF_CSB OVTK_GDF_CSB 0x404
OVTK_GDF_Sleep_Hypoventilation OVTK_GDF_Sleep_Hypoventilation 0x405
OVTK_GDF_Maximum_Inspiration OVTK_GDF_Maximum_Inspiration 0x40E
OVTK_GDF_Start_Of_Inspiration OVTK_GDF_Start_Of_Inspiration 0x40F
OVTK_GDF_Wake OVTK_GDF_Wake 0x410
OVTK_GDF_Stage_1 OVTK_GDF_Stage_1 0x411
OVTK_GDF_Stage_2 OVTK_GDF_Stage_2 0x412
OVTK_GDF_Stage_3 OVTK_GDF_Stage_3 0x413
OVTK_GDF_Stage_4 OVTK_GDF_Stage_4 0x414
OVTK_GDF_REM OVTK_GDF_REM 0x415
OVTK_GDF_Lights_On OVTK_GDF_Lights_On 0x420
OVTK_GDF_Lights_Off OVTK_GDF_Lights_Off 0x8420
OVTK_GDF_Eyes_Left OVTK_GDF_Eyes_Left 0x431
OVTK_GDF_Eyes_Right OVTK_GDF_Eyes_Right 0x432
OVTK_GDF_Eyes_Up OVTK_GDF_Eyes_Up 0x433
OVTK_GDF_Eyes_Down OVTK_GDF_Eyes_Down 0x434
OVTK_GDF_Horizontal_Eye_Movement OVTK_GDF_Horizontal_Eye_Movement 0x435
OVTK_GDF_Vertical_Eye_Movement OVTK_GDF_Vertical_Eye_Movement 0x436
OVTK_GDF_Rotation_Clockwise OVTK_GDF_Rotation_Clockwise 0x437
OVTK_GDF_Rotation_Counterclockwise OVTK_GDF_Rotation_Counterclockwise 0x438
OVTK_GDF_Eye_Blink OVTK_GDF_Eye_Blink 0x439
OVTK_GDF_Left_Hand_Movement OVTK_GDF_Left_Hand_Movement 0x441
OVTK_GDF_Right_Hand_Movement OVTK_GDF_Right_Hand_Movement 0x442
OVTK_GDF_Head_Movement OVTK_GDF_Head_Movement 0x443
OVTK_GDF_Tongue_Movement OVTK_GDF_Tongue_Movement 0x444
OVTK_GDF_Swallowing OVTK_GDF_Swallowing 0x445
OVTK_GDF_Biting OVTK_GDF_Biting 0x446
OVTK_GDF_Foot_Movement OVTK_GDF_Foot_Movement 0x447
OVTK_GDF_Foot_Right_Movement OVTK_GDF_Foot_Right_Movement 0x448
OVTK_GDF_Arm_Movement OVTK_GDF_Arm_Movement 0x449
OVTK_GDF_Arm_Right_Movement OVTK_GDF_Arm_Right_Movement 0x44A
OVTK_GDF_ECG_Fiducial_Point_QRS_Complex OVTK_GDF_ECG_Fiducial_Point_QRS_Complex 0x501
OVTK_GDF_ECG_P_Wave OVTK_GDF_ECG_P_Wave 0x502
OVTK_GDF_ECG_QRS_Complex OVTK_GDF_ECG_QRS_Complex 0x503
OVTK_GDF_ECG_R_Point OVTK_GDF_ECG_R_Point 0x504
OVTK_GDF_ECG_T_Wave OVTK_GDF_ECG_T_Wave 0x506
OVTK_GDF_ECG_U_Wave OVTK_GDF_ECG_U_Wave 0x507
OVTK_GDF_Start OVTK_GDF_Start 0x580
OVTK_GDF_25_Watt OVTK_GDF_25_Watt 0x581
OVTK_GDF_50_Watt OVTK_GDF_50_Watt 0x582
OVTK_GDF_75_Watt OVTK_GDF_75_Watt 0x583
OVTK_GDF_100_Watt OVTK_GDF_100_Watt 0x584
OVTK_GDF_125_Watt OVTK_GDF_125_Watt 0x585
OVTK_GDF_150_Watt OVTK_GDF_150_Watt 0x586
OVTK_GDF_175_Watt OVTK_GDF_175_Watt 0x587
OVTK_GDF_200_Watt OVTK_GDF_200_Watt 0x588
OVTK_GDF_225_Watt OVTK_GDF_225_Watt 0x589
OVTK_GDF_250_Watt OVTK_GDF_250_Watt 0x58A
OVTK_GDF_275_Watt OVTK_GDF_275_Watt 0x58B
OVTK_GDF_300_Watt OVTK_GDF_300_Watt 0x58C
OVTK_GDF_325_Watt OVTK_GDF_325_Watt 0x58D
OVTK_GDF_350_Watt OVTK_GDF_350_Watt 0x58E
OVTK_GDF_Start_Of_New_Segment OVTK_GDF_Start_Of_New_Segment 0x7FFE
OVTK_GDF_Non_Equidistant_Sampling_Value OVTK_GDF_Non_Equidistant_Sampling_Value 0x7FFF
@@ -0,0 +1,198 @@
#include "ovtkCAlgorithmClassifier.h"
#include "ovtkCFeatureVector.hpp"
#include "ovtkCFeatureVectorSet.hpp"
#include "ovtkCVector.hpp"
#include <xml/IXMLHandler.h>
#include <iostream>
namespace OpenViBE {
namespace Toolkit {
bool CAlgorithmClassifier::initialize()
{
m_AlgorithmProxy = nullptr;
m_ExtraParametersMap = nullptr;
return true;
}
bool CAlgorithmClassifier::uninitialize()
{
if (m_AlgorithmProxy != nullptr)
{
m_AlgorithmProxy->uninitialize();
this->getAlgorithmManager().releaseAlgorithm(*m_AlgorithmProxy);
m_AlgorithmProxy = nullptr;
}
return true;
}
bool CAlgorithmClassifier::process()
{
const Kernel::TParameterHandler<CMatrix*> ip_FeatureVector(this->getInputParameter(OVTK_Algorithm_Classifier_InputParameterId_FeatureVector));
const Kernel::TParameterHandler<CMatrix*> ip_FeatureVectorSet(this->getInputParameter(OVTK_Algorithm_Classifier_InputParameterId_FeatureVectorSet));
const Kernel::TParameterHandler<XML::IXMLNode*> ip_Config(this->getInputParameter(OVTK_Algorithm_Classifier_InputParameterId_Config));
Kernel::TParameterHandler<double> op_EstimatedClass(this->getOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_Class));
Kernel::TParameterHandler<CMatrix*> op_ClassificationValues(this->getOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_ClassificationValues));
Kernel::TParameterHandler<CMatrix*> op_ProbabilityValues(this->getOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_ProbabilityValues));
Kernel::TParameterHandler<XML::IXMLNode*> op_Config(this->getOutputParameter(OVTK_Algorithm_Classifier_OutputParameterId_Config));
if (this->isInputTriggerActive(OVTK_Algorithm_Classifier_InputTriggerId_Train))
{
CMatrix* featureVectorSet = ip_FeatureVectorSet;
if (!featureVectorSet)
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Feature vector set is NULL", Kernel::ErrorType::BadInput);
}
const CFeatureVectorSet featureVectorSetAdapter(*featureVectorSet);
if (this->train(featureVectorSetAdapter)) { this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Success, true); }
else
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Training failed", Kernel::ErrorType::Internal);
}
}
if (this->isInputTriggerActive(OVTK_Algorithm_Classifier_InputTriggerId_Classify))
{
CMatrix* featureVector = ip_FeatureVector;
CMatrix* classificationValues = op_ClassificationValues;
CMatrix* probabilityValues = op_ProbabilityValues;
if (!featureVector || !classificationValues || !probabilityValues)
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Classifying failed", (!featureVector) ? Kernel::ErrorType::BadInput : Kernel::ErrorType::BadOutput);
}
double estimatedClass = 0;
const CFeatureVector featureVectorAdapter(*featureVector);
CVector classificationValuesAdapter(*classificationValues);
CVector probabilityValuesAdapter(*probabilityValues);
if (this->classify(featureVectorAdapter, estimatedClass, classificationValuesAdapter, probabilityValuesAdapter))
{
op_EstimatedClass = estimatedClass;
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Success, true);
}
else
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Classifying failed", Kernel::ErrorType::Internal);
}
}
if (this->isInputTriggerActive(OVTK_Algorithm_Classifier_InputTriggerId_SaveConfig))
{
XML::IXMLNode* rootNode = this->saveConfig();
op_Config = rootNode;
if (rootNode) { this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Success, true); }
else
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Saving configuration failed", Kernel::ErrorType::Internal);
}
}
if (this->isInputTriggerActive(OVTK_Algorithm_Classifier_InputTriggerId_LoadConfig))
{
XML::IXMLNode* rootNode = ip_Config;
if (!rootNode)
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Configuration XML node is NULL", Kernel::ErrorType::BadInput);
}
if (this->loadConfig(rootNode))
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Success, true);
//Now we need to parametrize the two output Matrix for values
setMatrixOutputDimension(op_ProbabilityValues, this->getNProbabilities());
setMatrixOutputDimension(op_ClassificationValues, this->getNDistances());
}
else
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Loading configuration failed", Kernel::ErrorType::Internal);
}
}
return true;
}
bool CAlgorithmClassifier::initializeExtraParameterMechanism()
{
const Kernel::TParameterHandler<std::map<CString, CString>*> ip_ExtraParameter(
this->getInputParameter(OVTK_Algorithm_Classifier_InputParameterId_ExtraParameter));
m_ExtraParametersMap = static_cast<std::map<CString, CString>*>(ip_ExtraParameter);
m_AlgorithmProxy = &this->getAlgorithmManager().getAlgorithm(this->getAlgorithmManager().createAlgorithm(this->getClassIdentifier()));
OV_ERROR_UNLESS_KRF(m_AlgorithmProxy->initialize(), "Failed to initialize algorithm", Kernel::ErrorType::Internal);
return true;
}
bool CAlgorithmClassifier::uninitializeExtraParameterMechanism()
{
OV_ERROR_UNLESS_KRF(m_AlgorithmProxy->uninitialize(), "Failed to uninitialize algorithm", Kernel::ErrorType::Internal);
this->getAlgorithmManager().releaseAlgorithm(*m_AlgorithmProxy);
m_AlgorithmProxy = nullptr;
m_ExtraParametersMap = nullptr;
return true;
}
CString& CAlgorithmClassifier::getParameterValue(const CIdentifier& parameterID) const
{
const CString parameterName = m_AlgorithmProxy->getInputParameterName(parameterID);
return (*static_cast<std::map<CString, CString>*>(m_ExtraParametersMap))[parameterName];
}
void CAlgorithmClassifier::setMatrixOutputDimension(Kernel::TParameterHandler<CMatrix*>& matrix, const size_t length) { matrix->resize(length); }
uint64_t CAlgorithmClassifier::getUInt64Parameter(const CIdentifier& parameterID)
{
Kernel::TParameterHandler<uint64_t> temp(getInputParameter(parameterID));
temp = this->getAlgorithmContext().getConfigurationManager().expandAsUInteger(getParameterValue(parameterID));
return uint64_t(temp);
}
int64_t CAlgorithmClassifier::getInt64Parameter(const CIdentifier& parameterID)
{
Kernel::TParameterHandler<int64_t> temp(getInputParameter(parameterID));
temp = this->getAlgorithmContext().getConfigurationManager().expandAsInteger(getParameterValue(parameterID));
return int64_t(temp);
}
double CAlgorithmClassifier::getDoubleParameter(const CIdentifier& parameterID)
{
Kernel::TParameterHandler<double> temp(getInputParameter(parameterID));
temp = this->getAlgorithmContext().getConfigurationManager().expandAsFloat(getParameterValue(parameterID));
return double(temp);
}
bool CAlgorithmClassifier::getBooleanParameter(const CIdentifier& parameterID)
{
Kernel::TParameterHandler<bool> temp(getInputParameter(parameterID));
temp = this->getAlgorithmContext().getConfigurationManager().expandAsBoolean(getParameterValue(parameterID));
return bool(temp);
}
CString* CAlgorithmClassifier::getCStringParameter(const CIdentifier& parameterID)
{
Kernel::TParameterHandler<CString*> temp(getInputParameter(parameterID));
temp = &getParameterValue(parameterID);
return static_cast<CString*>(temp);
}
uint64_t CAlgorithmClassifier::getEnumerationParameter(const CIdentifier& parameterID, const CIdentifier& enumerationIdentifier)
{
Kernel::TParameterHandler<uint64_t> temp(getInputParameter(parameterID));
temp = this->getTypeManager().getEnumerationEntryValueFromName(enumerationIdentifier, getParameterValue(parameterID));
return uint64_t(temp);
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,50 @@
#include "ovtkCAlgorithmClassifierTrainer.h"
#include "ovtkCFeatureVectorSet.hpp"
namespace OpenViBE {
namespace Toolkit {
bool CAlgorithmClassifierTrainer::process()
{
Kernel::TParameterHandler<CMatrix*> ip_featureVectorSet(this->getInputParameter(OVTK_Algorithm_ClassifierTrainer_InputParameterId_FeatureVectorSet));
Kernel::TParameterHandler<IMemoryBuffer*> op_config(this->getOutputParameter(OVTK_Algorithm_ClassifierTrainer_OutputParameterId_Config));
if (this->isInputTriggerActive(OVTK_Algorithm_ClassifierTrainer_InputTriggerId_Train))
{
CMatrix* featureVectorSet = ip_featureVectorSet;
if (!featureVectorSet)
{
this->activateOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Feature vector set is NULL", Kernel::ErrorType::BadInput);
}
const CFeatureVectorSet featureVectorSetAdapter(*featureVectorSet);
if (this->train(featureVectorSetAdapter)) { this->activateOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Success, true); }
else
{
this->activateOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Training failed", Kernel::ErrorType::Internal);
}
}
if (this->isInputTriggerActive(OVTK_Algorithm_ClassifierTrainer_InputTriggerId_SaveConfig))
{
IMemoryBuffer* config = op_config;
if (!config)
{
this->activateOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Configuration memory buffer is NULL", Kernel::ErrorType::BadOutput);
}
config->setSize(0, true);
if (this->saveConfig(*config)) { this->activateOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Success, true); }
else
{
this->activateOutputTrigger(OVTK_Algorithm_ClassifierTrainer_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Saving configuration failed", Kernel::ErrorType::Internal);
}
}
return true;
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,44 @@
#include "ovtkCAlgorithmClassifier.h"
#include "ovtkCAlgorithmPairingStrategy.h"
#include <map>
namespace OpenViBE {
namespace Toolkit {
static std::map<uint64_t, fClassifierComparison> comparisionFunctions;
void registerClassificationComparisonFunction(const CIdentifier& classID, const fClassifierComparison comparision)
{
comparisionFunctions[classID.id()] = comparision;
}
fClassifierComparison getClassificationComparisonFunction(const CIdentifier& classID)
{
if (comparisionFunctions.count(classID.id()) == 0) { return nullptr; }
return comparisionFunctions[classID.id()];
}
bool CAlgorithmPairingStrategy::process()
{
if (this->isInputTriggerActive(OVTK_Algorithm_PairingStrategy_InputTriggerId_DesignArchitecture))
{
Kernel::TParameterHandler<CIdentifier*>
ip_classifierID(this->getInputParameter(OVTK_Algorithm_PairingStrategy_InputParameterId_SubClassifierAlgorithm));
Kernel::TParameterHandler<uint64_t> ip_nClass(this->getInputParameter(OVTK_Algorithm_Classifier_InputParameterId_NClasses));
const uint64_t nClass = uint64_t(ip_nClass);
const CIdentifier classifierID = *static_cast<CIdentifier*>(ip_classifierID);
if (this->designArchitecture(classifierID, size_t(nClass))) { this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Success, true); }
else
{
this->activateOutputTrigger(OVTK_Algorithm_Classifier_OutputTriggerId_Failed, true);
OV_ERROR_KRF("Designing architecture failed", Kernel::ErrorType::Internal);
}
}
else { return CAlgorithmClassifier::process(); }
return true;
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,23 @@
#pragma once
#include "ovtkCVector.hpp"
#include "../../ovtkIFeatureVector.h"
namespace OpenViBE {
namespace Toolkit {
template <class TParent>
class TFeatureVector final : public TVector<TParent>
{
public:
explicit TFeatureVector(CMatrix& rMatrix) : TVector<TParent>(rMatrix) { }
double getLabel() const override { return 0; }
bool setLabel(const double /*label*/) override { return false; }
_IsDerivedFromClass_Final_(TVector<TParent>, CIdentifier::undefined())
};
typedef TFeatureVector<IFeatureVector> CFeatureVector;
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,31 @@
#include "ovtkCFeatureVectorSet.hpp"
namespace OpenViBE {
namespace Toolkit {
CFeatureVectorSet::CFeatureVectorSet(const CMatrix& matrix) : m_matrix(matrix)
{
if (matrix.getDimensionCount() != 2) { throw std::runtime_error("Fetaure vector set matrix must be 2 dimensions"); }
for (size_t i = 0; i < matrix.getDimensionSize(0); ++i)
{
m_features[i].m_Matrix = &matrix;
m_features[i].m_DimensionIdx = i;
m_features[i].m_Size = matrix.getDimensionSize(1) - 1;
m_features[i].m_Buffer = matrix.getBuffer() + i * matrix.getDimensionSize(1);
}
}
IFeatureVector& CFeatureVectorSet::getFeatureVector(const size_t index) { return m_features.find(index)->second; }
const IFeatureVector& CFeatureVectorSet::getFeatureVector(const size_t index) const { return m_features.find(index)->second; }
size_t CFeatureVectorSet::getLabelCount() const
{
std::map<double, bool> labels;
for (auto it = m_features.begin(); it != m_features.end(); ++it) { labels[it->second.getLabel()] = true; }
return labels.size();
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,52 @@
#pragma once
#include "../../ovtkIFeatureVector.h"
#include "../../ovtkIFeatureVectorSet.h"
#include <map>
namespace OpenViBE {
namespace Toolkit {
class CInternalFeatureVector final : public IFeatureVector
{
public:
CInternalFeatureVector() { }
uint32_t getSize() const override { return m_Size; }
bool setSize(const uint32_t /*size*/) override { return false; }
double* getBuffer() override { return nullptr; }
const double* getBuffer() const override { return m_Buffer; }
const char* getElementLabel(const uint32_t index) const override { return m_Matrix->getDimensionLabel(m_DimensionIdx, index); }
bool setElementLabel(const uint32_t /*index*/, const char* /*elementLabel*/) override { return false; }
double getLabel() const override { return m_Buffer[m_Size]; }
bool setLabel(const double /*label*/) override { return false; }
_IsDerivedFromClass_Final_(IFeatureVector, CIdentifier::undefined())
const CMatrix* m_Matrix = nullptr;
uint32_t m_DimensionIdx = 0;
uint32_t m_Size = 0;
const double* m_Buffer = nullptr;
};
class CFeatureVectorSet final : public IFeatureVectorSet
{
public:
explicit CFeatureVectorSet(const CMatrix& matrix);
size_t getFeatureVectorCount() const override { return m_matrix.getDimensionSize(0); }
bool setFeatureVectorCount(const size_t /*nFeatureVector*/) override { return false; }
bool addFeatureVector(const IFeatureVector& /*featureVector*/) override { return false; }
IFeatureVector& getFeatureVector(const size_t index) override;
const IFeatureVector& getFeatureVector(const size_t index) const override;
size_t getLabelCount() const override;
_IsDerivedFromClass_Final_(IFeatureVectorSet, CIdentifier::undefined())
protected:
const CMatrix& m_matrix;
std::map<uint32_t, CInternalFeatureVector> m_features;
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,42 @@
#pragma once
#include "../../ovtk_base.h"
#include "../../ovtkIVector.h"
namespace OpenViBE {
namespace Toolkit {
template <class TParent>
class TVector : public TParent
{
public:
explicit TVector(CMatrix& matrix) : m_matrix(matrix) { }
uint32_t getSize() const override { return m_matrix.getBufferElementCount(); }
bool setSize(const uint32_t size) override
{
m_matrix.resize(size);
return true;
}
double* getBuffer() override { return m_matrix.getBuffer(); }
const double* getBuffer() const override { return m_matrix.getBuffer(); }
const char* getElementLabel(const uint32_t index) const override { return m_matrix.getDimensionLabel(0, index); }
bool setElementLabel(const uint32_t index, const char* label) override
{
m_matrix.setDimensionLabel(0, index, label);
return true;
}
_IsDerivedFromClass_Final_(TParent, CIdentifier::undefined())
protected:
CMatrix& m_matrix;
};
typedef TVector<IVector> CVector;
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,403 @@
#include "ovtkCAlgorithmScenarioExporter.h"
#include <vector>
#include <sstream>
namespace OpenViBE {
namespace Toolkit {
namespace {
class CAlgorithmScenarioExporterHelper
{
friend class CAlgorithmScenarioExporter;
public:
CAlgorithmScenarioExporterHelper(Kernel::IAlgorithmContext& context, CAlgorithmScenarioExporter& parent);
bool exportBox(IMemoryBuffer& buffer, const Kernel::IBox& box) const;
bool exportComment(IMemoryBuffer& buffer, const Kernel::IComment& comment) const;
bool exportMetadata(IMemoryBuffer& buffer, const Kernel::IMetadata& metadata) const;
bool exportSetting(IMemoryBuffer& buffer, const Kernel::IScenario& scenario, const size_t index) const;
bool exportInput(IMemoryBuffer& buffer, const Kernel::IScenario& scenario, size_t index) const;
bool exportOutput(IMemoryBuffer& buffer, const Kernel::IScenario& scenario, size_t index) const;
bool exportLink(IMemoryBuffer& buffer, const Kernel::ILink& link) const;
void exportAttributes(const Kernel::IAttributable& attributable, IMemoryBuffer& buffer, const CIdentifier& idAttributes,
const CIdentifier& idAttribute, const CIdentifier& idAttributeID, const CIdentifier& idAttributeValue) const;
protected:
Kernel::IAlgorithmContext& m_algorithmContext;
CAlgorithmScenarioExporter& m_parent;
};
} // namespace
#define exportAttributesMacro(exporter, attributable, memoryBuffer, AttributableName) \
do { \
(exporter).exportAttributes(attributable, memoryBuffer, \
OVTK_Algorithm_ScenarioExporter_NodeId_##AttributableName##_Attributes, \
OVTK_Algorithm_ScenarioExporter_NodeId_##AttributableName##_Attribute, \
OVTK_Algorithm_ScenarioExporter_NodeId_##AttributableName##_Attribute_ID, \
OVTK_Algorithm_ScenarioExporter_NodeId_##AttributableName##_Attribute_Value); \
} while (0)
void CAlgorithmScenarioExporterHelper::exportAttributes(const Kernel::IAttributable& attributable, IMemoryBuffer& buffer, const CIdentifier& idAttributes,
const CIdentifier& idAttribute, const CIdentifier& idAttributeID,
const CIdentifier& idAttributeValue) const
{
if (attributable.getNextAttributeIdentifier(CIdentifier::undefined()) != CIdentifier::undefined())
{
CIdentifier attributeIdentifier;
m_parent.exportStart(buffer, idAttributes);
while ((attributeIdentifier = attributable.getNextAttributeIdentifier(attributeIdentifier)) != CIdentifier::undefined())
{
// do not export attributes that are used only in the designer for bookkeeping
if ((attributeIdentifier != OV_AttributeId_Box_ToBeUpdated) && (attributeIdentifier != OV_AttributeId_Box_PendingDeprecatedInterfacors))
{
m_parent.exportStart(buffer, idAttribute);
m_parent.exportIdentifier(buffer, idAttributeID, attributeIdentifier);
m_parent.exportString(buffer, idAttributeValue, attributable.getAttributeValue(attributeIdentifier));
m_parent.exportStop(buffer);
}
}
m_parent.exportStop(buffer);
}
}
bool CAlgorithmScenarioExporter::process()
{
const CAlgorithmScenarioExporterHelper helper(this->getAlgorithmContext(), *this);
CMemoryBuffer tmpBuffer;
// preallocates 1 Mbytes
tmpBuffer.reserve(1024 * 1024);
Kernel::TParameterHandler<Kernel::IScenario*> ip_scenario(this->getInputParameter(OV_Algorithm_ScenarioExporter_InputParameterId_Scenario));
Kernel::IScenario* scenario = ip_scenario;
OV_ERROR_UNLESS_KRF(scenario, "Input scenario is NULL", Kernel::ErrorType::BadInput);
Kernel::TParameterHandler<IMemoryBuffer*> op_buffer(this->getOutputParameter(OV_Algorithm_ScenarioExporter_OutputParameterId_MemoryBuffer));
IMemoryBuffer* buffer = op_buffer;
OV_ERROR_UNLESS_KRF(buffer, "Output memory buffer is NULL", Kernel::ErrorType::BadOutput);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_OpenViBEScenario);
this->exportString(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_FormatVersion, CString("2"));
this->exportString(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Creator, this->getConfigurationManager().expand("${Application_Name}"));
this->exportString(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_CreatorVersion, this->getConfigurationManager().expand("${Application_Version}"));
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Settings);
for (size_t i = 0; i < scenario->getSettingCount(); ++i) { helper.exportSetting(tmpBuffer, *scenario, i); }
this->exportStop(tmpBuffer);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Inputs);
for (size_t i = 0; i < scenario->getInputCount(); ++i) { helper.exportInput(tmpBuffer, *scenario, i); }
this->exportStop(tmpBuffer);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Outputs);
for (size_t i = 0; i < scenario->getOutputCount(); ++i) { helper.exportOutput(tmpBuffer, *scenario, i); }
this->exportStop(tmpBuffer);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Boxes);
{
CIdentifier* listID = nullptr;
size_t nbElems = 0;
scenario->getBoxIdentifierList(&listID, &nbElems);
for (size_t i = 0; i < nbElems; ++i) { helper.exportBox(tmpBuffer, *scenario->getBoxDetails(listID[i])); }
scenario->releaseIdentifierList(listID);
}
this->exportStop(tmpBuffer);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Links);
{
CIdentifier* listID = nullptr;
size_t nbElems = 0;
scenario->getLinkIdentifierList(&listID, &nbElems);
for (size_t i = 0; i < nbElems; ++i)
{
const Kernel::ILink* link = scenario->getLinkDetails(listID[i]);
// do not export invalid links
if (!link->hasAttribute(OV_AttributeId_Link_Invalid)) { helper.exportLink(tmpBuffer, *link); }
}
scenario->releaseIdentifierList(listID);
}
this->exportStop(tmpBuffer);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Comments);
{
CIdentifier* listID = nullptr;
size_t nbElems = 0;
scenario->getCommentIdentifierList(&listID, &nbElems);
for (size_t i = 0; i < nbElems; ++i) { helper.exportComment(tmpBuffer, *scenario->getCommentDetails(listID[i])); }
scenario->releaseIdentifierList(listID);
}
this->exportStop(tmpBuffer);
this->exportStart(tmpBuffer, OVTK_Algorithm_ScenarioExporter_NodeId_Metadata);
{
CIdentifier* listID = nullptr;
size_t nbElems = 0;
scenario->getMetadataIdentifierList(&listID, &nbElems);
for (size_t i = 0; i < nbElems; ++i) { helper.exportMetadata(tmpBuffer, *scenario->getMetadataDetails(listID[i])); }
scenario->releaseIdentifierList(listID);
}
this->exportStop(tmpBuffer);
exportAttributesMacro(helper, *scenario, tmpBuffer, Scenario);
this->exportStop(tmpBuffer);
buffer->setSize(0, true);
buffer->append(tmpBuffer);
return true;
}
CAlgorithmScenarioExporterHelper::CAlgorithmScenarioExporterHelper(Kernel::IAlgorithmContext& context, CAlgorithmScenarioExporter& parent)
: m_algorithmContext(context), m_parent(parent) {}
bool CAlgorithmScenarioExporterHelper::exportBox(IMemoryBuffer& buffer, const Kernel::IBox& box) const
{
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_ID, box.getIdentifier());
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Name, box.getName());
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_AlgorithmClassIdD, box.getAlgorithmClassIdentifier());
if (box.getInputCount() != 0)
{
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Inputs);
for (size_t i = 0; i < box.getInputCount(); ++i)
{
CIdentifier inputID;
CIdentifier inputTypeID;
CString inputName;
box.getInputType(i, inputTypeID);
box.getInputName(i, inputName);
box.getInterfacorIdentifier(Kernel::Input, i, inputID);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input);
if (inputID != CIdentifier::undefined()) { m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_ID, inputID); }
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_TypeID, inputTypeID);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_Name, inputName);
m_parent.exportStop(buffer);
}
m_parent.exportStop(buffer);
}
if (box.getOutputCount() != 0)
{
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Outputs);
for (size_t i = 0; i < box.getOutputCount(); ++i)
{
CIdentifier outputID;
CIdentifier outputTypeID;
CString outputName;
box.getOutputType(i, outputTypeID);
box.getOutputName(i, outputName);
box.getInterfacorIdentifier(Kernel::Output, i, outputID);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output);
if (outputID != CIdentifier::undefined()) { m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_ID, outputID); }
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_TypeID, outputTypeID);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_Name, outputName);
m_parent.exportStop(buffer);
}
m_parent.exportStop(buffer);
}
if (box.getSettingCount() != 0)
{
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Settings);
for (size_t i = 0; i < box.getSettingCount(); ++i)
{
CIdentifier settingID;
CIdentifier settingTypeID;
CString settingName;
CString defaultValue;
CString value;
bool modifiability;
box.getInterfacorIdentifier(Kernel::Setting, i, settingID);
box.getSettingType(i, settingTypeID);
box.getSettingName(i, settingName);
box.getSettingDefaultValue(i, defaultValue);
box.getSettingValue(i, value);
box.getSettingMod(i, modifiability);
CString str;
if (modifiability) { str = CString("true"); }
else { str = CString("false"); }
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting);
if (settingID != CIdentifier::undefined()) // do not export identifier if not defined
{
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_ID, settingID);
}
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_TypeID, settingTypeID);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Name, settingName);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_DefaultValue, defaultValue);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Value, value);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Modifiability, str);
m_parent.exportStop(buffer);
}
m_parent.exportStop(buffer);
}
exportAttributesMacro((*this), box, buffer, Box);
m_parent.exportStop(buffer);
return true;
}
bool CAlgorithmScenarioExporterHelper::exportComment(IMemoryBuffer& buffer, const Kernel::IComment& comment) const
{
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Comment);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Comment_ID, comment.getIdentifier());
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Text, comment.getText());
exportAttributesMacro((*this), comment, buffer, Comment);
m_parent.exportStop(buffer);
return true;
}
bool CAlgorithmScenarioExporterHelper::exportMetadata(IMemoryBuffer& buffer, const Kernel::IMetadata& metadata) const
{
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_ID, metadata.getIdentifier());
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_Type, metadata.getType());
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_Data, metadata.getData());
m_parent.exportStop(buffer);
return true;
}
bool CAlgorithmScenarioExporterHelper::exportLink(IMemoryBuffer& buffer, const Kernel::ILink& link) const
{
CIdentifier srcBoxID;
CIdentifier dstBoxID;
size_t srcBoxOutputIdx = size_t(-1);
size_t dstBoxInputIdx = size_t(-1);
CIdentifier srcBoxOutputID;
CIdentifier dstBoxInputID;
link.getSource(srcBoxID, srcBoxOutputIdx, srcBoxOutputID);
link.getTarget(dstBoxID, dstBoxInputIdx, dstBoxInputID);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_ID, link.getIdentifier());
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxID, srcBoxID);
if (srcBoxOutputID != CIdentifier::undefined())
{
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputID, srcBoxOutputID);
}
else { m_parent.exportUInteger(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputIdx, srcBoxOutputIdx); }
m_parent.exportStop(buffer);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxID, dstBoxID);
if (dstBoxInputID != CIdentifier::undefined())
{
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputID, dstBoxInputID);
}
else { m_parent.exportUInteger(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputIdx, dstBoxInputIdx); }
m_parent.exportStop(buffer);
exportAttributesMacro((*this), link, buffer, Link);
m_parent.exportStop(buffer);
return true;
}
bool CAlgorithmScenarioExporterHelper::exportSetting(IMemoryBuffer& buffer, const Kernel::IScenario& scenario, const size_t index) const
{
CIdentifier settingID;
CIdentifier settingTypeID;
CString settingName;
CString defaultValue;
CString value;
scenario.getSettingName(index, settingName);
scenario.getInterfacorIdentifier(Kernel::Setting, index, settingID);
scenario.getSettingType(index, settingTypeID);
scenario.getSettingValue(index, value);
scenario.getSettingDefaultValue(index, defaultValue);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_ID, settingID);
m_parent.exportIdentifier(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_TypeID, settingTypeID);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_Name, settingName);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_DefaultValue, defaultValue);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_Value, value);
m_parent.exportStop(buffer);
return true;
}
bool CAlgorithmScenarioExporterHelper::exportInput(IMemoryBuffer& buffer, const Kernel::IScenario& scenario, const size_t index) const
{
CIdentifier inputID;
CIdentifier inputTypeID;
CString inputName;
CIdentifier linkedBoxID;
size_t linkedBoxInputIdx;
CIdentifier linkedBoxInputID;
scenario.getInterfacorIdentifier(Kernel::Input, index, inputID);
scenario.getInputType(index, inputTypeID);
scenario.getInputName(index, inputName);
scenario.getScenarioInputLink(index, linkedBoxID, linkedBoxInputIdx);
scenario.getScenarioInputLink(index, linkedBoxID, linkedBoxInputID);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input);
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_ID, inputID);
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_TypeID, inputTypeID);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_Name, inputName);
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxID, linkedBoxID);
if (linkedBoxInputID != CIdentifier::undefined())
{
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxInputID, linkedBoxInputID);
}
else { m_parent.exportUInteger(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxInputIdx, uint64_t(linkedBoxInputIdx)); }
m_parent.exportStop(buffer);
return true;
}
bool CAlgorithmScenarioExporterHelper::exportOutput(IMemoryBuffer& buffer, const Kernel::IScenario& scenario, const size_t index) const
{
CIdentifier outputID;
CIdentifier outputTypeID;
CString outputName;
CIdentifier linkedBoxID;
size_t linkedBoxOutputIdx;
CIdentifier linkedBoxOutputID;
scenario.getInterfacorIdentifier(Kernel::Output, index, outputID);
scenario.getOutputType(index, outputTypeID);
scenario.getOutputName(index, outputName);
scenario.getScenarioOutputLink(index, linkedBoxID, linkedBoxOutputIdx);
scenario.getScenarioOutputLink(index, linkedBoxID, linkedBoxOutputID);
m_parent.exportStart(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output);
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_ID, outputID);
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_TypeID, outputTypeID);
m_parent.exportString(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_Name, outputName);
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxID, linkedBoxID);
if (linkedBoxOutputID != CIdentifier::undefined())
{
m_parent.exportIdentifier(buffer,OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxOutputID, linkedBoxOutputID);
}
else { m_parent.exportUInteger(buffer, OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxOutputIdx, uint64_t(linkedBoxOutputIdx)); }
m_parent.exportStop(buffer);
return true;
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,509 @@
#include "ovtkCAlgorithmScenarioImporter.h"
#include <vector>
#include <map>
#include <iostream>
#include <algorithm>
namespace OpenViBE {
namespace Toolkit {
namespace {
typedef struct SScenarioInput
{
CIdentifier id = CIdentifier::undefined();
CIdentifier typeID = CIdentifier::undefined();
CString name;
CIdentifier linkedBoxID = CIdentifier::undefined();
size_t linkedBoxInputIdx = size_t(-1);
CIdentifier linkedBoxInputID = CIdentifier::undefined();
} scenario_input_t;
typedef struct SScenarioOutput
{
CIdentifier id = CIdentifier::undefined();
CIdentifier typeID = CIdentifier::undefined();
CString name;
CIdentifier linkedBoxID = CIdentifier::undefined();
size_t linkedBoxOutputIdx = size_t(-1);
CIdentifier linkedBoxOutputID = CIdentifier::undefined();
} scenario_output_t;
typedef struct SInput
{
CIdentifier id = CIdentifier::undefined();
CIdentifier typeID = CIdentifier::undefined();
CString name;
} input_t;
typedef struct SOutput
{
CIdentifier id = CIdentifier::undefined();
CIdentifier typeID = CIdentifier::undefined();
CString name;
} output_t;
typedef struct SSetting
{
CIdentifier typeID = CIdentifier::undefined();
CString name;
CString defaultValue;
CString value;
bool modifiability = false;
CIdentifier id = CIdentifier::undefined();
} setting_t;
typedef struct SAttribute
{
CIdentifier id = CIdentifier::undefined();
CString value;
} attribute_t;
typedef struct SBox
{
CIdentifier id = CIdentifier::undefined();
CIdentifier algorithmClassID = CIdentifier::undefined();
CString name;
std::vector<input_t> inputs;
std::vector<output_t> outputs;
std::vector<setting_t> settings;
std::vector<attribute_t> attributes;
} box_t;
typedef struct SComment
{
CIdentifier id;
CString text;
std::vector<attribute_t> attributes;
} comment_t;
typedef struct SMetadata
{
CIdentifier identifier;
CIdentifier type;
CString data;
} metadata_t;
typedef struct SLinkSrc
{
CIdentifier boxID;
size_t boxOutputIdx = size_t(-1);
CIdentifier boxOutputID = CIdentifier::undefined();
} link_src_t;
typedef struct SLinkDst
{
CIdentifier boxID;
size_t boxInputIdx = size_t(-1);
CIdentifier boxInputID = CIdentifier::undefined();
} link_dst_t;
typedef struct SLink
{
CIdentifier id;
link_src_t linkSrc;
link_dst_t linkDst;
std::vector<attribute_t> attributes;
} link_t;
typedef struct SScenario
{
std::vector<setting_t> settings;
std::vector<scenario_input_t> iScenarios;
std::vector<scenario_output_t> oScenarios;
std::vector<box_t> boxes;
std::vector<comment_t> comments;
std::vector<metadata_t> metadata;
std::vector<link_t> links;
std::vector<attribute_t> attributes;
} scenario_t;
} // namespace
class CAlgorithmScenarioImporterContext final : public Plugins::IAlgorithmScenarioImporterContext
{
public:
explicit CAlgorithmScenarioImporterContext(Kernel::IAlgorithmContext& algorithmCtx) : m_AlgorithmContext(algorithmCtx) { }
bool processStart(const CIdentifier& identifier) override;
bool processIdentifier(const CIdentifier& identifier, const CIdentifier& value) override;
bool processString(const CIdentifier& identifier, const CString& value) override;
bool processUInteger(const CIdentifier& identifier, uint64_t value) override;
bool processStop() override { return true; }
_IsDerivedFromClass_Final_(IAlgorithmScenarioImporterContext, CIdentifier::undefined())
Kernel::IAlgorithmContext& m_AlgorithmContext;
scenario_t m_SymbolicScenario;
};
bool CAlgorithmScenarioImporter::process()
{
Kernel::TParameterHandler<Kernel::IScenario*> op_scenario(this->getOutputParameter(OV_Algorithm_ScenarioImporter_OutputParameterId_Scenario));
Kernel::IScenario* scenario = op_scenario;
OV_ERROR_UNLESS_KRF(scenario, "Output scenario is NULL", Kernel::ErrorType::BadOutput);
Kernel::TParameterHandler<IMemoryBuffer*> ip_buffer(this->getInputParameter(OV_Algorithm_ScenarioImporter_InputParameterId_MemoryBuffer));
IMemoryBuffer* memoryBuffer = ip_buffer;
OV_ERROR_UNLESS_KRF(memoryBuffer, "Input memory buffer is NULL", Kernel::ErrorType::BadInput);
std::map<CIdentifier, CIdentifier> boxIdMapping;
CAlgorithmScenarioImporterContext context(this->getAlgorithmContext());
OV_ERROR_UNLESS_KRF(this->import(context, *memoryBuffer), "Import failed", Kernel::ErrorType::Internal);
scenario_t& symbolicScenario = context.m_SymbolicScenario;
// Now build the scenario according to what has been loaded
for (auto s = symbolicScenario.settings.begin(); s != symbolicScenario.settings.end(); ++s)
{
CIdentifier settingID = s->id;
// compute identifier only if it does not exists
if (settingID == CIdentifier::undefined()) { settingID = scenario->getUnusedSettingIdentifier(); }
scenario->addSetting(s->name, s->typeID, s->defaultValue, size_t(-1), false, settingID);
scenario->setSettingValue(scenario->getSettingCount() - 1, s->value);
}
for (auto b = symbolicScenario.boxes.begin(); b != symbolicScenario.boxes.end(); ++b)
{
Kernel::IBox* box = nullptr;
CIdentifier newBoxID;
scenario->addBox(newBoxID, b->id);
box = scenario->getBoxDetails(newBoxID);
if (box)
{
box->setName(b->name);
for (auto i = b->inputs.begin(); i != b->inputs.end(); ++i) { box->addInput(i->name, i->typeID, i->id); }
for (auto o = b->outputs.begin(); o != b->outputs.end(); ++o) { box->addOutput(o->name, o->typeID, o->id); }
for (auto s = b->settings.begin(); s != b->settings.end(); ++s)
{
const CIdentifier& type = s->typeID;
if (!this->getTypeManager().isRegistered(type) && !(this->getTypeManager().isEnumeration(type)) && (!this->getTypeManager().isBitMask(type)))
{
const std::string msg = std::string("The type of the setting ") + s->name.toASCIIString() + " (" + type.str() + ") from box "
+ b->name.toASCIIString() + " cannot be recognized.";
if (this->getConfigurationManager().expandAsBoolean("${Kernel_AbortScenarioImportOnUnknownSetting}", true))
{
OV_ERROR_KRF(msg, Kernel::ErrorType::BadSetting);
}
OV_WARNING_K(msg);
}
box->addSetting(s->name, s->typeID, s->defaultValue, size_t(-1), s->modifiability, s->id);
box->setSettingValue(box->getSettingCount() - 1, s->value);
}
for (auto a = b->attributes.begin(); a != b->attributes.end(); ++a) { box->addAttribute(a->id, a->value); }
// it is important to set box algorithm at
// last so the box listener is never called
box->setAlgorithmClassIdentifier(b->algorithmClassID);
}
boxIdMapping[b->id] = newBoxID;
}
for (auto c = symbolicScenario.comments.begin(); c != symbolicScenario.comments.end(); ++c)
{
Kernel::IComment* comment = nullptr;
CIdentifier newCommentID;
scenario->addComment(newCommentID, c->id);
comment = scenario->getCommentDetails(newCommentID);
if (comment)
{
comment->setText(c->text);
for (auto a = c->attributes.begin(); a != c->attributes.end(); ++a) { comment->addAttribute(a->id, a->value); }
}
}
for (auto& symbolicMetadata : symbolicScenario.metadata)
{
CIdentifier newMetadataIdentifier;
scenario->addMetadata(newMetadataIdentifier, symbolicMetadata.identifier);
Kernel::IMetadata* metadata = scenario->getMetadataDetails(newMetadataIdentifier);
if (metadata)
{
metadata->setType(symbolicMetadata.type);
metadata->setData(symbolicMetadata.data);
}
}
for (auto l = symbolicScenario.links.begin(); l != symbolicScenario.links.end(); ++l)
{
Kernel::ILink* link = nullptr;
CIdentifier newLinkID;
size_t srcBoxOutputIdx = l->linkSrc.boxOutputIdx;
size_t dstBoxInputIdx = l->linkDst.boxInputIdx;
CIdentifier srcBoxOutputID = l->linkSrc.boxOutputID;
CIdentifier dstBoxInputID = l->linkDst.boxInputID;
if (srcBoxOutputID != CIdentifier::undefined()) { scenario->getSourceBoxOutputIndex(boxIdMapping[l->linkSrc.boxID], srcBoxOutputID, srcBoxOutputIdx); }
OV_ERROR_UNLESS_KRF(srcBoxOutputIdx != size_t(-1), "Output index of the source box could not be found", Kernel::ErrorType::BadOutput);
if (dstBoxInputID != CIdentifier::undefined()) { scenario->getTargetBoxInputIndex(boxIdMapping[l->linkDst.boxID], dstBoxInputID, dstBoxInputIdx); }
OV_ERROR_UNLESS_KRF(dstBoxInputIdx != size_t(-1), "Input index of the target box could not be found", Kernel::ErrorType::BadOutput);
scenario->connect(newLinkID, boxIdMapping[l->linkSrc.boxID], srcBoxOutputIdx, boxIdMapping[l->linkDst.boxID], dstBoxInputIdx, l->id);
link = scenario->getLinkDetails(newLinkID);
if (link) { for (auto a = l->attributes.begin(); a != l->attributes.end(); ++a) { link->addAttribute(a->id, a->value); } }
}
size_t scenarioInputIdx = 0;
for (auto symbolicScenarioInput : symbolicScenario.iScenarios)
{
CIdentifier scenarioInputID = symbolicScenarioInput.id;
// compute identifier only if it does not exists
if (scenarioInputID == CIdentifier::undefined()) { scenarioInputID = scenario->getUnusedInputIdentifier(); }
scenario->addInput(symbolicScenarioInput.name, symbolicScenarioInput.typeID, scenarioInputID);
if (symbolicScenarioInput.linkedBoxID != CIdentifier::undefined())
{
// Only try to set scenario output links from boxes that actually exist
// This enables the usage of header-only importers
if (symbolicScenario.boxes.end() != std::find_if(symbolicScenario.boxes.begin(), symbolicScenario.boxes.end(),
[&symbolicScenarioInput](const box_t& box) { return box.id == symbolicScenarioInput.linkedBoxID; })
)
{
CIdentifier linkedBoxInputIdentifier = symbolicScenarioInput.linkedBoxInputID;
size_t linkedBoxInputIndex = symbolicScenarioInput.linkedBoxInputIdx;
if (linkedBoxInputIdentifier != CIdentifier::undefined())
{
scenario->getTargetBoxInputIndex(symbolicScenarioInput.linkedBoxID, linkedBoxInputIdentifier, linkedBoxInputIndex);
}
OV_ERROR_UNLESS_KRF(linkedBoxInputIndex != size_t(-1), "Input index of the target box could not be found",
Kernel::ErrorType::BadOutput);
scenario->setScenarioInputLink(scenarioInputIdx, symbolicScenarioInput.linkedBoxID, linkedBoxInputIndex);
}
}
scenarioInputIdx++;
}
size_t scenarioOutputIdx = 0;
for (auto symbolicScenarioOutput : symbolicScenario.oScenarios)
{
CIdentifier scenarioOutputID = symbolicScenarioOutput.id;
// compute identifier only if it does not exists
if (scenarioOutputID == CIdentifier::undefined()) { scenarioOutputID = scenario->getUnusedOutputIdentifier(); }
scenario->addOutput(symbolicScenarioOutput.name, symbolicScenarioOutput.typeID, scenarioOutputID);
if (symbolicScenarioOutput.linkedBoxID != CIdentifier::undefined())
{
// Only try to set scenario output links from boxes that actually exist
// This enables the usage of header-only importers
if (std::any_of(symbolicScenario.boxes.begin(), symbolicScenario.boxes.end(), [&symbolicScenarioOutput](const box_t& box)
{
return box.id == symbolicScenarioOutput.linkedBoxID;
}))
{
CIdentifier linkedBoxOutputIdentifier = symbolicScenarioOutput.linkedBoxOutputID;
size_t linkedBoxOutputIndex = symbolicScenarioOutput.linkedBoxOutputIdx;
if (linkedBoxOutputIdentifier != CIdentifier::undefined())
{
scenario->getSourceBoxOutputIndex(symbolicScenarioOutput.linkedBoxID, linkedBoxOutputIdentifier, linkedBoxOutputIndex);
}
OV_ERROR_UNLESS_KRF(linkedBoxOutputIndex != size_t(-1), "Output index of the target box could not be found",
Kernel::ErrorType::BadOutput);
scenario->setScenarioOutputLink(scenarioOutputIdx, symbolicScenarioOutput.linkedBoxID, linkedBoxOutputIndex);
}
}
scenarioOutputIdx++;
}
for (auto a = symbolicScenario.attributes.begin(); a != symbolicScenario.attributes.end(); ++a) { scenario->addAttribute(a->id, a->value); }
if (scenario->checkOutdatedBoxes())
{
CIdentifier* listID = nullptr;
size_t nbElems = 0;
scenario->getOutdatedBoxIdentifierList(&listID, &nbElems);
for (size_t i = 0; i < nbElems; ++i)
{
const Kernel::IBox* box = scenario->getBoxDetails(listID[i]);
OV_WARNING_K(std::string("Box ") + box->getName().toASCIIString() + " [" + box->getAlgorithmClassIdentifier().str() + "] should be updated");
}
scenario->releaseIdentifierList(listID);
}
return true;
}
bool CAlgorithmScenarioImporterContext::processStart(const CIdentifier& identifier)
{
if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_OpenViBEScenario) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Settings) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting) { m_SymbolicScenario.settings.push_back(setting_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Inputs) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input) { m_SymbolicScenario.iScenarios.push_back(scenario_input_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Outputs) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output) { m_SymbolicScenario.oScenarios.push_back(scenario_output_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Creator) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_CreatorVersion) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attributes) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute) { m_SymbolicScenario.attributes.push_back(attribute_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attributes) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute) { m_SymbolicScenario.boxes.back().attributes.push_back(attribute_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attributes) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute) { m_SymbolicScenario.links.back().attributes.push_back(attribute_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Boxes) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box) { m_SymbolicScenario.boxes.push_back(box_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comments) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment) { m_SymbolicScenario.comments.push_back(comment_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attributes) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute) { m_SymbolicScenario.comments.back().attributes.push_back(attribute_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Metadata) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry) { m_SymbolicScenario.metadata.push_back(metadata_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Links) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link) { m_SymbolicScenario.links.push_back(link_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Inputs) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input) { m_SymbolicScenario.boxes.back().inputs.push_back(input_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Outputs) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output) { m_SymbolicScenario.boxes.back().outputs.push_back(output_t()); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Settings) { }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting) { m_SymbolicScenario.boxes.back().settings.push_back(setting_t()); }
//
else
{
OV_ERROR("(start) Unexpected node identifier " << identifier.str(), Kernel::ErrorType::BadArgument, false,
m_AlgorithmContext.getErrorManager(), m_AlgorithmContext.getLogManager());
}
return true;
}
bool CAlgorithmScenarioImporterContext::processIdentifier(const CIdentifier& identifier, const CIdentifier& value)
{
if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_ID) { m_SymbolicScenario.settings.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_TypeID) { m_SymbolicScenario.settings.back().typeID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_ID) { m_SymbolicScenario.iScenarios.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_TypeID) { m_SymbolicScenario.iScenarios.back().typeID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxID) { m_SymbolicScenario.iScenarios.back().linkedBoxID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxInputID)
{
m_SymbolicScenario.iScenarios.back().linkedBoxInputID = value;
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_ID) { m_SymbolicScenario.oScenarios.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_TypeID) { m_SymbolicScenario.oScenarios.back().typeID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxID) { m_SymbolicScenario.oScenarios.back().linkedBoxID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxOutputID)
{
m_SymbolicScenario.oScenarios.back().linkedBoxOutputID = value;
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute_ID) { m_SymbolicScenario.boxes.back().attributes.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_ID) { m_SymbolicScenario.boxes.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_AlgorithmClassIdD) { m_SymbolicScenario.boxes.back().algorithmClassID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_ID) { m_SymbolicScenario.boxes.back().inputs.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_TypeID) { m_SymbolicScenario.boxes.back().inputs.back().typeID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_ID) { m_SymbolicScenario.boxes.back().outputs.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_TypeID) { m_SymbolicScenario.boxes.back().outputs.back().typeID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_ID) { m_SymbolicScenario.boxes.back().settings.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_TypeID) { m_SymbolicScenario.boxes.back().settings.back().typeID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment_ID) { m_SymbolicScenario.comments.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute_ID) { m_SymbolicScenario.comments.back().attributes.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_ID) { m_SymbolicScenario.metadata.back().identifier = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_Type) { m_SymbolicScenario.metadata.back().type = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute_ID) { m_SymbolicScenario.links.back().attributes.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_ID) { m_SymbolicScenario.links.back().id = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxID) { m_SymbolicScenario.links.back().linkSrc.boxID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputID) { m_SymbolicScenario.links.back().linkSrc.boxOutputID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxID) { m_SymbolicScenario.links.back().linkDst.boxID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputID) { m_SymbolicScenario.links.back().linkDst.boxInputID = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute_ID) { m_SymbolicScenario.attributes.back().id = value; }
else
{
OV_ERROR("(id) Unexpected node identifier " << identifier.str(),
Kernel::ErrorType::BadArgument, false, m_AlgorithmContext.getErrorManager(), m_AlgorithmContext.getLogManager());
}
return true;
}
bool CAlgorithmScenarioImporterContext::processString(const CIdentifier& identifier, const CString& value)
{
if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute_Value) { m_SymbolicScenario.boxes.back().attributes.back().value = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Name) { m_SymbolicScenario.boxes.back().name = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_Name) { m_SymbolicScenario.boxes.back().inputs.back().name = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_Name) { m_SymbolicScenario.boxes.back().outputs.back().name = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Name) { m_SymbolicScenario.boxes.back().settings.back().name = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_DefaultValue)
{
m_SymbolicScenario.boxes.back().settings.back().defaultValue = value;
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Value) { m_SymbolicScenario.boxes.back().settings.back().value = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Modifiability)
{
m_SymbolicScenario.boxes.back().settings.back().modifiability = (value == CString("true")) ? true : false;
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Text) { m_SymbolicScenario.comments.back().text = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute_Value)
{
m_SymbolicScenario.comments.back().attributes.back().value = value;
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_MetadataEntry_Data) { m_SymbolicScenario.metadata.back().data = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute_Value) { m_SymbolicScenario.links.back().attributes.back().value = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute_Value) { m_SymbolicScenario.attributes.back().value = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_Name) { m_SymbolicScenario.settings.back().name = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_DefaultValue) { m_SymbolicScenario.settings.back().defaultValue = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Setting_Value) { m_SymbolicScenario.settings.back().value = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_Name) { m_SymbolicScenario.iScenarios.back().name = value; }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_Name) { m_SymbolicScenario.oScenarios.back().name = value; }
else
{
OV_ERROR("(string) Unexpected node identifier " << identifier.str(), Kernel::ErrorType::BadArgument,
false, m_AlgorithmContext.getErrorManager(), m_AlgorithmContext.getLogManager());
}
return true;
}
bool CAlgorithmScenarioImporterContext::processUInteger(const CIdentifier& identifier, const uint64_t value)
{
if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputIdx) { m_SymbolicScenario.links.back().linkSrc.boxOutputIdx = size_t(value); }
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputIdx)
{
m_SymbolicScenario.links.back().linkDst.boxInputIdx = size_t(value);
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Input_LinkedBoxInputIdx)
{
m_SymbolicScenario.iScenarios.back().linkedBoxInputIdx = size_t(value);
}
else if (identifier == OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Output_LinkedBoxOutputIdx)
{
m_SymbolicScenario.oScenarios.back().linkedBoxOutputIdx = size_t(value);
}
else
{
OV_ERROR("(uint) Unexpected node identifier " << identifier.str(), Kernel::ErrorType::BadArgument, false,
m_AlgorithmContext.getErrorManager(), m_AlgorithmContext.getLogManager());
}
return true;
}
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,261 @@
#include "toolkit/ovtk_all.h"
namespace OpenViBE {
namespace Toolkit {
// ********************************************************************************************************************
// *
// VIM Replace string to easily add enumeration values : *
// *
// :%s/#define \([A-Za-z0-9_]\+\).*/ typeManager.registerEnumerationEntry(OV_TypeId_Stimulation, "\1", \1);/g *
// *
// ********************************************************************************************************************
bool initialize(const Kernel::IKernelContext& ctx)
{
Kernel::ITypeManager& typeManager = ctx.getTypeManager();
initializeStimulationList(ctx);
// Register measurement units. See ovtk_defines.h for details.
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "?", OVTK_UNIT_Unspecified);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "-", OVTK_UNIT_Dimensionless);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "%", OVTK_UNIT_10_2_Percent);
// typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "percent", OVTK_UNIT_10_2_Percent);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ppht", OVTK_UNIT_10_3_Parts_Per_Thousand);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ppm", OVTK_UNIT_10_6_Parts_Per_Million);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ppmd", OVTK_UNIT_10_9_Parts_Per_Milliard);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ppb", OVTK_UNIT_10_12_Parts_Per_Billion);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ppt", OVTK_UNIT_10_18_Parts_Per_Trillion);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "degree", OVTK_UNIT_Angle_Degree);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "rad", OVTK_UNIT_Angle_Radian);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g g-1", OVTK_UNIT_Grams_Per_Gram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g kg-1", OVTK_UNIT_Grams_Per_Kilogram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol mol-1", OVTK_UNIT_Moles_Per_Mole);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l l-1", OVTK_UNIT_Litres_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m m-3", OVTK_UNIT_Cubic_Metres_Per_Cubic_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m cm-3", OVTK_UNIT_Cubic_Metres_Per_Cubic_Centimetre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "vol %", OVTK_UNIT_Volume_Percent);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "pH", OVTK_UNIT_Ph);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "drop", OVTK_UNIT_Drop);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "rbc", OVTK_UNIT_Red_Blood_Cells);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "beat", OVTK_UNIT_Beat);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "breath", OVTK_UNIT_Breath);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cell", OVTK_UNIT_Cell);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cough", OVTK_UNIT_Cough);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "sigh", OVTK_UNIT_Sigh);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "%PCV", OVTK_UNIT_Percent_Of_Packed_Cell_Volume);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m", OVTK_UNIT_Metres);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "yd", OVTK_UNIT_Yard);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ft", OVTK_UNIT_Foot);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "in", OVTK_UNIT_Inch);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "lm-2", OVTK_UNIT_Litres_Per_Square_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m-1", OVTK_UNIT_Per_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m2", OVTK_UNIT_Square_Metres);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "in2", OVTK_UNIT_Square_Inch);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m-2", OVTK_UNIT_Per_Square_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m3", OVTK_UNIT_Cubic_Metres);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l", OVTK_UNIT_Litres);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l_breath-1", OVTK_UNIT_Litres_Per_Breath);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l_beat-1", OVTK_UNIT_Litres_Per_Beat);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m-3", OVTK_UNIT_Per_Cubic_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l-1", OVTK_UNIT_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g", OVTK_UNIT_Gram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "lb", OVTK_UNIT_Pound);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "oz", OVTK_UNIT_Ounce);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g-1", OVTK_UNIT_Per_Gram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "gm", OVTK_UNIT_Gram_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g m m-2", OVTK_UNIT_Grams_Meter_Per_Square_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "kg m2", OVTK_UNIT_Gram_Metre_Squared);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "kg m-2", OVTK_UNIT_Kilograms_Per_Square_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g m-3", OVTK_UNIT_Grams_Per_Cubic_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g cm-3", OVTK_UNIT_Grams_Per_Cubic_Centimetre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g l-1", OVTK_UNIT_Grams_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g cl-3", OVTK_UNIT_Grams_Per_Centilitre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g dl-3", OVTK_UNIT_Grams_Per_Decilitre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g ml-3", OVTK_UNIT_Grams_Per_Millilitre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "s", OVTK_UNIT_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "min", OVTK_UNIT_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "h", OVTK_UNIT_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "d", OVTK_UNIT_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "weeks", OVTK_UNIT_Weeks);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mth", OVTK_UNIT_Months);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "y", OVTK_UNIT_Year);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "TOD", OVTK_UNIT_Time_Of_Day_Hh_Mm_Ss);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "DATE", OVTK_UNIT_Date_Yyyy_Mm_Dd);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "s-1", OVTK_UNIT_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Hz", OVTK_UNIT_Hertz);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "min-1", OVTK_UNIT_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "h-1", OVTK_UNIT_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "d-1", OVTK_UNIT_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "week-1", OVTK_UNIT_Per_Week);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mth-1", OVTK_UNIT_Per_Month);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "y-1", OVTK_UNIT_Per_Year);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "bpm", OVTK_UNIT_Beat_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "puls min-1", OVTK_UNIT_Puls_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "resp min-1", OVTK_UNIT_Respirations_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m s-1", OVTK_UNIT_Metres_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l min-1 m-2", OVTK_UNIT_Litres_Per_Minute_Per_Square_Meter);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m2 s-1", OVTK_UNIT_Square_Metres_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m3 s-1", OVTK_UNIT_Cubic_Metres_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m3 min-1", OVTK_UNIT_Cubic_Metres_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m3 h-1", OVTK_UNIT_Cubic_Metres_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m3 d-1", OVTK_UNIT_Cubic_Metres_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l s-1", OVTK_UNIT_Litres_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l min-1", OVTK_UNIT_Litres_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l h-1", OVTK_UNIT_Litres_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l d-1", OVTK_UNIT_Litres_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l kg-1", OVTK_UNIT_Litres_Per_Kilogram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m3 kg-1", OVTK_UNIT_Cubic_Metres_Per_Kilogram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m Pa-1s-1", OVTK_UNIT_Meter_Per_Pascal_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l min-1 mmHG-1", OVTK_UNIT_Litre_Per_Min_Per_Millimetre_Of_Mercury);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g s-1", OVTK_UNIT_Grams_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g m-1", OVTK_UNIT_Grams_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g h-1", OVTK_UNIT_Grams_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g d-1", OVTK_UNIT_Grams_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g kg-1 s-1", OVTK_UNIT_Grams_Per_Kilogram_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g kg-1 m-1", OVTK_UNIT_Grams_Per_Kilogram_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g kg-1 h-1", OVTK_UNIT_Grams_Per_Kilogram_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g kg-1 d-1", OVTK_UNIT_Grams_Per_Kilogram_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g l-1_s-1", OVTK_UNIT_Grams_Per_Litre_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g l-1 m-1", OVTK_UNIT_Grams_Per_Litre_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g l-1 h-1", OVTK_UNIT_Grams_Per_Litre_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g l-1 d-1", OVTK_UNIT_Grams_Per_Litre_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g m-1 s-1", OVTK_UNIT_Grams_Per_Meter_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "gm s-1", OVTK_UNIT_Gram_Metres_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Ns", OVTK_UNIT_Newton_Seconds);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "N", OVTK_UNIT_Newton);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "dyn", OVTK_UNIT_Dyne);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Pa", OVTK_UNIT_Pascal);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mmHg", OVTK_UNIT_Millimetres_Of_Mercury);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cm H2O", OVTK_UNIT_Centimetre_Of_Water);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "bar", OVTK_UNIT_Bar);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "J", OVTK_UNIT_Joules);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eV", OVTK_UNIT_Electronvolts);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "W", OVTK_UNIT_Watts);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Pa_s_m-3", OVTK_UNIT_Pascal_Second_Per_Cubic_Meter);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Pa_s_l-1", OVTK_UNIT_Pascal_Second_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "dyne s cm-5", OVTK_UNIT_Dyne_Second_Per_Cm5);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l cmH2O-1", OVTK_UNIT_Litre_Per_Centimetre_Of_Water);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l mmHg-1", OVTK_UNIT_Litre_Per_Millimetre_Of_Mercury);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l Pa-1", OVTK_UNIT_Litre_Per_Pascal);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cmH2O l-1", OVTK_UNIT_Centimetre_Of_Water_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mmHg l-1", OVTK_UNIT_Millimetre_Of_Mercury_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Pa l-1", OVTK_UNIT_Pascal_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "A", OVTK_UNIT_Amperes);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "C", OVTK_UNIT_Coulombs);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Ah", OVTK_UNIT_Amperes_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "A m-1", OVTK_UNIT_Amperes_Per_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "V", OVTK_UNIT_Volts);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Ohm", OVTK_UNIT_Ohms);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Wm", OVTK_UNIT_Ohm_Metres);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "F", OVTK_UNIT_Farads);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "K", OVTK_UNIT_Kelvin);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "degC", OVTK_UNIT_Degree_Celcius);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "degF", OVTK_UNIT_Degree_Fahrenheit);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "K W-1", OVTK_UNIT_Kelvins_Per_Watt);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cd", OVTK_UNIT_Candelas);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "osmole", OVTK_UNIT_Osmoles);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol", OVTK_UNIT_Moles);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq", OVTK_UNIT_Equivalent);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "osmol l-1", OVTK_UNIT_Osmoles_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol cm-3", OVTK_UNIT_Moles_Per_Cubic_Centimetre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol m-3", OVTK_UNIT_Moles_Per_Cubic_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol l-1", OVTK_UNIT_Moles_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol ml-1", OVTK_UNIT_Moles_Per_Millilitre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq cm-3", OVTK_UNIT_Equivalents_Per_Cubic_Centimetre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq m-3", OVTK_UNIT_Equivalents_Per_Cubic_Metre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq l-1", OVTK_UNIT_Equivalents_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq ml-1", OVTK_UNIT_Equivalents_Per_Millilitre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "osmol kg-1", OVTK_UNIT_Osmoles_Per_Kilogram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol kg-1", OVTK_UNIT_Moles_Per_Kilogram);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol s-1", OVTK_UNIT_Moles_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol min-1", OVTK_UNIT_Moles_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol h-1", OVTK_UNIT_Moles_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol d-1", OVTK_UNIT_Moles_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq s-1", OVTK_UNIT_Equivalents_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq min-1", OVTK_UNIT_Equivalents_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq h-1", OVTK_UNIT_Equivalents_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq d-1", OVTK_UNIT_Equivalents_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol kg-1 s-1", OVTK_UNIT_Moles_Per_Kilogram_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol kg-1 min-1", OVTK_UNIT_Moles_Per_Kilogram_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol kg-1 h-1", OVTK_UNIT_Moles_Per_Kilogram_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol kg-1 d-1", OVTK_UNIT_Moles_Per_Kilogram_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq kg-1 s-1", OVTK_UNIT_Equivalents_Per_Kilogram_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq kg-1 min-1", OVTK_UNIT_Equivalents_Per_Kilogram_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq kg-1 h-1", OVTK_UNIT_Equivalents_Per_Kilogram_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "eq kg-1 d-1", OVTK_UNIT_Equivalents_Per_Kilogram_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u.", OVTK_UNIT_International_Unit);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. cm-3", OVTK_UNIT_International_Units_Per_Cubic_Centimetre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. m-3", OVTK_UNIT_International_Units_Per_Cubic_Meter);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. l-1", OVTK_UNIT_International_Units_Per_Litre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. ml-1", OVTK_UNIT_International_Units_Per_Millilitre);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. s-1", OVTK_UNIT_International_Units_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. min-1", OVTK_UNIT_International_Units_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. h-1", OVTK_UNIT_International_Units_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. d-1", OVTK_UNIT_International_Units_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. kg-1_s-1", OVTK_UNIT_International_Units_Per_Kilogram_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. kg-1_min-1", OVTK_UNIT_International_Units_Per_Kilogram_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. kg-1_h-1", OVTK_UNIT_International_Units_Per_Kilogram_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "i.u. kg-1_d-1", OVTK_UNIT_International_Units_Per_Kilogram_Per_Day);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cmH2O l-1s-1", OVTK_UNIT_Centimetre_Of_Water_Per_Litre_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l2s-1", OVTK_UNIT_Litre_Squared_Per_Second);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "cmH2O %-1", OVTK_UNIT_Centimetre_Of_Water_Per_Percent);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "dyne s m-2 cm-5",
OVTK_UNIT_Dyne_Seconds_Per_Square_Meter_Per_Centimetre_To_The_Power_Of_5);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mmHg %-1", OVTK_UNIT_Millimetres_Of_Mercury_Per_Percent);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "Pa %-1", OVTK_UNIT_Pascal_Per_Percent);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "B", OVTK_UNIT_Relative_Power_Decibel);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m s-2", OVTK_UNIT_Meter_Per_Second_Squared);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "rad s2-2", OVTK_UNIT_Radians_Per_Second_Squared);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "ft min-1", OVTK_UNIT_Foot_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "in min-1", OVTK_UNIT_Inch_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "step min-1", OVTK_UNIT_Step_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "kcal", OVTK_UNIT_Kilocalories);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "rpm", OVTK_UNIT_Revolution_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "V s-1", OVTK_UNIT_V_Per_S);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "m m-1", OVTK_UNIT_M_Per_M);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "km/h", OVTK_UNIT_Velocity_Kilometer_Per_Hour);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g_s-2", OVTK_UNIT_Left_Stroke_Work_Index_Lswi);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "g_s-3", OVTK_UNIT_Indexed_Left_Cardiac_Work_Lcwi);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mHg_s-1", OVTK_UNIT_Mhg_Per_S);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "mol l-1 mm", OVTK_UNIT_Millimol_Per_Liter_X_Millimeter);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "r.p.m", OVTK_UNIT_Rotations_Per_Minute);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "dyne*s*m*m cm-5", OVTK_UNIT_Dyne_Seconds_Square_Meter_Per_Centimetre_To_The_Power_Of_5);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "l m-2", OVTK_UNIT_Litres_Per_Square_Meter);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "T", OVTK_UNIT_Tesla);
typeManager.registerEnumerationEntry(OV_TypeId_MeasurementUnit, "deg/s", OVTK_UNIT_Degree_Per_Second);
// Register measurement factors
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+24", OVTK_FACTOR_Yotta);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+21", OVTK_FACTOR_Zetta);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+18", OVTK_FACTOR_Exa);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+15", OVTK_FACTOR_Peta);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+12", OVTK_FACTOR_Tera);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+09", OVTK_FACTOR_Giga);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+06", OVTK_FACTOR_Mega);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+03", OVTK_FACTOR_Kilo);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+02", OVTK_FACTOR_Hecto);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+01", OVTK_FACTOR_Deca);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e+00", OVTK_FACTOR_Base);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-01", OVTK_FACTOR_Deci);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-02", OVTK_FACTOR_Centi);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-03", OVTK_FACTOR_Milli);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-06", OVTK_FACTOR_Micro);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-09", OVTK_FACTOR_Nano);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-12", OVTK_FACTOR_Pico);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-15", OVTK_FACTOR_Femto);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-18", OVTK_FACTOR_Atto);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-21", OVTK_FACTOR_Zepto);
typeManager.registerEnumerationEntry(OV_TypeId_Factor, "1e-24", OVTK_FACTOR_Yocto);
typeManager.registerEnumerationType(OVTK_TypeId_ClassificationAlgorithm, "Classification algorithm");
typeManager.registerEnumerationType(OVTK_TypeId_ClassificationStrategy, "Classification strategy");
return true;
}
bool uninitialize(const Kernel::IKernelContext& ctx) { return true; }
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,417 @@
#include "ovtkMatrix.h"
#include <fs/Files.h>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cerrno>
// for save/load
#include <fstream>
#include <iostream>
#include <vector>
#include <locale> // std::isspace
#include <sstream>
namespace OpenViBE {
namespace Toolkit {
namespace Matrix {
enum class EParsingStatus { Nothing, ParsingHeader, ParsingHeaderDimension, ParsingHeaderLabel, ParsingBuffer, ParsingBufferValue };
// tokens in the ascii matrix format
const char CONSTANT_LEFT_SQUARE_BRACKET = '[';
const char CONSTANT_RIGHT_SQUARE_BRACKET = ']';
const char CONSTANT_HASHTAG = '#';
const char CONSTANT_DOUBLE_QUOTE = '"';
const char CONSTANT_TAB = '\t';
const char CONSTANT_CARRIAGE_RETURN = '\r';
const char CONSTANT_EOL = '\n';
const char CONSTANT_SPACE = ' ';
bool fromString(CMatrix& matrix, const CString& str)
{
std::stringstream buffer;
buffer << str.toASCIIString();
const std::locale locale("C");
//current string to parse
std::string what;
//current parsing status
EParsingStatus status = EParsingStatus::Nothing;
//current element index (incremented every time a value is stored in matrix)
size_t curElementIdx = 0;
//current dimension index
size_t curDimIdx = size_t(-1);
//vector keeping track of dimension sizes
std::vector<size_t> dimSize;
//vector keeping track of number of values found in each dimension
std::vector<size_t> nValue;
// Dim labels
std::vector<std::string> labels;
//current quote-delimited string
std::string curString;
do
{
//read current line
std::getline(buffer, what, CONSTANT_EOL);
//is line empty?
if (what.length() == 0) { continue; } //skip it
//output line to be parsed in debug level
// getLogManager() << Kernel::LogLevel_Debug << what << "\n";
//remove ending carriage return (if any) for windows / linux compatibility
if (what[what.length() - 1] == CONSTANT_CARRIAGE_RETURN) { what.erase(what.length() - 1, 1); }
//start parsing current line
auto it = what.begin();
//parse current line
while (it != what.end())
{
switch (status)
{
//initial parsing status
case EParsingStatus::Nothing:
//comments starting
if (*it == CONSTANT_HASHTAG) { it = what.end() - 1; } // ignore rest of line by skipping to last character
//header starting
else if (*it == CONSTANT_LEFT_SQUARE_BRACKET) { status = EParsingStatus::ParsingHeader; } // update status
else if (!std::isspace(*it, locale)) { return false; }
break;
//parse header
case EParsingStatus::ParsingHeader:
//comments starting
if (*it == CONSTANT_HASHTAG) { it = what.end() - 1; } //ignore rest of line by skipping to last character
//new dimension opened
else if (*it == CONSTANT_LEFT_SQUARE_BRACKET)
{
dimSize.resize(dimSize.size() + 1); //increment dimension count
curDimIdx++; //update current dimension index
status = EParsingStatus::ParsingHeaderDimension; //update status
}
//finished parsing header
else if (*it == CONSTANT_RIGHT_SQUARE_BRACKET)
{
if (dimSize.empty()) { return false; } //ensure at least one dimension was found
matrix.resize(dimSize); //resize matrix
nValue.resize(matrix.getDimensionCount());
// set labels now that we know the matrix size
size_t idx = 0;
for (size_t i = 0; i < matrix.getDimensionCount(); ++i)
{
for (size_t j = 0; j < matrix.getDimensionSize(i); ++j) { matrix.setDimensionLabel(i, j, labels[idx++].c_str()); }
}
//reset current dimension index
curDimIdx = size_t(-1);
//update status
status = EParsingStatus::ParsingBuffer;
}
else if (!std::isspace(*it, locale)) { return false; }
break;
case EParsingStatus::ParsingHeaderDimension:
//comments starting
if (*it == CONSTANT_HASHTAG) { it = what.end() - 1; } //ignore rest of line by skipping to last character
//new label found
else if (*it == CONSTANT_DOUBLE_QUOTE)
{
//new element found in current dimension
dimSize[curDimIdx]++;
//update status
status = EParsingStatus::ParsingHeaderLabel;
}
//finished parsing current dimension header
else if (*it == CONSTANT_RIGHT_SQUARE_BRACKET) { status = EParsingStatus::ParsingHeader; } //update status
else if (!std::isspace(*it, locale)) { return false; }
break;
//look for end of label (first '"' char not preceded by the '\' escape char)
case EParsingStatus::ParsingHeaderLabel:
//found '"' char not preceded by escape char : end of label reached
if (*it == CONSTANT_DOUBLE_QUOTE && *(it - 1) != '\\')
{
// We can only attach the label later after we know the size
labels.push_back(curString);
// std::cout << " lab " << curDimensionIdx << " " << dimSize[curDimensionIdx]-1 << " : " << curString << "\n";
//clear current string
curString.erase();
//update status
status = EParsingStatus::ParsingHeaderDimension;
}
//otherwise, keep parsing current label
else { curString.append(1, *it); }
break;
case EParsingStatus::ParsingBuffer:
//comments starting
if (*it == CONSTANT_HASHTAG) { it = what.end() - 1; } //ignore rest of line by skipping to last character
//going down one dimension
else if (*it == CONSTANT_LEFT_SQUARE_BRACKET)
{
//update dimension index
curDimIdx++;
//ensure dimension count remains in allocated range
if (curDimIdx == matrix.getDimensionCount()) { return false; }
//ensure values count remains in allocated range
if (nValue[curDimIdx] == matrix.getDimensionSize(curDimIdx)) { return false; }
//increment values count for current dimension, if it is not the innermost
if (curDimIdx < matrix.getDimensionCount() - 1) { nValue[curDimIdx]++; }
}
//going up one dimension
else if (*it == CONSTANT_RIGHT_SQUARE_BRACKET)
{
//if we are not in innermost dimension
if (curDimIdx < matrix.getDimensionCount() - 1)
{
//ensure the right number of values was parsed in lower dimension
if (nValue[curDimIdx + 1] != matrix.getDimensionSize(curDimIdx + 1)) { return false; }
//reset values count of lower dimension to 0
nValue[curDimIdx + 1] = 0;
}
//ensure dimension count is correct
else if (curDimIdx == size_t(-1)) { return false; }
//go up one dimension
curDimIdx--;
}
//non whitespace character found
else if (!std::isspace(*it, locale))
{
//if we are in innermost dimension, assume a value is starting here
if (curDimIdx == matrix.getDimensionCount() - 1)
{
//ensure values parsed so far in current dimension doesn't exceed current dimension size
if (nValue.back() == matrix.getDimensionSize(curDimIdx)) { return false; }
//increment values count found in innermost dimension
nValue[curDimIdx]++;
//append current character to current string
curString.append(1, *it);
//update status
status = EParsingStatus::ParsingBufferValue;
}
else { return false; }
}
break;
//look for end of value (first '"' char not preceded by the '\' escape char)
case EParsingStatus::ParsingBufferValue:
//values end at first whitespace character or ']' character
if (std::isspace(*it, locale) == true || *it == CONSTANT_RIGHT_SQUARE_BRACKET)
{
//if dimension closing bracket is found
if (*it == CONSTANT_RIGHT_SQUARE_BRACKET)
{
//move back iterator by one character so that closing bracket is taken into account in EParsingStatus::ParsingBuffer case
--it;
}
//retrieve value
errno = 0;
char* end;
const double value = strtod(curString.c_str(), &end);
#if defined TARGET_OS_Windows
//string couldn't be converted to a double
if (errno == ERANGE) { return false; }
#endif
//store value in matrix
(matrix.getBuffer())[curElementIdx] = value;
//update element index
curElementIdx++;
//reset current string
curString.erase();
//update status
status = EParsingStatus::ParsingBuffer;
}
//otherwise, append current character to current string
else { curString.append(1, *it); }
break;
} // switch(status)
//increment iterator
++it;
} // while(it != what.end()) (read each character of current line)
} while (buffer.good()); //read each line in turn
//If the file is empty or other (like directory)
if (nValue.empty()) { return false; }
//ensure the right number of values were parsed in first dimension
if (nValue[0] != matrix.getDimensionSize(0)) { return false; }
return true;
}
// A recursive helper function to spool matrix contents to a txt stringstream.
bool dumpMatrixBuffer(const CMatrix& matrix, std::stringstream& buffer, const size_t index1, size_t& index2)
{
//are we in innermost dimension?
if (index1 == matrix.getDimensionCount() - 1)
{
//dimension start
for (size_t j = 0; j < index1; ++j) { buffer << CONSTANT_TAB; }
buffer << CONSTANT_LEFT_SQUARE_BRACKET;
//dump current cell contents
for (size_t j = 0; j < matrix.getDimensionSize(index1); j++, index2++) { buffer << CONSTANT_SPACE << matrix.getBuffer()[index2]; }
//dimension end
buffer << CONSTANT_SPACE << CONSTANT_RIGHT_SQUARE_BRACKET << CONSTANT_EOL;
}
else
{
//dump all entries in current dimension
for (size_t i = 0; i < matrix.getDimensionSize(index1); ++i)
{
//dimension start
for (size_t j = 0; j < index1; ++j) { buffer << CONSTANT_TAB; }
buffer << CONSTANT_LEFT_SQUARE_BRACKET << CONSTANT_EOL;
dumpMatrixBuffer(matrix, buffer, index1 + 1, index2);
//dimension end
for (size_t j = 0; j < index1; ++j) { buffer << CONSTANT_TAB; }
buffer << CONSTANT_RIGHT_SQUARE_BRACKET << CONSTANT_EOL;
}
}
return true;
}
bool toString(const CMatrix& matrix, CString& str, const size_t precision /* = 6 */)
{
std::stringstream buffer;
buffer << std::scientific;
buffer.precision(std::streamsize(precision));
// Dump header
//header start
buffer << CONSTANT_LEFT_SQUARE_BRACKET << CONSTANT_EOL;
//dump labels for each dimension
for (size_t i = 0; i < matrix.getDimensionCount(); ++i)
{
buffer << CONSTANT_TAB << CONSTANT_LEFT_SQUARE_BRACKET;
for (size_t j = 0; j < matrix.getDimensionSize(i); ++j)
{
buffer << CONSTANT_SPACE << CONSTANT_DOUBLE_QUOTE << matrix.getDimensionLabel(i, j) << CONSTANT_DOUBLE_QUOTE;
}
buffer << CONSTANT_SPACE << CONSTANT_RIGHT_SQUARE_BRACKET << CONSTANT_EOL;
}
//header end
buffer << CONSTANT_RIGHT_SQUARE_BRACKET << CONSTANT_EOL;
// Dump buffer using a recursive algorithm
size_t idx = 0;
dumpMatrixBuffer(matrix, buffer, 0, idx);
str = buffer.str().c_str();
return true;
}
bool loadFromTextFile(CMatrix& matrix, const CString& filename)
{
std::ifstream dataFile;
FS::Files::openIFStream(dataFile, filename.toASCIIString(), std::ios_base::in);
if (!dataFile.is_open()) { return false; }
std::stringstream buffer;
buffer << dataFile.rdbuf();
const bool res = fromString(matrix, CString(buffer.str().c_str()));
dataFile.close();
return res;
}
bool saveToTextFile(const CMatrix& matrix, const CString& filename, const size_t precision /* = 6 */)
{
std::ofstream dataFile;
FS::Files::openOFStream(dataFile, filename.toASCIIString(), std::ios_base::out | std::ios_base::trunc);
if (!dataFile.is_open()) { return false; }
CString str;
if (!toString(matrix, str, precision)) { return false; }
dataFile << str.toASCIIString();
dataFile.close();
return true;
}
bool copy(CMatrix& dst, const CMatrix& src)
{
if (&dst == &src) { return true; }
dst.copy(src);
return true;
}
bool copyDescription(CMatrix& dst, const CMatrix& src)
{
if (&dst == &src) { return true; }
dst.copyDescription(src);
return true;
}
bool copyContent(CMatrix& dst, const CMatrix& src)
{
if (&dst == &src) { return true; }
const size_t nElementIn = src.getBufferElementCount();
const size_t nElementOut = dst.getBufferElementCount();
if (nElementOut != nElementIn) { return false; }
dst.copyContent(src);
return true;
}
bool clearContent(CMatrix& matrix)
{
matrix.resetBuffer();
return true;
}
bool isDescriptionSimilar(const CMatrix& src1, const CMatrix& src2, const bool checkLabels)
{
if (&src1 == &src2) { return true; }
return src1.isDescriptionEqual(src2, checkLabels);
}
bool isContentSimilar(const CMatrix& src1, const CMatrix& src2)
{
if (&src1 == &src2) { return true; }
return src1.isBufferEqual(src2);
}
bool isContentValid(const CMatrix& src, const bool checkNotANumber, const bool checkInfinity) { return src.isBufferValid(checkNotANumber, checkInfinity); }
} // namespace Matrix
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,56 @@
#include "ovtkStimulationSet.h"
namespace OpenViBE {
namespace Toolkit {
namespace StimulationSet {
bool shift(IStimulationSet& stimSet, const uint64_t timeShift)
{
const size_t count = stimSet.getStimulationCount();
for (size_t i = 0; i < count; ++i) { stimSet.setStimulationDate(i, stimSet.getStimulationDate(i) + timeShift); }
return true;
}
bool copy(IStimulationSet& dst, const IStimulationSet& src, const uint64_t timeShift)
{
dst.clear();
return append(dst, src, timeShift);
}
bool append(IStimulationSet& dst, const IStimulationSet& src, const uint64_t timeShift)
{
const size_t count = src.getStimulationCount();
for (size_t i = 0; i < count; ++i)
{
dst.appendStimulation(src.getStimulationIdentifier(i), src.getStimulationDate(i) + timeShift, src.getStimulationDuration(i));
}
return true;
}
bool appendRange(IStimulationSet& dst, const IStimulationSet& src, const uint64_t srcStartTime, const uint64_t srcEndTime, const uint64_t timeShift)
{
const size_t count = src.getStimulationCount();
for (size_t i = 0; i < count; ++i)
{
const uint64_t date = src.getStimulationDate(i);
if (srcStartTime <= date && date < srcEndTime)
{
dst.appendStimulation(src.getStimulationIdentifier(i), src.getStimulationDate(i) + timeShift, src.getStimulationDuration(i));
}
}
return true;
}
bool removeRange(IStimulationSet& stimSet, const uint64_t startTime, const uint64_t endTime)
{
for (size_t i = 0; i < stimSet.getStimulationCount(); ++i)
{
const uint64_t date = stimSet.getStimulationDate(i);
if (startTime <= date && date < endTime) { stimSet.removeStimulation(i--); }
}
return true;
}
} // namespace StimulationSet
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,92 @@
#include "ovtkString.h"
#include <cstring>
#include <string>
#include <algorithm>
#include <functional>
#include <cctype>
#include <cstring>
namespace OpenViBE {
namespace Toolkit {
namespace String {
static bool isSeparator(const uint8_t value, const uint8_t* separator, const size_t nSeparator)
{
for (size_t i = 0; i < nSeparator; ++i) { if (value == separator[i]) { return true; } }
return false;
}
// because std::tolower has multiple signatures,
// it can not be easily used in std::transform
// this workaround is taken from http://www.gcek.net/ref/books/sw/cpp/ticppv2/
template <class T>
static T ToLower(T c) { return std::tolower(c); }
size_t split(const CString& str, const ISplitCallback& splitCB, uint8_t separator) { return split(str, splitCB, &separator, 1); }
size_t split(const CString& str, const ISplitCallback& splitCB, uint8_t* separator, const size_t nSeparator)
{
if (nSeparator == 0 || separator == nullptr) { return 0; }
size_t n = 0;
std::string tmp(str.toASCIIString());
size_t i = 0;
while (i < tmp.length())
{
size_t j = i;
while (j < tmp.length() && !isSeparator(tmp[j], separator, nSeparator)) { j++; }
//if(i!=j)
{
splitCB.setToken(std::string(tmp, i, j - i).c_str());
n++;
}
i = j + 1;
}
if (tmp.length() != 0 && isSeparator(tmp[tmp.length() - 1], separator, nSeparator))
{
splitCB.setToken("");
n++;
}
return n;
}
bool isAlmostEqual(const CString& str1, const CString& str2, const bool caseSensitive, const bool removeStartSpaces, const bool removeEndSpaces)
{
const char* str1Start = str1.toASCIIString();
const char* str1End = str1Start + strlen(str1Start) - 1;
const char* str2Start = str2.toASCIIString();
const char* str2End = str2Start + strlen(str2Start) - 1;
if (removeStartSpaces)
{
while (*str1Start == ' ') { str1Start++; }
while (*str2Start == ' ') { str2Start++; }
}
if (removeEndSpaces)
{
while (str1Start < str1End && *str1End == ' ') { str1End--; }
while (str2Start < str2End && *str2End == ' ') { str2End--; }
}
std::string tmp1(str1Start, str1End - str1Start + 1);
std::string tmp2(str2Start, str2End - str2Start + 1);
if (!caseSensitive)
{
std::transform(tmp1.begin(), tmp1.end(), tmp1.begin(), ToLower<std::string::value_type>);
std::transform(tmp2.begin(), tmp2.end(), tmp2.begin(), ToLower<std::string::value_type>);
}
return tmp1 == tmp2;
}
} // namespace String
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,88 @@
#include "ovtkCSignalTrial.hpp"
namespace OpenViBE {
namespace Toolkit {
bool CSignalTrial::setSamplingRate(const size_t sampling)
{
m_sampling = sampling;
return m_sampling != 0;
}
bool CSignalTrial::setChannelCount(const size_t count)
{
size_t i;
for (i = 0; i < count; ++i) { if (m_channelSamples.find(i) == m_channelSamples.end()) { m_channelSamples[i] = new double[m_nSampleReserved]; } }
for (i = count; i < m_nChannel; ++i)
{
delete [] m_channelSamples[i];
m_channelSamples.erase(m_channelSamples.find(i));
}
m_nChannel = count;
m_nSample = 0;
m_channelNames.clear();
return m_nChannel != 0;
}
bool CSignalTrial::setChannelName(const size_t index, const char* name)
{
if (index < m_nChannel)
{
m_channelNames[index] = name;
return true;
}
return false;
}
bool CSignalTrial::setLabelIdentifier(const CIdentifier& labelID)
{
m_labelID = labelID;
return true;
}
bool CSignalTrial::setSampleCount(const size_t count, const bool preserve)
{
const size_t nSampleRounding = 0x00000fff;
if (count > m_nSampleReserved)
{
const size_t nSampleReserved = (count + nSampleRounding + 1) & (~nSampleRounding);
for (auto it = m_channelSamples.begin(); it != m_channelSamples.end(); ++it)
{
double* sample = new double[nSampleReserved];
if (preserve) { memcpy(sample, it->second, (count < m_nSample ? count : m_nSample) * sizeof(double)); }
delete [] it->second;
it->second = sample;
}
m_nSampleReserved = nSampleReserved;
}
m_nSample = count;
return true;
}
// ________________________________________________________________________________________________________________
//
const char* CSignalTrial::getChannelName(const size_t index) const
{
const auto it = m_channelNames.find(index);
if (it != m_channelNames.end()) { return it->second.c_str(); }
return "";
}
double* CSignalTrial::getChannelSampleBuffer(const size_t index) const
{
const auto it = m_channelSamples.find(index);
if (it != m_channelSamples.end()) { return it->second; }
return nullptr;
}
// ________________________________________________________________________________________________________________
//
ISignalTrial* createSignalTrial() { return new CSignalTrial(); }
void releaseSignalTrial(ISignalTrial* trial) { delete trial; }
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,42 @@
#pragma once
#include "ovtkISignalTrial.h"
#include <map>
#include <string>
namespace OpenViBE {
namespace Toolkit {
class CSignalTrial final : public ISignalTrial
{
public:
CSignalTrial() {}
~CSignalTrial() override { for (auto& s : m_channelSamples) { delete [] s.second; } }
bool setSamplingRate(size_t sampling) override;
bool setChannelCount(size_t count) override;
bool setChannelName(size_t index, const char* name) override;
bool setLabelIdentifier(const CIdentifier& labelID) override;
bool setSampleCount(size_t count, bool preserve) override;
size_t getSamplingRate() const override { return m_sampling; }
size_t getChannelCount() const override { return m_nChannel; }
const char* getChannelName(const size_t index) const override;
CIdentifier getLabelIdentifier() const override { return m_labelID; }
size_t getSampleCount() const override { return m_nSample; }
uint64_t getDuration() const override { return (m_sampling ? CTime(m_sampling, m_nSample).time() : 0); }
double* getChannelSampleBuffer(size_t index) const override;
_IsDerivedFromClass_Final_(ISignalTrial, OVTK_ClassId_)
protected:
std::map<size_t, std::string> m_channelNames;
std::map<size_t, double*> m_channelSamples;
size_t m_nChannel = 0;
size_t m_nSample = 0;
size_t m_nSampleReserved = 0;
size_t m_sampling = 0;
CIdentifier m_labelID = CIdentifier::undefined();
};
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,22 @@
#include "ovtkCSignalTrialSet.hpp"
namespace OpenViBE {
namespace Toolkit {
bool CSignalTrialSet::addSignalTrial(ISignalTrial& rSignalTrial)
{
m_signalTrials.push_back(&rSignalTrial);
return true;
}
bool CSignalTrialSet::clear()
{
m_signalTrials.clear();
return true;
}
ISignalTrialSet* createSignalTrialSet() { return new CSignalTrialSet(); }
void releaseSignalTrialSet(ISignalTrialSet* signalTrialSet) { delete signalTrialSet; }
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,26 @@
#pragma once
#include "ovtkISignalTrialSet.h"
#include <vector>
namespace OpenViBE {
namespace Toolkit {
class CSignalTrialSet final : public ISignalTrialSet
{
public:
bool addSignalTrial(ISignalTrial& rSignalTrial) override;
bool clear() override;
size_t getSignalTrialCount() const override { return m_signalTrials.size(); }
ISignalTrial& getSignalTrial(const size_t index) const override { return *m_signalTrials[index]; }
_IsDerivedFromClass_Final_(ISignalTrialSet, OVTK_ClassId_)
protected:
mutable std::vector<ISignalTrial*> m_signalTrials;
};
extern OVTK_API ISignalTrialSet* createSignalTrialSet();
} // namespace Toolkit
} // namespace OpenViBE
@@ -0,0 +1,127 @@
#include "ovtkISignalTrial.h"
namespace OpenViBE {
namespace Toolkit {
ISignalTrial& copyHeader(ISignalTrial& trial, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
if (srcTrial != &trial)
{
const size_t nChannel = srcTrial->getChannelCount();
trial.setChannelCount(nChannel);
for (size_t i = 0; i < nChannel; ++i) { trial.setChannelName(i, srcTrial->getChannelName(i)); }
trial.setSamplingRate(srcTrial->getSamplingRate());
}
return trial;
}
ISignalTrial& copy(ISignalTrial& trial, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
// copyHeader(trial, srcTrial);
if (srcTrial != &trial)
{
const size_t nChannel = srcTrial->getChannelCount();
const size_t nSample = srcTrial->getSampleCount();
trial.setSampleCount(nSample, false);
for (size_t i = 0; i < nChannel; ++i) { memcpy(trial.getChannelSampleBuffer(i), srcTrial->getChannelSampleBuffer(i), nSample * sizeof(double)); }
}
return trial;
}
ISignalTrial& selectSamples(ISignalTrial& trial, const size_t sampleStart, const size_t sampleEnd, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
if (srcTrial == &trial) { return trial; } // $$$ NOT YET IMPLEMENTED
// copyHeader(trial, srcTrial);
const size_t nChannel = srcTrial->getChannelCount();
const size_t nSample = sampleEnd - sampleStart;
trial.setSampleCount(nSample, false);
for (size_t i = 0; i < nChannel; ++i)
{
memcpy(trial.getChannelSampleBuffer(i), srcTrial->getChannelSampleBuffer(i) + sampleStart, nSample * sizeof(double));
}
return trial;
}
ISignalTrial& selectTime(ISignalTrial& trial, const uint64_t timeStart, const uint64_t timeEnd, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
if (srcTrial == &trial) { return trial; } // $$$ NOT YET IMPLEMENTED
const size_t sampleStart = size_t((timeStart * srcTrial->getSamplingRate()) >> 32);
const size_t sampleEnd = size_t((timeEnd * srcTrial->getSamplingRate()) >> 32);
return selectSamples(trial, sampleStart, sampleEnd, srcTrial);
}
ISignalTrial& removeSamples(ISignalTrial& trial, const size_t sampleStart, const size_t sampleEnd, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
if (srcTrial == &trial) { return trial; } // $$$ NOT YET IMPLEMENTED
// copyHeader(trial, srcTrial);
const size_t srcNChannel = srcTrial->getChannelCount();
const size_t srcNSample = srcTrial->getSampleCount() - (sampleEnd - sampleStart);
trial.setSampleCount(srcNSample, false);
for (size_t i = 0; i < srcNChannel; ++i)
{
memcpy(trial.getChannelSampleBuffer(i), srcTrial->getChannelSampleBuffer(i), sampleStart * sizeof(double));
memcpy(trial.getChannelSampleBuffer(i) + sampleStart, srcTrial->getChannelSampleBuffer(i) + sampleEnd, (srcNSample - sampleStart) * sizeof(double));
}
return trial;
}
ISignalTrial& removeTime(ISignalTrial& trial, const uint64_t timeStart, const uint64_t timeEnd, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
if (srcTrial == &trial) { return trial; } // $$$ NOT YET IMPLEMENTED
const size_t sampleStart = size_t((timeStart * srcTrial->getSamplingRate()) >> 32);
const size_t sampleEnd = size_t((timeEnd * srcTrial->getSamplingRate()) >> 32);
return removeSamples(trial, sampleStart, sampleEnd, srcTrial);
}
ISignalTrial& insertBufferSamples(ISignalTrial& trial, const size_t sampleStart, const size_t nSample, const double* buffer, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
// copyHeader(trial, srcTrial);
const size_t srcNChannel = srcTrial->getChannelCount();
const size_t srcNSample = srcTrial->getSampleCount();
trial.setSampleCount(srcNSample + nSample, true);
for (size_t i = 0; i < srcNChannel; ++i)
{
if (&trial != srcTrial) { memcpy(trial.getChannelSampleBuffer(i), srcTrial->getChannelSampleBuffer(i), sampleStart * sizeof(double)); }
memcpy(trial.getChannelSampleBuffer(i) + sampleStart + nSample, srcTrial->getChannelSampleBuffer(i), (srcNSample - sampleStart) * sizeof(double));
memcpy(trial.getChannelSampleBuffer(i) + sampleStart, buffer + nSample * i, nSample * sizeof(double));
}
return trial;
}
ISignalTrial& insertBufferTime(ISignalTrial& trial, const uint64_t timeStart, const size_t nSample, const double* buffer, const ISignalTrial* srcTrial)
{
if (srcTrial == nullptr) { srcTrial = &trial; }
const size_t sampleStart = size_t((timeStart * srcTrial->getSamplingRate()) >> 32);
return insertBufferSamples(trial, sampleStart, nSample, buffer, srcTrial);
}
} // namespace Toolkit
} // namespace OpenViBE