From ef551cb937956e2c13570ab3f8f119c48fa5656e Mon Sep 17 00:00:00 2001 From: Stefan Radomski Date: Fri, 11 Oct 2013 22:25:39 +0200 Subject: Reactivated plugin system --- CMakeLists.txt | 24 +- apps/samples/put-that-there/put-that-there.scxml | 29 ++ .../ctest/hosts/buildslave-opensuse-12-32.ctest | 6 + .../ctest/hosts/buildslave-ubuntu-1204-32.ctest | 6 + contrib/ctest/tests/plugins.ctest | 2 + src/bindings/swig/java/CMakeLists.txt | 2 +- src/bindings/swig/php/uscxmlNativePHP.php | 18 + src/uscxml/CMakeLists.txt | 2 +- src/uscxml/interpreter/InterpreterDraft6.cpp | 5 + src/uscxml/plugins/datamodel/CMakeLists.txt | 26 +- src/uscxml/plugins/element/CMakeLists.txt | 10 +- src/uscxml/plugins/invoker/CMakeLists.txt | 96 +++--- .../invoker/graphics/openscenegraph/OSGInvoker.cpp | 365 +++++++++++++++++++-- .../invoker/graphics/openscenegraph/OSGInvoker.h | 41 ++- src/uscxml/plugins/invoker/miles/SpatialAudio.cpp | 220 ------------- .../plugins/invoker/miles/SpatialAudio.cpp.old | 220 +++++++++++++ src/uscxml/plugins/invoker/miles/SpatialAudio.h | 57 ---- .../plugins/invoker/miles/SpatialAudio.h.old | 57 ++++ src/uscxml/plugins/ioprocessor/CMakeLists.txt | 15 +- test/CMakeLists.txt | 8 +- 20 files changed, 812 insertions(+), 397 deletions(-) create mode 100644 apps/samples/put-that-there/put-that-there.scxml create mode 100644 contrib/ctest/tests/plugins.ctest delete mode 100644 src/uscxml/plugins/invoker/miles/SpatialAudio.cpp create mode 100644 src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old delete mode 100644 src/uscxml/plugins/invoker/miles/SpatialAudio.h create mode 100644 src/uscxml/plugins/invoker/miles/SpatialAudio.h.old diff --git a/CMakeLists.txt b/CMakeLists.txt index 533106e..4e7cadc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -402,6 +402,12 @@ endforeach() OPTION(BUILD_AS_PLUGINS "Build invokers, ioprocessors and datamodels as plugins" OFF) +if (BUILD_AS_PLUGINS) + add_definitions("-DBUILD_AS_PLUGINS") + include_directories("src/uscxml/plugins") +# list(APPEND USCXML_FILES "src/uscxml/plugins/Plugins.cpp") +endif() + # this is where the config.h ends up include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(src) @@ -444,8 +450,10 @@ if (NOT WIN32) elseif(APPLE) find_library(APP_SERVICES_LIBRARY ApplicationServices) find_library(COREFOUNDATION_LIBRARY CoreFoundation) + find_library(FOUNDATION_LIBRARY Foundation) list (APPEND USCXML_CORE_LIBS ${APP_SERVICES_LIBRARY}) list (APPEND USCXML_CORE_LIBS ${COREFOUNDATION_LIBRARY}) + list (APPEND USCXML_CORE_LIBS ${FOUNDATION_LIBRARY}) endif() elseif(WIN32) list (APPEND XML_LIBRARIES "Ws2_32") @@ -653,11 +661,11 @@ endif() find_package(MILES) if (MILES_FOUND) # openal is only needed for miles - # find_package(OpenAL REQUIRED) - # find_package(JPEG REQUIRED) - # list (APPEND MILES_LIBRARIES "iconv") - # list (APPEND MILES_LIBRARIES ${JPEG_LIBRARIES}) - # list (APPEND USCXML_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR}) + find_package(OpenAL REQUIRED) + find_package(JPEG REQUIRED) + list (APPEND MILES_LIBRARIES "iconv") + list (APPEND MILES_LIBRARIES ${JPEG_LIBRARIES}) + list (APPEND USCXML_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR}) include_directories (${MILES_INCLUDE_DIR}) list (APPEND USCXML_OPT_LIBS ${MILES_LIBRARIES}) @@ -757,7 +765,7 @@ endif() if (NOT CMAKE_CROSSCOMPILING) set_target_properties(uscxml PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "src/uscxml/pch.h") set_target_properties(uscxml PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(uscxml) +# cotire(uscxml) endif() if (NOT CMAKE_CROSSCOMPILING) @@ -765,13 +773,13 @@ if (NOT CMAKE_CROSSCOMPILING) target_link_libraries(uscxml-browser uscxml) if (NOT CMAKE_CROSSCOMPILING) set_target_properties(uscxml-browser PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE) - cotire(uscxml-browser) +# cotire(uscxml-browser) endif() set_target_properties(uscxml-browser PROPERTIES FOLDER "Apps") install_executable(TARGETS uscxml-browser COMPONENT tools) - if (PROTOBUF_FOUND) + if (PROTOBUF_FOUND AND OFF) file(GLOB W3C-MMI-COMMON ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/*.cpp ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/*.h) file(GLOB_RECURSE W3C-MMI-IM ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/im/*.cpp ${PROJECT_SOURCE_DIR}/apps/w3c-mmi/im/*.h) diff --git a/apps/samples/put-that-there/put-that-there.scxml b/apps/samples/put-that-there/put-that-there.scxml new file mode 100644 index 0000000..fee9f39 --- /dev/null +++ b/apps/samples/put-that-there/put-that-there.scxml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest b/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest index 8b49d1a..e5a0406 100644 --- a/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest +++ b/contrib/ctest/hosts/buildslave-opensuse-12-32.ctest @@ -13,3 +13,9 @@ set(REMOVE_PREBUILDS OFF) set(CTEST_BUILD_NAME "linux-x86 gcc 4.7.2") include("tests/xpath.ctest") include("common.ctest.inc") + +set(RETAIN_BUILD_DIR OFF) +set(REMOVE_PREBUILDS OFF) +set(CTEST_BUILD_NAME "linux-x86 gcc 4.7.2") +include("tests/plugins.ctest") +include("common.ctest.inc") diff --git a/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest b/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest index 8636679..b77b3a7 100644 --- a/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest +++ b/contrib/ctest/hosts/buildslave-ubuntu-1204-32.ctest @@ -13,3 +13,9 @@ set(REMOVE_PREBUILDS OFF) set(CTEST_BUILD_NAME "linux-x86 gcc 4.6.3") include("tests/xpath.ctest") include("common.ctest.inc") + +set(RETAIN_BUILD_DIR OFF) +set(REMOVE_PREBUILDS OFF) +set(CTEST_BUILD_NAME "linux-x86 gcc 4.6.3") +include("tests/plugins.ctest") +include("common.ctest.inc") diff --git a/contrib/ctest/tests/plugins.ctest b/contrib/ctest/tests/plugins.ctest new file mode 100644 index 0000000..a983bb9 --- /dev/null +++ b/contrib/ctest/tests/plugins.ctest @@ -0,0 +1,2 @@ +set(CTEST_BUILD_OPTIONS "-DBUILD_AS_PLUGINS=ON -DENABLE_GCOV:BOOL=ON") +set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME} - plugins") \ No newline at end of file diff --git a/src/bindings/swig/java/CMakeLists.txt b/src/bindings/swig/java/CMakeLists.txt index 2b604f3..fb02b17 100644 --- a/src/bindings/swig/java/CMakeLists.txt +++ b/src/bindings/swig/java/CMakeLists.txt @@ -16,7 +16,7 @@ SET(SCXMLPL_JAVA_PACKAGE "org.uscxml") SET(SCXMLPL_JAVA_DIR "org/uscxml") # we need ; to produce a space with the package .. weird -SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES SWIG_FLAGS "-package;${SCXMLPL_JAVA_PACKAGE}") +SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES SWIG_FLAGS "-w473 -package;${SCXMLPL_JAVA_PACKAGE}") SET_SOURCE_FILES_PROPERTIES(uscxml.i PROPERTIES CPLUSPLUS ON) SET(CMAKE_SWIG_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/${SCXMLPL_JAVA_DIR}") diff --git a/src/bindings/swig/php/uscxmlNativePHP.php b/src/bindings/swig/php/uscxmlNativePHP.php index 4a9c37b..a0c8cd2 100644 --- a/src/bindings/swig/php/uscxmlNativePHP.php +++ b/src/bindings/swig/php/uscxmlNativePHP.php @@ -260,6 +260,24 @@ class Blob { default: $this->_cPtr=new_Blob($size_or_data,$size,$adopt); } } + + function md5() { + return Blob_md5($this->_cPtr); + } + + function base64() { + return Blob_base64($this->_cPtr); + } + + function fromBase64($base64) { + $r=Blob_fromBase64($this->_cPtr,$base64); + if (is_resource($r)) { + $c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3)); + if (class_exists($c)) return new $c($r); + return new Blob($r); + } + return $r; + } } class Data { diff --git a/src/uscxml/CMakeLists.txt b/src/uscxml/CMakeLists.txt index 20c9010..9582112 100644 --- a/src/uscxml/CMakeLists.txt +++ b/src/uscxml/CMakeLists.txt @@ -38,7 +38,7 @@ source_group("Interpreter" FILES ${USCXML_INTERPRETERS}) list (APPEND USCXML_FILES ${USCXML_INTERPRETERS}) if(APPLE OR IOS) - file(GLOB_RECURSE USCXML_APPLE + file(GLOB USCXML_APPLE *.mm ) source_group("Interpreter" FILES ${USCXML_APPLE}) diff --git a/src/uscxml/interpreter/InterpreterDraft6.cpp b/src/uscxml/interpreter/InterpreterDraft6.cpp index 3480c43..7ea09c2 100644 --- a/src/uscxml/interpreter/InterpreterDraft6.cpp +++ b/src/uscxml/interpreter/InterpreterDraft6.cpp @@ -34,6 +34,11 @@ void InterpreterDraft6::interpret() { datamodelName = ATTR(_scxml, "profile"); if(datamodelName.length() > 0) { _dataModel = _factory->createDataModel(datamodelName, this); + if (!_dataModel) { + Event e; + e.data.compound["cause"] = Data("Cannot instantiate datamodel"); + throw e; + } } else { _dataModel = _factory->createDataModel("null", this); } diff --git a/src/uscxml/plugins/datamodel/CMakeLists.txt b/src/uscxml/plugins/datamodel/CMakeLists.txt index 3b6a852..4811551 100644 --- a/src/uscxml/plugins/datamodel/CMakeLists.txt +++ b/src/uscxml/plugins/datamodel/CMakeLists.txt @@ -8,22 +8,21 @@ if (BUILD_DM_ECMA) ecmascript/*.cpp ecmascript/*.h ) - source_group("Datamodel\\jsc" FILES ${JSC_DATAMODEL}) file(GLOB_RECURSE JSC_DOM ecmascript/JavaScriptCore/dom/*.cpp ecmascript/JavaScriptCore/dom/*.h ) - source_group("Datamodel\\DOM" FILES ${JSC_DOM}) if (BUILD_AS_PLUGINS) + source_group("JavaScriptCore" FILES ${JSC_DATAMODEL}) + source_group("dom" FILES ${JSC_DOM}) + add_library( datamodel_jsc SHARED ${JSC_DATAMODEL} ${JSC_DOM}) - target_link_libraries(datamodel_jsc - uscxml - ${JSC_LIBRARY}) + target_link_libraries(datamodel_jsc uscxml ${JSC_LIBRARY}) set_target_properties(datamodel_jsc PROPERTIES FOLDER "Plugin DataModel") - else() + else() list (APPEND USCXML_FILES ${JSC_DATAMODEL}) list (APPEND USCXML_FILES ${JSC_DOM}) list (APPEND USCXML_OPT_LIBS ${JSC_LIBRARY}) @@ -40,21 +39,20 @@ if (BUILD_DM_ECMA) ecmascript/*.cpp ecmascript/*.h ) - source_group("Datamodel\\v8" FILES ${V8_DATAMODEL}) file(GLOB_RECURSE V8_DOM ecmascript/v8/dom/*.cpp ecmascript/v8/dom/*.h ) - source_group("Datamodel\\v8\\DOM" FILES ${V8_DOM}) if (BUILD_AS_PLUGINS) + source_group("V8" FILES ${V8_DATAMODEL}) + source_group("dom" FILES ${V8_DOM}) + add_library( datamodel_v8 SHARED ${V8_DATAMODEL} ${V8_DOM}) - target_link_libraries(datamodel_v8 - uscxml - ${V8_LIBRARY}) + target_link_libraries(datamodel_v8 uscxml ${V8_LIBRARY}) set_target_properties(datamodel_v8 PROPERTIES FOLDER "Plugin DataModel") else() list (APPEND USCXML_FILES ${V8_DATAMODEL}) @@ -72,8 +70,8 @@ file(GLOB NULL_DATAMODEL null/*.cpp null/*.h ) -source_group("Datamodel\\null" FILES ${NULL_DATAMODEL}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${NULL_DATAMODEL}) add_library(datamodel_null SHARED ${NULL_DATAMODEL}) target_link_libraries(datamodel_null uscxml) set_target_properties(datamodel_null PROPERTIES FOLDER "Plugin DataModel") @@ -90,8 +88,8 @@ if (BUILD_DM_XPATH) xpath/*.cpp xpath/*.h ) - source_group("Datamodel\\xpath" FILES ${XPATH_DATAMODEL}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${XPATH_DATAMODEL}) add_library(datamodel_xpath SHARED ${XPATH_DATAMODEL}) target_link_libraries(datamodel_xpath uscxml) set_target_properties(datamodel_xpath PROPERTIES FOLDER "Plugin DataModel") @@ -116,8 +114,8 @@ if (SWI_FOUND AND BUILD_DM_PROLOG) prolog/swi/*.cpp prolog/swi/*.h ) - source_group("Datamodel\\swi" FILES ${SWI_DATAMODEL}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${SWI_DATAMODEL}) add_library( datamodel_swi SHARED ${SWI_DATAMODEL}) diff --git a/src/uscxml/plugins/element/CMakeLists.txt b/src/uscxml/plugins/element/CMakeLists.txt index fd69417..c0a7e15 100644 --- a/src/uscxml/plugins/element/CMakeLists.txt +++ b/src/uscxml/plugins/element/CMakeLists.txt @@ -5,8 +5,8 @@ file(GLOB_RECURSE FETCH_ELEMENT fetch/*.cpp fetch/*.h ) -source_group("Element\\fetch" FILES ${FETCH_ELEMENT}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${FETCH_ELEMENT}) add_library( element_fetch SHARED ${FETCH_ELEMENT}) @@ -22,8 +22,8 @@ endif() # mmi/*.cpp # mmi/*.h # ) -# source_group("Element\\mmi" FILES ${MMI_ELEMENT}) # if (BUILD_AS_PLUGINS) +# source_group("" FILES ${MMI_ELEMENT}) # add_library( # element_mmi SHARED # ${MMI_ELEMENT}) @@ -41,8 +41,8 @@ file(GLOB_RECURSE POSTPONE_ELEMENT postpone/*.cpp postpone/*.h ) -source_group("Element\\postpone" FILES ${POSTPONE_ELEMENT}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${POSTPONE_ELEMENT}) add_library( element_postpone SHARED ${POSTPONE_ELEMENT}) @@ -60,8 +60,8 @@ file(GLOB_RECURSE FILE_ELEMENT file/*.cpp file/*.h ) -source_group("Element\\file" FILES ${FILE_ELEMENT}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${FILE_ELEMENT}) add_library( element_file SHARED ${FILE_ELEMENT}) @@ -79,8 +79,8 @@ file(GLOB_RECURSE RESPOND_ELEMENT respond/*.cpp respond/*.h ) -source_group("Element\\respond" FILES ${RESPOND_ELEMENT}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${RESPOND_ELEMENT}) add_library( element_respond SHARED ${RESPOND_ELEMENT}) diff --git a/src/uscxml/plugins/invoker/CMakeLists.txt b/src/uscxml/plugins/invoker/CMakeLists.txt index 5f767c9..43dd683 100644 --- a/src/uscxml/plugins/invoker/CMakeLists.txt +++ b/src/uscxml/plugins/invoker/CMakeLists.txt @@ -5,8 +5,8 @@ file(GLOB_RECURSE SAMPLE_INVOKER sample/*.h ) -source_group("Invoker\\sample" FILES ${SAMPLE_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${SAMPLE_INVOKER}) add_library( invoker_sample SHARED ${SAMPLE_INVOKER}) @@ -23,8 +23,8 @@ file(GLOB_RECURSE DIRMON_INVOKER filesystem/dirmon/*.cpp filesystem/dirmon/*.h ) -source_group("Invoker\\dirmon" FILES ${DIRMON_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${DIRMON_INVOKER}) add_library( invoker_dirmon SHARED ${DIRMON_INVOKER}) @@ -37,20 +37,20 @@ endif() # Location invoker to watch for proximity to GPS coordinates -file(GLOB_RECURSE LOCATION_INVOKER - location/*.cpp - location/*.h -) -source_group("Invoker\\location" FILES ${LOCATION_INVOKER}) -if (BUILD_AS_PLUGINS) - add_library( - invoker_location SHARED - ${LOCATION_INVOKER}) - target_link_libraries(invoker_location uscxml) - set_target_properties(invoker_location PROPERTIES FOLDER "Plugin Invoker") -else() - list (APPEND USCXML_FILES ${LOCATION_INVOKER}) -endif() +# file(GLOB_RECURSE LOCATION_INVOKER +# location/*.cpp +# location/*.h +# ) +# if (BUILD_AS_PLUGINS) +# source_group("" FILES ${LOCATION_INVOKER}) +# add_library( +# invoker_location SHARED +# ${LOCATION_INVOKER}) +# target_link_libraries(invoker_location uscxml) +# set_target_properties(invoker_location PROPERTIES FOLDER "Plugin Invoker") +# else() +# list (APPEND USCXML_FILES ${LOCATION_INVOKER}) +# endif() # XHTML invoker @@ -60,8 +60,8 @@ file(GLOB_RECURSE XHTML_INVOKER xhtml/*.cpp xhtml/*.h ) -source_group("Invoker\\xhtml" FILES ${XHTML_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${XHTML_INVOKER}) add_library( invoker_xhtml SHARED ${XHTML_INVOKER}) @@ -78,8 +78,8 @@ file(GLOB_RECURSE SYSTEM_INVOKER system/*.cpp system/*.h ) -source_group("Invoker\\system" FILES ${SYSTEM_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${SYSTEM_INVOKER}) add_library( invoker_system SHARED ${SYSTEM_INVOKER}) @@ -97,8 +97,8 @@ if (SQLITE3_FOUND) sqlite3/*.cpp sqlite3/*.h ) - source_group("Invoker\\sqlite" FILES ${SQLITE3_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${SQLITE3_INVOKER}) add_library( invoker_sqlite3 SHARED ${SQLITE3_INVOKER}) @@ -118,12 +118,12 @@ if (FFMPEG_FOUND) ffmpeg/*.cpp ffmpeg/*.h ) - source_group("Invoker\\ffmpeg" FILES ${FFMPEG_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${FFMPEG_INVOKER}) add_library( invoker_ffmpeg SHARED ${FFMPEG_INVOKER}) - target_link_libraries(invoker_ffmpeg uscxml) + target_link_libraries(invoker_ffmpeg uscxml ${FFMPEG_LIBRARIES}) set_target_properties(invoker_ffmpeg PROPERTIES FOLDER "Plugin Invoker") else() list (APPEND USCXML_FILES ${FFMPEG_INVOKER}) @@ -139,12 +139,12 @@ if (LIBPURPLE_FOUND) im/*.cpp im/*.h ) - source_group("Invoker\\im" FILES ${LIBPURPLE_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${LIBPURPLE_INVOKER}) add_library( invoker_im SHARED ${LIBPURPLE_INVOKER}) - target_link_libraries(invoker_im uscxml) + target_link_libraries(invoker_im uscxml ${LIBPURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${ICONV_LIBRARIES}) set_target_properties(invoker_im PROPERTIES FOLDER "Plugin Invoker") else() list (APPEND USCXML_FILES ${LIBPURPLE_INVOKER}) @@ -160,12 +160,12 @@ if (LIBICAL_FOUND) calendar/*.cpp calendar/*.h ) - source_group("Invoker\\calendar" FILES ${CALENDAR_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${CALENDAR_INVOKER}) add_library( invoker_calendar SHARED ${CALENDAR_INVOKER}) - target_link_libraries(invoker_calendar uscxml) + target_link_libraries(invoker_calendar uscxml ${LIBICAL_LIBRARIES}) set_target_properties(invoker_calendar PROPERTIES FOLDER "Plugin Invoker") else() list (APPEND USCXML_FILES ${CALENDAR_INVOKER}) @@ -182,8 +182,8 @@ if (CORELOCATION_LIBRARY AND OFF) location/CoreLocation/*.mm location/CoreLocation/*.h ) - source_group("Invoker\\location" FILES ${LOCATION_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${LOCATION_INVOKER}) add_library( invoker_location SHARED ${LOCATION_INVOKER}) @@ -203,14 +203,16 @@ if (UMUNDO_FOUND) umundo/*.cpp umundo/*.cc umundo/*.h) - source_group("Invoker\\umundo" FILES ${UMUNDO_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${UMUNDO_INVOKER}) +# message(FATAL_ERROR "UMUNDO_LIBRARIES: ${UMUNDO_LIBRARIES}") add_library( invoker_umundo SHARED ${UMUNDO_INVOKER}) - target_link_libraries(invoker_umundo - uscxml - ${UMUNDO_LIBRARIES}) + target_link_libraries(invoker_umundo uscxml + optimized ${PROTOBUF_LIBRARY} + debug ${PROTOBUF_LIBRARY_DEBUG} + ${UMUNDO_LIBRARIES}) set_target_properties(invoker_umundo PROPERTIES FOLDER "Plugin Invoker") else() list (APPEND USCXML_FILES ${UMUNDO_INVOKER}) @@ -224,8 +226,8 @@ set(USCXML_INVOKERS "scxml ${USCXML_INVOKERS}") file(GLOB_RECURSE USCXML_INVOKER scxml/*.cpp scxml/*.h) -source_group("Invoker\\uscxml" FILES ${USCXML_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${USCXML_INVOKER}) add_library( invoker_uscxml SHARED ${USCXML_INVOKER}) @@ -243,8 +245,8 @@ set(USCXML_INVOKERS "httpservlet ${USCXML_INVOKERS}") file(GLOB_RECURSE HTTPSERVLET_INVOKER http/*.cpp http/*.h) -source_group("Invoker\\httpservlet" FILES ${HTTPSERVLET_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${HTTPSERVLET_INVOKER}) add_library( invoker_httpserver SHARED ${HTTPSERVLET_INVOKER}) @@ -263,8 +265,8 @@ file(GLOB_RECURSE HEARTBEAT_INVOKER heartbeat/*.cpp heartbeat/*.h ) -source_group("Invoker\\heartbeat" FILES ${HEARTBEAT_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${HEARTBEAT_INVOKER}) add_library( invoker_heartbeat SHARED ${HEARTBEAT_INVOKER}) @@ -281,9 +283,9 @@ if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND) file(GLOB OPENSCENEGRAPH_INVOKER graphics/openscenegraph/*.cpp graphics/openscenegraph/*.h) - source_group("Invoker\\scenegraph" FILES ${OPENSCENEGRAPH_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${OPENSCENEGRAPH_INVOKER}) add_library( invoker_openscenegraph SHARED ${OPENSCENEGRAPH_INVOKER}) @@ -300,9 +302,9 @@ if (OPENSCENEGRAPH_FOUND AND OPENGL_FOUND) file(GLOB OPENSCENEGRAPH_CONVERTER_INVOKER graphics/openscenegraph/converter/*.cpp graphics/openscenegraph/converter/*.h) - source_group("Invoker\\scenegraph\\convert" FILES ${OPENSCENEGRAPH_CONVERTER_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${OPENSCENEGRAPH_CONVERTER_INVOKER}) add_library( invoker_openscenegraph_convert SHARED ${OPENSCENEGRAPH_CONVERTER_INVOKER}) @@ -335,16 +337,24 @@ if (OPENAL_FOUND AND (LIBSNDFILE_FOUND OR AUDIOTOOLBOX_FOUND)) audio/AudioToolbox*.h) LIST(APPEND OPENAL_INVOKER ${AUDIOTOOLBOX_WRAPPER}) endif() - source_group("Invoker\\audio" FILES ${OPENAL_INVOKER}) # message("MILES_INVOKER ${MILES_INVOKER}") if (BUILD_AS_PLUGINS) + source_group("" FILES ${OPENAL_INVOKER}) add_library( invoker_openal SHARED ${OPENAL_INVOKER}) - target_link_libraries(invoker_openal - ${OPENAL_LIBRARY} - uscxml) + if (LIBSNDFILE_FOUND) + target_link_libraries(invoker_openal + ${OPENAL_LIBRARY} + ${LIBSNDFILE_LIBRARY} + uscxml) + elseif(AUDIOTOOLBOX_FOUND) + target_link_libraries(invoker_openal + ${OPENAL_LIBRARY} + ${AUDIOTOOLBOX}/AudioToolbox + uscxml) + endif() set_target_properties(invoker_openal PROPERTIES FOLDER "Plugin Invoker") else() list (APPEND USCXML_FILES ${OPENAL_INVOKER}) @@ -359,16 +369,18 @@ if (MILES_FOUND) file(GLOB_RECURSE MILES_INVOKER miles/*.cpp miles/*.h) - source_group("Invoker\\miles" FILES ${MILES_INVOKER}) # message("MILES_INVOKER ${MILES_INVOKER}") if (BUILD_AS_PLUGINS) + source_group("" FILES ${MILES_INVOKER}) add_library( invoker_miles SHARED ${MILES_INVOKER}) target_link_libraries(invoker_miles ${MILES_LIBRARIES} ${OPENAL_LIBRARY} + ${JPEG_LIBRARIES} + ${ICONV_LIBRARIES} uscxml) set_target_properties(invoker_miles PROPERTIES FOLDER "Plugin Invoker") else() @@ -379,14 +391,14 @@ endif() # VoiceXML modality components -if (UMUNDO_FOUND) +if (UMUNDO_FOUND AND OFF) set(USCXML_INVOKERS "vxml ${USCXML_INVOKERS}") file(GLOB_RECURSE VXML_INVOKER vxml/*.cpp vxml/*.h ) - source_group("Invoker\\voicexml" FILES ${VXML_INVOKER}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${VXML_INVOKER}) add_library( invoker_voicexml SHARED ${VXML_INVOKER}) diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp index 2b77baf..d732e63 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp @@ -3,10 +3,36 @@ #include "uscxml/UUID.h" #include +#include +#include +#include +#include + #ifdef BUILD_AS_PLUGINS #include #endif +#define OSG_SET_MATERIAL \ +osg::ref_ptr mat = getMaterial(element); \ +if (mat) { \ + osg::ref_ptr nodeSS = geode->getOrCreateStateSet(); \ +\ + nodeSS->setAttribute(mat.get()); \ + nodeSS->setMode( GL_BLEND, osg::StateAttribute::ON ); \ +/* nodeSS->setRenderingHint( osg::StateSet::TRANSPARENT_BIN ); \ + nodeSS->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON ); \ + osg::Depth* depth = new osg::Depth; \ + depth->setWriteMask( false ); \ + nodeSS->setAttributeAndModes( depth, osg::StateAttribute::ON ); \ + nodeSS->setMode( GL_LIGHTING, osg::StateAttribute::OFF );*/ \ +} + +#define OSG_SET_COLOR \ +bool validColor = true; \ +osg::Vec4 color = getColor(element, "color", validColor); \ +if (validColor) \ +drawable->setColor(color); + namespace uscxml { #ifdef BUILD_AS_PLUGINS @@ -17,6 +43,12 @@ bool connect(pluma::Host& host) { } #endif +#define OSG_TAG_HANDLE(tagName, procFunc) \ +} else if (boost::iequals(LOCALNAME(childs.item(i)), tagName) && \ + validChildren.find(tagName) != validChildren.end()) { \ + procFunc(childs.item(i));\ + + OSGInvoker::OSGInvoker() { } @@ -35,6 +67,9 @@ Data OSGInvoker::getDataModelVariables() { } void OSGInvoker::send(const SendRequest& req) { + if (boost::iequals(req.name, "intersect")) { + + } } void OSGInvoker::cancel(const std::string sendId) { @@ -43,6 +78,10 @@ void OSGInvoker::cancel(const std::string sendId) { void OSGInvoker::invoke(const InvokeRequest& req) { tthread::lock_guard lock(_mutex); + setupColors(); + + std::cout << req.dom; + // register default event handlers Arabica::DOM::Events::EventTarget evTarget = Arabica::DOM::Events::EventTarget(req.dom); evTarget.addEventListener("DOMSubtreeModified", *this, false); @@ -52,9 +91,37 @@ void OSGInvoker::invoke(const InvokeRequest& req) { std::set validChilds; validChilds.insert("display"); - processChildren(validChilds, req.dom); + + // this is somewhat unfortunate, if content contains a single child, we will get that, otherwise its parent () + if (boost::iequals(LOCALNAME(req.dom), "display")) { + processChildren(validChilds, req.dom.getParentNode()); + } else { + processChildren(validChilds, req.dom); + } } +void OSGInvoker::setupColors() { + _colors["red"] = osg::Vec4(1.0, 0.0, 0.0, 1.0); + _colors["cyan"] = osg::Vec4(0.0, 1.0, 1.0, 1.0); + _colors["blue"] = osg::Vec4(0.0, 0.0, 1.0, 1.0); + _colors["darkblue"] = osg::Vec4(0.0, 0.0, 0.625, 1.0); + _colors["lightblue"] = osg::Vec4(0.675, 0.84375,0.89844,1.0); + _colors["purple"] = osg::Vec4(0.5, 0.0, 0.5, 1.0); + _colors["yellow"] = osg::Vec4(1.0, 1.0, 0.0, 1.0); + _colors["lime"] = osg::Vec4(0.0, 1.0, 0.0, 1.0); + _colors["magenta"] = osg::Vec4(1.0, 0.0, 1.0, 1.0); + _colors["white"] = osg::Vec4(1.0, 1.0, 1.0, 1.0); + _colors["silver"] = osg::Vec4(0.75, 0.75, 0.75, 1.0); + _colors["grey"] = osg::Vec4(0.5, 0.5, 0.5, 1.0); + _colors["gray"] = osg::Vec4(0.5, 0.5, 0.5, 1.0); + _colors["black"] = osg::Vec4(0.0, 0.0, 0.0, 1.0); + _colors["orange"] = osg::Vec4(1.0, 0.644, 0.0, 1.0); + _colors["brown"] = osg::Vec4(0.644, 0.164, 0.164, 1.0); + _colors["maroon"] = osg::Vec4(0.5, 0.0, 0.0, 1.0); + _colors["green"] = osg::Vec4(0.0, 0.5, 0.0, 1.0); + _colors["olive"] = osg::Vec4(0.5, 0.5, 0.0, 1.0); +} + void OSGInvoker::runOnMainThread() { _displays_t::iterator dispIter = _displays.begin(); if (_mutex.try_lock()) { @@ -70,7 +137,7 @@ void OSGInvoker::handleEvent(Arabica::DOM::Events::Event& event) { // std::cout << "Handling Event!" << std::endl; Arabica::DOM::Node node(event.getTarget()); if (_nodes.find(node) != _nodes.end()) { - osg::Node* osgNode = _nodes[node]; + osg::ref_ptr osgNode = _nodes[node]; if (false) { } else if (boost::iequals(LOCALNAME(node), "rotation")) { updateRotation(osgNode, event); @@ -117,26 +184,39 @@ void OSGInvoker::processViewport(const Arabica::DOM::Node& element) unsigned int actualY = 0; unsigned int actualWidth = 0; unsigned int actualHeight = 0; + getViewport(element, actualX, actualY, actualWidth, actualHeight, compDisp); - osg::Viewport* viewPort = new osg::Viewport(actualX, actualY, actualWidth, actualHeight); compDisp->addView(name, viewPort, sceneView); + bool hasBGColor; + osg::Vec4 bgColor = getColor(element, "bgcolor", hasBGColor); + if (hasBGColor) { + sceneView->getCamera()->setClearColor(bgColor); + } else { + sceneView->getCamera()->setClearColor(_colors["white"]); + } + std::set validChilds; validChilds.insert("camera"); validChilds.insert("translation"); validChilds.insert("rotation"); validChilds.insert("scale"); validChilds.insert("node"); + validChilds.insert("sphere"); + validChilds.insert("box"); + validChilds.insert("capsule"); + validChilds.insert("cone"); + validChilds.insert("cylinder"); processChildren(validChilds, element); } void OSGInvoker::processCamera(const Arabica::DOM::Node& element) {} -void OSGInvoker::updateCamera(osg::Node* node, Arabica::DOM::Events::Event& event) {} +void OSGInvoker::updateCamera(osg::ref_ptr node, Arabica::DOM::Events::Event& event) {} void OSGInvoker::processTranslation(const Arabica::DOM::Node& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); - osg::Node* node = _nodes[element.getParentNode()]; + osg::ref_ptr node = _nodes[element.getParentNode()]; double x = 0, y = 0, z = 0; if (HAS_ATTR(element, "x")) @@ -159,12 +239,17 @@ void OSGInvoker::processTranslation(const Arabica::DOM::Node& eleme validChilds.insert("rotation"); validChilds.insert("scale"); validChilds.insert("node"); + validChilds.insert("sphere"); + validChilds.insert("box"); + validChilds.insert("capsule"); + validChilds.insert("cone"); + validChilds.insert("cylinder"); processChildren(validChilds, element); } void OSGInvoker::processRotation(const Arabica::DOM::Node& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); - osg::Node* node = _nodes[element.getParentNode()]; + osg::ref_ptr node = _nodes[element.getParentNode()]; osg::Matrix rotation = rotationFromElement(element); osg::MatrixTransform* transform = new osg::MatrixTransform(); @@ -177,11 +262,16 @@ void OSGInvoker::processRotation(const Arabica::DOM::Node& element) validChilds.insert("rotation"); validChilds.insert("scale"); validChilds.insert("node"); + validChilds.insert("sphere"); + validChilds.insert("box"); + validChilds.insert("capsule"); + validChilds.insert("cone"); + validChilds.insert("cylinder"); processChildren(validChilds, element); } -void OSGInvoker::updateRotation(osg::Node* node, Arabica::DOM::Events::Event& event) { - osg::MatrixTransform* transform = static_cast(node); +void OSGInvoker::updateRotation(osg::ref_ptr node, Arabica::DOM::Events::Event& event) { + osg::ref_ptr transform = static_cast(node->asTransform()); if (false) { } else if (boost::iequals(event.getType(), "DOMAttrModified")) { osg::Matrix rotation = rotationFromElement(Arabica::DOM::Node(event.getTarget())); @@ -232,7 +322,7 @@ osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Node& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); - osg::Node* node = _nodes[element.getParentNode()]; + osg::ref_ptr node = _nodes[element.getParentNode()]; double x = 1, y = 1, z = 1; if (HAS_ATTR(element, "x")) @@ -255,6 +345,11 @@ void OSGInvoker::processScale(const Arabica::DOM::Node& element) { validChilds.insert("rotation"); validChilds.insert("scale"); validChilds.insert("node"); + validChilds.insert("sphere"); + validChilds.insert("box"); + validChilds.insert("capsule"); + validChilds.insert("cone"); + validChilds.insert("cylinder"); processChildren(validChilds, element); } @@ -263,7 +358,7 @@ void OSGInvoker::processNode(const Arabica::DOM::Node& element) { assert(nodeIter != _nodes.end()); assert(_nodes.find(element.getParentNode()) != _nodes.end()); - osg::Node* parent = _nodes[element.getParentNode()]; + osg::ref_ptr parent = _nodes[element.getParentNode()]; std::string filename; if (HAS_ATTR(element, "src")) { @@ -290,33 +385,241 @@ void OSGInvoker::processNode(const Arabica::DOM::Node& element) { } } +void OSGInvoker::processSphere(const Arabica::DOM::Node& element) { + assert(_nodes.find(element.getParentNode()) != _nodes.end()); + osg::ref_ptr parent = _nodes[element.getParentNode()]; + + float radius = 1; + osg::Vec3 center(0,0,0); + + if (HAS_ATTR(element, "radius")) { + radius = strTo(ATTR(element, "radius")); + } + + osg::ref_ptr sphere = new osg::Sphere(center, radius); + osg::ref_ptr drawable = new osg::ShapeDrawable(sphere); + osg::ref_ptr geode = new osg::Geode(); + geode->addDrawable(drawable); + + OSG_SET_COLOR; + OSG_SET_MATERIAL; + + _nodes[element] = geode; + + parent->asGroup()->addChild(geode); +} + +void OSGInvoker::updateSphere(osg::ref_ptr node, Arabica::DOM::Events::Event& event) { +} + +void OSGInvoker::processBox(const Arabica::DOM::Node& element) { + assert(_nodes.find(element.getParentNode()) != _nodes.end()); + osg::ref_ptr parent = _nodes[element.getParentNode()]; + + float x = 1; + float y = 1; + float z = 1; + osg::Vec3 center(0,0,0); + + if (HAS_ATTR(element, "x")) x = strTo(ATTR(element, "x")); + if (HAS_ATTR(element, "y")) y = strTo(ATTR(element, "y")); + if (HAS_ATTR(element, "z")) z = strTo(ATTR(element, "z")); + + osg::ref_ptr box = new osg::Box(center, x, y, z); + osg::ref_ptr drawable = new osg::ShapeDrawable(box); + osg::ref_ptr geode = new osg::Geode(); + geode->addDrawable(drawable); + + OSG_SET_COLOR; + OSG_SET_MATERIAL; + + _nodes[element] = geode; + + parent->asGroup()->addChild(geode); + +} +void OSGInvoker::updateBox(osg::ref_ptr node, Arabica::DOM::Events::Event& event) { +} +void OSGInvoker::processCapsule(const Arabica::DOM::Node& element) { + assert(_nodes.find(element.getParentNode()) != _nodes.end()); + osg::ref_ptr parent = _nodes[element.getParentNode()]; + + float radius = 1; + float height = 1; + osg::Vec3 center(0,0,0); + + if (HAS_ATTR(element, "radius")) radius = strTo(ATTR(element, "radius")); + if (HAS_ATTR(element, "height")) height = strTo(ATTR(element, "height")); + + osg::ref_ptr capsule = new osg::Capsule(center, radius, height); + osg::ref_ptr drawable = new osg::ShapeDrawable(capsule); + osg::ref_ptr geode = new osg::Geode(); + geode->addDrawable(drawable); + + OSG_SET_COLOR; + OSG_SET_MATERIAL; + + _nodes[element] = geode; + parent->asGroup()->addChild(geode); +} +void OSGInvoker::updateCapsule(osg::ref_ptr node, Arabica::DOM::Events::Event& event) { +} + +void OSGInvoker::processCone(const Arabica::DOM::Node& element) { + assert(_nodes.find(element.getParentNode()) != _nodes.end()); + osg::ref_ptr parent = _nodes[element.getParentNode()]; + + float radius = 1; + float height = 1; + osg::Vec3 center(0,0,0); + + if (HAS_ATTR(element, "radius")) radius = strTo(ATTR(element, "radius")); + if (HAS_ATTR(element, "height")) height = strTo(ATTR(element, "height")); + + osg::ref_ptr cone = new osg::Cone(center, radius, height); + osg::ref_ptr drawable = new osg::ShapeDrawable(cone); + osg::ref_ptr geode = new osg::Geode(); + geode->addDrawable(drawable); + + OSG_SET_COLOR; + OSG_SET_MATERIAL; + + _nodes[element] = geode; + + parent->asGroup()->addChild(geode); + +} +void OSGInvoker::updateCone(osg::ref_ptr node, Arabica::DOM::Events::Event& event) { +} + +void OSGInvoker::processCylinder(const Arabica::DOM::Node& element) { + assert(_nodes.find(element.getParentNode()) != _nodes.end()); + osg::ref_ptr parent = _nodes[element.getParentNode()]; + + float radius = 1; + float height = 1; + osg::Vec3 center(0,0,0); + + if (HAS_ATTR(element, "radius")) radius = strTo(ATTR(element, "radius")); + if (HAS_ATTR(element, "height")) height = strTo(ATTR(element, "height")); + + osg::ref_ptr cylinder = new osg::Cylinder(center, radius, height); + osg::ref_ptr drawable = new osg::ShapeDrawable(cylinder); + osg::ref_ptr geode = new osg::Geode(); + geode->addDrawable(drawable); + + OSG_SET_COLOR; + OSG_SET_MATERIAL; + + _nodes[element] = geode; + + parent->asGroup()->addChild(geode); + +} +void OSGInvoker::updateCylinder(osg::ref_ptr node, Arabica::DOM::Events::Event& event) { +} + +osg::Vec4 OSGInvoker::getColor(const Arabica::DOM::Node& element, const std::string& attr, bool& valid) { + if (HAS_ATTR(element, attr)) { + std::string color = ATTR(element, attr); + + // is this one of the predefined colors? + if (_colors.find(color) != _colors.end()) { + valid = true; + return _colors[color]; + } + + // otherwise try to parse as rgba values + int i; + osg::Vec4 colorVec = parseVec4(color, i); + + if (i == 1) { + // only a single value was given, interpret as grey value + colorVec[1] = colorVec[2] = colorVec[0]; colorVec[3] = 1.0; + valid = true; + return colorVec; + } + + if (i == 3) { + // three values were given, set opacity to max + colorVec[3] = 1.0; + valid = true; + return colorVec; + } + } + + // return empty reference + valid = false; + return osg::Vec4(); +} + +osg::ref_ptr OSGInvoker::getMaterial(const Arabica::DOM::Node& element) { + + osg::ref_ptr nodeMat; + + // material color + bool hasMatColor; + osg::Vec4 matColor = getColor(element, "materialcolor", hasMatColor); + if (hasMatColor) { + if (!nodeMat) + nodeMat = new osg::Material; + nodeMat->setDiffuse(osg::Material::FRONT, matColor); + nodeMat->setDiffuse(osg::Material::BACK, matColor); + } + + // translucency + if (HAS_ATTR(element, "transparency")) { + std::string transparency = ATTR(element, "transparency"); + float trans = strTo(transparency); + if (!nodeMat) + nodeMat = new osg::Material; + nodeMat->setTransparency(osg::Material::FRONT, trans); + nodeMat->setTransparency(osg::Material::BACK, trans); + } + + return nodeMat; +} + +osg::Vec4 OSGInvoker::parseVec4(const std::string& coeffs, int& i) { + + // otherwise try to parse as rgba values + std::string coeff; + std::stringstream coeffSS(coeffs); + + osg::Vec4 vec; + + i = 0; + while(std::getline(coeffSS, coeff, ',')) { + boost::trim(coeff); + if (coeff.length() == 0) + continue; + if (!isNumeric(coeff.c_str(), 10)) + continue; + + vec[i] = strTo(coeff); + i++; + } + return vec; +} + void OSGInvoker::processChildren(const std::set& validChildren, const Arabica::DOM::Node& element) { Arabica::DOM::NodeList childs = element.getChildNodes(); for (int i = 0; i < childs.getLength(); ++i) { if (childs.item(i).getNodeType() != Arabica::DOM::Node_base::ELEMENT_NODE) continue; if (false) { - } else if (boost::iequals(LOCALNAME(childs.item(i)), "node") && - validChildren.find("node") != validChildren.end()) { - processNode(childs.item(i)); - } else if (boost::iequals(LOCALNAME(childs.item(i)), "translation") && - validChildren.find("translation") != validChildren.end()) { - processTranslation(childs.item(i)); - } else if (boost::iequals(LOCALNAME(childs.item(i)), "rotation") && - validChildren.find("rotation") != validChildren.end()) { - processRotation(childs.item(i)); - } else if (boost::iequals(LOCALNAME(childs.item(i)), "scale") && - validChildren.find("scale") != validChildren.end()) { - processScale(childs.item(i)); - } else if (boost::iequals(LOCALNAME(childs.item(i)), "viewport") && - validChildren.find("viewport") != validChildren.end()) { - processViewport(childs.item(i)); - } else if (boost::iequals(LOCALNAME(childs.item(i)), "camera") && - validChildren.find("camera") != validChildren.end()) { - processCamera(childs.item(i)); - } else if (boost::iequals(LOCALNAME(childs.item(i)), "display") && - validChildren.find("display") != validChildren.end()) { - processDisplay(childs.item(i)); + OSG_TAG_HANDLE("node", processNode); + OSG_TAG_HANDLE("translation", processTranslation); + OSG_TAG_HANDLE("rotation", processRotation); + OSG_TAG_HANDLE("scale", processScale); + OSG_TAG_HANDLE("viewport", processViewport); + OSG_TAG_HANDLE("camera", processCamera); + OSG_TAG_HANDLE("display", processDisplay); + OSG_TAG_HANDLE("sphere", processSphere); + OSG_TAG_HANDLE("box", processBox); + OSG_TAG_HANDLE("cone", processCone); + OSG_TAG_HANDLE("capsule", processCapsule); + OSG_TAG_HANDLE("cylinder", processCylinder); } else { LOG(INFO) << "Unknown XML element " << TAGNAME(childs.item(i)); } diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h index bb46e79..512eecb 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h @@ -5,9 +5,12 @@ #include #include #include + #include "CompositeDisplay.h" #include +#include #include + #include #ifdef BUILD_AS_PLUGINS @@ -40,23 +43,39 @@ public: protected: void processDisplay(const Arabica::DOM::Node& element); - void updateDisplay(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateDisplay(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processViewport(const Arabica::DOM::Node& element); - void updateViewport(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateViewport(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processCamera(const Arabica::DOM::Node& element); - void updateCamera(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateCamera(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processTranslation(const Arabica::DOM::Node& element); - void updateTranslation(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateTranslation(osg::ref_ptr node, Arabica::DOM::Events::Event& event); void processRotation(const Arabica::DOM::Node& element); - void updateRotation(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateRotation(osg::ref_ptr node, Arabica::DOM::Events::Event& event); static osg::Matrix rotationFromElement(const Arabica::DOM::Node& element); void processScale(const Arabica::DOM::Node& element); - void updateScale(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateScale(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + void processNode(const Arabica::DOM::Node& element); - void updateNode(osg::Node* node, Arabica::DOM::Events::Event& event); + void updateNode(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + + void processSphere(const Arabica::DOM::Node& element); + void updateSphere(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + void processBox(const Arabica::DOM::Node& element); + void updateBox(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + void processCapsule(const Arabica::DOM::Node& element); + void updateCapsule(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + void processCone(const Arabica::DOM::Node& element); + void updateCone(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + void processCylinder(const Arabica::DOM::Node& element); + void updateCylinder(osg::ref_ptr node, Arabica::DOM::Events::Event& event); + + osg::Vec4 getColor(const Arabica::DOM::Node& element, const std::string& attr, bool& valid); + osg::ref_ptr getMaterial(const Arabica::DOM::Node& element); + osg::Vec4 parseVec4(const std::string& coeffs, int& number); void processChildren(const std::set& validChildren, const Arabica::DOM::Node& element); @@ -90,9 +109,13 @@ protected: std::map, osgViewer::View*> _views; typedef std::map, osgViewer::View*> _views_t; - std::map, osg::Node*> _nodes; - typedef std::map, osg::Node*> _nodes_t; + std::map, osg::ref_ptr > _nodes; + typedef std::map, osg::ref_ptr > _nodes_t; + void setupColors(); + std::map _colors; + typedef std::map _colors_t; + tthread::recursive_mutex _mutex; }; diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp deleted file mode 100644 index 9a26960..0000000 --- a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp +++ /dev/null @@ -1,220 +0,0 @@ -#include "uscxml/Common.h" -#include "SpatialAudio.h" -#include "uscxml/Interpreter.h" -#include "uscxml/URL.h" - -#include - -#ifdef _WIN32 -#define _USE_MATH_DEFINES -#endif -#include - -namespace uscxml { - -#ifdef BUILD_AS_PLUGINS -PLUMA_CONNECTOR -bool connect(pluma::Host& host) { - host.add( new SpatialAudioProvider() ); - return true; -} -#endif - -SpatialAudio::SpatialAudio() { - _audioDevOpen = false; - _audioDev = NULL; - _audioDevIndex = -1; - _pos = new float[3]; - _pos[0] = _pos[1] = _pos[2] = 0.0; - _listener = new float[3]; - _listener[0] = _listener[1] = _listener[2] = 0.0; - _maxPos = new float[3]; - _maxPos[0] = _maxPos[1] = _maxPos[2] = 1.0; - miles_init(); -} - -SpatialAudio::~SpatialAudio() { -}; - -boost::shared_ptr SpatialAudio::create(InterpreterImpl* interpreter) { - boost::shared_ptr invoker = boost::shared_ptr(new SpatialAudio()); - invoker->_interpreter = interpreter; - return invoker; -} - -Data SpatialAudio::getDataModelVariables() { - Data data; -// data.compound["foo"] = Data("32"); - return data; -} - -void SpatialAudio::send(const SendRequest& req) { - if (!_audioDevOpen) { - _audioDev = miles_audio_device_open(MILES_AUDIO_IO_OPENAL, _audioDevIndex, 0, 22050, 2, 1, 1024, false); - if (_audioDev != NULL) { - _audioDevOpen = true; -// float rolloffFactor = 1.0; -// miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_ROLLOFF_FACTOR, &rolloffFactor); - } - } - - if (boost::iequals(req.name, "play")) { - if (_audioDevOpen) { - getPosFromParams(req.params, _pos); - -// std::cout << "Source: "; -// for (int i = 0; i < 3; i++) { -// std::cout << _pos[i] << " "; -// } -// std::cout << std::endl; - - miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_POSITION, _pos); - - - char* buffer = (char*)malloc(_audioDev->chunk_size); - // skip wav header - _dataStream.seekg(44); - - while(_dataStream.readsome(buffer, _audioDev->chunk_size) != 0) { - int written = 0; - while(written < _audioDev->chunk_size) { - written += miles_audio_device_write(MILES_AUDIO_IO_OPENAL, _audioDev, buffer + written, _audioDev->chunk_size - written); - tthread::this_thread::sleep_for(tthread::chrono::milliseconds(10)); - } - } - _dataStream.seekg(0); - free(buffer); - } - } else if (boost::iequals(req.name, "move.listener")) { - if (_audioDevOpen) { - getPosFromParams(req.params, _listener); - -// std::cout << "Listener: "; -// for (int i = 0; i < 3; i++) { -// std::cout << _listener[i] << " "; -// } -// std::cout << std::endl; - - miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_LISTENER_POS, _listener); - - } - } -} - -void SpatialAudio::cancel(const std::string sendId) { - assert(false); -} - -void SpatialAudio::sendToParent(SendRequest& req) { - req.invokeid = _invokeId; - assert(false); -} - -void SpatialAudio::invoke(const InvokeRequest& req) { - _invokeId = req.invokeid; - - if (req.src.length() > 0) { - URL scriptUrl(req.src); - if (!scriptUrl.toAbsolute(_interpreter->getBaseURI())) { - LOG(ERROR) << "Source attribute for audio invoker has relative URI " << req.src << " with no base URI set for interpreter"; - return; - } - - _dataStream << scriptUrl; - } - - getPosFromParams(req.params, _pos); - - std::multimap::const_iterator paramIter = req.params.begin(); - while(paramIter != req.params.end()) { - if (boost::iequals(paramIter->first, "maxX")) - _maxPos[0] = strTo(paramIter->second); - if (boost::iequals(paramIter->first, "maxY")) - _maxPos[1] = strTo(paramIter->second); - if (boost::iequals(paramIter->first, "maxZ")) - _maxPos[2] = strTo(paramIter->second); - paramIter++; - } - - struct miles_audio_device_description *devices; - int ndevs; - - ndevs = miles_audio_device_get_supported_devices(MILES_AUDIO_IO_OPENAL, &devices); - - for (int i = 0; i < ndevs; i++) { - if ((devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_SPATIAL) && - (devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_OUTPUT)) { - _audioDevIndex = i; - break; - } - } -} - -void SpatialAudio::getPosFromParams(const std::multimap& params, float* position) { - // vector explicitly given - try { - if (params.find("x") != params.end()) - position[0] = boost::lexical_cast(params.find("x")->second); - if (params.find("y") != params.end()) - position[1] = boost::lexical_cast(params.find("y")->second); - if (params.find("z") != params.end()) - position[2] = boost::lexical_cast(params.find("z")->second); - } catch (boost::bad_lexical_cast& e) { - LOG(ERROR) << "Cannot interpret x, y or z as float value in params: " << e.what(); - } - - try { - // right is an alias for x - if (params.find("right") != params.end()) - position[0] = boost::lexical_cast(params.find("right")->second); - // height is an alias for y - if (params.find("height") != params.end()) - position[1] = boost::lexical_cast(params.find("height")->second); - // front is an alias for z - if (params.find("front") != params.end()) - position[2] = boost::lexical_cast(params.find("front")->second); - } catch (boost::bad_lexical_cast& e) { - LOG(ERROR) << "Cannot interpret right, height or front as float value in params: " << e.what(); - } - - // do we have a position on a circle? - try { - if (params.find("circle") != params.end()) { - float rad = posToRadian(params.find("circle")->second); - position[0] = cosf(rad); - position[2] = -1 * sinf(rad); // z axis increases to front - } - } catch (boost::bad_lexical_cast& e) { - LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what(); - } - - position[0] = position[0] / _maxPos[0]; - position[1] = position[1] / _maxPos[1]; - position[2] = position[2] / _maxPos[2]; -// std::cout << _pos[0] << ":" << _pos[1] << ":" << _pos[2] << std::endl; - -} - -float SpatialAudio::posToRadian(const std::string& pos) { - - std::string trimmedPos = boost::trim_copy(pos); - float rad = 0; - - if (trimmedPos.size() > 3 && boost::iequals("deg", trimmedPos.substr(trimmedPos.length() - 3, 3))) { - rad = boost::lexical_cast(trimmedPos.substr(0, trimmedPos.size() - 3)); - rad = fmodf(rad, 360); // into range [0-360] - rad /= 180; // into range [0-2] - rad *= M_PI; // into range [0-2PI] - rad -= M_PI_2; // 0 to top; - rad *= -1; // make clockwise - rad += 2 * M_PI; // make positive - } else if (trimmedPos.size() > 3 && boost::iequals("rad", trimmedPos.substr(trimmedPos.length() - 3, 3))) { - rad = boost::lexical_cast(trimmedPos.substr(0, trimmedPos.size() - 3)); - rad = fmodf(rad, M_PI * 2); // into range [0-2*PI] - } else { - LOG(ERROR) << "Cannot make sense of position value " << trimmedPos << ": does not end in 'deg', 'rad'"; - } - return rad; -} - -} \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old new file mode 100644 index 0000000..9a26960 --- /dev/null +++ b/src/uscxml/plugins/invoker/miles/SpatialAudio.cpp.old @@ -0,0 +1,220 @@ +#include "uscxml/Common.h" +#include "SpatialAudio.h" +#include "uscxml/Interpreter.h" +#include "uscxml/URL.h" + +#include + +#ifdef _WIN32 +#define _USE_MATH_DEFINES +#endif +#include + +namespace uscxml { + +#ifdef BUILD_AS_PLUGINS +PLUMA_CONNECTOR +bool connect(pluma::Host& host) { + host.add( new SpatialAudioProvider() ); + return true; +} +#endif + +SpatialAudio::SpatialAudio() { + _audioDevOpen = false; + _audioDev = NULL; + _audioDevIndex = -1; + _pos = new float[3]; + _pos[0] = _pos[1] = _pos[2] = 0.0; + _listener = new float[3]; + _listener[0] = _listener[1] = _listener[2] = 0.0; + _maxPos = new float[3]; + _maxPos[0] = _maxPos[1] = _maxPos[2] = 1.0; + miles_init(); +} + +SpatialAudio::~SpatialAudio() { +}; + +boost::shared_ptr SpatialAudio::create(InterpreterImpl* interpreter) { + boost::shared_ptr invoker = boost::shared_ptr(new SpatialAudio()); + invoker->_interpreter = interpreter; + return invoker; +} + +Data SpatialAudio::getDataModelVariables() { + Data data; +// data.compound["foo"] = Data("32"); + return data; +} + +void SpatialAudio::send(const SendRequest& req) { + if (!_audioDevOpen) { + _audioDev = miles_audio_device_open(MILES_AUDIO_IO_OPENAL, _audioDevIndex, 0, 22050, 2, 1, 1024, false); + if (_audioDev != NULL) { + _audioDevOpen = true; +// float rolloffFactor = 1.0; +// miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_ROLLOFF_FACTOR, &rolloffFactor); + } + } + + if (boost::iequals(req.name, "play")) { + if (_audioDevOpen) { + getPosFromParams(req.params, _pos); + +// std::cout << "Source: "; +// for (int i = 0; i < 3; i++) { +// std::cout << _pos[i] << " "; +// } +// std::cout << std::endl; + + miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_POSITION, _pos); + + + char* buffer = (char*)malloc(_audioDev->chunk_size); + // skip wav header + _dataStream.seekg(44); + + while(_dataStream.readsome(buffer, _audioDev->chunk_size) != 0) { + int written = 0; + while(written < _audioDev->chunk_size) { + written += miles_audio_device_write(MILES_AUDIO_IO_OPENAL, _audioDev, buffer + written, _audioDev->chunk_size - written); + tthread::this_thread::sleep_for(tthread::chrono::milliseconds(10)); + } + } + _dataStream.seekg(0); + free(buffer); + } + } else if (boost::iequals(req.name, "move.listener")) { + if (_audioDevOpen) { + getPosFromParams(req.params, _listener); + +// std::cout << "Listener: "; +// for (int i = 0; i < 3; i++) { +// std::cout << _listener[i] << " "; +// } +// std::cout << std::endl; + + miles_audio_device_control(MILES_AUDIO_IO_OPENAL, _audioDev, MILES_AUDIO_DEVICE_CTRL_SET_LISTENER_POS, _listener); + + } + } +} + +void SpatialAudio::cancel(const std::string sendId) { + assert(false); +} + +void SpatialAudio::sendToParent(SendRequest& req) { + req.invokeid = _invokeId; + assert(false); +} + +void SpatialAudio::invoke(const InvokeRequest& req) { + _invokeId = req.invokeid; + + if (req.src.length() > 0) { + URL scriptUrl(req.src); + if (!scriptUrl.toAbsolute(_interpreter->getBaseURI())) { + LOG(ERROR) << "Source attribute for audio invoker has relative URI " << req.src << " with no base URI set for interpreter"; + return; + } + + _dataStream << scriptUrl; + } + + getPosFromParams(req.params, _pos); + + std::multimap::const_iterator paramIter = req.params.begin(); + while(paramIter != req.params.end()) { + if (boost::iequals(paramIter->first, "maxX")) + _maxPos[0] = strTo(paramIter->second); + if (boost::iequals(paramIter->first, "maxY")) + _maxPos[1] = strTo(paramIter->second); + if (boost::iequals(paramIter->first, "maxZ")) + _maxPos[2] = strTo(paramIter->second); + paramIter++; + } + + struct miles_audio_device_description *devices; + int ndevs; + + ndevs = miles_audio_device_get_supported_devices(MILES_AUDIO_IO_OPENAL, &devices); + + for (int i = 0; i < ndevs; i++) { + if ((devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_SPATIAL) && + (devices[i].capabilities & MILES_AUDIO_DEVICE_CAPABILITY_OUTPUT)) { + _audioDevIndex = i; + break; + } + } +} + +void SpatialAudio::getPosFromParams(const std::multimap& params, float* position) { + // vector explicitly given + try { + if (params.find("x") != params.end()) + position[0] = boost::lexical_cast(params.find("x")->second); + if (params.find("y") != params.end()) + position[1] = boost::lexical_cast(params.find("y")->second); + if (params.find("z") != params.end()) + position[2] = boost::lexical_cast(params.find("z")->second); + } catch (boost::bad_lexical_cast& e) { + LOG(ERROR) << "Cannot interpret x, y or z as float value in params: " << e.what(); + } + + try { + // right is an alias for x + if (params.find("right") != params.end()) + position[0] = boost::lexical_cast(params.find("right")->second); + // height is an alias for y + if (params.find("height") != params.end()) + position[1] = boost::lexical_cast(params.find("height")->second); + // front is an alias for z + if (params.find("front") != params.end()) + position[2] = boost::lexical_cast(params.find("front")->second); + } catch (boost::bad_lexical_cast& e) { + LOG(ERROR) << "Cannot interpret right, height or front as float value in params: " << e.what(); + } + + // do we have a position on a circle? + try { + if (params.find("circle") != params.end()) { + float rad = posToRadian(params.find("circle")->second); + position[0] = cosf(rad); + position[2] = -1 * sinf(rad); // z axis increases to front + } + } catch (boost::bad_lexical_cast& e) { + LOG(ERROR) << "Cannot interpret circle as float value in params: " << e.what(); + } + + position[0] = position[0] / _maxPos[0]; + position[1] = position[1] / _maxPos[1]; + position[2] = position[2] / _maxPos[2]; +// std::cout << _pos[0] << ":" << _pos[1] << ":" << _pos[2] << std::endl; + +} + +float SpatialAudio::posToRadian(const std::string& pos) { + + std::string trimmedPos = boost::trim_copy(pos); + float rad = 0; + + if (trimmedPos.size() > 3 && boost::iequals("deg", trimmedPos.substr(trimmedPos.length() - 3, 3))) { + rad = boost::lexical_cast(trimmedPos.substr(0, trimmedPos.size() - 3)); + rad = fmodf(rad, 360); // into range [0-360] + rad /= 180; // into range [0-2] + rad *= M_PI; // into range [0-2PI] + rad -= M_PI_2; // 0 to top; + rad *= -1; // make clockwise + rad += 2 * M_PI; // make positive + } else if (trimmedPos.size() > 3 && boost::iequals("rad", trimmedPos.substr(trimmedPos.length() - 3, 3))) { + rad = boost::lexical_cast(trimmedPos.substr(0, trimmedPos.size() - 3)); + rad = fmodf(rad, M_PI * 2); // into range [0-2*PI] + } else { + LOG(ERROR) << "Cannot make sense of position value " << trimmedPos << ": does not end in 'deg', 'rad'"; + } + return rad; +} + +} \ No newline at end of file diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.h b/src/uscxml/plugins/invoker/miles/SpatialAudio.h deleted file mode 100644 index e7ab830..0000000 --- a/src/uscxml/plugins/invoker/miles/SpatialAudio.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef SPATIALAUDIO_H_EH11SAQC -#define SPATIALAUDIO_H_EH11SAQC - -#include -#include - -extern "C" { -#include "miles/audio_device.h" -#include "miles/audio_codec.h" -#include "miles/audio_io.h" -#include "miles/miles.h" -} - -namespace uscxml { - -class SpatialAudio : public InvokerImpl { -public: - SpatialAudio(); - virtual ~SpatialAudio(); - virtual boost::shared_ptr create(InterpreterImpl* interpreter); - - virtual std::set getNames() { - std::set names; - names.insert("spatial-audio"); - names.insert("audio"); - names.insert("http://www.smartvortex.eu/mmi/spatial-audio"); - names.insert("http://www.smartvortex.eu/mmi/spatial-audio/"); - return names; - } - - virtual Data getDataModelVariables(); - virtual void send(const SendRequest& req); - virtual void cancel(const std::string sendId); - virtual void invoke(const InvokeRequest& req); - virtual void sendToParent(SendRequest& req); - - void getPosFromParams(const std::multimap& params, float* position); - static float posToRadian(const std::string& position); - -protected: - std::string _invokeId; - Interpreter* _invokedInterpreter; - - std::stringstream _dataStream; - - float* _pos; - float* _listener; - float* _maxPos; - bool _audioDevOpen; - int _audioDevIndex; - struct miles_audio_device* _audioDev; - -}; - -} - -#endif /* end of include guard: SPATIALAUDIO_H_EH11SAQC */ diff --git a/src/uscxml/plugins/invoker/miles/SpatialAudio.h.old b/src/uscxml/plugins/invoker/miles/SpatialAudio.h.old new file mode 100644 index 0000000..e7ab830 --- /dev/null +++ b/src/uscxml/plugins/invoker/miles/SpatialAudio.h.old @@ -0,0 +1,57 @@ +#ifndef SPATIALAUDIO_H_EH11SAQC +#define SPATIALAUDIO_H_EH11SAQC + +#include +#include + +extern "C" { +#include "miles/audio_device.h" +#include "miles/audio_codec.h" +#include "miles/audio_io.h" +#include "miles/miles.h" +} + +namespace uscxml { + +class SpatialAudio : public InvokerImpl { +public: + SpatialAudio(); + virtual ~SpatialAudio(); + virtual boost::shared_ptr create(InterpreterImpl* interpreter); + + virtual std::set getNames() { + std::set names; + names.insert("spatial-audio"); + names.insert("audio"); + names.insert("http://www.smartvortex.eu/mmi/spatial-audio"); + names.insert("http://www.smartvortex.eu/mmi/spatial-audio/"); + return names; + } + + virtual Data getDataModelVariables(); + virtual void send(const SendRequest& req); + virtual void cancel(const std::string sendId); + virtual void invoke(const InvokeRequest& req); + virtual void sendToParent(SendRequest& req); + + void getPosFromParams(const std::multimap& params, float* position); + static float posToRadian(const std::string& position); + +protected: + std::string _invokeId; + Interpreter* _invokedInterpreter; + + std::stringstream _dataStream; + + float* _pos; + float* _listener; + float* _maxPos; + bool _audioDevOpen; + int _audioDevIndex; + struct miles_audio_device* _audioDev; + +}; + +} + +#endif /* end of include guard: SPATIALAUDIO_H_EH11SAQC */ diff --git a/src/uscxml/plugins/ioprocessor/CMakeLists.txt b/src/uscxml/plugins/ioprocessor/CMakeLists.txt index 8f124ed..bcab37c 100644 --- a/src/uscxml/plugins/ioprocessor/CMakeLists.txt +++ b/src/uscxml/plugins/ioprocessor/CMakeLists.txt @@ -3,8 +3,8 @@ file(GLOB_RECURSE SAMPLE_IOPROCESSOR sample/*.cpp sample/*.h ) -source_group("IOProcessor\\sample" FILES ${SAMPLE_IOPROCESSOR}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${SAMPLE_IOPROCESSOR}) add_library( ioprocessor_sample SHARED ${SAMPLE_IOPROCESSOR}) @@ -19,8 +19,8 @@ file(GLOB_RECURSE COMET_IOPROCESSOR comet/*.cpp comet/*.h ) -source_group("IOProcessor\\comet" FILES ${COMET_IOPROCESSOR}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${COMET_IOPROCESSOR}) add_library( ioprocessor_comet SHARED ${COMET_IOPROCESSOR}) @@ -38,8 +38,8 @@ file(GLOB_RECURSE BASICHTTP_IOPROCESSOR basichttp/*.cpp basichttp/*.h ) -source_group("IOProcessor\\basichttp" FILES ${BASICHTTP_IOPROCESSOR}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${BASICHTTP_IOPROCESSOR}) add_library( ioprocessor_basichttp SHARED ${BASICHTTP_IOPROCESSOR}) @@ -57,12 +57,13 @@ file(GLOB_RECURSE SCXML_IOPROCESSOR scxml/*.cpp scxml/*.h ) -source_group("IOProcessor\\scxml" FILES ${SCXML_IOPROCESSOR}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${SCXML_IOPROCESSOR}) add_library( ioprocessor_scxml SHARED ${SCXML_IOPROCESSOR}) - target_link_libraries(ioprocessor_scxml uscxml) + # scxml ioprocessor is a basichttp ioprocessor + target_link_libraries(ioprocessor_scxml ioprocessor_basichttp uscxml) set_target_properties(ioprocessor_scxml PROPERTIES FOLDER "Plugin IOProcessor") else() list (APPEND USCXML_FILES ${SCXML_IOPROCESSOR}) @@ -71,7 +72,7 @@ endif() # mmi ioprocessor -if (PROTOBUF_FOUND) +if (PROTOBUF_FOUND AND OFF) if (NOT PROTOBUF_PROTOC_EXECUTABLE) message(FATAL_ERROR "protoc binary required for serialization") @@ -94,8 +95,8 @@ if (PROTOBUF_FOUND) add_library(mmi_proto STATIC ${PROTO_SRCS}) set_target_properties(mmi_proto PROPERTIES FOLDER "Generated") - source_group("IOProcessor\\modality" FILES ${MMI_IOPROCESSOR}) if (BUILD_AS_PLUGINS) + source_group("" FILES ${MMI_IOPROCESSOR}) add_library( ioprocessor_mmi SHARED ${MMI_IOPROCESSOR}) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4fba8a5..261817b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -64,13 +64,17 @@ if (NOT WIN32) set_target_properties(test-arabica-parsing PROPERTIES FOLDER "Tests") add_executable(test-stress src/test-stress.cpp) - target_link_libraries(test-stress uscxml) + if (BUILD_AS_PLUGINS) + target_link_libraries(test-stress uscxml invoker_dirmon) + else() + target_link_libraries(test-stress uscxml) + endif() add_test(test-stress ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-stress ${CMAKE_SOURCE_DIR}/test/samples/w3c) set_target_properties(test-stress PROPERTIES FOLDER "Tests") if (LIBPURPLE_FOUND) add_executable(test-instant-messaging src/test-instant-messaging.cpp) - target_link_libraries(test-instant-messaging uscxml) + target_link_libraries(test-instant-messaging uscxml ${LIBPURPLE_LIBRARY} ${GLIB2_LIBRARIES} ${ICONV_LIBRARIES}) add_test(test-instant-messaging ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/test-instant-messaging) set_target_properties(test-instant-messaging PROPERTIES FOLDER "Tests") endif() -- cgit v0.12