Commit 8160dcd8 authored by Jussi Lindgren's avatar Jussi Lindgren

Modules: Removed unused modules Automation and Stream

parent 07adf448
# ---------------------------------
# Finds module Automaton
# Adds library to target
# Adds include path
# ---------------------------------
OPTION(DYNAMIC_LINK_OPENVIBE_MODULE_AUTOMATON "Dynamically link OpenViBE module Automaton" ON)
IF(DYNAMIC_LINK_OPENVIBE_MODULE_AUTOMATON)
SET(OPENVIBE_MODULE_AUTOMATON_LINKING "")
ELSE(DYNAMIC_LINK_OPENVIBE_MODULE_AUTOMATON)
SET(OPENVIBE_MODULE_AUTOMATON_LINKING "-static")
ENDIF(DYNAMIC_LINK_OPENVIBE_MODULE_AUTOMATON)
set(SRC_DIR ${OV_BASE_DIR}/modules/automaton/include)
FIND_PATH(PATH_OPENVIBE_MODULES_AUTOMATON automaton/defines.h PATHS ${SRC_DIR} NO_DEFAULT_PATH)
IF(PATH_OPENVIBE_MODULES_AUTOMATON)
MESSAGE(STATUS " Found OpenViBE module Automaton...")
INCLUDE_DIRECTORIES(${PATH_OPENVIBE_MODULES_AUTOMATON}/)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} openvibe-module-automaton${OPENVIBE_MODULE_AUTOMATON_LINKING})
ADD_DEFINITIONS(-DTARGET_HAS_Automaton)
ELSE(PATH_OPENVIBE_MODULES_AUTOMATON)
MESSAGE(STATUS " FAILED to find OpenViBE module Automaton...")
ENDIF(PATH_OPENVIBE_MODULES_AUTOMATON)
PROJECT(openvibe-module-automaton)
SET(PROJECT_VERSION_MAJOR ${OV_GLOBAL_VERSION_MAJOR})
SET(PROJECT_VERSION_MINOR ${OV_GLOBAL_VERSION_MINOR})
SET(PROJECT_VERSION_PATCH ${OV_GLOBAL_VERSION_PATCH})
SET(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
FILE(GLOB_RECURSE source_files src/*.cpp src/*.h src/*.inl src/*.hpp include/*.h)
INCLUDE_DIRECTORIES(include/automaton)
ADD_LIBRARY(${PROJECT_NAME} SHARED ${source_files})
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
COMPILE_FLAGS "-DOV_Shared -DOV_Exports")
INCLUDE("FindOpenViBE")
INCLUDE("FindOpenViBECommon")
INCLUDE("FindOpenViBEModuleXML")
# ---------------------------------
# Test applications
# ---------------------------------
OPTION(BUILD_OPENVIBE_MODULE_Automaton_EXAMPLES "Build OpenViBE module Automaton examples" OFF)
IF(BUILD_OPENVIBE_MODULE_Automaton_EXAMPLES)
SUBDIRS(test)
ENDIF(BUILD_OPENVIBE_MODULE_Automaton_EXAMPLES)
# ---------------------------------
# Target macros
# Defines target operating system
# Defines target architecture
# Defines target compiler
# ---------------------------------
IF(WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-DTARGET_OS_Windows)
ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386)
ADD_DEFINITIONS(-DTARGET_COMPILER_VisualStudio)
ENDIF(WIN32)
IF(UNIX)
# ADD_DEFINITIONS(-fvisibility=hidden) # This flag should be present... man gcc
ADD_DEFINITIONS(-g)
ADD_DEFINITIONS(-fnon-call-exceptions)
ADD_DEFINITIONS(-DTARGET_OS_Linux)
ADD_DEFINITIONS(-DTARGET_ARCHITECTURE_i386)
ADD_DEFINITIONS(-DTARGET_COMPILER_GCC)
ENDIF(UNIX)
# -----------------------------
# Install files
# -----------------------------
INSTALL(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
INSTALL(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE)
/**
* \file CIdentifier.h
* \author Yann Renard (INRIA/IRISA)
* \date 2006-08-07
* \brief Automaton::CIdentifier class definition
*/
#ifndef __Automaton_CIdentifier_H__
#define __Automaton_CIdentifier_H__
#include "defines.h"
namespace Automaton
{
/**
* \class CIdentifier
* \author Yann Renard (INRIA/IRISA)
* \date 2006-08-07
* \brief Base class to work with Automaton identifiers
*
* This class is used in order to work on Automaton identifier.
* It handles 64 bits values for now, but could easily be
* changed to handle bigger values if needed.
*
*/
class OV_API CIdentifier
{
public:
/** \name Constructors */
//@{
/**
* \brief Basic constructor
*
* Initializes the identifier to 0.
*/
CIdentifier(void);
/**
* \brief Integer based constructor
* \param ui64Identifier [in] : The value to use
*
* Initializes the identifier to the given 64 bits value.
*/
CIdentifier(const Automaton::uint64 ui64Identifier);
/**
* \brief 32 bits integer based constructor
* \param ui32Identifier1 [in] : the first part of the identifier
* \param ui32Identifier2 [in] : the second part of the identifier
*
* Builds up the 64 bits identifier given its two 32 bits
* components.
*/
CIdentifier(const Automaton::uint32 ui32Identifier1, const Automaton::uint32 ui32Identifier2);
/**
* \brief Copy constructor
* \param rIdentifier [in] : The source identifier to use
*
* Initializes this identifier to the same value as
* the given source identifier.
*/
CIdentifier(const Automaton::CIdentifier& rIdentifier);
//@}
/** \name Operators */
//@{
/**
* \brief Copy operator
* \param rIdentifier [in] : The source identifier to copy from
* \return a const reference on this identifier
*
* Initializes this identifier to the same value as
* the given source identifier.
*/
const Automaton::CIdentifier& operator=(const Automaton::CIdentifier& rIdentifier);
/**
* \brief Equality comparison operator
* \param rIdentifier1 [in] : The first identifier to compare
* \param rIdentifier2 [in] : The second identifier to compare
* \return \e true when the identifiers are equal, \e false
* when they are different.
*
* This function compares the two 64 bits values.
*/
friend OV_API bool operator==(const Automaton::CIdentifier& rIdentifier1, const Automaton::CIdentifier& rIdentifier2);
/**
* \brief Difference comparison operator
* \param rIdentifier1 [in] : The first identifier to compare
* \param rIdentifier2 [in] : The second identifier to compare
* \return \e true when the identifiers are different, \e false
* when they are equal.
*
* This function compares the two 64 bits values.
*/
friend OV_API bool operator!=(const Automaton::CIdentifier& rIdentifier1, const Automaton::CIdentifier& rIdentifier2);
/**
* \brief Ordering comparison operator
* \param rIdentifier1 [in] : The first identifier to compare
* \param rIdentifier2 [in] : The second identifier to compare
* \return \e true when the first identifier is lesser or equal
* to the second identifier, \e false in other cases.
*
* This function compares the two 64 bits values.
*/
friend OV_API bool operator<=(const Automaton::CIdentifier& rIdentifier1, const Automaton::CIdentifier& rIdentifier2);
/**
* \brief Ordering comparison operator
* \param rIdentifier1 [in] : The first identifier to compare
* \param rIdentifier2 [in] : The second identifier to compare
* \return \e true when the first identifier is greater or equal
* to the second identifier, \e false in other cases.
*
* This function compares the two 64 bits values.
*/
friend OV_API bool operator>=(const Automaton::CIdentifier& rIdentifier1, const Automaton::CIdentifier& rIdentifier2);
/**
* \brief Ordering comparison operator
* \param rIdentifier1 [in] : The first identifier to compare
* \param rIdentifier2 [in] : The second identifier to compare
* \return \e true when the first identifier is lesser and not equal
* to the second identifier, \e false in other cases.
*
* This function compares the two 64 bits values.
*/
friend OV_API bool operator<(const Automaton::CIdentifier& rIdentifier1, const Automaton::CIdentifier& rIdentifier2);
/**
* \brief Ordering comparison operator
* \param rIdentifier1 [in] : The first identifier to compare
* \param rIdentifier2 [in] : The second identifier to compare
* \return \e true when the first identifier is greater and not equal
* to the second identifier, \e false in other cases.
*
* This function compares the two 64 bits values.
*/
friend OV_API bool operator>(const Automaton::CIdentifier& rIdentifier1, const Automaton::CIdentifier& rIdentifier2);
/**
* \brief Cast operator
* \return \e the 64 bits value contained by this identifier.
*/
operator Automaton::uint64(void) const;
//@}
protected:
Automaton::uint64 m_ui64Identifier; ///< The 64 bits value of this identifier
};
};
#endif // __Automaton_CIdentifier_H__
#ifndef __Automaton_IAutomatonContext_H__
#define __Automaton_IAutomatonContext_H__
#include "CIdentifier.h"
#include "defines.h"
#include "INode.h"
#include <vector>
#include <string>
namespace Automaton
{
class INode;
class OV_API IAutomatonContext
{
public:
/**
* Gets A node object's pointer from its identifier.
* \param oIdentifier The identifier of the node.
* \return A pointer to this node.
*/
virtual INode * getNode(const CIdentifier& oIdentifier) = 0;
virtual INode * getInitialNode() = 0;
/**
* Adds a new node to the Automaton context.
* \param pNode A pointer to the node to add.
* \return The identifier associated with this node.
*/
virtual CIdentifier addNode(INode* pNode) = 0;
/**
* Adds a node to the successors of an other.
* \param The node to which we add a successor.
* \param The successor.
* \return True if the operation was successful.
*/
virtual boolean addSuccessor(CIdentifier oStart, CIdentifier oEnd) = 0;
/**
* Gets the list of events that were received by the automaton.
* \return The list of events that were received by the automaton
*/
virtual const CIdentifier * getReceivedEvents() = 0;
virtual Automaton::uint32 getReceivedEventsCount() = 0;
virtual void clearReceivedEvents() = 0;
/**
* Adds a new event to the list of received events.
* \param oIdentifier The identifier of the new event.
*/
virtual void addReceivedEvent(CIdentifier& oIdentifier) = 0;
virtual const CIdentifier * getSentEvents() = 0;
virtual Automaton::uint32 getSentEventsCount() = 0;
virtual void clearSentEvents() = 0;
/**
* Sends a new event to the external world.
* \param oIdentifier The identifier of the event sent.
*/
virtual void sendEvent(CIdentifier& oIdentifier) = 0;
/**
* Converts an XML node name to an identifier.
* \param oXMLNodeName The node's name.
* \return This node category's identifier.
*/
virtual CIdentifier getIdentifier(const std::string& oXMLNodeName) = 0;
virtual void setCurrentTime(Automaton::uint64 ui64Time) = 0;
virtual Automaton::uint64 getCurrentTime() = 0;
virtual CIdentifier addParameter(const char * pName, Automaton::uint64 ui64Value) = 0;
virtual CIdentifier getVariableIdentifier(const char * pName) = 0;
virtual const char* getParameterName(const CIdentifier& oIdentifier) = 0;
virtual Automaton::uint64 getParameterValue(const CIdentifier& oIdentifier) = 0;
virtual void release() = 0;
protected:
virtual ~IAutomatonContext(){ }
};
extern OV_API IAutomatonContext* createAutomatonContext();
extern OV_API void releaseAutomatonContext(IAutomatonContext* pContext);
};
#endif
#ifndef __Automaton_IAutomatonController_H__
#define __Automaton_IAutomatonController_H__
#include "defines.h"
#include "IAutomatonContext.h"
namespace Automaton
{
class OV_API IAutomatonController
{
public:
virtual Automaton::boolean process() = 0;
virtual IAutomatonContext* getAutomatonContext() = 0;
virtual void release() = 0;
protected:
virtual ~IAutomatonController(){ }
};
extern OV_API IAutomatonController* createAutomatonController(IAutomatonContext* pContext);
extern OV_API void releaseAutomatonController(IAutomatonController* pController);
};
#endif
#ifndef __Automaton_INode_H__
#define __Automaton_INode_H__
#include "CIdentifier.h"
#include "defines.h"
#include "IAutomatonContext.h"
namespace Automaton
{
class IAutomatonContext;
class OV_API INode
{
public:
virtual ~INode(){}
public:
virtual Automaton::boolean preProcess(Automaton::IAutomatonContext * pContext) = 0;
virtual Automaton::boolean postProcess(Automaton::IAutomatonContext * pContext) = 0;
virtual Automaton::boolean process(Automaton::IAutomatonContext * pContext) = 0;
virtual Automaton::CIdentifier getSuccessor(IAutomatonContext * pContext) = 0;
virtual void addSuccessor(CIdentifier oSuccessorIdentifier) = 0;
};
};
#endif
#ifndef __Automaton_INodeFactory_H__
#define __Automaton_INodeFactory_H__
#include "CIdentifier.h"
#include "INode.h"
namespace Automaton
{
class OV_API INodeFactory
{
public:
virtual INode * createNode(const CIdentifier& oIdentifier) = 0;
virtual void releaseNode(INode * pNode) = 0;
virtual void release() = 0;
protected:
virtual ~INodeFactory(){}
};
extern OV_API Automaton::INodeFactory* createNodeFactory();
extern OV_API void releaseNodeFactory(Automaton::INodeFactory* pFactory);
};
#endif
#ifndef __Automaton_IXMLAutomatonReader_H__
#define __Automaton_IXMLAutomatonReader_H__
#include "defines.h"
#include "IAutomatonContext.h"
#include "IAutomatonController.h"
namespace Automaton
{
class OV_API IXMLAutomatonReader
{
public:
virtual void release() = 0;
virtual Automaton::boolean processData(const void * pBuffer, const Automaton::uint64 ui64BufferSize) = 0;
virtual IAutomatonController* getAutomatonController() = 0;
protected:
virtual ~IXMLAutomatonReader() {}
};
extern OV_API IXMLAutomatonReader* createXMLAutomatonReader();
extern OV_API void releaseXMLAutomatonReader(IXMLAutomatonReader* pReader);
};
#endif
#ifndef __Automata_CXMLNodeReader_H__
#define __Automata_CXMLNodeReader_H__
#include "INode.h"
#include "IAutomatonContext.h"
#include "CIdentifier.h"
#include "xml/IReader.h"
namespace Automaton
{
enum EParsingStatus{
ParsingStatus_Nothing,
ParsingStatus_Automaton,
ParsingStatus_Variable,
ParsingStatus_Node,
ParsingStatus_Action,
ParsingStatus_Property,
ParsingStatus_Parameter,
ParsingStatus_Loop,
ParsingStatus_Child,
ParsingStatus_Switch,
ParsingStatus_Complete,
ParsingStatus_RandomOrder,
ParsingStatus_Error
};
class OV_API IXMLNodeReader
{
protected:
virtual ~IXMLNodeReader(){}
public:
virtual EParsingStatus openChild(const char* sName, const char** sAttributeName, const char** sAttributeValue, uint64 ui64AttributeCount, IAutomatonContext* pContext) = 0;
virtual EParsingStatus processChildData(const char* sData, IAutomatonContext* pContext) = 0;
virtual EParsingStatus closeChild(IAutomatonContext* pContext) = 0;
virtual CIdentifier getNodeIdentifier() = 0;
virtual void release() = 0;
};
};
#endif
#ifndef __Automaton_IXMLNodeReaderFactory_H__
#define __Automaton_IXMLNodeReaderFactory_H__
#include "CIdentifier.h"
#include "IXMLNodeReader.h"
namespace Automaton
{
class OV_API IXMLNodeReaderFactory
{
public:
virtual IXMLNodeReader * createNodeReader(const CIdentifier& oIdentifier) = 0;
virtual void releaseNodeReader(IXMLNodeReader * pReader) = 0;
virtual void release() = 0;
protected:
virtual ~IXMLNodeReaderFactory(){}
};
extern OV_API Automaton::IXMLNodeReaderFactory* createXMLNodeReaderFactory();
extern OV_API void releaseXMLNodeReaderFactory(Automaton::IXMLNodeReaderFactory* pFactory);
};
#endif
#ifndef __Automaton_Defines_H__
#define __Automaton_Defines_H__
#include <ov_common_defines.h>
#define OV_APPEND_TO_NAMESPACE Automaton
#include <ov_common_types.h>
#undef OV_APPEND_TO_NAMESPACE
//___________________________________________________________________//
// //
// Node type identifiers definitions //
//___________________________________________________________________//
// //
#define Automaton_Node_Identifier_Automaton Automaton::CIdentifier(0x00000000)
#define Automaton_Node_Identifier_No_Node Automaton::CIdentifier(0x00000001)
#define Automaton_Node_Identifier_Action Automaton::CIdentifier(0x00000010)
#define Automaton_Node_Identifier_ActionSendEvent Automaton::CIdentifier(0x00000011)
#define Automaton_Node_Identifier_ActionWaitEvent Automaton::CIdentifier(0x00000012)
#define Automaton_Node_Identifier_ActionWaitTime Automaton::CIdentifier(0x00000013)
#define Automaton_Node_Identifier_Loop Automaton::CIdentifier(0x00000021)
#define Automaton_Node_Identifier_LoopFinite Automaton::CIdentifier(0x00000022)
#define Automaton_Node_Identifier_LoopInfinite Automaton::CIdentifier(0x00000023)
#define Automaton_Node_Identifier_LoopWaitEvent Automaton::CIdentifier(0x00000024)
#define Automaton_Node_Identifier_Switch Automaton::CIdentifier(0x00000031)
#define Automaton_Node_Identifier_SwitchProbabilist Automaton::CIdentifier(0x00000032)
#define Automaton_Node_Identifier_SwitchEvent Automaton::CIdentifier(0x00000033)
#define Automaton_Node_Identifier_RandomOrder Automaton::CIdentifier(0x00000041)
#define Automaton_No_Successor Automaton::CIdentifier(0xFFFFFFFF)
#endif // __Automaton_Defines_H__
#include "CIdentifier.h"
using namespace Automaton;
CIdentifier::CIdentifier(void)
:m_ui64Identifier(0)
{
}
CIdentifier::CIdentifier(const uint64 ui64Identifier)
:m_ui64Identifier(ui64Identifier)
{
}
CIdentifier::CIdentifier(const uint32 ui32Identifier1, const uint32 ui32Identifier2)
{
m_ui64Identifier=(((uint64)ui32Identifier1)<<32)+ui32Identifier2;
}
CIdentifier::CIdentifier(const CIdentifier& rIdentifier)
:m_ui64Identifier(rIdentifier.m_ui64Identifier)
{
}
const CIdentifier& CIdentifier::operator=(const CIdentifier& rIdentifier)
{
m_ui64Identifier=rIdentifier.m_ui64Identifier;
return *this;
}
namespace Automaton
{
boolean operator==(const CIdentifier& rIdentifier1, const CIdentifier& rIdentifier2)
{
return rIdentifier1.m_ui64Identifier==rIdentifier2.m_ui64Identifier;
}
boolean operator!=(const CIdentifier& rIdentifier1, const CIdentifier& rIdentifier2)
{
return rIdentifier1.m_ui64Identifier!=rIdentifier2.m_ui64Identifier;
}
boolean operator<=(const CIdentifier& rIdentifier1, const CIdentifier& rIdentifier2)
{
return rIdentifier1.m_ui64Identifier<=rIdentifier2.m_ui64Identifier;
}
boolean operator>=(const CIdentifier& rIdentifier1, const CIdentifier& rIdentifier2)
{
return rIdentifier1.m_ui64Identifier>=rIdentifier2.m_ui64Identifier;
}
boolean operator<(const CIdentifier& rIdentifier1, const CIdentifier& rIdentifier2)
{
return rIdentifier1.m_ui64Identifier<rIdentifier2.m_ui64Identifier;
}
boolean operator>(const CIdentifier& rIdentifier1, const CIdentifier& rIdentifier2)
{
return rIdentifier1.m_ui64Identifier>rIdentifier2.m_ui64Identifier;
}
};
CIdentifier::operator uint64(void) const
{
return m_ui64Identifier;
}
#include "IAutomatonContext.h"
#include "INode.h"
#include "CIdentifier.h"
#include "defines.h"
#include <map>
#include <string>
#include <iostream>
using namespace Automaton;
using namespace std;
namespace Automaton
{
class CAutomatonContext : public IAutomatonContext
{
std::map<CIdentifier, INode*> m_oNodes;
std::vector<CIdentifier> m_oReceivedEvents;
std::vector<CIdentifier> m_oSentEvents;
std::map<std::string, CIdentifier> m_oXMLNodeToIdentifier;
Automaton::uint64 m_ui64CurrentTime;
std::map<CIdentifier, string> m_oParameterName;
std::map<CIdentifier, Automaton::uint64> m_oParameterValue;
public:
CAutomatonContext();
virtual ~CAutomatonContext();
virtual void release(){ delete this; }
virtual INode * getNode(const CIdentifier& oIdentifier);
virtual INode * getInitialNode();
virtual CIdentifier addNode(INode* pNode);
virtual boolean addSuccessor(CIdentifier oStart, CIdentifier oEnd);