diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ba46044aecdeaa959f036abadd8e77496e7a4bc..e5cf35b32fa48b1a54500f791a5f54f494288602 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,7 +255,7 @@ ENDIF() # add the scripts to the project so IDEs using the CMake file are aware of them FILE(GLOB_RECURSE script_files scripts/*.cmd scripts/*.sh scripts/*.nsi scripts/*.cmake) -CONFIGURE_FILE(scripts/AddCertivibeComponents.cmake ${DIST_DATADIR} COPYONLY) +INSTALL(FILES scripts/AddCertivibeComponents.cmake DESTINATION ${DIST_DATADIR}) ADD_CUSTOM_TARGET(openvibe-scripts SOURCES ${script_files}) # Enable/Disable unit test diff --git a/kernel/src/kernel/configuration/ovkCConfigurationManager.cpp b/kernel/src/kernel/configuration/ovkCConfigurationManager.cpp index 43b5cf6048fa09c0f6124b83ca088491fb390fc2..649e1a03ff07161593eb4cde4b407b8a3794980e 100755 --- a/kernel/src/kernel/configuration/ovkCConfigurationManager.cpp +++ b/kernel/src/kernel/configuration/ovkCConfigurationManager.cpp @@ -77,7 +77,7 @@ namespace OpenViBE return sValue.substr(i, j-i+1); } - virtual FS::boolean callback( + virtual bool callback( FS::IEntryEnumerator::IEntry& rEntry, FS::IEntryEnumerator::IAttributes& rAttributes) { @@ -192,13 +192,13 @@ void CConfigurationManager::clear(void) m_vConfigurationToken.clear(); } -OpenViBE::boolean CConfigurationManager::addConfigurationFromFile( +bool CConfigurationManager::addConfigurationFromFile( const CString& rFileNameWildCard) { this->getLogManager() << LogLevel_Trace << "Adding configuration file(s) [" << rFileNameWildCard << "]\n"; - boolean l_bResult; + bool l_bResult; CConfigurationManagerEntryEnumeratorCallBack l_rCB(getKernelContext().getLogManager(), getKernelContext().getErrorManager(), *this); FS::IEntryEnumerator* l_pEntryEnumerator=FS::createEntryEnumerator(l_rCB); l_bResult=l_pEntryEnumerator->enumerate(rFileNameWildCard); @@ -225,7 +225,7 @@ CIdentifier CConfigurationManager::createConfigurationToken( return l_oIdentifier; } -OpenViBE::boolean CConfigurationManager::releaseConfigurationToken( +bool CConfigurationManager::releaseConfigurationToken( const CIdentifier& rConfigurationTokenIdentifier) { std::map < CIdentifier, SConfigurationToken >::iterator itConfigurationToken=m_vConfigurationToken.find(rConfigurationTokenIdentifier); @@ -288,7 +288,7 @@ CString CConfigurationManager::getConfigurationTokenValue( // ---------------------------------------------------------------------------------------------------------------------------- -OpenViBE::boolean CConfigurationManager::setConfigurationTokenName( +bool CConfigurationManager::setConfigurationTokenName( const CIdentifier& rConfigurationTokenIdentifier, const CString& rConfigurationTokenName) { @@ -310,7 +310,7 @@ OpenViBE::boolean CConfigurationManager::setConfigurationTokenName( return true; } -OpenViBE::boolean CConfigurationManager::setConfigurationTokenValue( +bool CConfigurationManager::setConfigurationTokenValue( const CIdentifier& rConfigurationTokenIdentifier, const CString& rConfigurationTokenValue) { @@ -326,7 +326,7 @@ OpenViBE::boolean CConfigurationManager::setConfigurationTokenValue( return true; } -OpenViBE::boolean CConfigurationManager::addOrReplaceConfigurationToken( +bool CConfigurationManager::addOrReplaceConfigurationToken( const CString& rConfigurationTokenName, const CString& rConfigurationTokenValue) { @@ -345,7 +345,7 @@ OpenViBE::boolean CConfigurationManager::addOrReplaceConfigurationToken( CIdentifier CConfigurationManager::lookUpConfigurationTokenIdentifier( const CString& rConfigurationTokenName, - const OpenViBE::boolean bRecursive) const + const bool bRecursive) const { std::map < CIdentifier, SConfigurationToken >::const_iterator itConfigurationToken=m_vConfigurationToken.begin(); while(itConfigurationToken!=m_vConfigurationToken.end()) @@ -384,7 +384,7 @@ CString CConfigurationManager::lookUpConfigurationTokenValue( // ---------------------------------------------------------------------------------------------------------------------------- -OpenViBE::boolean CConfigurationManager::registerKeywordParser(const OpenViBE::CString& rKeyword, const IConfigurationKeywordExpandCallback& rCallback) +bool CConfigurationManager::registerKeywordParser(const OpenViBE::CString& rKeyword, const IConfigurationKeywordExpandCallback& rCallback) { OV_ERROR_UNLESS_KRF( rKeyword != CString("") && rKeyword != CString("core") && rKeyword != CString("environment"), @@ -397,7 +397,7 @@ OpenViBE::boolean CConfigurationManager::registerKeywordParser(const OpenViBE::C return true; } -OpenViBE::boolean CConfigurationManager::unregisterKeywordParser(const OpenViBE::CString& rKeyword) +bool CConfigurationManager::unregisterKeywordParser(const OpenViBE::CString& rKeyword) { OV_ERROR_UNLESS_KRF( m_vKeywordOverride.count(rKeyword), @@ -410,7 +410,7 @@ OpenViBE::boolean CConfigurationManager::unregisterKeywordParser(const OpenViBE: return true; } -OpenViBE::boolean CConfigurationManager::unregisterKeywordParser(const IConfigurationKeywordExpandCallback& rCallback) +bool CConfigurationManager::unregisterKeywordParser(const IConfigurationKeywordExpandCallback& rCallback) { std::map < OpenViBE::CString, const OpenViBE::Kernel::IConfigurationKeywordExpandCallback*>::iterator l_itOverrideIterator = m_vKeywordOverride.begin(); @@ -453,7 +453,7 @@ CString CConfigurationManager::expand( CIdentifier CConfigurationManager::getUnusedIdentifier(void) const { - uint64 l_ui64Identifier=(((uint64)rand())<<32)+((uint64)rand()); + uint64_t l_ui64Identifier=(((uint64_t)rand())<<32)+((uint64_t)rand()); CIdentifier l_oResult; std::map < CIdentifier, SConfigurationToken >::const_iterator i; do @@ -478,7 +478,7 @@ namespace }; }; -OpenViBE::boolean CConfigurationManager::internalExpand(const std::string& sValue, std::string& sResult) const +bool CConfigurationManager::internalExpand(const std::string& sValue, std::string& sResult) const { std::stack < std::pair < ENodeType, std::string > > l_vChildren; l_vChildren.push(std::make_pair(NodeType_Value, std::string())); @@ -492,7 +492,7 @@ OpenViBE::boolean CConfigurationManager::internalExpand(const std::string& sValu for(std::string::size_type i=0; i<sValue.length(); i++) { - boolean l_bShouldExpand; + bool l_bShouldExpand; switch(sValue[i]) { @@ -515,19 +515,18 @@ OpenViBE::boolean CConfigurationManager::internalExpand(const std::string& sValu "Could not expand token with syntax error while expanding " << CString(sValue.c_str()), ErrorType::BadFileParsing ); - l_sPostfix=l_vChildren.top().second; + l_sPostfix = l_vChildren.top().second; + l_sLowerPostfix.resize(l_sPostfix.size()); + std::transform(l_sPostfix.begin(), l_sPostfix.end(), l_sLowerPostfix.begin(), ::to_lower<std::string::value_type>); l_vChildren.pop(); - l_sPrefix=l_vChildren.top().second; + l_sPrefix = l_vChildren.top().second; + l_sLowerPrefix.resize(l_sPrefix.size()); + std::transform(l_sPrefix.begin(), l_sPrefix.end(), l_sLowerPrefix.begin(), ::to_lower<std::string::value_type>); l_vChildren.pop(); l_bShouldExpand=true; - l_sLowerPrefix=l_sPrefix; - l_sLowerPostfix=l_sPostfix; - std::transform(l_sLowerPrefix.begin(), l_sLowerPrefix.end(), l_sLowerPrefix.begin(), ::to_lower<std::string::value_type>); - std::transform(l_sLowerPostfix.begin(), l_sLowerPostfix.end(), l_sLowerPostfix.begin(), ::to_lower<std::string::value_type>); - if(l_sLowerPrefix=="") { // l_sValue=this->getConfigurationTokenValue(this->lookUpConfigurationTokenIdentifier(l_sPostfix.c_str())); @@ -647,6 +646,22 @@ OpenViBE::boolean CConfigurationManager::internalExpand(const std::string& sValu } } + /* This will merge all NamePrefix Node on top of the pile into the first which isn't. + * In case of handling an UNC path, pile should look like this, eventually with multiple NodeType_NamePrefix : + * NodeType_NamePrefix, value2 + * NodeType_Value, value1 + * + * This will merge all of them into the Node below, like this : + * NodeType_Value, value1 + '$' + value2 + ( '$' + value3 ...) + * Using this method, tokens are not reinterpreted, which reduce risks introduced by introducing parser leniency. + */ + while(l_vChildren.top().first == NodeType_NamePrefix && l_vChildren.size() > 1) + { + const std::string topVal = l_vChildren.top().second; + l_vChildren.pop(); + l_vChildren.top().second += "$" + topVal; + } + OV_ERROR_UNLESS_KRF( l_vChildren.size() == 1, "Could not expand token with unterminated string while expanding " << CString(sValue.c_str()), @@ -658,7 +673,7 @@ OpenViBE::boolean CConfigurationManager::internalExpand(const std::string& sValu return true; } -OpenViBE::boolean CConfigurationManager::internalExpandOnlyKeyword(const std::string& sKeyword, const std::string& sValue, std::string& sResult) const +bool CConfigurationManager::internalExpandOnlyKeyword(const std::string& sKeyword, const std::string& sValue, std::string& sResult) const { std::stack < std::pair < ENodeType, std::string > > l_vChildren; l_vChildren.push(std::make_pair(NodeType_Value, std::string())); @@ -672,7 +687,7 @@ OpenViBE::boolean CConfigurationManager::internalExpandOnlyKeyword(const std::st for(std::string::size_type i=0; i<sValue.length(); i++) { - boolean l_bShouldExpand; + bool l_bShouldExpand; switch(sValue[i]) { @@ -709,52 +724,6 @@ OpenViBE::boolean CConfigurationManager::internalExpandOnlyKeyword(const std::st std::transform(l_sLowerPrefix.begin(), l_sLowerPrefix.end(), l_sLowerPrefix.begin(), ::to_lower<std::string::value_type>); std::transform(l_sLowerPostfix.begin(), l_sLowerPostfix.end(), l_sLowerPostfix.begin(), ::to_lower<std::string::value_type>); - - /* - else if(l_sLowerPrefix=="environment" || l_sLowerPrefix=="env") - { - char* l_sEnvValue=::getenv(l_sPostfix.c_str()); - l_sValue=(l_sEnvValue?l_sEnvValue:""); - l_bShouldExpand=false; - } - else if(l_sLowerPrefix=="core") - { - char l_sLocalValue[1024]; - if(l_sLowerPostfix=="random") - { - sprintf(l_sLocalValue, "%u", this->getRandom()); - l_sValue=l_sLocalValue; - } - else if(l_sLowerPostfix=="index") - { - sprintf(l_sLocalValue, "%u", this->getIndex()); - l_sValue=l_sLocalValue; - } - else if(l_sLowerPostfix=="time") - { - l_sValue=this->getTime(); - } - else if(l_sLowerPostfix=="date") - { - l_sValue=this->getDate(); - } - else if(l_sLowerPostfix=="real-time") - { - sprintf(l_sLocalValue, "%u", this->getRealTime()); - l_sValue=l_sLocalValue; - } - else if(l_sLowerPostfix=="process-id") - { - sprintf(l_sLocalValue, "%u", this->getProcessId()); - l_sValue=l_sLocalValue; - } - else - { - this->getLogManager() << LogLevel_Warning << "Could not expand token with " << CString(l_sPrefix.c_str()) << " prefix and " << CString(l_sPostfix.c_str()) << " postfix while expanding " << CString(sValue.c_str()) << "\n"; - return false; - } - } - else*/ if (l_sLowerPrefix == sKeyword) { OV_ERROR_UNLESS_KRF( @@ -821,7 +790,7 @@ OpenViBE::boolean CConfigurationManager::internalExpandOnlyKeyword(const std::st return true; } -OpenViBE::boolean CConfigurationManager::internalGetConfigurationTokenValueFromName(const std::string& sTokenName, std::string& sTokenValue) const +bool CConfigurationManager::internalGetConfigurationTokenValueFromName(const std::string& sTokenName, std::string& sTokenValue) const { CIdentifier l_oTokenIdentifier=this->lookUpConfigurationTokenIdentifier(sTokenName.c_str(), false); if(l_oTokenIdentifier == OV_UndefinedIdentifier) @@ -874,12 +843,12 @@ float64 CConfigurationManager::expandAsFloat( return l_f64Result; } -int64 CConfigurationManager::expandAsInteger( +int64_t CConfigurationManager::expandAsInteger( const CString& rExpression, - const int64 i64FallbackValue) const + const int64_t i64FallbackValue) const { CString l_sResult=this->expand(rExpression); - int64 l_i64Result; + int64_t l_i64Result; try { @@ -893,12 +862,12 @@ int64 CConfigurationManager::expandAsInteger( return l_i64Result; } -uint64 CConfigurationManager::expandAsUInteger( +uint64_t CConfigurationManager::expandAsUInteger( const CString& rExpression, - const uint64 ui64FallbackValue) const + const uint64_t ui64FallbackValue) const { CString l_sResult=this->expand(rExpression); - uint64 l_ui64Result; + uint64_t l_ui64Result; try { @@ -912,9 +881,9 @@ uint64 CConfigurationManager::expandAsUInteger( return l_ui64Result; } -OpenViBE::boolean CConfigurationManager::expandAsBoolean( +bool CConfigurationManager::expandAsBoolean( const CString& rExpression, - const OpenViBE::boolean bFallbackValue) const + const bool bFallbackValue) const { std::string l_sResult=this->expand(rExpression).toASCIIString(); std::transform(l_sResult.begin(), l_sResult.end(), l_sResult.begin(), ::to_lower<std::string::value_type>); @@ -930,13 +899,13 @@ OpenViBE::boolean CConfigurationManager::expandAsBoolean( return bFallbackValue; } -uint64 CConfigurationManager::expandAsEnumerationEntryValue( +uint64_t CConfigurationManager::expandAsEnumerationEntryValue( const CString& rExpression, const CIdentifier& rEnumerationTypeIdentifier, - const uint64 ui64FallbackValue) const + const uint64_t ui64FallbackValue) const { CString l_sResult=this->expand(rExpression); - uint64 l_ui64Result=this->getTypeManager().getEnumerationEntryValueFromName(rEnumerationTypeIdentifier, l_sResult); + uint64_t l_ui64Result=this->getTypeManager().getEnumerationEntryValueFromName(rEnumerationTypeIdentifier, l_sResult); if(l_ui64Result!=0xffffffffffffffffll) { return l_ui64Result; @@ -945,12 +914,12 @@ uint64 CConfigurationManager::expandAsEnumerationEntryValue( return ui64FallbackValue; } -uint32 CConfigurationManager::getRandom(void) const +uint32_t CConfigurationManager::getRandom(void) const { return System::Math::randomUInteger32(); } -uint32 CConfigurationManager::getIndex(void) const +uint32_t CConfigurationManager::getIndex(void) const { return m_ui32Index++; } @@ -981,17 +950,17 @@ CString CConfigurationManager::getDate(void) const return l_sResult; } -uint32 CConfigurationManager::getRealTime(void) const +uint32_t CConfigurationManager::getRealTime(void) const { return System::Time::getTime()-m_ui32StartTime; } -uint32 CConfigurationManager::getProcessId(void) const +uint32_t CConfigurationManager::getProcessId(void) const { #if defined TARGET_OS_Linux || defined TARGET_OS_MacOS - return (uint32)getpid(); + return (uint32_t)getpid(); #elif defined TARGET_OS_Windows - return (uint32)GetCurrentProcessId(); + return (uint32_t)GetCurrentProcessId(); #else #error TODO #endif diff --git a/kernel/src/kernel/configuration/ovkCConfigurationManager.h b/kernel/src/kernel/configuration/ovkCConfigurationManager.h old mode 100644 new mode 100755 index 851e1761afefd675a35a5d44f0effeaa23db6776..029c9aa98a6dc7143937a364c09e0bb821d599da --- a/kernel/src/kernel/configuration/ovkCConfigurationManager.h +++ b/kernel/src/kernel/configuration/ovkCConfigurationManager.h @@ -26,13 +26,13 @@ namespace OpenViBE virtual void clear(void); - virtual OpenViBE::boolean addConfigurationFromFile( + virtual bool addConfigurationFromFile( const OpenViBE::CString& rFileNameWildCard); virtual OpenViBE::CIdentifier createConfigurationToken( const OpenViBE::CString& rConfigurationTokenName, const OpenViBE::CString& rConfigurationTokenValue); - virtual OpenViBE::boolean releaseConfigurationToken( + virtual bool releaseConfigurationToken( const OpenViBE::CIdentifier& rConfigurationTokenIdentifier); virtual OpenViBE::CIdentifier getNextConfigurationTokenIdentifier( const OpenViBE::CIdentifier& rPreviousConfigurationTokenIdentifier) const; @@ -42,30 +42,30 @@ namespace OpenViBE virtual OpenViBE::CString getConfigurationTokenValue( const OpenViBE::CIdentifier& rConfigurationTokenIdentifier) const; - virtual OpenViBE::boolean setConfigurationTokenName( + virtual bool setConfigurationTokenName( const OpenViBE::CIdentifier& rConfigurationTokenIdentifier, const OpenViBE::CString& rConfigurationTokenName); - virtual OpenViBE::boolean setConfigurationTokenValue( + virtual bool setConfigurationTokenValue( const OpenViBE::CIdentifier& rConfigurationTokenIdentifier, const OpenViBE::CString& rConfigurationTokenValue); - virtual OpenViBE::boolean addOrReplaceConfigurationToken( + virtual bool addOrReplaceConfigurationToken( const OpenViBE::CString& rConfigurationTokenName, const OpenViBE::CString& rConfigurationTokenValue); virtual OpenViBE::CIdentifier lookUpConfigurationTokenIdentifier( const OpenViBE::CString& rConfigurationTokenName, - const OpenViBE::boolean bRecursive) const; + const bool bRecursive) const; virtual OpenViBE::CString lookUpConfigurationTokenValue( const OpenViBE::CString& rConfigurationTokenName) const; - virtual OpenViBE::boolean registerKeywordParser( + virtual bool registerKeywordParser( const OpenViBE::CString& rKeyword, const IConfigurationKeywordExpandCallback& rCallback); - virtual OpenViBE::boolean unregisterKeywordParser( + virtual bool unregisterKeywordParser( const OpenViBE::CString& rKeyword); - virtual OpenViBE::boolean unregisterKeywordParser( + virtual bool unregisterKeywordParser( const IConfigurationKeywordExpandCallback& rCallback); virtual OpenViBE::CString expand( @@ -79,27 +79,27 @@ namespace OpenViBE virtual OpenViBE::float64 expandAsFloat( const OpenViBE::CString& rExpression, const OpenViBE::float64 f64FallbackValue) const; - virtual OpenViBE::int64 expandAsInteger( + virtual int64_t expandAsInteger( const OpenViBE::CString& rExpression, - const OpenViBE::int64 i64FallbackValue) const; - virtual OpenViBE::uint64 expandAsUInteger( + const int64_t i64FallbackValue) const; + virtual uint64_t expandAsUInteger( const OpenViBE::CString& rExpression, - const OpenViBE::uint64 ui64FallbackValue) const; - virtual OpenViBE::boolean expandAsBoolean( + const uint64_t ui64FallbackValue) const; + virtual bool expandAsBoolean( const OpenViBE::CString& rExpression, - const OpenViBE::boolean bFallbackValue) const; - virtual OpenViBE::uint64 expandAsEnumerationEntryValue( + const bool bFallbackValue) const; + virtual uint64_t expandAsEnumerationEntryValue( const OpenViBE::CString& rExpression, const OpenViBE::CIdentifier& rEnumerationTypeIdentifier, - const OpenViBE::uint64 ui64FallbackValue) const; + const uint64_t ui64FallbackValue) const; protected: virtual OpenViBE::CIdentifier getUnusedIdentifier(void) const; - OpenViBE::boolean internalExpand(const std::string& sValue, std::string& sResult) const; - OpenViBE::boolean internalExpandOnlyKeyword(const std::string& sKeyword, const std::string& sValue, std::string& sResult) const; - OpenViBE::boolean internalGetConfigurationTokenValueFromName(const std::string& sTokenName, std::string& sTokenValue) const; + bool internalExpand(const std::string& sValue, std::string& sResult) const; + bool internalExpandOnlyKeyword(const std::string& sKeyword, const std::string& sValue, std::string& sResult) const; + bool internalGetConfigurationTokenValueFromName(const std::string& sTokenName, std::string& sTokenValue) const; protected: @@ -107,15 +107,15 @@ namespace OpenViBE protected: - mutable OpenViBE::uint32 m_ui32Index; - mutable OpenViBE::uint32 m_ui32StartTime; + mutable uint32_t m_ui32Index; + mutable uint32_t m_ui32StartTime; - OpenViBE::uint32 getRandom(void) const; - OpenViBE::uint32 getIndex(void) const; + uint32_t getRandom(void) const; + uint32_t getIndex(void) const; OpenViBE::CString getTime(void) const; OpenViBE::CString getDate(void) const; - OpenViBE::uint32 getRealTime(void) const; - OpenViBE::uint32 getProcessId(void) const; + uint32_t getRealTime(void) const; + uint32_t getProcessId(void) const; protected: diff --git a/toolkit/CMakeLists.txt b/toolkit/CMakeLists.txt index 6d9a0e51c2a7389e43aa072b80dddcdbf0246c5a..fd570ec5d4581241d125591e9bc4bf66ab68e4d9 100644 --- a/toolkit/CMakeLists.txt +++ b/toolkit/CMakeLists.txt @@ -66,7 +66,6 @@ INCLUDE("FindOpenViBEModuleSystem") # --------------------------------- SET_BUILD_PLATFORM() - # ----------------------------- # Install files # ----------------------------- @@ -76,4 +75,5 @@ INSTALL(TARGETS ${PROJECT_NAME} ARCHIVE DESTINATION ${DIST_LIBDIR}) INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ ${CMAKE_CURRENT_BINARY_DIR}/include/ DESTINATION ${DIST_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE) +INSTALL(DIRECTORY share/ DESTINATION ${DIST_DATADIR}/openvibe/toolkit PATTERN ".svn" EXCLUDE PATTERN "*-base" EXCLUDE)