[Orxonox-commit 4881] r9550 - in code/trunk: . cmake/tools src src/external src/libraries/core src/libraries/core/command src/libraries/core/input src/libraries/network src/libraries/tools src/libraries/util src/libraries/util/output src/modules/notifications/dispatchers src/orxonox src/orxonox/graphics src/orxonox/overlays
landauf at orxonox.net
landauf at orxonox.net
Tue Mar 12 23:13:04 CET 2013
Author: landauf
Date: 2013-03-12 23:13:03 +0100 (Tue, 12 Mar 2013)
New Revision: 9550
Added:
code/trunk/src/SourceConfig.cmake
code/trunk/src/external/gmock/
code/trunk/src/external/gtest/
code/trunk/src/libraries/util/output/AdditionalContextListener.h
code/trunk/src/template.vcproj.user.in
code/trunk/src/template.vcxproj.user.in
code/trunk/test/
Removed:
code/trunk/src/orxonox-main.vcproj.user.in
code/trunk/src/orxonox-main.vcxproj.user.in
Modified:
code/trunk/
code/trunk/CMakeLists.txt
code/trunk/cmake/tools/TargetUtilities.cmake
code/trunk/src/CMakeLists.txt
code/trunk/src/external/CMakeLists.txt
code/trunk/src/libraries/core/CommandLineParser.cc
code/trunk/src/libraries/core/CommandLineParser.h
code/trunk/src/libraries/core/ConfigValueContainer.cc
code/trunk/src/libraries/core/Core.cc
code/trunk/src/libraries/core/PathConfig.cc
code/trunk/src/libraries/core/command/CommandEvaluation.cc
code/trunk/src/libraries/core/command/CommandExecutor.cc
code/trunk/src/libraries/core/command/ConsoleCommand.h
code/trunk/src/libraries/core/command/Executor.cc
code/trunk/src/libraries/core/command/Executor.h
code/trunk/src/libraries/core/command/Functor.h
code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
code/trunk/src/libraries/core/command/IOConsoleWindows.cc
code/trunk/src/libraries/core/command/Shell.cc
code/trunk/src/libraries/core/command/TclBind.cc
code/trunk/src/libraries/core/input/InputManager.cc
code/trunk/src/libraries/network/Client.cc
code/trunk/src/libraries/tools/Shader.cc
code/trunk/src/libraries/tools/Shader.h
code/trunk/src/libraries/util/Math.h
code/trunk/src/libraries/util/MultiType.cc
code/trunk/src/libraries/util/MultiType.h
code/trunk/src/libraries/util/MultiTypeValue.h
code/trunk/src/libraries/util/SignalHandler.cc
code/trunk/src/libraries/util/SignalHandler.h
code/trunk/src/libraries/util/StringUtils.cc
code/trunk/src/libraries/util/StringUtils.h
code/trunk/src/libraries/util/SubString.cc
code/trunk/src/libraries/util/SubString.h
code/trunk/src/libraries/util/UtilPrereqs.h
code/trunk/src/libraries/util/VA_NARGS.h
code/trunk/src/libraries/util/output/ConsoleWriter.cc
code/trunk/src/libraries/util/output/ConsoleWriter.h
code/trunk/src/libraries/util/output/LogWriter.cc
code/trunk/src/libraries/util/output/LogWriter.h
code/trunk/src/libraries/util/output/MemoryWriter.cc
code/trunk/src/libraries/util/output/MemoryWriter.h
code/trunk/src/libraries/util/output/OutputDefinitions.h
code/trunk/src/libraries/util/output/OutputListener.cc
code/trunk/src/libraries/util/output/OutputListener.h
code/trunk/src/libraries/util/output/OutputManager.cc
code/trunk/src/libraries/util/output/OutputManager.h
code/trunk/src/libraries/util/output/OutputStream.h
code/trunk/src/libraries/util/output/SubcontextOutputListener.h
code/trunk/src/modules/notifications/dispatchers/CommandNotification.cc
code/trunk/src/orxonox/LevelManager.cc
code/trunk/src/orxonox/Main.cc
code/trunk/src/orxonox/graphics/ParticleEmitter.cc
code/trunk/src/orxonox/overlays/InGameConsole.cc
Log:
merged testing branch back to trunk. unbelievable it took me 13 months to finish this chore...
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/Racingbot:9388-9513
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationHS12:9481-9525
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/steering:5949-6091,8140-8595
/code/branches/surfaceRace:9028-9199
/code/branches/tetris:8100-8563
/code/branches/turret:9380-9501
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
+ /code/branches/Racingbot:9388-9513
/code/branches/ai:6592-7033
/code/branches/ai2:8721-8880
/code/branches/bigships:8137-8588
/code/branches/buildsystem:1874-2276,2278-2400
/code/branches/buildsystem2:2506-2658
/code/branches/buildsystem3:2662-2708
/code/branches/ceguilua:1802-1808
/code/branches/chat:6527-6797
/code/branches/chat2:6836-6910
/code/branches/console:5941-6104
/code/branches/consolecommands2:6451-7178
/code/branches/consolecommands3:7178-7283
/code/branches/core3:1572-1739
/code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
/code/branches/core5:5768-5928,6009
/code/branches/data_cleanup:7537-7686
/code/branches/doc:7290-7400
/code/branches/dockingsystem:8101-8192
/code/branches/dockingsystem2:8196-8560
/code/branches/dynamicmatch:6584-7030
/code/branches/environment3:8887-8975
/code/branches/formation:8885-8991
/code/branches/fps:6591-7072
/code/branches/gamecontent:8893-8968
/code/branches/gameimmersion:8102-8577
/code/branches/gamestate:6430-6572,6621-6661
/code/branches/gamestates2:6594-6745
/code/branches/gametypes:2826-3031
/code/branches/gcc43:1580
/code/branches/gui:1635-1723,2795-2894
/code/branches/hud:8883-8986
/code/branches/hudelements:6584-6941
/code/branches/hudimprovements:7920-8672
/code/branches/ingamemenu:6000-6023
/code/branches/input:1629-1636
/code/branches/ipv6:7293-7458
/code/branches/kicklib:7940-8096,8098-8277
/code/branches/kicklib2:8282-8350
/code/branches/largeShip1:9384-9515
/code/branches/lastmanstanding:7479-7644
/code/branches/lastmanstanding3:7903-8175
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/lod:6586-6911
/code/branches/lodfinal:2372-2411
/code/branches/mac_osx:7789-8128,8135
/code/branches/map:2801-3086,3089
/code/branches/masterserver:7502-7738
/code/branches/masterserverfix:8933-8936
/code/branches/menu:5941-6146,6148,7536-7687
/code/branches/menue:8884-8976
/code/branches/miniprojects:2754-2824
/code/branches/netp2:2835-2988
/code/branches/netp3:2988-3082
/code/branches/netp6:3214-3302
/code/branches/network:2356
/code/branches/network2:6434-6465
/code/branches/network3:7196-7344
/code/branches/network4:7497-7755
/code/branches/network5:7757-7781
/code/branches/network6:7823-8315
/code/branches/network64:2210-2355
/code/branches/newlevel2012:9033-9244
/code/branches/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/output:8739-8857
/code/branches/overlay:2117-2385
/code/branches/pCuts:9023-9284
/code/branches/particles:2829-3085
/code/branches/particles2:6050-6106,6109
/code/branches/pch:3113-3194
/code/branches/physics:1912-2055,2107-2439
/code/branches/physics_merge:2436-2457
/code/branches/pickup:8145-8555
/code/branches/pickup2:5942-6405
/code/branches/pickup2012:9029-9189
/code/branches/pickup3:6418-6523
/code/branches/pickup4:6594-6710
/code/branches/pickups:1926-2086,2127,2827-2915
/code/branches/pickups2:2107-2497,2915-3071
/code/branches/png2:7262-7263
/code/branches/portals:8087-8455
/code/branches/portals2:8460-8602
/code/branches/ppspickups1:6552-6708
/code/branches/ppspickups2:6527-6532,6554-6709
/code/branches/ppspickups3:6757-6997
/code/branches/ppspickups4:7003-7089
/code/branches/presentation:2369-2652,2654-2660,7736-7786,8500-8705
/code/branches/presentation2:6106-6416,7787-7800
/code/branches/presentation2011:8974-9015
/code/branches/presentation2012:9189-9268
/code/branches/presentation2012merge:9266-9347
/code/branches/presentation3:6913-7162
/code/branches/presentationHS12:9481-9525
/code/branches/questsystem:1894-2088
/code/branches/questsystem2:2107-2259
/code/branches/questsystem5:2776-2905
/code/branches/releasetodo:7614-7647
/code/branches/resource:3327-3366
/code/branches/resource2:3372-5694
/code/branches/rocket:6523-6950
/code/branches/rocket2:6953-6970
/code/branches/script_trigger:1295-1953,1955
/code/branches/shipSelection:9038-9206
/code/branches/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound2012:9205-9214
/code/branches/sound3:5941-6102
/code/branches/spaceNavigation:9381-9497
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/spaceraceTwo:8881-8996
/code/branches/steering:5949-6091,8140-8595
/code/branches/surfaceRace:9028-9199
/code/branches/testing:9015-9549
/code/branches/tetris:8100-8563
/code/branches/turret:9380-9501
/code/branches/tutoriallevel:7827-8370
/code/branches/tutoriallevel2:8370-8452
/code/branches/tutoriallevel3:8453-8636
/code/branches/unity_build:8440-8716
/code/branches/usability:7915-8078
/code/branches/weapon:1925-2094
/code/branches/weapon2:2107-2488
/code/branches/weapons:2897-3051,8143-8591
/code/branches/weaponsystem:2742-2890
Modified: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/CMakeLists.txt 2013-03-12 22:13:03 UTC (rev 9550)
@@ -160,6 +160,9 @@
# Create the actual project
ADD_SUBDIRECTORY(src)
+# Create the test suites
+ADD_SUBDIRECTORY(test)
+
# Configure the binary output directory. Do this after src!
ADD_SUBDIRECTORY(bin)
Modified: code/trunk/cmake/tools/TargetUtilities.cmake
===================================================================
--- code/trunk/cmake/tools/TargetUtilities.cmake 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/cmake/tools/TargetUtilities.cmake 2013-03-12 22:13:03 UTC (rev 9550)
@@ -81,6 +81,23 @@
MACRO(ORXONOX_ADD_EXECUTABLE _target_name)
TU_ADD_TARGET(${_target_name} EXECUTABLE "WIN32" ${ARGN})
+
+ # When using Visual Studio we want to use the output directory as working
+ # directory and we also want to specify where the external dlls
+ # (lua, ogre, etc.) are. The problem hereby is that these information cannot
+ # be specified in CMake because they are not stored in the actual project file.
+ # This workaround will create a configured *.vcproj.user file that holds the
+ # right values. When starting the solution for the first time,
+ # these get written to the *vcproj.yourPCname.yourname.user
+ IF(MSVC)
+ IF(MSVC10)
+ CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/src/template.vcxproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/${_target_name}.vcxproj.user")
+ ELSE()
+ STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?).*$" "\\1"
+ VISUAL_STUDIO_VERSION_SIMPLE "${CMAKE_GENERATOR}")
+ CONFIGURE_FILE("${CMAKE_SOURCE_DIR}/src/template.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/${_target_name}.vcproj.user")
+ ENDIF()
+ ENDIF(MSVC)
ENDMACRO(ORXONOX_ADD_EXECUTABLE)
@@ -333,6 +350,13 @@
TARGET_LINK_LIBRARIES(${_target_name} ${_arg_LINK_LIBS_UNIX})
ENDIF()
+ # Enable gcov (gcc code coverage analysis tool) if ENABLE_GCOV flag is defined
+ IF(ENABLE_GCOV)
+ TARGET_LINK_LIBRARIES(${_target_name} gcov)
+ ADD_COMPILER_FLAGS("-fprofile-arcs")
+ ADD_COMPILER_FLAGS("-ftest-coverage")
+ ENDIF()
+
# Visual Leak Detector specific stuff (avoids the include)
IF(VISUAL_LEAK_DETECTOR_ENABLE)
TARGET_LINK_LIBRARIES(${_target_name} debug ${VLD_LIBRARY})
Modified: code/trunk/src/CMakeLists.txt
===================================================================
--- code/trunk/src/CMakeLists.txt 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/CMakeLists.txt 2013-03-12 22:13:03 UTC (rev 9550)
@@ -27,127 +27,11 @@
INCLUDE(FlagUtilities)
INCLUDE(TargetUtilities)
+INCLUDE(SourceConfig.cmake)
+
# Configure the two headers and set some options
INCLUDE(OrxonoxConfig.cmake)
-####### Library Behaviour (dependencies) ########
-
-# Disable auto linking completely for Boost and POCO
-ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
-ADD_COMPILER_FLAGS("-DPOCO_NO_AUTOMATIC_LIBS")
-
-IF(WIN32)
- # If no defines are specified, these libs get linked statically
- ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" LINK_BOOST_DYNAMIC)
- #ADD_COMPILER_FLAGS("-DENET_DLL" LINK_ENET_DYNAMIC)
- ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" LINK_LUA5.1_DYNAMIC)
- # If no defines are specified, these libs get linked dynamically
- ADD_COMPILER_FLAGS("-DCEGUI_STATIC -DTOLUA_STATIC" NOT LINK_CEGUI_DYNAMIC)
- ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" NOT LINK_OGRE_DYNAMIC)
- ADD_COMPILER_FLAGS("-DSTATIC_BUILD" NOT LINK_TCL_DYNAMIC)
-
- # Target Windows XP as minimum Windows version
- # And try to catch all the different macro defines for that...
- ADD_COMPILER_FLAGS("-D_WIN32_WINNT=0x0501")
- ADD_COMPILER_FLAGS("-D_WIN32_WINDOWS=0x0501")
- ADD_COMPILER_FLAGS("-DWINVER=0x0501")
- ADD_COMPILER_FLAGS("-DNTDDI_VERSION=0x05010000")
-ENDIF(WIN32)
-
-# Visual Leak Dectector configuration
-IF(MSVC AND VLD_FOUND)
- OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" OFF)
- IF(VISUAL_LEAK_DETECTOR_ENABLE)
- # Force library linking by forcing the inclusion of a symbol
- ADD_LINKER_FLAGS("-INCLUDE:__imp_?vld@@3VVisualLeakDetector@@A" Debug)
- IF(MSVC90)
- # VS 2008 incremental linker crashes with /INCLUDE most of the time
- REMOVE_LINKER_FLAGS("-INCREMENTAL:YES" Debug)
- ADD_LINKER_FLAGS ("-INCREMENTAL:NO" Debug)
- ENDIF()
- ENDIF()
-ENDIF()
-
-######### Library Behaviour (external) ##########
-
-# Use TinyXML++
-ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP")
-
-# Default linking for externals
-IF(CMAKE_BUILD_TYPE MATCHES "(Debug|RelForDevs)")
- SET(_default_link_mode "SHARED")
-ELSE()
- SET(_default_link_mode "STATIC")
-ENDIF()
-SET(_message "Link mode for external libraries that we build ourselves.
-MSVC Note: certain libraries will not be linked shared.")
-SET(ORXONOX_EXTERNAL_LINK_MODE "${_default_link_mode}" CACHE STRING "${_message}")
-
-IF(ORXONOX_EXTERNAL_LINK_MODE STREQUAL "SHARED")
- SET(_external_shared_link TRUE)
-ELSE()
- SET(_external_shared_link FALSE)
-ENDIF()
-# If no defines are specified, these libs get linked dynamically
-ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 _external_shared_link)
-ADD_COMPILER_FLAGS("-DOGRE_GUIRENDERER_STATIC_LIB" WIN32 NOT _external_shared_link)
-ADD_COMPILER_FLAGS("-DOIS_STATIC_LIB" WIN32 NOT _external_shared_link)
-
-############## Include Directories ##############
-
-# Set the search paths for include files
-INCLUDE_DIRECTORIES(
- # OrxonoxConfig.h
- ${CMAKE_CURRENT_BINARY_DIR}
-
- # All includes in "externals" should be prefixed with the path
- # relative to "external" to avoid conflicts
- ${CMAKE_CURRENT_SOURCE_DIR}/external
- # Include directories needed even if only included by Orxonox
- ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet
- ${CMAKE_CURRENT_SOURCE_DIR}/external/ois
-
- # External
- ${OGRE_INCLUDE_DIR}
- ${CEGUI_INCLUDE_DIR}
- ${CEGUI_TOLUA_INCLUDE_DIR}
- #${ENET_INCLUDE_DIR}
- ${Boost_INCLUDE_DIRS}
- ${POCO_INCLUDE_DIR}
- ${OPENAL_INCLUDE_DIRS}
- ${ALUT_INCLUDE_DIR}
- ${VORBIS_INCLUDE_DIR}
- ${OGG_INCLUDE_DIR}
- ${LUA5.1_INCLUDE_DIR}
- ${TCL_INCLUDE_PATH}
- ${DIRECTX_INCLUDE_DIR}
- ${ZLIB_INCLUDE_DIR}
-)
-
-IF(CEGUI_OLD_VERSION)
- INCLUDE_DIRECTORIES(${CEGUILUA_INCLUDE_DIR})
-ENDIF()
-
-IF (DBGHELP_FOUND)
- INCLUDE_DIRECTORIES(${DBGHELP_INCLUDE_DIR})
-ENDIF()
-
-IF(VISUAL_LEAK_DETECTOR_ENABLE)
- INCLUDE_DIRECTORIES(${VLD_INCLUDE_DIR})
-ENDIF()
-
-############## CEGUI OGRE Renderer ##############
-
-IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
- SET(CEGUI_OGRE_RENDERER_LIBRARY ogreceguirenderer_orxonox)
-ENDIF()
-
-################### Tolua Bind ##################
-
-# Add hook script to the lua code that generates the bindings
-SET(TOLUA_PARSER_HOOK_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/ToluaInterfaceHook.lua)
-SET(TOLUA_PARSER_DEPENDENCIES ${TOLUA_PARSER_DEPENDENCIES} ${TOLUA_PARSER_HOOK_SCRIPT})
-
################ Sub Directories ################
ADD_SUBDIRECTORY(external)
@@ -193,26 +77,12 @@
SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE INTERNAL "")
-# When using Visual Studio we want to use the output directory as working
-# directory and we also want to specify where the external dlls
-# (lua, ogre, etc.) are. The problem hereby is that these information cannot
-# be specified in CMake because they are not stored in the actual project file.
-# This workaround will create a configured *.vcproj.user file that holds the
-# right values. When starting the solution for the first time,
-# these get written to the *vcproj.yourPCname.yourname.user
IF(MSVC)
IF(CMAKE_CL_64)
SET(MSVC_PLATFORM "x64")
ELSE()
SET(MSVC_PLATFORM "Win32")
ENDIF()
- IF(MSVC10)
- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcxproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcxproj.user")
- ELSE()
- STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?).*$" "\\1"
- VISUAL_STUDIO_VERSION_SIMPLE "${CMAKE_GENERATOR}")
- CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcproj.user")
- ENDIF()
ENDIF(MSVC)
# Apple Mac OS X specific build settings
Copied: code/trunk/src/SourceConfig.cmake (from rev 9549, code/branches/testing/src/SourceConfig.cmake)
===================================================================
--- code/trunk/src/SourceConfig.cmake (rev 0)
+++ code/trunk/src/SourceConfig.cmake 2013-03-12 22:13:03 UTC (rev 9550)
@@ -0,0 +1,145 @@
+ #
+ # ORXONOX - the hottest 3D action shooter ever to exist
+ # > www.orxonox.net <
+ #
+ # This program is free software; you can redistribute it and/or
+ # modify it under the terms of the GNU General Public License
+ # as published by the Free Software Foundation; either version 2
+ # of the License, or (at your option) any later version.
+ #
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ # GNU General Public License for more details.
+ #
+ # You should have received a copy of the GNU General Public License along
+ # with this program; if not, write to the Free Software Foundation,
+ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ #
+ #
+ # Author:
+ # Reto Grieder
+ # Description:
+ # Configures the compilers and sets build options.
+ #
+
+# Required macros and functions
+INCLUDE(FlagUtilities)
+
+####### Library Behaviour (dependencies) ########
+
+# Disable auto linking completely for Boost and POCO
+ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB")
+ADD_COMPILER_FLAGS("-DPOCO_NO_AUTOMATIC_LIBS")
+
+IF(WIN32)
+ # If no defines are specified, these libs get linked statically
+ ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" LINK_BOOST_DYNAMIC)
+ #ADD_COMPILER_FLAGS("-DENET_DLL" LINK_ENET_DYNAMIC)
+ ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" LINK_LUA5.1_DYNAMIC)
+ # If no defines are specified, these libs get linked dynamically
+ ADD_COMPILER_FLAGS("-DCEGUI_STATIC -DTOLUA_STATIC" NOT LINK_CEGUI_DYNAMIC)
+ ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" NOT LINK_OGRE_DYNAMIC)
+ ADD_COMPILER_FLAGS("-DSTATIC_BUILD" NOT LINK_TCL_DYNAMIC)
+
+ # Target Windows XP as minimum Windows version
+ # And try to catch all the different macro defines for that...
+ ADD_COMPILER_FLAGS("-D_WIN32_WINNT=0x0501")
+ ADD_COMPILER_FLAGS("-D_WIN32_WINDOWS=0x0501")
+ ADD_COMPILER_FLAGS("-DWINVER=0x0501")
+ ADD_COMPILER_FLAGS("-DNTDDI_VERSION=0x05010000")
+ENDIF(WIN32)
+
+# Visual Leak Dectector configuration
+IF(MSVC AND VLD_FOUND)
+ OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" OFF)
+ IF(VISUAL_LEAK_DETECTOR_ENABLE)
+ # Force library linking by forcing the inclusion of a symbol
+ ADD_LINKER_FLAGS("-INCLUDE:__imp_?vld@@3VVisualLeakDetector@@A" Debug)
+ IF(MSVC90)
+ # VS 2008 incremental linker crashes with /INCLUDE most of the time
+ REMOVE_LINKER_FLAGS("-INCREMENTAL:YES" Debug)
+ ADD_LINKER_FLAGS ("-INCREMENTAL:NO" Debug)
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+######### Library Behaviour (external) ##########
+
+# Use TinyXML++
+ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP")
+
+# Default linking for externals
+IF(CMAKE_BUILD_TYPE MATCHES "(Debug|RelForDevs)")
+ SET(_default_link_mode "SHARED")
+ELSE()
+ SET(_default_link_mode "STATIC")
+ENDIF()
+SET(_message "Link mode for external libraries that we build ourselves.
+MSVC Note: certain libraries will not be linked shared.")
+SET(ORXONOX_EXTERNAL_LINK_MODE "${_default_link_mode}" CACHE STRING "${_message}")
+
+IF(ORXONOX_EXTERNAL_LINK_MODE STREQUAL "SHARED")
+ SET(_external_shared_link TRUE)
+ELSE()
+ SET(_external_shared_link FALSE)
+ENDIF()
+# If no defines are specified, these libs get linked dynamically
+ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 _external_shared_link)
+ADD_COMPILER_FLAGS("-DOGRE_GUIRENDERER_STATIC_LIB" WIN32 NOT _external_shared_link)
+ADD_COMPILER_FLAGS("-DOIS_STATIC_LIB" WIN32 NOT _external_shared_link)
+
+############## Include Directories ##############
+
+# Set the search paths for include files
+INCLUDE_DIRECTORIES(
+ # OrxonoxConfig.h
+ ${CMAKE_CURRENT_BINARY_DIR}
+
+ # All includes in "externals" should be prefixed with the path
+ # relative to "external" to avoid conflicts
+ ${CMAKE_CURRENT_SOURCE_DIR}/external
+ # Include directories needed even if only included by Orxonox
+ ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet
+ ${CMAKE_CURRENT_SOURCE_DIR}/external/ois
+
+ # External
+ ${OGRE_INCLUDE_DIR}
+ ${CEGUI_INCLUDE_DIR}
+ ${CEGUI_TOLUA_INCLUDE_DIR}
+ #${ENET_INCLUDE_DIR}
+ ${Boost_INCLUDE_DIRS}
+ ${POCO_INCLUDE_DIR}
+ ${OPENAL_INCLUDE_DIRS}
+ ${ALUT_INCLUDE_DIR}
+ ${VORBIS_INCLUDE_DIR}
+ ${OGG_INCLUDE_DIR}
+ ${LUA5.1_INCLUDE_DIR}
+ ${TCL_INCLUDE_PATH}
+ ${DIRECTX_INCLUDE_DIR}
+ ${ZLIB_INCLUDE_DIR}
+)
+
+IF(CEGUI_OLD_VERSION)
+ INCLUDE_DIRECTORIES(${CEGUILUA_INCLUDE_DIR})
+ENDIF()
+
+IF (DBGHELP_FOUND)
+ INCLUDE_DIRECTORIES(${DBGHELP_INCLUDE_DIR})
+ENDIF()
+
+IF(VISUAL_LEAK_DETECTOR_ENABLE)
+ INCLUDE_DIRECTORIES(${VLD_INCLUDE_DIR})
+ENDIF()
+
+############## CEGUI OGRE Renderer ##############
+
+IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
+ SET(CEGUI_OGRE_RENDERER_LIBRARY ogreceguirenderer_orxonox)
+ENDIF()
+
+################### Tolua Bind ##################
+
+# Add hook script to the lua code that generates the bindings
+SET(TOLUA_PARSER_HOOK_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/ToluaInterfaceHook.lua)
+SET(TOLUA_PARSER_DEPENDENCIES ${TOLUA_PARSER_DEPENDENCIES} ${TOLUA_PARSER_HOOK_SCRIPT})
Modified: code/trunk/src/external/CMakeLists.txt
===================================================================
--- code/trunk/src/external/CMakeLists.txt 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/external/CMakeLists.txt 2013-03-12 22:13:03 UTC (rev 9550)
@@ -23,6 +23,8 @@
ADD_SUBDIRECTORY(bullet)
ADD_SUBDIRECTORY(cpptcl)
ADD_SUBDIRECTORY(enet)
+ADD_SUBDIRECTORY(gmock)
+ADD_SUBDIRECTORY(gtest)
ADD_SUBDIRECTORY(loki)
IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED)
ADD_SUBDIRECTORY(ogreceguirenderer)
Modified: code/trunk/src/libraries/core/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/CommandLineParser.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -49,7 +49,7 @@
*/
void CommandLineArgument::parse(const std::string& value)
{
- if (value_.getType() == MT_Type::Bool)
+ if (value_.isType<bool>())
{
// simulate command line switch
bool temp;
@@ -68,9 +68,9 @@
}
else
{
- if (!value_.setValue(value))
+ if (!value_.set(value))
{
- value_.setValue(defaultValue_);
+ value_.set(defaultValue_);
ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
}
else
@@ -297,10 +297,10 @@
else
infoStr << " ";
infoStr << "--" << it->second->getName() << ' ';
- if (it->second->getValue().getType() != MT_Type::Bool)
+ if (it->second->getValue().isType<bool>())
+ infoStr << " ";
+ else
infoStr << "ARG ";
- else
- infoStr << " ";
// fill with the necessary amount of blanks
infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
infoStr << ": " << it->second->getInformation();
Modified: code/trunk/src/libraries/core/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/CommandLineParser.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -199,7 +199,7 @@
template <>
inline void CommandLineParser::getValue<std::string>(const std::string& name, std::string* value)
{
- *value = getArgument(name)->getValue().getString();
+ *value = getArgument(name)->getValue().get<std::string>();
}
/**
@@ -216,7 +216,7 @@
{
OrxAssert(!_getInstance().existsArgument(name),
"Cannot add a command line argument with name '" + name + "' twice.");
- OrxAssert(MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true,
+ OrxAssert(!MultiType(defaultValue).isType<bool>() || MultiType(defaultValue).get<bool>() != true,
"Boolean command line arguments with positive default values are not supported." << endl
<< "Please use SetCommandLineSwitch and adjust your argument: " << name);
Modified: code/trunk/src/libraries/core/ConfigValueContainer.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigValueContainer.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/ConfigValueContainer.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -69,7 +69,7 @@
this->value_ = defvalue;
this->bIsVector_ = false;
- this->defvalueString_ = this->value_.getString();
+ this->defvalueString_ = this->value_.get<std::string>();
this->update();
}
@@ -82,7 +82,7 @@
for (unsigned int i = 0; i < this->valueVector_.size(); i++)
{
- ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
+ ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType<std::string>());
this->defvalueStringVector_.push_back(this->valueVector_[i]);
}
@@ -117,7 +117,7 @@
{
if (this->tset(input))
{
- ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
+ ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, input, this->value_.isType<std::string>());
return true;
}
}
@@ -136,7 +136,7 @@
{
if (this->tset(index, input))
{
- ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
+ ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, index, input, this->value_.isType<std::string>());
return true;
}
}
@@ -235,7 +235,7 @@
// Erase the entry from the vector, change (shift) all entries beginning with index in the config file, remove the last entry from the file
this->valueVector_.erase(this->valueVector_.begin() + index);
for (unsigned int i = index; i < this->valueVector_.size(); i++)
- ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
+ ConfigFileManager::getInstance().getConfigFile(this->type_)->setValue(this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType<std::string>());
ConfigFileManager::getInstance().getConfigFile(this->type_)->deleteVectorEntries(this->sectionname_, this->varname_, this->valueVector_.size());
return true;
@@ -271,7 +271,7 @@
void ConfigValueContainer::update()
{
if (!this->bIsVector_)
- this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
+ this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType<std::string>());
else
{
this->valueVector_.clear();
@@ -280,11 +280,11 @@
{
if (i < this->defvalueStringVector_.size())
{
- this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
+ this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType<std::string>());
}
else
{
- this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
+ this->value_ = ConfigFileManager::getInstance().getConfigFile(this->type_)->getOrCreateValue(this->sectionname_, this->varname_, i, MultiType(), this->value_.isType<std::string>());
}
this->valueVector_.push_back(this->value_);
Modified: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/Core.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -54,6 +54,7 @@
#include "util/Output.h"
#include "util/Exception.h"
#include "util/output/LogWriter.h"
+#include "util/output/OutputManager.h"
#include "util/Scope.h"
#include "util/ScopedSingletonManager.h"
#include "util/SignalHandler.h"
@@ -166,7 +167,7 @@
orxout(internal_info) << "Loading config:" << endl;
this->configFileManager_ = new ConfigFileManager();
this->configFileManager_->setFilename(ConfigFileType::Settings,
- CommandLineParser::getValue("settingsFile").getString());
+ CommandLineParser::getValue("settingsFile").get<std::string>());
// Required as well for the config values
orxout(internal_info) << "Loading language:" << endl;
@@ -179,11 +180,11 @@
this->setConfigValues();
// Set the correct log path and rewrite the log file with the correct log levels
- LogWriter::getInstance().setLogPath(PathConfig::getLogPathString());
+ OutputManager::getInstance().getLogWriter()->setLogDirectory(PathConfig::getLogPathString());
#if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
// Create persistent IO console
- if (CommandLineParser::getValue("noIOConsole").getBool())
+ if (CommandLineParser::getValue("noIOConsole").get<bool>())
{
ModifyConfigValue(bStartIOConsole_, tset, false);
}
@@ -257,24 +258,24 @@
//! Function to collect the SetConfigValue-macro calls.
void Core::setConfigValues()
{
- SetConfigValueExternal(LogWriter::getInstance().configurableMaxLevel_,
- LogWriter::getInstance().getConfigurableSectionName(),
- LogWriter::getInstance().getConfigurableMaxLevelName(),
- LogWriter::getInstance().configurableMaxLevel_)
+ SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableMaxLevel_,
+ OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+ OutputManager::getInstance().getLogWriter()->getConfigurableMaxLevelName(),
+ OutputManager::getInstance().getLogWriter()->configurableMaxLevel_)
.description("The maximum level of output shown in the log file")
- .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableLevel);
- SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContextsMaxLevel_,
- LogWriter::getInstance().getConfigurableSectionName(),
- LogWriter::getInstance().getConfigurableAdditionalContextsMaxLevelName(),
- LogWriter::getInstance().configurableAdditionalContextsMaxLevel_)
+ .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableLevel);
+ SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_,
+ OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+ OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsMaxLevelName(),
+ OutputManager::getInstance().getLogWriter()->configurableAdditionalContextsMaxLevel_)
.description("The maximum level of output shown in the log file for additional contexts")
- .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
- SetConfigValueExternal(LogWriter::getInstance().configurableAdditionalContexts_,
- LogWriter::getInstance().getConfigurableSectionName(),
- LogWriter::getInstance().getConfigurableAdditionalContextsName(),
- LogWriter::getInstance().configurableAdditionalContexts_)
+ .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContextsLevel);
+ SetConfigValueExternal(OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_,
+ OutputManager::getInstance().getLogWriter()->getConfigurableSectionName(),
+ OutputManager::getInstance().getLogWriter()->getConfigurableAdditionalContextsName(),
+ OutputManager::getInstance().getLogWriter()->configurableAdditionalContexts_)
.description("Additional output contexts shown in the log file")
- .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContexts);
+ .callback(static_cast<BaseWriter*>(OutputManager::getInstance().getLogWriter()), &BaseWriter::changedConfigurableAdditionalContexts);
SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
.description("Developer mode. If not set, hides some things from the user to not confuse him.")
@@ -336,7 +337,7 @@
void Core::loadGraphics()
{
orxout(internal_info) << "loading graphics in Core" << endl;
-
+
// Any exception should trigger this, even in upgradeToGraphics (see its remarks)
Loki::ScopeGuard unloader = Loki::MakeObjGuard(*this, &Core::unloadGraphics);
Modified: code/trunk/src/libraries/core/PathConfig.cc
===================================================================
--- code/trunk/src/libraries/core/PathConfig.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/PathConfig.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -187,7 +187,7 @@
// Check for data path override by the command line
if (!CommandLineParser::getArgument("externalDataPath")->hasDefaultValue())
- externalDataPath_ = CommandLineParser::getValue("externalDataPath").getString();
+ externalDataPath_ = CommandLineParser::getValue("externalDataPath").get<std::string>();
else
externalDataPath_ = specialConfig::externalDataDevDirectory;
}
@@ -226,7 +226,7 @@
// Option to put all the config and log files in a separate folder
if (!CommandLineParser::getArgument("writingPathSuffix")->hasDefaultValue())
{
- const std::string& directory(CommandLineParser::getValue("writingPathSuffix").getString());
+ const std::string& directory(CommandLineParser::getValue("writingPathSuffix").get<std::string>());
configPath_ = configPath_ / directory;
logPath_ = logPath_ / directory;
}
Modified: code/trunk/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandEvaluation.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/CommandEvaluation.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -118,7 +118,7 @@
/**
@brief Executes the command which was evaluated by this object and returns its return-value.
@param error A pointer to an integer (or NULL) which will be used to write error codes to (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
- @return Returns the result of the command (or MT_Type::Null if there is no return value)
+ @return Returns the result of the command (or MultiType::Null if there is no return value)
*/
MultiType CommandEvaluation::query(int* error)
{
@@ -137,7 +137,7 @@
*error = CommandExecutor::Denied;
if (*error != CommandExecutor::Success)
- return MT_Type::Null;
+ return MultiType::Null;
}
// check if it's possible to execute the command
@@ -169,7 +169,7 @@
}
// return a null value in case of an error
- return MT_Type::Null;
+ return MultiType::Null;
}
/**
@@ -224,7 +224,7 @@
if (index < MAX_FUNCTOR_ARGUMENTS)
return this->arguments_[index];
- return MT_Type::Null;
+ return MultiType::Null;
}
/**
@@ -599,7 +599,7 @@
// print the default value if available
if (command->getExecutor()->defaultValueSet(i))
- output += '=' + command->getExecutor()->getDefaultValue(i).getString() + ']';
+ output += '=' + command->getExecutor()->getDefaultValue(i).get<std::string>() + ']';
else
output += '}';
}
Modified: code/trunk/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/CommandExecutor.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -82,7 +82,7 @@
@param command A string containing the command
@param error A pointer to a value (or NULL) where the error-code should be written to (see @ref CommandExecutorErrorCodes "error codes")
@param useTcl If true, the command is passed to tcl (see TclBind)
- @return Returns the return-value of the command (if any - MT_Type::Null otherwise)
+ @return Returns the return-value of the command (if any - MultiType::Null otherwise)
*/
/* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl)
{
@@ -132,7 +132,7 @@
*/
/* static */ std::string CommandExecutor::query(const std::string& command, int* error, bool useTcl)
{
- return CommandExecutor::queryMT(command, error, useTcl).getString();
+ return CommandExecutor::queryMT(command, error, useTcl).get<std::string>();
}
/**
Modified: code/trunk/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -221,8 +221,6 @@
#include <stack>
#include <vector>
-#include <boost/preprocessor/cat.hpp>
-#include <boost/preprocessor/facilities/expand.hpp>
#include "util/VA_NARGS.h"
#include "ArgumentCompletionFunctions.h"
Modified: code/trunk/src/libraries/core/command/Executor.cc
===================================================================
--- code/trunk/src/libraries/core/command/Executor.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/Executor.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -78,7 +78,7 @@
@param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
@param delimiter The delimiter that is used to separate the arguments in the string @a arguments
@param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments
- @return Returns the return value of the function (or MT_Type::Null if there is no return value)
+ @return Returns the return value of the function (or MultiType::Null if there is no return value)
*/
MultiType Executor::parse(const std::string& arguments, int* error, const std::string& delimiter, bool bPrintError) const
{
@@ -91,7 +91,7 @@
@param error A pointer to a variable (or NULL) that is used to store the error code (see @ref CommandExecutorErrorCodes "CommandExecutor error codes")
@param delimiter The delimiter that was used to separate the arguments in the SubString @a arguments (used to join the surplus arguments)
@param bPrintError If true, errors are printed to the console if the function couldn't be executed with the given arguments
- @return Returns the return value of the function (or MT_Type::Null if there is no return value)
+ @return Returns the return value of the function (or MultiType::Null if there is no return value)
*/
MultiType Executor::parse(const SubString& arguments, int* error, const std::string& delimiter, bool bPrintError) const
{
@@ -104,7 +104,7 @@
{
if (bPrintError)
orxout(internal_warning) << "Can't call executor " << this->name_ << " through parser: Not enough arguments or default values given (input: " << arguments.join() << ")." << endl;
- return MT_Type::Null;
+ return MultiType::Null;
}
orxout(verbose, context::misc::executor) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << argCount << " arguments: " << arg[0] << " / " << arg[1] << " / " << arg[2] << " / " << arg[3] << " / " << arg[4] << endl;
Modified: code/trunk/src/libraries/core/command/Executor.h
===================================================================
--- code/trunk/src/libraries/core/command/Executor.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/Executor.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -168,7 +168,7 @@
if (index < MAX_FUNCTOR_ARGUMENTS)
return this->defaultValue_[index];
- return MT_Type::Null;
+ return MultiType::Null;
}
bool allDefaultValuesSet() const;
Modified: code/trunk/src/libraries/core/command/Functor.h
===================================================================
--- code/trunk/src/libraries/core/command/Functor.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/Functor.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -188,8 +188,8 @@
public:
virtual ~Functor() {}
- /// Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. @return Returns the return-value of the function (if any; MT_Type::Null otherwise)
- virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
+ /// Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
+ virtual MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0;
/// Creates a new instance of Functor with the same values like this (used instead of a copy-constructor)
virtual FunctorPtr clone() = 0;
@@ -244,11 +244,11 @@
FunctorMember(O* object = 0) : object_(object), bSafeMode_(false) {}
virtual ~FunctorMember() { if (this->bSafeMode_) { this->unregisterObject(this->object_); } }
- /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MT_Type::Null otherwise)
- virtual MultiType operator()(O* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
+ /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
+ virtual MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0;
// see Functor::operator()()
- MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
+ MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)
{
// call the function if an object was assigned
if (this->object_)
@@ -256,7 +256,7 @@
else
{
orxout(internal_error) << "Can't execute FunctorMember, no object set." << endl;
- return MT_Type::Null;
+ return MultiType::Null;
}
}
@@ -323,11 +323,11 @@
/// Constructor: Stores the object-pointer.
FunctorMember(void* object = 0) {}
- /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MT_Type::Null otherwise)
- virtual MultiType operator()(void* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
+ /// Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be NULL. @return Returns the return-value of the function (if any; MultiType::Null otherwise)
+ virtual MultiType operator()(void* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null) = 0;
// see Functor::operator()()
- MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
+ MultiType operator()(const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)
{
return (*this)((void*)0, param1, param2, param3, param4, param5);
}
@@ -415,24 +415,24 @@
template <class R, class O, bool isconst, class P1, class P2> struct FunctorCaller<R, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2); } };
template <class R, class O, bool isconst, class P1> struct FunctorCaller<R, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1); } };
template <class R, class O, bool isconst> struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(); } };
- template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
- template <class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
- template <class O, bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
- template <class O, bool isconst, class P1, class P2> struct FunctorCaller<void, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MT_Type::Null; } };
- template <class O, bool isconst, class P1> struct FunctorCaller<void, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MT_Type::Null; } };
- template <class O, bool isconst> struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MT_Type::Null; } };
+ template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } };
+ template <class O, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } };
+ template <class O, bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MultiType::Null; } };
+ template <class O, bool isconst, class P1, class P2> struct FunctorCaller<void, O, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MultiType::Null; } };
+ template <class O, bool isconst, class P1> struct FunctorCaller<void, O, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MultiType::Null; } };
+ template <class O, bool isconst> struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MultiType::Null; } };
template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } };
template <class R, bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (*functionPointer)(param1, param2, param3, param4); } };
template <class R, bool isconst, class P1, class P2, class P3> struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2, param3); } };
template <class R, bool isconst, class P1, class P2> struct FunctorCaller<R, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2); } };
template <class R, bool isconst, class P1> struct FunctorCaller<R, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1); } };
template <class R, bool isconst> struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(); } };
- template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
- template <bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
- template <bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
- template <bool isconst, class P1, class P2> struct FunctorCaller<void, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MT_Type::Null; } };
- template <bool isconst, class P1> struct FunctorCaller<void, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MT_Type::Null; } };
- template <bool isconst> struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MT_Type::Null; } };
+ template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MultiType::Null; } };
+ template <bool isconst, class P1, class P2, class P3, class P4> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MultiType::Null; } };
+ template <bool isconst, class P1, class P2, class P3> struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MultiType::Null; } };
+ template <bool isconst, class P1, class P2> struct FunctorCaller<void, void, isconst, P1, P2, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MultiType::Null; } };
+ template <bool isconst, class P1> struct FunctorCaller<void, void, isconst, P1, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MultiType::Null; } };
+ template <bool isconst> struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MultiType::Null; } };
// Helper class, used to identify the header of a function-pointer (independent of its class)
template <class R, class P1, class P2, class P3, class P4, class P5>
@@ -496,7 +496,7 @@
FunctorTemplate(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object = 0) : FunctorPointer<typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type, O>(functionPointer, object) {}
// see FunctorMember::operator()()
- MultiType operator()(O* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
+ MultiType operator()(O* object, const MultiType& param1 = MultiType::Null, const MultiType& param2 = MultiType::Null, const MultiType& param3 = MultiType::Null, const MultiType& param4 = MultiType::Null, const MultiType& param5 = MultiType::Null)
{
return detail::FunctorCaller<R, O, isconst, P1, P2, P3, P4, P5>::call(this->functionPointer_, object, param1, param2, param3, param4, param5);
}
Modified: code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsolePOSIX.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/IOConsolePOSIX.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -37,6 +37,7 @@
#include "util/Clock.h"
#include "util/Math.h"
#include "util/output/ConsoleWriter.h"
+#include "util/output/OutputManager.h"
#include "core/Game.h"
#include "core/input/InputBuffer.h"
@@ -74,7 +75,7 @@
this->lastTerminalHeight_ = this->terminalHeight_;
// Disable standard std::cout logging
- ConsoleWriter::getInstance().disable();
+ OutputManager::getInstance().getConsoleWriter()->disable();
// Redirect std::cout to an ostringstream
// (Other part is in the initialiser list)
std::cout.rdbuf(this->origCout_.rdbuf());
@@ -102,7 +103,7 @@
// Restore this->cout_ redirection
std::cout.rdbuf(this->cout_.rdbuf());
// Enable standard std::cout logging again
- ConsoleWriter::getInstance().enable();
+ OutputManager::getInstance().getConsoleWriter()->enable();
}
void IOConsole::preUpdate(const Clock& time)
Modified: code/trunk/src/libraries/core/command/IOConsoleWindows.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsoleWindows.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/IOConsoleWindows.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -34,6 +34,7 @@
#include "util/Clock.h"
#include "util/Math.h"
#include "util/output/ConsoleWriter.h"
+#include "util/output/OutputManager.h"
#include "core/Game.h"
#include "core/input/InputBuffer.h"
@@ -52,7 +53,7 @@
, lastOutputLineHeight_(0)
{
// Disable standard this->cout_ logging
- ConsoleWriter::getInstance().disable();
+ OutputManager::getInstance().getConsoleWriter()->disable();
// Redirect std::cout to an ostringstream
// (Other part is in the initialiser list)
std::cout.rdbuf(this->origCout_.rdbuf());
@@ -108,7 +109,7 @@
// Restore this->cout_ redirection
std::cout.rdbuf(this->cout_.rdbuf());
// Enable standard this->cout_ logging again
- ConsoleWriter::getInstance().enable();
+ OutputManager::getInstance().getConsoleWriter()->enable();
resetTerminalMode();
this->shell_->destroy();
Modified: code/trunk/src/libraries/core/command/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/command/Shell.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/Shell.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -87,7 +87,7 @@
this->setConfigValues();
// Get the previous output and add it to the Shell
- MemoryWriter::getInstance().resendOutput(this);
+ OutputManager::getInstance().getMemoryWriter()->resendOutput(this);
}
/**
@@ -169,7 +169,7 @@
else
{
OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
- ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level);
+ ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, static_cast<int>(level));
}
}
Modified: code/trunk/src/libraries/core/command/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclBind.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/command/TclBind.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -182,7 +182,7 @@
CommandEvaluation evaluation = CommandExecutor::evaluate(command);
if (bQuery)
- result = evaluation.query(&error).getString();
+ result = evaluation.query(&error).get<std::string>();
else
error = evaluation.execute();
Modified: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/core/input/InputManager.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -175,7 +175,7 @@
if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
{
- if (CommandLineParser::getValue("keyboard_no_grab").getBool())
+ if (CommandLineParser::getValue("keyboard_no_grab").get<bool>())
paramList.insert(StringPair("x11_keyboard_grab", "false"));
else
paramList.insert(StringPair("x11_keyboard_grab", "true"));
Modified: code/trunk/src/libraries/network/Client.cc
===================================================================
--- code/trunk/src/libraries/network/Client.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/network/Client.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -67,7 +67,7 @@
gameStateFailure_(false),
timeSinceLastUpdate_(0)
{
- this->setDestination( CommandLineParser::getValue("dest").getString(), CommandLineParser::getValue("port") );
+ this->setDestination( CommandLineParser::getValue("dest").get<std::string>(), CommandLineParser::getValue("port") );
}
Client::~Client()
Modified: code/trunk/src/libraries/tools/Shader.cc
===================================================================
--- code/trunk/src/libraries/tools/Shader.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/tools/Shader.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -160,7 +160,7 @@
*/
void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, int value)
{
- ParameterContainer container = {technique, pass, parameter, value, 0.0f, MT_Type::Int};
+ ParameterContainer container = {technique, pass, parameter, value};
this->parameters_.push_back(container);
this->addAsListener();
}
@@ -170,7 +170,7 @@
*/
void Shader::setParameter(size_t technique, size_t pass, const std::string& parameter, float value)
{
- ParameterContainer container = {technique, pass, parameter, 0, value, MT_Type::Float};
+ ParameterContainer container = {technique, pass, parameter, value};
this->parameters_.push_back(container);
this->addAsListener();
}
@@ -203,17 +203,10 @@
if (passPtr)
{
// change the value of the parameter depending on its type
- switch (it->valueType_)
- {
- case MT_Type::Int:
- passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueInt_);
- break;
- case MT_Type::Float:
- passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->valueFloat_);
- break;
- default:
- break;
- }
+ if (it->value_.isType<int>())
+ passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.get<int>());
+ else if (it->value_.isType<float>())
+ passPtr->getFragmentProgramParameters()->setNamedConstant(it->parameter_, it->value_.get<float>());
}
else
orxout(internal_warning) << "No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl;
Modified: code/trunk/src/libraries/tools/Shader.h
===================================================================
--- code/trunk/src/libraries/tools/Shader.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/tools/Shader.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -113,10 +113,7 @@
size_t pass_; ///< The ID of the pass
std::string parameter_; ///< The name of the parameter
- int valueInt_; ///< The desired int value of the parameter
- float valueFloat_; ///< The desired float value of the parameter
-
- MT_Type::Value valueType_; ///< The type of the parameter (currently only int or float)
+ MultiType value_; ///< The desired value of the parameter
};
std::list<ParameterContainer> parameters_; ///< The list of parameters that should be set on the next update
Modified: code/trunk/src/libraries/util/Math.h
===================================================================
--- code/trunk/src/libraries/util/Math.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/Math.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -141,15 +141,6 @@
}
/**
- @brief Rounds the value to the nearest integer.
- */
- template <typename T>
- inline int round(T x)
- {
- return static_cast<int>(x + 0.5);
- }
-
- /**
@brief The modulo operation, enhanced to work properly with negative values.
@param x The value
@param max The operand
@@ -246,7 +237,7 @@
template <typename T>
inline T interpolate(float time, const T& start, const T& end)
{
- return time * (end - start) + start;
+ return static_cast<T>(time * (end - start) + start);
}
/**
@@ -259,7 +250,7 @@
template <typename T>
inline T interpolateSmooth(float time, const T& start, const T& end)
{
- return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start;
+ return static_cast<T>((-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start);
}
/**
Modified: code/trunk/src/libraries/util/MultiType.cc
===================================================================
--- code/trunk/src/libraries/util/MultiType.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/MultiType.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -36,61 +36,63 @@
namespace orxonox
{
+ const MultiType MultiType::Null;
+
/**
@brief Converts the current value of the MultiType to a new type.
@param type The type
*/
- bool MultiType::convert(MT_Type::Value type)
+ bool MultiType::convert(Type::Enum type)
{
switch (type)
{
- case MT_Type::Null:
+ case Type::Null:
this->reset(); return true;
- case MT_Type::Char:
+ case Type::Char:
return this->convert<char>(); break;
- case MT_Type::UnsignedChar:
+ case Type::UnsignedChar:
return this->convert<unsigned char>(); break;
- case MT_Type::Short:
+ case Type::Short:
return this->convert<short>(); break;
- case MT_Type::UnsignedShort:
+ case Type::UnsignedShort:
return this->convert<unsigned short>(); break;
- case MT_Type::Int:
+ case Type::Int:
return this->convert<int>(); break;
- case MT_Type::UnsignedInt:
+ case Type::UnsignedInt:
return this->convert<unsigned int>(); break;
- case MT_Type::Long:
+ case Type::Long:
return this->convert<long>(); break;
- case MT_Type::UnsignedLong:
+ case Type::UnsignedLong:
return this->convert<unsigned long>(); break;
- case MT_Type::LongLong:
+ case Type::LongLong:
return this->convert<long long>(); break;
- case MT_Type::UnsignedLongLong:
+ case Type::UnsignedLongLong:
return this->convert<unsigned long long>(); break;
- case MT_Type::Float:
+ case Type::Float:
return this->convert<float>(); break;
- case MT_Type::Double:
+ case Type::Double:
return this->convert<double>(); break;
- case MT_Type::LongDouble:
+ case Type::LongDouble:
return this->convert<long double>(); break;
- case MT_Type::Bool:
+ case Type::Bool:
return this->convert<bool>(); break;
- case MT_Type::VoidPointer:
+ case Type::VoidPointer:
return this->convert<void*>(); break;
- case MT_Type::String:
+ case Type::String:
return this->convert<std::string>(); break;
- case MT_Type::Vector2:
+ case Type::Vector2:
return this->convert<orxonox::Vector2>(); break;
- case MT_Type::Vector3:
+ case Type::Vector3:
return this->convert<orxonox::Vector3>(); break;
- case MT_Type::Vector4:
+ case Type::Vector4:
return this->convert<orxonox::Vector4>(); break;
- case MT_Type::ColourValue:
+ case Type::ColourValue:
return this->convert<orxonox::ColourValue>(); break;
- case MT_Type::Quaternion:
+ case Type::Quaternion:
return this->convert<orxonox::Quaternion>(); break;
- case MT_Type::Radian:
+ case Type::Radian:
return this->convert<orxonox::Radian>(); break;
- case MT_Type::Degree:
+ case Type::Degree:
return this->convert<orxonox::Degree>(); break;
default:
this->reset(); return false; break;
@@ -103,106 +105,82 @@
*/
std::string MultiType::getTypename() const
{
- MT_Type::Value type = (this->value_) ? this->value_->type_ : MT_Type::Null;
+ Type::Enum type = (this->value_) ? this->value_->type_ : Type::Null;
switch (type)
{
- case MT_Type::Char:
+ case Type::Char:
return "char"; break;
- case MT_Type::UnsignedChar:
+ case Type::UnsignedChar:
return "unsigned char"; break;
- case MT_Type::Short:
+ case Type::Short:
return "short"; break;
- case MT_Type::UnsignedShort:
+ case Type::UnsignedShort:
return "unsigned short"; break;
- case MT_Type::Int:
+ case Type::Int:
return "int"; break;
- case MT_Type::UnsignedInt:
+ case Type::UnsignedInt:
return "unsigned int"; break;
- case MT_Type::Long:
+ case Type::Long:
return "long"; break;
- case MT_Type::UnsignedLong:
+ case Type::UnsignedLong:
return "unsigned long"; break;
- case MT_Type::LongLong:
+ case Type::LongLong:
return "long long"; break;
- case MT_Type::UnsignedLongLong:
+ case Type::UnsignedLongLong:
return "unsigned long long"; break;
- case MT_Type::Float:
+ case Type::Float:
return "float"; break;
- case MT_Type::Double:
+ case Type::Double:
return "double"; break;
- case MT_Type::LongDouble:
+ case Type::LongDouble:
return "long double"; break;
- case MT_Type::Bool:
+ case Type::Bool:
return "bool"; break;
- case MT_Type::VoidPointer:
+ case Type::VoidPointer:
return "void*"; break;
- case MT_Type::String:
+ case Type::String:
return "std::string"; break;
- case MT_Type::Vector2:
+ case Type::Vector2:
return "orxonox::Vector2"; break;
- case MT_Type::Vector3:
+ case Type::Vector3:
return "orxonox::Vector3"; break;
- case MT_Type::Vector4:
+ case Type::Vector4:
return "orxonox::Vector4"; break;
- case MT_Type::ColourValue:
+ case Type::ColourValue:
return "orxonox::ColourValue"; break;
- case MT_Type::Quaternion:
+ case Type::Quaternion:
return "orxonox::Quaternion"; break;
- case MT_Type::Radian:
+ case Type::Radian:
return "orxonox::Radian"; break;
- case MT_Type::Degree:
+ case Type::Degree:
return "orxonox::Degree"; break;
default:
return "unknown"; break;
};
}
- MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } ///< Returns the current value, converted to the requested type.
- MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_Type::String ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_Type::ColourValue ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } ///< Returns the current value, converted to the requested type.
- MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } ///< Returns the current value, converted to the requested type.
-
- template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_Type::Char ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_Type::UnsignedChar ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_Type::Short ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_Type::UnsignedShort ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_Type::Int ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_Type::UnsignedInt ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_Type::Long ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_Type::UnsignedLong ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_Type::LongLong ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_Type::UnsignedLongLong); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_Type::Float ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_Type::Double ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_Type::LongDouble ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_Type::Bool ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_Type::VoidPointer ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_Type::String ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_Type::Vector2 ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_Type::Vector3 ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_Type::Vector4 ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_Type::Radian ); } ///< Creates a new value container for the given type.
- template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_Type::Degree ); } ///< Creates a new value container for the given type.
+ template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, Type::Char ); }
+ template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, Type::UnsignedChar ); }
+ template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, Type::Short ); }
+ template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, Type::UnsignedShort ); }
+ template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, Type::Int ); }
+ template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, Type::UnsignedInt ); }
+ template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, Type::Long ); }
+ template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, Type::UnsignedLong ); }
+ template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, Type::LongLong ); }
+ template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, Type::UnsignedLongLong); }
+ template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, Type::Float ); }
+ template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, Type::Double ); }
+ template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, Type::LongDouble ); }
+ template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, Type::Bool ); }
+ template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, Type::VoidPointer ); }
+ template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, Type::String ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, Type::Vector2 ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, Type::Vector3 ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, Type::Vector4 ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, Type::ColourValue ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, Type::Quaternion ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, Type::Radian ); }
+ template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, Type::Degree ); }
}
Modified: code/trunk/src/libraries/util/MultiType.h
===================================================================
--- code/trunk/src/libraries/util/MultiType.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/MultiType.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -50,23 +50,23 @@
The MultiType has an internal "type" determined by the first assigned value, using one of these ways:
- @ref orxonox::MultiType::MultiType "The constructor"
- The assignment operator= (orxonox::MultiType::operator=())
- - @ref orxonox::MultiType::setValue() "setValue(value)"
+ - @ref orxonox::MultiType::set() "set(value)"
If you assign another value of another type, the MultiType keeps "its" type and
converts the new value to the old type.
If you want to change the type, there are three possibilities:
- @ref orxonox::MultiType::convert "convert<T>()" sets the type to T and converts the currently assigned value
- - @ref orxonox::MultiType::setType "setType<T>()" sets the type to T and resets the value to zero using zeroise<T>()
- - setValue<T>(value) assigns a new value and changes the type to T.
+ - @ref orxonox::MultiType::reset "reset<T>()" sets the type to T and resets the value to zero using zeroise<T>()
+ - force<T>(value) assigns a new value and changes the type to T.
Examples:
@code
- MultiType a = 10; // a has now the type int and the value 10
- a.setValue("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3
- a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
- a.convert<bool>(); // converts 3.14f to bool, which is true
- a = false; // assigns false, this is equivalent to a.setValue(false)
+ MultiType a = 10; // a has now the type int and the value 10
+ a.set("3.14"); // a has still the type int and "3.14" gets converted, therefore the value is now 3
+ a.force<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14f
+ a.convert<bool>(); // converts 3.14f to bool, which is true
+ a = false; // assigns false, this is equivalent to a.setValue(false)
@endcode
You can pass a MultiType to a function as an argument, even if the argument is
@@ -105,45 +105,12 @@
#include <OgreQuaternion.h>
#include <OgreColourValue.h>
#include <loki/TypeTraits.h>
+#include "Math.h"
#include "mbool.h"
namespace orxonox
{
/**
- @brief Enum of all possible types of a MultiType.
- */
- namespace MT_Type
- {
- enum Value
- {
- Null,
- Char,
- UnsignedChar,
- Short,
- UnsignedShort,
- Int,
- UnsignedInt,
- Long,
- UnsignedLong,
- LongLong,
- UnsignedLongLong,
- Float,
- Double,
- LongDouble,
- Bool,
- VoidPointer,
- String,
- Vector2,
- Vector3,
- Vector4,
- ColourValue,
- Quaternion,
- Radian,
- Degree
- };
- }
-
- /**
@brief The MultiType can hold a value of many possible types and convert them to other types.
The following types are supported by the MultiType:
@@ -164,6 +131,40 @@
_UtilExport friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt);
template <typename T> friend class MT_Value;
+ struct Type
+ {
+ /**
+ @brief Enum of all possible types of a MultiType.
+ */
+ enum Enum
+ {
+ Null,
+ Char,
+ UnsignedChar,
+ Short,
+ UnsignedShort,
+ Int,
+ UnsignedInt,
+ Long,
+ UnsignedLong,
+ LongLong,
+ UnsignedLongLong,
+ Float,
+ Double,
+ LongDouble,
+ Bool,
+ VoidPointer,
+ String,
+ Vector2,
+ Vector3,
+ Vector4,
+ ColourValue,
+ Quaternion,
+ Radian,
+ Degree
+ };
+ };
+
public:
/**
@brief MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType.
@@ -172,19 +173,20 @@
class _UtilExport MT_ValueBase
{
public:
- MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {}
- virtual ~MT_ValueBase() {}
+ inline MT_ValueBase(void* data, Type::Enum type) : type_(type), bLastConversionSuccessful(true), data_(data) {}
+ inline virtual ~MT_ValueBase() {}
virtual MT_ValueBase* clone() const = 0;
virtual void reset() = 0;
- virtual bool assimilate(const MultiType& other) = 0;
/// Returns the type of the current value.
- const MT_Type::Value& getType() const { return this->type_; }
+ inline const Type::Enum& getType() const { return this->type_; }
+ /// Returns true if the type of the stored value is T.
+ template <typename T> inline bool isType() const { return false; }
/// Checks whether the value is a default one.
- bool hasDefaultValue() const { return this->bHasDefaultValue_; }
+ inline bool lastConversionSuccessful() const { return this->bLastConversionSuccessful; }
virtual bool setValue(const char& value) = 0;
virtual bool setValue(const unsigned char& value) = 0;
@@ -210,6 +212,8 @@
virtual bool setValue(const orxonox::Radian& value) = 0;
virtual bool setValue(const orxonox::Degree& value) = 0;
+ virtual bool setValue(const MultiType& other) = 0;
+
virtual bool getValue(char* value) const = 0;
virtual bool getValue(unsigned char* value) const = 0;
virtual bool getValue(short* value) const = 0;
@@ -234,319 +238,261 @@
virtual bool getValue(orxonox::Radian* value) const = 0;
virtual bool getValue(orxonox::Degree* value) const = 0;
- virtual operator char() const = 0;
- virtual operator unsigned char() const = 0;
- virtual operator short() const = 0;
- virtual operator unsigned short() const = 0;
- virtual operator int() const = 0;
- virtual operator unsigned int() const = 0;
- virtual operator long() const = 0;
- virtual operator unsigned long() const = 0;
- virtual operator long long() const = 0;
- virtual operator unsigned long long() const = 0;
- virtual operator float() const = 0;
- virtual operator double() const = 0;
- virtual operator long double() const = 0;
- virtual operator bool() const = 0;
- virtual operator void*() const = 0;
- virtual operator std::string() const = 0;
- virtual operator orxonox::Vector2() const = 0;
- virtual operator orxonox::Vector3() const = 0;
- virtual operator orxonox::Vector4() const = 0;
- virtual operator orxonox::ColourValue() const = 0;
- virtual operator orxonox::Quaternion() const = 0;
- virtual operator orxonox::Radian() const = 0;
- virtual operator orxonox::Degree() const = 0;
+ template <typename T> T get() const
+ {
+ if (this->isType<T>())
+ return *reinterpret_cast<const T*>(this->data_);
+ else
+ {
+ T value;
+ this->getValue(&value);
+ return value;
+ }
+ }
virtual void toString(std::ostream& outstream) const = 0;
- virtual void importData( uint8_t*& mem )=0;
- virtual void exportData( uint8_t*& mem ) const=0;
- virtual uint8_t getSize() const=0;
+ virtual void importData(uint8_t*& mem) = 0;
+ virtual void exportData(uint8_t*& mem) const = 0;
+ virtual uint8_t getSize() const = 0;
- MT_Type::Value type_; ///< The type of the current value
- bool bHasDefaultValue_; ///< True if the last conversion wasn't successful
+ Type::Enum type_; ///< The type of the current value
+ bool bLastConversionSuccessful; ///< True if the last conversion was successful
+ void* data_; ///< For direct access to the value if the type is known
};
public:
- inline MultiType() : value_(0) {} ///< Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
- inline MultiType(const char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const unsigned char& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const unsigned short& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const unsigned int& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const unsigned long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const unsigned long long& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const float& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const long double& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const bool& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType( void* const& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const std::string& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::Vector2& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::Vector3& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::Vector4& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::Quaternion& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } ///< Constructor: Assigns the given value and sets the type.
- inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } ///< Constructor: Assigns the given mbool and converts it to bool.
- inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } ///< Constructor: Converts the char array to a std::string, assigns the value and sets the type.
- inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } ///< Copyconstructor: Assigns value and type of the other MultiType.
- inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } ///< Constructor: Sets the type, the next assignment will determine the value.
+ static const MultiType Null;
+ /// Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value.
+ inline MultiType() : value_(0) { }
+ /// Constructor: Assigns the given value and sets the type.
+ template <typename V>
+ inline MultiType(const V& value) : value_(0) { this->set(value); }
+ /// Copyconstructor: Assigns value and type of the other MultiType.
+ inline MultiType(const MultiType& other) : value_(0) { this->set(other); }
+
/// Destructor: Deletes the MT_Value.
inline ~MultiType() { if (this->value_) { delete this->value_; } }
- template <typename V> inline MultiType& operator=(const V& value) { this->setValue(value); return (*this); } ///< Assigns a new value. The value will be converted to the current type of the MultiType.
- template <typename V> inline MultiType& operator=(V* value) { this->setValue(value); return (*this); } ///< Assigns a pointer.
- inline MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } ///< Assigns the value of the other MultiType and converts it to the current type of the MultiType.
- inline MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } ///< Resets the value and changes the type.
+ /// Assigns a new value. The value will be converted to the current type of the MultiType.
+ template <typename V> inline MultiType& operator=(const V& value) { this->set(value); return (*this); }
+ /// Assigns a pointer.
+ template <typename V> inline MultiType& operator=(V* value) { this->set(value); return (*this); }
+ /// Assigns the value of the other MultiType and converts it to the current type of the MultiType.
+ inline MultiType& operator=(const MultiType& other) { this->set(other); return (*this); }
- inline bool setValue(const char& value);
- inline bool setValue(const unsigned char& value);
- inline bool setValue(const short& value);
- inline bool setValue(const unsigned short& value);
- inline bool setValue(const int& value);
- inline bool setValue(const unsigned int& value);
- inline bool setValue(const long& value);
- inline bool setValue(const unsigned long& value);
- inline bool setValue(const long long& value);
- inline bool setValue(const unsigned long long& value);
- inline bool setValue(const float& value);
- inline bool setValue(const double& value);
- inline bool setValue(const long double& value);
- inline bool setValue(const bool& value);
- inline bool setValue( void* const& value);
- inline bool setValue(const std::string& value);
- inline bool setValue(const orxonox::Vector2& value);
- inline bool setValue(const orxonox::Vector3& value);
- inline bool setValue(const orxonox::Vector4& value);
- inline bool setValue(const orxonox::ColourValue& value);
- inline bool setValue(const orxonox::Quaternion& value);
- inline bool setValue(const orxonox::Radian& value);
- inline bool setValue(const orxonox::Degree& value);
- inline bool setValue(const char* value);
+ /// Assigns the given value and converts it to the current type.
+ template <typename V> inline bool set(const V& value)
+ {
+ if (this->value_)
+ return this->value_->setValue(value);
+
+ this->assignValue(value);
+ return true;
+ }
/// Assigns a pointer.
- template <typename V> inline bool setValue(V* value)
+ template <typename V> inline bool set(V* value)
{
if (this->value_)
return this->value_->setValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
- else
- return this->assignValue (static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
+
+ this->assignValue(static_cast<void*>(const_cast<typename Loki::TypeTraits<V>::UnqualifiedType*>(value)));
+ return true;
}
/// Assigns the value of the other MultiType and converts it to the current type.
- bool setValue(const MultiType& other) { if (this->value_) { return this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } return true; } }
+ inline bool set(const MultiType& other)
+ {
+ if (this->value_)
+ return this->value_->setValue(other);
+ else if (other.value_)
+ this->value_ = other.value_->clone();
+ return true;
+ }
+
/// Changes the type to T and assigns the new value (which might be of another type than T - it gets converted).
- template <typename T, typename V> inline bool setValue(const V& value) { this->setType<T>(); return this->setValue(value); }
+ template <typename T, typename V> inline bool force(const V& value)
+ {
+ this->reset<T>();
+ return this->set(value);
+ }
-
/// Copies the other MultiType by assigning value and type.
- inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
+ inline void copy(const MultiType& other)
+ {
+ if (this == &other)
+ return;
+ if (this->value_)
+ delete this->value_;
+ this->value_ = (other.value_) ? other.value_->clone() : 0;
+ }
/// Converts the current value to type T.
- template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); }
- /// Converts the current value to the type of the other MultiType.
- inline bool convert(const MultiType& other) { return this->convert(other.getType()); }
- bool convert(MT_Type::Value type);
+ template <typename T> inline bool convert() { return this->force<T>(MultiType(*this)); }
- /// Current content gets deleted. New type is MT_Type::Null
- inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
- /// Current content gets overridden with default zero value
- inline void resetValue() { if (this->value_) this->value_->reset(); }
-
+ /// Resets value and type. Type will be void afterwards and null() returns true.
+ inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
/// Resets the value and changes the internal type to T.
- template <typename T> inline void setType() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
- /// Resets the value and changes the internal type to the type of the other MultiType.
- inline void setType(const MultiType& other) { this->setType(other.getType()); }
- /// Resets the value and changes the internal type to the given type.
- inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); }
+ template <typename T> inline void reset() { this->assignValue(typename Loki::TypeTraits<T>::UnqualifiedReferredType()); }
+ /// Current value gets overridden with default zero value
+ inline void resetValue() { if (this->value_) this->value_->reset(); }
- /// Returns the current type.
- inline MT_Type::Value getType() const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
- /// Returns true if the current type equals the given type.
- inline bool isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
- /// Returns true if the current type is T.
- template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below
- std::string getTypename() const;
+ /// Returns true if the type of the current value is T.
+ template <typename T> inline bool isType() const { return (this->value_ ? this->value_->isType<T>() : false); }
+ std::string getTypename() const;
- /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
- inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
- /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
- inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*static_cast<uint8_t*>(mem))); mem+=sizeof(uint8_t); this->value_->importData(mem); }
- /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
- inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; }
- /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
- inline void operator >> (uint8_t*& mem) const { exportData(mem); }
- inline uint32_t getNetworkSize() const { assert(this->value_); return this->value_->getSize() + sizeof(uint8_t); }
+ /// Checks whether the last conversion was successful
+ inline bool lastConversionSuccessful() const { return !this->value_ || this->value_->lastConversionSuccessful(); }
- /// Checks whether the value is a default one (assigned after a failed conversion)
- bool hasDefaultValue() const { return this->value_->hasDefaultValue(); }
-
/// Checks if the MT contains no value.
- bool null() const { return (!this->value_); }
+ inline bool null() const { return !this->value_; }
- operator char() const;
- operator unsigned char() const;
- operator short() const;
- operator unsigned short() const;
- operator int() const;
- operator unsigned int() const;
- operator long() const;
- operator unsigned long() const;
- operator long long() const;
- operator unsigned long long() const;
- operator float() const;
- operator double() const;
- operator long double() const;
- operator bool() const;
- operator void*() const;
- operator std::string() const;
- operator orxonox::Vector2() const;
- operator orxonox::Vector3() const;
- operator orxonox::Vector4() const;
- operator orxonox::ColourValue() const;
- operator orxonox::Quaternion() const;
- operator orxonox::Radian() const;
- operator orxonox::Degree() const;
+ inline operator char() const { return (this->value_ ? this->value_->get<char>() : 0); }
+ inline operator unsigned char() const { return (this->value_ ? this->value_->get<unsigned char>() : 0); }
+ inline operator short() const { return (this->value_ ? this->value_->get<short>() : 0); }
+ inline operator unsigned short() const { return (this->value_ ? this->value_->get<unsigned short>() : 0); }
+ inline operator int() const { return (this->value_ ? this->value_->get<int>() : 0); }
+ inline operator unsigned int() const { return (this->value_ ? this->value_->get<unsigned int>() : 0); }
+ inline operator long() const { return (this->value_ ? this->value_->get<long>() : 0); }
+ inline operator unsigned long() const { return (this->value_ ? this->value_->get<unsigned long>() : 0); }
+ inline operator long long() const { return (this->value_ ? this->value_->get<long long>() : 0); }
+ inline operator unsigned long long() const { return (this->value_ ? this->value_->get<unsigned long long>() : 0); }
+ inline operator float() const { return (this->value_ ? this->value_->get<float>() : 0); }
+ inline operator double() const { return (this->value_ ? this->value_->get<double>() : 0); }
+ inline operator long double() const { return (this->value_ ? this->value_->get<long double>() : 0); }
+ inline operator bool() const { return (this->value_ ? this->value_->get<bool>() : 0); }
+ inline operator void*() const { return (this->value_ ? this->value_->get<void*>() : 0); }
+ inline operator std::string() const { return (this->value_ ? this->value_->get<std::string>() : NilValue<std::string>()); }
+ inline operator orxonox::Vector2() const { return (this->value_ ? this->value_->get<orxonox::Vector2>() : NilValue<orxonox::Vector2>()); }
+ inline operator orxonox::Vector3() const { return (this->value_ ? this->value_->get<orxonox::Vector3>() : NilValue<orxonox::Vector3>()); }
+ inline operator orxonox::Vector4() const { return (this->value_ ? this->value_->get<orxonox::Vector4>() : NilValue<orxonox::Vector4>()); }
+ inline operator orxonox::ColourValue() const { return (this->value_ ? this->value_->get<orxonox::ColourValue>() : NilValue<orxonox::ColourValue>()); }
+ inline operator orxonox::Quaternion() const { return (this->value_ ? this->value_->get<orxonox::Quaternion>() : NilValue<orxonox::Quaternion>()); }
+ inline operator orxonox::Radian() const { return (this->value_ ? this->value_->get<orxonox::Radian>() : NilValue<orxonox::Radian>()); }
+ inline operator orxonox::Degree() const { return (this->value_ ? this->value_->get<orxonox::Degree>() : NilValue<orxonox::Degree>()); }
/// Returns the current value, converted to a T* pointer.
template <class T> operator T*() const { return (static_cast<T*>(this->operator void*())); }
- inline bool getValue(char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(unsigned char* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(unsigned short* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(unsigned int* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(unsigned long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(unsigned long long* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(float* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(long double* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(bool* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(void** value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(std::string* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Vector2* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Vector3* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Vector4* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::ColourValue* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Quaternion* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Radian* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Degree* value) const { if (this->value_) { return this->value_->getValue(value); } return false; } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ /// Assigns the value to the given pointer. The value gets converted if the types don't match.
+ template <typename T> inline bool getValue(T* value) const { if (this->value_) { return this->value_->getValue(value); } return false; }
- inline char getChar() const { return this->operator char(); } ///< Returns the current value, converted to the requested type.
- inline unsigned char getUnsignedChar() const { return this->operator unsigned char(); } ///< Returns the current value, converted to the requested type.
- inline short getShort() const { return this->operator short(); } ///< Returns the current value, converted to the requested type.
- inline unsigned short getUnsignedShort() const { return this->operator unsigned short(); } ///< Returns the current value, converted to the requested type.
- inline int getInt() const { return this->operator int(); } ///< Returns the current value, converted to the requested type.
- inline unsigned int getUnsignedInt() const { return this->operator unsigned int(); } ///< Returns the current value, converted to the requested type.
- inline long getLong() const { return this->operator long(); } ///< Returns the current value, converted to the requested type.
- inline unsigned long getUnsignedLong() const { return this->operator unsigned long(); } ///< Returns the current value, converted to the requested type.
- inline long long getLongLong() const { return this->operator long long(); } ///< Returns the current value, converted to the requested type.
- inline unsigned long long getUnsignedLongLong() const { return this->operator unsigned long long(); } ///< Returns the current value, converted to the requested type.
- inline float getFloat() const { return this->operator float(); } ///< Returns the current value, converted to the requested type.
- inline double getDouble() const { return this->operator double(); } ///< Returns the current value, converted to the requested type.
- inline long double getLongDouble() const { return this->operator long double(); } ///< Returns the current value, converted to the requested type.
- inline bool getBool() const { return this->operator bool(); } ///< Returns the current value, converted to the requested type.
- inline void* getVoid() const { return this->operator void*(); } ///< Returns the current value, converted to the requested type.
- inline std::string getString() const { return this->operator std::string(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::Vector2 getVector2() const { return this->operator orxonox::Vector2(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::Vector3 getVector3() const { return this->operator orxonox::Vector3(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::Vector4 getVector4() const { return this->operator orxonox::Vector4(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::ColourValue getColourValue() const { return this->operator orxonox::ColourValue(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::Quaternion getQuaternion() const { return this->operator orxonox::Quaternion(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::Radian getRadian() const { return this->operator orxonox::Radian(); } ///< Returns the current value, converted to the requested type.
- inline orxonox::Degree getDegree() const { return this->operator orxonox::Degree(); } ///< Returns the current value, converted to the requested type.
- template <typename T> inline T* getPointer() const { return static_cast<T*>(this->getVoid()); } ///< Returns the current value, converted to a T* pointer.
+ /// Returns the current value, converted to the requested type.
+ template <typename T> inline T get() const { return *this; }
+
+ ///////////////////////////////
+ // network-related functions //
+ ///////////////////////////////
+ /// Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT
+ inline void exportData(uint8_t*& mem) const
+ {
+ assert(sizeof(Type::Enum) <= 8);
+ *static_cast<uint8_t*>(mem) = this->getType();
+ mem += sizeof(uint8_t);
+ this->value_->exportData(mem);
+ }
+ /// Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT
+ inline void importData(uint8_t*& mem)
+ {
+ assert(sizeof(Type::Enum) <= 8);
+ this->setType(static_cast<Type::Enum>(*static_cast<uint8_t*>(mem)));
+ mem += sizeof(uint8_t);
+ this->value_->importData(mem);
+ }
+ /// Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT
+ inline uint8_t*& operator<<(uint8_t*& mem)
+ {
+ importData(mem);
+ return mem;
+ }
+ /// Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT
+ inline void operator>>(uint8_t*& mem) const
+ {
+ exportData(mem);
+ }
+ inline uint32_t getNetworkSize() const
+ {
+ assert(this->value_);
+ return this->value_->getSize() + sizeof(uint8_t);
+ }
+
private:
- inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
- inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } ///< Assigns a new value by changing type and creating a new container.
+ /// Assigns a new value by changing type and creating a new container.
+ template <typename T> inline void assignValue(const T& value)
+ {
+ if (this->isType<T>())
+ this->value_->setValue(value);
+ else
+ this->changeValueContainer(value);
+ }
+ /// Assigns a new value by changing type and creating a new container (overload for pointers).
+ template <typename T> inline void assignValue(T* const& value)
+ {
+ if (this->isType<void*>())
+ this->value_->setValue(static_cast<void*>(value));
+ else
+ this->changeValueContainer<void*>(value);
+ }
+ /// Resets the value and changes the internal type to the given type.
+ inline void setType(Type::Enum type) { this->reset(); this->convert(type); this->resetValue(); }
+ /// Returns the current type.
+ inline Type::Enum getType() const { return (this->value_) ? this->value_->type_ : Type::Null; }
+ /// Converts the current value to the given type.
+ bool convert(Type::Enum type);
+
/// Changes the value container.
- template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
+ template <typename T> inline void changeValueContainer(const T& value)
+ {
+ if (this->value_)
+ delete this->value_;
+ this->createNewValueContainer(value);
+ }
/// Creates a new value container (works only with specialized types).
- template <typename T> void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
+ template <typename T> inline void createNewValueContainer(const T& value) { /* STATIC ASSERT */ *****value; return false; }
MT_ValueBase* value_; //!< A pointer to the value container
};
/// Puts the MultiType on a stream by using the native << operator of the current type.
- _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
+ _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt)
+ {
+ if (mt.value_)
+ mt.value_->toString(outstream);
+ return outstream;
+ }
- template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } ///< Returns true if the current type equals the given type.
- template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } ///< Returns true if the current type equals the given type.
+ template <> inline bool MultiType::MT_ValueBase::isType<char>() const { return this->type_ == Type::Char; }
+ template <> inline bool MultiType::MT_ValueBase::isType<unsigned char>() const { return this->type_ == Type::UnsignedChar; }
+ template <> inline bool MultiType::MT_ValueBase::isType<short>() const { return this->type_ == Type::Short; }
+ template <> inline bool MultiType::MT_ValueBase::isType<unsigned short>() const { return this->type_ == Type::UnsignedShort; }
+ template <> inline bool MultiType::MT_ValueBase::isType<int>() const { return this->type_ == Type::Int; }
+ template <> inline bool MultiType::MT_ValueBase::isType<unsigned int>() const { return this->type_ == Type::UnsignedInt; }
+ template <> inline bool MultiType::MT_ValueBase::isType<long>() const { return this->type_ == Type::Long; }
+ template <> inline bool MultiType::MT_ValueBase::isType<unsigned long>() const { return this->type_ == Type::UnsignedLong; }
+ template <> inline bool MultiType::MT_ValueBase::isType<long long>() const { return this->type_ == Type::LongLong; }
+ template <> inline bool MultiType::MT_ValueBase::isType<unsigned long long>() const { return this->type_ == Type::UnsignedLongLong; }
+ template <> inline bool MultiType::MT_ValueBase::isType<float>() const { return this->type_ == Type::Float; }
+ template <> inline bool MultiType::MT_ValueBase::isType<double>() const { return this->type_ == Type::Double; }
+ template <> inline bool MultiType::MT_ValueBase::isType<long double>() const { return this->type_ == Type::LongDouble; }
+ template <> inline bool MultiType::MT_ValueBase::isType<bool>() const { return this->type_ == Type::Bool; }
+ template <> inline bool MultiType::MT_ValueBase::isType<void*>() const { return this->type_ == Type::VoidPointer; }
+ template <> inline bool MultiType::MT_ValueBase::isType<std::string>() const { return this->type_ == Type::String; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector2>() const { return this->type_ == Type::Vector2; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector3>() const { return this->type_ == Type::Vector3; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Vector4>() const { return this->type_ == Type::Vector4; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::ColourValue>() const { return this->type_ == Type::ColourValue; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Quaternion>() const { return this->type_ == Type::Quaternion; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Radian>() const { return this->type_ == Type::Radian; }
+ template <> inline bool MultiType::MT_ValueBase::isType<orxonox::Degree>() const { return this->type_ == Type::Degree; }
- /// Deletes the content, type becomes MT_Type::Null.
- template <> inline bool MultiType::convert<void>() { this->reset(); return true; }
+ template <> inline bool MultiType::set(const char* value) { return this->set(std::string(value)); }
+ template <> inline bool MultiType::set(const mbool& value) { return this->set((bool)value); }
- // Specialization to avoid ambiguities with the conversion operator
- template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::Vector2>() { return this->setValue<orxonox::Vector2> (this->operator orxonox::Vector2()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::Vector3>() { return this->setValue<orxonox::Vector3> (this->operator orxonox::Vector3()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::Vector4>() { return this->setValue<orxonox::Vector4> (this->operator orxonox::Vector4()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::ColourValue>() { return this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::Quaternion>() { return this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::Radian>() { return this->setValue<orxonox::Radian> (this->operator orxonox::Radian()); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<orxonox::Degree>() { return this->setValue<orxonox::Degree> (this->operator orxonox::Degree()); } ///< Converts the current value to the given type.
+ // Spezializations for void
+ template <> inline bool MultiType::isType<void>() const { return this->null(); }
+ template <> inline bool MultiType::convert<void>() { this->reset(); return true; }
- // Specialization to avoid ambiguities with the conversion operator
- template <> inline bool MultiType::convert<const std::string&>() { return this->convert<std::string>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::Vector2&>() { return this->convert<orxonox::Vector2>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::Vector3&>() { return this->convert<orxonox::Vector3>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::Vector4&>() { return this->convert<orxonox::Vector4>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::ColourValue&>() { return this->convert<orxonox::ColourValue>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::Quaternion&>() { return this->convert<orxonox::Quaternion>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::Radian&>() { return this->convert<orxonox::Radian>(); } ///< Converts the current value to the given type.
- template <> inline bool MultiType::convert<const orxonox::Degree&>() { return this->convert<orxonox::Degree>(); } ///< Converts the current value to the given type.
-
template <> _UtilExport void MultiType::createNewValueContainer(const char& value);
template <> _UtilExport void MultiType::createNewValueContainer(const unsigned char& value);
template <> _UtilExport void MultiType::createNewValueContainer(const short& value);
@@ -570,33 +516,6 @@
template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Quaternion& value);
template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Radian& value);
template <> _UtilExport void MultiType::createNewValueContainer(const orxonox::Degree& value);
-
- inline bool MultiType::setValue(const char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const unsigned char& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const unsigned short& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const unsigned int& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const unsigned long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const unsigned long long& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const float& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const long double& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const bool& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue( void* const& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const std::string& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::Vector2& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::Vector3& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::Vector4& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::ColourValue& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::Quaternion& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::Radian& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const orxonox::Degree& value) { if (this->value_) { return this->value_->setValue(value); } else { return this->assignValue(value); } } ///< Assigns the given value and converts it to the current type.
-
- /// Assigns the given value and converts it to the current type.
- inline bool MultiType::setValue(const char* value) { if (this->value_) { return this->value_->setValue(std::string(value)); } else { return this->assignValue(std::string(value)); } }
}
#endif /* _MultiType_H__ */
Modified: code/trunk/src/libraries/util/MultiTypeValue.h
===================================================================
--- code/trunk/src/libraries/util/MultiTypeValue.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/MultiTypeValue.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -54,31 +54,14 @@
{
public:
/// Constructor: Assigns the value and the type identifier.
- MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {}
+ MT_Value(const T& value, MultiType::Type::Enum type) : MT_ValueBase(&this->value_, type), value_(value) {}
/// Creates a copy of itself.
inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
/// Resets the current value to the default.
- inline void reset() { this->value_ = zeroise<T>(); bHasDefaultValue_ = true; }
+ inline void reset() { this->value_ = zeroise<T>(); bLastConversionSuccessful = true; }
- /**
- @brief Assigns the value of the other MultiType, converted to T.
- @param other The other MultiType
- */
- inline bool assimilate(const MultiType& other)
- {
- if (other.value_)
- {
- return !(bHasDefaultValue_ = !other.value_->getValue(&value_));
- }
- else
- {
- this->value_ = zeroise<T>();
- return !(bHasDefaultValue_ = true);
- }
- }
-
inline bool getValue(char* value) const { return convertValue<T, char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
inline bool getValue(unsigned char* value) const { return convertValue<T, unsigned char >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
inline bool getValue(short* value) const { return convertValue<T, short >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
@@ -94,62 +77,55 @@
inline bool getValue(long double* value) const { return convertValue<T, long double >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
inline bool getValue(bool* value) const { return convertValue<T, bool >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
inline bool getValue(void** value) const { return convertValue<T, void* >(value, value_, 0); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(std::string* value) const { return convertValue<T, std::string >(value, value_, zeroise<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Vector2* value) const { return convertValue<T, orxonox::Vector2 >(value, value_, zeroise<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Vector3* value) const { return convertValue<T, orxonox::Vector3 >(value, value_, zeroise<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Vector4* value) const { return convertValue<T, orxonox::Vector4 >(value, value_, zeroise<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, zeroise<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Quaternion* value) const { return convertValue<T, orxonox::Quaternion >(value, value_, zeroise<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Radian* value) const { return convertValue<T, orxonox::Radian >(value, value_, zeroise<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool getValue(orxonox::Degree* value) const { return convertValue<T, orxonox::Degree >(value, value_, zeroise<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(std::string* value) const { return convertValue<T, std::string >(value, value_, NilValue<std::string> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::Vector2* value) const { return convertValue<T, orxonox::Vector2 >(value, value_, NilValue<orxonox::Vector2> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::Vector3* value) const { return convertValue<T, orxonox::Vector3 >(value, value_, NilValue<orxonox::Vector3> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::Vector4* value) const { return convertValue<T, orxonox::Vector4 >(value, value_, NilValue<orxonox::Vector4> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::ColourValue* value) const { return convertValue<T, orxonox::ColourValue>(value, value_, NilValue<orxonox::ColourValue>()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::Quaternion* value) const { return convertValue<T, orxonox::Quaternion >(value, value_, NilValue<orxonox::Quaternion> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::Radian* value) const { return convertValue<T, orxonox::Radian >(value, value_, NilValue<orxonox::Radian> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
+ inline bool getValue(orxonox::Degree* value) const { return convertValue<T, orxonox::Degree >(value, value_, NilValue<orxonox::Degree> ()); } ///< Assigns the value to the given pointer. The value gets converted if the types don't match.
- inline bool setValue(const char& value) { return !(bHasDefaultValue_ = !convertValue<char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const unsigned char& value) { return !(bHasDefaultValue_ = !convertValue<unsigned char , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const short& value) { return !(bHasDefaultValue_ = !convertValue<short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const unsigned short& value) { return !(bHasDefaultValue_ = !convertValue<unsigned short , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const int& value) { return !(bHasDefaultValue_ = !convertValue<int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const unsigned int& value) { return !(bHasDefaultValue_ = !convertValue<unsigned int , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const long& value) { return !(bHasDefaultValue_ = !convertValue<long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const unsigned long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const long long& value) { return !(bHasDefaultValue_ = !convertValue<long long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const unsigned long long& value) { return !(bHasDefaultValue_ = !convertValue<unsigned long long , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const float& value) { return !(bHasDefaultValue_ = !convertValue<float , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const double& value) { return !(bHasDefaultValue_ = !convertValue<double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const long double& value) { return !(bHasDefaultValue_ = !convertValue<long double , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const bool& value) { return !(bHasDefaultValue_ = !convertValue<bool , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue( void* const& value) { return !(bHasDefaultValue_ = !convertValue<void* , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const std::string& value) { return !(bHasDefaultValue_ = !convertValue<std::string , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::Vector2& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector2 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::Vector3& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector3 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::Vector4& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Vector4 , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::ColourValue& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::ColourValue, T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::Quaternion& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Quaternion , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::Radian& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Radian , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
- inline bool setValue(const orxonox::Degree& value) { return !(bHasDefaultValue_ = !convertValue<orxonox::Degree , T>(&value_, value, zeroise<T>())); } ///< Assigns the value by converting it to T.
+ /**
+ @brief Assigns the value of the other MultiType, converted to T.
+ @param other The other MultiType
+ */
+ inline bool setValue(const MultiType& other)
+ {
+ if (other.value_)
+ {
+ return (this->bLastConversionSuccessful = other.value_->getValue(&value_));
+ }
+ else
+ {
+ this->value_ = zeroise<T>();
+ return (bLastConversionSuccessful = false);
+ }
+ }
- inline operator char() const { return getConvertedValue<T, char> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator unsigned char() const { return getConvertedValue<T, unsigned char> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator short() const { return getConvertedValue<T, short> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator unsigned short() const { return getConvertedValue<T, unsigned short> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator int() const { return getConvertedValue<T, int> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator unsigned int() const { return getConvertedValue<T, unsigned int> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator long() const { return getConvertedValue<T, long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator unsigned long() const { return getConvertedValue<T, unsigned long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator long long() const { return getConvertedValue<T, long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator unsigned long long() const { return getConvertedValue<T, unsigned long long> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator float() const { return getConvertedValue<T, float> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator double() const { return getConvertedValue<T, double> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } ///< Returns the current value, converted to the requested type.
- inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } ///< Returns the current value, converted to the requested type.
- inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } ///< Returns the current value, converted to the requested type.
+ inline bool setValue(const char& value) { return (bLastConversionSuccessful = convertValue<char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const unsigned char& value) { return (bLastConversionSuccessful = convertValue<unsigned char , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const short& value) { return (bLastConversionSuccessful = convertValue<short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const unsigned short& value) { return (bLastConversionSuccessful = convertValue<unsigned short , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const int& value) { return (bLastConversionSuccessful = convertValue<int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const unsigned int& value) { return (bLastConversionSuccessful = convertValue<unsigned int , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const long& value) { return (bLastConversionSuccessful = convertValue<long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const unsigned long& value) { return (bLastConversionSuccessful = convertValue<unsigned long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const long long& value) { return (bLastConversionSuccessful = convertValue<long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const unsigned long long& value) { return (bLastConversionSuccessful = convertValue<unsigned long long , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const float& value) { return (bLastConversionSuccessful = convertValue<float , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const double& value) { return (bLastConversionSuccessful = convertValue<double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const long double& value) { return (bLastConversionSuccessful = convertValue<long double , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const bool& value) { return (bLastConversionSuccessful = convertValue<bool , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue( void* const& value) { return (bLastConversionSuccessful = convertValue<void* , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const std::string& value) { return (bLastConversionSuccessful = convertValue<std::string , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::Vector2& value) { return (bLastConversionSuccessful = convertValue<orxonox::Vector2 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::Vector3& value) { return (bLastConversionSuccessful = convertValue<orxonox::Vector3 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::Vector4& value) { return (bLastConversionSuccessful = convertValue<orxonox::Vector4 , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::ColourValue& value) { return (bLastConversionSuccessful = convertValue<orxonox::ColourValue, T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::Quaternion& value) { return (bLastConversionSuccessful = convertValue<orxonox::Quaternion , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::Radian& value) { return (bLastConversionSuccessful = convertValue<orxonox::Radian , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
+ inline bool setValue(const orxonox::Degree& value) { return (bLastConversionSuccessful = convertValue<orxonox::Degree , T>(&value_, value, NilValue<T>())); } ///< Assigns the value by converting it to T.
/// Puts the current value on the stream
inline void toString(std::ostream& outstream) const { outstream << this->value_; }
Modified: code/trunk/src/libraries/util/SignalHandler.cc
===================================================================
--- code/trunk/src/libraries/util/SignalHandler.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/SignalHandler.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -20,7 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Christoph Renner
+ * Christoph Renner (Linux implementation)
+ * Fabian 'x3n' Landau (Windows implementation)
* Co-authors:
* ...
*
@@ -138,46 +139,46 @@
orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Try to write backtrace to file orxonox_crash.log" << endl;
-
+
// First start GDB which will be attached to this process later on
-
+
int gdbIn[2];
int gdbOut[2];
int gdbErr[2];
-
+
if ( pipe(gdbIn) == -1 || pipe(gdbOut) == -1 || pipe(gdbErr) == -1 )
{
perror("pipe failed!\n");
exit(EXIT_FAILURE);
}
-
+
int gdbPid = fork();
// this process will run gdb
-
+
if ( gdbPid == -1 )
{
perror("fork failed\n");
exit(EXIT_FAILURE);
}
-
+
if ( gdbPid == 0 )
{
// start gdb
-
+
close(gdbIn[1]);
close(gdbOut[0]);
close(gdbErr[0]);
-
+
dup2( gdbIn[0], STDIN_FILENO );
dup2( gdbOut[1], STDOUT_FILENO );
dup2( gdbErr[1], STDERR_FILENO );
-
+
execlp( "sh", "sh", "-c", "gdb", static_cast<void*>(NULL));
}
-
-
+
+
// Now start a fork of this process on which GDB will be attached on
-
+
int sigPipe[2];
if ( pipe(sigPipe) == -1 )
{
@@ -201,13 +202,13 @@
if ( sigPid == 0 )
{
getInstance().dontCatch();
-
+
// make sure gdb is allowed to attach to our PID even if there are some system restrictions
#ifdef PR_SET_PTRACER
if( prctl(PR_SET_PTRACER, gdbPid, 0, 0, 0) == -1 )
orxout(user_error) << "could not set proper permissions for GDB to attach to process..." << endl;
#endif
-
+
// wait for message from parent when it has attached gdb
int someData;
Modified: code/trunk/src/libraries/util/SignalHandler.h
===================================================================
--- code/trunk/src/libraries/util/SignalHandler.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/SignalHandler.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -20,7 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Christoph Renner
+ * Christoph Renner (Linux implementation)
+ * Fabian 'x3n' Landau (Windows implementation)
* Co-authors:
* ...
*
Modified: code/trunk/src/libraries/util/StringUtils.cc
===================================================================
--- code/trunk/src/libraries/util/StringUtils.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/StringUtils.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -80,9 +80,10 @@
return str.substr(pos1, pos2 - pos1 + 1);
}
- /// Splits a given string by a delimiter and stores it in an output vector
+ /// Splits a given string by a delimiter and stores it in an output vector. See @ref SubString for a more sophisticated implementation.
void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output)
{
+ output->clear();
for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1)
{
end = str.find_first_of(delimiter, start);
@@ -91,7 +92,7 @@
}
/**
- @brief Returns the position of the next quotation mark in the string, starting with start.
+ @brief Returns the position of the next quotation mark in the string, starting with start. Escaped quotation marks (with \ in front) are not considered.
@param str The string
@param start The first position to look at
@return The position of the next quotation mark (@c std::string::npos if there is none)
@@ -129,12 +130,10 @@
size_t quotecount = 0;
size_t quote = static_cast<size_t>(-1);
while ((quote = getNextQuote(str, quote + 1)) < pos)
- {
- if (quote == pos)
- return false;
quotecount++;
- }
+ if (quote == pos)
+ return false;
if (quote == std::string::npos)
return false;
@@ -155,7 +154,7 @@
size_t pos1 = getNextQuote(str, 0);
size_t pos2 = getNextQuote(str, pos1 + 1);
if (pos1 != std::string::npos && pos2 != std::string::npos)
- return str.substr(pos1, pos2 - pos1 + 1);
+ return str.substr(pos1 + 1, pos2 - pos1 - 1);
else
return "";
}
@@ -248,25 +247,6 @@
return getStripped(str).empty();
}
- /// Determines if a string contains only numbers and maximal one '.'.
- bool isNumeric(const std::string& str)
- {
- bool foundPoint = false;
-
- for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
- {
- if (((*it) < '0' || (*it) > '9'))
- {
- if ((*it) != '.' && !foundPoint)
- foundPoint = true;
- else
- return false;
- }
- }
-
- return true;
- }
-
/**
@brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
@@ -443,23 +423,21 @@
/// Returns true if the string contains a comment, introduced by #, %, ; or //.
bool hasComment(const std::string& str)
{
- return (getCommentPosition(str) != std::string::npos);
+ return (getNextCommentPosition(str) != std::string::npos);
}
- /// If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
+ /// If the string contains a comment, the comment gets returned (including the comment symbol and white spaces in front of it), an empty string otherwise.
std::string getComment(const std::string& str)
{
- return str.substr(getCommentPosition(str));
+ size_t pos = getNextCommentPosition(str);
+ if (pos == std::string::npos)
+ return "";
+ else
+ return str.substr(pos);
}
- /// If the string contains a comment, the position of the comment-symbol gets returned, @c std::string::npos otherwise.
- size_t getCommentPosition(const std::string& str)
- {
- return getNextCommentPosition(str, 0);
- }
-
/**
- @brief Returns the position of the next comment-symbol, starting with @a start.
+ @brief Returns the beginning of the next comment including whitespaces in front of the comment symbol.
@param str The string
@param start The first position to look at
*/
Modified: code/trunk/src/libraries/util/StringUtils.h
===================================================================
--- code/trunk/src/libraries/util/StringUtils.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/StringUtils.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -57,7 +57,7 @@
_UtilExport void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output);
- _UtilExport size_t getNextQuote(const std::string& str, size_t start);
+ _UtilExport size_t getNextQuote(const std::string& str, size_t start = 0);
_UtilExport bool isBetweenQuotes(const std::string& str, size_t pos);
_UtilExport bool hasStringBetweenQuotes(const std::string& str);
@@ -68,7 +68,6 @@
_UtilExport bool isEmpty(const std::string& str);
_UtilExport bool isComment(const std::string& str);
- _UtilExport bool isNumeric(const std::string& str);
_UtilExport std::string addSlashes(const std::string& str);
_UtilExport std::string removeSlashes(const std::string& str);
@@ -84,7 +83,6 @@
_UtilExport bool hasComment(const std::string& str);
_UtilExport std::string getComment(const std::string& str);
- _UtilExport size_t getCommentPosition(const std::string& str);
_UtilExport size_t getNextCommentPosition(const std::string& str, size_t start = 0);
_UtilExport size_t replaceCharacters(std::string& str, char target, char replacement);
Modified: code/trunk/src/libraries/util/SubString.cc
===================================================================
--- code/trunk/src/libraries/util/SubString.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/SubString.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -86,34 +86,19 @@
@brief creates a new SubString based on a subset of an other SubString.
@param other The other SubString
@param begin The beginning of the subset
+ @param length The length of the subset
- The subset ranges from the token with index @a begin to the end of the tokens.
- If @a begin is greater than the greatest index, the new SubString will be empty.
+ The subset ranges from the token with index @a begin and contains @a length elements.
*/
- SubString::SubString(const SubString& other, unsigned int begin)
+ SubString::SubString(const SubString& other, size_t begin, size_t length)
{
- for (unsigned int i = begin; i < other.size(); ++i)
+ for (size_t i = 0; i < length; ++i)
{
- this->tokens_.push_back(other[i]);
- this->bTokenInSafemode_.push_back(other.isInSafemode(i));
- }
- }
+ if (begin + i >= other.size())
+ break;
- /**
- @brief creates a new SubString based on a subset of an other SubString.
- @param other The other SubString
- @param begin The beginning of the subset
- @param end The end of the subset
-
- The subset ranges from the token with index @a begin until (but not including) the token with index @a end.
- If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty.
- */
- SubString::SubString(const SubString& other, unsigned int begin, unsigned int end)
- {
- for (unsigned int i = begin; i < std::min(other.size(), end); ++i)
- {
- this->tokens_.push_back(other[i]);
- this->bTokenInSafemode_.push_back(other.isInSafemode(i));
+ this->tokens_.push_back(other[begin + i]);
+ this->bTokenInSafemode_.push_back(other.isInSafemode(begin + i));
}
}
@@ -122,9 +107,9 @@
@param argc The number of arguments
@param argv An array of pointers to the arguments
*/
- SubString::SubString(unsigned int argc, const char** argv)
+ SubString::SubString(size_t argc, const char** argv)
{
- for(unsigned int i = 0; i < argc; ++i)
+ for (size_t i = 0; i < argc; ++i)
{
this->tokens_.push_back(std::string(argv[i]));
this->bTokenInSafemode_.push_back(false);
@@ -157,26 +142,19 @@
}
/**
- @copydoc operator==
- */
- bool SubString::compare(const SubString& other) const
- {
- return (*this == other);
- }
-
- /**
@brief Compares this SubString to another SubString and returns true if the first @a length values match.
@param other The other SubString
@param length How many tokens to compare
*/
- bool SubString::compare(const SubString& other, unsigned int length) const
+ bool SubString::compare(const SubString& other, size_t length) const
{
- if (length > this->size() || length > other.size())
+ if (std::min(length, this->size()) != std::min(length, other.size()))
return false;
- for (unsigned int i = 0; i < length; ++i)
+ for (size_t i = 0; i < std::min(length, this->size()); ++i)
if ((this->tokens_[i] != other.tokens_[i]) || (this->bTokenInSafemode_[i] != other.bTokenInSafemode_[i]))
return false;
+
return true;
}
@@ -195,7 +173,7 @@
*/
SubString& SubString::operator+=(const SubString& other)
{
- for (unsigned int i = 0; i < other.size(); ++i)
+ for (size_t i = 0; i < other.size(); ++i)
{
this->tokens_.push_back(other[i]);
this->bTokenInSafemode_.push_back(other.isInSafemode(i));
@@ -206,10 +184,10 @@
/**
@copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char)
*/
- unsigned int SubString::split(const std::string& line,
- const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
- char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
- char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
+ size_t SubString::split(const std::string& line,
+ const std::string& delimiters, const std::string& delimiterNeighbours, bool bAllowEmptyEntries,
+ char escapeChar, bool bRemoveEscapeChar, char safemodeChar, bool bRemoveSafemodeChar,
+ char openparenthesisChar, char closeparenthesisChar, bool bRemoveParenthesisChars, char commentChar)
{
this->tokens_.clear();
this->bTokenInSafemode_.clear();
@@ -227,7 +205,7 @@
if (!this->tokens_.empty())
{
std::string retVal = this->tokens_[0];
- for (unsigned int i = 1; i < this->tokens_.size(); ++i)
+ for (size_t i = 1; i < this->tokens_.size(); ++i)
retVal += delimiter + this->tokens_[i];
return retVal;
}
@@ -238,37 +216,20 @@
/**
@brief Creates a subset of this SubString.
@param begin The beginning of the subset
+ @param length The length of the subset
@return A new SubString containing the defined subset.
- The subset ranges from the token with index @a begin to the end of the tokens.
- If @a begin is greater than the greatest index, the new SubString will be empty.
+ The subset ranges from the token with index @a begin and contains @a length elements.
This function is added for your convenience, and does the same as
- SubString::SubString(const SubString& other, unsigned int begin)
+ SubString::SubString(const SubString& other, size_t begin, size_t length)
*/
- SubString SubString::subSet(unsigned int begin) const
+ SubString SubString::subSet(size_t begin, size_t length) const
{
- return SubString(*this, begin);
+ return SubString(*this, begin, length);
}
/**
- @brief Creates a subset of this SubString.
- @param begin The beginning of the subset
- @param end The ending of the subset
- @return A new SubString containing the defined subset.
-
- The subset ranges from the token with index @a begin until (but not including) the token with index @a end.
- If @a begin or @a end are beyond the allowed index, the resulting SubString will be empty.
-
- This function is added for your convenience, and does the same as
- SubString::SubString(const SubString& other, unsigned int begin, unsigned int end)
- */
- SubString SubString::subSet(unsigned int begin, unsigned int end) const
- {
- return SubString(*this, begin, end);
- }
-
- /**
@copydoc SubString(const std::string&,const std::string&,const std::string&,bool,char,bool,char,bool,char,char,bool,char)
@param tokens The array, where the splitted strings will be stored in
@param bTokenInSafemode A vector wich stores for each character of the string if it is in safemode or not
@@ -297,8 +258,8 @@
SPLIT_LINE_STATE start_state)
{
SPLIT_LINE_STATE state = start_state;
- unsigned int i = 0;
- unsigned int fallBackNeighbours = 0;
+ size_t i = 0;
+ size_t fallBackNeighbours = 0;
std::string token;
bool inSafemode = false;
@@ -513,7 +474,7 @@
void SubString::debug() const
{
orxout(debug_output) << "Substring-information::count=" << this->tokens_.size() << " ::";
- for (unsigned int i = 0; i < this->tokens_.size(); ++i)
+ for (size_t i = 0; i < this->tokens_.size(); ++i)
orxout(debug_output) << "s" << i << "='" << this->tokens_[i].c_str() << "'::";
orxout(debug_output) << endl;
}
Modified: code/trunk/src/libraries/util/SubString.h
===================================================================
--- code/trunk/src/libraries/util/SubString.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/SubString.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -57,7 +57,7 @@
std::string text = "This is a test, \"Hello \\\" World\" and vector {1, 2, 3}";
SubString tokens(text, SubString::WhiteSpaces, "", false, '\\', true, '"', true, '{', '}', true, '\0');
- for (unsigned int i = 0; i < tokens.size(); ++i)
+ for (size_t i = 0; i < tokens.size(); ++i)
orxout() << i << ": " << tokens[i] << endl;
@endcode
@@ -126,16 +126,14 @@
char closeparenthesisChar = '}',
bool bRemoveParenthesisChars = true,
char commentChar = '\0');
- SubString(unsigned int argc, const char** argv);
- SubString(const SubString& other, unsigned int begin);
- SubString(const SubString& other, unsigned int begin, unsigned int end);
+ SubString(size_t argc, const char** argv);
+ SubString(const SubString& other, size_t begin, size_t length = std::string::npos);
~SubString();
// operate on the SubString
SubString& operator=(const SubString& other);
bool operator==(const SubString& other) const;
- bool compare(const SubString& other) const;
- bool compare(const SubString& other, unsigned int length) const;
+ bool compare(const SubString& other, size_t length = std::string::npos) const;
SubString operator+(const SubString& other) const;
SubString& operator+=(const SubString& other);
/// Appends the tokens of another SubString to this. @return This SubString.
@@ -143,39 +141,38 @@
/////////////////////////////////////////
// Split and Join the any String. ///////
- unsigned int split(const std::string& line,
- const std::string& delimiters = SubString::WhiteSpaces,
- const std::string& delimiterNeighbours = "",
- bool bAllowEmptyEntries = false,
- char escapeChar ='\\',
- bool bRemoveEscapeChar = true,
- char safemodeChar = '"',
- bool bRemoveSafemodeChar = true,
- char openparenthesisChar = '{',
- char closeparenthesisChar = '}',
- bool bRemoveParenthesisChars = true,
- char commentChar = '\0');
+ size_t split(const std::string& line,
+ const std::string& delimiters = SubString::WhiteSpaces,
+ const std::string& delimiterNeighbours = "",
+ bool bAllowEmptyEntries = false,
+ char escapeChar ='\\',
+ bool bRemoveEscapeChar = true,
+ char safemodeChar = '"',
+ bool bRemoveSafemodeChar = true,
+ char openparenthesisChar = '{',
+ char closeparenthesisChar = '}',
+ bool bRemoveParenthesisChars = true,
+ char commentChar = '\0');
std::string join(const std::string& delimiter = " ") const;
////////////////////////////////////////
// retrieve a SubSet from the String
- SubString subSet(unsigned int begin) const;
- SubString subSet(unsigned int begin, unsigned int end) const;
+ SubString subSet(size_t begin, size_t length = std::string::npos) const;
// retrieve Information from within
/// Returns true if the SubString is empty
inline bool empty() const { return this->tokens_.empty(); }
/// Returns the number of tokens stored in this SubString
- inline unsigned int size() const { return this->tokens_.size(); }
+ inline size_t size() const { return this->tokens_.size(); }
/// Returns the i'th token from the subset of strings @param index The index of the requested token
- inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; }
+ inline const std::string& operator[](size_t index) const { return this->tokens_[index]; }
/// Returns the i'th token from the subset of strings @param index The index of the requested token
- inline const std::string& getString(unsigned int index) const { return (*this)[index]; }
+ inline const std::string& getString(size_t index) const { return (*this)[index]; }
/// Returns all tokens as std::vector
inline const std::vector<std::string>& getAllStrings() const { return this->tokens_; }
/// Returns true if the token is in safemode. @param index The index of the token
- inline bool isInSafemode(unsigned int index) const { return this->bTokenInSafemode_[index]; }
+ inline bool isInSafemode(size_t index) const { return this->bTokenInSafemode_[index]; }
/// Returns the front of the list of tokens.
inline const std::string& front() const { return this->tokens_.front(); }
/// Returns the back of the list of tokens.
Modified: code/trunk/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/trunk/src/libraries/util/UtilPrereqs.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/UtilPrereqs.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -83,9 +83,14 @@
namespace orxonox
{
+ class AdditionalContextListener;
+ class BaseWriter;
class Clock;
+ class ConsoleWriter;
class Exception;
class ExprParser;
+ class LogWriter;
+ class MemoryWriter;
class MultiType;
class OutputListener;
class OutputManager;
@@ -95,9 +100,12 @@
template <class, ScopeID::Value>
class ScopedSingleton;
class ScopeListener;
+ template <class T>
+ class SharedPtr;
class SignalHandler;
template <class T>
class Singleton;
+ class SubcontextOutputListener;
class SubString;
}
Modified: code/trunk/src/libraries/util/VA_NARGS.h
===================================================================
--- code/trunk/src/libraries/util/VA_NARGS.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/VA_NARGS.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -35,6 +35,8 @@
(of course overloading is not possible for different types, as macros are not
type aware, but for different numbers of arguments is still very powerful).
+ Important: The macro can not be overloaded for 0 arguments: ORXONOX_VA_NARGS() returns 1!
+
Example: A macro to call functions
@code
myfunction(); // A static function
@@ -63,6 +65,7 @@
the number of arguments ("1" - "N"). Then all arguments are passed to the right macro.
*/
+#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/facilities/expand.hpp>
/**
Copied: code/trunk/src/libraries/util/output/AdditionalContextListener.h (from rev 9549, code/branches/testing/src/libraries/util/output/AdditionalContextListener.h)
===================================================================
--- code/trunk/src/libraries/util/output/AdditionalContextListener.h (rev 0)
+++ code/trunk/src/libraries/util/output/AdditionalContextListener.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -0,0 +1,60 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @ingroup Output
+ @brief Declaration of the AdditionalContextListener interface
+*/
+
+#ifndef _AdditionalContextListener_H__
+#define _AdditionalContextListener_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <vector>
+
+#include "OutputDefinitions.h"
+
+namespace orxonox
+{
+ /**
+ @brief AdditionalContextListener is an interface which is used to notify OutputManager about additional contexts in OutputListeners
+ */
+ class _UtilExport AdditionalContextListener
+ {
+ public:
+ virtual ~AdditionalContextListener() {}
+
+ virtual void updatedLevelMask(const OutputListener* listener) = 0;
+ virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener) = 0;
+ virtual void updatedAdditionalContextsMask(const OutputListener* listener) = 0;
+ };
+}
+
+#endif /* _AdditionalContextListener_H__ */
Modified: code/trunk/src/libraries/util/output/ConsoleWriter.cc
===================================================================
--- code/trunk/src/libraries/util/output/ConsoleWriter.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -33,7 +33,6 @@
#include "ConsoleWriter.h"
-#include <iostream>
#include "OutputManager.h"
@@ -47,7 +46,7 @@
After creation, the instance is enabled.
*/
- ConsoleWriter::ConsoleWriter() : BaseWriter("Console")
+ ConsoleWriter::ConsoleWriter(std::ostream& outputStream) : BaseWriter("Console"), outputStream_(outputStream)
{
#ifdef ORXONOX_RELEASE
this->setLevelMax(level::user_info);
@@ -65,20 +64,11 @@
}
/**
- @brief Returns the only existing instance of this class.
- */
- /*static*/ ConsoleWriter& ConsoleWriter::getInstance()
- {
- static ConsoleWriter instance;
- return instance;
- }
-
- /**
@brief Inherited function from BaseWriter, writes output to the console using std::cout.
*/
void ConsoleWriter::printLine(const std::string& line, OutputLevel)
{
- std::cout << line << std::endl;
+ this->outputStream_ << line << std::endl;
}
/**
Modified: code/trunk/src/libraries/util/output/ConsoleWriter.h
===================================================================
--- code/trunk/src/libraries/util/output/ConsoleWriter.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -36,6 +36,9 @@
#define _ConsoleWriter_H__
#include "util/UtilPrereqs.h"
+
+#include <ostream>
+
#include "BaseWriter.h"
namespace orxonox
@@ -43,26 +46,27 @@
/**
@brief ConsoleWriter inherits from BaseWriter and writes output to the console.
- This class can be seen as an equivalent to std::cout within the output
- system. It is implemented as a singleton for static acces.
+ This class can be seen as an equivalent to std::cout within the output system.
*/
class _UtilExport ConsoleWriter : public BaseWriter
{
public:
- static ConsoleWriter& getInstance();
+ ConsoleWriter(std::ostream& outputStream);
+ ConsoleWriter(const ConsoleWriter&);
+ virtual ~ConsoleWriter();
void enable();
void disable();
+ inline const std::ostream& getOutputStream() const
+ { return this->outputStream_; }
+
protected:
virtual void printLine(const std::string& line, OutputLevel level);
private:
- ConsoleWriter();
- ConsoleWriter(const ConsoleWriter&);
- virtual ~ConsoleWriter();
-
- bool bEnabled_; ///< If false, the instance will not write output to the console.
+ std::ostream& outputStream_; ///< The ostream to which the console writer writes its output
+ bool bEnabled_; ///< If false, the instance will not write output to the console.
};
}
Modified: code/trunk/src/libraries/util/output/LogWriter.cc
===================================================================
--- code/trunk/src/libraries/util/output/LogWriter.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/LogWriter.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -38,9 +38,12 @@
#include "OutputManager.h"
#include "MemoryWriter.h"
+#include "util/Convert.h"
namespace orxonox
{
+ static const int MAX_ARCHIVED_FILES = 9;
+
/**
@brief Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.
@@ -57,12 +60,14 @@
// get the path for a temporary file, depending on the system
#ifdef ORXONOX_PLATFORM_WINDOWS
- this->path_ = getenv("TEMP");
+ this->directory_ = getenv("TEMP");
#else
- this->path_ = "/tmp";
+ this->directory_ = "/tmp";
#endif
- this->bDefaultPath_ = true;
+ // send a message to the user so that he can find the file in the case of a crash.
+ OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + this->getPath());
+
this->openFile();
}
@@ -75,28 +80,15 @@
}
/**
- @brief Returns the only existing instance of this class.
- */
- /*static*/ LogWriter& LogWriter::getInstance()
- {
- static LogWriter instance;
- return instance;
- }
-
- /**
@brief Opens the log-file in order to write output to it.
*/
void LogWriter::openFile()
{
- // get the full file-name
- std::string name = this->path_ + '/' + this->filename_;
+ // archive the old log file
+ this->archive();
- // if we open the log file in the default directory, send a message to the user so that he can find the file in the case of a crash.
- if (this->bDefaultPath_)
- OutputManager::getInstance().pushMessage(level::user_info, context::undefined(), "Opening log file " + name);
-
// open the file
- this->file_.open(name.c_str(), std::fstream::out);
+ this->file_.open(this->getPath().c_str(), std::fstream::out);
// check if it worked and print some output
if (this->file_.is_open())
@@ -118,21 +110,65 @@
}
/**
+ * @brief Archives old copies of the log file by adding increasing numbers to the filename.
+ */
+ void LogWriter::archive(int index)
+ {
+ std::string oldPath = this->getArchivedPath(index);
+
+ // see if the file already exists, otherwise return
+ std::ifstream stream(oldPath.c_str());
+ bool exists = stream.is_open();
+ stream.close();
+
+ if (!exists)
+ return;
+
+ if (index < MAX_ARCHIVED_FILES)
+ {
+ // increment the index and archive the file with the next higher index
+ this->archive(++index);
+
+ // create the new path based on the incremented index
+ std::string newPath = this->getArchivedPath(index);
+
+ // move the file
+ std::rename(oldPath.c_str(), newPath.c_str());
+ }
+ else
+ {
+ // delete the file
+ std::remove(oldPath.c_str());
+ }
+ }
+
+ /**
+ * @brief Returns the path for archived copies of the logfile (based on the archive index)
+ */
+ std::string LogWriter::getArchivedPath(int index) const
+ {
+ std::string path = this->getPath();
+ if (index > 0)
+ path += '.' + multi_cast<std::string>(index);
+ return path;
+ }
+
+ /**
@brief Changes the path of the log-file. Re-writes the log-file by using MemoryWriter.
*/
- void LogWriter::setLogPath(const std::string& path)
+ void LogWriter::setLogDirectory(const std::string& directory)
{
// notify about the change of the log-file (because the old file will no longer be updated)
- OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->path_ + "\nto " + path);
+ OutputManager::getInstance().pushMessage(level::internal_info, context::undefined(), "Migrating log file from " + this->directory_ + "\nto " + directory);
// close the old file, update the path and open the new file
this->closeFile();
- this->path_ = path;
- this->bDefaultPath_ = false;
+ this->directory_ = directory;
this->openFile();
// request old output from MemoryWriter
- MemoryWriter::getInstance().resendOutput(this);
+ if (OutputManager::getInstance().getMemoryWriter())
+ OutputManager::getInstance().getMemoryWriter()->resendOutput(this);
}
/**
Modified: code/trunk/src/libraries/util/output/LogWriter.h
===================================================================
--- code/trunk/src/libraries/util/output/LogWriter.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/LogWriter.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -46,8 +46,7 @@
/**
@brief The LogWriter class inherits from BaseWriter and writes output to a log-file.
- It is implemented as singleton because we (currently) use only one
- log-file. The path of the file can be changed, in which case the file
+ The path of the file can be changed, in which case the file
is rewritten by using the output stored by MemoryWriter. This adds the
possibility to change the desired output levels before changing the
path in order to get the complete output with the new output levels
@@ -56,25 +55,31 @@
class _UtilExport LogWriter : public BaseWriter
{
public:
- static LogWriter& getInstance();
+ LogWriter();
+ LogWriter(const LogWriter&);
+ virtual ~LogWriter();
- void setLogPath(const std::string& path);
+ void setLogDirectory(const std::string& directory);
+ /** @brief Returns the path to the logfile. */
+ inline std::string getPath() const
+ { return this->directory_ + '/' + this->filename_; }
+ /** @brief Returns the open file stream. */
+ inline const std::ofstream& getFile() const
+ { return this->file_; }
+
protected:
virtual void printLine(const std::string& line, OutputLevel level);
private:
- LogWriter();
- LogWriter(const LogWriter&);
- virtual ~LogWriter();
-
void openFile();
void closeFile();
- std::string filename_; ///< The name of the log-file (without directories)
- std::string path_; ///< The path of the log-file (without file-name)
- bool bDefaultPath_; ///< If true, the log-file resides at the default path (which is usually a temporary directory)
+ void archive(int index = 0);
+ std::string getArchivedPath(int index) const;
+ std::string filename_; ///< The name of the log-file (without directory)
+ std::string directory_; ///< The directory where the log-file resided (without file-name)
std::ofstream file_; ///< The output file stream.
};
}
Modified: code/trunk/src/libraries/util/output/MemoryWriter.cc
===================================================================
--- code/trunk/src/libraries/util/output/MemoryWriter.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/MemoryWriter.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -52,15 +52,6 @@
}
/**
- @brief Returns the only existing instance of this singleton class.
- */
- /*static*/ MemoryWriter& MemoryWriter::getInstance()
- {
- static MemoryWriter instance;
- return instance;
- }
-
- /**
@brief Implementation of the output() function inherited from OutputListener, stores the received output in memory.
*/
void MemoryWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
Modified: code/trunk/src/libraries/util/output/MemoryWriter.h
===================================================================
--- code/trunk/src/libraries/util/output/MemoryWriter.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/MemoryWriter.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -66,7 +66,9 @@
};
public:
- static MemoryWriter& getInstance();
+ MemoryWriter();
+ MemoryWriter(const MemoryWriter&);
+ virtual ~MemoryWriter();
void resendOutput(OutputListener* listener) const;
void disable();
@@ -75,10 +77,6 @@
virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines);
private:
- MemoryWriter();
- MemoryWriter(const MemoryWriter&);
- virtual ~MemoryWriter();
-
std::vector<Message> messages_; ///< Stores all output messages from the creation of this instance until disable() is called.
};
}
Modified: code/trunk/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputDefinitions.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/OutputDefinitions.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -46,8 +46,13 @@
functions (or the containers they return) can be passed to orxout() as
context argument.
*/
-#define REGISTER_OUTPUT_CONTEXT(name) \
- const OutputContextContainer& name() { static const OutputContextContainer& context = registerContext(#name); return context; }
+#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
+ #define REGISTER_OUTPUT_CONTEXT(name) \
+ const OutputContextContainer& name() { static OutputContextContainer context = registerContext(#name); return context; }
+#else
+ #define REGISTER_OUTPUT_CONTEXT(name) \
+ const OutputContextContainer& name() { return registerContext(#name); }
+#endif
/**
@brief Defines a sub-context.
@@ -59,8 +64,13 @@
more descriptive names (e.g. input::keyboard) and they can be filtered
individually by derivatives of orxonox::SubcontextOutputListener.
*/
-#define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
- const OutputContextContainer& subname() { static const OutputContextContainer& context = registerContext(#name, #subname); return context; }
+#ifndef DISABLE_OUTPUT_CONTEXT_STATIC_CACHE
+ #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
+ const OutputContextContainer& subname() { static const OutputContextContainer context = registerContext(#name, #subname); return context; }
+#else
+ #define REGISTER_OUTPUT_SUBCONTEXT(name, subname) \
+ const OutputContextContainer& subname() { return registerContext(#name, #subname); }
+#endif
// tolua_begin
namespace orxonox
@@ -104,6 +114,11 @@
OutputContextMask mask; ///< The mask of the context (or the mask of the main-context if this container defines a sub-context)
OutputContextSubID sub_id; ///< The id of the sub-context (or context::no_subcontext if this container doesn't define a sub-context)
std::string name; ///< The name of this context
+
+ inline bool operator==(const OutputContextContainer& other) const
+ {
+ return this->mask == other.mask && this->sub_id == other.sub_id && this->name == other.name;
+ }
};
typedef const OutputContextContainer& (OutputContextFunction)();
Modified: code/trunk/src/libraries/util/output/OutputListener.cc
===================================================================
--- code/trunk/src/libraries/util/output/OutputListener.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/OutputListener.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -61,6 +61,29 @@
}
/**
+ @brief Adds a listener to the list.
+ */
+ void OutputListener::registerListener(AdditionalContextListener* listener)
+ {
+ this->listeners_.push_back(listener);
+ }
+
+ /**
+ @brief Removes a listener from the list.
+ */
+ void OutputListener::unregisterListener(AdditionalContextListener* listener)
+ {
+ for (std::vector<AdditionalContextListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+ {
+ if (*it == listener)
+ {
+ this->listeners_.erase(it);
+ break;
+ }
+ }
+ }
+
+ /**
@brief Defines the level mask in a way which accepts all output up to the level \c max.
*/
void OutputListener::setLevelMax(OutputLevel max)
@@ -87,7 +110,8 @@
{
this->levelMask_ = mask;
- OutputManager::getInstance().updateCombinedLevelMask();
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ this->listeners_[i]->updatedLevelMask(this);
}
/**
@@ -117,7 +141,8 @@
{
this->additionalContextsLevelMask_ = mask;
- OutputManager::getInstance().updateCombinedAdditionalContextsLevelMask();
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ this->listeners_[i]->updatedAdditionalContextsLevelMask(this);
}
/**
@@ -127,7 +152,8 @@
{
this->additionalContextsMask_ = mask;
- OutputManager::getInstance().updateCombinedAdditionalContextsMask();
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ this->listeners_[i]->updatedAdditionalContextsMask(this);
}
/**
Modified: code/trunk/src/libraries/util/output/OutputListener.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputListener.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/OutputListener.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -54,6 +54,9 @@
OutputListener(bool bRegister = true);
virtual ~OutputListener();
+ void registerListener(AdditionalContextListener* listener);
+ void unregisterListener(AdditionalContextListener* listener);
+
void setLevelMax(OutputLevel max);
void setLevelRange(OutputLevel min, OutputLevel max);
void setLevelMask(OutputLevel mask);
@@ -62,7 +65,7 @@
void setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max);
void setAdditionalContextsLevelMask(OutputLevel mask);
- void setAdditionalContextsMask(OutputContextMask mask);
+ virtual void setAdditionalContextsMask(OutputContextMask mask);
/// @brief Returns the level mask.
inline OutputLevel getLevelMask() const
@@ -77,17 +80,22 @@
virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
/// @brief Called by OutputManager for each line of output, checks if this listener actually accepts this output before it calls the output() function.
- inline void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
+ virtual void unfilteredOutput(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
{ if (this->acceptsOutput(level, context)) this->output(level, context, lines); }
protected:
/// @brief Pure virtual function, needs to be implemented in order to receive output.
virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines) = 0;
+ inline const std::vector<AdditionalContextListener*>& getListeners() const
+ { return this->listeners_; }
+
private:
- OutputLevel levelMask_; ///< Mask of accepted output levels, independent of contexts
- OutputContextMask additionalContextsMask_; ///< Mask of accepted additional contexts
- OutputLevel additionalContextsLevelMask_; ///< Mask of accepted output levels of the additional contexts
+ std::vector<AdditionalContextListener*> listeners_; ///< List of all registered additional context listeners
+
+ OutputLevel levelMask_; ///< Mask of accepted output levels, independent of contexts
+ OutputContextMask additionalContextsMask_; ///< Mask of accepted additional contexts
+ OutputLevel additionalContextsLevelMask_; ///< Mask of accepted output levels of the additional contexts
};
/**
Modified: code/trunk/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/trunk/src/libraries/util/output/OutputManager.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/OutputManager.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -33,11 +33,14 @@
#include "OutputManager.h"
+#include <iostream>
+
#include "MemoryWriter.h"
#include "ConsoleWriter.h"
#include "LogWriter.h"
#include "util/Output.h"
#include "util/StringUtils.h"
+#include "util/SharedPtr.h"
namespace orxonox
{
@@ -51,6 +54,14 @@
this->combinedAdditionalContextsMask_ = context::none;
this->subcontextCounter_ = 0;
+
+ this->isInitialized_ = false;
+ this->memoryWriterInstance_ = 0;
+ this->consoleWriterInstance_ = 0;
+ this->logWriterInstance_ = 0;
+
+ // register 'undefined' context in order to give it always the first context-ID
+ this->registerContext("undefined");
}
/**
@@ -58,15 +69,29 @@
*/
OutputManager::~OutputManager()
{
+ while (!this->listeners_.empty())
+ this->unregisterListener(this->listeners_[0]);
+
+ if (this->memoryWriterInstance_)
+ delete this->memoryWriterInstance_;
+ if (this->consoleWriterInstance_)
+ delete this->consoleWriterInstance_;
+ if (this->logWriterInstance_)
+ delete this->logWriterInstance_;
}
+ /*static*/ SharedPtr<OutputManager>& OutputManager::Testing::getInstancePointer()
+ {
+ static SharedPtr<OutputManager> instance(new OutputManager());
+ return instance;
+ }
+
/**
@brief Returns the only existing instance of the OutputManager singleton.
*/
/*static*/ OutputManager& OutputManager::getInstance()
{
- static OutputManager instance;
- return instance;
+ return *OutputManager::Testing::getInstancePointer();
}
/**
@@ -79,11 +104,14 @@
*/
/*static*/ OutputManager& OutputManager::getInstanceAndCreateListeners()
{
- static OutputManager& instance = OutputManager::getInstance();
+ OutputManager& instance = *OutputManager::Testing::getInstancePointer();
- static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
- static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
- static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
+ if (!instance.isInitialized_) {
+ instance.isInitialized_ = true;
+ instance.memoryWriterInstance_ = new MemoryWriter();
+ instance.consoleWriterInstance_ = new ConsoleWriter(std::cout);
+ instance.logWriterInstance_ = new LogWriter();
+ }
return instance;
}
@@ -112,6 +140,7 @@
*/
void OutputManager::registerListener(OutputListener* listener)
{
+ listener->registerListener(this);
this->listeners_.push_back(listener);
this->updateMasks();
}
@@ -121,6 +150,7 @@
*/
void OutputManager::unregisterListener(OutputListener* listener)
{
+ listener->unregisterListener(this);
for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
{
if (*it == listener)
@@ -266,7 +296,7 @@
std::string OutputManager::getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const
{
// "undefined" context is ignored because it's used implicitly if no explicit context is defined
- static OutputContextMask undefined_mask = context::undefined().mask;
+ OutputContextMask undefined_mask = context::undefined().mask;
std::string prefix = this->getLevelName(level) + ": ";
if (context.mask != undefined_mask)
Modified: code/trunk/src/libraries/util/output/OutputManager.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputManager.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/OutputManager.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -42,6 +42,7 @@
#include <map>
#include "OutputDefinitions.h"
+#include "AdditionalContextListener.h"
namespace orxonox
{
@@ -60,22 +61,32 @@
Additionally OutputManager is used to register output contexts.
*/
- class _UtilExport OutputManager
+ class _UtilExport OutputManager : public AdditionalContextListener
{
public:
+ OutputManager();
+ OutputManager(const OutputManager&);
+ virtual ~OutputManager();
+
static OutputManager& getInstance();
static OutputManager& getInstanceAndCreateListeners();
- void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
+ inline MemoryWriter* getMemoryWriter() { return this->memoryWriterInstance_; }
+ inline ConsoleWriter* getConsoleWriter() { return this->consoleWriterInstance_; }
+ inline LogWriter* getLogWriter() { return this->logWriterInstance_; }
- void registerListener(OutputListener* listener);
- void unregisterListener(OutputListener* listener);
+ virtual void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
- void updateMasks();
- void updateCombinedLevelMask();
- void updateCombinedAdditionalContextsLevelMask();
- void updateCombinedAdditionalContextsMask();
+ virtual void registerListener(OutputListener* listener);
+ virtual void unregisterListener(OutputListener* listener);
+ virtual void updatedLevelMask(const OutputListener* listener)
+ { this->updateCombinedLevelMask(); }
+ virtual void updatedAdditionalContextsLevelMask(const OutputListener* listener)
+ { this->updateCombinedAdditionalContextsLevelMask(); }
+ virtual void updatedAdditionalContextsMask(const OutputListener* listener)
+ { this->updateCombinedAdditionalContextsMask(); }
+
/**
@brief Returns true if at least one of the output listeners will accept output with the given level and context.
@@ -94,10 +105,18 @@
const std::string& getLevelName(OutputLevel level) const;
std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
+ inline const std::vector<OutputListener*>& getListeners() const
+ { return this->listeners_; }
+
+ inline OutputLevel getCombinedLevelMask() const { return this->combinedLevelMask_; }
+ inline OutputLevel getCombinedAdditionalContextsLevelMask() const { return this->combinedAdditionalContextsLevelMask_; }
+ inline OutputContextMask getCombinedAdditionalContextsMask() const { return this->combinedAdditionalContextsMask_; }
+
private:
- OutputManager();
- OutputManager(const OutputManager&);
- ~OutputManager();
+ void updateMasks();
+ void updateCombinedLevelMask();
+ void updateCombinedAdditionalContextsLevelMask();
+ void updateCombinedAdditionalContextsMask();
std::vector<OutputListener*> listeners_; ///< List of all registered output listeners
@@ -108,6 +127,17 @@
std::map<std::string, OutputContextMask> contextMasks_; ///< Contains all main-contexts and their masks
std::map<std::string, OutputContextContainer> contextContainers_; ///< Contains all contexts including sub-contexts and their containers
OutputContextSubID subcontextCounter_; ///< Counts the number of sub-contexts (and generates their IDs)
+
+ bool isInitialized_; ///< Becomes true once the following instances were created
+ MemoryWriter* memoryWriterInstance_; ///< The main instance of MemoryWriter, managed by OutputManager
+ ConsoleWriter* consoleWriterInstance_; ///< The main instance of ConsoleWriter, managed by OutputManager
+ LogWriter* logWriterInstance_; ///< The main instance of LogWriter, managed by OutputManager
+
+ public:
+ struct _UtilExport Testing
+ {
+ static SharedPtr<OutputManager>& getInstancePointer();
+ };
};
}
Modified: code/trunk/src/libraries/util/output/OutputStream.h
===================================================================
--- code/trunk/src/libraries/util/output/OutputStream.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/OutputStream.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -101,6 +101,10 @@
return *this;
}
+ inline const OutputLevel getOutputLevel() const { return this->level_; }
+ inline const OutputContextContainer* getOutputContext() const { return this->context_; }
+ inline bool acceptsOutput() const { return this->bAcceptsOutput_; }
+
private:
/// @brief Generic function to add values to the output stream, using the inherited << operator from std::ostringstream.
template <class T>
Modified: code/trunk/src/libraries/util/output/SubcontextOutputListener.h
===================================================================
--- code/trunk/src/libraries/util/output/SubcontextOutputListener.h 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/libraries/util/output/SubcontextOutputListener.h 2013-03-12 22:13:03 UTC (rev 9550)
@@ -72,11 +72,14 @@
SubcontextOutputListener(bool bRegister = true);
virtual ~SubcontextOutputListener();
- void setAdditionalContextsMask(OutputContextMask mask);
+ virtual void setAdditionalContextsMask(OutputContextMask mask);
void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
+ inline const std::set<OutputContextSubID>& getSubcontexts() const
+ { return this->subcontexts_; }
+
private:
OutputContextMask subcontextsCheckMask_; ///< All contexts defined by this mask need to be checked whether they are accepted by the set of sub-contexts
OutputContextMask subcontextsNoCheckMask_; ///< All contexts defined by this mask don't need to be checked since we accept all sub-contexts
Modified: code/trunk/src/modules/notifications/dispatchers/CommandNotification.cc
===================================================================
--- code/trunk/src/modules/notifications/dispatchers/CommandNotification.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/modules/notifications/dispatchers/CommandNotification.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -116,19 +116,19 @@
//TODO: Move to KeyBinderManager...
const std::string& CommandNotification::bindingNiceifyer(const std::string& binding)
{
- SubString string = SubString(binding, ".");
+ SubString substring = SubString(binding, ".");
std::string name;
std::string group;
- switch(string.size())
+ switch(substring.size())
{
case 0:
return binding;
case 1:
return binding;
case 2:
- group = string[0];
+ group = substring[0];
default:
- name = string.subSet(1, string.size()).join(".");
+ name = substring.subSet(1).join(".");
}
std::stringstream stream;
@@ -147,5 +147,5 @@
return *(new std::string(stream.str()));
}
-
+
}
Modified: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/orxonox/LevelManager.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -64,7 +64,7 @@
// check override
if (!CommandLineParser::getArgument("level")->hasDefaultValue())
{
- ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").getString());
+ ModifyConfigValue(defaultLevelName_, tset, CommandLineParser::getValue("level").get<std::string>());
}
this->compileAvailableLevelList();
Modified: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/orxonox/Main.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -67,7 +67,7 @@
Game* game = new Game(strCmdLine);
orxout(user_status) << "Finished initialization" << endl;
- if (CommandLineParser::getValue("generateDoc").getString().empty())
+ if (CommandLineParser::getValue("generateDoc").get<std::string>().empty())
{
orxout(internal_info) << "preparing game states" << endl;
@@ -85,22 +85,22 @@
game->requestState("root");
// Some development hacks (not really, but in the future, these calls won't make sense anymore)
- if (CommandLineParser::getValue("standalone").getBool())
+ if (CommandLineParser::getValue("standalone").get<bool>())
Game::getInstance().requestStates("graphics, standalone, level");
- else if (CommandLineParser::getValue("server").getBool())
+ else if (CommandLineParser::getValue("server").get<bool>())
Game::getInstance().requestStates("graphics, server, level");
- else if (CommandLineParser::getValue("client").getBool())
+ else if (CommandLineParser::getValue("client").get<bool>())
Game::getInstance().requestStates("graphics, client, level");
- else if (CommandLineParser::getValue("dedicated").getBool())
+ else if (CommandLineParser::getValue("dedicated").get<bool>())
Game::getInstance().requestStates("server, level");
- else if (CommandLineParser::getValue("dedicatedClient").getBool())
+ else if (CommandLineParser::getValue("dedicatedClient").get<bool>())
Game::getInstance().requestStates("client, level");
/* ADD masterserver command */
- else if (CommandLineParser::getValue("masterserver").getBool())
+ else if (CommandLineParser::getValue("masterserver").get<bool>())
Game::getInstance().requestStates("masterserver");
else
{
- if (!CommandLineParser::getValue("console").getBool())
+ if (!CommandLineParser::getValue("console").get<bool>())
Game::getInstance().requestStates("graphics, mainMenu");
}
Modified: code/trunk/src/orxonox/graphics/ParticleEmitter.cc
===================================================================
--- code/trunk/src/orxonox/graphics/ParticleEmitter.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/orxonox/graphics/ParticleEmitter.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -70,7 +70,7 @@
{
SUPER(ParticleEmitter, XMLPort, xmlelement, mode);
- XMLPortParam(ParticleEmitter, "lod", setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::Normal);
+ XMLPortParam(ParticleEmitter, "lod", setLODxml, getLODxml, xmlelement, mode).defaultValues(static_cast<unsigned int>(LODParticle::Normal));
XMLPortParam(ParticleEmitter, "source", setSource, getSource, xmlelement, mode);
}
Modified: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc 2013-03-12 22:13:03 UTC (rev 9550)
@@ -46,6 +46,7 @@
#include "util/DisplayStringConversions.h"
#include "util/ScopedSingletonManager.h"
#include "util/output/MemoryWriter.h"
+#include "util/output/OutputManager.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/command/ConsoleCommand.h"
@@ -94,7 +95,7 @@
// Output buffering is not anymore needed. Not the best solution to do
// this here, but there isn't much of another way.
- MemoryWriter::getInstance().disable();
+ OutputManager::getInstance().getMemoryWriter()->disable();
}
/**
Deleted: code/trunk/src/orxonox-main.vcproj.user.in
===================================================================
--- code/trunk/src/orxonox-main.vcproj.user.in 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/orxonox-main.vcproj.user.in 2013-03-12 22:13:03 UTC (rev 9550)
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioUserFile
- ProjectType="Visual C++"
- Version="${VISUAL_STUDIO_VERSION_SIMPLE}.00"
- ShowAllFiles="false"
- >
- <Configurations>
- <Configuration
- Name="Debug|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="RelForDevs|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="Release|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="MinSizeRel|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
- EnvironmentMerge="true"
- />
- </Configuration>
- <Configuration
- Name="RelWithDebInfo|${MSVC_PLATFORM}"
- >
- <DebugSettings
- WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
- Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
- EnvironmentMerge="true"
- />
- </Configuration>
- </Configurations>
-</VisualStudioUserFile>
Deleted: code/trunk/src/orxonox-main.vcxproj.user.in
===================================================================
--- code/trunk/src/orxonox-main.vcxproj.user.in 2013-03-12 21:37:37 UTC (rev 9549)
+++ code/trunk/src/orxonox-main.vcxproj.user.in 2013-03-12 22:13:03 UTC (rev 9550)
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|${MSVC_PLATFORM}'">
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
- <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelForDevs|${MSVC_PLATFORM}'">
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
- <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|${MSVC_PLATFORM}'">
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
- <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|${MSVC_PLATFORM}'">
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
- <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|${MSVC_PLATFORM}'">
- <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
- <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
- <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
- </PropertyGroup>
-</Project>
Copied: code/trunk/src/template.vcproj.user.in (from rev 9549, code/branches/testing/src/template.vcproj.user.in)
===================================================================
--- code/trunk/src/template.vcproj.user.in (rev 0)
+++ code/trunk/src/template.vcproj.user.in 2013-03-12 22:13:03 UTC (rev 9550)
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="${VISUAL_STUDIO_VERSION_SIMPLE}.00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="Debug|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="RelForDevs|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="MinSizeRel|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ <Configuration
+ Name="RelWithDebInfo|${MSVC_PLATFORM}"
+ >
+ <DebugSettings
+ WorkingDirectory="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$(OutDir)"
+ Environment="PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%"
+ EnvironmentMerge="true"
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
Copied: code/trunk/src/template.vcxproj.user.in (from rev 9549, code/branches/testing/src/template.vcxproj.user.in)
===================================================================
--- code/trunk/src/template.vcxproj.user.in (rev 0)
+++ code/trunk/src/template.vcxproj.user.in 2013-03-12 22:13:03 UTC (rev 9550)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|${MSVC_PLATFORM}'">
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
+ <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelForDevs|${MSVC_PLATFORM}'">
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
+ <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MinSizeRel|${MSVC_PLATFORM}'">
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
+ <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|${MSVC_PLATFORM}'">
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
+ <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|${MSVC_PLATFORM}'">
+ <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
+ <LocalDebuggerEnvironment>PATH=${RUNTIME_LIBRARY_DIRECTORY};%PATH%</LocalDebuggerEnvironment>
+ <LocalDebuggerWorkingDirectory>$(Outdir)</LocalDebuggerWorkingDirectory>
+ </PropertyGroup>
+</Project>
More information about the Orxonox-commit
mailing list