[Orxonox-commit 4187] r8858 - in code/trunk: . data/gui/scripts data/levels data/levels/templates data/lua data/overlays data/tcl src src/libraries/core src/libraries/core/command src/libraries/core/input src/libraries/network src/libraries/network/packet src/libraries/network/synchronisable src/libraries/tools src/libraries/util src/libraries/util/output src/modules/designtools src/modules/docking src/modules/gametypes src/modules/notifications src/modules/objects src/modules/objects/collisionshapes src/modules/objects/eventsystem src/modules/objects/triggers src/modules/overlays src/modules/overlays/hud src/modules/pickup src/modules/pickup/items src/modules/pong src/modules/questsystem src/modules/questsystem/effects src/modules/tetris src/modules/weapons src/modules/weapons/projectiles src/orxonox src/orxonox/chat src/orxonox/collisionshapes src/orxonox/controllers src/orxonox/gamestates src/orxonox/gametypes src/orxonox/graphics src/orxonox/infos src/orxonox/interfaces src/orxonox/items src/orxonox/overlays src/orxonox/pickup src/orxonox/sound src/orxonox/weaponsystem src/orxonox/worldentities src/orxonox/worldentities/pawns
landauf at orxonox.net
landauf at orxonox.net
Tue Aug 23 00:45:55 CEST 2011
Author: landauf
Date: 2011-08-23 00:45:53 +0200 (Tue, 23 Aug 2011)
New Revision: 8858
Added:
code/trunk/src/libraries/network/NetworkChatListener.h
code/trunk/src/libraries/util/Output.h
code/trunk/src/libraries/util/output/
code/trunk/src/libraries/util/output/BaseWriter.cc
code/trunk/src/libraries/util/output/BaseWriter.h
code/trunk/src/libraries/util/output/CMakeLists.txt
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.cc
code/trunk/src/libraries/util/output/OutputStream.h
code/trunk/src/libraries/util/output/SubcontextOutputListener.cc
code/trunk/src/libraries/util/output/SubcontextOutputListener.h
code/trunk/src/orxonox/chat/
code/trunk/src/orxonox/chat/CMakeLists.txt
code/trunk/src/orxonox/chat/ChatHistory.cc
code/trunk/src/orxonox/chat/ChatHistory.h
code/trunk/src/orxonox/chat/ChatInputHandler.cc
code/trunk/src/orxonox/chat/ChatInputHandler.h
code/trunk/src/orxonox/chat/ChatListener.h
code/trunk/src/orxonox/chat/ChatManager.cc
code/trunk/src/orxonox/chat/ChatManager.h
Removed:
code/trunk/data/overlays/OrxonoxLoading.overlay
code/trunk/src/libraries/network/ChatListener.cc
code/trunk/src/libraries/network/ChatListener.h
code/trunk/src/libraries/util/Debug.h
code/trunk/src/libraries/util/OutputHandler.cc
code/trunk/src/libraries/util/OutputHandler.h
code/trunk/src/libraries/util/output/BaseWriter.cc
code/trunk/src/libraries/util/output/BaseWriter.h
code/trunk/src/libraries/util/output/CMakeLists.txt
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.cc
code/trunk/src/libraries/util/output/OutputStream.h
code/trunk/src/libraries/util/output/SubcontextOutputListener.cc
code/trunk/src/libraries/util/output/SubcontextOutputListener.h
code/trunk/src/orxonox/ChatHistory.cc
code/trunk/src/orxonox/ChatHistory.h
code/trunk/src/orxonox/ChatInputHandler.cc
code/trunk/src/orxonox/ChatInputHandler.h
code/trunk/src/orxonox/chat/CMakeLists.txt
code/trunk/src/orxonox/chat/ChatHistory.cc
code/trunk/src/orxonox/chat/ChatHistory.h
code/trunk/src/orxonox/chat/ChatInputHandler.cc
code/trunk/src/orxonox/chat/ChatInputHandler.h
code/trunk/src/orxonox/chat/ChatListener.h
code/trunk/src/orxonox/chat/ChatManager.cc
code/trunk/src/orxonox/chat/ChatManager.h
code/trunk/src/orxonox/graphics/CEGuiSample.cc
code/trunk/src/orxonox/graphics/CEGuiSample.h
Modified:
code/trunk/
code/trunk/CMakeLists.txt
code/trunk/data/gui/scripts/GameplayMenu.lua
code/trunk/data/gui/scripts/MultiplayerMenu.lua
code/trunk/data/gui/scripts/NotificationLayer.lua
code/trunk/data/gui/scripts/QuestGUI.lua
code/trunk/data/levels/presentationDM.oxw
code/trunk/data/levels/templates/FPS.oxt
code/trunk/data/levels/templates/spaceshipAssff.oxt
code/trunk/data/levels/templates/spaceshipAssff2.oxt
code/trunk/data/levels/templates/spaceshipGhost.oxt
code/trunk/data/levels/templates/spaceshipH2.oxt
code/trunk/data/levels/templates/spaceshipHXY.oxt
code/trunk/data/levels/templates/spaceshipHXYSL.oxt
code/trunk/data/levels/templates/spaceshipPirate.oxt
code/trunk/data/levels/templates/spaceshipSwallow.oxt
code/trunk/data/levels/templates/spaceshipTransporter.oxt
code/trunk/data/levels/templates/spaceshipTransporterSL.oxt
code/trunk/data/lua/LuaStateInit.lua
code/trunk/data/overlays/debug.oxo
code/trunk/data/tcl/init.tcl
code/trunk/src/Orxonox.cc
code/trunk/src/OrxonoxConfig.h.in
code/trunk/src/libraries/core/BaseObject.cc
code/trunk/src/libraries/core/CMakeLists.txt
code/trunk/src/libraries/core/ClassFactory.h
code/trunk/src/libraries/core/CommandLineParser.cc
code/trunk/src/libraries/core/CommandLineParser.h
code/trunk/src/libraries/core/ConfigFileManager.cc
code/trunk/src/libraries/core/ConfigValueContainer.cc
code/trunk/src/libraries/core/ConfigValueIncludes.h
code/trunk/src/libraries/core/Core.cc
code/trunk/src/libraries/core/Core.h
code/trunk/src/libraries/core/CoreIncludes.h
code/trunk/src/libraries/core/CorePrecompiledHeaders.h
code/trunk/src/libraries/core/DynLib.cc
code/trunk/src/libraries/core/Event.cc
code/trunk/src/libraries/core/GUIManager.cc
code/trunk/src/libraries/core/GUIManager.h
code/trunk/src/libraries/core/Game.cc
code/trunk/src/libraries/core/Game.h
code/trunk/src/libraries/core/GameState.cc
code/trunk/src/libraries/core/GraphicsManager.cc
code/trunk/src/libraries/core/GraphicsManager.h
code/trunk/src/libraries/core/Identifier.cc
code/trunk/src/libraries/core/Identifier.h
code/trunk/src/libraries/core/Language.cc
code/trunk/src/libraries/core/Language.h
code/trunk/src/libraries/core/Loader.cc
code/trunk/src/libraries/core/Loader.h
code/trunk/src/libraries/core/LuaState.cc
code/trunk/src/libraries/core/LuaState.h
code/trunk/src/libraries/core/MetaObjectList.cc
code/trunk/src/libraries/core/NamespaceNode.cc
code/trunk/src/libraries/core/OrxonoxClass.cc
code/trunk/src/libraries/core/OrxonoxClass.h
code/trunk/src/libraries/core/PathConfig.cc
code/trunk/src/libraries/core/SubclassIdentifier.h
code/trunk/src/libraries/core/Super.h
code/trunk/src/libraries/core/Template.cc
code/trunk/src/libraries/core/WeakPtr.h
code/trunk/src/libraries/core/XMLPort.cc
code/trunk/src/libraries/core/XMLPort.h
code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
code/trunk/src/libraries/core/command/CommandEvaluation.cc
code/trunk/src/libraries/core/command/CommandExecutor.cc
code/trunk/src/libraries/core/command/CommandExecutor.h
code/trunk/src/libraries/core/command/ConsoleCommand.cc
code/trunk/src/libraries/core/command/ConsoleCommand.h
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
code/trunk/src/libraries/core/command/ConsoleCommandCompilation.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/IOConsolePOSIX.h
code/trunk/src/libraries/core/command/IOConsoleWindows.cc
code/trunk/src/libraries/core/command/IOConsoleWindows.h
code/trunk/src/libraries/core/command/IRC.cc
code/trunk/src/libraries/core/command/Shell.cc
code/trunk/src/libraries/core/command/Shell.h
code/trunk/src/libraries/core/command/TclBind.cc
code/trunk/src/libraries/core/command/TclThreadManager.cc
code/trunk/src/libraries/core/input/Button.cc
code/trunk/src/libraries/core/input/InputDevice.h
code/trunk/src/libraries/core/input/InputManager.cc
code/trunk/src/libraries/core/input/JoyStick.cc
code/trunk/src/libraries/core/input/KeyBinder.cc
code/trunk/src/libraries/core/input/KeyBinderManager.cc
code/trunk/src/libraries/network/CMakeLists.txt
code/trunk/src/libraries/network/Client.cc
code/trunk/src/libraries/network/Client.h
code/trunk/src/libraries/network/ClientConnection.cc
code/trunk/src/libraries/network/Connection.cc
code/trunk/src/libraries/network/GamestateManager.cc
code/trunk/src/libraries/network/Host.cc
code/trunk/src/libraries/network/Host.h
code/trunk/src/libraries/network/LANDiscoverable.cc
code/trunk/src/libraries/network/LANDiscovery.cc
code/trunk/src/libraries/network/LANDiscovery.h
code/trunk/src/libraries/network/MasterServer.cc
code/trunk/src/libraries/network/MasterServerComm.cc
code/trunk/src/libraries/network/MasterServerComm.h
code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h
code/trunk/src/libraries/network/NetworkPrereqs.h
code/trunk/src/libraries/network/PeerList.cc
code/trunk/src/libraries/network/Server.cc
code/trunk/src/libraries/network/Server.h
code/trunk/src/libraries/network/ServerConnection.cc
code/trunk/src/libraries/network/TrafficControl.cc
code/trunk/src/libraries/network/WANDiscoverable.cc
code/trunk/src/libraries/network/WANDiscoverable.h
code/trunk/src/libraries/network/WANDiscovery.cc
code/trunk/src/libraries/network/WANDiscovery.h
code/trunk/src/libraries/network/packet/Acknowledgement.cc
code/trunk/src/libraries/network/packet/Chat.cc
code/trunk/src/libraries/network/packet/Chat.h
code/trunk/src/libraries/network/packet/ClassID.cc
code/trunk/src/libraries/network/packet/DeleteObjects.cc
code/trunk/src/libraries/network/packet/FunctionIDs.cc
code/trunk/src/libraries/network/packet/Gamestate.cc
code/trunk/src/libraries/network/packet/Packet.cc
code/trunk/src/libraries/network/packet/Welcome.cc
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
code/trunk/src/libraries/network/synchronisable/Synchronisable.h
code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
code/trunk/src/libraries/tools/BillboardSet.cc
code/trunk/src/libraries/tools/Mesh.cc
code/trunk/src/libraries/tools/ParticleInterface.cc
code/trunk/src/libraries/tools/ResourceCollection.cc
code/trunk/src/libraries/tools/ResourceLocation.cc
code/trunk/src/libraries/tools/Shader.cc
code/trunk/src/libraries/tools/Timer.h
code/trunk/src/libraries/util/CMakeLists.txt
code/trunk/src/libraries/util/Clipboard.cc
code/trunk/src/libraries/util/Convert.h
code/trunk/src/libraries/util/Exception.cc
code/trunk/src/libraries/util/Exception.h
code/trunk/src/libraries/util/ExprParser.h
code/trunk/src/libraries/util/MultiType.h
code/trunk/src/libraries/util/OrxAssert.h
code/trunk/src/libraries/util/Scope.h
code/trunk/src/libraries/util/ScopedSingletonManager.h
code/trunk/src/libraries/util/SignalHandler.cc
code/trunk/src/libraries/util/Singleton.h
code/trunk/src/libraries/util/Sleep.cc
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/modules/designtools/ScreenshotManager.cc
code/trunk/src/modules/designtools/SkyboxGenerator.cc
code/trunk/src/modules/docking/Dock.cc
code/trunk/src/modules/docking/DockToShip.cc
code/trunk/src/modules/docking/DockingController.cc
code/trunk/src/modules/docking/DockingTarget.cc
code/trunk/src/modules/gametypes/RaceCheckPoint.cc
code/trunk/src/modules/gametypes/SpaceRace.cc
code/trunk/src/modules/notifications/NotificationDispatcher.cc
code/trunk/src/modules/notifications/NotificationManager.cc
code/trunk/src/modules/notifications/NotificationQueue.cc
code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc
code/trunk/src/modules/objects/ForceField.cc
code/trunk/src/modules/objects/Planet.cc
code/trunk/src/modules/objects/Script.cc
code/trunk/src/modules/objects/SpaceBoundaries.cc
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
code/trunk/src/modules/objects/eventsystem/EventFilter.cc
code/trunk/src/modules/objects/eventsystem/EventListener.cc
code/trunk/src/modules/objects/eventsystem/EventTarget.cc
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
code/trunk/src/modules/objects/triggers/TriggerBase.cc
code/trunk/src/modules/overlays/GUIOverlay.cc
code/trunk/src/modules/overlays/hud/ChatOverlay.cc
code/trunk/src/modules/overlays/hud/ChatOverlay.h
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
code/trunk/src/modules/overlays/hud/HUDRadar.cc
code/trunk/src/modules/pickup/Pickup.cc
code/trunk/src/modules/pickup/PickupManager.cc
code/trunk/src/modules/pickup/PickupRepresentation.cc
code/trunk/src/modules/pickup/PickupSpawner.cc
code/trunk/src/modules/pickup/items/DronePickup.cc
code/trunk/src/modules/pickup/items/HealthPickup.cc
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
code/trunk/src/modules/pickup/items/MetaPickup.cc
code/trunk/src/modules/pickup/items/ShieldPickup.cc
code/trunk/src/modules/pickup/items/ShrinkPickup.h
code/trunk/src/modules/pickup/items/SpeedPickup.cc
code/trunk/src/modules/pong/Pong.cc
code/trunk/src/modules/questsystem/GlobalQuest.cc
code/trunk/src/modules/questsystem/LocalQuest.cc
code/trunk/src/modules/questsystem/Quest.cc
code/trunk/src/modules/questsystem/QuestDescription.cc
code/trunk/src/modules/questsystem/QuestEffect.cc
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
code/trunk/src/modules/questsystem/QuestHint.cc
code/trunk/src/modules/questsystem/QuestItem.cc
code/trunk/src/modules/questsystem/QuestListener.cc
code/trunk/src/modules/questsystem/QuestManager.cc
code/trunk/src/modules/questsystem/effects/AddQuest.cc
code/trunk/src/modules/questsystem/effects/AddQuestHint.cc
code/trunk/src/modules/questsystem/effects/AddReward.cc
code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
code/trunk/src/modules/questsystem/effects/CompleteQuest.cc
code/trunk/src/modules/questsystem/effects/FailQuest.cc
code/trunk/src/modules/tetris/Tetris.cc
code/trunk/src/modules/weapons/RocketController.cc
code/trunk/src/modules/weapons/projectiles/BasicProjectile.h
code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc
code/trunk/src/orxonox/CMakeLists.txt
code/trunk/src/orxonox/Level.cc
code/trunk/src/orxonox/LevelInfo.cc
code/trunk/src/orxonox/LevelManager.cc
code/trunk/src/orxonox/Main.cc
code/trunk/src/orxonox/MoodManager.cc
code/trunk/src/orxonox/OrxonoxPrereqs.h
code/trunk/src/orxonox/PlayerManager.cc
code/trunk/src/orxonox/Radar.cc
code/trunk/src/orxonox/Scene.cc
code/trunk/src/orxonox/Test.cc
code/trunk/src/orxonox/Test.h
code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
code/trunk/src/orxonox/controllers/ArtificialController.cc
code/trunk/src/orxonox/controllers/HumanController.cc
code/trunk/src/orxonox/controllers/NewHumanController.cc
code/trunk/src/orxonox/gamestates/GSClient.cc
code/trunk/src/orxonox/gamestates/GSLevel.cc
code/trunk/src/orxonox/gamestates/GSMainMenu.cc
code/trunk/src/orxonox/gamestates/GSMasterServer.cc
code/trunk/src/orxonox/gamestates/GSRoot.cc
code/trunk/src/orxonox/gamestates/GSServer.cc
code/trunk/src/orxonox/gametypes/Asteroids.cc
code/trunk/src/orxonox/gametypes/Deathmatch.cc
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
code/trunk/src/orxonox/gametypes/Gametype.cc
code/trunk/src/orxonox/gametypes/LastManStanding.cc
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
code/trunk/src/orxonox/gametypes/UnderAttack.cc
code/trunk/src/orxonox/graphics/AnimatedModel.cc
code/trunk/src/orxonox/graphics/AnimatedModel.h
code/trunk/src/orxonox/graphics/Model.cc
code/trunk/src/orxonox/graphics/ParticleEmitter.cc
code/trunk/src/orxonox/infos/GametypeInfo.cc
code/trunk/src/orxonox/interfaces/PickupCarrier.cc
code/trunk/src/orxonox/interfaces/Pickupable.cc
code/trunk/src/orxonox/interfaces/RadarViewable.cc
code/trunk/src/orxonox/items/Engine.cc
code/trunk/src/orxonox/overlays/InGameConsole.cc
code/trunk/src/orxonox/overlays/InGameConsole.h
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
code/trunk/src/orxonox/pickup/PickupIdentifier.cc
code/trunk/src/orxonox/sound/AmbientSound.cc
code/trunk/src/orxonox/sound/BaseSound.cc
code/trunk/src/orxonox/sound/SoundBuffer.cc
code/trunk/src/orxonox/sound/SoundManager.cc
code/trunk/src/orxonox/sound/SoundStreamer.cc
code/trunk/src/orxonox/sound/WorldSound.cc
code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
code/trunk/src/orxonox/worldentities/BigExplosion.cc
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
code/trunk/src/orxonox/worldentities/MobileEntity.cc
code/trunk/src/orxonox/worldentities/SpawnPoint.cc
code/trunk/src/orxonox/worldentities/StaticEntity.cc
code/trunk/src/orxonox/worldentities/WorldEntity.cc
code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
Log:
merged output branch back to trunk.
Changes:
- you have to include util/Output.h instead of util/Debug.h
- COUT(x) is now called orxout(level)
- output levels are now defined by an enum instead of numbers. see util/Output.h for the definition
- it's possible to use output contexts with orxout(level, context). see util/Output.h for some common contexts. you can define more contexts
- you must use 'endl' at the end of an output message, '\n' does not flush the message
Output levels:
- instead of COUT(0) use orxout()
- instead of COUT(1) use orxout(user_error) or orxout(internal_error)
- instead of COUT(2) use orxout(user_warning) or orxout(internal_warning)
- instead of COUT(3) use orxout(user_status/user_info) or orxout(internal_status/internal_info)
- instead of COUT(4) use orxout(verbose)
- instead of COUT(5) use orxout(verbose_more)
- instead of COUT(6) use orxout(verbose_ultra)
Guidelines:
- user_* levels are for the user, visible in the console and the log-file
- internal_* levels are for developers, visible in the log-file
- verbose_* levels are for debugging, only visible if the context of the output is activated
Usage in C++:
- orxout() << "message" << endl;
- orxout(level) << "message" << endl;
- orxout(level, context) << "message" << endl;
Usage in Lua:
- orxout("message")
- orxout(orxonox.level.levelname, "message")
- orxout(orxonox.level.levelname, "context", "message")
Usage in Tcl (and in the in-game-console):
- orxout levelname message
- orxout_context levelname context message
- shortcuts: log message, error message, warning message, status message, info message, debug message
Property changes on: code/trunk
___________________________________________________________________
Modified: svn:ignore
- build
codeblocks
dependencies
+ build
codeblocks
vs
dependencies
Modified: svn:mergeinfo
- /code/branches/ai:6592-7033
/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/fps:6591-7072
/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/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/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/menu:5941-6146,6148,7536-7687
/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/notifications:7314-7401
/code/branches/objecthierarchy:1911-2085,2100,2110-2169
/code/branches/objecthierarchy2:2171-2479
/code/branches/ois_update:7506-7788
/code/branches/overlay:2117-2385
/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/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/presentation3:6913-7162
/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/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/steering:5949-6091,8140-8595
/code/branches/tetris:8100-8563
/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/ai:6592-7033
/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/fps:6591-7072
/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/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/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/menu:5941-6146,6148,7536-7687
/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/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/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/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/presentation3:6913-7162
/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/skybox2:6559-6989
/code/branches/sound:2829-3010
/code/branches/sound3:5941-6102
/code/branches/spaceboundaries:8085-8457
/code/branches/spaceboundaries2:8460-8613
/code/branches/spacerace:8182-8630
/code/branches/steering:5949-6091,8140-8595
/code/branches/tetris:8100-8563
/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 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -28,6 +28,16 @@
SET(LINUX TRUE)
ENDIF()
+# Keep devs from using the root directory as binary directory (messes up the source tree)
+IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
+ MESSAGE(FATAL_ERROR "Please do not use the root directory as CMake output directory!
+ mkdir build; cd build; cmake ..
+ And you will have to clean the source directory by deleting CMakeCache.txt and the folder CMakeFiles")
+ENDIF()
+
+PROJECT(Orxonox C CXX)
+
+# Check AFTER the PROJECT command because MSVC10 gets defined there
IF(WIN32)
IF(MSVC10)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3 FATAL_ERROR)
@@ -38,15 +48,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
ENDIF()
-# Keep devs from using the root directory as binary directory (messes up the source tree)
-IF(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
- MESSAGE(FATAL_ERROR "Please do not use the root directory as CMake output directory!
- mkdir build; cd build; cmake ..
- And you will have to clean the source directory by deleting CMakeCache.txt and the folder CMakeFiles")
-ENDIF()
-
-PROJECT(Orxonox C CXX)
-
################ General Config #################
# Version info
Modified: code/trunk/data/gui/scripts/GameplayMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/GameplayMenu.lua 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/gui/scripts/GameplayMenu.lua 2011-08-22 22:45:53 UTC (rev 8858)
@@ -17,22 +17,22 @@
function P.GameplayThemeCombobox_changed(e)
-- theme
- logMessage(0, "event: theme")
+ orxout("event: theme")
end
function P.GameplayDifficultyEasyButton_clicked(e)
-- difficulty easy
- logMessage(0, "event: easy")
+ orxout("event: easy")
end
function P.GameplayDifficultyNormalButton_clicked(e)
-- difficulty normal
- logMessage(0, "event: normal")
+ orxout("event: normal")
end
function P.GameplayDifficultyHardButton_clicked(e)
-- difficulty hard
- logMessage(0, "event: hard")
+ orxout("event: hard")
end
function P.GameplayBackButton_clicked(e)
Modified: code/trunk/data/gui/scripts/MultiplayerMenu.lua
===================================================================
--- code/trunk/data/gui/scripts/MultiplayerMenu.lua 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/gui/scripts/MultiplayerMenu.lua 2011-08-22 22:45:53 UTC (rev 8858)
@@ -116,10 +116,10 @@
elseif P.joinMode == 2 then
local listbox = winMgr:getWindow("orxonox/MultiplayerListbox")
CEGUI.toListbox(listbox):resetList()
- local discovery = orxonox.WANDiscovery:getInstance()
- cout(0, "discovering.\n" )
+ local discovery = orxonox.WANDiscovery()
+ orxout("discovering." )
discovery:discover()
- cout(0, "discovered.\n" )
+ orxout("discovered." )
P.serverList = {}
local index = 0
local servername = ""
Modified: code/trunk/data/gui/scripts/NotificationLayer.lua
===================================================================
--- code/trunk/data/gui/scripts/NotificationLayer.lua 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/gui/scripts/NotificationLayer.lua 2011-08-22 22:45:53 UTC (rev 8858)
@@ -135,7 +135,7 @@
local moved = false
if index > queue.first then -- Move all older notifications up in the list.
for i=index-1,-1,queue.first do
- cout(0, i)
+ orxout(i)
item = queue.items[i]
item:setYposition(CEGUI.UDim(0, itemHeight*(queue.last-i-1)))
queue.items[i+1] = item
Modified: code/trunk/data/gui/scripts/QuestGUI.lua
===================================================================
--- code/trunk/data/gui/scripts/QuestGUI.lua 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/gui/scripts/QuestGUI.lua 2011-08-22 22:45:53 UTC (rev 8858)
@@ -219,7 +219,7 @@
-- quest is the quest to be selected.
function P.selectQuest(list, quest)
if quest == nil then -- If the input quest is nil, there is nothing to be selected, an error is output and the first quest is selected instead.
- cout(1, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.")
+ orxout(orxonox.level.internal_error, "Error in QuestGUI: selectQuest(), input quest is nil. Selecting first.")
list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
return
end
@@ -239,7 +239,7 @@
if found then -- If the quest was found it is selected.
list:setItemSelectState(list:getListboxItemFromIndex(index), true)
else -- If the quest isn't found an error is output and the first quest is selected instead.
- cout(1, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.")
+ orxout(orxonox.level.internal_error, "Error in QuestGUI: selectQuest(), input quest is not in list. Selecting first.")
list:setItemSelectState(list:getListboxItemFromIndex(0), true) -- Select first
end
end
@@ -312,7 +312,7 @@
P.loadQuestsList(quest)
end
else
- cout(1, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...")
+ orxout(orxonox.level.internal_error, "Error in QuestGUI: changeToSubquest(), quest was nil. Ignoring...")
end
end
end
Modified: code/trunk/data/levels/presentationDM.oxw
===================================================================
--- code/trunk/data/levels/presentationDM.oxw 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/presentationDM.oxw 2011-08-22 22:45:53 UTC (rev 8858)
@@ -15,6 +15,7 @@
<Level
name = "Presentation"
description = "A simple testlevel"
+ gametype = Deathmatch
>
<templates>
<Template link=lodtemplate_default />
@@ -45,13 +46,14 @@
<?lua
for i = 1, 100, 1 do
j = math.random()
+ scale = j * 50 + 5
?>
- <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass="<?lua print(j * 50) ?>" scale="<?lua print(j * 5) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
+ <MovableEntity position="<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000-2000) ?>,<?lua print(math.random() * 5000 - 2000) ?>" collisionType=dynamic linearDamping=0.8 angularDamping=0 mass="<?lua print(scale) ?>" rotationaxis="<?lua print(math.random()) ?>, <?lua print(math.random()) ?>, <?lua print(math.random()) ?>" rotationrate="<?lua print(math.random() * 30 + 5) ?>">
<attached>
- <Model position="0,0,0" scale="<?lua print(j * 10) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
+ <Model scale="<?lua print(scale) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />
</attached>
<collisionShapes>
- <SphereCollisionShape radius="<?lua print(j * 70) ?>" />
+ <SphereCollisionShape radius="<?lua print(scale * 2.5) ?>" />
</collisionShapes>
</MovableEntity>
<?lua end ?>
Modified: code/trunk/data/levels/templates/FPS.oxt
===================================================================
--- code/trunk/data/levels/templates/FPS.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/FPS.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,7 +29,7 @@
</camerapositions>
<?lua
- include("includes/weaponSettingsFPS.oxi")
+ include("../includes/weaponSettingsFPS.oxi")
?>
</FpsPlayer>
@@ -50,4 +50,4 @@
</camerapositions>
</FpsPlayer>
</Template>
--->
\ No newline at end of file
+-->
Modified: code/trunk/data/levels/templates/spaceshipAssff.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipAssff.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipAssff.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -55,7 +55,7 @@
<BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
</collisionShapes>
<?lua
- include("includes/weaponSettingsAssff.oxi")
+ include("../includes/weaponSettingsAssff.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipAssff2.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipAssff2.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipAssff2.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -55,7 +55,7 @@
<BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
</collisionShapes>
<?lua
- include("includes/weaponSettingsAssff2.oxi")
+ include("../includes/weaponSettingsAssff2.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipGhost.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipGhost.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipGhost.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -52,7 +52,7 @@
<BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
</collisionShapes>
<?lua
- include("includes/weaponSettingsGhost.oxi")
+ include("../includes/weaponSettingsGhost.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipH2.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipH2.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipH2.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -21,7 +21,7 @@
>
<?lua
- include("includes/weaponSettingsH2.oxi")
+ include("../includes/weaponSettingsH2.oxi")
?>
<engines>
<MultiStateEngine position="0,0,0" template=spaceshipHtwoengine />
Modified: code/trunk/data/levels/templates/spaceshipHXY.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipHXY.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipHXY.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -36,7 +36,7 @@
</collisionShapes>
<?lua
- include("includes/weaponSettingsHXY.oxi")
+ include("../includes/weaponSettingsHXY.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipHXYSL.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipHXYSL.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipHXYSL.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -35,7 +35,7 @@
</collisionShapes>
<?lua
- include("includes/weaponSettingsHXY.oxi")
+ include("../includes/weaponSettingsHXY.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipPirate.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipPirate.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipPirate.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -54,7 +54,7 @@
</collisionShapes>
<?lua
- include("includes/weaponSettingsPirate.oxi")
+ include("../includes/weaponSettingsPirate.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipSwallow.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipSwallow.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipSwallow.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -49,7 +49,7 @@
<BoxCollisionShape position="0,0.1,-19" halfExtents="1.4, 1, 2" />
</collisionShapes>
<?lua
- include("includes/weaponSettingsSwallow.oxi")
+ include("../includes/weaponSettingsSwallow.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipTransporter.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipTransporter.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipTransporter.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -35,7 +35,7 @@
</collisionShapes>
<?lua
- include("includes/weaponSettingsTransporter.oxi")
+ include("../includes/weaponSettingsTransporter.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/levels/templates/spaceshipTransporterSL.oxt
===================================================================
--- code/trunk/data/levels/templates/spaceshipTransporterSL.oxt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/levels/templates/spaceshipTransporterSL.oxt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -35,7 +35,7 @@
</collisionShapes>
<?lua
- include("includes/weaponSettingsTransporter.oxi")
+ include("../includes/weaponSettingsTransporter.oxi")
?>
</SpaceShip>
</Template>
Modified: code/trunk/data/lua/LuaStateInit.lua
===================================================================
--- code/trunk/data/lua/LuaStateInit.lua 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/lua/LuaStateInit.lua 2011-08-22 22:45:53 UTC (rev 8858)
@@ -6,11 +6,21 @@
luaState:luaPrint(s)
end
--- Create function to log text like COUT, but always prints a line!
-logMessage = function(level, message)
- luaState:luaLog(level, message)
+-- Prints output to the console and the logfile
+--
+-- Accepts the following arguments:
+-- orxout("message")
+-- orxout(orxonox.level.levelname, "message")
+-- orxout(orxonox.level.levelname, "context", "message)
+orxout = function(arg1, arg2, arg3)
+ if arg1 and arg2 and arg3 then
+ luaState:luaOutput(arg1, arg2, arg3)
+ elseif arg1 and arg2 then
+ luaState:luaOutput(arg1, arg2)
+ else
+ luaState:luaOutput(arg1)
+ end
end
-cout = logMessage
-- Redirect dofile in order to load with the resource manager
original_dofile = dofile
@@ -41,7 +51,7 @@
LuaStateReturnValue = true
require = function(moduleName)
if not luaState:fileExists(moduleName .. ".lua") then
- logMessage(2, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
+ orxout(orxonox.level.internal_warning, "Warning: Lua function require() could not find file '" .. moduleName .. ".lua' ")
return nil
end
@@ -84,7 +94,7 @@
else
-- Fallback pause function
pause = function()
- logMessage(2, [["Warning: debug() called in Lua, but Debugger is not active.
+ orxout(orxonox.level.internal_warning, [["Warning: debug() called in Lua, but Debugger is not active.
Do you have the IOConsole disabled and are you using Lua version 5.1?"]])
end
end
@@ -97,7 +107,7 @@
return err
end
-- Display the error message
- logMessage(1, "Lua runtime error: "..err)
+ orxout(orxonox.level.internal_error, "Lua runtime error: "..err)
end
-- Start debugger if possible
@@ -105,7 +115,7 @@
pause()
else
-- Fallback: print stack trace
- logMessage(3, debug.traceback(""))
+ orxout(orxonox.level.internal_error, debug.traceback(""))
end
return err -- Hello Lua debugger user! Please type 'set 2' to get to the
-- actual position in the stack where the error occurred
Deleted: code/trunk/data/overlays/OrxonoxLoading.overlay
===================================================================
--- code/trunk/data/overlays/OrxonoxLoading.overlay 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/overlays/OrxonoxLoading.overlay 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,13 +0,0 @@
-Orxonox/LoadingScreenSample
-{
- container Panel(Orxonox/LoadingScreenSample)
- {
- metrics_mode pixels
- vert_align top
- left 12
- top 12
- width 300
- height 300
- material Orxonox/LoadingScreenSample
- }
-}
\ No newline at end of file
Modified: code/trunk/data/overlays/debug.oxo
===================================================================
--- code/trunk/data/overlays/debug.oxo 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/overlays/debug.oxo 2011-08-22 22:45:53 UTC (rev 8858)
@@ -39,14 +39,6 @@
<Template name="defaultHUD">
<OverlayGroup name = "defaultHUD" scale = "1, 1">
- <ChatOverlay
- name = "chat"
- position = "0.03, 0.08"
- font = "VeraMono"
- caption = ""
- textsize = 0.025
- />
-
<KillMessage
name = "killmessage"
position = "0.5, 0.15"
@@ -83,5 +75,13 @@
align = "center"
/>
+ <ChatOverlay
+ name = "chat"
+ position = "0.03, 0.08"
+ font = "VeraMono"
+ caption = ""
+ textsize = 0.025
+ />
+
</OverlayGroup>
</Template>
Modified: code/trunk/data/tcl/init.tcl
===================================================================
--- code/trunk/data/tcl/init.tcl 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/data/tcl/init.tcl 2011-08-22 22:45:53 UTC (rev 8858)
@@ -168,8 +168,10 @@
foreach {channel s} $input break
- if {$channel == "stdout" || $channel == "stderr"} {
- execute puts $newline $s
+ if {$channel == "stdout"} {
+ execute log $s
+ } elseif {$channel == "stderr"} {
+ execute error $s
} else {
eval [concat ::tcl::puts $args]
}
Modified: code/trunk/src/Orxonox.cc
===================================================================
--- code/trunk/src/Orxonox.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/Orxonox.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -42,7 +42,7 @@
#include <windows.h>
#endif
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "orxonox/Main.h"
@@ -58,6 +58,13 @@
int main(int argc, char** argv)
#endif
{
+ using namespace orxonox;
+
+ orxout(user_status) << "Welcome to Orxonox (v" << ORXONOX_VERSION_MAJOR << '.' << ORXONOX_VERSION_MINOR << '.' << ORXONOX_VERSION_PATCH << ' ' << ORXONOX_VERSION_NAME << ')' << endl;
+ orxout(internal_status) << "Congratulations, you survived the static initialization. Entering main()" << endl;
+ if (argc > 0)
+ orxout(internal_info) << "argv[0]: " << argv[0] << endl;
+
try
{
#ifndef ORXONOX_USE_WINMAIN
@@ -69,18 +76,20 @@
// 0 is the execution path
const int firstArgument = 1;
#endif
-
+
std::string strCmdLine;
for (int i = firstArgument; i < argc; ++i)
strCmdLine = strCmdLine + argv[i] + ' ';
#endif
- return orxonox::main(strCmdLine);
+ int value = main(strCmdLine);
+ orxout(internal_status) << "Terminating main() normally with value " << value << endl;
+ return value;
}
catch (...)
{
- COUT(0) << "Orxonox failed to initialise: " << orxonox::Exception::handleMessage() << std::endl;
- COUT(0) << "Terminating program." << std::endl;
+ orxout(user_error) << "Exception caught in main(): " << orxonox::Exception::handleMessage() << endl;
+ orxout(user_error) << "Terminating program." << endl;
return 1;
}
}
Modified: code/trunk/src/OrxonoxConfig.h.in
===================================================================
--- code/trunk/src/OrxonoxConfig.h.in 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/OrxonoxConfig.h.in 2011-08-22 22:45:53 UTC (rev 8858)
@@ -108,6 +108,17 @@
# endif
#endif
+// Declare a function deprecated
+#ifndef __DEPRECATED__
+# if defined(ORXONOX_COMPILER_GCC)
+# define __DEPRECATED__(function) function __attribute__ ((deprecated))
+# elif defined(ORXONOX_COMPILER_MSVC)
+# define __DEPRECATED__(function) __declspec(deprecated) function
+# else
+# define __DEPRECATED__(function) function
+# endif
+#endif
+
#ifndef __UNIQUE_NUMBER__
# if defined(ORXONOX_COMPILER_GCC) && ORXONOX_COMP_VER >= 430
# define __UNIQUE_NUMBER__ __COUNTER__
Modified: code/trunk/src/libraries/core/BaseObject.cc
===================================================================
--- code/trunk/src/libraries/core/BaseObject.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/BaseObject.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -108,7 +108,7 @@
/** @brief Adds an object which listens to the events of this object. */
void BaseObject::registerEventListener(BaseObject* object)
{
- COUT(4) << "New EventListener: " << object->getIdentifier()->getName() << " &(" << object << ")." << std::endl;
+ orxout(verbose, context::events) << "New EventListener: " << object->getIdentifier()->getName() << " &(" << object << ")." << endl;
this->eventListeners_.insert(object);
}
@@ -185,7 +185,7 @@
if (temp)
this->addTemplate(temp);
else
- COUT(1) << "Error: \"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << std::endl;
+ orxout(internal_error) << "\"" << name << "\" is not a valid Template name (in class: " << this->getIdentifier()->getName() << ", name: " << this->getName() << ")." << endl;
}
/**
@@ -311,7 +311,7 @@
std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(name);
if (it != this->eventStates_.end())
{
- COUT(2) << "Warning: Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << std::endl;
+ orxout(internal_warning, context::events) << "Overwriting EventState in class " << this->getIdentifier()->getName() << '.' << endl;
delete (it->second);
}
@@ -378,15 +378,15 @@
{
this->registerEventStates();
- COUT(4) << this->getIdentifier()->getName() << " (&" << this << ") processing event. originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << "." << std::endl;
+ orxout(verbose, context::events) << this->getIdentifier()->getName() << " (&" << this << ") processing event. originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << "." << endl;
std::map<std::string, EventState*>::const_iterator it = this->eventStates_.find(event.statename_);
if (it != this->eventStates_.end())
it->second->process(event, this);
else if (!event.statename_.empty())
- COUT(2) << "Warning: \"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
+ orxout(internal_warning, context::events) << "\"" << event.statename_ << "\" is not a valid state in object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << endl;
else
- COUT(2) << "Warning: Event with invalid source sent to object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << std::endl;
+ orxout(internal_warning, context::events) << "Event with invalid source sent to object \"" << this->getName() << "\" of class " << this->getIdentifier()->getName() << "." << endl;
}
/**
@@ -411,7 +411,7 @@
}
}
else
- COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;
+ orxout(internal_warning, context::events) << "No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << endl;
}
/**
@@ -431,10 +431,10 @@
if (it->second->getFunctor()->getParamCount() <= 1)
this->mainStateFunctor_ = it->second->getFunctor();
else
- COUT(2) << "Warning: Can't use \"" << this->mainStateName_ << "\" as MainState because it needs a second argument." << std::endl;
+ orxout(internal_warning, context::events) << "Can't use \"" << this->mainStateName_ << "\" as MainState because it needs a second argument." << endl;
}
else
- COUT(2) << "Warning: \"" << this->mainStateName_ << "\" is not a valid MainState." << std::endl;
+ orxout(internal_warning, context::events) << "\"" << this->mainStateName_ << "\" is not a valid MainState." << endl;
}
}
Modified: code/trunk/src/libraries/core/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/core/CMakeLists.txt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -85,6 +85,7 @@
input/InputManager.h
input/KeyBinder.h
input/KeyBinderManager.h
+ ../util/output/OutputDefinitions.h
PCH_FILE
CorePrecompiledHeaders.h
LINK_LIBRARIES
Modified: code/trunk/src/libraries/core/ClassFactory.h
===================================================================
--- code/trunk/src/libraries/core/ClassFactory.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/ClassFactory.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -41,7 +41,7 @@
#include <string>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "Identifier.h"
namespace orxonox
@@ -72,7 +72,7 @@
*/
ClassFactory(const std::string& name, bool bLoadable = true)
{
- COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
+ orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl;
ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
}
Modified: code/trunk/src/libraries/core/CommandLineParser.cc
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/CommandLineParser.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -32,7 +32,7 @@
#include <sstream>
#include "util/Convert.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/StringUtils.h"
#include "util/SubString.h"
@@ -228,8 +228,8 @@
}
catch (const ArgumentException& ex)
{
- COUT(0) << "Could not parse command line: " << ex.what() << std::endl;
- COUT(0) << CommandLineParser::getUsageInformation() << std::endl;
+ orxout(user_error) << "Could not parse command line: " << ex.what() << endl;
+ orxout(user_error) << CommandLineParser::getUsageInformation() << endl;
throw GeneralException("");
}
}
@@ -285,9 +285,9 @@
maxNameSize = std::max(it->second->getName().size(), maxNameSize);
}
- infoStr << std::endl;
- infoStr << "Usage: orxonox [options]" << std::endl;
- infoStr << "Available options:" << std::endl;
+ infoStr << endl;
+ infoStr << "Usage: orxonox [options]" << endl;
+ infoStr << "Available options:" << endl;
for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
it != inst.cmdLineArgs_.end(); ++it)
@@ -304,7 +304,7 @@
// fill with the necessary amount of blanks
infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
infoStr << ": " << it->second->getInformation();
- infoStr << std::endl;
+ infoStr << endl;
}
return infoStr.str();
}
Modified: code/trunk/src/libraries/core/CommandLineParser.h
===================================================================
--- code/trunk/src/libraries/core/CommandLineParser.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/CommandLineParser.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -217,7 +217,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,
- "Boolean command line arguments with positive default values are not supported." << std::endl
+ "Boolean command line arguments with positive default values are not supported." << endl
<< "Please use SetCommandLineSwitch and adjust your argument: " << name);
return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
Modified: code/trunk/src/libraries/core/ConfigFileManager.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigFileManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/ConfigFileManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -122,12 +122,9 @@
unsigned int size = 0;
for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
if ((*it)->getName() == name)
- if ((*it)->getIndex() > size)
- size = (*it)->getIndex();
- if (size == 0)
- return 0;
- else
- return (size + 1);
+ if ((*it)->getIndex() >= size)
+ size = (*it)->getIndex() + 1;
+ return size;
}
/**
@@ -273,10 +270,10 @@
try
{
boost::filesystem::copy_file(defaultFilepath, filepath);
- COUT(3) << "Copied " << this->filename_ << " from the default config folder." << std::endl;
+ orxout(internal_info, context::config) << "Copied " << this->filename_ << " from the default config folder." << endl;
}
catch (const boost::filesystem::filesystem_error& ex)
- { COUT(1) << "Error in ConfigFile: " << ex.what() << std::endl; }
+ { orxout(user_error, context::config) << "Error in ConfigFile: " << ex.what() << endl; }
}
}
}
@@ -374,7 +371,7 @@
file.close();
- COUT(3) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
+ orxout(internal_info, context::config) << "Loaded config file \"" << this->filename_ << "\"." << endl;
// DO NOT save the file --> we can open supposedly read only config files
} // end file.is_open()
@@ -403,23 +400,23 @@
if (!file.is_open())
{
- COUT(1) << "Error: Couldn't open config-file \"" << filename << "\"." << std::endl;
+ orxout(user_error, context::config) << "Couldn't open config-file \"" << filename << "\"." << endl;
return;
}
for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
{
- file << (*it)->getFileEntry() << std::endl;
+ file << (*it)->getFileEntry() << endl;
for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
- file << (*it_entries)->getFileEntry() << std::endl;
+ file << (*it_entries)->getFileEntry() << endl;
- file << std::endl;
+ file << endl;
}
file.close();
- COUT(4) << "Saved config file \"" << filename << "\"." << std::endl;
+ orxout(verbose, context::config) << "Saved config file \"" << filename << "\"." << endl;
}
/**
@@ -668,7 +665,7 @@
void SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value)
{
if (!this->configImpl(section, entry, value, &ConfigValueContainer::set))
- COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl;
+ orxout(user_error, context::config) << "Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << endl;
}
/**
@@ -681,7 +678,7 @@
void SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value)
{
if (!this->configImpl(section, entry, value, &ConfigValueContainer::tset))
- COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl;
+ orxout(user_error, context::config) << "Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << endl;
}
/**
Modified: code/trunk/src/libraries/core/ConfigValueContainer.cc
===================================================================
--- code/trunk/src/libraries/core/ConfigValueContainer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/ConfigValueContainer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -142,7 +142,7 @@
}
else
{
- COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+ orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl;
}
return false;
}
@@ -181,7 +181,7 @@
{
if (index > MAX_VECTOR_INDEX)
{
- COUT(1) << "Error: Index " << index << " is too large." << std::endl;
+ orxout(user_error, context::config) << "Index " << index << " is too large." << endl;
return false;
}
@@ -202,7 +202,7 @@
}
else
{
- COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+ orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl;
return false;
}
}
@@ -217,7 +217,7 @@
if (this->bIsVector_)
return this->set(this->valueVector_.size(), input);
- COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+ orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl;
return false;
}
@@ -240,10 +240,10 @@
return true;
}
- COUT(1) << "Error: Invalid vector-index." << std::endl;
+ orxout(user_error, context::config) << "Invalid vector-index." << endl;
}
- COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+ orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << endl;
return false;
}
@@ -311,11 +311,11 @@
{
if (!success)
{
- COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is a vector." << std::endl;
+ orxout(user_error, context::config) << "Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is a vector." << endl;
}
else
{
- COUT(1) << "Error: Invalid vector-index." << std::endl;
+ orxout(user_error, context::config) << "Invalid vector-index." << endl;
}
return false;
}
Modified: code/trunk/src/libraries/core/ConfigValueIncludes.h
===================================================================
--- code/trunk/src/libraries/core/ConfigValueIncludes.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/ConfigValueIncludes.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -86,8 +86,8 @@
Some other code:
@code
MyObject orxonoxobject;
- std::cout << "Name: " << orxonoxobject.getName() << std::endl;
- std::cout << "Version: " << orxonoxobject.getVersion() << std::endl;
+ orxout() << "Name: " << orxonoxobject.getName() << endl;
+ orxout() << "Version: " << orxonoxobject.getVersion() << endl;
@endcode
Output:
@@ -199,8 +199,8 @@
}
else
{
- COUT(2) << "Warning: Couldn't reset config-value '" << entryName << "' in class '"
- << ClassIdentifier<T>::getIdentifier()->getName() << "', corresponding container doesn't exist." << std::endl;
+ orxout(user_warning, context::config) << "Couldn't reset config-value '" << entryName << "' in class '"
+ << ClassIdentifier<T>::getIdentifier()->getName() << "', corresponding container doesn't exist." << endl;
}
}
}
@@ -237,8 +237,8 @@
} \
else \
{ \
- COUT(2) << "Warning: Couln't modify config-value '" << entryName << "' in class '" \
- << ClassByObjectType(object)->getName() << "', corresponding container doesn't exist." << std::endl; \
+ orxout(user_warning, context::config) << "Couldn't modify config-value '" << entryName << "' in class '" \
+ << ClassByObjectType(object)->getName() << "', corresponding container doesn't exist." << endl; \
}
/** Modifies a runtime configurable value by using a modifier and some arguments.
Modified: code/trunk/src/libraries/core/Core.cc
===================================================================
--- code/trunk/src/libraries/core/Core.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Core.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -51,8 +51,9 @@
#endif
#include "util/Clock.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
+#include "util/output/LogWriter.h"
#include "util/Scope.h"
#include "util/ScopedSingletonManager.h"
#include "util/SignalHandler.h"
@@ -110,6 +111,8 @@
, bDevMode_(false)
, destructionHelper_(this)
{
+ orxout(internal_status) << "initializing Core object..." << endl;
+
// Set the hard coded fixed paths
this->pathConfig_ = new PathConfig();
@@ -117,6 +120,7 @@
this->dynLibManager_ = new DynLibManager();
// Load modules
+ orxout(internal_info) << "Loading modules:" << endl;
const std::vector<std::string>& modulePaths = this->pathConfig_->getModulePaths();
for (std::vector<std::string>::const_iterator it = modulePaths.begin(); it != modulePaths.end(); ++it)
{
@@ -126,7 +130,7 @@
}
catch (...)
{
- COUT(1) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << std::endl;
+ orxout(user_error) << "Couldn't load module \"" << *it << "\": " << Exception::handleMessage() << endl;
}
}
@@ -136,14 +140,19 @@
// Set configurable paths like log, config and media
this->pathConfig_->setConfigurablePaths();
+ orxout(internal_info) << "Root path: " << PathConfig::getRootPathString() << endl;
+ orxout(internal_info) << "Executable path: " << PathConfig::getExecutablePathString() << endl;
+ orxout(internal_info) << "Data path: " << PathConfig::getDataPathString() << endl;
+ orxout(internal_info) << "Ext. data path: " << PathConfig::getExternalDataPathString() << endl;
+ orxout(internal_info) << "Config path: " << PathConfig::getConfigPathString() << endl;
+ orxout(internal_info) << "Log path: " << PathConfig::getLogPathString() << endl;
+ orxout(internal_info) << "Modules path: " << PathConfig::getModulePathString() << endl;
+
// create a signal handler (only active for Linux)
// This call is placed as soon as possible, but after the directories are set
this->signalHandler_ = new SignalHandler();
this->signalHandler_->doCatch(PathConfig::getExecutablePathString(), PathConfig::getLogPathString() + "orxonox_crash.log");
- // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
- OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
-
#ifdef ORXONOX_PLATFORM_WINDOWS
// limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
// do this after ogre has initialised. Somehow Ogre changes the settings again (not through
@@ -154,20 +163,24 @@
#endif
// Manage ini files and set the default settings file (usually orxonox.ini)
+ orxout(internal_info) << "Loading config:" << endl;
this->configFileManager_ = new ConfigFileManager();
this->configFileManager_->setFilename(ConfigFileType::Settings,
CommandLineParser::getValue("settingsFile").getString());
// Required as well for the config values
+ orxout(internal_info) << "Loading language:" << endl;
this->languageInstance_ = new Language();
// Do this soon after the ConfigFileManager has been created to open up the
// possibility to configure everything below here
RegisterRootObject(Core);
+ orxout(internal_info) << "configuring Core" << endl;
this->setConfigValues();
- // Rewrite the log file with the correct log levels
- OutputHandler::getInstance().rewriteLogFile();
+ // Set the correct log path and rewrite the log file with the correct log levels
+ LogWriter::getInstance().setLogPath(PathConfig::getLogPathString());
+
#if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
// Create persistent IO console
if (CommandLineParser::getValue("noIOConsole").getBool())
@@ -175,13 +188,18 @@
ModifyConfigValue(bStartIOConsole_, tset, false);
}
if (this->bStartIOConsole_)
+ {
+ orxout(internal_info) << "creating IO console" << endl;
this->ioConsole_ = new IOConsole();
+ }
#endif
// creates the class hierarchy for all classes with factories
+ orxout(internal_info) << "creating class hierarchy" << endl;
Identifier::createClassHierarchy();
// Load OGRE excluding the renderer and the render window
+ orxout(internal_info) << "creating GraphicsManager:" << endl;
this->graphicsManager_ = new GraphicsManager(false);
// initialise Tcl
@@ -189,6 +207,7 @@
this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
// Create singletons that always exist (in other libraries)
+ orxout(internal_info) << "creating root scope:" << endl;
this->rootScope_ = new Scope<ScopeID::Root>();
// Generate documentation instead of normal run?
@@ -203,12 +222,16 @@
docFile.close();
}
else
- COUT(0) << "Error: Could not open file for documentation writing" << endl;
+ orxout(internal_error) << "Could not open file for documentation writing" << endl;
}
+
+ orxout(internal_status) << "finished initializing Core object" << endl;
}
void Core::destroy()
{
+ orxout(internal_status) << "destroying Core object..." << endl;
+
// Remove us from the object lists again to avoid problems when destroying them
this->unregisterObject();
@@ -227,24 +250,32 @@
safeObjectDelete(&signalHandler_);
safeObjectDelete(&dynLibManager_);
safeObjectDelete(&pathConfig_);
- }
- namespace DefaultLevelLogFile
- {
- const OutputLevel::Value Dev = OutputLevel::Debug;
- const OutputLevel::Value User = OutputLevel::Info;
+ orxout(internal_status) << "finished destroying Core object" << endl;
}
//! Function to collect the SetConfigValue-macro calls.
void Core::setConfigValues()
{
- // Choose the default level according to the path Orxonox was started (build directory or not)
- OutputLevel::Value defaultLogLevel = (PathConfig::buildDirectoryRun() ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
+ SetConfigValueExternal(LogWriter::getInstance().configurableMaxLevel_,
+ LogWriter::getInstance().getConfigurableSectionName(),
+ LogWriter::getInstance().getConfigurableMaxLevelName(),
+ LogWriter::getInstance().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_)
+ .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_)
+ .description("Additional output contexts shown in the log file")
+ .callback(static_cast<BaseWriter*>(&LogWriter::getInstance()), &BaseWriter::changedConfigurableAdditionalContexts);
- SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile", defaultLogLevel)
- .description("The maximum level of debug output written to the log file");
- OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
-
SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
.description("Developer mode. If not set, hides some things from the user to not confuse him.")
.callback(this, &Core::devModeChanged);
@@ -278,17 +309,6 @@
*/
void Core::devModeChanged()
{
- bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun());
- if (isNormal)
- {
- ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);
- }
- else
- {
- OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
- ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);
- }
-
// Inform listeners
ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
for (; it != ObjectList<DevModeListener>::end(); ++it)
@@ -315,6 +335,8 @@
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);
@@ -326,7 +348,7 @@
catch (const InitialisationFailedException&)
{
// Exit the application if the Ogre config dialog was canceled
- COUT(1) << Exception::handleMessage() << std::endl;
+ orxout(user_error) << Exception::handleMessage() << endl;
exit(EXIT_FAILURE);
}
catch (...)
@@ -337,9 +359,9 @@
// throws an exception and the graphics engine then gets destroyed
// and reloaded between throw and catch (access violation in MSVC).
// That's why we abort completely and only display the exception.
- COUT(1) << "An exception occurred during upgrade to graphics. "
- << "That is unrecoverable. The message was:" << endl
- << Exception::handleMessage() << endl;
+ orxout(user_error) << "An exception occurred during upgrade to graphics. "
+ << "That is unrecoverable. The message was:" << endl
+ << Exception::handleMessage() << endl;
abort();
}
@@ -356,13 +378,18 @@
graphicsManager_->loadDebugOverlay();
// Create singletons associated with graphics (in other libraries)
+ orxout(internal_info) << "creating graphics scope:" << endl;
graphicsScope_ = new Scope<ScopeID::Graphics>();
unloader.Dismiss();
+
+ orxout(internal_info) << "finished loading graphics in Core" << endl;
}
void Core::unloadGraphics()
{
+ orxout(internal_info) << "unloading graphics in Core" << endl;
+
safeObjectDelete(&graphicsScope_);
safeObjectDelete(&guiManager_);
safeObjectDelete(&inputManager_);
@@ -373,9 +400,9 @@
{ this->graphicsManager_ = new GraphicsManager(false); }
catch (...)
{
- COUT(0) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << std::endl
- << "Another exception might be being handled which may lead to undefined behaviour!" << std::endl
- << "Terminating the program." << std::endl;
+ orxout(user_error) << "An exception occurred during 'unloadGraphics':" << Exception::handleMessage() << endl
+ << "Another exception might be being handled which may lead to undefined behaviour!" << endl
+ << "Terminating the program." << endl;
abort();
}
Modified: code/trunk/src/libraries/core/Core.h
===================================================================
--- code/trunk/src/libraries/core/Core.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Core.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -135,7 +135,6 @@
Scope<ScopeID::Graphics>* graphicsScope_;
bool bGraphicsLoaded_;
- int debugLevelLogFile_; //!< The debug level for the log file (belongs to OutputHandler)
std::string language_; //!< The language
bool bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
bool bStartIOConsole_; //!< Set to false if you don't want to use the IOConsole
Modified: code/trunk/src/libraries/core/CoreIncludes.h
===================================================================
--- code/trunk/src/libraries/core/CoreIncludes.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/CoreIncludes.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,7 +33,7 @@
/**
@file
- @ingroup Object Factory
+ @ingroup Object Factory Class Identifier
@brief Defines several very important macros used to register objects, create factories, and to work with identifiers.
Every class needs the @c RegisterObject(class) macro in its constructor. If the class is an interface
@@ -77,7 +77,7 @@
#include "CorePrereqs.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "Identifier.h"
#include "ClassFactory.h"
#include "ObjectList.h"
Modified: code/trunk/src/libraries/core/CorePrecompiledHeaders.h
===================================================================
--- code/trunk/src/libraries/core/CorePrecompiledHeaders.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/CorePrecompiledHeaders.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,7 +50,7 @@
#include <sstream> // 53
#include <set> // 50
-#include "util/Debug.h" // 48
+#include "util/Output.h" // 48
#include <deque> // 43
#include <list> // 44
Modified: code/trunk/src/libraries/core/DynLib.cc
===================================================================
--- code/trunk/src/libraries/core/DynLib.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/DynLib.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -67,7 +67,7 @@
void DynLib::load()
{
// Log library load
- COUT(2) << "Loading module " << mName << std::endl;
+ orxout(internal_info) << "Loading module " << mName << endl;
std::string name = mName;
#ifdef ORXONOX_PLATFORM_LINUX
@@ -98,7 +98,7 @@
void DynLib::unload()
{
// Log library unload
- COUT(4) << "Unloading module " << mName << std::endl;
+ orxout(internal_info) << "Unloading module " << mName << endl;
if (DYNLIB_UNLOAD( m_hInst ))
{
Modified: code/trunk/src/libraries/core/Event.cc
===================================================================
--- code/trunk/src/libraries/core/Event.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Event.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -48,13 +48,13 @@
{
if (this->bProcessingEvent_)
{
- COUT(2) << "Warning: Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << '"' << std::endl;
+ orxout(internal_warning, context::events) << "Detected Event loop in section \"" << event.statename_ << "\" of object \"" << object->getName() << "\" and fired by \"" << event.originator_->getName() << '"' << endl;
return;
}
this->bProcessingEvent_ = true;
- COUT(4) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << "." << std::endl;
+ orxout(verbose, context::events) << "Processing event (EventState) : originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << "), activate: " << event.activate_ << ", name: " << event.name_ << ", statename: " << event.statename_ << ", object: " << object->getIdentifier()->getName() << " (&" << object << ")" << "." << endl;
// check if the originator is an instance of the requested class
if (event.originator_->isA(this->subclass_))
Modified: code/trunk/src/libraries/core/GUIManager.cc
===================================================================
--- code/trunk/src/libraries/core/GUIManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/GUIManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -72,10 +72,11 @@
#include "util/Clock.h"
#include "util/Convert.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/Math.h"
#include "util/OrxAssert.h"
+#include "util/output/BaseWriter.h"
#include "ConfigValueIncludes.h"
#include "Core.h"
#include "CoreIncludes.h"
@@ -100,19 +101,19 @@
public:
void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
{
- int orxonoxLevel = CEGUI::Standard;
+ OutputLevel orxonoxLevel = level::debug_output;
switch (level)
{
- case CEGUI::Errors: orxonoxLevel = 1; break;
- case CEGUI::Warnings: orxonoxLevel = 2; break;
- case CEGUI::Standard: orxonoxLevel = 4; break;
- case CEGUI::Informative: orxonoxLevel = 5; break;
- case CEGUI::Insane: orxonoxLevel = 6; break;
+ case CEGUI::Errors: orxonoxLevel = level::internal_error; break;
+ case CEGUI::Warnings: orxonoxLevel = level::internal_warning; break;
+ case CEGUI::Standard: orxonoxLevel = level::verbose; break;
+ case CEGUI::Informative: orxonoxLevel = level::verbose_more; break;
+ case CEGUI::Insane: orxonoxLevel = level::verbose_ultra; break;
default: OrxAssert(false, "CEGUI log level out of range, inspect immediately!");
}
- OutputHandler::getOutStream(orxonoxLevel)
- << "CEGUI: " << message << std::endl;
+ orxout(orxonoxLevel, context::cegui) << message << endl;
+
CEGUI::DefaultLogger::logEvent(message, level);
}
@@ -255,14 +256,17 @@
, destructionHelper_(this)
{
RegisterRootObject(GUIManager);
+
+ orxout(internal_status) << "initializing GUIManager..." << endl;
+
this->setConfigValues();
using namespace CEGUI;
- COUT(3) << "Initialising CEGUI." << std::endl;
+ orxout(internal_info) << "Initialising CEGUI." << endl;
this->oldCEGUI_ = false;
-
+
// Note: No SceneManager specified yet
#ifdef ORXONOX_OLD_CEGUI
guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000);
@@ -299,9 +303,7 @@
// Create our own logger to specify the filepath
std::auto_ptr<CEGUILogger> ceguiLogger(new CEGUILogger());
ceguiLogger->setLogFilename(PathConfig::getLogPathString() + "cegui.log");
- // Set the log level according to ours (translate by subtracting 1)
- ceguiLogger->setLoggingLevel(
- static_cast<LoggingLevel>(OutputHandler::getInstance().getSoftDebugLevel("logFile") - 1));
+ ceguiLogger->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
this->ceguiLogger_ = ceguiLogger.release();
// Create the CEGUI system singleton
@@ -335,10 +337,14 @@
// Set up the sheet manager in the Lua framework
this->luaState_->doFile("SheetManager.lua");
+
+ orxout(internal_status) << "finished initializing GUIManager" << endl;
}
void GUIManager::destroy()
{
+ orxout(internal_status) << "destroying GUIManager..." << endl;
+
using namespace CEGUI;
#ifdef ORXONOX_OLD_CEGUI
@@ -355,18 +361,27 @@
safeObjectDelete(&rqListener_);
#endif
safeObjectDelete(&luaState_);
+
+ orxout(internal_status) << "finished destroying GUIManager" << endl;
}
void GUIManager::setConfigValues(void)
{
- SetConfigValue(guiScheme_, GUIManager::defaultScheme_) .description("Changes the current GUI scheme.") .callback(this, &GUIManager::changedGUIScheme);
+ SetConfigValue(guiScheme_, GUIManager::defaultScheme_).description("Changes the current GUI scheme.").callback(this, &GUIManager::changedGUIScheme);
SetConfigValue(numScrollLines_, 1).description("How many lines to scroll in a list if the scroll wheel is used");
+ SetConfigValueExternal(outputLevelCeguiLog_, BaseWriter::getConfigurableSectionName(), "outputLevelCeguiLog", CEGUI::Standard).description("The log level of the CEGUI log file").callback(this, &GUIManager::changedCeguiOutputLevel);
}
void GUIManager::changedGUIScheme(void)
{
}
+ void GUIManager::changedCeguiOutputLevel()
+ {
+ if (this->ceguiLogger_)
+ this->ceguiLogger_->setLoggingLevel(static_cast<CEGUI::LoggingLevel>(this->outputLevelCeguiLog_));
+ }
+
/**
@brief
used to tick the GUI
@@ -669,7 +684,7 @@
catch (CEGUI::ScriptException& ex)
{
// Display the error and proceed. See @remarks why this can be dangerous.
- COUT(1) << ex.getMessage() << std::endl;
+ orxout(internal_error) << ex.getMessage() << endl;
return true;
}
}
Modified: code/trunk/src/libraries/core/GUIManager.h
===================================================================
--- code/trunk/src/libraries/core/GUIManager.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/GUIManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -151,6 +151,8 @@
template <typename FunctionType>
bool protectedCall(FunctionType function);
+ void changedCeguiOutputLevel();
+
// keyHandler functions
void buttonPressed (const KeyEvent& evt);
void buttonReleased(const KeyEvent& evt);
@@ -167,35 +169,36 @@
virtual void windowFocusChanged(bool bFocus);
#ifdef ORXONOX_OLD_CEGUI
- CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
- CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
+ CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
+ CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
#else
- CEGUI::OgreRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
- CEGUI::OgreResourceProvider* resourceProvider_; //!< CEGUI's resource provider
- Ogre::RenderQueueListener* rqListener_; //!< RQ listener so we can draw UNDER Ogre overlays
+ CEGUI::OgreRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
+ CEGUI::OgreResourceProvider* resourceProvider_; //!< CEGUI's resource provider
+ Ogre::RenderQueueListener* rqListener_; //!< RQ listener so we can draw UNDER Ogre overlays
CEGUI::OgreImageCodec* imageCodec_;
#endif
- LuaState* luaState_; //!< LuaState, access point to the Lua engine
- CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua
- CEGUI::System* guiSystem_; //!< CEGUI's main system
- shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script
- CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
- CEGUI::Window* rootWindow_; //!< Root node for all windows
- CEGUI::Window* hudRootWindow_; //!< Root node for the HUD sheets
- CEGUI::Window* menuRootWindow_; //!< Root node for the menu sheets (used by Lua)
- std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each GUI
- Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI
+ LuaState* luaState_; //!< LuaState, access point to the Lua engine
+ CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua
+ CEGUI::System* guiSystem_; //!< CEGUI's main system
+ shared_ptr<ResourceInfo> rootFileInfo_; //!< Resource information about the root script
+ CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
+ int outputLevelCeguiLog_; //!< CEGUI's log level
+ CEGUI::Window* rootWindow_; //!< Root node for all windows
+ CEGUI::Window* hudRootWindow_; //!< Root node for the HUD sheets
+ CEGUI::Window* menuRootWindow_; //!< Root node for the menu sheets (used by Lua)
+ std::map<std::string, PlayerInfo*> players_; //!< Stores the player (owner) for each GUI
+ Ogre::Camera* camera_; //!< Camera used to render the scene with the GUI
/// Helper object that executes the surrogate destructor destroy()
DestructionHelper<GUIManager> destructionHelper_;
- static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
+ static GUIManager* singletonPtr_s; //!< Singleton reference to GUIManager
// The used CEGUI scheme.
static const std::string defaultScheme_;
std::string guiScheme_;
bool oldCEGUI_;
-
+
int numScrollLines_; ///< How many lines to scroll in a list if the scroll wheel is used
}; // tolua_export
Modified: code/trunk/src/libraries/core/Game.cc
===================================================================
--- code/trunk/src/libraries/core/Game.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Game.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -39,7 +39,7 @@
#include <loki/ScopeGuard.h>
#include "util/Clock.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/Sleep.h"
#include "util/SubString.h"
@@ -59,10 +59,10 @@
{ Game::getInstance().stop(); }
SetConsoleCommand("exit", &stop_game);
static void printFPS()
- { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
+ { orxout(message) << Game::getInstance().getAvgFPS() << endl; }
SetConsoleCommand("Stats", "printFPS", &printFPS);
static void printTickTime()
- { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
+ { orxout(message) << Game::getInstance().getAvgTickTime() << endl; }
SetConsoleCommand("Stats", "printTickTime", &printTickTime);
std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
@@ -83,6 +83,8 @@
, bAbort_(false)
, destructionHelper_(this)
{
+ orxout(internal_status) << "initializing Game object..." << endl;
+
#ifdef ORXONOX_PLATFORM_WINDOWS
minimumSleepTime_ = 1000/*us*/;
#else
@@ -105,6 +107,7 @@
this->gameClock_ = new Clock();
// Create the Core
+ orxout(internal_info) << "creating Core object:" << endl;
this->core_ = new Core(cmdLine);
// Do this after the Core creation!
@@ -124,10 +127,14 @@
this->rootStateNode_->name_ = "emptyRootGameState";
this->loadedTopStateNode_ = this->rootStateNode_;
this->loadedStates_.push_back(this->getState(rootStateNode_->name_));
+
+ orxout(internal_status) << "finished initializing Game object" << endl;
}
void Game::destroy()
{
+ orxout(internal_status) << "destroying Game object..." << endl;
+
// Remove us from the object lists again to avoid problems when destroying them
this->unregisterObject();
@@ -138,6 +145,8 @@
GameStateFactory::getFactories().clear();
safeObjectDelete(&core_);
safeObjectDelete(&gameClock_);
+
+ orxout(internal_status) << "finished destroying Game object..." << endl;
}
void Game::setConfigValues()
@@ -162,8 +171,15 @@
void Game::run()
{
if (this->requestedStateNodes_.empty())
- COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
+ orxout(user_error) << "Starting game without requesting GameState. This automatically terminates the program." << endl;
+ // Update the GameState stack if required. We do this already here to have a properly initialized game before entering the main loop
+ this->updateGameStateStack();
+
+ orxout(user_status) << "Game loaded" << endl;
+ orxout(internal_status) << "--------------------------------------------------" << endl;
+ orxout(internal_status) << "starting main loop..." << endl;
+
// START GAME
// first delta time should be about 0 seconds
this->gameClock_->capture();
@@ -188,8 +204,8 @@
{ this->core_->preUpdate(*this->gameClock_); }
catch (...)
{
- COUT(0) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << std::endl;
- COUT(0) << "This should really never happen! Closing the program." << std::endl;
+ orxout(user_error) << "An exception occurred in the Core preUpdate: " << Exception::handleMessage() << endl;
+ orxout(user_error) << "This should really never happen! Closing the program." << endl;
this->stop();
break;
}
@@ -202,8 +218,8 @@
{ this->core_->postUpdate(*this->gameClock_); }
catch (...)
{
- COUT(0) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << std::endl;
- COUT(0) << "This should really never happen! Closing the program." << std::endl;
+ orxout(user_error) << "An exception occurred in the Core postUpdate: " << Exception::handleMessage() << endl;
+ orxout(user_error) << "This should really never happen! Closing the program." << endl;
this->stop();
break;
}
@@ -217,6 +233,9 @@
this->updateFPSLimiter();
}
+ orxout(internal_status) << "finished main loop" << endl;
+ orxout(internal_status) << "--------------------------------------------------" << endl;
+
// UNLOAD all remaining states
while (this->loadedStates_.size() > 1)
this->unloadState(this->loadedStates_.back()->getName());
@@ -240,10 +259,10 @@
}
catch (...)
{
- COUT(1) << "Error: Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << std::endl;
+ orxout(user_error) << "Loading GameState '" << requestedStateNode->name_ << "' failed: " << Exception::handleMessage() << endl;
// All scheduled operations have now been rendered inert --> flush them and issue a warning
if (this->requestedStateNodes_.size() > 1)
- COUT(4) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
+ orxout(internal_info) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << endl;
this->requestedStateNodes_.clear();
break;
}
@@ -271,9 +290,9 @@
}
catch (...)
{
- COUT(1) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << std::endl;
- COUT(1) << "This should really never happen!" << std::endl;
- COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
+ orxout(user_error) << "An exception occurred while updating '" << (*it)->getName() << "': " << Exception::handleMessage() << endl;
+ orxout(user_error) << "This should really never happen!" << endl;
+ orxout(user_error) << "Unloading all GameStates depending on the one that crashed." << endl;
shared_ptr<GameStateTreeNode> current = this->loadedTopStateNode_;
while (current->name_ != (*it)->getName() && current)
current = current->parent_.lock();
@@ -337,6 +356,7 @@
void Game::stop()
{
+ orxout(user_status) << "Exit" << endl;
this->bAbort_ = true;
}
@@ -354,13 +374,13 @@
{
if (!this->checkState(name))
{
- COUT(2) << "Warning: GameState named '" << name << "' doesn't exist!" << std::endl;
+ orxout(user_warning) << "GameState named '" << name << "' doesn't exist!" << endl;
return;
}
if (this->bChangingState_)
{
- COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
+ orxout(user_warning) << "Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << endl;
return;
}
@@ -371,7 +391,7 @@
lastRequestedNode = this->requestedStateNodes_.back();
if (name == lastRequestedNode->name_)
{
- COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;
+ orxout(user_warning) << "Requesting the currently active state! Ignoring." << endl;
return;
}
@@ -402,7 +422,7 @@
}
if (requestedNodes.empty())
- COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
+ orxout(user_error) << "Requested GameState transition is not allowed. Ignoring." << endl;
else
this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
}
@@ -424,7 +444,7 @@
if (lastRequestedNode != this->rootStateNode_)
this->requestState(lastRequestedNode->parent_.lock()->name_);
else
- COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;
+ orxout(internal_warning) << "Can't pop the internal dummy root GameState" << endl;
}
shared_ptr<GameState> Game::getState(const std::string& name)
@@ -436,9 +456,9 @@
{
std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(name);
if (it != gameStateDeclarations_s.end())
- COUT(1) << "Error: GameState '" << name << "' has not yet been loaded." << std::endl;
+ orxout(internal_error) << "GameState '" << name << "' has not yet been loaded." << endl;
else
- COUT(1) << "Error: Could not find GameState '" << name << "'." << std::endl;
+ orxout(internal_error) << "Could not find GameState '" << name << "'." << endl;
return shared_ptr<GameState>();
}
}
@@ -506,6 +526,9 @@
{
if (!GameMode::showsGraphics())
{
+ orxout(user_status) << "Loading graphics" << endl;
+ orxout(internal_info) << "loading graphics in Game" << endl;
+
core_->loadGraphics();
Loki::ScopeGuard graphicsUnloader = Loki::MakeObjGuard(*this, &Game::unloadGraphics);
@@ -523,6 +546,8 @@
}
}
graphicsUnloader.Dismiss();
+
+ orxout(internal_info) << "finished loading graphics in Game" << endl;
}
}
@@ -530,6 +555,9 @@
{
if (GameMode::showsGraphics())
{
+ orxout(user_status) << "Unloading graphics" << endl;
+ orxout(internal_info) << "unloading graphics in Game" << endl;
+
// Destroy all the GameStates that require graphics
for (GameStateMap::iterator it = constructedStates_.begin(); it != constructedStates_.end();)
{
@@ -554,6 +582,8 @@
void Game::loadState(const std::string& name)
{
+ orxout(internal_status) << "loading state '" << name << "'" << endl;
+
this->bChangingState_ = true;
LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState); (void)LOKI_ANONYMOUS_VARIABLE(scopeGuard);
@@ -576,6 +606,8 @@
void Game::unloadState(const std::string& name)
{
+ orxout(internal_status) << "unloading state '" << name << "'" << endl;
+
this->bChangingState_ = true;
try
{
@@ -588,8 +620,8 @@
}
catch (...)
{
- COUT(2) << "Warning: Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << std::endl;
- COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
+ orxout(internal_warning) << "Unloading GameState '" << name << "' threw an exception: " << Exception::handleMessage() << endl;
+ orxout(internal_warning) << "There might be potential resource leaks involved! To avoid this, improve exception-safety." << endl;
}
// Check if graphics is still required
if (!bAbort_)
Modified: code/trunk/src/libraries/core/Game.h
===================================================================
--- code/trunk/src/libraries/core/Game.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Game.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -46,7 +46,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/preprocessor/cat.hpp>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/DestructionHelper.h"
#include "util/Singleton.h"
#include "OrxonoxClass.h"
@@ -214,8 +214,8 @@
}
else
{
- COUT(0) << "Error: Cannot declare two GameStates with the same name." << std::endl;
- COUT(0) << " Ignoring second one ('" << stateName << "')." << std::endl;
+ orxout(internal_warning) << "Cannot declare two GameStates with the same name." << endl;
+ orxout(internal_warning) << "Ignoring second one ('" << stateName << "')." << endl;
}
// Create a factory to delay GameState creation
Modified: code/trunk/src/libraries/core/GameState.cc
===================================================================
--- code/trunk/src/libraries/core/GameState.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/GameState.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -34,7 +34,6 @@
#include "GameState.h"
-#include "util/Debug.h"
#include "util/Exception.h"
#include "util/OrxAssert.h"
#include "Game.h"
Modified: code/trunk/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/GraphicsManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -103,6 +103,7 @@
{
RegisterObject(GraphicsManager);
+ orxout(internal_status) << "initializing GraphicsManager..." << endl;
this->setConfigValues();
// Ogre setup procedure (creating Ogre::Root)
@@ -113,7 +114,7 @@
// Load resources
resources_.reset(new XMLFile("DefaultResources.oxr"));
resources_->setLuaSupport(false);
- Loader::open(resources_.get());
+ Loader::open(resources_.get(), ClassTreeMask(), false);
// Only for runs in the build directory (not installed)
if (PathConfig::buildDirectoryRun())
@@ -121,17 +122,21 @@
extResources_.reset(new XMLFile("resources.oxr"));
extResources_->setLuaSupport(false);
- Loader::open(extResources_.get());
+ Loader::open(extResources_.get(), ClassTreeMask(), false);
if (bLoadRenderer)
{
// Reads the ogre config and creates the render window
this->upgradeToGraphics();
}
+
+ orxout(internal_status) << "finished initializing GraphicsManager" << endl;
}
void GraphicsManager::destroy()
{
+ orxout(internal_status) << "destroying GraphicsManager..." << endl;
+
Loader::unload(debugOverlay_.get());
Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_);
@@ -147,6 +152,8 @@
safeObjectDelete(&ogreRoot_);
safeObjectDelete(&ogreLogger_);
safeObjectDelete(&ogreWindowEventListener_);
+
+ orxout(internal_status) << "finished destroying GraphicsManager" << endl;
}
void GraphicsManager::setConfigValues()
@@ -157,12 +164,6 @@
.description("Comma separated list of all plugins to load.");
SetConfigValue(ogreLogFile_, "ogre.log")
.description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
- SetConfigValue(ogreLogLevelTrivial_ , 5)
- .description("Corresponding orxonox debug level for ogre Trivial");
- SetConfigValue(ogreLogLevelNormal_ , 4)
- .description("Corresponding orxonox debug level for ogre Normal");
- SetConfigValue(ogreLogLevelCritical_, 2)
- .description("Corresponding orxonox debug level for ogre Critical");
}
/**
@@ -178,6 +179,8 @@
if (renderWindow_ != NULL)
return;
+ orxout(internal_info) << "GraphicsManager upgrade to graphics" << endl;
+
// load all the required plugins for Ogre
this->loadOgrePlugins();
@@ -188,6 +191,8 @@
// already been initialised. If you need to load resources later, you will have to
// choose another resource group.
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+
+ orxout(internal_info) << "GraphicsManager finished upgrade to graphics" << endl;
}
/**
@@ -196,16 +201,16 @@
*/
void GraphicsManager::loadOgreRoot()
{
- COUT(3) << "Setting up Ogre..." << std::endl;
+ orxout(internal_info) << "Setting up Ogre..." << endl;
if (ogreConfigFile_.empty())
{
- COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
+ orxout(internal_warning) << "Ogre config file set to \"\". Defaulting to config.cfg" << endl;
ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
}
if (ogreLogFile_.empty())
{
- COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
+ orxout(internal_warning) << "Ogre log file set to \"\". Defaulting to ogre.log" << endl;
ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
}
@@ -215,17 +220,17 @@
// create a new logManager
// Ogre::Root will detect that we've already created a Log
ogreLogger_ = new Ogre::LogManager();
- COUT(4) << "Ogre LogManager created" << std::endl;
+ orxout(internal_info) << "Ogre LogManager created" << endl;
// create our own log that we can listen to
Ogre::Log *myLog;
myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
- COUT(4) << "Ogre Log created" << std::endl;
+ orxout(internal_info) << "Ogre Log created" << endl;
myLog->setLogDetail(Ogre::LL_BOREME);
myLog->addListener(this);
- COUT(4) << "Creating Ogre Root..." << std::endl;
+ orxout(internal_info) << "Creating Ogre Root..." << endl;
// check for config file existence because Ogre displays (caught) exceptions if not
if (!boost::filesystem::exists(ogreConfigFilepath))
@@ -239,11 +244,13 @@
// Leave plugins file empty. We're going to do that part manually later
ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
- COUT(3) << "Ogre set up done." << std::endl;
+ orxout(internal_info) << "Ogre set up done." << endl;
}
void GraphicsManager::loadOgrePlugins()
{
+ orxout(internal_info) << "loading ogre plugins" << endl;
+
// Plugin path can have many different locations...
std::string pluginPath = specialConfig::ogrePluginsDirectory;
#ifdef DEPENDENCY_PACKAGE_ENABLE
@@ -276,11 +283,11 @@
void GraphicsManager::loadRenderer()
{
- CCOUT(4) << "Configuring Renderer" << std::endl;
+ orxout(internal_info) << "GraphicsManager: Configuring Renderer" << endl;
bool updatedConfig = Core::getInstance().getOgreConfigTimestamp() > Core::getInstance().getLastLevelTimestamp();
if (updatedConfig)
- COUT(2) << "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << std::endl;
+ orxout(user_info)<< "Ogre config file has changed, but no level was started since then. Displaying config dialogue again to verify the changes." << endl;
if (!ogreRoot_->restoreConfig() || updatedConfig)
{
@@ -290,7 +297,7 @@
Core::getInstance().updateOgreConfigTimestamp();
}
- CCOUT(4) << "Creating render window" << std::endl;
+ orxout(internal_info) << "Creating render window" << endl;
this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
// Propagate the size of the new winodw
@@ -316,9 +323,9 @@
void GraphicsManager::loadDebugOverlay()
{
// Load debug overlay to show info about fps and tick time
- COUT(4) << "Loading Debug Overlay..." << std::endl;
+ orxout(internal_info) << "Loading Debug Overlay..." << endl;
debugOverlay_.reset(new XMLFile("debug.oxo"));
- Loader::open(debugOverlay_.get());
+ Loader::open(debugOverlay_.get(), ClassTreeMask(), false);
}
/**
@@ -395,12 +402,12 @@
void GraphicsManager::messageLogged(const std::string& message,
Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
{
- int orxonoxLevel;
+ OutputLevel orxonoxLevel;
std::string introduction;
// Do not show caught OGRE exceptions in front
if (message.find("EXCEPTION") != std::string::npos)
{
- orxonoxLevel = OutputLevel::Debug;
+ orxonoxLevel = level::internal_error;
introduction = "Ogre, caught exception: ";
}
else
@@ -408,21 +415,21 @@
switch (lml)
{
case Ogre::LML_TRIVIAL:
- orxonoxLevel = this->ogreLogLevelTrivial_;
+ orxonoxLevel = level::verbose_more;
break;
case Ogre::LML_NORMAL:
- orxonoxLevel = this->ogreLogLevelNormal_;
+ orxonoxLevel = level::verbose;
break;
case Ogre::LML_CRITICAL:
- orxonoxLevel = this->ogreLogLevelCritical_;
+ orxonoxLevel = level::internal_warning;
break;
default:
- orxonoxLevel = 0;
+ orxonoxLevel = level::debug_output;
}
introduction = "Ogre: ";
}
- OutputHandler::getOutStream(orxonoxLevel)
- << introduction << message << std::endl;
+
+ orxout(orxonoxLevel, context::ogre) << introduction << message << endl;
}
size_t GraphicsManager::getRenderWindowHandle()
Modified: code/trunk/src/libraries/core/GraphicsManager.h
===================================================================
--- code/trunk/src/libraries/core/GraphicsManager.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/GraphicsManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -133,9 +133,6 @@
std::string ogreConfigFile_; //!< ogre config filename
std::string ogrePlugins_; //!< Comma separated list of all plugins to load
std::string ogreLogFile_; //!< log filename for Ogre log messages
- int ogreLogLevelTrivial_; //!< Corresponding Orxonox debug level for LL_TRIVIAL
- int ogreLogLevelNormal_; //!< Corresponding Orxonox debug level for LL_NORMAL
- int ogreLogLevelCritical_; //!< Corresponding Orxonox debug level for LL_CRITICAL
/// Helper object that executes the surrogate destructor destroy()
DestructionHelper<GraphicsManager> destructionHelper_;
Modified: code/trunk/src/libraries/core/Identifier.cc
===================================================================
--- code/trunk/src/libraries/core/Identifier.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Identifier.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -129,7 +129,7 @@
if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy())
{
// If no: We have to store the information and initialize the Identifier
- COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl;
+ orxout(verbose, context::identifier) << "Register Class in ClassIdentifier<" << this->getName() << ">-Singleton -> Initialize Singleton." << endl;
if (bRootClass)
this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
else
@@ -143,7 +143,7 @@
*/
void Identifier::initialize(std::set<const Identifier*>* parents)
{
- COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl;
+ orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << this->name_ << ">-Singleton." << endl;
this->bCreatedOneObject_ = true;
if (parents)
@@ -190,7 +190,7 @@
*/
void Identifier::createClassHierarchy()
{
- COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;
+ orxout(internal_status) << "Create class-hierarchy" << endl;
Identifier::startCreatingHierarchy();
for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
{
@@ -202,7 +202,7 @@
}
}
Identifier::stopCreatingHierarchy();
- COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;
+ orxout(internal_status) << "Finished class-hierarchy creation" << endl;
}
/**
@@ -241,9 +241,9 @@
}
else
{
- COUT(1) << "An error occurred in Identifier.cc:" << std::endl;
- COUT(1) << "Error: Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << std::endl;
- COUT(1) << "Aborting..." << std::endl;
+ orxout(user_error) << "An error occurred in Identifier.cc:" << endl;
+ orxout(user_error) << "Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << endl;
+ orxout(user_error) << "Aborting..." << endl;
abort();
return 0;
}
@@ -403,7 +403,7 @@
std::map<std::string, ConfigValueContainer*>::const_iterator it = this->configValues_.find(varname);
if (it != this->configValues_.end())
{
- COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << '.' << std::endl;
+ orxout(internal_warning) << "Overwriting config-value with name " << varname << " in class " << this->getName() << '.' << endl;
delete (it->second);
}
@@ -449,7 +449,7 @@
std::map<std::string, XMLPortParamContainer*>::const_iterator it = this->xmlportParamContainers_.find(paramname);
if (it != this->xmlportParamContainers_.end())
{
- COUT(2) << "Warning: Overwriting XMLPortParamContainer in class " << this->getName() << '.' << std::endl;
+ orxout(internal_warning) << "Overwriting XMLPortParamContainer in class " << this->getName() << '.' << endl;
delete (it->second);
}
@@ -480,7 +480,7 @@
std::map<std::string, XMLPortObjectContainer*>::const_iterator it = this->xmlportObjectContainers_.find(sectionname);
if (it != this->xmlportObjectContainers_.end())
{
- COUT(2) << "Warning: Overwriting XMLPortObjectContainer in class " << this->getName() << '.' << std::endl;
+ orxout(internal_warning) << "Overwriting XMLPortObjectContainer in class " << this->getName() << '.' << endl;
delete (it->second);
}
Modified: code/trunk/src/libraries/core/Identifier.h
===================================================================
--- code/trunk/src/libraries/core/Identifier.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Identifier.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -63,7 +63,7 @@
int count;
for (Iterator<BaseObject> it = objects.begin(); it != objects.end(); ++it) // iterate through the objects
++count;
- COUT(0) << count << std::endl; // prints "2" because we created 2 instances of MyClass so far
+ orxout() << count << endl; // prints "2" because we created 2 instances of MyClass so far
// test the class hierarchy
@@ -88,7 +88,7 @@
#include <typeinfo>
#include <loki/TypeTraits.h>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "MetaObjectList.h"
#include "ObjectList.h"
#include "ObjectListBase.h"
@@ -404,11 +404,11 @@
if (ClassIdentifier<T>::classIdentifier_s == proposal)
{
- COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl;
+ orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was not yet existing and got created." << endl;
}
else
{
- COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl;
+ orxout(verbose, context::identifier) << "Requested Identifier for " << name << " was already existing and got assigned." << endl;
}
}
@@ -422,9 +422,9 @@
bool ClassIdentifier<T>::initialiseObject(T* object, const std::string& className, bool bRootClass)
{
if (bRootClass)
- COUT(5) << "*** Register Root-Object: " << className << std::endl;
+ orxout(verbose, context::object_list) << "Register Root-Object: " << className << endl;
else
- COUT(5) << "*** Register Object: " << className << std::endl;
+ orxout(verbose, context::object_list) << "Register Object: " << className << endl;
object->identifier_ = this;
if (Identifier::isCreatingHierarchy())
@@ -443,7 +443,7 @@
}
else
{
- COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
+ orxout(verbose, context::object_list) << "Added object to " << this->getName() << "-list." << endl;
object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
// Add pointer of type T to the map in the OrxonoxClass instance that enables "dynamic_casts"
Modified: code/trunk/src/libraries/core/Language.cc
===================================================================
--- code/trunk/src/libraries/core/Language.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Language.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -34,7 +34,7 @@
#include "Language.h"
#include <fstream>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/StringUtils.h"
#include "Core.h"
#include "PathConfig.h"
@@ -130,7 +130,7 @@
return newEntry;
}
- COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << '!' << std::endl;
+ orxout(internal_warning, context::language) << "Language entry " << label << " is duplicate in " << getFilename(this->defaultLanguage_) << '!' << endl;
return it->second;
}
@@ -141,7 +141,7 @@
*/
void Language::addEntry(const LanguageEntryLabel& label, const std::string& entry)
{
- COUT(5) << "Language: Called addEntry with\n label: " << label << "\n entry: " << entry << std::endl;
+ orxout(verbose, context::language) << "Called addEntry with" << '\n' << "label: " << label << '\n' << "entry: " << entry << endl;
std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
if (it == this->languageEntries_.end())
{
@@ -178,7 +178,7 @@
else if (bError)
{
// Uh, oh, an undefined entry was requested: return the default string
- COUT(2) << "Warning: Language entry \"" << label << "\" not found!" << std::endl;
+ orxout(internal_warning, context::language) << "Language entry \"" << label << "\" not found!" << endl;
return this->defaultLocalisation_;
}
else
@@ -200,7 +200,7 @@
*/
void Language::readDefaultLanguageFile()
{
- COUT(4) << "Read default language file." << std::endl;
+ orxout(internal_info, context::language) << "Read default language file." << endl;
const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
@@ -215,8 +215,8 @@
if (!file.is_open())
{
- COUT(1) << "An error occurred in Language.cc:" << std::endl;
- COUT(1) << "Error: Couldn't open file " << getFilename(this->defaultLanguage_) << " to read the default language entries!" << std::endl;
+ orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl;
+ orxout(internal_error, context::language) << "Couldn't open file " << getFilename(this->defaultLanguage_) << " to read the default language entries!" << endl;
return;
}
@@ -236,7 +236,7 @@
this->createEntry(lineString.substr(0, pos), lineString.substr(pos + 1));
else
{
- COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(this->defaultLanguage_) << std::endl;
+ orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(this->defaultLanguage_) << endl;
}
}
}
@@ -249,7 +249,7 @@
*/
void Language::readTranslatedLanguageFile()
{
- COUT(4) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << std::endl;
+ orxout(internal_info, context::language) << "Read translated language file (" << Core::getInstance().getLanguage() << ")." << endl;
const std::string& filepath = PathConfig::getConfigPathString() + getFilename(Core::getInstance().getLanguage());
@@ -259,10 +259,10 @@
if (!file.is_open())
{
- COUT(1) << "An error occurred in Language.cc:" << std::endl;
- COUT(1) << "Error: Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << std::endl;
+ orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl;
+ orxout(internal_error, context::language) << "Couldn't open file " << getFilename(Core::getInstance().getLanguage()) << " to read the translated language entries!" << endl;
Core::getInstance().resetLanguage();
- COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << '.' << std::endl;
+ orxout(internal_info, context::language) << "Reset language to " << this->defaultLanguage_ << '.' << endl;
return;
}
@@ -290,7 +290,7 @@
}
else
{
- COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << std::endl;
+ orxout(internal_warning, context::language) << "Invalid language entry \"" << lineString << "\" in " << getFilename(Core::getInstance().getLanguage()) << endl;
}
}
}
@@ -303,7 +303,7 @@
*/
void Language::writeDefaultLanguageFile() const
{
- COUT(4) << "Language: Write default language file." << std::endl;
+ orxout(verbose, context::language) << "Write default language file." << endl;
const std::string& filepath = PathConfig::getConfigPathString() + getFilename(this->defaultLanguage_);
@@ -313,15 +313,15 @@
if (!file.is_open())
{
- COUT(1) << "An error occurred in Language.cc:" << std::endl;
- COUT(1) << "Error: Couldn't open file " << getFilename(this->defaultLanguage_) << " to write the default language entries!" << std::endl;
+ orxout(internal_error, context::language) << "An error occurred in Language.cc:" << endl;
+ orxout(internal_error, context::language) << "Couldn't open file " << getFilename(this->defaultLanguage_) << " to write the default language entries!" << endl;
return;
}
// Iterate through the list an write the lines into the file
for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
{
- file << it->second->getLabel() << '=' << it->second->getDefault() << std::endl;
+ file << it->second->getLabel() << '=' << it->second->getDefault() << endl;
}
file.close();
Modified: code/trunk/src/libraries/core/Language.h
===================================================================
--- code/trunk/src/libraries/core/Language.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Language.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,14 +50,14 @@
- Get the localisation of the entry in the configured language:
@code
- std::cout << Language::getInstance()->getLocalisation("name of the entry") << std::endl;
+ orxout() << Language::getInstance()->getLocalisation("name of the entry") << endl;
@endcode
Example:
@code
int age = 20;
AddLanguageEntry("user_age", "Age");
- std::cout << GetLocalisation("user_age") << ": " << age << std::endl;
+ orxout() << GetLocalisation("user_age") << ": " << age << endl;
@endcode
Resulting output:
Modified: code/trunk/src/libraries/core/Loader.cc
===================================================================
--- code/trunk/src/libraries/core/Loader.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Loader.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -32,7 +32,7 @@
#include <tinyxml/ticpp.h>
#include <boost/scoped_ptr.hpp>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/StringUtils.h"
#include "BaseObject.h"
@@ -48,10 +48,10 @@
std::vector<std::pair<const XMLFile*, ClassTreeMask> > Loader::files_s;
ClassTreeMask Loader::currentMask_s;
- bool Loader::open(const XMLFile* file, const ClassTreeMask& mask)
+ bool Loader::open(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
{
Loader::add(file, mask);
- return Loader::load(file, mask);
+ return Loader::load(file, mask, bVerbose);
}
void Loader::close()
@@ -92,16 +92,16 @@
Loads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
@param mask
A ClassTreeMask, which defines which types of classes are loaded and which aren't.
- @param verbose
+ @param bVerbose
Whether the loader is verbose (prints its progress in a low output level) or not.
@return
Returns true if successful.
*/
- bool Loader::load(const ClassTreeMask& mask, bool verbose)
+ bool Loader::load(const ClassTreeMask& mask, bool bVerbose)
{
bool success = true;
for (std::vector<std::pair<const XMLFile*, ClassTreeMask> >::iterator it = Loader::files_s.begin(); it != Loader::files_s.end(); ++it)
- if (!Loader::load(it->first, it->second * mask, verbose))
+ if (!Loader::load(it->first, it->second * mask, bVerbose))
success = false;
return success;
@@ -123,15 +123,15 @@
Reloads all opened files, while conforming to the restrictions given by the input ClassTreeMask.
@param mask
A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
- @param verbose
+ @param bVerbose
Whether the loader is verbose (prints its progress in a low output level) or not.
@return
Returns true if successful.
*/
- bool Loader::reload(const ClassTreeMask& mask, bool verbose)
+ bool Loader::reload(const ClassTreeMask& mask, bool bVerbose)
{
Loader::unload(mask);
- return Loader::load(mask, verbose);
+ return Loader::load(mask, bVerbose);
}
/**
@@ -141,14 +141,14 @@
The file to be loaded.
@param mask
A ClassTreeMask, which defines which types of classes are loaded and which aren't.
- @param verbose
+ @param bVerbose
Whether the loader is verbose (prints its progress in a low output level) or not.
@param bRemoveLuaTags
If true lua tags are just ignored and removed. The default is false.
@return
Returns true if successful.
*/
- bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool verbose, bool bRemoveLuaTags)
+ bool Loader::load(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose, bool bRemoveLuaTags)
{
if (!file)
return false;
@@ -169,7 +169,7 @@
shared_ptr<ResourceInfo> info = Resource::getInfo(file->getFilename());
if (info == NULL)
{
- COUT(1) << "Error: Could not find XML file '" << file->getFilename() << "'." << std::endl;
+ orxout(user_error, context::loader) << "Could not find XML file '" << file->getFilename() << "'." << endl;
return false;
}
xmlInput = Resource::open(file->getFilename())->getAsString();
@@ -186,15 +186,15 @@
try
{
- if(verbose)
+ if(bVerbose)
{
- COUT(0) << "Start loading " << file->getFilename() << "..." << std::endl;
- COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
+ orxout(user_info) << "Start loading " << file->getFilename() << "..." << endl;
+ orxout(internal_info, context::loader) << "Mask: " << Loader::currentMask_s << endl;
}
else
{
- COUT(4) << "Start loading " << file->getFilename() << "..." << std::endl;
- COUT(4) << "Mask: " << Loader::currentMask_s << std::endl;
+ orxout(verbose, context::loader) << "Start loading " << file->getFilename() << "..." << endl;
+ orxout(verbose_more, context::loader) << "Mask: " << Loader::currentMask_s << endl;
}
ticpp::Document xmlfile(file->getFilename());
@@ -207,7 +207,7 @@
for (ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++)
rootElement.InsertEndChild(*child);
- COUT(4) << " creating root-namespace..." << std::endl;
+ orxout(verbose, context::loader) << " creating root-namespace..." << endl;
Namespace* rootNamespace = new Namespace(0);
rootNamespace->setLoaderIndentation(" ");
rootNamespace->setFile(file);
@@ -215,37 +215,37 @@
rootNamespace->setRoot(true);
rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
- if(verbose)
- COUT(0) << "Finished loading " << file->getFilename() << '.' << std::endl;
+ if(bVerbose)
+ orxout(user_info) << "Finished loading " << file->getFilename() << '.' << endl;
else
- COUT(4) << "Finished loading " << file->getFilename() << '.' << std::endl;
+ orxout(verbose, context::loader) << "Finished loading " << file->getFilename() << '.' << endl;
- COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString(" ") << std::endl;
+ orxout(verbose, context::loader) << "Namespace-tree:" << '\n' << rootNamespace->toString(" ") << endl;
return true;
}
catch (ticpp::Exception& ex)
{
- COUT(1) << std::endl;
- COUT(1) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
- COUT(1) << ex.what() << std::endl;
- COUT(1) << "Loading aborted." << std::endl;
+ orxout(user_error, context::loader) << endl;
+ orxout(user_error, context::loader) << "An XML-error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl;
+ orxout(user_error, context::loader) << ex.what() << endl;
+ orxout(user_error, context::loader) << "Loading aborted." << endl;
return false;
}
catch (Exception& ex)
{
- COUT(1) << std::endl;
- COUT(1) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
- COUT(1) << ex.what() << std::endl;
- COUT(1) << "Loading aborted." << std::endl;
+ orxout(user_error, context::loader) << endl;
+ orxout(user_error, context::loader) << "A loading-error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl;
+ orxout(user_error, context::loader) << ex.what() << endl;
+ orxout(user_error, context::loader) << "Loading aborted." << endl;
return false;
}
catch (...)
{
- COUT(1) << std::endl;
- COUT(1) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << std::endl;
- COUT(1) << Exception::handleMessage() << std::endl;
- COUT(1) << "Loading aborted." << std::endl;
+ orxout(user_error, context::loader) << endl;
+ orxout(user_error, context::loader) << "An error occurred in Loader.cc while loading " << file->getFilename() << ':' << endl;
+ orxout(user_error, context::loader) << Exception::handleMessage() << endl;
+ orxout(user_error, context::loader) << "Loading aborted." << endl;
return false;
}
}
@@ -270,15 +270,15 @@
The file to be reloaded.
@param mask
A ClassTreeMask, which defines which types of classes are reloaded and which aren't.
- @param verbose
+ @param bVerbose
Whether the loader is verbose (prints its progress in a low output level) or not.
@return
Returns true if successful.
*/
- bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool verbose)
+ bool Loader::reload(const XMLFile* file, const ClassTreeMask& mask, bool bVerbose)
{
Loader::unload(file, mask);
- return Loader::load(file, mask, verbose);
+ return Loader::load(file, mask, bVerbose);
}
bool Loader::getLuaTags(const std::string& text, std::map<size_t, bool>& luaTags)
@@ -336,9 +336,9 @@
}
if (!expectedValue)
{
- COUT(2) << "Warning: Error in level file" << std::endl;
+ orxout(internal_error, context::loader) << "Error in level file" << endl;
// TODO: error handling
- return false;
+ return false;
}
}
Modified: code/trunk/src/libraries/core/Loader.h
===================================================================
--- code/trunk/src/libraries/core/Loader.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Loader.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,21 +50,21 @@
class _CoreExport Loader
{
public:
- static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
+ static bool open(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
static void close();
static void close(const XMLFile* file);
static void add(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
static void remove(const XMLFile* file);
- static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
+ static bool load(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
static void unload(const ClassTreeMask& mask = ClassTreeMask());
- static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
+ static bool reload(const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
static bool load(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(),
- bool verbose = true, bool bRemoveLuaTags = false);
+ bool bVerbose = true, bool bRemoveLuaTags = false);
static void unload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask());
- static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool verbose = true);
+ static bool reload(const XMLFile* file, const ClassTreeMask& mask = ClassTreeMask(), bool bVerbose = true);
static std::string replaceLuaTags(const std::string& text);
static std::string removeLuaTags(const std::string& text);
Modified: code/trunk/src/libraries/core/LuaState.cc
===================================================================
--- code/trunk/src/libraries/core/LuaState.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/LuaState.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -36,7 +36,7 @@
}
#include <loki/ScopeGuard.h>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "Resource.h"
#include "command/IOConsole.h"
@@ -95,7 +95,7 @@
return this->includeString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
else
{
- COUT(2) << "LuaState: Cannot include file '" << filename << "' (not found)." << std::endl;
+ orxout(internal_warning, context::lua) << "LuaState: Cannot include file '" << filename << "' (not found)." << endl;
return false;
}
}
@@ -135,7 +135,7 @@
return this->doString(Resource::open(sourceInfo)->getAsString(), sourceInfo);
else
{
- COUT(2) << "LuaState: Cannot do file '" << filename << "' (not found)." << std::endl;
+ orxout(internal_warning, context::lua) << "LuaState: Cannot do file '" << filename << "' (not found)." << endl;
return false;
}
}
@@ -175,10 +175,10 @@
switch (error)
{
case LUA_ERRSYNTAX: // Syntax error
- COUT(1) << "Lua syntax error: " << lua_tostring(luaState_, -1) << std::endl;
+ orxout(internal_error, context::lua) << "Lua syntax error: " << lua_tostring(luaState_, -1) << endl;
break;
case LUA_ERRMEM: // Memory allocation error
- COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl;
+ orxout(internal_error, context::lua) << "Lua memory allocation error: Consult your dentist immediately!" << endl;
break;
}
@@ -199,14 +199,14 @@
{
std::string errorString = lua_tostring(this->luaState_, -1);
if (errorString.find("Error propagation") == std::string::npos)
- COUT(1) << "Lua runtime error: " << errorString << std::endl;
+ orxout(internal_error, context::lua) << "Lua runtime error: " << errorString << endl;
}
break;
case LUA_ERRERR: // Error in the error handler
- COUT(1) << "Lua error in error handler. No message available." << std::endl;
+ orxout(internal_error, context::lua) << "Lua error in error handler. No message available." << endl;
break;
case LUA_ERRMEM: // Memory allocation error
- COUT(1) << "Lua memory allocation error: Consult your dentist immediately!" << std::endl;
+ orxout(internal_error, context::lua) << "Lua memory allocation error: Consult your dentist immediately!" << endl;
break;
}
}
@@ -235,11 +235,21 @@
output_ << str;
}
- void LuaState::luaLog(unsigned int level, const std::string& message)
+ void LuaState::luaOutput(OutputLevel level, const std::string& context, const std::string& message)
{
- OutputHandler::getOutStream(level) << message << std::endl;
+ orxout(level, registerContext(context)) << message << endl;
}
+ void LuaState::luaOutput(OutputLevel level, const std::string& message)
+ {
+ orxout(level, context::lua) << message << endl;
+ }
+
+ void LuaState::luaOutput(const std::string& message)
+ {
+ orxout(debug_output, context::lua) << message << endl;
+ }
+
bool LuaState::fileExists(const std::string& filename)
{
shared_ptr<ResourceInfo> info = this->getFileInfo(filename);
@@ -287,7 +297,7 @@
{
if (it->first == name || it->second == function)
{
- COUT(2) << "Warning: Trying to add a Tolua interface with the same name or function." << std::endl;
+ orxout(internal_warning, context::lua) << "Trying to add a Tolua interface with the same name or function." << endl;
return true;
}
}
@@ -306,7 +316,7 @@
ToluaInterfaceMap::iterator it = getToluaInterfaces().find(name);
if (it == getToluaInterfaces().end())
{
- COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl;
+ orxout(internal_warning, context::lua) << "Cannot remove Tolua interface '" << name << "': Not found" << endl;
return true;
}
Modified: code/trunk/src/libraries/core/LuaState.h
===================================================================
--- code/trunk/src/libraries/core/LuaState.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/LuaState.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -48,6 +48,8 @@
#include <vector>
#include <boost/shared_ptr.hpp>
+#include "util/Output.h"
+
namespace orxonox // tolua_export
{ // tolua_export
class LuaFunctor; // tolua_export
@@ -82,7 +84,9 @@
bool includeString(const std::string& code, const shared_ptr<ResourceInfo>& sourceFileInfo = shared_ptr<ResourceInfo>());
void luaPrint(const std::string& str); // tolua_export
- void luaLog(unsigned int level, const std::string& message); // tolua_export
+ void luaOutput(orxonox::level::OutputLevel level, const std::string& context, const std::string& message); // tolua_export
+ void luaOutput(orxonox::level::OutputLevel level, const std::string& message); // tolua_export
+ void luaOutput(const std::string& message); // tolua_export
bool fileExists(const std::string& filename); // tolua_export
std::string getSourceCode(const std::string& filename); // tolua_export
Modified: code/trunk/src/libraries/core/MetaObjectList.cc
===================================================================
--- code/trunk/src/libraries/core/MetaObjectList.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/MetaObjectList.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,7 +33,7 @@
#include "MetaObjectList.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "Identifier.h"
#include "ObjectListBase.h"
@@ -47,7 +47,7 @@
*/
MetaObjectListElement::~MetaObjectListElement()
{
- COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;
+ orxout(verbose, context::object_list) << "Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << endl;
this->list_->notifyIterators(this->element_->objectBase_);
if (this->element_->next_)
Modified: code/trunk/src/libraries/core/NamespaceNode.cc
===================================================================
--- code/trunk/src/libraries/core/NamespaceNode.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/NamespaceNode.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -27,7 +27,7 @@
*/
#include "NamespaceNode.h"
-#include "util/Debug.h"
+#include "util/Output.h"
namespace orxonox
{
@@ -69,12 +69,12 @@
{
if (this->bRoot_)
{
- COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl;
+ orxout(internal_warning) << "Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << endl;
nodes = this->getNodeRelative(secondPart);
}
else if (!this->parent_)
{
- COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl;
+ orxout(internal_warning) << "Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << endl;
nodes = this->getNodeRelative(secondPart);
}
else
@@ -90,7 +90,7 @@
if (it->second->isHidden())
{
- COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;
+ orxout(internal_warning) << "Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << endl;
nodes.insert(this);
}
else
@@ -114,7 +114,7 @@
if (!bFoundMatchingNamespace)
{
- COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl;
+ orxout(internal_warning) << "No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << endl;
nodes = this->getNodeRelative(secondPart);
}
}
Modified: code/trunk/src/libraries/core/OrxonoxClass.cc
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/OrxonoxClass.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -59,7 +59,7 @@
OrxonoxClass::~OrxonoxClass()
{
// if (!this->requestedDestruction_)
-// COUT(2) << "Warning: Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << std::endl;
+// orxout(internal_warning) << "Destroyed object without destroy() (" << this->getIdentifier()->getName() << ')' << endl;
assert(this->referenceCount_ <= 0);
Modified: code/trunk/src/libraries/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/libraries/core/OrxonoxClass.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/OrxonoxClass.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -49,13 +49,6 @@
#include <vector>
#include "Super.h"
-/**
- at def CCOUT
- Acts almost exactly like COUT(x), but prepends "ClassName: "
-*/
-#define CCOUT(level) \
- COUT(level) << this->getIdentifier()->getName() << ": "
-
namespace orxonox
{
/**
Modified: code/trunk/src/libraries/core/PathConfig.cc
===================================================================
--- code/trunk/src/libraries/core/PathConfig.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/PathConfig.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,7 +50,7 @@
#endif
#include "SpecialConfig.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "CommandLineParser.h"
@@ -136,7 +136,7 @@
if (bf::exists(executablePath_ / "orxonox_dev_build.keep_me"))
{
- COUT(1) << "Running from the build tree." << std::endl;
+ orxout(internal_info) << "Running from the build tree." << endl;
PathConfig::bBuildDirectoryRun_ = true;
modulePath_ = specialConfig::moduleDevDirectory;
}
@@ -246,7 +246,7 @@
}
if (bf::create_directories(it->first)) // function may not return true at all (bug?)
{
- COUT(4) << "Created " << it->second << " directory" << std::endl;
+ orxout(internal_info) << "Created " << it->second << " directory" << endl;
}
}
}
Modified: code/trunk/src/libraries/core/SubclassIdentifier.h
===================================================================
--- code/trunk/src/libraries/core/SubclassIdentifier.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/SubclassIdentifier.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -68,7 +68,7 @@
#include "CorePrereqs.h"
#include <cstdlib>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "Identifier.h"
namespace orxonox
@@ -118,15 +118,15 @@
{
if (!identifier || !identifier->isA(ClassIdentifier<T>::getIdentifier()))
{
- COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+ orxout(internal_error) << "An error occurred in SubclassIdentifier (Identifier.h):" << endl;
if (identifier)
{
- COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;
- COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
+ orxout(internal_error) << "Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << endl;
+ orxout(internal_error) << "SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << endl;
}
else
{
- COUT(1) << "Error: Can't assign NULL identifier" << std::endl;
+ orxout(internal_error) << "Can't assign NULL identifier" << endl;
}
}
else
@@ -176,17 +176,17 @@
// Something went terribly wrong
if (this->identifier_)
{
- COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
- COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << std::endl;
- COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
+ orxout(user_error) << "An error occurred in SubclassIdentifier (Identifier.h):" << endl;
+ orxout(user_error) << "Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << '!' << endl;
+ orxout(user_error) << "Couldn't fabricate a new Object." << endl;
}
else
{
- COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
- COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;
+ orxout(user_error) << "An error occurred in SubclassIdentifier (Identifier.h):" << endl;
+ orxout(user_error) << "Couldn't fabricate a new Object - Identifier is undefined." << endl;
}
- COUT(1) << "Aborting..." << std::endl;
+ orxout(user_error) << "Aborting..." << endl;
abort();
return 0;
}
Modified: code/trunk/src/libraries/core/Super.h
===================================================================
--- code/trunk/src/libraries/core/Super.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Super.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -72,7 +72,7 @@
#define _Super_H__
#include "CorePrereqs.h"
-#include "util/Debug.h"
+#include "util/Output.h"
///////////////////////
// Macro definitions //
@@ -113,7 +113,7 @@
\
if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
{ \
- COUT(5) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \
+ orxout(verbose, context::super) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << endl; \
((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
} \
} \
@@ -183,7 +183,7 @@
if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
{
// Add the SuperFunctionCaller
- COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;
+ orxout(verbose, context::super) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << endl;
((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
}
}
Modified: code/trunk/src/libraries/core/Template.cc
===================================================================
--- code/trunk/src/libraries/core/Template.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/Template.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,7 +31,7 @@
#include <tinyxml/tinyxml.h>
#include <tinyxml/ticpp.h>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "CoreIncludes.h"
#include "XMLPort.h"
@@ -87,7 +87,7 @@
it = Template::getTemplateMap().find(this->getName());
if (it != Template::getTemplateMap().end())
- COUT(2) << "Warning: Template with name \"" << this->getName() << "\" already exists." << std::endl;
+ orxout(internal_warning, context::templates) << "Template with name \"" << this->getName() << "\" already exists." << endl;
else
Template::getTemplateMap()[this->getName()] = this;
}
@@ -116,12 +116,12 @@
}
else
{
- COUT(2) << "Warning: Linking from " << this->getName() << " to " << this->link_ << " leads to an infinite loop. Returning own element." << std::endl;
+ orxout(internal_warning, context::templates) << "Linking from \"" << this->getName() << "\" to \"" << this->link_ << "\" leads to an infinite loop. Returning own element." << endl;
}
}
else
{
- COUT(2) << "Warning: " << this->link_ << " is not an existing Template name. Returning own element." << std::endl;
+ orxout(internal_warning, context::templates) << '"' << this->link_ << "\" is not an existing Template name. Returning own element." << endl;
}
}
@@ -141,12 +141,12 @@
{
if (!object->isA(this->baseclassIdentifier_))
{
- COUT(1) << "Error: Can't apply template (name: " << this->getName() << "), object (name: " << object->getName() << ", class: " << object->getIdentifier()->getName() << ") is not a " << this->baseclassIdentifier_->getName() << std::endl;
+ orxout(internal_error, context::templates) << "Can't apply template (name: " << this->getName() << "), object (name: " << object->getName() << ", class: " << object->getIdentifier()->getName() << ") is not a " << this->baseclassIdentifier_->getName() << endl;
return;
}
}
- COUT(4) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << std::endl;
+ orxout(verbose, context::templates) << object->getLoaderIndentation() << " aplying Template \"" << this->getName() << "\"..." << endl;
Element temp = &const_cast<TiXmlElement&>(this->getXMLElement());
@@ -169,7 +169,7 @@
return it->second;
else
{
- COUT(2) << "Warning: Template with name " << name << " doesn't exist." << std::endl;
+ orxout(internal_warning, context::templates) << "Template with name " << name << " doesn't exist." << endl;
return 0;
}
}
Modified: code/trunk/src/libraries/core/WeakPtr.h
===================================================================
--- code/trunk/src/libraries/core/WeakPtr.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/WeakPtr.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -64,7 +64,7 @@
@code
void myCallback() // definition of the callback function
{
- COUT(0) << "Object destroyed" << std::endl;
+ orxout() << "Object destroyed" << endl;
}
MyClass* object = new MyClass(); // create an instance of MyClass
Modified: code/trunk/src/libraries/core/XMLPort.cc
===================================================================
--- code/trunk/src/libraries/core/XMLPort.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/XMLPort.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -63,7 +63,7 @@
{
if (!this->sectionname_.empty())
{
- COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
+ orxout(internal_warning, context::xml) << object->getLoaderIndentation() << "'" << child->Value() << "' is not a valid classname." << endl;
}
else
{
@@ -73,12 +73,12 @@
}
if (!identifier->isA(objectIdentifier_))
{
- COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << objectIdentifier_->getName() << "'." << std::endl;
+ orxout(internal_warning, context::xml) << object->getLoaderIndentation() << "'" << child->Value() << "' is not a '" << objectIdentifier_->getName() << "'." << endl;
continue;
}
if (!identifier->isLoadable())
{
- COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not loadable." << std::endl;
+ orxout(internal_warning, context::xml) << object->getLoaderIndentation() << "'" << child->Value() << "' is not loadable." << endl;
continue;
}
if (!this->identifierIsIncludedInLoaderMask(identifier))
@@ -86,7 +86,7 @@
try
{
- COUT(4) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
+ orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricating " << child->Value() << "..." << endl;
BaseObject* newObject = identifier->fabricate(object);
newObject->setLoaderIndentation(object->getLoaderIndentation() + " ");
@@ -94,39 +94,37 @@
if (this->bLoadBefore_)
{
newObject->XMLPort(*child, XMLPort::LoadObject);
- COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
+ orxout(verbose, context::xml) << object->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << endl;
}
else
{
- COUT(4) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << std::endl;
+ orxout(verbose, context::xml) << object->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << static_cast<BaseObject*>(object)->getName() << ')' << endl;
}
- COUT(5) << object->getLoaderIndentation();
-
this->callLoadExecutor(object, newObject);
if (!this->bLoadBefore_)
newObject->XMLPort(*child, XMLPort::LoadObject);
- COUT(5) << object->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+ orxout(verbose, context::xml) << object->getLoaderIndentation() << "fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << endl;
}
catch (AbortLoadingException& ex)
{
- COUT(1) << "An error occurred while loading object, abort loading..." << std::endl;
+ orxout(internal_error, context::xml) << "An error occurred while loading object, abort loading..." << endl;
throw ex;
}
catch (...)
{
- COUT(1) << "An error occurred while loading object:" << std::endl;
- COUT(1) << Exception::handleMessage() << std::endl;
+ orxout(internal_error, context::xml) << "An error occurred while loading object:" << endl;
+ orxout(internal_error, context::xml) << Exception::handleMessage() << endl;
}
}
}
catch (ticpp::Exception& ex)
{
- COUT(1) << std::endl;
- COUT(1) << "An error occurred in XMLPort.h while loading a '" << objectIdentifier_->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << std::endl;
- COUT(1) << ex.what() << std::endl;
+ orxout(internal_error, context::xml) << endl;
+ orxout(internal_error, context::xml) << "An error occurred in XMLPort.h while loading a '" << objectIdentifier_->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << object->getName() << ") in " << object->getFilename() << ':' << endl;
+ orxout(internal_error, context::xml) << ex.what() << endl;
}
}
else if (mode == XMLPort::SaveObject)
Modified: code/trunk/src/libraries/core/XMLPort.h
===================================================================
--- code/trunk/src/libraries/core/XMLPort.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/XMLPort.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -52,7 +52,7 @@
#include <string>
#include <tinyxml/ticpp.h>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/MultiType.h"
#include "util/OrxAssert.h"
@@ -414,7 +414,7 @@
// Unfortunately this does not seem to work with the Executor parser yet.
if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
{
- COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
+ orxout(verbose_more, context::xml) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << endl;
int error;
this->loadexecutor_->parse(object, attributeValue, &error, ",");
if (!error || (mode == XMLPort::ExpandObject))
@@ -429,9 +429,9 @@
}
catch (ticpp::Exception& ex)
{
- COUT(1) << std::endl;
- COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ':' << std::endl;
- COUT(1) << ex.what() << std::endl;
+ orxout(internal_error, context::xml) << endl;
+ orxout(internal_error, context::xml) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getFilename() << ':' << endl;
+ orxout(internal_error, context::xml) << ex.what() << endl;
}
}
else if (mode == XMLPort::SaveObject)
Modified: code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc
===================================================================
--- code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/ArgumentCompletionFunctions.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -89,7 +89,7 @@
*/
ArgumentCompletionList _groupsandcommands(const std::string& fragment, bool bOnlyShowHidden)
{
- // note: this function returns only arguments that begin with "fragment", which would't be necessary for the
+ // note: this function returns only arguments that begin with "fragment", which wouldn't be necessary for the
// auto-completion, but it's necessary to place the line-break "\n" between groups and commands
// only if both groups AND commands are in the list.
@@ -99,7 +99,7 @@
// get all the groups that are visible (except the shortcut group "")
const std::map<std::string, std::map<std::string, ConsoleCommand*> >& commands = ConsoleCommand::getCommands();
for (std::map<std::string, std::map<std::string, ConsoleCommand*> >::const_iterator it_group = commands.begin(); it_group != commands.end(); ++it_group)
- if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find_first_of(fragmentLC) == 0))
+ if (groupIsVisible(it_group->second, bOnlyShowHidden) && it_group->first != "" && (fragmentLC == "" || getLowercase(it_group->first).find(fragmentLC) == 0))
groupList.push_back(ArgumentCompletionListElement(it_group->first, getLowercase(it_group->first)));
// now add all shortcuts (in group "")
@@ -112,7 +112,7 @@
// add the shortcuts
for (std::map<std::string, ConsoleCommand*>::const_iterator it_command = it_group->second.begin(); it_command != it_group->second.end(); ++it_command)
- if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find_first_of(fragmentLC) == 0))
+ if (it_command->second->isActive() && it_command->second->hasAccess() && (!it_command->second->isHidden())^bOnlyShowHidden && (fragmentLC == "" || getLowercase(it_command->first).find(fragmentLC) == 0))
groupList.push_back(ArgumentCompletionListElement(it_command->first, getLowercase(it_command->first)));
}
Modified: code/trunk/src/libraries/core/command/CommandEvaluation.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandEvaluation.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/CommandEvaluation.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -130,7 +130,7 @@
*error = CommandExecutor::Success;
if (!this->execCommand_)
- *error = CommandExecutor::Error;
+ *error = CommandExecutor::Inexistent;
else if (!this->execCommand_->isActive())
*error = CommandExecutor::Deactivated;
else if (!this->execCommand_->hasAccess())
@@ -150,7 +150,7 @@
// check if the argument evaluation succeded
if (this->bEvaluatedArguments_)
{
- COUT(6) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedArguments_ << " arguments: " << this->arguments_[0] << ' ' << this->arguments_[1] << ' ' << this->arguments_[2] << ' ' << this->arguments_[3] << ' ' << this->arguments_[4] << std::endl;
+ orxout(verbose, context::commands) << "CE_execute (evaluation): " << this->execCommand_->getName() << " with " << this->numberOfEvaluatedArguments_ << " arguments: " << this->arguments_[0] << ' ' << this->arguments_[1] << ' ' << this->arguments_[2] << ' ' << this->arguments_[3] << ' ' << this->arguments_[4] << endl;
// pass as many arguments to the executor as were evaluated (thus the executor can still use additional default values)
switch (this->numberOfEvaluatedArguments_)
@@ -185,8 +185,8 @@
if (!this->execCommand_)
{
if (bPrintError)
- COUT(1) << "Error: Can't evaluate arguments, no console command assigned." << std::endl;
- return CommandExecutor::Error;
+ orxout(internal_error, context::commands) << "Can't evaluate arguments, no console command assigned." << endl;
+ return CommandExecutor::Inexistent;
}
int error;
@@ -199,7 +199,7 @@
if (!error)
this->bEvaluatedArguments_ = true;
else if (bPrintError)
- COUT(1) << "Error: Can't evaluate arguments, not enough arguments given." << std::endl;
+ orxout(internal_error, context::commands) << "Can't evaluate arguments, not enough arguments given." << endl;
return error;
}
Modified: code/trunk/src/libraries/core/command/CommandExecutor.cc
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/CommandExecutor.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -68,10 +68,12 @@
@param useTcl If true, the command is passed to tcl (see TclBind)
@return Returns the error-code (see @ref CommandExecutorErrorCodes "error codes")
*/
- /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl)
+ /* static */ int CommandExecutor::execute(const std::string& command, bool useTcl, bool printErrors)
{
int error;
CommandExecutor::queryMT(command, &error, useTcl);
+ if (error && printErrors)
+ orxout(user_error) << "Can't execute \"" << command << "\", " << CommandExecutor::getErrorDescription(error) << ". (execute)" << endl;
return error;
}
@@ -84,10 +86,13 @@
*/
/* static */ MultiType CommandExecutor::queryMT(const std::string& command, int* error, bool useTcl)
{
+ MultiType result;
+ int error_internal;
+
if (useTcl)
{
// pass the command to tcl
- return TclBind::eval(command, error);
+ result = TclBind::eval(command, &error_internal);
}
else
{
@@ -107,8 +112,15 @@
}
// query the command and return its return-value
- return evaluation.query(error);
+ result = evaluation.query(&error_internal);
}
+
+ if (error)
+ *error = error_internal;
+ else if (error_internal)
+ orxout(user_error) << "Can't execute \"" << command << "\", " << CommandExecutor::getErrorDescription(error_internal) << ". (query)" << endl;
+
+ return result;
}
/**
@@ -171,6 +183,23 @@
}
/**
+ @brief Returns a description of the error code.
+ @param error The error code
+ */
+ /* static */ std::string CommandExecutor::getErrorDescription(int error)
+ {
+ switch (error)
+ {
+ case CommandExecutor::Inexistent: return "command doesn't exist";
+ case CommandExecutor::Incomplete: return "not enough arguments given";
+ case CommandExecutor::Deactivated: return "command is not active";
+ case CommandExecutor::Denied: return "access denied";
+ case CommandExecutor::Error: return "an error occurred";
+ default: return "";
+ }
+ }
+
+ /**
@brief Gets an evaluated command from the cache.
@param command The command that should be looked up in the cache
@param evaluation Reference to a CommandEvaluation that will be used to return the cached evaluation.
@@ -260,7 +289,7 @@
// check if the alias already exists - print an error and return if it does
if ((tokens.size() == 1 && ConsoleCommand::getCommand(tokens[0])) || (tokens.size() == 2 && ConsoleCommand::getCommand(tokens[0], tokens[1])))
{
- COUT(1) << "Error: A command with name \"" << alias << "\" already exists." << std::endl;
+ orxout(user_error) << "A command with name \"" << alias << "\" already exists." << endl;
return;
}
@@ -270,9 +299,9 @@
else if (tokens.size() == 2)
createConsoleCommand(tokens[0], tokens[1], executor);
else
- COUT(1) << "Error: \"" << alias << "\" is not a valid alias name (must have one or two words)." << std::endl;
+ orxout(user_error) << "\"" << alias << "\" is not a valid alias name (must have one or two words)." << endl;
}
else
- COUT(1) << "Error: \"" << command << "\" is not a valid command (did you mean \"" << evaluation.getCommandSuggestion() << "\"?)." << std::endl;
+ orxout(user_error) << "\"" << command << "\" is not a valid command (did you mean \"" << evaluation.getCommandSuggestion() << "\"?)." << endl;
}
}
Modified: code/trunk/src/libraries/core/command/CommandExecutor.h
===================================================================
--- code/trunk/src/libraries/core/command/CommandExecutor.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/CommandExecutor.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -110,7 +110,7 @@
{
// tolua_end
public:
- static int execute(const std::string& command, bool useTcl = true); // tolua_export
+ static int execute(const std::string& command, bool useTcl = true, bool printErrors = true); // tolua_export
static MultiType queryMT(const std::string& command, int* error = 0, bool useTcl = true);
static std::string query(const std::string& command, int* error = 0, bool useTcl = true); // tolua_export
@@ -118,11 +118,14 @@
static CommandEvaluation evaluate(const std::string& command);
static const int Success = 0; ///< Error code for "success" (or no error)
- static const int Error = 1; ///< Error code if the command doesn't exist
+ static const int Inexistent = 1; ///< Error code if the command doesn't exist
static const int Incomplete = 2; ///< Error code if the command needs more arguments
static const int Deactivated = 3; ///< Error code if the command is not active
static const int Denied = 4; ///< Error code if the command needs a different access level
+ static const int Error = 5; ///< Error code if the command returned an error
+ static std::string getErrorDescription(int error);
+
static MultiType unhide(const std::string& command);
static void alias(const std::string& alias, const std::string& command);
static void _autocomplete(const std::string& group, const std::string& name) {} ///< Pseudo console command used whenever no real command is available. In these cases this command provides auto-completion for console commands and groups.
Modified: code/trunk/src/libraries/core/command/ConsoleCommand.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -171,7 +171,7 @@
{
if (!this->executor_->defaultValueSet(i))
{
- COUT(2) << "Default value " << i << " is missing" << std::endl;
+ orxout(internal_warning, context::commands) << "Default value " << i << " is missing" << endl;
return false;
}
}
@@ -201,7 +201,7 @@
{
if (!executor->defaultValueSet(i))
{
- COUT(2) << "Default value " << i << " is missing" << std::endl;
+ orxout(internal_warning, context::commands) << "Default value " << i << " is missing" << endl;
return false;
}
}
@@ -228,7 +228,7 @@
}
else
{
- COUT(1) << "Error: Couldn't assign new executor to console command \"" << this->baseName_ << "\", headers don't match." << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't assign new executor to console command \"" << this->baseName_ << "\", headers don't match." << endl;
return false;
}
}
@@ -255,7 +255,7 @@
}
else
{
- COUT(1) << "Error: Couldn't assign new functor to console command \"" << this->baseName_ << "\", headers don't match." << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't assign new functor to console command \"" << this->baseName_ << "\", headers don't match." << endl;
return false;
}
}
@@ -306,7 +306,7 @@
if (this->executor_)
this->pushFunction(new Executor(*this->executor_.get()));
else
- COUT(1) << "Error: Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't push copy of executor in console command \"" << this->baseName_ << "\", no executor set." << endl;
}
/**
@@ -366,10 +366,10 @@
return true;
}
else if (object)
- COUT(1) << "Error: Can't assign object to console command \"" << this->baseName_ << "\", no functor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't assign object to console command \"" << this->baseName_ << "\", no functor set." << endl;
}
else if (object)
- COUT(1) << "Error: Can't assign object to console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't assign object to console command \"" << this->baseName_ << "\", no executor set." << endl;
return false;
}
@@ -417,7 +417,7 @@
if (this->executor_)
this->executor_->setDefaultValues(arg1);
else
- COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl;
return *this;
}
@@ -430,7 +430,7 @@
if (this->executor_)
this->executor_->setDefaultValues(arg1, arg2);
else
- COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl;
return *this;
}
@@ -443,7 +443,7 @@
if (this->executor_)
this->executor_->setDefaultValues(arg1, arg2, arg3);
else
- COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl;
return *this;
}
@@ -456,7 +456,7 @@
if (this->executor_)
this->executor_->setDefaultValues(arg1, arg2, arg3, arg4);
else
- COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl;
return *this;
}
@@ -469,7 +469,7 @@
if (this->executor_)
this->executor_->setDefaultValues(arg1, arg2, arg3, arg4, arg5);
else
- COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl;
return *this;
}
@@ -484,7 +484,7 @@
if (this->executor_)
this->executor_->setDefaultValue(index, arg);
else
- COUT(1) << "Error: Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << std::endl;
+ orxout(internal_error, context::commands) << "Can't set default values in console command \"" << this->baseName_ << "\", no executor set." << endl;
return *this;
}
@@ -499,7 +499,7 @@
if (index < 5)
this->argumentCompleter_[index] = completer;
else
- COUT(2) << "Warning: Couldn't add autocompletion-function for index " << index << " in console command \"" << this->baseName_ << "\": index out of bound." << std::endl;
+ orxout(internal_warning, context::commands) << "Couldn't add autocompletion-function for index " << index << " in console command \"" << this->baseName_ << "\": index out of bound." << endl;
return *this;
}
@@ -610,9 +610,9 @@
if (bPrintError)
{
if (group == "")
- COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
else
- COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
}
return 0;
}
@@ -643,9 +643,9 @@
if (bPrintError)
{
if (group == "")
- COUT(1) << "Error: Couldn't find console command with shortcut \"" << name << "\"" << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't find console command with shortcut \"" << name << "\"" << endl;
else
- COUT(1) << "Error: Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << std::endl;
+ orxout(internal_error, context::commands) << "Couldn't find console command with group \"" << group << "\" and name \"" << name << "\"" << endl;
}
return 0;
}
@@ -680,9 +680,9 @@
if (ConsoleCommand::getCommand(group, name) != 0)
{
if (group == "")
- COUT(2) << "Warning: A console command with shortcut \"" << name << "\" already exists." << std::endl;
+ orxout(internal_warning, context::commands) << "A console command with shortcut \"" << name << "\" already exists." << endl;
else
- COUT(2) << "Warning: A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << std::endl;
+ orxout(internal_warning, context::commands) << "A console command with name \"" << name << "\" already exists in group \"" << group << "\"." << endl;
}
else
{
Modified: code/trunk/src/libraries/core/command/ConsoleCommand.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommand.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/ConsoleCommand.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -52,7 +52,7 @@
@code
void myCoutFunction(const std::string& text) // Define a static function
{
- COUT(0) << "Text: " << text << std::endl; // Print the text to the console
+ orxout() << "Text: " << text << endl; // Print the text to the console
}
SetConsoleCommand("cout", &myCoutFunction); // Register the function as command with name "cout"
@@ -124,7 +124,7 @@
@code
void myOtherCoutFunction(const std::string& text) // Define a new static function
{
- COUT(0) << "Uppercase: " << getUppercase(text) << std::endl; // Print the text in uppercase to the console
+ orxout() << "Uppercase: " << getUppercase(text) << endl; // Print the text in uppercase to the console
}
{
Modified: code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/ConsoleCommandCompilation.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -37,7 +37,7 @@
#include <set>
#include <string>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/ExprParser.h"
#include "util/StringUtils.h"
#include "ConsoleCommand.h"
@@ -45,10 +45,19 @@
namespace orxonox
{
-// SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl
SetConsoleCommand("echo", echo);
-// SetConsoleCommand("puts", puts); // disabled because we use the implementation in Tcl
+ SetConsoleCommand("orxout", orxout_level);
+ SetConsoleCommand("orxout_context", orxout_level_context);
+
+ SetConsoleCommand("log" , log );
+ SetConsoleCommand("error" , error ).hide();
+ SetConsoleCommand("warning", warning).hide();
+ SetConsoleCommand("status" , status ).hide();
+ SetConsoleCommand("info" , info ).hide();
+ SetConsoleCommand("debug" , debug ).hide();
+
+// SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl
// SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl
// SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl
// SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files()); // disabled because we use the implementation in Tcl
@@ -56,6 +65,101 @@
SetConsoleCommand("calculate", calculate);
/**
+ @brief Simply returns the arguments.
+ */
+ std::string echo(const std::string& text)
+ {
+ return text;
+ }
+
+ /**
+ @brief Builds a map that maps the levels of all output levels to their ID.
+ */
+ std::map<std::string, OutputLevel> getOutputLevelsMap()
+ {
+ std::map<std::string, OutputLevel> levels;
+
+ levels["message"] = level::message;
+ levels["debug_output"] = level::debug_output;
+ levels["user_error"] = level::user_error;
+ levels["user_warning"] = level::user_warning;
+ levels["user_status"] = level::user_status;
+ levels["user_info"] = level::user_info;
+ levels["internal_error"] = level::internal_error;
+ levels["internal_warning"] = level::internal_warning;
+ levels["internal_status"] = level::internal_status;
+ levels["internal_info"] = level::internal_info;
+ levels["verbose"] = level::verbose;
+ levels["verbose_more"] = level::verbose_more;
+ levels["verbose_ultra"] = level::verbose_ultra;
+
+ return levels;
+ }
+
+ /**
+ @brief Prints text to the console.
+ @param level_name The name of the output level
+ */
+ void orxout_level(const std::string& level_name, const std::string& text)
+ {
+ static std::map<std::string, OutputLevel> levels = getOutputLevelsMap();
+
+ OutputLevel level = level::debug_output;
+ std::map<std::string, OutputLevel>::iterator it = levels.find(level_name);
+ if (it != levels.end())
+ level = it->second;
+ else
+ orxout(internal_warning) << "'" << level_name << "' is not a valid output level" << endl;
+
+ orxout(level) << text << endl;
+ }
+
+ /**
+ @brief Prints text to the console.
+ @param level_name The name of the output level
+ @param context_name The name of the output context
+ */
+ void orxout_level_context(const std::string& level_name, const std::string& context_name, const std::string& text)
+ {
+ static std::map<std::string, OutputLevel> levels = getOutputLevelsMap();
+
+ OutputLevel level = level::debug_output;
+ std::map<std::string, OutputLevel>::iterator it = levels.find(level_name);
+ if (it != levels.end())
+ level = it->second;
+ else
+ orxout(internal_warning) << "'" << level_name << "' is not a valid output level" << endl;
+
+ OutputContextContainer context = registerContext(context_name);
+
+ orxout(level, context) << text << endl;
+ }
+
+ /// @brief Prints text to the console and the logfile.
+ void log(const std::string& text)
+ { orxout() << text << endl; }
+
+ /// @brief Prints output with error level.
+ void error(const std::string& text)
+ { orxout(user_error) << text << endl; }
+
+ /// @brief Prints output with warning level.
+ void warning(const std::string& text)
+ { orxout(user_warning) << text << endl; }
+
+ /// @brief Prints output with status level.
+ void status(const std::string& text)
+ { orxout(user_status) << text << endl; }
+
+ /// @brief Prints output with info level.
+ void info(const std::string& text)
+ { orxout(user_info) << text << endl; }
+
+ /// @brief Prints debug output with verbose level.
+ void debug(const std::string& text)
+ { orxout(verbose, context::tcl) << text << endl; }
+
+ /**
@brief Reads the content of a file and executes the commands in it line by line.
*/
void source(const std::string& filename)
@@ -65,7 +169,7 @@
std::set<std::string>::const_iterator it = executingFiles.find(filename);
if (it != executingFiles.end())
{
- COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl;
+ orxout(user_error) << "Recurring source command in \"" << filename << "\". Stopped execution." << endl;
return;
}
@@ -75,7 +179,7 @@
if (!file.is_open())
{
- COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl;
+ orxout(user_error) << "Couldn't open file \"" << filename << "\"." << endl;
return;
}
@@ -94,29 +198,6 @@
}
/**
- @brief Simply returns the arguments.
- */
- std::string echo(const std::string& text)
- {
- return text;
- }
-
- /**
- @brief Writes text to the console, depending on the first argument with or without a line-break after it.
- */
- void puts(bool newline, const std::string& text)
- {
- if (newline)
- {
- COUT(0) << stripEnclosingBraces(text) << std::endl;
- }
- else
- {
- COUT(0) << stripEnclosingBraces(text);
- }
- }
-
- /**
@brief Writes text to a file.
*/
void write(const std::string& filename, const std::string& text)
@@ -126,11 +207,11 @@
if (!file.is_open())
{
- COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl;
+ orxout(user_error) << "Couldn't write to file \"" << filename << "\"." << endl;
return;
}
- file << text << std::endl;
+ file << text << endl;
file.close();
}
@@ -144,11 +225,11 @@
if (!file.is_open())
{
- COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl;
+ orxout(user_error) << "Couldn't append to file \"" << filename << "\"." << endl;
return;
}
- file << text << std::endl;
+ file << text << endl;
file.close();
}
@@ -162,7 +243,7 @@
if (!file.is_open())
{
- COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl;
+ orxout(user_error) << "Couldn't read from file \"" << filename << "\"." << endl;
return "";
}
@@ -191,17 +272,17 @@
{
if (expr.getResult() == 42.0)
{
- COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
+ orxout(user_info) << "Greetings from the restaurant at the end of the universe." << endl;
}
if (!expr.getRemains().empty())
{
- COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
+ orxout(user_warning) << "Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << endl;
}
return static_cast<float>(expr.getResult());
}
else
{
- COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
+ orxout(user_error) << "Cannot calculate expression: Parse error." << endl;
return 0;
}
}
Modified: code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h
===================================================================
--- code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/ConsoleCommandCompilation.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -41,8 +41,17 @@
{
_CoreExport void source(const std::string& filename);
_CoreExport std::string echo(const std::string& text);
- _CoreExport void puts(bool newline, const std::string& test);
+ _CoreExport void orxout_level(const std::string& level_name, const std::string& text);
+ _CoreExport void orxout_level_context(const std::string& level_name, const std::string& context_name, const std::string& text);
+
+ _CoreExport void log(const std::string& text);
+ _CoreExport void error(const std::string& text);
+ _CoreExport void warning(const std::string& text);
+ _CoreExport void status(const std::string& text);
+ _CoreExport void info(const std::string& text);
+ _CoreExport void debug(const std::string& text);
+
_CoreExport void write(const std::string& filename, const std::string& text);
_CoreExport void append(const std::string& filename, const std::string& text);
_CoreExport std::string read(const std::string& filename);
Modified: code/trunk/src/libraries/core/command/Executor.cc
===================================================================
--- code/trunk/src/libraries/core/command/Executor.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/Executor.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -37,7 +37,7 @@
#include <algorithm>
#include "util/Convert.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/StringUtils.h"
#include "util/SubString.h"
#include "CommandExecutor.h"
@@ -103,11 +103,11 @@
if (error && *error)
{
if (bPrintError)
- COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough arguments or default values given (input: " << arguments.join() << ")." << std::endl;
+ 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;
}
- COUT(5) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << argCount << " arguments: " << arg[0] << " / " << arg[1] << " / " << arg[2] << " / " << arg[3] << " / " << arg[4] << std::endl;
+ orxout(verbose, context::misc::executor) << "Executor::parse: \"" << arguments.join(delimiter) << "\" -> " << argCount << " arguments: " << arg[0] << " / " << arg[1] << " / " << arg[2] << " / " << arg[3] << " / " << arg[4] << endl;
// execute the function with the evaluated arguments (the default values of the executor are also included in these arguments)
switch (argCount)
Modified: code/trunk/src/libraries/core/command/Executor.h
===================================================================
--- code/trunk/src/libraries/core/command/Executor.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/Executor.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -56,7 +56,7 @@
@code
void myFunction(int a, int b) // declare a static function
{
- COUT(0) << "The sum is " << (a + b) << std::endl; // print the sum of a and b to the console
+ orxout() << "The sum is " << (a + b) << endl; // print the sum of a and b to the console
}
FunctorPtr functor = createFunctor(&myFunction); // create a functor that wraps the function-pointer
Modified: code/trunk/src/libraries/core/command/Functor.h
===================================================================
--- code/trunk/src/libraries/core/command/Functor.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/Functor.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -117,7 +117,7 @@
#include <typeinfo>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/MultiType.h"
#include "core/OrxonoxClass.h"
#include "FunctorPtr.h"
@@ -255,7 +255,7 @@
return (*this)(this->object_, param1, param2, param3, param4, param5);
else
{
- COUT(1) << "Error: Can't execute FunctorMember, no object set." << std::endl;
+ orxout(internal_error) << "Can't execute FunctorMember, no object set." << endl;
return MT_Type::Null;
}
}
@@ -338,7 +338,7 @@
// see Functor::setRawObjectPointer()
inline void setRawObjectPointer(void*)
- { COUT(2) << "Warning: Can't assign an object pointer to a static functor" << std::endl; }
+ { orxout(internal_warning) << "Can't assign an object pointer to a static functor" << endl; }
// see Functor::getRawObjectPointer()
inline void* getRawObjectPointer() const
{ return 0; }
Modified: code/trunk/src/libraries/core/command/IOConsolePOSIX.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsolePOSIX.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/IOConsolePOSIX.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -36,6 +36,7 @@
#include "util/Clock.h"
#include "util/Math.h"
+#include "util/output/ConsoleWriter.h"
#include "core/Game.h"
#include "core/input/InputBuffer.h"
@@ -54,7 +55,7 @@
}
IOConsole::IOConsole()
- : shell_(new Shell("IOConsole", false))
+ : shell_(new Shell("Console", false))
, buffer_(shell_->getInputBuffer())
, cout_(std::cout.rdbuf())
, promptString_("orxonox # ")
@@ -73,7 +74,7 @@
this->lastTerminalHeight_ = this->terminalHeight_;
// Disable standard std::cout logging
- OutputHandler::getInstance().disableCout();
+ ConsoleWriter::getInstance().disable();
// Redirect std::cout to an ostringstream
// (Other part is in the initialiser list)
std::cout.rdbuf(this->origCout_.rdbuf());
@@ -87,7 +88,7 @@
// Process output written to std::cout in the meantime
std::cout.flush();
if (!this->origCout_.str().empty())
- this->shell_->addOutput(this->origCout_.str(), Shell::None);
+ this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
// Erase input and status lines
this->cout_ << "\033[1G\033[J";
// Move cursor to the bottom
@@ -101,7 +102,7 @@
// Restore this->cout_ redirection
std::cout.rdbuf(this->cout_.rdbuf());
// Enable standard std::cout logging again
- OutputHandler::getInstance().enableCout();
+ ConsoleWriter::getInstance().enable();
}
void IOConsole::preUpdate(const Clock& time)
@@ -228,7 +229,7 @@
std::cout.flush();
if (!this->origCout_.str().empty())
{
- this->shell_->addOutput(this->origCout_.str(), Shell::None);
+ this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
this->origCout_.str("");
}
}
@@ -238,16 +239,27 @@
// Colour line
switch (type)
{
- case Shell::Error: this->cout_ << "\033[91m"; break;
- case Shell::Warning: this->cout_ << "\033[93m"; break;
- case Shell::Info: this->cout_ << "\033[90m"; break;
- case Shell::Debug: this->cout_ << "\033[90m"; break;
- case Shell::Verbose: this->cout_ << "\033[90m"; break;
- case Shell::Ultra: this->cout_ << "\033[90m"; break;
- case Shell::Command: this->cout_ << "\033[36m"; break;
- case Shell::Hint: this->cout_ << "\033[33m"; break;
- case Shell::TDebug: this->cout_ << "\033[95m"; break;
- default: break;
+ case Shell::Message:
+ case Shell::DebugOutput: this->cout_ << "\033[0m"; break;
+
+ case Shell::UserError: this->cout_ << "\033[91m"; break;
+ case Shell::UserWarning: this->cout_ << "\033[93m"; break;
+ case Shell::UserStatus: this->cout_ << "\033[92m"; break;
+ case Shell::UserInfo: this->cout_ << "\033[96m"; break;
+
+ case Shell::InternalError: this->cout_ << "\033[31m"; break;
+ case Shell::InternalWarning: this->cout_ << "\033[33m"; break;
+ case Shell::InternalStatus: this->cout_ << "\033[32m"; break;
+ case Shell::InternalInfo: this->cout_ << "\033[36m"; break;
+
+ case Shell::Verbose: this->cout_ << "\033[94m"; break;
+ case Shell::VerboseMore: this->cout_ << "\033[34m"; break;
+ case Shell::VerboseUltra: this->cout_ << "\033[34m"; break;
+
+ case Shell::Command: this->cout_ << "\033[95m"; break;
+ case Shell::Hint: this->cout_ << "\033[35m"; break;
+
+ default: this->cout_ << "\033[37m"; break;
}
// Print output line
@@ -370,7 +382,7 @@
//! Called if a command is about to be executed
void IOConsole::executed()
{
- this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
+ this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command);
}
//! Called if the console gets closed
@@ -379,20 +391,6 @@
// Exit is not an option, just do nothing (Shell doesn't really exit too)
}
- //! Called if only the last output-line has changed
- void IOConsole::onlyLastLineChanged()
- {
- // Save cursor position and move it to the beginning of the first output line
- this->cout_ << "\033[s\033[1A\033[1G";
- // Erase the line
- this->cout_ << "\033[K";
- // Reprint the last output line
- this->printOutputLine(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second);
- // Restore cursor
- this->cout_ << "\033[u";
- this->cout_.flush();
- }
-
//! Called if a new output-line was added
void IOConsole::lineAdded()
{
Modified: code/trunk/src/libraries/core/command/IOConsolePOSIX.h
===================================================================
--- code/trunk/src/libraries/core/command/IOConsolePOSIX.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/IOConsolePOSIX.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -65,7 +65,6 @@
// Methods from ShellListener
void linesChanged();
- void onlyLastLineChanged();
void lineAdded();
void inputChanged();
void cursorChanged();
Modified: code/trunk/src/libraries/core/command/IOConsoleWindows.cc
===================================================================
--- code/trunk/src/libraries/core/command/IOConsoleWindows.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/IOConsoleWindows.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,6 +33,7 @@
#include "util/Clock.h"
#include "util/Math.h"
+#include "util/output/ConsoleWriter.h"
#include "core/Game.h"
#include "core/input/InputBuffer.h"
@@ -42,7 +43,7 @@
//! Redirects std::cout, creates the corresponding Shell and changes the terminal mode
IOConsole::IOConsole()
- : shell_(new Shell("IOConsole", false))
+ : shell_(new Shell("Console", false))
, buffer_(shell_->getInputBuffer())
, cout_(std::cout.rdbuf())
, promptString_("orxonox # ")
@@ -51,7 +52,7 @@
, lastOutputLineHeight_(0)
{
// Disable standard this->cout_ logging
- OutputHandler::getInstance().disableCout();
+ ConsoleWriter::getInstance().disable();
// Redirect std::cout to an ostringstream
// (Other part is in the initialiser list)
std::cout.rdbuf(this->origCout_.rdbuf());
@@ -94,7 +95,7 @@
// Process output written to std::cout in the meantime
std::cout.flush();
if (!this->origCout_.str().empty())
- this->shell_->addOutput(this->origCout_.str(), Shell::None);
+ this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
this->shell_->unregisterListener(this);
@@ -107,7 +108,7 @@
// Restore this->cout_ redirection
std::cout.rdbuf(this->cout_.rdbuf());
// Enable standard this->cout_ logging again
- OutputHandler::getInstance().enableCout();
+ ConsoleWriter::getInstance().enable();
resetTerminalMode();
this->shell_->destroy();
@@ -187,7 +188,7 @@
std::cout.flush();
if (!this->origCout_.str().empty())
{
- this->shell_->addOutput(this->origCout_.str(), Shell::None);
+ this->shell_->addOutput(this->origCout_.str(), Shell::Cout);
this->origCout_.str("");
}
}
@@ -199,16 +200,27 @@
WORD colour = 0;
switch (type)
{
- case Shell::Error: colour = FOREGROUND_INTENSITY | FOREGROUND_RED; break;
- case Shell::Warning: colour = FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED; break;
- case Shell::Info:
- case Shell::Debug:
- case Shell::Verbose:
- case Shell::Ultra: colour = FOREGROUND_INTENSITY ; break;
- case Shell::Command: colour = FOREGROUND_GREEN | FOREGROUND_BLUE; break;
- case Shell::Hint: colour = FOREGROUND_GREEN | FOREGROUND_RED ; break;
- case Shell::TDebug: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE; break;
- default: colour = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break;
+ case Shell::Message:
+ case Shell::DebugOutput: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+
+ case Shell::UserError: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | 0 ; break;
+ case Shell::UserWarning: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break;
+ case Shell::UserStatus: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | 0 ; break;
+ case Shell::UserInfo: colour = FOREGROUND_INTENSITY | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+
+ case Shell::InternalError: colour = 0 | FOREGROUND_RED | 0 | 0 ; break;
+ case Shell::InternalWarning: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | 0 ; break;
+ case Shell::InternalStatus: colour = 0 | 0 | FOREGROUND_GREEN | 0 ; break;
+ case Shell::InternalInfo: colour = 0 | 0 | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
+
+ case Shell::Verbose: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;
+ case Shell::VerboseMore: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;
+ case Shell::VerboseUltra: colour = FOREGROUND_INTENSITY | 0 | 0 | FOREGROUND_BLUE; break;
+
+ case Shell::Command: colour = FOREGROUND_INTENSITY | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break;
+ case Shell::Hint: colour = 0 | FOREGROUND_RED | 0 | FOREGROUND_BLUE; break;
+
+ default: colour = 0 | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; break;
}
// Print output line
@@ -237,7 +249,7 @@
|| !GetConsoleMode(this->stdInHandle_, &this->originalTerminalSettings_)
|| !SetConsoleMode(this->stdInHandle_, 0))
{
- COUT(1) << "Error: Could not set Windows console settings" << std::endl;
+ orxout(user_error) << "Could not set Windows console settings" << endl;
return;
}
FlushConsoleInputBuffer(this->stdInHandle_);
@@ -317,7 +329,7 @@
//! Called if a command is about to be executed
void IOConsole::executed()
{
- this->shell_->addOutput(this->promptString_ + this->shell_->getInput() + '\n', Shell::Command);
+ this->shell_->addOutput(this->promptString_ + this->shell_->getInput(), Shell::Command);
}
//! Called if the console gets closed
@@ -376,20 +388,6 @@
SetConsoleCursorPosition(stdOutHandle_, pos);
}
- //! Called if only the last output-line has changed
- void IOConsole::onlyLastLineChanged()
- {
- int newLineHeight = 1 + this->shell_->getNewestLineIterator()->first.size() / this->terminalWidth_;
- // Compute the number of new lines needed
- int newLines = newLineHeight - this->lastOutputLineHeight_;
- this->lastOutputLineHeight_ = newLineHeight;
- // Scroll console if necessary
- if (newLines > 0) // newLines < 0 is assumed impossible
- this->createNewOutputLines(newLines);
- Shell::LineList::const_iterator it = this->shell_->getNewestLineIterator();
- this->printOutputLine(it->first, it->second, makeCOORD(0, this->inputLineRow_ - newLineHeight));
- }
-
//! Called if a new output line was added
void IOConsole::lineAdded()
{
Modified: code/trunk/src/libraries/core/command/IOConsoleWindows.h
===================================================================
--- code/trunk/src/libraries/core/command/IOConsoleWindows.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/IOConsoleWindows.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -67,7 +67,6 @@
// Methods from ShellListener
void linesChanged();
- void onlyLastLineChanged();
void lineAdded();
void inputChanged();
void cursorChanged();
Modified: code/trunk/src/libraries/core/command/IRC.cc
===================================================================
--- code/trunk/src/libraries/core/command/IRC.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/IRC.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -84,7 +84,7 @@
this->interpreter_->def("::orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
}
catch (Tcl::tcl_error const &e)
- { COUT(1) << "Tcl (IRC) error: " << e.what(); }
+ { orxout(user_error, context::tcl) << "Tcl (IRC) error: " << e.what() << endl; }
this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
@@ -99,7 +99,7 @@
if (!IRC::getInstance().interpreter_)
{
IRC::getInstance().initialize();
- COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;
+ orxout(user_error) << "IRC client wasn't yet initialized, please try again." << endl;
return false;
}
@@ -109,7 +109,7 @@
return true;
}
catch (Tcl::tcl_error const &e)
- { COUT(1) << "Tcl (IRC) error: " << e.what(); }
+ { orxout(user_error, context::tcl) << "Tcl (IRC) error: " << e.what() << endl; }
return false;
}
@@ -138,24 +138,24 @@
/// Tcl-callback: Prints a message that was received from the current IRC channel to the console.
void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
{
- COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+ orxout(message) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << endl;
}
/// Tcl-callback: Prints a private message that was received from a user to the console.
void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args)
{
- COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+ orxout(message) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << endl;
}
/// Tcl-callback: Prints an action-message (usually /me ...) that was received from the current IRC channel to the console.
void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
{
- COUT(0) << "IRC> * " << nick.get() << ' ' << stripEnclosingBraces(args.get()) << std::endl;
+ orxout(message) << "IRC> * " << nick.get() << ' ' << stripEnclosingBraces(args.get()) << endl;
}
/// Tcl-callback: Prints all kinds of information that were received from the IRC server or channel (connection info, join, part, modes, ...) to the console.
void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
{
- COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;
+ orxout(message) << "IRC> --> " << stripEnclosingBraces(args.get()) << endl;
}
}
Modified: code/trunk/src/libraries/core/command/Shell.cc
===================================================================
--- code/trunk/src/libraries/core/command/Shell.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/Shell.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -34,45 +34,45 @@
#include "Shell.h"
#include "util/Math.h"
-#include "util/OutputHandler.h"
#include "util/StringUtils.h"
#include "util/SubString.h"
+#include "util/output/OutputManager.h"
+#include "util/output/MemoryWriter.h"
#include "core/CoreIncludes.h"
#include "core/ConfigFileManager.h"
#include "core/ConfigValueIncludes.h"
#include "core/PathConfig.h"
#include "core/input/InputBuffer.h"
#include "CommandExecutor.h"
-#include "ConsoleCommand.h"
namespace orxonox
{
- SetConsoleCommand("log", OutputHandler::log );
- SetConsoleCommand("error", OutputHandler::error ).hide();
- SetConsoleCommand("warning", OutputHandler::warning).hide();
- SetConsoleCommand("info", OutputHandler::info ).hide();
- SetConsoleCommand("debug", OutputHandler::debug ).hide();
-
unsigned int Shell::cacheSize_s;
+ namespace DefaultLogLevel
+ {
+ const OutputLevel Dev = level::internal_warning;
+ const OutputLevel User = level::user_info;
+ }
+
/**
- @brief Constructor: Initializes the values and registers itself at OutputHandler.
+ @brief Constructor: Initializes the values.
@param consoleName The name of the shell - used to define the name of the soft-debug-level config-value
@param bScrollable If true, the user is allowed to scroll through the output-lines
*/
Shell::Shell(const std::string& consoleName, bool bScrollable)
- : OutputListener(consoleName)
+ : BaseWriter(consoleName, false)
, inputBuffer_(new InputBuffer())
- , consoleName_(consoleName)
, bScrollable_(bScrollable)
{
RegisterRootObject(Shell);
+ OutputManager::getInstance().registerListener(this);
+
this->scrollPosition_ = 0;
this->maxHistoryLength_ = 100;
this->historyPosition_ = 0;
this->historyOffset_ = 0;
- this->bFinishedLastLine_ = true;
this->clearOutput();
this->configureInputBuffer();
@@ -80,40 +80,24 @@
// Specify file for the command history
ConfigFileManager::getInstance().setFilename(ConfigFileType::CommandHistory, "commandHistory.ini");
- // Use a stringstream object to buffer the output
- this->outputStream_ = &this->outputBuffer_;
+ // Choose the default level according to the path Orxonox was started (build directory or not)
+ OutputLevel defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+ this->setLevelMax(defaultDebugLevel);
this->setConfigValues();
// Get the previous output and add it to the Shell
- OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin();
- for (;it != OutputHandler::getInstance().getOutput().end(); ++it)
- {
- if (it->first <= debugLevel_)
- {
- this->outputBuffer_ << it->second;
- this->outputChanged(it->first);
- }
- }
-
- // Register the shell as output listener
- OutputHandler::getInstance().registerOutputListener(this);
- OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
+ MemoryWriter::getInstance().resendOutput(this);
}
/**
- @brief Destructor: Unregisters the shell from OutputHandler.
+ @brief Destructor
*/
Shell::~Shell()
{
- OutputHandler::getInstance().unregisterOutputListener(this);
this->inputBuffer_->destroy();
- }
- namespace DefaultLogLevel
- {
- const OutputLevel::Value Dev = OutputLevel::Info;
- const OutputLevel::Value User = OutputLevel::Error;
+ OutputManager::getInstance().unregisterListener(this);
}
/**
@@ -128,11 +112,24 @@
setConfigValueGeneric(this, &commandHistory_, ConfigFileType::CommandHistory, "Shell", "commandHistory_", std::vector<std::string>());
SetConfigValue(cacheSize_s, 32);
- // Choose the default level according to the path Orxonox was started (build directory or not)
- OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
- SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel)
- .description("The maximum level of debug output shown in the " + consoleName_);
- OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
+ SetConfigValueExternal(this->configurableMaxLevel_,
+ this->getConfigurableSectionName(),
+ this->getConfigurableMaxLevelName(),
+ this->configurableMaxLevel_)
+ .description("The maximum level of output shown in the " + this->getName())
+ .callback(static_cast<BaseWriter*>(this), &BaseWriter::changedConfigurableLevel);
+ SetConfigValueExternal(this->configurableAdditionalContextsMaxLevel_,
+ this->getConfigurableSectionName(),
+ this->getConfigurableAdditionalContextsMaxLevelName(),
+ this->configurableAdditionalContextsMaxLevel_)
+ .description("The maximum level of output shown in the " + this->getName() + " for additional contexts")
+ .callback(static_cast<BaseWriter*>(this), &BaseWriter::changedConfigurableAdditionalContextsLevel);
+ SetConfigValueExternal(this->configurableAdditionalContexts_,
+ this->getConfigurableSectionName(),
+ this->getConfigurableAdditionalContextsName(),
+ this->configurableAdditionalContexts_)
+ .description("Additional output contexts shown in the " + this->getName())
+ .callback(static_cast<BaseWriter*>(this), &BaseWriter::changedConfigurableAdditionalContexts);
}
/**
@@ -167,12 +164,12 @@
bool isNormal = (value == PathConfig::buildDirectoryRun());
if (isNormal)
{
- ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update);
+ ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), update);
}
else
{
- OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
- ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level);
+ OutputLevel level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
+ ModifyConfigValueExternal(this->configurableMaxLevel_, this->getConfigurableMaxLevelName(), tset, level);
}
}
@@ -251,15 +248,36 @@
}
/**
- @brief Sends output to the internal output buffer.
+ @brief Adds multiple lines to the internal output buffer.
*/
void Shell::addOutput(const std::string& text, LineType type)
{
- this->outputBuffer_ << text;
- this->outputChanged(type);
+ std::vector<std::string> lines;
+ vectorize(text, '\n', &lines);
+
+ for (size_t i = 0; i < lines.size(); ++i)
+ this->addLine(lines[i], type);
}
/**
+ @brief Adds a line to the internal output buffer.
+ */
+ void Shell::addLine(const std::string& line, LineType type)
+ {
+ // yes it was - push the new line to the list
+ this->outputLines_.push_front(std::make_pair(line, static_cast<LineType>(type)));
+
+ // adjust the scroll position if needed
+ if (this->scrollPosition_)
+ this->scrollPosition_++;
+ else
+ this->scrollIterator_ = this->outputLines_.begin();
+
+ if (!this->scrollPosition_)
+ this->updateListeners<&ShellListener::lineAdded>();
+ }
+
+ /**
@brief Clears the list of output-lines.
*/
void Shell::clearOutput()
@@ -268,12 +286,19 @@
this->scrollIterator_ = this->outputLines_.begin();
this->scrollPosition_ = 0;
- this->bFinishedLastLine_ = true;
this->updateListeners<&ShellListener::linesChanged>();
}
/**
+ @brief Inherited from BaseWriter (LogListener), called if a new line of output was sent.
+ */
+ void Shell::printLine(const std::string& line, OutputLevel level)
+ {
+ this->addLine(line, static_cast<LineType>(level));
+ }
+
+ /**
@brief Returns an iterator to the newest line of output (except if the user is currently scrolling through the output).
*/
Shell::LineList::const_iterator Shell::getNewestLineIterator() const
@@ -322,61 +347,6 @@
}
/**
- @brief Called by OutputHandler or internally whenever output was sent to the output buffer. Reads from the buffer and writes the new output-lines to the list.
- */
- void Shell::outputChanged(int lineType)
- {
- bool newline = false;
- do
- {
- // get the first line from the buffer
- std::string output;
- std::getline(this->outputBuffer_, output);
-
- // check the state of the buffer
- bool eof = this->outputBuffer_.eof();
- bool fail = this->outputBuffer_.fail();
- if (eof)
- this->outputBuffer_.flush(); // check if more output was received in the meantime
- if (eof || fail)
- this->outputBuffer_.clear(); // clear the error flags
-
- // the line is terminated with a line-break if neither an error occurred nor the end of the file was reached
- newline = (!eof && !fail);
-
- // no output retrieved - break the loop
- if (!newline && output.empty())
- break;
-
- // check if the last line was terminated with a line-break
- if (this->bFinishedLastLine_)
- {
- // yes it was - push the new line to the list
- this->outputLines_.push_front(std::make_pair(output, static_cast<LineType>(lineType)));
-
- // adjust the scroll position if needed
- if (this->scrollPosition_)
- this->scrollPosition_++;
- else
- this->scrollIterator_ = this->outputLines_.begin();
-
- if (!this->scrollPosition_)
- this->updateListeners<&ShellListener::lineAdded>();
- }
- else
- {
- // no it wasn't - add the new output to the last line
- this->outputLines_.front().first += output;
- this->updateListeners<&ShellListener::onlyLastLineChanged>();
- }
-
- // remember if the last line was terminated with a line-break
- this->bFinishedLastLine_ = newline;
-
- } while (newline); // loop as long as more lines are in the buffer
- }
-
- /**
@brief Clears the text in the input buffer.
*/
void Shell::clearInput()
@@ -408,21 +378,9 @@
int error;
const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &error);
if (error)
- {
- switch (error)
- {
- case CommandExecutor::Error: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command doesn't exist. (S)" << std::endl; break;
- case CommandExecutor::Incomplete: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", not enough arguments given. (S)" << std::endl; break;
- case CommandExecutor::Deactivated: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", command is not active. (S)" << std::endl; break;
- case CommandExecutor::Denied: this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\", access denied. (S)" << std::endl; break;
- }
- this->outputChanged(Error);
- }
+ this->addOutput("Error: Can't execute \"" + this->inputBuffer_->get() + "\", " + CommandExecutor::getErrorDescription(error) + ". (Shell)", UserError);
else if (result != "")
- {
- this->outputBuffer_ << result << std::endl;
- this->outputChanged(Command);
- }
+ this->addOutput(result, Result);
this->clearInput();
}
@@ -431,8 +389,7 @@
void Shell::hintAndComplete()
{
this->inputBuffer_->set(CommandExecutor::evaluate(this->inputBuffer_->get()).complete());
- this->outputBuffer_ << CommandExecutor::evaluate(this->inputBuffer_->get()).hint() << std::endl;
- this->outputChanged(Hint);
+ this->addOutput(CommandExecutor::evaluate(this->inputBuffer_->get()).hint(), Hint);
this->inputChanged();
}
Modified: code/trunk/src/libraries/core/command/Shell.h
===================================================================
--- code/trunk/src/libraries/core/command/Shell.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/Shell.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -47,7 +47,7 @@
#include <string>
#include <vector>
-#include "util/OutputHandler.h"
+#include "util/output/BaseWriter.h"
#include "core/Core.h"
#include "core/OrxonoxClass.h"
@@ -65,7 +65,6 @@
private:
virtual void linesChanged() {} ///< Called if all output-lines have changed
- virtual void onlyLastLineChanged() {} ///< Called if only the last output-line has changed
virtual void lineAdded() {} ///< Called if a new line was added to the output
virtual void inputChanged() {} ///< Called if the input has changed
virtual void cursorChanged() {} ///< Called if the cursor in the input line has changed
@@ -77,29 +76,36 @@
/**
@brief The Shell is the logical component of the console that displays output to the user and allows him to enter commands.
- The Shell gathers output sent from OutputHandler by inheriting from OutputListener.
+ The Shell gathers output sent from OutputManager by inheriting from BaseWriter.
The output-lines are stored in the shell, so they can be displayed in a graphical
console. Additionally the Shell has an InputBuffer which is needed by the user to
enter commands.
Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole.
*/
- class _CoreExport Shell : public OutputListener, public DevModeListener
+ class _CoreExport Shell : public BaseWriter, public DevModeListener
{
public:
/// Defines the type of a line of text in the Shell - some types depend on the output level, others are of internal use.
enum LineType
{
- TDebug = OutputLevel::TDebug,
- None = OutputLevel::None,
- Warning = OutputLevel::Warning,
- Error = OutputLevel::Error,
- Info = OutputLevel::Info,
- Debug = OutputLevel::Debug,
- Verbose = OutputLevel::Verbose,
- Ultra = OutputLevel::Ultra,
+ DebugOutput = debug_output,
+ Message = message,
+ UserError = user_error,
+ UserWarning = user_warning,
+ UserStatus = user_status,
+ UserInfo = user_info,
+ InternalError = internal_error,
+ InternalWarning = internal_warning,
+ InternalStatus = internal_status,
+ InternalInfo = internal_info,
+ Verbose = verbose,
+ VerboseMore = verbose_more,
+ VerboseUltra = verbose_ultra,
+ Cout,
Input,
Command,
+ Result,
Hint
};
@@ -126,7 +132,8 @@
LineList::const_iterator getNewestLineIterator() const;
LineList::const_iterator getEndIterator() const;
- void addOutput(const std::string& text, LineType type = None);
+ void addOutput(const std::string& text, LineType type = DebugOutput);
+ void addLine(const std::string& line, LineType type = DebugOutput);
void clearOutput();
/// Returns the number of output-lines that are displayed in the shell.
@@ -149,8 +156,8 @@
void addToHistory(const std::string& command);
const std::string& getFromHistory() const;
void clearInput();
- // OutputListener
- void outputChanged(int level);
+ // BaseWriter
+ virtual void printLine(const std::string& line, OutputLevel level);
void configureInputBuffer();
@@ -182,21 +189,16 @@
std::list<ShellListener*> listeners_; ///< The registered shell listeners
InputBuffer* inputBuffer_; ///< The input buffer that is needed by the user to enter text
- std::stringstream outputBuffer_; ///< The output buffer that is used to retrieve lines of output from OutputListener
- bool bFinishedLastLine_; ///< Stores if the most recent output-line was terminated with a line-break or if more output is expected for this line
LineList outputLines_; ///< A list of all output-lines that were displayed in the shell so far
LineList::const_iterator scrollIterator_; ///< An iterator to an entry of the list of output-lines, changes if the user scrolls through the output in the shell
unsigned int scrollPosition_; ///< The number of the line that is currently being referenced by scrollIterator_
unsigned int historyPosition_; ///< If the user scrolls through the history of entered commands (stored in commandHistory_), this contains the currently viewed history entry
-
- const std::string consoleName_; ///< The name of this shell - used to define the name of the soft-debug-level config-value
const bool bScrollable_; ///< If true, the user can scroll through the output-lines
// Config values
unsigned int maxHistoryLength_; ///< The maximum number of saved commands
unsigned int historyOffset_; ///< The command history is a circular buffer, this variable defines the current write-offset
std::vector<std::string> commandHistory_; ///< The history of commands that were entered by the user
- int debugLevel_; //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
static unsigned int cacheSize_s; ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
};
}
Modified: code/trunk/src/libraries/core/command/TclBind.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclBind.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/TclBind.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,7 +33,7 @@
#include <cpptcl/cpptcl.h>
#include "SpecialConfig.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/StringUtils.h"
#include "core/PathConfig.h"
@@ -105,7 +105,7 @@
this->interpreter_->eval("rename exit ::tcl::exit; proc exit {} { execute exit }");
}
catch (Tcl::tcl_error const &e)
- { COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; }
+ { orxout(internal_error, context::tcl) << "Tcl error while creating Tcl-interpreter: " << e.what() << endl; }
}
}
@@ -128,7 +128,10 @@
interpreter->eval("source \"" + TclBind::getInstance().tclDataPath_ + "/init.tcl\"");
}
catch (Tcl::tcl_error const &e)
- { COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl; COUT(1) << "Error: Tcl isn't properly initialized. Orxonox might possibly not work like that." << std::endl; }
+ {
+ orxout(internal_error, context::tcl) << "Tcl error while creating Tcl-interpreter: " << e.what() << endl;
+ orxout(user_error, context::tcl) << "Tcl isn't properly initialized. Orxonox might possibly not work like that." << endl;
+ }
return interpreter;
}
@@ -153,7 +156,7 @@
*/
std::string TclBind::tcl_query(Tcl::object const &args)
{
- COUT(4) << "Tcl_query: " << args.get() << std::endl;
+ orxout(verbose, context::commands) << "Tcl_query: " << args.get() << endl;
return TclBind::tcl_helper(args, true);
}
@@ -162,7 +165,7 @@
*/
void TclBind::tcl_execute(Tcl::object const &args)
{
- COUT(4) << "Tcl_execute: " << args.get() << std::endl;
+ orxout(verbose, context::commands) << "Tcl_execute: " << args.get() << endl;
TclBind::tcl_helper(args, false);
}
@@ -183,17 +186,13 @@
else
error = evaluation.execute();
- switch (error)
+ if (error)
{
- case CommandExecutor::Error: COUT(1) << "Error: Can't execute command \"" << command << "\", command doesn't exist. (B)" << std::endl; break;
- case CommandExecutor::Incomplete: COUT(1) << "Error: Can't execute command \"" << command << "\", not enough arguments given. (B)" << std::endl; break;
- case CommandExecutor::Deactivated: COUT(1) << "Error: Can't execute command \"" << command << "\", command is not active. (B)" << std::endl; break;
- case CommandExecutor::Denied: COUT(1) << "Error: Can't execute command \"" << command << "\", access denied. (B)" << std::endl; break;
+ orxout(user_error) << "Can't execute command \"" << command << "\", " + CommandExecutor::getErrorDescription(error) + ". (TclBind)" << endl;
+ if (error == CommandExecutor::Inexistent)
+ orxout(user_info) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << endl;
}
- if (error == CommandExecutor::Error)
- COUT(3) << "Did you mean \"" << evaluation.getCommandSuggestion() << "\"?" << std::endl;
-
return result;
}
@@ -210,7 +209,7 @@
return TclBind::getInstance().interpreter_->eval("uplevel #0 " + tclcode);
}
catch (Tcl::tcl_error const &e)
- { COUT(1) << "Tcl error: " << e.what() << std::endl; }
+ { orxout(user_error, context::tcl) << "Tcl error: " << e.what() << endl; }
}
return "";
@@ -222,7 +221,7 @@
*/
void TclBind::bgerror(const std::string& error)
{
- COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
+ orxout(user_error, context::tcl) << "Tcl background error: " << stripEnclosingBraces(error) << endl;
}
/**
@@ -242,7 +241,7 @@
return TclBind::getInstance().interpreter_->eval(tclcode);
}
catch (Tcl::tcl_error const &e)
- { COUT(1) << "Tcl error: " << e.what() << std::endl; }
+ { orxout(user_error, context::tcl) << "Tcl error: " << e.what() << endl; }
if (error)
*error = CommandExecutor::Error;
Modified: code/trunk/src/libraries/core/command/TclThreadManager.cc
===================================================================
--- code/trunk/src/libraries/core/command/TclThreadManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/command/TclThreadManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -224,7 +224,7 @@
{
TclThreadManager::getInstance().numInterpreterBundles_++;
TclThreadManager::createWithId(TclThreadManager::getInstance().numInterpreterBundles_);
- COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().numInterpreterBundles_ << std::endl;
+ orxout(user_info) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().numInterpreterBundles_ << endl;
return TclThreadManager::getInstance().numInterpreterBundles_;
}
@@ -287,7 +287,10 @@
bundle->interpreter_->eval("rename ::orxonox::for for");
}
catch (const Tcl::tcl_error& e)
- { bundle->interpreter_ = 0; COUT(1) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << std::endl; }
+ {
+ bundle->interpreter_ = 0;
+ orxout(user_error, context::tcl) << "Tcl error while creating Tcl-interpreter (" << id_string << "): " << e.what() << endl;
+ }
}
/**
@@ -406,7 +409,7 @@
if ((source_bundle->id_ == target_bundle->id_) || source_bundle->queriers_.is_in(target_bundle->id_))
{
// This query would lead to a deadlock - return with an error
- TclThreadManager::error("Error: Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + multi_cast<std::string>(source_bundle->id_) \
+ TclThreadManager::error("Circular query (" + this->dumpList(source_bundle->queriers_.getList()) + ' ' + multi_cast<std::string>(source_bundle->id_) \
+ " -> " + multi_cast<std::string>(target_bundle->id_) \
+ "), couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) \
+ " from other interpreter with ID " + multi_cast<std::string>(source_bundle->id_) + '.');
@@ -445,13 +448,8 @@
TclThreadManager::debug("TclThread_query -> CE: " + command);
int error;
output = CommandExecutor::query(command, &error, false);
- switch (error)
- {
- case CommandExecutor::Error: TclThreadManager::error("Error: Can't execute command \"" + command + "\", command doesn't exist. (T)"); break;
- case CommandExecutor::Incomplete: TclThreadManager::error("Error: Can't execute command \"" + command + "\", not enough arguments given. (T)"); break;
- case CommandExecutor::Deactivated: TclThreadManager::error("Error: Can't execute command \"" + command + "\", command is not active. (T)"); break;
- case CommandExecutor::Denied: TclThreadManager::error("Error: Can't execute command \"" + command + "\", access denied. (T)"); break;
- }
+ if (error)
+ TclThreadManager::error("Can't execute command \"" + command + "\", " + CommandExecutor::getErrorDescription(error) + ". (TclThreadManager)");
}
else
{
@@ -475,7 +473,7 @@
{
// This happens if the main thread tries to query a busy interpreter
// To avoid a lock of the main thread, we simply don't proceed with the query in this case
- TclThreadManager::error("Error: Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) + ", interpreter is busy right now.");
+ TclThreadManager::error("Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target_bundle->id_) + ", interpreter is busy right now.");
}
}
@@ -521,7 +519,7 @@
}
else
{
- TclThreadManager::error("Error: No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing.");
+ TclThreadManager::error("No Tcl-interpreter with ID " + multi_cast<std::string>(id) + " existing.");
return 0;
}
}
Modified: code/trunk/src/libraries/core/input/Button.cc
===================================================================
--- code/trunk/src/libraries/core/input/Button.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/input/Button.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -37,7 +37,7 @@
#include "util/Convert.h"
#include "util/SubString.h"
#include "util/StringUtils.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "core/command/ConsoleCommand.h"
#include "core/command/CommandEvaluation.h"
#include "core/command/CommandExecutor.h"
@@ -254,13 +254,13 @@
{
if (serious)
{
- COUT(2) << "Error while parsing binding for button/axis " << this->name_ << ". "
- << message << std::endl;
+ orxout(internal_error, context::input) << "Error while parsing binding for button/axis " << this->name_ << ". "
+ << message << endl;
}
else
{
- COUT(3) << "Warning while parsing binding for button/axis " << this->name_ << ". "
- << message << std::endl;
+ orxout(internal_warning, context::input) << "Warning while parsing binding for button/axis " << this->name_ << ". "
+ << message << endl;
}
}
}
Modified: code/trunk/src/libraries/core/input/InputDevice.h
===================================================================
--- code/trunk/src/libraries/core/input/InputDevice.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/input/InputDevice.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -42,7 +42,7 @@
#include <ois/OISException.h>
#include "util/Clock.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "InputState.h"
@@ -134,7 +134,7 @@
// Note: after the static_cast here, the cast this pointer becomes
// invalid right until the subclass has been constructed!
oisDevice_->setEventCallback(static_cast<DeviceClass*>(this));
- COUT(4) << "Instantiated a " << this->getClassName() << std::endl;
+ orxout(verbose, context::input) << "Instantiated a " << this->getClassName() << endl;
}
//! Destroys the OIS device
@@ -146,8 +146,8 @@
}
catch (const OIS::Exception& ex)
{
- COUT(1) << this->getClassName() << " destruction failed: " << ex.eText << std::endl
- << " Potential resource leak!" << std::endl;
+ orxout(internal_error, context::input) << this->getClassName() << " destruction failed: " << ex.eText << '\n'
+ << "Potential resource leak!" << endl;
}
}
Modified: code/trunk/src/libraries/core/input/InputManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/InputManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/input/InputManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -99,7 +99,7 @@
{
RegisterRootObject(InputManager);
- CCOUT(4) << "Constructing..." << std::endl;
+ orxout(internal_status, context::input) << "InputManager: Constructing..." << endl;
// Allocate space for the function call buffer
this->callBuffer_.reserve(16);
@@ -127,7 +127,7 @@
ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(this);
ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this);
- CCOUT(4) << "Construction complete." << std::endl;
+ orxout(internal_status, context::input) << "InputManager: Construction complete." << endl;
internalState_ = Nothing;
}
@@ -142,7 +142,7 @@
*/
void InputManager::loadDevices()
{
- CCOUT(4) << "Loading input devices..." << std::endl;
+ orxout(verbose, context::input) << "InputManager: Loading input devices..." << endl;
// When loading the devices they should not already be loaded
assert(internalState_ & Bad);
@@ -195,7 +195,7 @@
oisInputManager_ = OIS::InputManager::createInputSystem(paramList);
// Exception-safety
Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, oisInputManager_);
- CCOUT(4) << "Created OIS input manager." << std::endl;
+ orxout(verbose, context::input) << "Created OIS input manager." << endl;
if (oisInputManager_->getNumberOfDevices(OIS::OISKeyboard) > 0)
devices_[InputDeviceEnumerator::Keyboard] = new Keyboard(InputDeviceEnumerator::Keyboard, oisInputManager_);
@@ -218,7 +218,7 @@
// Reorder states in case some joy sticks were added/removed
this->updateActiveStates();
- CCOUT(4) << "Input devices loaded." << std::endl;
+ orxout(verbose, context::input) << "Input devices loaded." << endl;
}
//! Creates a new orxonox::Mouse
@@ -232,12 +232,12 @@
}
catch (const std::exception& ex)
{
- CCOUT(2) << "Warning: Failed to create Mouse:" << ex.what() << std::endl
- << "Proceeding without mouse support." << std::endl;
+ orxout(user_warning, context::input) << "Failed to create Mouse:" << ex.what() << '\n'
+ << "Proceeding without mouse support." << endl;
}
}
else
- CCOUT(2) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;
+ orxout(user_warning, context::input) << "No mouse found! Proceeding without mouse support." << endl;
}
//! Creates as many joy sticks as are available.
@@ -251,7 +251,7 @@
}
catch (const std::exception& ex)
{
- CCOUT(2) << "Warning: Failed to create joy stick: " << ex.what() << std::endl;
+ orxout(user_warning, context::input) << "Failed to create joy stick: " << ex.what() << endl;
}
}
@@ -269,7 +269,7 @@
InputManager::~InputManager()
{
- CCOUT(3) << "Destroying..." << std::endl;
+ orxout(internal_status, context::input) << "InputManager: Destroying..." << endl;
// Leave all active InputStates (except "empty")
while (this->activeStates_.size() > 1)
@@ -294,7 +294,7 @@
ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0);
ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0);
- CCOUT(3) << "Destruction complete." << std::endl;
+ orxout(internal_status, context::input) << "InputManager: Destruction complete." << endl;
}
/**
@@ -305,7 +305,7 @@
*/
void InputManager::destroyDevices()
{
- CCOUT(4) << "Destroying devices..." << std::endl;
+ orxout(verbose, context::input) << "InputManager: Destroying devices..." << endl;
BOOST_FOREACH(InputDevice*& device, devices_)
{
@@ -314,7 +314,7 @@
const std::string& className = device->getClassName();
delete device;
device = 0;
- CCOUT(4) << className << " destroyed." << std::endl;
+ orxout(verbose, context::input) << className << " destroyed." << endl;
}
devices_.resize(InputDeviceEnumerator::FirstJoyStick);
@@ -325,13 +325,13 @@
}
catch (const OIS::Exception& ex)
{
- COUT(1) << "OIS::InputManager destruction failed" << ex.eText << std::endl
- << " Potential resource leak!" << std::endl;
+ orxout(internal_error, context::input) << "OIS::InputManager destruction failed" << ex.eText << '\n'
+ << "Potential resource leak!" << endl;
}
oisInputManager_ = NULL;
internalState_ |= Bad;
- CCOUT(4) << "Destroyed devices." << std::endl;
+ orxout(verbose, context::input) << "Destroyed devices." << endl;
}
// ############################################################
@@ -342,7 +342,7 @@
void InputManager::reload()
{
if (internalState_ & Calibrating)
- CCOUT(2) << "Warning: Cannot reload input system. Joy sticks are currently being calibrated." << std::endl;
+ orxout(internal_warning, context::input) << "Cannot reload input system. Joy sticks are currently being calibrated." << endl;
else
reloadInternal();
}
@@ -350,13 +350,13 @@
//! Internal reload method. Destroys the OIS devices and loads them again.
void InputManager::reloadInternal()
{
- CCOUT(4) << "Reloading ..." << std::endl;
+ orxout(verbose, context::input) << "InputManager: Reloading ..." << endl;
this->destroyDevices();
this->loadDevices();
internalState_ &= ~Bad;
- CCOUT(4) << "Reloading complete." << std::endl;
+ orxout(verbose, context::input) << "InputManager: Reloading complete." << endl;
}
// ############################################################
@@ -470,8 +470,8 @@
void InputManager::calibrate()
{
- COUT(0) << "Move all joy stick axes fully in all directions." << std::endl
- << "When done, put the axex in the middle position and press enter." << std::endl;
+ orxout(message) << "Move all joy stick axes fully in all directions." << '\n'
+ << "When done, put the axex in the middle position and press enter." << endl;
BOOST_FOREACH(InputDevice* device, devices_)
if (device != NULL)
@@ -494,7 +494,7 @@
// Clear buffers to prevent button hold events
this->clearBuffers();
- COUT(0) << "Calibration has been stored." << std::endl;
+ orxout(message) << "Calibration has been stored." << endl;
}
//! Gets called by WindowEventListener upon focus change --> clear buffers
@@ -534,8 +534,8 @@
{
if (it->second->getPriority() == priority)
{
- COUT(2) << "Warning: Could not add an InputState with the same priority '"
- << static_cast<int>(priority) << "' != 0." << std::endl;
+ orxout(internal_warning, context::input) << "Could not add an InputState with the same priority '"
+ << static_cast<int>(priority) << "' != 0." << endl;
return 0;
}
}
@@ -547,7 +547,7 @@
}
else
{
- COUT(2) << "Warning: Could not add an InputState with the same name '" << name << "'." << std::endl;
+ orxout(internal_warning, context::input) << "Could not add an InputState with the same name '" << name << "'." << endl;
return 0;
}
}
@@ -597,7 +597,7 @@
{
if (name == "empty")
{
- COUT(2) << "InputManager: Leaving the empty state is not allowed!" << std::endl;
+ orxout(internal_warning, context::input) << "InputManager: Leaving the empty state is not allowed!" << endl;
return false;
}
// get pointer from the map with all stored handlers
@@ -622,7 +622,7 @@
{
if (name == "empty")
{
- COUT(2) << "InputManager: Removing the empty state is not allowed!" << std::endl;
+ orxout(internal_warning, context::input) << "InputManager: Removing the empty state is not allowed!" << endl;
return false;
}
std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
@@ -648,7 +648,7 @@
{
if (name == "empty")
{
- COUT(2) << "InputManager: Changing the empty state is not allowed!" << std::endl;
+ orxout(internal_warning, context::input) << "InputManager: Changing the empty state is not allowed!" << endl;
return false;
}
std::map<std::string, InputState*>::iterator it = statesByName_.find(name);
Modified: code/trunk/src/libraries/core/input/JoyStick.cc
===================================================================
--- code/trunk/src/libraries/core/input/JoyStick.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/input/JoyStick.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -79,7 +79,7 @@
}
}
- COUT(4) << "Created OIS joy stick with ID " << deviceName_ << std::endl;
+ orxout(verbose, context::input) << "Created OIS joy stick with ID " << deviceName_ << endl;
// Load calibration
size_t axes = sliderAxes_s + static_cast<size_t>(oisDevice_->getNumberOfComponents(OIS::OIS_Axis));
Modified: code/trunk/src/libraries/core/input/KeyBinder.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinder.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/input/KeyBinder.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,7 +31,7 @@
#include <algorithm>
#include <sstream>
#include "util/Convert.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
@@ -250,7 +250,7 @@
*/
void KeyBinder::loadBindings()
{
- COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
+ orxout(internal_info, context::input) << "KeyBinder: Loading key bindings..." << endl;
this->configFile_ = new ConfigFile(this->filename_, !PathConfig::buildDirectoryRun());
this->configFile_->load();
@@ -276,7 +276,7 @@
addButtonToCommand(it->second->bindingString_, it->second);
}
- COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
+ orxout(internal_info, context::input) << "KeyBinder: Loading key bindings done." << endl;
}
bool KeyBinder::setBinding(const std::string& binding, const std::string& name, bool bTemporary)
@@ -293,7 +293,7 @@
}
else
{
- COUT(2) << "Could not find key/button/axis with name '" << name << "'." << std::endl;
+ orxout(internal_warning, context::input) << "Could not find key/button/axis with name '" << name << "'." << endl;
return false;
}
}
Modified: code/trunk/src/libraries/core/input/KeyBinderManager.cc
===================================================================
--- code/trunk/src/libraries/core/input/KeyBinderManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/core/input/KeyBinderManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -28,7 +28,7 @@
#include "KeyBinderManager.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Exception.h"
#include "util/ScopedSingletonManager.h"
#include "core/ConfigValueIncludes.h"
@@ -167,7 +167,7 @@
{
if (!this->bBinding_)
{
- COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+ orxout(message) << "Press any button/key or move a mouse/joystick axis" << endl;
KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this));
InputManager::getInstance().enterState("detector");
this->command_ = command;
@@ -184,11 +184,11 @@
{
if (keyName == "Keys.KeyEscape")
{
- COUT(0) << "Keybinding aborted." << std::endl;
+ orxout(message) << "Keybinding aborted." << endl;
}
else
{
- COUT(0) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << std::endl;
+ orxout(message) << "Binding string \"" << command_ << "\" on key '" << keyName << "'" << endl;
this->currentBinder_->setBinding(command_, keyName, bTemporary_);
}
InputManager::getInstance().leaveState("detector");
Modified: code/trunk/src/libraries/network/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/network/CMakeLists.txt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -18,7 +18,6 @@
#
SET_SOURCE_FILES(NETWORK_SRC_FILES
- ChatListener.cc
Client.cc
ClientConnection.cc
ClientConnectionListener.cc
@@ -44,7 +43,6 @@
)
SET_SOURCE_FILES(NETWORK_HDR_FILES
- ChatListener.h
Client.h
ClientConnection.h
ClientConnectionListener.h
@@ -60,6 +58,7 @@
WANDiscoverable.h
WANDiscovery.h
MasterServerComm.h
+ NetworkChatListener.h
NetworkFunction.h
NetworkPrecompiledHeaders.h
NetworkPrereqs.h
Deleted: code/trunk/src/libraries/network/ChatListener.cc
===================================================================
--- code/trunk/src/libraries/network/ChatListener.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/ChatListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,50 +0,0 @@
-/*
- * 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:
- * ...
- *
- */
-
-#include "ChatListener.h"
-#include "core/CoreIncludes.h"
-
-namespace orxonox
-{
- ChatListener::ChatListener()
- {
- RegisterRootObject(ChatListener);
- }
-
- //void ChatListener::incomingChat( const std::string& message,
- //unsigned int senderID )
- //{
- //COUT(0) << "Chat: \"" << message << "\"\n";
-
-
- //}
-
-
-}
-
-
Deleted: code/trunk/src/libraries/network/ChatListener.h
===================================================================
--- code/trunk/src/libraries/network/ChatListener.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/ChatListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,49 +0,0 @@
-/*
- * 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:
- * ...
- *
- */
-
-#ifndef _NETWORK_ChatListener__
-#define _NETWORK_ChatListener__
-
-#include "NetworkPrereqs.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
- class _NetworkExport ChatListener : virtual public OrxonoxClass
- {
- public:
- /* constructor, destructor */
- ChatListener();
- virtual ~ChatListener() {}
-
- /* What to do with incoming chat */
- virtual void incomingChat(const std::string& message, unsigned int senderID) = 0;
- };
-}
-
-#endif /* _NETWORK_ChatListener__ */
Modified: code/trunk/src/libraries/network/Client.cc
===================================================================
--- code/trunk/src/libraries/network/Client.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Client.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -43,7 +43,7 @@
#include <cassert>
#include "util/Clock.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/ScopedSingletonManager.h"
#include "synchronisable/Synchronisable.h"
#include "packet/Chat.h"
@@ -115,29 +115,33 @@
ClientConnection::addPacket(packet, channelID);
}
- bool Client::processChat(const std::string& message, unsigned int playerID)
+ void Client::printRTT()
{
-// COUT(1) << "Player " << playerID << ": " << message << std::endl;
- return true;
+ orxout(message) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
}
- void Client::printRTT()
+ /**
+ * @brief Sends a chat message to the server.
+ * @param message message to be sent
+ * @param sourceID the ID of the sender
+ * @param targetID the ID of the receiver
+ */
+ void Client::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- COUT(0) << "Round trip time to server is " << ClientConnection::getRTT() << " ms" << endl;
+ // send the message to the server
+ packet::Chat* packet = new packet::Chat(message, sourceID, targetID);
+ packet->send(static_cast<Host*>(this));
}
/**
- * This function implements the method of sending a chat message to the server
- * @param message message to be sent
- * @return result(true/false)
+ * @brief Gets called if a packet::Chat packet is received. Calls the parent function which passes the message to the listeners.
*/
- bool Client::chat(const std::string& message)
+ void Client::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- packet::Chat *m = new packet::Chat(message, Host::getPlayerID());
- return m->send(static_cast<Host*>(this));
+ // call the parent function which passes the message to the listeners
+ Host::doReceiveChat(message, sourceID, targetID);
}
-
/**
* Processes incoming packets, sends a gamestate to the server and does the cleanup
* @param time
@@ -149,10 +153,9 @@
if(timeSinceLastUpdate_>=NETWORK_PERIOD)
{
timeSinceLastUpdate_ -= static_cast<unsigned int>( timeSinceLastUpdate_ / NETWORK_PERIOD ) * NETWORK_PERIOD;
- // COUT(3) << '.';
if ( isConnected() && isSynched_ )
{
- COUT(4) << "popping partial gamestate: " << std::endl;
+ orxout(verbose, context::network) << "popping partial gamestate: " << endl;
// packet::Gamestate *gs = GamestateClient::getGamestate();
if( GamestateManager::update() )
{
@@ -165,9 +168,9 @@
}
//assert(gs); <--- there might be the case that no data has to be sent, so its commented out now
// if(gs){
-// COUT(4) << "client tick: sending gs " << gs << std::endl;
+// orxout(verbose, context::network) << "client tick: sending gs " << gs << endl;
// if( !gs->send() )
-// COUT(2) << "Problem adding partial gamestate to queue" << std::endl;
+// orxout(internal_warning, context::network) << "Problem adding partial gamestate to queue" << endl;
// // gs gets automatically deleted by enet callback
// }
FunctionCallManager::sendCalls(static_cast<Host*>(this));
@@ -203,7 +206,7 @@
Game::getInstance().popState();
Game::getInstance().popState();
}
-
+
void Client::processPacket(packet::Packet* packet)
{
if( packet->isReliable() )
@@ -216,8 +219,4 @@
else
packet->process(static_cast<Host*>(this));
}
-
-
-
-
}
Modified: code/trunk/src/libraries/network/Client.h
===================================================================
--- code/trunk/src/libraries/network/Client.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Client.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -72,7 +72,7 @@
public:
Client();
~Client();
-
+
static Client* getInstance(){ return singletonPtr_s; } // tolua_export
bool establishConnection();
@@ -80,9 +80,8 @@
bool closeConnection();
void queuePacket(ENetPacket* packet, int clientID, uint8_t channelID);
virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
- bool processChat(const std::string& message, unsigned int playerID);
- virtual bool chat(const std::string& message);
- virtual bool broadcast(const std::string& message) { return false; }
+ virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
+ virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
virtual void printRTT();
void update(const Clock& time);
Modified: code/trunk/src/libraries/network/ClientConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ClientConnection.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/ClientConnection.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,7 +31,7 @@
#include <cassert>
#define WIN32_LEAN_AND_MEAN
#include <enet/enet.h>
-#include "util/Debug.h"
+#include "util/Output.h"
namespace orxonox
{
@@ -59,7 +59,7 @@
void ClientConnection::setServerAddress( const std::string& serverAddress ) {
if (enet_address_set_host (this->serverAddress_, serverAddress.c_str()) < 0)
- COUT(1) << "Error: Could not resolve \"" << serverAddress << "\"." << std::endl;
+ orxout(internal_error, context::network) << "Could not resolve \"" << serverAddress << "\"." << endl;
}
void ClientConnection::setPort( unsigned int port ) {
@@ -75,7 +75,7 @@
if ( this->host_ == NULL )
{
- COUT(1) << "ClientConnection: host_ == NULL" << std::endl;
+ orxout(internal_error, context::network) << "ClientConnection: host_ == NULL" << endl;
// error handling
return false;
}
@@ -85,16 +85,16 @@
assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
if (this->host_->socket4 == ENET_SOCKET_NULL)
- COUT(2) << "Warning: IPv4 Socket failed." << std::endl;
+ orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl;
else if (this->host_->socket6 == ENET_SOCKET_NULL)
- COUT(2) << "Warning: IPv6 Socket failed." << std::endl;
+ orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl;
else
- COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
+ orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl;
this->server_ = enet_host_connect(this->host_, serverAddress_, NETWORK_CHANNEL_COUNT, 0);
if ( this->server_==NULL )
{
- COUT(1) << "ClientConnection: server_ == NULL" << std::endl;
+ orxout(internal_error, context::network) << "ClientConnection: server_ == NULL" << endl;
// error handling
return false;
}
@@ -112,7 +112,7 @@
return true;
}
}
- COUT(1) << "Could not connect to server" << endl;
+ orxout(user_error, context::network) << "Could not connect to server" << endl;
return false;
}
@@ -139,7 +139,7 @@
enet_packet_destroy(event.packet);
break;
case ENET_EVENT_TYPE_DISCONNECT:
- COUT(4) << "received disconnect confirmation from server" << endl;
+ orxout(verbose, context::network) << "received disconnect confirmation from server" << endl;
this->connectionClosed();
return true;
}
@@ -166,7 +166,7 @@
void ClientConnection::removePeer(uint32_t peerID)
{
this->established_=false;
- COUT(1) << "Received disconnect Packet from Server!" << endl;
+ orxout(internal_error, context::network) << "Received disconnect Packet from Server!" << endl;
// server closed the connection
this->stopCommunicationThread();
this->connectionClosed();
Modified: code/trunk/src/libraries/network/Connection.cc
===================================================================
--- code/trunk/src/libraries/network/Connection.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Connection.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -143,7 +143,7 @@
this->outgoingEventsMutex_->unlock();
while( outgoingEventsCount > 0 )
{
-// COUT(0) << "outgoing event" << endl;
+// orxout(verbose, context::network) << "outgoing event" << endl;
this->outgoingEventsMutex_->lock();
outgoingEvent outEvent = this->outgoingEvents_.front();
this->outgoingEvents_.pop_front();
Modified: code/trunk/src/libraries/network/GamestateManager.cc
===================================================================
--- code/trunk/src/libraries/network/GamestateManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/GamestateManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -51,7 +51,7 @@
#include "core/ThreadPool.h"
#include "core/command/Executor.h"
#include "core/GameMode.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/Clock.h"
#include "util/OrxAssert.h"
// #include "TrafficControl.h"
@@ -127,12 +127,12 @@
packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, peerID);
if( !this->sendPacket(ack))
{
- COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
+ orxout(internal_warning, context::network) << "could not ack gamestate: " << gamestateID << endl;
return false;
}
else
{
- COUT(5) << "acked a gamestate: " << gamestateID << std::endl;
+ orxout(verbose_more, context::network) << "acked a gamestate: " << gamestateID << endl;
return true;
}
}
@@ -181,11 +181,11 @@
{
if( !peerIt->second.isSynched )
{
- COUT(5) << "Server: not sending gamestate" << std::endl;
+ orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
continue;
}
- COUT(5) << "client id: " << peerIt->first << std::endl;
- COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
+ orxout(verbose_more, context::network) << "client id: " << peerIt->first << endl;
+ orxout(verbose_more, context::network) << "Server: doing gamestate gamestate preparation" << endl;
int peerID = peerIt->first; //get client id
unsigned int lastAckedGamestateID = peerIt->second.lastAckedGamestateID;
@@ -255,12 +255,12 @@
// OrxVerify(gs->compressData(), "");
clock.capture();
- COUT(5) << "diff and compress time: " << clock.getDeltaTime() << endl;
-// COUT(5) << "sending gamestate with id " << gs->getID();
+ orxout(verbose_more, context::network) << "diff and compress time: " << clock.getDeltaTime() << endl;
+// orxout(verbose_more, context::network) << "sending gamestate with id " << gs->getID();
// if(gamestate->isDiffed())
-// COUT(5) << " and baseid " << gs->getBaseID() << endl;
+// orxout(verbose_more, context::network) << " and baseid " << gs->getBaseID() << endl;
// else
-// COUT(5) << endl;
+// orxout(verbose_more, context::network) << endl;
gs->setPeerID(peerID);
destgamestate = gs;
}
@@ -290,7 +290,7 @@
// assert(curid==GAMESTATEID_INITIAL || curid<=gamestateID); // this line is commented out because acknowledgements are unreliable and may arrive in distorted order
if( gamestateID <= curid && curid != GAMESTATEID_INITIAL )
return true;
-COUT(4) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << std::endl;
+orxout(verbose, context::network) << "acking gamestate " << gamestateID << " for peerID: " << peerID << " curid: " << curid << endl;
std::map<uint32_t, packet::Gamestate*>::iterator it2;
for( it2=it->second.gamestates.begin(); it2!=it->second.gamestates.end(); )
{
Modified: code/trunk/src/libraries/network/Host.cc
===================================================================
--- code/trunk/src/libraries/network/Host.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Host.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,16 +31,16 @@
#include <cassert>
#include <string>
+#include "core/CoreIncludes.h"
#include "core/ObjectList.h"
#include "core/command/ConsoleCommand.h"
-#include "ChatListener.h"
+#include "NetworkChatListener.h"
namespace orxonox {
static const std::string __CC_printRTT_group = "Stats";
static const std::string __CC_printRTT_name = "printRTT";
- SetConsoleCommand("chat", &Host::Chat);
SetConsoleCommand(__CC_printRTT_group, __CC_printRTT_name, &Host::printRTT);
// Host* Host::instance_=0;
@@ -88,79 +88,42 @@
}
}
- void Host::Chat(const std::string& message)
+ /**
+ * @brief Sends a chat message through the network.
+ * @param message message to be sent
+ * @param sourceID the ID of the sender
+ * @param targetID the ID of the receiver
+ */
+ void Host::sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- if(instances_s.size()==0)
- {
- for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
- it->incomingChat(message, 0);
-// return true;
- }
- else
- {
- bool result = true;
- for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
- {
- if( (*it)->isActive() )
- {
- if( !(*it)->chat(message) )
- result = false;
- }
- }
-// return result;
- }
+ for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+ if( (*it)->isActive() )
+ (*it)->doSendChat(message, sourceID, targetID);
}
- bool Host::Broadcast(const std::string& message)
+ /**
+ * @brief Gets called if a packet::Chat packet is received. Passes the message to the listeners.
+ */
+ void Host::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- if(instances_s.size()==0)
- {
- for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
- it->incomingChat(message, NETWORK_PEER_ID_BROADCAST);
- return true;
- }
- else
- {
- bool result = true;
- for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
- {
- if( (*it)->isActive() )
- {
- if( !(*it)->broadcast(message) )
- result = false;
- }
- }
- return result;
- }
+ for (ObjectList<NetworkChatListener>::iterator it = ObjectList<NetworkChatListener>::begin(); it != ObjectList<NetworkChatListener>::end(); ++it)
+ it->incomingChat(message, sourceID);
}
- bool Host::incomingChat(const std::string& message, unsigned int playerID)
- {
- for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
- it->incomingChat(message, playerID);
- bool result = true;
- for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it )
+ bool Host::isServer()
+ {
+ for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it )
{
if( (*it)->isActive() )
{
- if( !(*it)->processChat(message, playerID) )
- result = false;
+ if( (*it)->isServer_() )
+ return true;
}
}
- return result;
- }
-
- bool Host::isServer()
- {
- for (std::vector<Host*>::iterator it=instances_s.begin(); it!=instances_s.end(); ++it )
- {
- if( (*it)->isServer_() )
- return true;
- }
return false;
}
-
+
Host* Host::getActiveInstance()
{
std::vector<Host*>::iterator it = Host::instances_s.begin();
@@ -175,4 +138,13 @@
}
+ //////////////////////////////////////////////////////////////////////////
+ // NetworkChatListener //
+ //////////////////////////////////////////////////////////////////////////
+
+ NetworkChatListener::NetworkChatListener()
+ {
+ RegisterRootObject(NetworkChatListener);
+ }
+
}//namespace orxonox
Modified: code/trunk/src/libraries/network/Host.h
===================================================================
--- code/trunk/src/libraries/network/Host.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Host.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -51,36 +51,28 @@
*/
class _NetworkExport Host: public GamestateManager
{
+ friend class packet::Chat;
+
private:
- //TODO add these functions or adequate
- //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
- //virtual bool sendChat(packet::Chat *chat)=0;
virtual void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID)=0;
- virtual bool chat(const std::string& message)=0;
- virtual bool broadcast(const std::string& message)=0;
- virtual bool processChat(const std::string& message, unsigned int playerID)=0;
virtual bool isServer_()=0;
-
-
protected:
Host();
virtual ~Host();
void setActive( bool bActive ){ bIsActive_ = bActive; }
-// static Host *instance_;
+ virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0;
+ virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)=0;
+
public:
static Host* getActiveInstance();
static bool running(){ return instances_s.size(); }
static void addPacket(ENetPacket* packet, int clientID = NETWORK_PEER_ID_SERVER, uint8_t channelID = 0);
- //static bool chat(std::string& message);
-// static bool receiveChat(packet::Chat *message, unsigned int clientID);
static unsigned int getPlayerID(){ return clientID_s; }
static void setClientID(unsigned int id){ clientID_s = id; }
static bool isServer();
- static void Chat(const std::string& message);
- static bool Broadcast(const std::string& message);
- static bool incomingChat(const std::string& message, unsigned int playerID);
+ static void sendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
virtual void printRTT()=0;
bool isActive(){ return bIsActive_; }
private:
Modified: code/trunk/src/libraries/network/LANDiscoverable.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscoverable.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/LANDiscoverable.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -32,7 +32,7 @@
#include <cassert>
#include <cstring>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "packet/ServerInformation.h"
namespace orxonox
@@ -70,7 +70,7 @@
assert( this->host_ == 0 );
this->host_ = enet_host_create( &bindAddress, 10, 0, 0, 0 );
if ( this->host_ == NULL )
- COUT(1) << "LANDiscoverable: host_ == NULL" << std::endl;
+ orxout(internal_error, context::network) << "LANDiscoverable: host_ == NULL" << endl;
}
else
{
@@ -93,7 +93,7 @@
switch(event.type)
{
case ENET_EVENT_TYPE_CONNECT:
- COUT(4) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << std::endl;
+ orxout(verbose, context::network) << "Received LAN discovery connect from client " << event.peer->host->receivedAddress << endl;
break;
case ENET_EVENT_TYPE_DISCONNECT:
case ENET_EVENT_TYPE_NONE:
@@ -101,7 +101,7 @@
case ENET_EVENT_TYPE_RECEIVE:
if( strcmp( LAN_DISCOVERY_MESSAGE, (char*)event.packet->data ) == 0 ) // check for a suitable orxonox client
{
- COUT(3) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << std::endl;
+ orxout(internal_info, context::network) << "Received LAN discovery message from client " << event.peer->host->receivedAddress << endl;
packet::ServerInformation info;
info.setServerName("Orxonox Server");
info.send(event.peer);
Modified: code/trunk/src/libraries/network/LANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/LANDiscovery.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/LANDiscovery.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Oliver Scheuss
* Co-authors:
* ...
*
@@ -43,7 +43,7 @@
{
this->host_ = enet_host_create(NULL, 10, 0, 0, 0 );
if ( this->host_ == NULL )
- COUT(1) << "LANDiscovery: host_ == NULL" << std::endl;
+ orxout(internal_error, context::network) << "LANDiscovery: host_ == NULL" << endl;
}
LANDiscovery::~LANDiscovery()
@@ -65,13 +65,13 @@
address.host = ENET_HOST_BROADCAST;
peer = enet_host_connect(this->host_, &address, 0, 0);
if (peer == NULL)
- COUT(1) << "Error: Could not send LAN discovery to IPv4 Broadcast." << std::endl;
+ orxout(internal_error, context::network) << "Could not send LAN discovery to IPv4 Broadcast." << endl;
/* IPv6 */
enet_address_set_host(&address, "ff02::1"); // TODO: use a multicast group
peer = enet_host_connect(this->host_, &address, 0, 0);
if (peer == NULL)
- COUT(1) << "Error: Could not send LAN discovery to IPv6 Multicast." << std::endl;
+ orxout(internal_error, context::network) << "Could not send LAN discovery to IPv6 Multicast." << endl;
ENetEvent event;
while( enet_host_service(this->host_, &event, 1000 ) )
@@ -80,7 +80,7 @@
{
case ENET_EVENT_TYPE_CONNECT:
{
- COUT(4) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << std::endl;
+ orxout(verbose, context::network) << "Received LAN discovery connect from server " << event.peer->host->receivedAddress << endl;
ENetPacket* packet = enet_packet_create(LAN_DISCOVERY_MESSAGE, strlen(LAN_DISCOVERY_MESSAGE)+1, ENET_PACKET_FLAG_RELIABLE);
enet_peer_send(event.peer, 0, packet);
break;
@@ -88,7 +88,7 @@
case ENET_EVENT_TYPE_RECEIVE:
{
packet::ServerInformation info(&event);
- COUT(3) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
+ orxout(internal_info, context::network) << "Received LAN discovery server information; Name: " << info.getServerName() << ", Address: " << info.getServerIP() << ", RTT: " << info.getServerRTT() << endl;
std::vector<packet::ServerInformation>::iterator it;
for( it=this->servers_.begin(); it!=this->servers_.end(); ++it )
{
Modified: code/trunk/src/libraries/network/LANDiscovery.h
===================================================================
--- code/trunk/src/libraries/network/LANDiscovery.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/LANDiscovery.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Oliver Scheuss
* Co-authors:
* ...
*
Modified: code/trunk/src/libraries/network/MasterServer.cc
===================================================================
--- code/trunk/src/libraries/network/MasterServer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/MasterServer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -37,14 +37,15 @@
static void
helper_output_debug( ENetEvent *event, char *addrconv )
{
- COUT(4) << "A packet of length"
+ orxout(verbose, context::master_server)
+ << "A packet of length"
<< event->packet->dataLength
<< " containing "
<< (const char*)event->packet->data
<< " was received from "
<< addrconv
<< " on channel "
- << event->channelID << "\n";
+ << event->channelID << endl;
}
void
@@ -65,7 +66,7 @@
char *tosend = (char *)calloc( (*i).getServerIP().length()
+ MSPROTO_SERVERLIST_ITEM_LEN + 2,1 );
if( !tosend )
- { COUT(2) << "Masterserver.cc: Memory allocation failed.\n";
+ { orxout(internal_warning, context::master_server) << "Masterserver.cc: Memory allocation failed." << endl;
continue;
}
sprintf( tosend, "%s %s", MSPROTO_SERVERLIST_ITEM,
@@ -107,7 +108,7 @@
MasterServer::eventConnect( ENetEvent *event )
{ /* check for bad parameters */
if( !event )
- { COUT(2) << "MasterServer::eventConnect: No event given.\n" ;
+ { orxout(internal_warning, context::master_server) << "MasterServer::eventConnect: No event given." << endl;
return -1;
}
@@ -116,10 +117,10 @@
enet_address_get_host_ip( &(event->peer->address), addrconv, 49 );
/* output debug info */
- COUT(4) << "A new client connected from "
+ orxout(verbose, context::master_server) << "A new client connected from "
<< addrconv
<< " on port "
- << event->peer->address.port << "\n";
+ << event->peer->address.port << endl;
/* store string form of address here */
event->peer->data = addrconv;
@@ -133,12 +134,12 @@
MasterServer::eventDisconnect( ENetEvent *event )
{ /* check for bad parameters */
if( !event )
- { COUT(2) << "No event given.\n";
+ { orxout(internal_warning, context::master_server) << "No event given." << endl;
return -1;
}
/* output that the disconnect happened */
- COUT(4) << (char*)event->peer->data << " disconnected.\n";
+ orxout(verbose, context::master_server) << (char*)event->peer->data << " disconnected." << endl;
/* create string from peer data */
std::string name = std::string( (char*)event->peer->data );
@@ -158,7 +159,7 @@
MasterServer::eventData( ENetEvent *event )
{ /* validate packet */
if( !event || !(event->packet) || !(event->peer) )
- { COUT(2) << "No complete event given.\n";
+ { orxout(internal_warning, context::master_server) << "No complete event given." << endl;
return -1;
}
@@ -181,8 +182,8 @@
mainlist.addServer( packet::ServerInformation( event ) );
/* tell people we did so */
- COUT(2) << "Added new server to list: " <<
- packet::ServerInformation( event ).getServerIP() << "\n";
+ orxout(internal_info, context::master_server) << "Added new server to list: " <<
+ packet::ServerInformation( event ).getServerIP() << endl;
}
else if( !strncmp( (char *)event->packet->data
@@ -196,7 +197,7 @@
this->mainlist.delServerByAddress( name );
/* tell the user */
- COUT(2) << "Removed server " << name << " from list.\n";
+ orxout(internal_info, context::master_server) << "Removed server " << name << " from list." << endl;
}
/* TODO add hook for disconnect here */
@@ -229,7 +230,7 @@
ENetEvent *event = (ENetEvent *)calloc(sizeof(ENetEvent), sizeof(char));
if( event == NULL )
{
- COUT(1) << "Could not create ENetEvent structure, exiting.\n";
+ orxout(user_error, context::master_server) << "Could not create ENetEvent structure, exiting." << endl;
exit( EXIT_FAILURE );
}
@@ -262,7 +263,7 @@
{
/***** INITIALIZE NETWORKING *****/
if( enet_initialize () != 0)
- { COUT(1) << "An error occurred while initializing ENet.\n";
+ { orxout(user_error, context::master_server) << "An error occurred while initializing ENet." << endl;
exit( EXIT_FAILURE );
}
@@ -284,8 +285,8 @@
/* see if creation worked */
if( !this->server )
- { COUT(1) <<
- "An error occurred while trying to create an ENet server host.\n";
+ { orxout(user_error, context::master_server) <<
+ "An error occurred while trying to create an ENet server host." << endl;
exit( EXIT_FAILURE );
}
@@ -293,7 +294,7 @@
this->peers = new PeerList();
/* tell people we're now initialized */
- COUT(0) << "MasterServer initialized, waiting for connections.\n";
+ orxout(internal_status, context::master_server) << "MasterServer initialized, waiting for connections." << endl;
}
/* destructor */
Modified: code/trunk/src/libraries/network/MasterServerComm.cc
===================================================================
--- code/trunk/src/libraries/network/MasterServerComm.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/MasterServerComm.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -27,7 +27,8 @@
*/
#include "MasterServerComm.h"
-#include "util/Debug.h"
+#include "util/Output.h"
+#include "WANDiscovery.h"
namespace orxonox
{
@@ -43,7 +44,7 @@
{
/* initialize Enet */
if( enet_initialize () != 0 )
- { COUT(1) << "An error occurred while initializing ENet.\n";
+ { orxout(internal_error, context::master_server) << "An error occurred while initializing ENet." << endl;
return 1;
}
@@ -60,8 +61,8 @@
/* see if it worked */
if (this->client == NULL)
- { COUT(1) << "An error occurred while trying to create an "
- << "ENet client host.\n";
+ { orxout(internal_error, context::master_server) << "An error occurred while trying to create an "
+ << "ENet client host." << endl;
return 1;
}
@@ -84,19 +85,19 @@
this->peer = enet_host_connect(this->client, &this->address, 2, 0);
if( this->peer == NULL )
- { COUT(2) << "ERROR: No available peers for initiating an ENet"
- << " connection.\n";
+ { orxout(internal_error, context::master_server) << "No available peers for initiating an ENet"
+ << " connection." << endl;
return -1;
}
/* Wait up to 2 seconds for the connection attempt to succeed. */
if (enet_host_service (this->client, &this->event, 500) > 0 &&
this->event.type == ENET_EVENT_TYPE_CONNECT )
- COUT(3) << "Connection to master server succeeded.\n";
+ orxout(internal_info, context::master_server) << "Connection to master server succeeded." << endl;
else
{
enet_peer_reset (this->peer);
- COUT(2) << "ERROR: connection to " << address << " failed.\n";
+ orxout(internal_warning, context::master_server) << "Connection to " << address << " failed." << endl;
return -1;
}
@@ -127,7 +128,7 @@
break;
case ENET_EVENT_TYPE_DISCONNECT:
- COUT(4) << "Disconnect from master server successful.\n";
+ orxout(verbose, context::master_server) << "Disconnect from master server successful." << endl;
return 0;
default: break;
}
@@ -148,12 +149,11 @@
* - the event
* so we can also make callbacks from objects
*/
- int MasterServerComm::pollForReply( int (*callback)( char*, ENetEvent* ),
- int delayms )
+ int MasterServerComm::pollForReply( WANDiscovery* listener, int delayms )
{
/* see whether anything happened */
/* WORK MARK REMOVE THIS OUTPUT */
- COUT(2) << "polling masterserver...\n";
+ orxout(verbose, context::master_server) << "polling masterserver..." << endl;
/* address buffer */
char *addrconv = NULL;
@@ -175,7 +175,7 @@
case ENET_EVENT_TYPE_RECEIVE:
addrconv = (char *) calloc( 50, 1 );
if( !addrconv )
- { COUT(2) << "MasterServerComm.cc: Could not allocate memory!\n";
+ { orxout(internal_warning, context::master_server) << "MasterServerComm.cc: Could not allocate memory!" << endl;
break;
}
@@ -184,7 +184,7 @@
addrconv, 49 );
/* DEBUG */
- COUT(3) << "MasterServer Debug: A packet of length "
+ orxout(verbose, context::master_server) << "MasterServer Debug: A packet of length "
<< this->event.packet->dataLength
<< " containing " << this->event.packet->data
<< " was received from " << addrconv
@@ -192,8 +192,8 @@
/* END DEBUG */
/* call the supplied callback, if any. */
- if( (*callback) != NULL )
- retval = (*callback)( addrconv, &(this->event) );
+ if( listener != NULL )
+ retval = listener->rhandler( addrconv, &(this->event) );
/* clean up */
enet_packet_destroy( event.packet );
Modified: code/trunk/src/libraries/network/MasterServerComm.h
===================================================================
--- code/trunk/src/libraries/network/MasterServerComm.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/MasterServerComm.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -92,7 +92,7 @@
* \return 0 for success, other for error
*
* Poll the master server for new data and act accordingly */
- int pollForReply( int (*callback)( char*, ENetEvent* ), int delayms );
+ int pollForReply( WANDiscovery* listener, int delayms );
private:
/** client handle */
Copied: code/trunk/src/libraries/network/NetworkChatListener.h (from rev 8857, code/branches/output/src/libraries/network/NetworkChatListener.h)
===================================================================
--- code/trunk/src/libraries/network/NetworkChatListener.h (rev 0)
+++ code/trunk/src/libraries/network/NetworkChatListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _NetworkChatListener_H__
+#define _NetworkChatListener_H__
+
+#include "NetworkPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ /**
+ @brief The only function of this interface, incomingChat(), gets called whenever a chat
+ message was received through the network.
+
+ This interface exists mostly to resolve circular dependencies between the chat functions
+ in Host and ChatManager. ChatManager is the main derivative of this interface.
+ */
+ class _NetworkExport NetworkChatListener : virtual public OrxonoxClass
+ {
+ friend class Host;
+
+ public:
+ NetworkChatListener(); // implemented in Host.cc
+ virtual ~NetworkChatListener() {}
+
+ protected:
+ /**
+ @brief Gets called when a chat message was received through the network.
+ @param message The message
+ @param sourceID The (network) client ID of the sender
+ */
+ virtual void incomingChat(const std::string& message, unsigned int sourceID) = 0;
+ };
+}
+
+#endif /* _NetworkChatListener_H__ */
Modified: code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h
===================================================================
--- code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/NetworkPrecompiledHeaders.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -51,7 +51,7 @@
#include <sstream> // 22
#include <set> // 20
-#include "util/Debug.h" // 20
+#include "util/Output.h" // 20
#include <loki/TypeTraits.h> // 18
#ifdef ORXONOX_COMPILER_MSVC
Modified: code/trunk/src/libraries/network/NetworkPrereqs.h
===================================================================
--- code/trunk/src/libraries/network/NetworkPrereqs.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/NetworkPrereqs.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -117,7 +117,6 @@
namespace orxonox
{
- class ChatListener;
class Client;
class ClientConnection;
class ClientConnectionListener;
@@ -129,15 +128,21 @@
class GamestateHandler;
class GamestateManager;
class Host;
+ class MasterServer;
+ class MasterServerComm;
+ class NetworkChatListener;
class NetworkFunctionBase;
struct NetworkFunctionPointer;
class NetworkFunctionStatic;
template <class T>
class NetworkMemberFunction;
class NetworkMemberFunctionBase;
+ class PeerList;
class Server;
class ServerConnection;
class TrafficControl;
+ class WANDiscoverable;
+ class WANDiscovery;
// packet
namespace packet
Modified: code/trunk/src/libraries/network/PeerList.cc
===================================================================
--- code/trunk/src/libraries/network/PeerList.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/PeerList.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -27,8 +27,10 @@
*/
#include "PeerList.h"
-#include <network/packet/ServerInformation.h>
+
#include <cstdio>
+#include "util/Output.h"
+#include "network/packet/ServerInformation.h"
namespace orxonox
{
@@ -39,7 +41,7 @@
PeerList::addPeer( ENetPeer *toadd )
{ /* error correction */
if( toadd == NULL )
- { fprintf( stderr, "PeerList::addPeer: empty peer given.\n" );
+ { orxout(internal_error, context::master_server) << "PeerList::addPeer: empty peer given." << endl;
return -1;
}
Modified: code/trunk/src/libraries/network/Server.cc
===================================================================
--- code/trunk/src/libraries/network/Server.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Server.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -46,7 +46,7 @@
#include <string>
#include "util/Clock.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "core/ObjectList.h"
#include "core/command/Executor.h"
#include "packet/Chat.h"
@@ -55,11 +55,9 @@
#include "packet/FunctionIDs.h"
#include "packet/Gamestate.h"
#include "packet/Welcome.h"
-#include "ChatListener.h"
// #include "ClientInformation.h"
#include "FunctionCallManager.h"
#include "GamestateManager.h"
-#include "WANDiscovery.h"
namespace orxonox
{
@@ -99,32 +97,20 @@
{
}
-
- /** helper that connects to the master server */
- void Server::helper_ConnectToMasterserver()
- {
-// WANDiscovery::getInstance().msc.sendRequest( MSPROTO_GAME_SERVER " "
-// MSPROTO_REGISTER_SERVER );
- }
-
/**
* This function opens the server by creating the listener thread
*/
void Server::open()
{
Host::setActive(true);
- COUT(4) << "opening server" << endl;
+ orxout(verbose, context::network) << "opening server" << endl;
this->openListener();
-
+
/* make discoverable on LAN */
LANDiscoverable::setActivity(true);
/* make discoverable on WAN */
WANDiscoverable::setActivity(true);
- /* TODO this needs to be optional, we need a switch from the UI to
- * enable/disable this
- */
-// helper_ConnectToMasterserver();
/* done */
return;
@@ -136,59 +122,19 @@
void Server::close()
{
Host::setActive(false);
- COUT(4) << "closing server" << endl;
+ orxout(verbose, context::network) << "closing server" << endl;
this->disconnectClients();
this->closeListener();
/* tell master server we're closing */
- COUT(2) << "disconnecting." << endl;
- WANDiscoverable::setActivity(false);
- COUT(2) << "disconnecting done" << endl;
+ orxout(internal_info, context::network) << "disconnecting." << endl;
+ WANDiscoverable::setActivity(false);
+ orxout(internal_info, context::network) << "disconnecting done" << endl;
LANDiscoverable::setActivity(false);
return;
}
- bool Server::processChat(const std::string& message, unsigned int playerID)
- {
-// ClientInformation *temp = ClientInformation::getBegin();
- packet::Chat *chat;
-// while(temp){
- chat = new packet::Chat(message, playerID);
- chat->setPeerID(NETWORK_PEER_ID_BROADCAST);
- chat->send( static_cast<Host*>(this) );
-// COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
-// temp = temp->next();
-// }
-// COUT(1) << "Player " << playerID << ": " << message << std::endl;
- return true;
- }
-
-
- /* handle incoming data */
- int rephandler( char *addr, ENetEvent *ev )
- {
- /* reply to pings */
- if( !strncmp( (char *)ev->packet->data, MSPROTO_PING_GAMESERVER,
- MSPROTO_PING_GAMESERVER_LEN ) )
- //this->msc.sendRequest( MSPROTO_ACK );
- /* NOTE implement this after pollForReply
- * reimplementation
- */
- return 0;
-
- /* done handling, return all ok code 0 */
- return 0;
- }
-
- void Server::helper_HandleMasterServerRequests()
- {
- /* poll the master server for replies and see whether something
- * has to be done or changed.
- */
- //WANDiscovery::getInstance().msc.pollForReply( rhandler, 10 );
- }
-
/**
* Run this function once every tick
* calls processQueue and updateGamestate
@@ -201,10 +147,6 @@
// receive and process incoming discovery packets
LANDiscoverable::update();
-
- // receive and process requests from master server
- /* todo */
- //helper_HandleMasterServerRequests();
if ( GamestateManager::hasPeers() )
{
@@ -245,7 +187,7 @@
void Server::printRTT()
{
// for( ClientInformation* temp=ClientInformation::getBegin(); temp!=0; temp=temp->next() )
-// COUT(0) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;
+// orxout(message) << "Round trip time to client with ID: " << temp->getID() << " is " << temp->getRTT() << " ms" << endl;
}
/**
@@ -267,13 +209,13 @@
//no client connected
return;
GamestateManager::update();
-// COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
- //std::cout << "updated gamestate, sending it" << std::endl;
+// orxout(verbose_more, context::network) << "Server: one gamestate update complete, goig to sendGameState" << endl;
+ //orxout(verbose_more, context::network) << "updated gamestate, sending it" << endl;
//if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
sendGameStates();
sendObjectDeletes();
-// COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
- //std::cout << "sent gamestate" << std::endl;
+// orxout(verbose_more, context::network) << "Server: one sendGameState turn complete, repeat in next tick" << endl;
+ //orxout(verbose_more, context::network) << "sent gamestate" << endl;
}
/**
@@ -304,11 +246,11 @@
delete del;
return true; //everything ok (no deletes this tick)
}
-// COUT(3) << "sending DeleteObjects" << std::endl;
+// orxout(verbose, context::network) << "sending DeleteObjects" << endl;
// while(temp != NULL){
// if( !(temp->getSynched()) )
// {
-// COUT(5) << "Server: not sending gamestate" << std::endl;
+// orxout(verbose_more, context::network) << "Server: not sending gamestate" << endl;
// temp=temp->next();
// continue;
// }
@@ -317,7 +259,7 @@
// assert(cd);
del->setPeerID(NETWORK_PEER_ID_BROADCAST);
if ( !del->send( static_cast<Host*>(this) ) )
- COUT(3) << "Server: could not broadcast deleteObjects packet" << std::endl;
+ orxout(internal_warning, context::network) << "Server: could not broadcast deleteObjects packet" << endl;
// temp=temp->next();
// gs gets automatically deleted by enet callback
// }
@@ -329,12 +271,12 @@
void Server::addPeer(uint32_t peerID)
{
// static unsigned int newid=1;
-//
-// COUT(2) << "Server: adding client" << std::endl;
+//
+// orxout(internal_info, context::network) << "Server: adding client" << endl;
// ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
// if(!temp)
// {
-// COUT(2) << "Server: could not add client" << std::endl;
+// orxout(internal_warning, context::network) << "Server: could not add client" << endl;
// }
// temp->setID(newid);
// temp->setPeer(event->peer);
@@ -346,13 +288,13 @@
// ++newid;
- COUT(3) << "Server: added client id: " << peerID << std::endl;
+ orxout(internal_info, context::network) << "Server: added client id: " << peerID << endl;
createClient(peerID);
}
void Server::removePeer(uint32_t peerID)
{
- COUT(4) << "removing client from list" << std::endl;
+ orxout(verbose, context::network) << "removing client from list" << endl;
// ClientInformation *client = ClientInformation::findClient(&event->peer->address);
// if(!client)
// return;
@@ -374,7 +316,7 @@
// delete client;
// }
}
-
+
void Server::processPacket(packet::Packet* packet)
{
if( packet->isReliable() )
@@ -394,10 +336,10 @@
// ClientInformation *temp = ClientInformation::findClient(clientID);
// if(!temp)
// {
-// COUT(2) << "Server. could not create client with id: " << clientID << std::endl;
+// orxout(internal_error, context::network) << "Server. could not create client with id: " << clientID << endl;
// return false;
// }
-// COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+// orxout(verbose, context::network) << "Con.Man: creating client id: " << temp->getID() << endl;
// synchronise class ids
syncClassid(clientID);
@@ -410,8 +352,8 @@
// temp->setSynched(true);
GamestateManager::setSynched(clientID);
-
- COUT(4) << "sending welcome" << std::endl;
+
+ orxout(verbose, context::network) << "sending welcome" << endl;
packet::Welcome *w = new packet::Welcome(clientID);
w->setPeerID(clientID);
b = w->send( static_cast<Host*>(this) );
@@ -437,33 +379,52 @@
// ClientConnectionListener::broadcastClientDisconnected(client->getID()); // this is done in ClientInformation now
}
- bool Server::chat(const std::string& message)
+ /**
+ * @brief Sends a chat message to the given target ID.
+ * @param message message to be sent
+ * @param sourceID the ID of the sender
+ * @param targetID the ID of the receiver
+ */
+ void Server::doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- return this->sendChat(message, Host::getPlayerID());
+ // check if the target exists. just ignore the message otherwise
+ if (!this->isValidTarget(targetID)) // TODO: remove this if an invalid clientIDs don't trigger assertions anymore
+ return;
+
+ // send the message to the target
+ packet::Chat* packet = new packet::Chat(message, sourceID, targetID);
+ packet->setPeerID(targetID);
+ packet->send( static_cast<Host*>(this) );
+
+ // if the target is (or includes) this host as well, call the parent function which passes the message to the listeners
+ if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == Host::getPlayerID())
+ Host::doReceiveChat(message, sourceID, targetID);
}
- bool Server::broadcast(const std::string& message)
+ /**
+ * @brief Gets called if a packet::Chat packet is received. Forwards the packet to the target
+ * and calls the parent function if necessary.
+ */
+ void Server::doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID)
{
- return this->sendChat(message, NETWORK_PEER_ID_BROADCAST);
+ this->doSendChat(message, sourceID, targetID);
}
- bool Server::sendChat(const std::string& message, unsigned int clientID)
+ /**
+ * @brief Returns true if the target ID is in the list of clients (or if it
+ * corresponds to the broadcast or the server ID).
+ */
+ bool Server::isValidTarget(unsigned int targetID)
{
-// ClientInformation *temp = ClientInformation::getBegin();
- packet::Chat *chat;
-// while(temp)
- {
- chat = new packet::Chat(message, clientID);
- chat->setPeerID(NETWORK_PEER_ID_BROADCAST);
- chat->send( static_cast<Host*>(this) );
-// COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
-// temp = temp->next();
- }
-// COUT(1) << "Player " << Host::getPlayerID() << ": " << message << std::endl;
- for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
- it->incomingChat(message, clientID);
+ if (targetID == NETWORK_PEER_ID_BROADCAST || targetID == NETWORK_PEER_ID_SERVER)
+ return true;
- return true;
+ std::vector<uint32_t>::iterator it;
+ for( it=this->clientIDs_.begin(); it!=this->clientIDs_.end(); ++it )
+ if( *it == targetID )
+ return true;
+
+ return false;
}
void Server::syncClassid(unsigned int clientID)
@@ -475,7 +436,7 @@
failures++;
}
assert(failures<10);
- COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
+ orxout(verbose, context::network) << "syncClassid:\tall synchClassID packets have been sent" << endl;
}
}
Modified: code/trunk/src/libraries/network/Server.h
===================================================================
--- code/trunk/src/libraries/network/Server.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/Server.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -41,8 +41,6 @@
#include "ServerConnection.h"
#include "LANDiscoverable.h"
#include "WANDiscoverable.h"
-// #include "MasterServerComm.h"
-// #include "MasterServerProtocol.h"
namespace orxonox
@@ -60,14 +58,8 @@
Server(int port, const std::string& bindAddress);
~Server();
- /* helpers */
- void helper_ConnectToMasterserver();
- void helper_HandleMasterServerRequests();
- int replyhandler( char *addr, ENetEvent *ev );
-
void open();
void close();
- bool processChat(const std::string& message, unsigned int playerID);
void queuePacket(ENetPacket *packet, int clientID, uint8_t channelID);
virtual bool sendPacket( packet::Packet* packet ){ return packet->send( static_cast<Host*>(this) ); }
void update(const Clock& time);
@@ -88,9 +80,9 @@
void disconnectClient( uint32_t clientID );
bool sendGameStates();
bool sendObjectDeletes();
- virtual bool chat(const std::string& message);
- virtual bool broadcast(const std::string& message);
- bool sendChat(const std::string& message, unsigned int clientID);
+ bool isValidTarget(unsigned int targetID);
+ virtual void doSendChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
+ virtual void doReceiveChat(const std::string& message, unsigned int sourceID, unsigned int targetID);
void syncClassid(unsigned int clientID);
float timeSinceLastUpdate_;
Modified: code/trunk/src/libraries/network/ServerConnection.cc
===================================================================
--- code/trunk/src/libraries/network/ServerConnection.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/ServerConnection.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,7 +33,7 @@
#define WIN32_LEAN_AND_MEAN
#include <enet/enet.h>
-#include "util/Debug.h"
+#include "util/Output.h"
#include <util/Sleep.h>
// #include "ClientInformation.h"
@@ -60,7 +60,7 @@
void ServerConnection::setBindAddress( const std::string& bindAddress )
{
if (enet_address_set_host (this->bindAddress_, bindAddress.c_str()) < 0)
- COUT(1) << "Error: Could not resolve \"" << bindAddress << "\"." << std::endl;
+ orxout(internal_error, context::network) << "Could not resolve \"" << bindAddress << "\"." << endl;
}
void ServerConnection::setPort( unsigned int port ) {
@@ -74,7 +74,7 @@
if ( this->host_ == NULL )
{
- COUT(1) << "ServerConnection: host_ == NULL" << std::endl;
+ orxout(internal_error, context::network) << "ServerConnection: host_ == NULL" << endl;
return false;
}
@@ -82,11 +82,11 @@
this->enableCompression();
assert( this->host_->socket4 != ENET_SOCKET_NULL || this->host_->socket6 != ENET_SOCKET_NULL );
if (this->host_->socket4 == ENET_SOCKET_NULL)
- COUT(2) << "Warning: IPv4 Socket failed." << std::endl;
+ orxout(internal_warning, context::network) << "IPv4 Socket failed." << endl;
else if (this->host_->socket6 == ENET_SOCKET_NULL)
- COUT(2) << "Warning: IPv6 Socket failed." << std::endl;
+ orxout(internal_warning, context::network) << "IPv6 Socket failed." << endl;
else
- COUT(3) << "Info: Using IPv4 and IPv6 Sockets." << std::endl;
+ orxout(internal_info, context::network) << "Using IPv4 and IPv6 Sockets." << endl;
// start communication thread
Connection::startCommunicationThread();
@@ -113,7 +113,7 @@
{
// ClientInformation *temp = ClientInformation::findClient(clientID);
// if(!temp){
-// COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
+// orxout(internal_warning, context::network) << "C.Man: addPacket findClient failed" << endl;
// }
Connection::addPacket(packet, clientID, channelID);
}
Modified: code/trunk/src/libraries/network/TrafficControl.cc
===================================================================
--- code/trunk/src/libraries/network/TrafficControl.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/TrafficControl.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -286,9 +286,9 @@
void TrafficControl::printList(std::list<obj>& list, unsigned int clientID)
{
std::list<obj>::iterator it;
- COUT(0) << "=========== Objectlist ===========" << endl;
+ orxout(debug_output, context::network) << "=========== Objectlist ===========" << endl;
for( it=list.begin(); it!=list.end(); it++)
- COUT(0) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl;
+ orxout(debug_output, context::network) << "ObjectID: " << it->objID << " creatorID: " << it->objCreatorID << " Priority: " << clientListPerm_[clientID][it->objID].objValuePerm + clientListPerm_[clientID][it->objID].objValueSched << " size: " << it->objSize << endl;
}
void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj>& list, unsigned int clientID)
Modified: code/trunk/src/libraries/network/WANDiscoverable.cc
===================================================================
--- code/trunk/src/libraries/network/WANDiscoverable.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/WANDiscoverable.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -20,10 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau (original)
+ * Sandro 'smerkli' Merkli
* Co-authors:
- * Sandro 'smerkli' Merkli (adaptions to WAN)
- * ...
+ * Oliver Scheuss (original)
*
*/
@@ -43,7 +42,7 @@
WANDiscoverable::WANDiscoverable(): bActive_(false)
{
/* debugging output */
- COUT(4) << "Creating WANDiscoverable.\n";
+ orxout(verbose, context::master_server) << "Creating WANDiscoverable." << endl;
/* register object in orxonox */
RegisterObject(WANDiscoverable);
@@ -90,20 +89,20 @@
/* initialize it and see if it worked */
if( msc.initialize() )
{
- COUT(2) << "Error: could not initialize master server communications!\n";
+ orxout(internal_error, context::master_server) << "Could not initialize master server communications!" << endl;
return false;
}
/* connect and see if it worked */
if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) )
{
- COUT(2) << "Error: could not connect to master server at "
- << this->msaddress << std::endl;
+ orxout(internal_error, context::master_server) << "Could not connect to master server at "
+ << this->msaddress << endl;
return false;
}
/* debugging output */
- COUT(4) << "Initialization of WANDiscoverable complete.\n";
+ orxout(verbose, context::master_server) << "Initialization of WANDiscoverable complete." << endl;
// Now register the server at the master server
Modified: code/trunk/src/libraries/network/WANDiscoverable.h
===================================================================
--- code/trunk/src/libraries/network/WANDiscoverable.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/WANDiscoverable.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -18,8 +18,10 @@
* 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 (original) Co-authors: Sandro 'smerkli' Merkli
- * (copied and adapted to WAN)
+ * Author:
+ * Sandro 'smerkli' Merkli
+ * Co-authors:
+ * Oliver Scheuss (original)
*
*/
Modified: code/trunk/src/libraries/network/WANDiscovery.cc
===================================================================
--- code/trunk/src/libraries/network/WANDiscovery.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/WANDiscovery.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -20,10 +20,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau (original)
+ * Sandro 'smerkli' Merkli
* Co-authors:
- * Sandro 'smerkli' Merkli (adaptions to WAN)
- * ...
+ * Oliver Scheuss (original)
*
*/
@@ -32,19 +31,15 @@
#include <enet/enet.h>
#include <cstring>
-#include "util/ScopedSingletonManager.h"
#include "core/CoreIncludes.h"
namespace orxonox
{
- ManageScopedSingleton(WANDiscovery, ScopeID::Graphics, true);
-
-
WANDiscovery::WANDiscovery()
{
/* debugging output */
- COUT(4) << "Creating WANDiscovery.\n";
+ orxout(verbose, context::master_server) << "Creating WANDiscovery." << endl;
/* register object in orxonox */
RegisterObject(WANDiscovery);
@@ -54,15 +49,15 @@
/* initialize it and see if it worked */
if( msc.initialize() )
- COUT(2) << "Error: could not initialize master server communications!\n";
+ orxout(internal_error, context::master_server) << "Could not initialize master server communications!" << endl;
/* connect and see if it worked */
if( msc.connect( this->msaddress.c_str(), ORX_MSERVER_PORT ) )
- COUT(2) << "Error: could not connect to master server at "
- << this->msaddress << std::endl;
+ orxout(internal_error, context::master_server) << "Could not connect to master server at "
+ << this->msaddress << endl;
/* debugging output */
- COUT(4) << "Initialization of WANDiscovery complete.\n";
+ orxout(verbose, context::master_server) << "Initialization of WANDiscovery complete." << endl;
}
void WANDiscovery::setConfigValues()
@@ -80,11 +75,11 @@
}
/* callback for the network reply poller */
- int rhandler( char *addr, ENetEvent *ev )
+ int WANDiscovery::rhandler( char *addr, ENetEvent *ev )
{
/* error recognition */
if( !ev || !ev->packet || !ev->packet->data )
- { COUT(2) << "Bad arguments received in WANDiscovery's reply handler.\n";
+ { orxout(internal_warning, context::master_server) << "Bad arguments received in WANDiscovery's reply handler." << endl;
return 0;
}
@@ -103,7 +98,7 @@
MSPROTO_SERVERLIST_ITEM_LEN+1) );
/* add to list */
- WANDiscovery::getInstance().servers_.push_back( toadd );
+ this->servers_.push_back( toadd );
}
else if( !strncmp( (char*)ev->packet->data, MSPROTO_SERVERLIST_END,
MSPROTO_SERVERLIST_END_LEN ) )
@@ -132,7 +127,7 @@
while( i > 0 )
{
/* poll for reply and act according to what was received */
- switch( this->msc.pollForReply( rhandler, 500 ) )
+ switch( this->msc.pollForReply( this, 500 ) )
{ case 0: /* no event occured, decrease timeout */
--i; break;
case 1: /* got a list element, continue */
Modified: code/trunk/src/libraries/network/WANDiscovery.h
===================================================================
--- code/trunk/src/libraries/network/WANDiscovery.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/WANDiscovery.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -18,8 +18,10 @@
* 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 (original) Co-authors: Sandro 'smerkli' Merkli
- * (copied and adapted to WAN)
+ * Author:
+ * Sandro 'smerkli' Merkli
+ * Co-authors:
+ * Oliver Scheuss (original)
*
*/
@@ -29,7 +31,6 @@
#include "NetworkPrereqs.h"
#include "packet/ServerInformation.h"
#include "core/ConfigFileManager.h"
-#include "util/Singleton.h"
#include "core/OrxonoxClass.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
@@ -46,12 +47,11 @@
class _NetworkExport WANDiscovery
// tolua_end
- : public Singleton<WANDiscovery>, public OrxonoxClass
+ : public OrxonoxClass
{ // tolua_export
- friend class Singleton<WANDiscovery>;
public:
/** constructor */
- WANDiscovery();
+ WANDiscovery(); // tolua_export
/** destructor */
~WANDiscovery();
@@ -80,12 +80,6 @@
*/
std::string getServerListItemIP( unsigned int index ); // tolua_export
- /** \return an instance of WANDiscovery
- *
- * Create and return an instance of WANDiscovery.
- */
- static WANDiscovery& getInstance() { return Singleton<WANDiscovery>::getInstance(); } // tolua_export
-
/* todo: might make this private and use getter/setter methods
* at some later time.
*/
@@ -97,11 +91,10 @@
/** Master server communications object */
MasterServerComm msc;
+
+ int rhandler( char *addr, ENetEvent *ev );
private:
- /** Singleton pointer */
- static WANDiscovery* singletonPtr_s;
-
/** master server address */
std::string msaddress;
Modified: code/trunk/src/libraries/network/packet/Acknowledgement.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Acknowledgement.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/Acknowledgement.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -28,7 +28,7 @@
#include "Acknowledgement.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "network/GamestateHandler.h"
#include "network/Host.h"
@@ -63,7 +63,7 @@
}
bool Acknowledgement::process(orxonox::Host* host){
- COUT(5) << "processing ACK with ID: " << getAckID() << endl;
+ orxout(verbose_more, context::packets) << "processing ACK with ID: " << getAckID() << endl;
bool b = host->ackGamestate(getAckID(), peerID_);
delete this;
return b;
Modified: code/trunk/src/libraries/network/packet/Chat.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Chat.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/Chat.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -38,12 +38,13 @@
#define PACKET_FLAGS_CHAT PacketFlag::Reliable
/* Some lengths */
-#define _PACKETID 0
-const int _PLAYERID = _PACKETID + sizeof(Type::Value);
-#define _MESSAGELENGTH _PLAYERID + sizeof(uint32_t)
-#define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t)
+#define _PACKETID 0
+#define _SOURCEID _PACKETID + sizeof(Type::Value)
+#define _TARGETID _SOURCEID + sizeof(uint32_t)
+#define _MESSAGELENGTH _TARGETID + sizeof(uint32_t)
+#define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t)
-Chat::Chat( const std::string& message, unsigned int playerID )
+Chat::Chat( const std::string& message, unsigned int sourceID, unsigned int targetID )
: Packet()
{
/* Add chat flag to packet flags */
@@ -56,7 +57,8 @@
data_=new unsigned char[ getSize() ];
*(Type::Value *)(data_ + _PACKETID ) = Type::Chat;
- *(unsigned int *)(data_ + _PLAYERID ) = playerID;
+ *(unsigned int *)(data_ + _SOURCEID ) = sourceID;
+ *(unsigned int *)(data_ + _TARGETID ) = targetID;
*(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
/* cast the hell out of the message string, and copy it into the
@@ -80,9 +82,9 @@
}
bool Chat::process(orxonox::Host* host){
- bool b = host->incomingChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_PLAYERID));
+ host->doReceiveChat(std::string((const char*)data_+_MESSAGE), *(uint32_t *)(data_+_SOURCEID), *(uint32_t *)(data_+_TARGETID));
delete this;
- return b;
+ return true;
}
unsigned char *Chat::getMessage(){
Modified: code/trunk/src/libraries/network/packet/Chat.h
===================================================================
--- code/trunk/src/libraries/network/packet/Chat.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/Chat.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -41,7 +41,7 @@
{
public:
/* constructors */
- Chat( const std::string& message, unsigned int playerID );
+ Chat( const std::string& message, unsigned int sourceID, unsigned int targetID );
Chat( uint8_t* data, unsigned int clientID );
/* destructor */
Modified: code/trunk/src/libraries/network/packet/ClassID.cc
===================================================================
--- code/trunk/src/libraries/network/packet/ClassID.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/ClassID.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -91,7 +91,7 @@
}
assert(tempsize==packetSize);
- COUT(5) << "classid packetSize is " << packetSize << endl;
+ orxout(verbose_more, context::packets) << "classid packetSize is " << packetSize << endl;
}
@@ -130,7 +130,7 @@
//clear the map of network ids
Identifier::clearNetworkIDs();
- COUT(4) << "=== processing classids: " << endl;
+ orxout(verbose, context::packets) << "=== processing classids: " << endl;
std::pair<uint32_t, std::string> tempPair;
Identifier *id;
// read the total number of classes
@@ -142,9 +142,9 @@
stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
classname = temp+2*sizeof(uint32_t);
id=ClassByString( std::string((const char*)classname) );
- COUT(3) << "processing classid: " << networkID << " name: " << classname << " id: " << id << std::endl;
+ orxout(internal_info, context::packets) << "processing classid: " << networkID << " name: " << classname << " id: " << id << endl;
if(id==NULL){
- COUT(0) << "Received a bad classname" << endl;
+ orxout(user_error, context::packets) << "Received a bad classname" << endl;
abort();
}
id->setNetworkID( networkID );
Modified: code/trunk/src/libraries/network/packet/DeleteObjects.cc
===================================================================
--- code/trunk/src/libraries/network/packet/DeleteObjects.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/DeleteObjects.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -30,7 +30,7 @@
#include "DeleteObjects.h"
#include <cassert>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "network/synchronisable/Synchronisable.h"
namespace orxonox {
@@ -61,7 +61,7 @@
unsigned int number = Synchronisable::getNumberOfDeletedObject();
if(number==0)
return false;
- COUT(4) << "sending DeleteObjects: ";
+ orxout(verbose, context::packets) << "sending DeleteObjects: ";
unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1);
data_ = new uint8_t[size];
uint8_t *tdata = data_;
@@ -72,10 +72,10 @@
for(unsigned int i=0; i<number; i++){
unsigned int temp = Synchronisable::popDeletedObject();
*reinterpret_cast<uint32_t*>(tdata) = temp;
- COUT(4) << temp << ' ';
+ orxout(verbose, context::packets) << temp << ' ';
tdata += sizeof(uint32_t);
}
- COUT(4) << std::endl;
+ orxout(verbose, context::packets) << endl;
return true;
}
@@ -89,7 +89,7 @@
{
for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++)
{
- COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;
+ orxout(verbose, context::packets) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << endl;
Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
}
delete this;
Modified: code/trunk/src/libraries/network/packet/FunctionIDs.cc
===================================================================
--- code/trunk/src/libraries/network/packet/FunctionIDs.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/FunctionIDs.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,7 +33,7 @@
#include <queue>
#include <string>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "core/ObjectList.h"
#include "network/NetworkFunction.h"
@@ -87,7 +87,7 @@
temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
}
- COUT(5) << "FunctionIDs packetSize is " << packetSize << endl;
+ orxout(verbose_more, context::packets) << "FunctionIDs packetSize is " << packetSize << endl;
}
@@ -125,7 +125,7 @@
uint32_t stringsize;
unsigned char *functionname;
- COUT(4) << "=== processing functionids: " << endl;
+ orxout(verbose, context::packets) << "=== processing functionids: " << endl;
std::pair<uint32_t, std::string> tempPair;
// read the total number of classes
nrOfFunctions = *(uint32_t*)temp;
@@ -136,7 +136,7 @@
networkID = *(uint32_t*)temp;
stringsize = *(uint32_t*)(temp+sizeof(uint32_t));
functionname = temp+2*sizeof(uint32_t);
- COUT(3) << "processing functionid: " << networkID << " name: " << functionname << std::endl;
+ orxout(internal_info, context::packets) << "processing functionid: " << networkID << " name: " << functionname << endl;
NetworkFunctionBase::setNetworkID((const char*)functionname, networkID);
temp += 2*sizeof(uint32_t) + stringsize;
}
Modified: code/trunk/src/libraries/network/packet/Gamestate.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Gamestate.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/Gamestate.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -30,7 +30,7 @@
#include <zlib.h>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "util/OrxAssert.h"
#include "core/GameMode.h"
#include "core/ObjectList.h"
@@ -107,13 +107,13 @@
assert(data_==0);
uint32_t size = calcGamestateSize(id, mode);
- COUT(5) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
+ orxout(verbose_more, context::packets) << "G.ST.Man: producing gamestate with id: " << id << endl;
if(size==0)
return false;
data_ = new uint8_t[size + GamestateHeader::getSize()];
if(!data_)
{
- COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
+ orxout(internal_warning, context::packets) << "GameStateManager: could not allocate memory" << endl;
return false;
}
@@ -138,7 +138,7 @@
{
assert(0); // if we don't use multithreading this part shouldn't be neccessary
// start allocate additional memory
- COUT(3) << "Gamestate: need additional memory" << std::endl;
+ orxout(internal_info, context::packets) << "Gamestate: need additional memory" << endl;
ObjectList<Synchronisable>::iterator temp = it;
uint32_t addsize=tempsize;
while(++temp)
@@ -166,15 +166,15 @@
header_.setCompressed( false );
//stop write gamestate header
- COUT(5) << "Gamestate: Gamestate size: " << currentsize << std::endl;
- COUT(5) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
+ orxout(verbose_more, context::packets) << "Gamestate: Gamestate size: " << currentsize << endl;
+ orxout(verbose_more, context::packets) << "Gamestate: 'estimated' (and corrected) Gamestate size: " << size << endl;
return true;
}
bool Gamestate::spreadData(uint8_t mode)
{
- COUT(5) << "processing gamestate with id " << header_.getID() << endl;
+ orxout(verbose_more, context::packets) << "processing gamestate with id " << header_.getID() << endl;
assert(data_);
assert(!header_.isCompressed());
uint8_t *mem=data_+GamestateHeader::getSize();
@@ -194,13 +194,13 @@
}
else
{
-// COUT(4) << "not creating object of classid " << objectheader.getClassID() << endl;
+// orxout(verbose, context::packets) << "not creating object of classid " << objectheader.getClassID() << endl;
mem += objectheader.getDataSize() + ( objectheader.isDiffed() ? SynchronisableHeaderLight::getSize() : SynchronisableHeader::getSize() );
}
}
else
{
-// COUT(4) << "updating object of classid " << objectheader.getClassID() << endl;
+// orxout(verbose, context::packets) << "updating object of classid " << objectheader.getClassID() << endl;
OrxVerify(s->updateData(mem, mode), "ERROR: could not update Synchronisable with Gamestate data");
}
}
@@ -218,9 +218,9 @@
{
if (it->objectMode_ != 0x0)
{
- COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
- COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
- COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
+ orxout(user_error, context::packets) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << endl;
+ orxout(user_error, context::packets) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << endl;
+ orxout(user_error, context::packets) << "Objects class: " << it->getIdentifier()->getName() << endl;
assert(false);
}
}
@@ -231,9 +231,9 @@
{
if (it->getObjectID() == *it2)
{
- COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
- << "Are you sure you don't create a Sychnronisable objcect with 'new' \
- that doesn't have objectMode = 0x0?" << std::endl;
+ orxout(user_error, context::packets) << "Found duplicate objectIDs on the client!" << endl
+ << "Are you sure you don't create a Sychnronisable objcect with 'new' \
+ that doesn't have objectMode = 0x0?" << endl;
assert(false);
}
}
@@ -292,10 +292,10 @@
retval = compress( dest, &buffer, source, (uLong)(header_.getDataSize()) );
switch ( retval )
{
- case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
- case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; return false;
- case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; return false;
- case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;
+ case Z_OK: orxout(verbose_more, context::packets) << "G.St.Man: compress: successfully compressed" << endl; break;
+ case Z_MEM_ERROR: orxout(internal_error, context::packets) << "G.St.Man: compress: not enough memory available in gamestate.compress" << endl; return false;
+ case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << endl; return false;
+ case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "G.St.Man: compress: data corrupted in gamestate.compress" << endl; return false;
}
//copy and modify header
@@ -309,7 +309,7 @@
data_ = ndata;
header_.setCompSize( buffer );
header_.setCompressed( true );
- COUT(4) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << std::endl;
+ orxout(verbose, context::packets) << "gamestate compress datasize: " << header_.getDataSize() << " compsize: " << header_.getCompSize() << endl;
return true;
}
@@ -318,7 +318,7 @@
{
assert(data_);
assert(header_.isCompressed());
- COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << std::endl;
+ orxout(verbose, context::packets) << "GameStateClient: uncompressing gamestate. id: " << header_.getID() << ", baseid: " << header_.getBaseID() << ", datasize: " << header_.getDataSize() << ", compsize: " << header_.getCompSize() << endl;
uint32_t datasize = header_.getDataSize();
uint32_t compsize = header_.getCompSize();
uint32_t bufsize;
@@ -332,10 +332,10 @@
retval = uncompress( dest, &length, source, (uLong)compsize );
switch ( retval )
{
- case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;
- case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return false;
- case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return false;
- case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
+ case Z_OK: orxout(verbose_more, context::packets) << "successfully decompressed" << endl; break;
+ case Z_MEM_ERROR: orxout(internal_error, context::packets) << "not enough memory available" << endl; return false;
+ case Z_BUF_ERROR: orxout(internal_warning, context::packets) << "not enough memory available in the buffer" << endl; return false;
+ case Z_DATA_ERROR: orxout(internal_warning, context::packets) << "data corrupted (zlib)" << endl; return false;
}
//copy over the header
@@ -374,7 +374,7 @@
// Check whether the whole object stayed the same
if( memcmp( origDataPtr+objectOffset, baseDataPtr+objectOffset, objectHeader.getDataSize()) == 0 )
{
-// COUT(4) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
+// orxout(verbose, context::packets) << "skip object " << Synchronisable::getSynchronisable(objectHeader.getObjectID())->getIdentifier()->getName() << endl;
origDataPtr += objectOffset + objectHeader.getDataSize(); // skip the whole object
baseDataPtr += objectOffset + objectHeader.getDataSize();
sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
@@ -430,7 +430,7 @@
inline void /*Gamestate::*/copyObject( uint8_t*& newData, uint8_t*& origData, uint8_t*& baseData, SynchronisableHeader& objectHeader, std::vector<uint32_t>::iterator& sizes )
{
- // COUT(4) << "docopy" << endl;
+ // orxout(verbose, context::packets) << "docopy" << endl;
// Just copy over the whole Object
memcpy( newData, origData, objectHeader.getDataSize()+SynchronisableHeader::getSize() );
SynchronisableHeader(newData).setDiffed(false);
@@ -439,15 +439,15 @@
origData += objectHeader.getDataSize()+SynchronisableHeader::getSize();
// SynchronisableHeader baseHeader( baseData );
// baseData += baseHeader.getDataSize()+SynchronisableHeader::getSize();
- // COUT(4) << "copy " << h.getObjectID() << endl;
- // COUT(4) << "copy " << h.getObjectID() << ":";
+ // orxout(verbose, context::packets) << "copy " << h.getObjectID() << endl;
+ // orxout(verbose, context::packets) << "copy " << h.getObjectID() << ":";
sizes += Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables();
// for( unsigned int i = 0; i < Synchronisable::getSynchronisable(objectHeader.getObjectID())->getNrOfVariables(); ++i )
// {
-// // COUT(4) << " " << *sizes;
+// // orxout(verbose, context::packets) << " " << *sizes;
// ++sizes;
// }
- // COUT(4) << endl;
+ // orxout(verbose, context::packets) << endl;
}
inline bool findObject(uint8_t*& dataPtr, uint8_t* endPtr, SynchronisableHeader& objectHeader)
@@ -540,13 +540,13 @@
assert(baseHeader.getDataSize() < 500);
if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
{
-// COUT(4) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
+// orxout(verbose, context::packets) << "diffing object in order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
diffedObject = true;
}
else
{
-// COUT(4) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
+// orxout(verbose, context::packets) << "copy object because of different data sizes (1): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
}
@@ -564,20 +564,20 @@
assert(baseHeader.getDataSize() < 500);
if( SynchronisableHeader(baseDataPtr).getDataSize()==origHeader.getDataSize() )
{
-// COUT(4) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
+// orxout(verbose, context::packets) << "diffing object out of order: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
diffObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
diffedObject = true;
}
else
{
-// COUT(4) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
+// orxout(verbose, context::packets) << "copy object because of different data sizes (2): " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
}
}
else
{
-// COUT(4) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
+// orxout(verbose, context::packets) << "copy object: " << Synchronisable::getSynchronisable(origHeader.getObjectID())->getIdentifier()->getName() << endl;
assert(baseDataPtr == oldBaseDataPtr);
copyObject(destDataPtr, origDataPtr, baseDataPtr, origHeader, sizesIt);
assert(sizesIt != this->sizes_.end() || origDataPtr==origDataEnd);
@@ -717,10 +717,10 @@
//copy in the zeros
// std::list<obj>::iterator itt;
-// COUT(0) << "myvector contains:";
+// orxout() << "myvector contains:";
// for ( itt=dataVector_.begin() ; itt!=dataVector_.end(); itt++ )
-// COUT(0) << " " << (*itt).objID;
-// COUT(0) << endl;
+// orxout() << " " << (*itt).objID;
+// orxout() << endl;
for(it=dataVector_.begin(); it!=dataVector_.end();){
SynchronisableHeader oldobjectheader(origdata);
SynchronisableHeader newobjectheader(newdata);
@@ -770,7 +770,7 @@
size+=it->getSize(id, mode); // size of the actual data of the synchronisable
nrOfVariables += it->getNrOfVariables();
}
-// COUT(0) << "allocating " << nrOfVariables << " ints" << endl;
+// orxout() << "allocating " << nrOfVariables << " ints" << endl;
this->sizes_.reserve(nrOfVariables);
return size;
}
Modified: code/trunk/src/libraries/network/packet/Packet.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Packet.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/Packet.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -36,7 +36,7 @@
#include <boost/static_assert.hpp>
#include <boost/thread/mutex.hpp>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "Acknowledgement.h"
#include "Chat.h"
#include "ClassID.h"
@@ -191,39 +191,39 @@
// if( peerID==static_cast<unsigned int>(-2))
// peerID = NETWORK_PEER_ID_SERVER;
Packet *p = 0;
-// COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
+// orxout(verbose_ultra, context::packets) << "packet type: " << *(Type::Value *)&data[_PACKETID] << endl;
switch( *(Type::Value *)(data + _PACKETID) )
{
case Type::Acknowledgement:
-// COUT(5) << "ack" << std::endl;
+// orxout(verbose_more, context::packets) << "ack" << endl;
p = new Acknowledgement( data, peerID );
break;
case Type::Chat:
-// COUT(5) << "chat" << std::endl;
+// orxout(verbose_more, context::packets) << "chat" << endl;
p = new Chat( data, peerID );
break;
case Type::ClassID:
-// COUT(5) << "classid" << std::endl;
+// orxout(verbose_more, context::packets) << "classid" << endl;
p = new ClassID( data, peerID );
break;
case Type::Gamestate:
-// COUT(5) << "gamestate" << std::endl;
+// orxout(verbose_more, context::packets) << "gamestate" << endl;
p = new Gamestate( data, peerID );
break;
case Type::Welcome:
-// COUT(5) << "welcome" << std::endl;
+// orxout(verbose_more, context::packets) << "welcome" << endl;
p = new Welcome( data, peerID );
break;
case Type::DeleteObjects:
-// COUT(5) << "deleteobjects" << std::endl;
+// orxout(verbose_more, context::packets) << "deleteobjects" << endl;
p = new DeleteObjects( data, peerID );
break;
case Type::FunctionCalls:
-// COUT(5) << "functionCalls" << std::endl;
+// orxout(verbose_more, context::packets) << "functionCalls" << endl;
p = new FunctionCalls( data, peerID );
break;
case Type::FunctionIDs:
-// COUT(5) << "functionIDs" << std::endl;
+// orxout(verbose_more, context::packets) << "functionIDs" << endl;
p = new FunctionIDs( data, peerID );
break;
default:
@@ -254,7 +254,7 @@
delete it->second;
packetMap_.erase(it);
Packet::packetMapMutex_.unlock();
-// COUT(6) << "PacketMap size: " << packetMap_.size() << std::endl;
+// orxout(verbose_ultra, context::packets) << "PacketMap size: " << packetMap_.size() << endl;
}
} // namespace packet
Modified: code/trunk/src/libraries/network/packet/Welcome.cc
===================================================================
--- code/trunk/src/libraries/network/packet/Welcome.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/packet/Welcome.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,7 +31,7 @@
#include "Welcome.h"
#include <cassert>
-#include "util/Debug.h"
+#include "util/Output.h"
#include "network/Host.h"
#include "network/synchronisable/Synchronisable.h"
@@ -77,7 +77,7 @@
clientID = *(uint32_t *)(data_ + _CLIENTID );
assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
host->setClientID(clientID);
- COUT(3) << "Welcome set clientId: " << clientID << endl;
+ orxout(internal_info, context::packets) << "Welcome set clientId: " << clientID << endl;
Synchronisable::setClient(true);
delete this;
return true;
Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -129,15 +129,15 @@
}
// assert( !header.isDiffed() );
- COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl;
+ orxout(verbose, context::network) << "fabricating object with id: " << header.getObjectID() << endl;
Identifier* id = ClassByID(header.getClassID());
if (!id)
{
for(int i = 0; i<160; i++)
- COUT(0) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
- COUT(0) << "Assertion failed: id" << std::endl;
- COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl;
+ orxout(user_error, context::network) << "classid: " << i << " identifier: " << ClassByID(i) << endl;
+ orxout(user_error, context::network) << "Assertion failed: id" << endl;
+ orxout(user_error, context::network) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << endl;
abort();
}
assert(id);
@@ -167,7 +167,7 @@
if( creator )
bo->setLevel(creator->getLevel()); // Note: this ensures that the level is known on the client for child objects of the scene (and the scene itself)
//assert(no->classID_ == header.getClassID());
- COUT(4) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << std::endl;
+ orxout(verbose, context::network) << "fabricate objectID_: " << no->objectID_ << " classID_: " << no->classID_ << endl;
// update data and create object/entity...
bool b = no->updateData(mem, mode, true);
assert(b);
@@ -241,7 +241,7 @@
#ifndef NDEBUG
uint8_t* oldmem = mem;
if (this->classID_==0)
- COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+ orxout(internal_info, context::network) << "classid 0 " << this->getIdentifier()->getName() << endl;
#endif
if (this->classID_ == static_cast<uint32_t>(-1))
@@ -257,20 +257,20 @@
mem += SynchronisableHeader::getSize();
// end copy header
- CCOUT(5) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << std::endl;
-// COUT(4) << "objectid: " << this->objectID_ << ":";
+ orxout(verbose_more, context::network) << "getting data from objectID_: " << objectID_ << ", classID_: " << classID_ << endl;
+// orxout(verbose, context::network) << "objectid: " << this->objectID_ << ":";
// copy to location
for(i=syncList_.begin(); i!=syncList_.end(); ++i)
{
uint32_t varsize = (*i)->getData( mem, mode );
-// COUT(4) << " " << varsize;
+// orxout(verbose, context::network) << " " << varsize;
tempsize += varsize;
sizes.push_back(varsize);
++test;
//tempsize += (*i)->getSize( mode );
}
assert(tempsize!=0); // if this happens an empty object (with no variables) would be transmitted
-// COUT(4) << endl;
+// orxout(verbose, context::network) << endl;
header.setObjectID( this->objectID_ );
header.setCreatorID( this->creatorID_ );
@@ -304,8 +304,8 @@
if(syncList_.empty())
{
+ orxout(internal_warning, context::network) << "Synchronisable::updateData syncList_ is empty" << endl;
assert(0);
- COUT(2) << "Synchronisable::updateData syncList_ is empty" << std::endl;
return false;
}
@@ -325,7 +325,7 @@
return true;
}
- //COUT(5) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
+ //orxout(verbose_more, context::network) << "Synchronisable: objectID_ " << syncHeader.getObjectID() << ", classID_ " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << endl;
if( !syncHeaderLight.isDiffed() )
{
SynchronisableHeader syncHeader2(mem);
@@ -343,11 +343,11 @@
else
{
mem += SynchronisableHeaderLight::getSize();
-// COUT(0) << "objectID: " << this->objectID_ << endl;
+// orxout(debug_output, context::network) << "objectID: " << this->objectID_ << endl;
while( mem < data+syncHeaderLight.getDataSize()+SynchronisableHeaderLight::getSize() )
{
VariableID varID = *(VariableID*)mem;
-// COUT(0) << "varID: " << varID << endl;
+// orxout(debug_output, context::network) << "varID: " << varID << endl;
assert( varID < syncList_.size() );
mem += sizeof(VariableID);
syncList_[varID]->putData( mem, mode, forceCallback );
Modified: code/trunk/src/libraries/network/synchronisable/Synchronisable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/Synchronisable.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/synchronisable/Synchronisable.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -231,7 +231,7 @@
else
it++;
}
- COUT(1) << "Tried to unregister not registered variable" << endl;
+ orxout(internal_error, context::network) << "Tried to unregister not registered variable" << endl;
assert(false); //if we reach this point something went wrong:
// the variable has not been registered before
}
Modified: code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h
===================================================================
--- code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/network/synchronisable/SynchronisableVariable.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -201,7 +201,7 @@
// check that the client (source of the data) has a recent version of this variable
if ( *static_cast<uint8_t*>(mem) != this->varReference_ )
{ // wrong reference number, so discard the data
-// COUT(0) << "discharding data" << endl;
+// orxout(debug_output, context::network) << "discharding data" << endl;
mem += getSize( mode ); // SynchronisableVariableBidirectional::getSize returns size of variable + reference
return;
}
Modified: code/trunk/src/libraries/tools/BillboardSet.cc
===================================================================
--- code/trunk/src/libraries/tools/BillboardSet.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/BillboardSet.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -79,7 +79,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;
+ orxout(internal_error) << "Couldn't load billboard \"" << file << '"' << endl;
this->billboardSet_ = 0;
}
@@ -102,7 +102,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load billboard \"" << file << '"' << std::endl;
+ orxout(internal_error) << "Couldn't load billboard \"" << file << '"' << endl;
this->billboardSet_ = 0;
}
Modified: code/trunk/src/libraries/tools/Mesh.cc
===================================================================
--- code/trunk/src/libraries/tools/Mesh.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/Mesh.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -71,7 +71,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load mesh \"" << meshsource << '"' << std::endl;
+ orxout(internal_error) << "Couldn't load mesh \"" << meshsource << '"' << endl;
this->entity_ = 0;
}
}
Modified: code/trunk/src/libraries/tools/ParticleInterface.cc
===================================================================
--- code/trunk/src/libraries/tools/ParticleInterface.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/ParticleInterface.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -77,7 +77,7 @@
}
catch (...)
{
- COUT(1) << "Error: Couln't load particle system \"" << templateName << '"' << std::endl;
+ orxout(internal_error) << "Couldn't load particle system \"" << templateName << '"' << endl;
this->particleSystem_ = 0;
}
}
Modified: code/trunk/src/libraries/tools/ResourceCollection.cc
===================================================================
--- code/trunk/src/libraries/tools/ResourceCollection.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/ResourceCollection.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -61,7 +61,7 @@
{
if (resourceGroup.empty())
{
- COUT(2) << "Warning: \"\" is not a valid resource group." << std::endl;
+ orxout(internal_warning) << "\"\" is not a valid resource group." << endl;
return;
}
if (!resourceLocations_.empty())
Modified: code/trunk/src/libraries/tools/ResourceLocation.cc
===================================================================
--- code/trunk/src/libraries/tools/ResourceLocation.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/ResourceLocation.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -79,7 +79,7 @@
path = PathConfig::getExternalDataPath() / this->getPath();
else
{
- COUT(2) << "Warning: ResourceLocation '" << this->getPath() << "' does not seem to exist" << std::endl;
+ orxout(internal_warning) << "ResourceLocation '" << this->getPath() << "' does not seem to exist" << endl;
return;
}
@@ -100,7 +100,7 @@
}
catch (const Ogre::Exception& ex)
{
- COUT(1) << "Removing of a ResourceLocation failed: " << ex.what() << std::endl;
+ orxout(internal_error) << "Removing of a ResourceLocation failed: " << ex.what() << endl;
}
}
}
Modified: code/trunk/src/libraries/tools/Shader.cc
===================================================================
--- code/trunk/src/libraries/tools/Shader.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/Shader.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -140,7 +140,7 @@
Ogre::CompositorManager::getSingleton().setCompositorEnabled(viewport, this->compositorName_, this->isVisible() && viewport->getCamera() && this->scenemanager_ == viewport->getCamera()->getSceneManager());
}
else
- COUT(2) << "Warning: Couldn't load compositor with name \"" << this->compositorName_ << "\"." << std::endl;
+ orxout(internal_warning) << "Couldn't load compositor with name \"" << this->compositorName_ << "\"." << endl;
}
this->oldcompositorName_ = this->compositorName_;
}
@@ -216,10 +216,10 @@
}
}
else
- COUT(2) << "Warning: No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << std::endl;
+ orxout(internal_warning) << "No pass " << it->pass_ << " in technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or pass has no shader." << endl;
}
else
- COUT(2) << "Warning: No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << std::endl;
+ orxout(internal_warning) << "No technique " << it->technique_ << " in compositor \"" << this->compositorName_ << "\" or technique has no pass with shader." << endl;
}
this->parameters_.clear();
}
Modified: code/trunk/src/libraries/tools/Timer.h
===================================================================
--- code/trunk/src/libraries/tools/Timer.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/tools/Timer.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -65,7 +65,7 @@
void MyClass::myFunction()
{
- COUT(0) << "Hello World" << std::endl;
+ orxout() << "Hello World" << endl;
}
@endcode
Modified: code/trunk/src/libraries/util/CMakeLists.txt
===================================================================
--- code/trunk/src/libraries/util/CMakeLists.txt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -25,7 +25,6 @@
Convert.cc
CRC32.cc
ExprParser.cc
- OutputHandler.cc
Scope.cc
ScopedSingletonManager.cc
SharedPtr.cc
@@ -41,6 +40,8 @@
StringUtils.cc
)
+ADD_SUBDIRECTORY(output)
+
ORXONOX_ADD_LIBRARY(util
FIND_HEADER_FILES
LINK_LIBRARIES
Modified: code/trunk/src/libraries/util/Clipboard.cc
===================================================================
--- code/trunk/src/libraries/util/Clipboard.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Clipboard.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -47,7 +47,7 @@
#include <windows.h>
#undef min
#undef max
-#include "Debug.h"
+#include "Output.h"
namespace orxonox
{
@@ -75,8 +75,8 @@
}
catch (...)
{
- COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
- COUT(1) << " \"" << text << '"' << std::endl;
+ orxout(user_error) << "Unable to copy the following text to the clipboard:" << endl;
+ orxout(user_error) << '"' << text << '"' << endl;
}
return false;
}
@@ -103,7 +103,7 @@
}
catch (...)
{
- COUT(1) << "Error: Unable to retrieve text from the clipboard." << std::endl;
+ orxout(user_error) << "Unable to retrieve text from the clipboard." << endl;
}
return "";
}
Modified: code/trunk/src/libraries/util/Convert.h
===================================================================
--- code/trunk/src/libraries/util/Convert.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Convert.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -129,7 +129,7 @@
#include <typeinfo>
#include <loki/TypeManip.h>
-#include "Debug.h"
+#include "Output.h"
#include "ImplicitConversion.h"
// disable warnings about possible loss of data
@@ -150,8 +150,8 @@
{
ORX_FORCEINLINE static bool convert(ToType* /*output*/, const FromType& /*input*/)
{
- COUT(2) << "Could not convert value of type " << typeid(FromType).name()
- << " to type " << typeid(ToType).name() << std::endl;
+ orxout(internal_warning) << "Could not convert value of type " << typeid(FromType).name()
+ << " to type " << typeid(ToType).name() << endl;
return false;
}
};
Deleted: code/trunk/src/libraries/util/Debug.h
===================================================================
--- code/trunk/src/libraries/util/Debug.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Debug.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,131 +0,0 @@
-/*
- * 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
- * Reto Grieder
- * Co-authors:
- * ...
- *
- */
-
-/**
- @defgroup COUT COUT(x) output macro
- @ingroup Util
-*/
-
-/**
- at file
- at ingroup COUT
- at brief
- Handles different output-levels of errors, warnings, infos, and debug information.
-
- The COUT(level) macro acts like @c std::cout, but the output is only performed if the given
- level is <= the soft debug level.
-
- There are two used values in this file:
- - The hard debug level is used during compile time. It describes the highest allowed output level.
- - The soft debug level is used during runtime and is the maximum of the three configurable
- output-levels for console, log file, and in game shell.
-
- The separation between the three devices is done by the OutputHandler.
-
- @anchor COUTlevels
- Possible levels are:
- - 0: Very important output
- - 1: Errors
- - 2: Warnings
- - 3: Information
- - 4: Debug information
- - 5: More debug information
- - 6: Crazy debug information
-
- Example:
- @code
- COUT(0) << "Very important output" << std::endl;
- COUT(1) << "Error: Something went wrong!" << std::endl;
- COUT(2) << "Warning: There might be a problem." << std::endl;
- COUT(3) << "Info: It's Monday" << std::endl;
- COUT(4) << "Debug: x is 1.23456" << std::endl;
- @endcode
-*/
-
-#ifndef _Util_Debug_H__
-#define _Util_Debug_H__
-
-#include "UtilPrereqs.h"
-#include "OutputHandler.h"
-
-namespace orxonox
-{
- // Just for convenience
- using std::endl;
-
- // Adjust this to discard certain output with level > hardDebugLevel at compile time already
-#ifdef ORXONOX_RELEASE
- const int hardDebugLevel = OutputLevel::Verbose;
-#else
- //! Maximum level for debug output that should be even processed at run time
- const int hardDebugLevel = OutputLevel::Ultra;
-#endif
-
- //! This function simply returns 0 and helps to suppress the "statement has no effect" compiler warning
- inline int debugDummyFunction()
- {
- return 0;
- }
-}
-
-/**
- at brief
- Logs text output: You can use COUT(level) exactly like @c std::cout, but you have to specify an output level as argument.
- at param level
- The level of the following output (passed with <tt><< "text"</tt>). Lower levels are more important. See @ref COUTlevels "the description above" for a list of possible output levels.
-
- Example:
- @code
- COUT(3) << "Some info" << std::endl; // Output with level 3
- @endcode
- at note
- <tt>(a > b ? 0 : c << "text")</tt> is equivalent to <tt>(a > b ? 0 : (c << "text")</tt>
- where <tt>(a > b ? 0 : )</tt> stands for COUT(x). This should explain how
- this macro magic can possibly even work ;)
- at remarks
- The <tt>? :</tt> operator requires both possible results to have the type of
- the first. This is achieved by the int conversion operator dummy
- in the @ref orxonox::OutputHandler.
-*/
-#define COUT(level) \
- /*if*/ (level > orxonox::hardDebugLevel) ? \
- orxonox::debugDummyFunction() \
- /*else*/ : \
- /*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
- orxonox::debugDummyFunction() \
- /*else*/ : \
- orxonox::OutputHandler::getOutStream(level)
-
-/** Logs debug output: You can use DOUT exactly like @c std::cout.
- Use this macro to produce temporary debug output that will be removed later on.
- The console output shall have a special colour if available.
-*/
-#define DOUT orxonox::OutputHandler::getOutStream(-1) << "+++ "
-
-#endif /* _Util_Debug_H__ */
Modified: code/trunk/src/libraries/util/Exception.cc
===================================================================
--- code/trunk/src/libraries/util/Exception.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Exception.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -36,7 +36,7 @@
#include <cstddef>
#include <CEGUIExceptions.h>
-#include "Debug.h"
+#include "Output.h"
namespace orxonox
{
@@ -110,8 +110,8 @@
}
catch (...)
{
- COUT(0) << "BIG WARNING: Unknown exception type encountered."
- << "Rethrowing" << endl;
+ orxout(user_error) << "BIG WARNING: Unknown exception type encountered."
+ << " Rethrowing" << endl;
throw;
}
}
Modified: code/trunk/src/libraries/util/Exception.h
===================================================================
--- code/trunk/src/libraries/util/Exception.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Exception.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -62,7 +62,7 @@
#include <exception>
#include <sstream>
#include <string>
-#include "Debug.h"
+#include "Output.h"
namespace orxonox
{
@@ -175,8 +175,8 @@
template <class T>
inline const T& exceptionThrowerHelper(const T& exception)
{
- // let the catcher decide whether to display the message below level 4
- COUT(4) << exception.getFullDescription() << std::endl;
+ // let the catcher decide whether to display the message also to the user
+ orxout(internal_error) << exception.getFullDescription() << endl;
return exception;
}
Modified: code/trunk/src/libraries/util/ExprParser.h
===================================================================
--- code/trunk/src/libraries/util/ExprParser.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/ExprParser.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -54,12 +54,12 @@
{
if (!expr.getRemains().empty())
{
- COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << std::endl;
+ orxout(user_warning) << "Expression could not be parsed to the end! Remains: '" << expr.getRemains() << '\'' << endl;
}
float result = expr.getResult();
}
else
- COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
+ orxout(user_error) << "Cannot calculate expression: Parse error." << endl;
@endcode
getRemains() returns the expression after what could be parsed. For instance
\c "2*3 text" will return \c "text" as remains.
Modified: code/trunk/src/libraries/util/MultiType.h
===================================================================
--- code/trunk/src/libraries/util/MultiType.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/MultiType.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -77,7 +77,7 @@
@code
void myfunction(int value)
{
- COUT(0) << "doubled value is " << (2 * value) << std::endl;
+ orxout() << "doubled value is " << (2 * value) << endl;
}
MultiType a = "50"; // Note: We assigned a string
Modified: code/trunk/src/libraries/util/OrxAssert.h
===================================================================
--- code/trunk/src/libraries/util/OrxAssert.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/OrxAssert.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -39,13 +39,13 @@
#include "UtilPrereqs.h"
#include <cassert>
-#include "Debug.h"
+#include "Output.h"
#ifndef NDEBUG
/** Run time assertion like assert(), but with an embedded message.
@details
- The message will be printed as error with COUT(1). <br>
+ The message will be printed as error with orxout(user_error). <br>
You can use the same magic here as you can with \ref ThrowException
@code
OrxAssert(condition, "Text: " << number << " more text");
@@ -56,10 +56,10 @@
{ \
if (!(condition)) \
{ \
- COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \
- COUT(1) << "Assertion failed in " << __FUNCTIONNAME__ << std::endl; \
- COUT(1) << "Expression: " << #condition << std::endl; \
- COUT(1) << "Message : " << errorMessage << std::endl; \
+ orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \
+ orxout(user_error) << "Assertion failed in " << __FUNCTIONNAME__ << endl; \
+ orxout(user_error) << "Expression: " << #condition << endl; \
+ orxout(user_error) << "Message : " << errorMessage << endl; \
/* Don't use the condition again to avoid double evaluation */ \
/* Instead, stringify the expression and negate it */ \
assert(!#condition); \
@@ -69,7 +69,7 @@
/** Works like OrxAssert in debug mode, but also checks the condition in release
mode (no abort() triggered then).
@details
- The message will be printed as error with COUT(1). <br>
+ The message will be printed as error with orxout(user_error). <br>
You can use the same magic here as you can with \ref ThrowException
@code
OrxVerify(condition, "Text: " << number << " more text");
@@ -80,10 +80,10 @@
{ \
if (!(condition)) \
{ \
- COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \
- COUT(1) << "Verification failed in " << __FUNCTIONNAME__ << std::endl; \
- COUT(1) << "Expression: " << #condition << std::endl; \
- COUT(1) << "Message : " << errorMessage << std::endl; \
+ orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \
+ orxout(user_error) << "Verification failed in " << __FUNCTIONNAME__ << endl; \
+ orxout(user_error) << "Expression: " << #condition << endl; \
+ orxout(user_error) << "Message : " << errorMessage << endl; \
/* Don't use the condition again to avoid double evaluation */ \
/* Instead, stringify the expression and negate it */ \
assert(!#condition); \
@@ -99,10 +99,10 @@
{ \
if (!(condition)) \
{ \
- COUT(1) << __FILE__ << "(" << __LINE__ << "): "; \
- COUT(1) << "Verification failed in " << __FUNCTIONNAME__ << std::endl; \
- COUT(1) << "Expression: " << #condition << std::endl; \
- COUT(1) << "Message : " << errorMessage << std::endl; \
+ orxout(user_error) << __FILE__ << "(" << __LINE__ << "): "; \
+ orxout(user_error) << "Verification failed in " << __FUNCTIONNAME__ << endl; \
+ orxout(user_error) << "Expression: " << #condition << endl; \
+ orxout(user_error) << "Message : " << errorMessage << endl; \
/* No assert() in release configuration */ \
} \
} while (false)
Copied: code/trunk/src/libraries/util/Output.h (from rev 8857, code/branches/output/src/libraries/util/Output.h)
===================================================================
--- code/trunk/src/libraries/util/Output.h (rev 0)
+++ code/trunk/src/libraries/util/Output.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,116 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+/**
+ @defgroup Output Output system
+ @ingroup Util
+*/
+
+/**
+ @file
+ @ingroup Output
+ @brief Defines the helper function orxout() and includes all necessary headers to use the output system.
+
+ The output system is used to write output to the console, the logfile, and
+ other instances of orxonox::OutputListener. Each line of output is assigned
+ a level and a context. The level defines the type and importance of a
+ message, e.g. if it's a fatal error or just some internal information.
+ The context defines to which part of the program the output belongs.
+ Levels and contexts are defined in OutputDefinitions.h
+
+ Each orxonox::OutputListener can define a mask of desired levels and
+ contexts, to receive only a part of the output. Instances of
+ orxonox::SubcontextOutputListener are even able to filter sub-contexts.
+ A derivative of orxonox::BaseWriter is able to define these levels and
+ contexts through config values.
+
+ @attention
+ A message sent to the output system MUST end with "endl" or the message
+ won't be flushed.
+
+ @code
+ orxout() << "Debug output" << endl;
+ orxout(user_info) << "Orxonox version 1.2.3" << endl;
+ orxout(internal_status, context::input) << "Loading joystick" << endl;
+ @endcode
+*/
+
+#ifndef _Output_H__
+#define _Output_H__
+
+#include "UtilPrereqs.h"
+#include "output/OutputStream.h"
+
+namespace orxonox
+{
+ // Just for convenience
+ using std::endl;
+
+ /**
+ @brief This helper function returns a reference to a commonly used
+ instance of OutputStream.
+
+ It can be used like std::cout except that it is a function. You can
+ pass level and context of the following output as function arguments.
+ */
+ inline OutputStream& orxout(OutputLevel level = level::debug_output, const OutputContextContainer& context = context::undefined())
+ {
+ static OutputStream stream;
+ stream.setOutputAttributes(level, context);
+ return stream;
+ }
+
+ /**
+ @brief Shortcut for orxout() to allow passing contexts directly as
+ functions without using "()".
+
+ @code
+ orxout(user_info, context::example) << "Hello World" << endl; // calls this function
+ orxout(user_info, context::example()) << "Hello World" << endl; // calls the other orxout function
+ @endcode
+ */
+ inline OutputStream& orxout(OutputLevel level, OutputContextFunction context)
+ {
+ return orxout(level, context());
+ }
+
+ // COUT() is deprecated, please use orxout()
+ inline __DEPRECATED__(OutputStream& COUT(int level));
+
+ /**
+ @brief Writes output to the orxonox console. This function is deprecated, please use orxout()
+ @note The output level argument is ignored since it's not supported anymore. See orxout() for the new output levels.
+ @deprecated This function is deprecated. Use orxout() instead.
+ */
+ inline OutputStream& COUT(int)
+ {
+ return orxout();
+ }
+}
+
+#endif /* _Output_H__ */
Deleted: code/trunk/src/libraries/util/OutputHandler.cc
===================================================================
--- code/trunk/src/libraries/util/OutputHandler.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/OutputHandler.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,356 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- *
- */
-
-/**
- at file
- at brief
- Definition of classes related to output (logging).
-*/
-
-#include "OutputHandler.h"
-
-#include <algorithm>
-#include <ctime>
-#include <cstdlib>
-#include <fstream>
-#include <iostream>
-#include <sstream>
-
-#include "Debug.h"
-
-namespace orxonox
-{
- //! How the log file shall be named on the filesystem
- const std::string logFileBaseName_g = "orxonox.log";
-
- /////////////////////////
- ///// LogFileWriter /////
- /////////////////////////
- /**
- @brief
- Writes the output to the log file.
- @note
- As long as the correct log path is not yet known (for pre main code), the
- LogFileWriter will write to a temporary file in /temp (Unix) or %TEMP% (Windows).
- As soon as you set the correct path setLogPath the content of the temporary file
- is read and put into the new file as well.
- */
- class LogFileWriter : public OutputListener
- {
- public:
- /**
- @brief
- Gets temporary log path and starts the log file
- */
- LogFileWriter()
- : OutputListener("LogFile")
- {
- // Get path for a temporary file
-#ifdef ORXONOX_PLATFORM_WINDOWS
- char* pTempDir = getenv("TEMP");
- this->logFilename_ = std::string(pTempDir) + '/' + logFileBaseName_g;
-#else
- this->logFilename_ = std::string("/tmp/") + logFileBaseName_g;
-#endif
-
- // Get current time
- time_t rawtime;
- struct tm* timeinfo;
- time(&rawtime);
- timeinfo = localtime(&rawtime);
-
- this->openFile();
- if (this->logFile_.is_open())
- {
- this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl;
- this->logFile_.flush();
- }
- }
-
- //! Closes the log file
- ~LogFileWriter()
- {
- if (this->logFile_.is_open())
- {
- this->logFile_ << "Closed log" << std::endl;
- this->logFile_.close();
- }
- }
-
- //! Changes the log path
- void setLogPath(const std::string& path)
- {
- if (this->logFile_.is_open())
- this->logFile_.close();
-
- // Open the new file
- this->logFilename_ = path + logFileBaseName_g;
- this->openFile();
- }
-
- //! Erases the log file
- void clearFile()
- {
- if (this->logFile_.is_open())
- {
- this->logFile_.close();
- this->openFile();
- }
- }
-
- private:
- void openFile()
- {
- this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
-
- if (this->logFile_.is_open())
- this->outputStream_ = &this->logFile_;
- else
- {
- COUT(2) << "Warning: Failed to open log file. File logging disabled." << std::endl;
- this->outputStream_ = NULL;
- }
- }
-
- std::ofstream logFile_; //!< File handle for the log file
- std::string logFilename_; //!< Filename of the log file
- };
-
-
- /////////////////////////
- ///// ConsoleWriter /////
- /////////////////////////
- /**
- @brief
- Writes the output to std::cout.
- @note
- This listener will usually be disable once an actual shell with console is instantiated.
- */
- class ConsoleWriter : public OutputListener
- {
- public:
- //! Only assigns the output stream with std::cout
- ConsoleWriter()
- : OutputListener("Console")
- {
- this->outputStream_ = &std::cout;
- }
- };
-
-
- ///////////////////////////
- ///// MemoryLogWriter /////
- ///////////////////////////
- /**
- @brief
- OutputListener that writes all the output piece by piece to an array
- associated with the corresponding output level.
- Used as buffer until all output devices have been initialised.
- @note
- At some point, OutputHandler::disableMemoryLog() has to be called in
- order to avoid large memory footprints of this class.
- */
- class MemoryLogWriter : public OutputListener
- {
- public:
- friend class OutputHandler;
-
- MemoryLogWriter()
- : OutputListener("memoryLog")
- {
- this->outputStream_ = &this->buffer_;
- }
-
- //! Push the just written output to the internal array
- void outputChanged(int level)
- {
- if (!this->buffer_.str().empty())
- {
- // Read ostringstream and store it
- this->output_.push_back(std::make_pair(level, this->buffer_.str()));
- // Clear content and flags
- this->buffer_.str(std::string());
- }
- this->buffer_.clear();
- }
-
- private:
- std::ostringstream buffer_; //!< Stream object used to process the output
- OutputHandler::OutputVector output_; //!< Vector containing ALL output
- };
-
-
- /////////////////////////
- ///// OutputHandler /////
- /////////////////////////
- int OutputHandler::softDebugLevel_s = hardDebugLevel;
-
- //! Creates the LogFileWriter and the MemoryLogWriter
- OutputHandler::OutputHandler()
- : outputLevel_(OutputLevel::Verbose)
- {
- // Note: These levels only concern startup before orxonox.ini is read.
-#ifdef ORXONOX_RELEASE
- const OutputLevel::Value initialLevelConsole = OutputLevel::Error;
-#else
- const OutputLevel::Value initialLevelConsole = OutputLevel::Info;
-#endif
- // Use high log level because we rewrite the log file anyway with the
- // correct level. But if Orxonox were to crash before that, we might be
- // grateful to have a high debug level, esp. for releases.
- const OutputLevel::Value intialLevelLogFile = OutputLevel::Debug;
-
- this->logFile_ = new LogFileWriter();
- // Use default level until we get the configValue from the Core
- this->logFile_->softDebugLevel_ = intialLevelLogFile;
- this->registerOutputListener(this->logFile_);
-
- this->consoleWriter_ = new ConsoleWriter();
- this->consoleWriter_->softDebugLevel_ = initialLevelConsole;
- this->registerOutputListener(this->consoleWriter_);
-
- this->memoryBuffer_ = new MemoryLogWriter();
- // Write everything, e.g. use hardDebugLevel
- this->memoryBuffer_->softDebugLevel_ = hardDebugLevel;
- this->registerOutputListener(this->memoryBuffer_);
- }
-
- //! Destroys the LogFileWriter and the MemoryLogWriter
- OutputHandler::~OutputHandler()
- {
- delete this->logFile_;
- delete this->consoleWriter_;
- delete this->memoryBuffer_; // Might already be NULL
- }
-
- OutputHandler& OutputHandler::getInstance()
- {
- static OutputHandler orxout;
- return orxout;
- }
-
- void OutputHandler::registerOutputListener(OutputListener* listener)
- {
- for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- {
- if ((*it)->name_ == listener->name_)
- {
- COUT(2) << "OutputHandler, Warning: Trying to register two listeners with the same name!" << std::endl;
- return;
- }
- }
- this->listeners_.push_back(listener);
- this->updateGlobalDebugLevel();
- }
-
- void OutputHandler::unregisterOutputListener(OutputListener* listener)
- {
- for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- {
- if ((*it)->name_ == listener->name_)
- {
- this->listeners_.erase(it);
- break;
- }
- }
- this->updateGlobalDebugLevel();
- }
-
- void OutputHandler::setLogPath(const std::string& path)
- {
- this->logFile_->setLogPath(path);
- this->rewriteLogFile();
- }
-
- void OutputHandler::rewriteLogFile()
- {
- logFile_->clearFile();
-
- if (logFile_->outputStream_ == NULL)
- return;
-
- for (OutputVector::const_iterator it = this->getOutput().begin(); it != this->getOutput().end(); ++it)
- {
- if (it->first <= logFile_->softDebugLevel_)
- (*logFile_->outputStream_) << it->second;
- }
- logFile_->outputStream_->flush();
- }
-
- void OutputHandler::disableCout()
- {
- this->unregisterOutputListener(this->consoleWriter_);
- }
-
- void OutputHandler::enableCout()
- {
- this->registerOutputListener(this->consoleWriter_);
- }
-
- void OutputHandler::disableMemoryLog()
- {
- this->unregisterOutputListener(this->memoryBuffer_);
- // Only clear the buffer so we can still reference the vector
- this->memoryBuffer_->output_.clear();
- }
-
- const OutputHandler::OutputVector& OutputHandler::getOutput() const
- {
- return this->memoryBuffer_->output_;
- }
-
- int OutputHandler::getSoftDebugLevel(const std::string& name) const
- {
- for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- {
- if ((*it)->name_ == name)
- return (*it)->softDebugLevel_;
- }
- return -1;
- }
-
- void OutputHandler::setSoftDebugLevel(const std::string& name, int level)
- {
- for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- {
- if ((*it)->name_ == name)
- (*it)->softDebugLevel_ = level;
- }
- this->updateGlobalDebugLevel();
- }
-
- void OutputHandler::updateGlobalDebugLevel()
- {
- int globalSoftDebugLevel = -1;
- std::vector<OutputListener*>::const_iterator it = this->listeners_.begin();
- for (; it != this->listeners_.end(); ++it)
- globalSoftDebugLevel = std::max(globalSoftDebugLevel, (*it)->softDebugLevel_);
-
- OutputHandler::softDebugLevel_s = globalSoftDebugLevel;
- }
-}
Deleted: code/trunk/src/libraries/util/OutputHandler.h
===================================================================
--- code/trunk/src/libraries/util/OutputHandler.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/OutputHandler.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,285 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- *
- */
-
-/**
- at file
- at ingroup Util Output
- at brief
- Declaration of classes related to output (logging), most notably OutputHandler and OutputListener.
-*/
-
-#ifndef _OutputHandler_H__
-#define _OutputHandler_H__
-
-#include "UtilPrereqs.h"
-
-#include <ostream>
-#include <string>
-#include <vector>
-#include <utility>
-
-namespace orxonox
-{
- /**
- @brief
- Denotes different levels of text output (log output)
-
- - 0, None : Very important output
- - 1, Error : Errors
- - 2, Warning: Warnings
- - 3, Info : Information
- - 4, Debug : Debug information
- - 5, Verbose: More debug information
- - 6, Ultra : Crazy debug information
- */
- namespace OutputLevel
- {
- enum Value
- {
- TDebug = -1,
- None = 0,
- Error = 1,
- Warning = 2,
- Info = 3,
- Debug = 4,
- Verbose = 5,
- Ultra = 6,
- };
- }
-
- // Forward declarations for classes in the source file
- class LogFileWriter;
- class ConsoleWriter;
- class MemoryLogWriter;
-
- /**
- @brief
- The OutputHandler acts like @c std::cout, but output isn't only shown in the console.
-
- Output passed to the OutputHandler is distributed to all registered listeners,
- for example the console, the logfile, or the ingame shell.
-
- You can register your own listener for output by inheriting from OutputListener.
- And if you need the output previously processed, iterate over it with
- OutputHandler::getOutputVectorBegin and OutputHandler::getOutputVectorEnd.
-
- The way to output text is to first set the desired output level with
- @ref getOutStream "OutputHandler::getOutStream(level)" and then use
- the "<<" operator like with @c std::cout. Alternatively you can use the COUT() macro.
- */
- class _UtilExport OutputHandler
- {
- public:
- //! Returns a reference to the only existing instance of the OutputHandler class.
- static OutputHandler& getInstance();
-
- //! Sets the output level and returns a stream to be used with "<<"
- static inline OutputHandler& getOutStream(int level)
- { return OutputHandler::getInstance().setOutputLevel(level); }
-
- typedef std::vector<std::pair<int, std::string> > OutputVector;
- //! Returns all output written so far (empty if disableMemoryLog() was called)
- const OutputVector& getOutput() const;
-
- //! Writes to all output devices
- static inline void log(const std::string& text)
- { OutputHandler::getOutStream(0).output(text) << std::endl; }
-
- //! Writes an error message to the output
- static inline void error(const std::string& text)
- { OutputHandler::getOutStream(1).output(text) << std::endl; }
-
- //! Writes a warning message to the output
- static inline void warning(const std::string& text)
- { OutputHandler::getOutStream(2).output(text) << std::endl; }
-
- //! Writes an informational message to the output
- static inline void info(const std::string& text)
- { OutputHandler::getOutStream(3).output(text) << std::endl; }
-
- //! Writes a debug message to the output
- static inline void debug(const std::string& text)
- { OutputHandler::getOutStream(4).output(text) << std::endl; }
-
- //! Registers an object that receives output via a provided std::ostream
- void registerOutputListener(OutputListener* listener);
- //! Unregisters an object that receives output via a provided std::ostream
- void unregisterOutputListener(OutputListener* listener);
-
- //! Set the log path once the program has been properly initialised
- void setLogPath(const std::string& path);
- /** Rewrites the log file (completely respects the current debug level).
- Once disableMemoryLog() has been called, this function will do nothing.
- */
- void rewriteLogFile();
-
- //! Disables the std::cout stream for output
- void disableCout();
- //! Enables the std::cout stream for output (startup behaviour)
- void enableCout();
- //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage)
- void disableMemoryLog();
-
- //! Sets the level of the incoming output and returns the OutputHandler
- inline OutputHandler& setOutputLevel(int level)
- { this->outputLevel_ = level; return *this; }
-
- //! Returns the level of the incoming output
- inline int getOutputLevel() const
- { return this->outputLevel_; }
-
- //! Returns the maximum debug level over all registered listeners (devices)
- static int getSoftDebugLevel() { return softDebugLevel_s; }
- //! Returns the soft debug level for a device by its name @return The level or -1 if the listener was not found
- int getSoftDebugLevel(const std::string& name) const;
- //! Sets the soft debug level for a listener by its name @remarks Only works for registered listeners!
- void setSoftDebugLevel(const std::string& name, int level);
-
- /**
- @brief
- General template that copes with all output.
- Required because operator << might be ambiguous.
- @a output will be streamed into every listener with an appropriate debug level
- @return
- Returns a reference to the OutputHandler so you can use it again directly
- */
- template <class T>
- OutputHandler& output(const T& output);
-
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(unsigned char val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(short val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(unsigned short val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(int val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(unsigned int val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(long val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(unsigned long val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(long long val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(unsigned long long val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(float val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(double val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(long double val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(const void* val) { return this->output(val); }
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(bool val) { return this->output(val); }
-
- //! Overloaded << operator, redirects the output to the listeners
- inline OutputHandler& operator<<(std::streambuf* sb) { return this->output(sb); }
-
- //! Overloaded << operator, redirect the output of classes with self defined 'operator <<' to the listeners
- template <class T>
- inline OutputHandler& operator<<(const T& val) { return this->output(val); }
-
- //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
- inline OutputHandler& operator<<(std::ostream& (*manip)(std::ostream&)) { return this->output(manip); }
- //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
- inline OutputHandler& operator<<(std::ios& (*manip)(std::ios&)) { return this->output(manip); }
- //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
- inline OutputHandler& operator<<(std::ios_base& (*manip)(std::ios_base&)) { return this->output(manip); }
-
- //! Dummy operator required by Debug.h for the ternary operator
- inline operator int() const { return 0; }
-
- private:
- OutputHandler();
- ~OutputHandler();
- OutputHandler(const OutputHandler& rhs); //!< Copy-constructor: Unused and undefined
-
- /// Evaluates the maximum global log level
- void updateGlobalDebugLevel();
-
- std::vector<OutputListener*> listeners_; //!< Array with all registered output listeners
- int outputLevel_; //!< The level of the incoming output
- LogFileWriter* logFile_; //!< Writes output to the log file
- ConsoleWriter* consoleWriter_; //!< Writes to std::cout (can be disabled)
- MemoryLogWriter* memoryBuffer_; //!< Writes to memory as a buffer (can/must be stopped at some time)
- static int softDebugLevel_s; //!< Maximum of all soft debug levels. @note This is only static for faster access
- };
-
- /**
- @brief
- Interface for listening to output.
- @remarks
- Remember to register the listener (not done automatically!)
- */
- class OutputListener
- {
- friend class OutputHandler;
-
- public:
- OutputListener(const std::string& name)
- : outputStream_(NULL)
- , name_(name)
- , softDebugLevel_(OutputLevel::Info)
- {}
- virtual ~OutputListener() {}
-
- //! Gets called whenever output is put into the stream
- virtual void outputChanged(int level) {}
- //! Returns the name of this output listener
- const std::string& getOutputListenerName() const { return this->name_; }
-
- protected:
- std::ostream* outputStream_; //!< Pointer to the associated output stream, can be NULL
-
- private:
- const std::string name_; //!< Name of the listener, constant and unique!
- int softDebugLevel_; //!< Current soft debug level that defines what kind of output is written to the stream
- };
-
- template<class T>
- inline OutputHandler& OutputHandler::output(const T& output)
- {
- for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- {
- if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
- {
- std::ostream& stream = *((*it)->outputStream_);
- stream << output;
- stream.flush();
- (*it)->outputChanged(this->outputLevel_);
- }
- }
-
- return *this;
- }
-}
-
-#endif /* _OutputHandler_H__ */
Modified: code/trunk/src/libraries/util/Scope.h
===================================================================
--- code/trunk/src/libraries/util/Scope.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Scope.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -59,7 +59,7 @@
#include <set>
#include <loki/ScopeGuard.h>
-#include "Debug.h"
+#include "Output.h"
namespace orxonox
{
@@ -127,6 +127,8 @@
//! Constructor: Increases the instance counter and activates the scope if the count went from 0 to 1. Counts >1 don't change anything.
Scope()
{
+ orxout(internal_status) << "creating scope... (" << scope << ")" << endl;
+
try
{
ScopeManager::instanceCounts_s[scope]++;
@@ -147,11 +149,15 @@
ScopeManager::instanceCounts_s[scope]--;
throw;
}
+
+ orxout(internal_status) << "created scope (" << scope << ")" << endl;
}
//! Destructor: Decreases the instance counter and deactivates the scope if the count went from 1 to 0. Counts >0 don't change anything.
~Scope()
{
+ orxout(internal_status) << "destroying scope... (" << scope << ")" << endl;
+
ScopeManager::instanceCounts_s[scope]--;
// This shouldn't happen but just to be sure: check if the count is positive
@@ -161,6 +167,8 @@
if (ScopeManager::instanceCounts_s[scope] == 0)
this->deactivateListeners();
+
+ orxout(internal_status) << "destroyed scope (" << scope << ")" << endl;
}
//! Deactivates the listeners of this scope in case the scope is destroyed or the construction fails.
@@ -173,7 +181,7 @@
try
{ (*it)->deactivated(); }
catch (...)
- { COUT(0) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << std::endl; }
+ { orxout(internal_warning) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << endl; }
(*(it++))->bActivated_ = false;
}
else
Modified: code/trunk/src/libraries/util/ScopedSingletonManager.h
===================================================================
--- code/trunk/src/libraries/util/ScopedSingletonManager.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/ScopedSingletonManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -230,9 +230,9 @@
try
{ singletonPtr_ = new T(); }
catch (const InitialisationAbortedException& ex)
- { COUT(3) << ex.getDescription() << std::endl; }
+ { orxout(internal_error) << ex.getDescription() << endl; }
catch (...)
- { COUT(1) << "Singleton creation failed: " << Exception::handleMessage() << std::endl; }
+ { orxout(internal_error) << "Singleton creation failed: " << Exception::handleMessage() << endl; }
}
//! Called if the Scope of this Singleton gets deactivated (destroys the instance)
Modified: code/trunk/src/libraries/util/SignalHandler.cc
===================================================================
--- code/trunk/src/libraries/util/SignalHandler.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/SignalHandler.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -38,7 +38,7 @@
#include <cstring>
#include <cstdio>
-#include "Debug.h"
+#include "Output.h"
namespace orxonox
{
@@ -126,7 +126,7 @@
// if the signalhandler has already been destroyed then don't do anything
if( SignalHandler::singletonPtr_s == 0 )
{
- COUT(0) << "Received signal " << sigName.c_str() << std::endl << "Can't write backtrace because SignalHandler is already destroyed" << std::endl;
+ orxout(user_error) << "Received signal " << sigName.c_str() << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl;
exit(EXIT_FAILURE);
}
@@ -136,7 +136,7 @@
}
- COUT(0) << "Received signal " << sigName.c_str() << std::endl << "Try to write backtrace to file orxonox_crash.log" << std::endl;
+ 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
@@ -205,18 +205,18 @@
// 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 )
- COUT(0) << "could not set proper permissions for GDB to attach to process..." << endl;
+ 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;
if( read( sigPipe[0], &someData, sizeof(someData) ) != sizeof(someData) )
- COUT(0) << "something went wrong :(" << std::endl;
+ orxout(user_error) << "something went wrong :(" << endl;
if ( someData != 0x12345678 )
{
- COUT(0) << "something went wrong :(" << std::endl;
+ orxout(user_error) << "something went wrong :(" << endl;
}
return;
@@ -327,7 +327,7 @@
if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
{
- COUT(0) << "could not write " << bt.length() << " byte to " << getInstance().filename << std::endl;
+ orxout(user_error) << "could not write " << bt.length() << " byte to " << getInstance().filename << endl;
exit(EXIT_FAILURE);
}
@@ -363,8 +363,9 @@
/// Overwrite the original abort() function in MinGW to enable a break point.
_UtilExport void __cdecl abort()
{
- COUT(1) << "This application has requested the Runtime to terminate it in an unusual way." << std::endl;
- COUT(1) << "Please contact the application's support team for more information." << std::endl;
+ using namespace orxonox;
+ orxout(user_error) << "This application has requested the Runtime to terminate it in an unusual way." << endl;
+ orxout(user_error) << "Please contact the application's support team for more information." << endl;
DebugBreak();
exit(0x3);
}
@@ -372,8 +373,9 @@
/// Overwrite the original _abort() function in MinGW to enable a break point.
_UtilExport void __cdecl _assert(const char* expression, const char* file, int line)
{
- COUT(1) << "Assertion failed: " << expression << ", file " << file << ", line " << line << std::endl;
- COUT(1) << std::endl;
+ using namespace orxonox;
+ orxout(user_error) << "Assertion failed: " << expression << ", file " << file << ", line " << line << endl;
+ orxout(user_error) << endl;
abort();
}
#endif
@@ -422,51 +424,51 @@
{
bExecuting = true;
- COUT(1) << std::endl;
+ orxout(user_error) << endl;
// if the signalhandler has already been destroyed then don't do anything
if (SignalHandler::singletonPtr_s == 0)
{
- COUT(1) << "Caught an unhandled exception" << std::endl << "Can't write backtrace because SignalHandler is already destroyed" << std::endl;
+ orxout(user_error) << "Caught an unhandled exception" << endl << "Can't write backtrace because SignalHandler is already destroyed" << endl;
exit(EXIT_FAILURE);
}
- COUT(1) << "Caught an unhandled exception" << std::endl << "Try to write backtrace to orxonox_crash.log..." << std::endl;
+ orxout(user_error) << "Caught an unhandled exception" << endl << "Try to write backtrace to orxonox_crash.log..." << endl;
// write the crash log
std::ofstream crashlog(SignalHandler::getInstance().filename_.c_str());
time_t now = time(NULL);
- crashlog << "=======================================================" << std::endl;
+ crashlog << "=======================================================" << endl;
crashlog << "= Time: " << std::string(ctime(&now));
- crashlog << "=======================================================" << std::endl;
- crashlog << std::endl;
+ crashlog << "=======================================================" << endl;
+ crashlog << endl;
const std::string& error = SignalHandler::getExceptionType(pExceptionInfo);
- crashlog << error << std::endl;
- crashlog << std::endl;
+ crashlog << error << endl;
+ crashlog << endl;
const std::string& callstack = SignalHandler::getStackTrace(pExceptionInfo);
- crashlog << "Call stack:" << std::endl;
- crashlog << callstack << std::endl;
+ crashlog << "Call stack:" << endl;
+ crashlog << callstack << endl;
crashlog.close();
// print the same information also to the console
- COUT(1) << std::endl;
- COUT(1) << error << std::endl;
- COUT(1) << std::endl;
- COUT(1) << "Call stack:" << std::endl;
- COUT(1) << callstack << std::endl;
+ orxout(user_error) << endl;
+ orxout(user_error) << error << endl;
+ orxout(user_error) << endl;
+ orxout(user_error) << "Call stack:" << endl;
+ orxout(user_error) << callstack << endl;
bExecuting = false;
}
else
{
- COUT(1) << "An error occurred while writing the backtrace" << std::endl;
+ orxout(user_error) << "An error occurred while writing the backtrace" << endl;
}
if (SignalHandler::getInstance().prevExceptionFilter_)
Modified: code/trunk/src/libraries/util/Singleton.h
===================================================================
--- code/trunk/src/libraries/util/Singleton.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Singleton.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -99,7 +99,7 @@
void TestSingleton::testFunction() // implement testFunction
{
- COUT(0) << "My value is " << this->testValue_ << std::endl;
+ orxout() << "My value is " << this->testValue_ << endl;
}
TestSingleton::getInstance().testFunction(); // prints "My value is 15"
Modified: code/trunk/src/libraries/util/Sleep.cc
===================================================================
--- code/trunk/src/libraries/util/Sleep.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/Sleep.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -33,7 +33,7 @@
*/
#include "Sleep.h"
-#include "Debug.h"
+#include "Output.h"
#ifdef ORXONOX_PLATFORM_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
@@ -48,7 +48,7 @@
void usleep(unsigned long microseconds)
{
//if (microseconds < 1000)
- // COUT(2) << "Warning: Windows cannot sleep less than 1ms, ignoring" << std::endl;
+ // orxout(internal_warning) << "Windows cannot sleep less than 1ms, ignoring" << endl;
Sleep(microseconds / 1000);
}
Modified: code/trunk/src/libraries/util/StringUtils.cc
===================================================================
--- code/trunk/src/libraries/util/StringUtils.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/StringUtils.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -80,6 +80,16 @@
return str.substr(pos1, pos2 - pos1 + 1);
}
+ /// Splits a given string by a delimiter and stores it in an output vector
+ void vectorize(const std::string& str, char delimiter, std::vector<std::string>* output)
+ {
+ for (size_t start = 0, end = 0; end != std::string::npos; start = end + 1)
+ {
+ end = str.find_first_of(delimiter, start);
+ output->push_back(str.substr(start, end - start));
+ }
+ }
+
/**
@brief Returns the position of the next quotation mark in the string, starting with start.
@param str The string
@@ -516,7 +526,7 @@
return matrix[(rows-1)*cols + cols-1];
}
-
+
/**
@brief
Get a timestamp for the curent time instant.
Modified: code/trunk/src/libraries/util/StringUtils.h
===================================================================
--- code/trunk/src/libraries/util/StringUtils.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/StringUtils.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -42,6 +42,7 @@
#include "UtilPrereqs.h"
#include <string>
+#include <vector>
namespace orxonox
{
@@ -54,6 +55,8 @@
_UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+ _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 bool isBetweenQuotes(const std::string& str, size_t pos);
@@ -87,7 +90,7 @@
_UtilExport size_t replaceCharacters(std::string& str, char target, char replacement);
_UtilExport unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2);
-
+
_UtilExport std::string getTimestamp(void);
}
Modified: code/trunk/src/libraries/util/SubString.cc
===================================================================
--- code/trunk/src/libraries/util/SubString.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/SubString.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -44,7 +44,7 @@
#include "SubString.h"
#include <cstdio>
-#include "Debug.h"
+#include "Output.h"
namespace orxonox
{
@@ -512,9 +512,9 @@
*/
void SubString::debug() const
{
- COUT(0) << "Substring-information::count=" << this->tokens_.size() << " ::";
+ orxout(debug_output) << "Substring-information::count=" << this->tokens_.size() << " ::";
for (unsigned int i = 0; i < this->tokens_.size(); ++i)
- COUT(0) << "s" << i << "='" << this->tokens_[i].c_str() << "'::";
- COUT(0) << std::endl;
+ 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 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/SubString.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -58,7 +58,7 @@
SubString tokens(text, SubString::WhiteSpaces, "", false, '\\', true, '"', true, '{', '}', true, '\0');
for (unsigned int i = 0; i < tokens.size(); ++i)
- COUT(0) << i << ": " << tokens[i] << std::endl;
+ orxout() << i << ": " << tokens[i] << endl;
@endcode
The output of this code is:
Modified: code/trunk/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/trunk/src/libraries/util/UtilPrereqs.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/UtilPrereqs.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -87,8 +87,9 @@
class Exception;
class ExprParser;
class MultiType;
- class OutputHandler;
class OutputListener;
+ class OutputManager;
+ class OutputStream;
template <ScopeID::Value>
class Scope;
template <class, ScopeID::Value>
Deleted: code/trunk/src/libraries/util/output/BaseWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/BaseWriter.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/BaseWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,147 +0,0 @@
-/*
- * 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
- @brief Implementation of the BaseWriter class.
-*/
-
-#include "BaseWriter.h"
-
-#include "OutputManager.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor: Initializes the config-values.
- */
- BaseWriter::BaseWriter(const std::string& name, bool bRegister) : SubcontextOutputListener(bRegister)
- {
- this->name_ = name;
-
- this->configurableMaxLevel_ = level::none;
- this->configurableAdditionalContextsMaxLevel_ = level::verbose;
- this->configurableAdditionalContexts_.push_back("example");
-
- this->changedConfigurableLevel();
- this->changedConfigurableAdditionalContextsLevel();
- this->changedConfigurableAdditionalContexts();
- }
-
- /**
- @brief Destructor.
- */
- BaseWriter::~BaseWriter()
- {
- }
-
- /**
- @brief This function is inherited from OutputListener, each message is split into lines and sent to printLine().
- */
- void BaseWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
- {
- const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
- std::string blanks(prefix.length(), ' ');
-
- for (size_t i = 0; i < lines.size(); ++i)
- this->printLine((i == 0 ? prefix : blanks) + lines[i], level);
- }
-
- /**
- @brief Overwritten implementation of the function inherited from OutputListener, sets also the corresponding config-value.
- */
- void BaseWriter::setLevelMax(OutputLevel max)
- {
- this->configurableMaxLevel_ = max;
- this->changedConfigurableLevel();
- }
-
- /**
- @brief Overwritten implementation of the function inherited from OutputListener, sets also the corresponding config-value.
- */
- void BaseWriter::setAdditionalContextsLevelMax(OutputLevel max)
- {
- this->configurableAdditionalContextsMaxLevel_ = max;
- this->changedConfigurableAdditionalContextsLevel();
- }
-
- /**
- @brief Called if the config value has changed, updates the corresponding mask in OutputListener.
- */
- void BaseWriter::changedConfigurableLevel()
- {
- OutputListener::setLevelMax(static_cast<OutputLevel>(this->configurableMaxLevel_));
- }
-
- /**
- @brief Called if the config value has changed, updates the corresponding mask in OutputListener.
- */
- void BaseWriter::changedConfigurableAdditionalContextsLevel()
- {
- OutputListener::setAdditionalContextsLevelMax(static_cast<OutputLevel>(this->configurableAdditionalContextsMaxLevel_));
- }
-
- /**
- @brief Called if the config-vector of accepted contexts has changed, updates the masks in SubcontextOutputListener.
- */
- void BaseWriter::changedConfigurableAdditionalContexts()
- {
- OutputContextMask main_contexts = context::none;
- std::set<const OutputContextContainer*> sub_contexts;
-
- // iterate over all strings in the config-vector
- for (size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i)
- {
- const std::string& full_name = this->configurableAdditionalContexts_[i];
-
- // split the name into main-name and sub-name (if given; otherwise sub-name remains empty). both names are separated by ::
- std::string name = full_name;
- std::string subname;
-
- size_t pos = full_name.find("::");
- if (pos != std::string::npos)
- {
- name = full_name.substr(0, pos);
- subname = full_name.substr(pos + 2);
- }
-
- // get the context defined by this name
- const OutputContextContainer& context = OutputManager::getInstance().registerContext(name, subname);
-
- // if the context is a sub-context, insert it to the set of sub-contexts. Otherwise add it's mask to the mask of main-contexts.
- if (context.sub_id == context::no_subcontext)
- main_contexts |= context.mask;
- else
- sub_contexts.insert(&context);
- }
-
- // pass main-contexts and sub-contexts to SubcontextOutputListener
- this->setAdditionalContextsMask(main_contexts);
- this->setAdditionalSubcontexts(sub_contexts);
- }
-}
Copied: code/trunk/src/libraries/util/output/BaseWriter.cc (from rev 8857, code/branches/output/src/libraries/util/output/BaseWriter.cc)
===================================================================
--- code/trunk/src/libraries/util/output/BaseWriter.cc (rev 0)
+++ code/trunk/src/libraries/util/output/BaseWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,147 @@
+/*
+ * 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
+ @brief Implementation of the BaseWriter class.
+*/
+
+#include "BaseWriter.h"
+
+#include "OutputManager.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor: Initializes the config-values.
+ */
+ BaseWriter::BaseWriter(const std::string& name, bool bRegister) : SubcontextOutputListener(bRegister)
+ {
+ this->name_ = name;
+
+ this->configurableMaxLevel_ = level::none;
+ this->configurableAdditionalContextsMaxLevel_ = level::verbose;
+ this->configurableAdditionalContexts_.push_back("example");
+
+ this->changedConfigurableLevel();
+ this->changedConfigurableAdditionalContextsLevel();
+ this->changedConfigurableAdditionalContexts();
+ }
+
+ /**
+ @brief Destructor.
+ */
+ BaseWriter::~BaseWriter()
+ {
+ }
+
+ /**
+ @brief This function is inherited from OutputListener, each message is split into lines and sent to printLine().
+ */
+ void BaseWriter::output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
+ {
+ const std::string& prefix = OutputManager::getInstance().getDefaultPrefix(level, context);
+ std::string blanks(prefix.length(), ' ');
+
+ for (size_t i = 0; i < lines.size(); ++i)
+ this->printLine((i == 0 ? prefix : blanks) + lines[i], level);
+ }
+
+ /**
+ @brief Overwritten implementation of the function inherited from OutputListener, sets also the corresponding config-value.
+ */
+ void BaseWriter::setLevelMax(OutputLevel max)
+ {
+ this->configurableMaxLevel_ = max;
+ this->changedConfigurableLevel();
+ }
+
+ /**
+ @brief Overwritten implementation of the function inherited from OutputListener, sets also the corresponding config-value.
+ */
+ void BaseWriter::setAdditionalContextsLevelMax(OutputLevel max)
+ {
+ this->configurableAdditionalContextsMaxLevel_ = max;
+ this->changedConfigurableAdditionalContextsLevel();
+ }
+
+ /**
+ @brief Called if the config value has changed, updates the corresponding mask in OutputListener.
+ */
+ void BaseWriter::changedConfigurableLevel()
+ {
+ OutputListener::setLevelMax(static_cast<OutputLevel>(this->configurableMaxLevel_));
+ }
+
+ /**
+ @brief Called if the config value has changed, updates the corresponding mask in OutputListener.
+ */
+ void BaseWriter::changedConfigurableAdditionalContextsLevel()
+ {
+ OutputListener::setAdditionalContextsLevelMax(static_cast<OutputLevel>(this->configurableAdditionalContextsMaxLevel_));
+ }
+
+ /**
+ @brief Called if the config-vector of accepted contexts has changed, updates the masks in SubcontextOutputListener.
+ */
+ void BaseWriter::changedConfigurableAdditionalContexts()
+ {
+ OutputContextMask main_contexts = context::none;
+ std::set<const OutputContextContainer*> sub_contexts;
+
+ // iterate over all strings in the config-vector
+ for (size_t i = 0; i < this->configurableAdditionalContexts_.size(); ++i)
+ {
+ const std::string& full_name = this->configurableAdditionalContexts_[i];
+
+ // split the name into main-name and sub-name (if given; otherwise sub-name remains empty). both names are separated by ::
+ std::string name = full_name;
+ std::string subname;
+
+ size_t pos = full_name.find("::");
+ if (pos != std::string::npos)
+ {
+ name = full_name.substr(0, pos);
+ subname = full_name.substr(pos + 2);
+ }
+
+ // get the context defined by this name
+ const OutputContextContainer& context = OutputManager::getInstance().registerContext(name, subname);
+
+ // if the context is a sub-context, insert it to the set of sub-contexts. Otherwise add it's mask to the mask of main-contexts.
+ if (context.sub_id == context::no_subcontext)
+ main_contexts |= context.mask;
+ else
+ sub_contexts.insert(&context);
+ }
+
+ // pass main-contexts and sub-contexts to SubcontextOutputListener
+ this->setAdditionalContextsMask(main_contexts);
+ this->setAdditionalSubcontexts(sub_contexts);
+ }
+}
Deleted: code/trunk/src/libraries/util/output/BaseWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/BaseWriter.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/BaseWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,120 +0,0 @@
-/*
- * 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 BaseWriter class, the base of all output writers.
-*/
-
-#ifndef _BaseWriter_H__
-#define _BaseWriter_H__
-
-#include "util/UtilPrereqs.h"
-#include "SubcontextOutputListener.h"
-
-namespace orxonox
-{
- /**
- @brief BaseWriter is an output listener and makes the accepted output levels and contexts configurable.
-
- All output writers like ConsoleWriter and LogWriter are inherited from
- this class. BaseWriter itself inherits from SubcontextOutputListener.
- It adds helper functions to configure the accepted levels and contexts.
-
- The levels are not fully configurable, only the "max" form is allowed
- (which means that it's only possible to define a maximum level, not
- the full mask).
-
- Contexts are defined by a vector of strings, each context is defined
- by it's name. Sub-contexts have the form \a "main-name::sub-name", i.e.
- their name is concatenated with :: in between.
-
- Each instance of BaseWriter needs a name to generate distinguishable
- config values.
-
- Received output messages are split into lines and sent line by line to
- the virtual printLine() function. Each line has a prepended prefix
- which describes the level and context of the output.
- */
- class _UtilExport BaseWriter : public SubcontextOutputListener
- {
- public:
- BaseWriter(const std::string& name, bool bRegister = true);
- virtual ~BaseWriter();
-
- void setLevelMax(OutputLevel max);
- void setAdditionalContextsLevelMax(OutputLevel max);
-
- /// @brief Returns the name of this instance.
- const std::string& getName() const
- { return this->name_; }
-
- /// Config value, used to define the maximum output level (independent of contexts)
- int configurableMaxLevel_;
- /// @brief Returns the name of the config value which defines the maximum output level (independent of contexts).
- inline std::string getConfigurableMaxLevelName() const
- { return this->name_ + "Level"; }
-
- /// Config value, used to define the maximum output level of additional context
- int configurableAdditionalContextsMaxLevel_;
- /// @brief Returns the name of the config value which defines the maximum output level of additional context.
- inline std::string getConfigurableAdditionalContextsMaxLevelName() const
- { return this->name_ + "AdditionalContextsLevel"; }
-
- /// Config vector, used to define the additional contexts (and sub-contexts)
- std::vector<std::string> configurableAdditionalContexts_;
- /// @brief Returns the name of the config vector which defines the additional contexts (and sub-contexts)
- inline std::string getConfigurableAdditionalContextsName() const
- { return this->name_ + "AdditionalContexts"; }
-
- void changedConfigurableLevel();
- void changedConfigurableAdditionalContextsLevel();
- void changedConfigurableAdditionalContexts();
-
- /// Returns the (static) name of the section wherein the config-values are defined.
- static inline std::string getConfigurableSectionName()
- { return "Output"; }
-
- protected:
- virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines);
-
- private:
- virtual void printLine(const std::string& line, OutputLevel level) = 0; ///< Pure virtual function, gets called for each line of output together with a prefix which describes level and context of the output.
-
- void setLevelRange(OutputLevel min, OutputLevel max); ///< Inherited function, overwritten as private because it is not supported by the config-value
- void setLevelMask(OutputLevel mask); ///< Inherited function, overwritten as private because it is not supported by the config-value
-
- void setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max); ///< Inherited function, overwritten as private because it is not supported by the config-value
- void setAdditionalContextsLevelMask(OutputLevel mask); ///< Inherited function, overwritten as private because it is not supported by the config-value
-
- std::string name_; ///< The name of this instance, used to generate unique config-values
- };
-}
-
-#endif /* _BaseWriter_H__ */
Copied: code/trunk/src/libraries/util/output/BaseWriter.h (from rev 8857, code/branches/output/src/libraries/util/output/BaseWriter.h)
===================================================================
--- code/trunk/src/libraries/util/output/BaseWriter.h (rev 0)
+++ code/trunk/src/libraries/util/output/BaseWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,120 @@
+/*
+ * 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 BaseWriter class, the base of all output writers.
+*/
+
+#ifndef _BaseWriter_H__
+#define _BaseWriter_H__
+
+#include "util/UtilPrereqs.h"
+#include "SubcontextOutputListener.h"
+
+namespace orxonox
+{
+ /**
+ @brief BaseWriter is an output listener and makes the accepted output levels and contexts configurable.
+
+ All output writers like ConsoleWriter and LogWriter are inherited from
+ this class. BaseWriter itself inherits from SubcontextOutputListener.
+ It adds helper functions to configure the accepted levels and contexts.
+
+ The levels are not fully configurable, only the "max" form is allowed
+ (which means that it's only possible to define a maximum level, not
+ the full mask).
+
+ Contexts are defined by a vector of strings, each context is defined
+ by it's name. Sub-contexts have the form \a "main-name::sub-name", i.e.
+ their name is concatenated with :: in between.
+
+ Each instance of BaseWriter needs a name to generate distinguishable
+ config values.
+
+ Received output messages are split into lines and sent line by line to
+ the virtual printLine() function. Each line has a prepended prefix
+ which describes the level and context of the output.
+ */
+ class _UtilExport BaseWriter : public SubcontextOutputListener
+ {
+ public:
+ BaseWriter(const std::string& name, bool bRegister = true);
+ virtual ~BaseWriter();
+
+ void setLevelMax(OutputLevel max);
+ void setAdditionalContextsLevelMax(OutputLevel max);
+
+ /// @brief Returns the name of this instance.
+ const std::string& getName() const
+ { return this->name_; }
+
+ /// Config value, used to define the maximum output level (independent of contexts)
+ int configurableMaxLevel_;
+ /// @brief Returns the name of the config value which defines the maximum output level (independent of contexts).
+ inline std::string getConfigurableMaxLevelName() const
+ { return this->name_ + "Level"; }
+
+ /// Config value, used to define the maximum output level of additional context
+ int configurableAdditionalContextsMaxLevel_;
+ /// @brief Returns the name of the config value which defines the maximum output level of additional context.
+ inline std::string getConfigurableAdditionalContextsMaxLevelName() const
+ { return this->name_ + "AdditionalContextsLevel"; }
+
+ /// Config vector, used to define the additional contexts (and sub-contexts)
+ std::vector<std::string> configurableAdditionalContexts_;
+ /// @brief Returns the name of the config vector which defines the additional contexts (and sub-contexts)
+ inline std::string getConfigurableAdditionalContextsName() const
+ { return this->name_ + "AdditionalContexts"; }
+
+ void changedConfigurableLevel();
+ void changedConfigurableAdditionalContextsLevel();
+ void changedConfigurableAdditionalContexts();
+
+ /// Returns the (static) name of the section wherein the config-values are defined.
+ static inline std::string getConfigurableSectionName()
+ { return "Output"; }
+
+ protected:
+ virtual void output(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines);
+
+ private:
+ virtual void printLine(const std::string& line, OutputLevel level) = 0; ///< Pure virtual function, gets called for each line of output together with a prefix which describes level and context of the output.
+
+ void setLevelRange(OutputLevel min, OutputLevel max); ///< Inherited function, overwritten as private because it is not supported by the config-value
+ void setLevelMask(OutputLevel mask); ///< Inherited function, overwritten as private because it is not supported by the config-value
+
+ void setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max); ///< Inherited function, overwritten as private because it is not supported by the config-value
+ void setAdditionalContextsLevelMask(OutputLevel mask); ///< Inherited function, overwritten as private because it is not supported by the config-value
+
+ std::string name_; ///< The name of this instance, used to generate unique config-values
+ };
+}
+
+#endif /* _BaseWriter_H__ */
Deleted: code/trunk/src/libraries/util/output/CMakeLists.txt
===================================================================
--- code/branches/output/src/libraries/util/output/CMakeLists.txt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,12 +0,0 @@
-ADD_SOURCE_FILES(UTIL_SRC_FILES
-BUILD_UNIT OutputBuildUnit.cc
- OutputStream.cc
- OutputManager.cc
- OutputListener.cc
- SubcontextOutputListener.cc
- BaseWriter.cc
- ConsoleWriter.cc
- LogWriter.cc
- MemoryWriter.cc
-END_BUILD_UNIT
-)
Copied: code/trunk/src/libraries/util/output/CMakeLists.txt (from rev 8857, code/branches/output/src/libraries/util/output/CMakeLists.txt)
===================================================================
--- code/trunk/src/libraries/util/output/CMakeLists.txt (rev 0)
+++ code/trunk/src/libraries/util/output/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,12 @@
+ADD_SOURCE_FILES(UTIL_SRC_FILES
+BUILD_UNIT OutputBuildUnit.cc
+ OutputStream.cc
+ OutputManager.cc
+ OutputListener.cc
+ SubcontextOutputListener.cc
+ BaseWriter.cc
+ ConsoleWriter.cc
+ LogWriter.cc
+ MemoryWriter.cc
+END_BUILD_UNIT
+)
Deleted: code/trunk/src/libraries/util/output/ConsoleWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,107 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- *
- */
-
-/**
- @file
- @brief Implementation of the ConsoleWriter singleton.
-*/
-
-#include "ConsoleWriter.h"
-
-#include <iostream>
-
-#include "OutputManager.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor, initializes the output level.
-
- In debug builds, it writes output up to level::internal_warning to the
- console, in release builds only up to level::user_info.
-
- After creation, the instance is enabled.
- */
- ConsoleWriter::ConsoleWriter() : BaseWriter("Console")
- {
-#ifdef ORXONOX_RELEASE
- this->setLevelMax(level::user_info);
-#else
- this->setLevelMax(level::internal_warning);
-#endif
- this->bEnabled_ = true;
- }
-
- /**
- @brief Destructor.
- */
- ConsoleWriter::~ConsoleWriter()
- {
- }
-
- /**
- @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;
- }
-
- /**
- @brief Enables the instance by registering itself as listener at OutputManager.
- */
- void ConsoleWriter::enable()
- {
- if (!this->bEnabled_)
- {
- OutputManager::getInstance().registerListener(this);
- this->bEnabled_ = true;
- }
- }
-
- /**
- @brief Disables the instance by unregistering itself from OutputManager.
- */
- void ConsoleWriter::disable()
- {
- if (this->bEnabled_)
- {
- OutputManager::getInstance().unregisterListener(this);
- this->bEnabled_ = false;
- }
- }
-}
Copied: code/trunk/src/libraries/util/output/ConsoleWriter.cc (from rev 8857, code/branches/output/src/libraries/util/output/ConsoleWriter.cc)
===================================================================
--- code/trunk/src/libraries/util/output/ConsoleWriter.cc (rev 0)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,107 @@
+/*
+ * 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:
+ * Reto Grieder
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the ConsoleWriter singleton.
+*/
+
+#include "ConsoleWriter.h"
+
+#include <iostream>
+
+#include "OutputManager.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor, initializes the output level.
+
+ In debug builds, it writes output up to level::internal_warning to the
+ console, in release builds only up to level::user_info.
+
+ After creation, the instance is enabled.
+ */
+ ConsoleWriter::ConsoleWriter() : BaseWriter("Console")
+ {
+#ifdef ORXONOX_RELEASE
+ this->setLevelMax(level::user_info);
+#else
+ this->setLevelMax(level::internal_warning);
+#endif
+ this->bEnabled_ = true;
+ }
+
+ /**
+ @brief Destructor.
+ */
+ ConsoleWriter::~ConsoleWriter()
+ {
+ }
+
+ /**
+ @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;
+ }
+
+ /**
+ @brief Enables the instance by registering itself as listener at OutputManager.
+ */
+ void ConsoleWriter::enable()
+ {
+ if (!this->bEnabled_)
+ {
+ OutputManager::getInstance().registerListener(this);
+ this->bEnabled_ = true;
+ }
+ }
+
+ /**
+ @brief Disables the instance by unregistering itself from OutputManager.
+ */
+ void ConsoleWriter::disable()
+ {
+ if (this->bEnabled_)
+ {
+ OutputManager::getInstance().unregisterListener(this);
+ this->bEnabled_ = false;
+ }
+ }
+}
Deleted: code/trunk/src/libraries/util/output/ConsoleWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/ConsoleWriter.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,69 +0,0 @@
-/*
- * 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 ConsoleWriter singleton which is used to write output to the console.
-*/
-
-#ifndef _ConsoleWriter_H__
-#define _ConsoleWriter_H__
-
-#include "util/UtilPrereqs.h"
-#include "BaseWriter.h"
-
-namespace orxonox
-{
- /**
- @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.
- */
- class _UtilExport ConsoleWriter : public BaseWriter
- {
- public:
- static ConsoleWriter& getInstance();
-
- void enable();
- void disable();
-
- 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.
- };
-}
-
-#endif /* _ConsoleWriter_H__ */
Copied: code/trunk/src/libraries/util/output/ConsoleWriter.h (from rev 8857, code/branches/output/src/libraries/util/output/ConsoleWriter.h)
===================================================================
--- code/trunk/src/libraries/util/output/ConsoleWriter.h (rev 0)
+++ code/trunk/src/libraries/util/output/ConsoleWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,69 @@
+/*
+ * 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 ConsoleWriter singleton which is used to write output to the console.
+*/
+
+#ifndef _ConsoleWriter_H__
+#define _ConsoleWriter_H__
+
+#include "util/UtilPrereqs.h"
+#include "BaseWriter.h"
+
+namespace orxonox
+{
+ /**
+ @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.
+ */
+ class _UtilExport ConsoleWriter : public BaseWriter
+ {
+ public:
+ static ConsoleWriter& getInstance();
+
+ void enable();
+ void disable();
+
+ 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.
+ };
+}
+
+#endif /* _ConsoleWriter_H__ */
Deleted: code/trunk/src/libraries/util/output/LogWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/LogWriter.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/LogWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,157 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- *
- */
-
-/**
- @file
- @brief Implementation of the LogWriter singleton.
-*/
-
-#include "LogWriter.h"
-
-#include <ctime>
-#include <cstdlib>
-
-#include "OutputManager.h"
-#include "MemoryWriter.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.
-
- By default, LogWriter receives all output up to level::internal_info.
- The log-file has a default name which usually doesn't change. The path
- is initialized with a temporary directory, depending on the system,
- and can be changed later.
- */
- LogWriter::LogWriter() : BaseWriter("Log")
- {
- this->setLevelMax(level::internal_info);
-
- this->filename_ = "orxonox.log";
-
- // get the path for a temporary file, depending on the system
-#ifdef ORXONOX_PLATFORM_WINDOWS
- this->path_ = getenv("TEMP");
-#else
- this->path_ = "/tmp";
-#endif
- this->bDefaultPath_ = true;
-
- this->openFile();
- }
-
- /**
- @brief Destructor, closes the log-file.
- */
- LogWriter::~LogWriter()
- {
- this->closeFile();
- }
-
- /**
- @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_;
-
- // 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);
-
- // check if it worked and print some output
- if (this->file_.is_open())
- this->printLine("Log file opened", level::none);
- else
- OutputManager::getInstance().pushMessage(level::user_warning, context::undefined(), "Failed to open log file. File logging disabled.");
- }
-
- /**
- @brief Closes the log-file.
- */
- void LogWriter::closeFile()
- {
- if (this->file_.is_open())
- {
- this->printLine("Log file closed", level::none);
- this->file_.close();
- }
- }
-
- /**
- @brief Changes the path of the log-file. Re-writes the log-file by using MemoryWriter.
- */
- void LogWriter::setLogPath(const std::string& path)
- {
- // 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);
-
- // close the old file, update the path and open the new file
- this->closeFile();
- this->path_ = path;
- this->bDefaultPath_ = false;
- this->openFile();
-
- // request old output from MemoryWriter
- MemoryWriter::getInstance().resendOutput(this);
- }
-
- /**
- @brief Inherited function from BaseWriter, writers output together with a timestamp to the log-file.
- */
- void LogWriter::printLine(const std::string& line, OutputLevel)
- {
- if (!this->file_.is_open())
- return;
-
- // get the current time
- time_t rawtime;
- struct tm* timeinfo;
- time(&rawtime);
- timeinfo = localtime(&rawtime);
-
- // print timestamp and output line to the log file
- this->file_ << (timeinfo->tm_hour < 10 ? "0" : "") << timeinfo->tm_hour << ':' <<
- (timeinfo->tm_min < 10 ? "0" : "") << timeinfo->tm_min << ':' <<
- (timeinfo->tm_sec < 10 ? "0" : "") << timeinfo->tm_sec << ' ' << line << std::endl;
- }
-}
Copied: code/trunk/src/libraries/util/output/LogWriter.cc (from rev 8857, code/branches/output/src/libraries/util/output/LogWriter.cc)
===================================================================
--- code/trunk/src/libraries/util/output/LogWriter.cc (rev 0)
+++ code/trunk/src/libraries/util/output/LogWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,157 @@
+/*
+ * 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:
+ * Reto Grieder
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the LogWriter singleton.
+*/
+
+#include "LogWriter.h"
+
+#include <ctime>
+#include <cstdlib>
+
+#include "OutputManager.h"
+#include "MemoryWriter.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor, initializes the desired output levels and the name and path of the log-file, and opens the log-file.
+
+ By default, LogWriter receives all output up to level::internal_info.
+ The log-file has a default name which usually doesn't change. The path
+ is initialized with a temporary directory, depending on the system,
+ and can be changed later.
+ */
+ LogWriter::LogWriter() : BaseWriter("Log")
+ {
+ this->setLevelMax(level::internal_info);
+
+ this->filename_ = "orxonox.log";
+
+ // get the path for a temporary file, depending on the system
+#ifdef ORXONOX_PLATFORM_WINDOWS
+ this->path_ = getenv("TEMP");
+#else
+ this->path_ = "/tmp";
+#endif
+ this->bDefaultPath_ = true;
+
+ this->openFile();
+ }
+
+ /**
+ @brief Destructor, closes the log-file.
+ */
+ LogWriter::~LogWriter()
+ {
+ this->closeFile();
+ }
+
+ /**
+ @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_;
+
+ // 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);
+
+ // check if it worked and print some output
+ if (this->file_.is_open())
+ this->printLine("Log file opened", level::none);
+ else
+ OutputManager::getInstance().pushMessage(level::user_warning, context::undefined(), "Failed to open log file. File logging disabled.");
+ }
+
+ /**
+ @brief Closes the log-file.
+ */
+ void LogWriter::closeFile()
+ {
+ if (this->file_.is_open())
+ {
+ this->printLine("Log file closed", level::none);
+ this->file_.close();
+ }
+ }
+
+ /**
+ @brief Changes the path of the log-file. Re-writes the log-file by using MemoryWriter.
+ */
+ void LogWriter::setLogPath(const std::string& path)
+ {
+ // 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);
+
+ // close the old file, update the path and open the new file
+ this->closeFile();
+ this->path_ = path;
+ this->bDefaultPath_ = false;
+ this->openFile();
+
+ // request old output from MemoryWriter
+ MemoryWriter::getInstance().resendOutput(this);
+ }
+
+ /**
+ @brief Inherited function from BaseWriter, writers output together with a timestamp to the log-file.
+ */
+ void LogWriter::printLine(const std::string& line, OutputLevel)
+ {
+ if (!this->file_.is_open())
+ return;
+
+ // get the current time
+ time_t rawtime;
+ struct tm* timeinfo;
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+
+ // print timestamp and output line to the log file
+ this->file_ << (timeinfo->tm_hour < 10 ? "0" : "") << timeinfo->tm_hour << ':' <<
+ (timeinfo->tm_min < 10 ? "0" : "") << timeinfo->tm_min << ':' <<
+ (timeinfo->tm_sec < 10 ? "0" : "") << timeinfo->tm_sec << ' ' << line << std::endl;
+ }
+}
Deleted: code/trunk/src/libraries/util/output/LogWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/LogWriter.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/LogWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,82 +0,0 @@
-/*
- * 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 LogWriter singleton which writes output to a log-file.
-*/
-
-#ifndef _LogWriter_H__
-#define _LogWriter_H__
-
-#include "util/UtilPrereqs.h"
-
-#include <fstream>
-
-#include "BaseWriter.h"
-
-namespace orxonox
-{
- /**
- @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
- 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
- at the new path.
- */
- class _UtilExport LogWriter : public BaseWriter
- {
- public:
- static LogWriter& getInstance();
-
- void setLogPath(const std::string& path);
-
- 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)
-
- std::ofstream file_; ///< The output file stream.
- };
-}
-
-#endif /* _LogWriter_H__ */
Copied: code/trunk/src/libraries/util/output/LogWriter.h (from rev 8857, code/branches/output/src/libraries/util/output/LogWriter.h)
===================================================================
--- code/trunk/src/libraries/util/output/LogWriter.h (rev 0)
+++ code/trunk/src/libraries/util/output/LogWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,82 @@
+/*
+ * 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 LogWriter singleton which writes output to a log-file.
+*/
+
+#ifndef _LogWriter_H__
+#define _LogWriter_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <fstream>
+
+#include "BaseWriter.h"
+
+namespace orxonox
+{
+ /**
+ @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
+ 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
+ at the new path.
+ */
+ class _UtilExport LogWriter : public BaseWriter
+ {
+ public:
+ static LogWriter& getInstance();
+
+ void setLogPath(const std::string& path);
+
+ 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)
+
+ std::ofstream file_; ///< The output file stream.
+ };
+}
+
+#endif /* _LogWriter_H__ */
Deleted: code/trunk/src/libraries/util/output/MemoryWriter.cc
===================================================================
--- code/branches/output/src/libraries/util/output/MemoryWriter.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/MemoryWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,91 +0,0 @@
-/*
- * 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:
- * Reto Grieder
- *
- */
-
-/**
- @file
- @brief Implementation of the MemoryWriter singleton.
-*/
-
-#include "MemoryWriter.h"
-#include "OutputManager.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor, initializes the level mask with all levels activated.
- */
- MemoryWriter::MemoryWriter()
- {
- this->setLevelMask(level::all);
- }
-
- /**
- @brief Destructor.
- */
- MemoryWriter::~MemoryWriter()
- {
- }
-
- /**
- @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)
- {
- this->messages_.push_back(Message(level, context, lines));
- }
-
- /**
- @brief Iterates over all stored output messages and sends them to the OutputListener.
- */
- void MemoryWriter::resendOutput(OutputListener* listener) const
- {
- for (size_t i = 0; i < this->messages_.size(); ++i)
- {
- const Message& message = this->messages_[i];
- listener->unfilteredOutput(message.level, *message.context, message.lines);
- }
- }
-
- /**
- @brief Unregisters the instance from OutputManager, hence it will not receive any further output.
- */
- void MemoryWriter::disable()
- {
- OutputManager::getInstance().unregisterListener(this);
- this->output(level::debug_output, context::undefined(), std::vector<std::string>(1, "MemoryWriter disabled, further messages may be lost"));
- }
-}
Copied: code/trunk/src/libraries/util/output/MemoryWriter.cc (from rev 8857, code/branches/output/src/libraries/util/output/MemoryWriter.cc)
===================================================================
--- code/trunk/src/libraries/util/output/MemoryWriter.cc (rev 0)
+++ code/trunk/src/libraries/util/output/MemoryWriter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,91 @@
+/*
+ * 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:
+ * Reto Grieder
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the MemoryWriter singleton.
+*/
+
+#include "MemoryWriter.h"
+#include "OutputManager.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor, initializes the level mask with all levels activated.
+ */
+ MemoryWriter::MemoryWriter()
+ {
+ this->setLevelMask(level::all);
+ }
+
+ /**
+ @brief Destructor.
+ */
+ MemoryWriter::~MemoryWriter()
+ {
+ }
+
+ /**
+ @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)
+ {
+ this->messages_.push_back(Message(level, context, lines));
+ }
+
+ /**
+ @brief Iterates over all stored output messages and sends them to the OutputListener.
+ */
+ void MemoryWriter::resendOutput(OutputListener* listener) const
+ {
+ for (size_t i = 0; i < this->messages_.size(); ++i)
+ {
+ const Message& message = this->messages_[i];
+ listener->unfilteredOutput(message.level, *message.context, message.lines);
+ }
+ }
+
+ /**
+ @brief Unregisters the instance from OutputManager, hence it will not receive any further output.
+ */
+ void MemoryWriter::disable()
+ {
+ OutputManager::getInstance().unregisterListener(this);
+ this->output(level::debug_output, context::undefined(), std::vector<std::string>(1, "MemoryWriter disabled, further messages may be lost"));
+ }
+}
Deleted: code/trunk/src/libraries/util/output/MemoryWriter.h
===================================================================
--- code/branches/output/src/libraries/util/output/MemoryWriter.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/MemoryWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,86 +0,0 @@
-/*
- * 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 MemoryWriter singleton.
-*/
-
-#ifndef _MemoryWriter_H__
-#define _MemoryWriter_H__
-
-#include "util/UtilPrereqs.h"
-#include "OutputListener.h"
-
-namespace orxonox
-{
- /**
- @brief MemoryWriter is a singleton which is derived from OutputListener and writes all output to a list.
-
- This list can be used to re-send old output to other instances of
- OutputListener, e.g. if they were newly created or to re-write the
- log-file.
-
- Since MemoryWriter receives output of all levels, this means also that
- all possible output needs to be generated as long as MemoryWriter stays
- active. Hence disable() should be called as soon as possible.
- */
- class _UtilExport MemoryWriter : public OutputListener
- {
- /// @brief A helper struct which is used to store output and its properties.
- struct Message
- {
- /// @brief Constructor, assigns all values.
- Message(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
- : level(level), context(&context), lines(lines) {}
-
- OutputLevel level; ///< The level of the output message
- const OutputContextContainer* context; ///< The context of the output message
- std::vector<std::string> lines; ///< The lines of text of the output message
- };
-
- public:
- static MemoryWriter& getInstance();
-
- void resendOutput(OutputListener* listener) const;
- void disable();
-
- protected:
- 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.
- };
-}
-
-#endif /* _MemoryWriter_H__ */
Copied: code/trunk/src/libraries/util/output/MemoryWriter.h (from rev 8857, code/branches/output/src/libraries/util/output/MemoryWriter.h)
===================================================================
--- code/trunk/src/libraries/util/output/MemoryWriter.h (rev 0)
+++ code/trunk/src/libraries/util/output/MemoryWriter.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,86 @@
+/*
+ * 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 MemoryWriter singleton.
+*/
+
+#ifndef _MemoryWriter_H__
+#define _MemoryWriter_H__
+
+#include "util/UtilPrereqs.h"
+#include "OutputListener.h"
+
+namespace orxonox
+{
+ /**
+ @brief MemoryWriter is a singleton which is derived from OutputListener and writes all output to a list.
+
+ This list can be used to re-send old output to other instances of
+ OutputListener, e.g. if they were newly created or to re-write the
+ log-file.
+
+ Since MemoryWriter receives output of all levels, this means also that
+ all possible output needs to be generated as long as MemoryWriter stays
+ active. Hence disable() should be called as soon as possible.
+ */
+ class _UtilExport MemoryWriter : public OutputListener
+ {
+ /// @brief A helper struct which is used to store output and its properties.
+ struct Message
+ {
+ /// @brief Constructor, assigns all values.
+ Message(OutputLevel level, const OutputContextContainer& context, const std::vector<std::string>& lines)
+ : level(level), context(&context), lines(lines) {}
+
+ OutputLevel level; ///< The level of the output message
+ const OutputContextContainer* context; ///< The context of the output message
+ std::vector<std::string> lines; ///< The lines of text of the output message
+ };
+
+ public:
+ static MemoryWriter& getInstance();
+
+ void resendOutput(OutputListener* listener) const;
+ void disable();
+
+ protected:
+ 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.
+ };
+}
+
+#endif /* _MemoryWriter_H__ */
Deleted: code/trunk/src/libraries/util/output/OutputDefinitions.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputDefinitions.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputDefinitions.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,166 +0,0 @@
-/*
- * 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 Defines output levels and output contexts.
-*/
-
-#ifndef _OutputDefinitions_H__
-#define _OutputDefinitions_H__
-
-#include "util/UtilPrereqs.h"
-#include <string>
-
-/**
- @brief Defines a context function with a given name.
- @param name Name of the context
-
- Context functions return a reference to a OutputContextContainer. Context
- 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; }
-
-/**
- @brief Defines a sub-context.
- @param name Name of the main-context
- @param subname Name of the sub-context
-
- Sub-contexts act like normal contexts, except that multiple sub-contexts
- share the context mask of their main-context. This allows contexts with
- 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; }
-
-// tolua_begin
-namespace orxonox
-{
- namespace level
- {
- /**
- @brief Output levels define type and importance of an output message.
- They can be passed to the orxout() function as level argument.
- */
- enum OutputLevel
- {
- all = 0xFFFF, ///< Level mask with all bits set to 1
- none = 0x0000, ///< Level mask with all bits set to 0
-
- message = 0x0001, ///< Output level, used for messages directed to the user (e.g. "Press any key to continue")
- debug_output = 0x0002, ///< Output level, used for temporary debug output while writing code
- user_error = 0x0004, ///< Output level, used for error messages which are important for the user
- user_warning = 0x0008, ///< Output level, used for warnings which are important for the user
- user_status = 0x0010, ///< Output level, used to notify the user about the program's state
- user_info = 0x0020, ///< Output level, used to provide the user with additional progress information
- internal_error = 0x0040, ///< Output level, used for error messages which are important for developers
- internal_warning = 0x0080, ///< Output level, used for warnings which are important for developers
- internal_status = 0x0100, ///< Output level, used to log the program's internal state in the log file
- internal_info = 0x0200, ///< Output level, used to log information about the program's progress in the log file
- verbose = 0x0400, ///< Output level, usually not visible, used for unimportant debug information
- verbose_more = 0x0800, ///< Output level, usually not visible, used for unimportant debug information (less important than verbose)
- verbose_ultra = 0x1000 ///< Output level, usually not visible, used for unimportant debug information (even less important than verbose_more)
- };
- }
-// tolua_end
-
- using namespace level;
-
- typedef uint64_t OutputContextMask; ///< Used to store the context masks. Each bit defines a context.
- typedef uint16_t OutputContextSubID; ///< Used to store the IDs of sub-contexts. Each number except context::no_subcontext defines a sub-context.
-
- /// @brief Stores all information about a context.
- struct OutputContextContainer
- {
- 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
- };
-
- typedef const OutputContextContainer& (OutputContextFunction)();
-
- /**
- @brief Registers a context.
- This is a shortcut to OutputManager::registerContext() to avoid the inclusion of its header file.
- */
- extern _UtilExport const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
-
- namespace context
- {
- static const OutputContextMask all = 0xFFFFFFFFFFFFFFFF; ///< Context mask, all bits set to 1
- static const OutputContextMask none = 0x0000000000000000; ///< Context mask, all bits set to 0
-
- static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
-
- namespace
- {
- REGISTER_OUTPUT_CONTEXT(undefined); ///< "undefined" context which is implicitly used for all output that has no explicit context
-
- REGISTER_OUTPUT_CONTEXT(ogre);
- REGISTER_OUTPUT_CONTEXT(cegui);
- REGISTER_OUTPUT_CONTEXT(lua);
- REGISTER_OUTPUT_CONTEXT(tcl);
- REGISTER_OUTPUT_CONTEXT(identifier);
- REGISTER_OUTPUT_CONTEXT(object_list);
- REGISTER_OUTPUT_CONTEXT(super);
- REGISTER_OUTPUT_CONTEXT(language);
- REGISTER_OUTPUT_CONTEXT(commands);
- REGISTER_OUTPUT_CONTEXT(input);
- REGISTER_OUTPUT_CONTEXT(events);
- REGISTER_OUTPUT_CONTEXT(config);
- REGISTER_OUTPUT_CONTEXT(templates);
- REGISTER_OUTPUT_CONTEXT(loader);
- REGISTER_OUTPUT_CONTEXT(xml);
- REGISTER_OUTPUT_CONTEXT(network);
- REGISTER_OUTPUT_CONTEXT(packets);
- REGISTER_OUTPUT_CONTEXT(master_server);
- REGISTER_OUTPUT_CONTEXT(sound);
- REGISTER_OUTPUT_CONTEXT(lod);
- REGISTER_OUTPUT_CONTEXT(pickups);
- REGISTER_OUTPUT_CONTEXT(quests);
- REGISTER_OUTPUT_CONTEXT(notifications);
- REGISTER_OUTPUT_CONTEXT(triggers);
- REGISTER_OUTPUT_CONTEXT(docking);
-
- namespace misc
- {
- REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
- REGISTER_OUTPUT_SUBCONTEXT(misc, factory);
- REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
- REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
- REGISTER_OUTPUT_SUBCONTEXT(misc, script);
- }
- }
- }
-} // tolua_export
-
-#endif /* _OutputDefinitions_H__ */
Copied: code/trunk/src/libraries/util/output/OutputDefinitions.h (from rev 8857, code/branches/output/src/libraries/util/output/OutputDefinitions.h)
===================================================================
--- code/trunk/src/libraries/util/output/OutputDefinitions.h (rev 0)
+++ code/trunk/src/libraries/util/output/OutputDefinitions.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,166 @@
+/*
+ * 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 Defines output levels and output contexts.
+*/
+
+#ifndef _OutputDefinitions_H__
+#define _OutputDefinitions_H__
+
+#include "util/UtilPrereqs.h"
+#include <string>
+
+/**
+ @brief Defines a context function with a given name.
+ @param name Name of the context
+
+ Context functions return a reference to a OutputContextContainer. Context
+ 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; }
+
+/**
+ @brief Defines a sub-context.
+ @param name Name of the main-context
+ @param subname Name of the sub-context
+
+ Sub-contexts act like normal contexts, except that multiple sub-contexts
+ share the context mask of their main-context. This allows contexts with
+ 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; }
+
+// tolua_begin
+namespace orxonox
+{
+ namespace level
+ {
+ /**
+ @brief Output levels define type and importance of an output message.
+ They can be passed to the orxout() function as level argument.
+ */
+ enum OutputLevel
+ {
+ all = 0xFFFF, ///< Level mask with all bits set to 1
+ none = 0x0000, ///< Level mask with all bits set to 0
+
+ message = 0x0001, ///< Output level, used for messages directed to the user (e.g. "Press any key to continue")
+ debug_output = 0x0002, ///< Output level, used for temporary debug output while writing code
+ user_error = 0x0004, ///< Output level, used for error messages which are important for the user
+ user_warning = 0x0008, ///< Output level, used for warnings which are important for the user
+ user_status = 0x0010, ///< Output level, used to notify the user about the program's state
+ user_info = 0x0020, ///< Output level, used to provide the user with additional progress information
+ internal_error = 0x0040, ///< Output level, used for error messages which are important for developers
+ internal_warning = 0x0080, ///< Output level, used for warnings which are important for developers
+ internal_status = 0x0100, ///< Output level, used to log the program's internal state in the log file
+ internal_info = 0x0200, ///< Output level, used to log information about the program's progress in the log file
+ verbose = 0x0400, ///< Output level, usually not visible, used for unimportant debug information
+ verbose_more = 0x0800, ///< Output level, usually not visible, used for unimportant debug information (less important than verbose)
+ verbose_ultra = 0x1000 ///< Output level, usually not visible, used for unimportant debug information (even less important than verbose_more)
+ };
+ }
+// tolua_end
+
+ using namespace level;
+
+ typedef uint64_t OutputContextMask; ///< Used to store the context masks. Each bit defines a context.
+ typedef uint16_t OutputContextSubID; ///< Used to store the IDs of sub-contexts. Each number except context::no_subcontext defines a sub-context.
+
+ /// @brief Stores all information about a context.
+ struct OutputContextContainer
+ {
+ 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
+ };
+
+ typedef const OutputContextContainer& (OutputContextFunction)();
+
+ /**
+ @brief Registers a context.
+ This is a shortcut to OutputManager::registerContext() to avoid the inclusion of its header file.
+ */
+ extern _UtilExport const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
+
+ namespace context
+ {
+ static const OutputContextMask all = 0xFFFFFFFFFFFFFFFF; ///< Context mask, all bits set to 1
+ static const OutputContextMask none = 0x0000000000000000; ///< Context mask, all bits set to 0
+
+ static const OutputContextSubID no_subcontext = 0; ///< Used as ID for contexts which are not sub-contexts
+
+ namespace
+ {
+ REGISTER_OUTPUT_CONTEXT(undefined); ///< "undefined" context which is implicitly used for all output that has no explicit context
+
+ REGISTER_OUTPUT_CONTEXT(ogre);
+ REGISTER_OUTPUT_CONTEXT(cegui);
+ REGISTER_OUTPUT_CONTEXT(lua);
+ REGISTER_OUTPUT_CONTEXT(tcl);
+ REGISTER_OUTPUT_CONTEXT(identifier);
+ REGISTER_OUTPUT_CONTEXT(object_list);
+ REGISTER_OUTPUT_CONTEXT(super);
+ REGISTER_OUTPUT_CONTEXT(language);
+ REGISTER_OUTPUT_CONTEXT(commands);
+ REGISTER_OUTPUT_CONTEXT(input);
+ REGISTER_OUTPUT_CONTEXT(events);
+ REGISTER_OUTPUT_CONTEXT(config);
+ REGISTER_OUTPUT_CONTEXT(templates);
+ REGISTER_OUTPUT_CONTEXT(loader);
+ REGISTER_OUTPUT_CONTEXT(xml);
+ REGISTER_OUTPUT_CONTEXT(network);
+ REGISTER_OUTPUT_CONTEXT(packets);
+ REGISTER_OUTPUT_CONTEXT(master_server);
+ REGISTER_OUTPUT_CONTEXT(sound);
+ REGISTER_OUTPUT_CONTEXT(lod);
+ REGISTER_OUTPUT_CONTEXT(pickups);
+ REGISTER_OUTPUT_CONTEXT(quests);
+ REGISTER_OUTPUT_CONTEXT(notifications);
+ REGISTER_OUTPUT_CONTEXT(triggers);
+ REGISTER_OUTPUT_CONTEXT(docking);
+
+ namespace misc
+ {
+ REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
+ REGISTER_OUTPUT_SUBCONTEXT(misc, factory);
+ REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
+ REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
+ REGISTER_OUTPUT_SUBCONTEXT(misc, script);
+ }
+ }
+ }
+} // tolua_export
+
+#endif /* _OutputDefinitions_H__ */
Deleted: code/trunk/src/libraries/util/output/OutputListener.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputListener.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,149 +0,0 @@
-/*
- * 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
- @brief Implementation of the OutputListener class.
-*/
-
-#include "OutputListener.h"
-
-#include "OutputManager.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor, initializes the values and registers the instance at OutputManager if requested.
- @param bRegister If \c true, the instance is automatically registered at OutputManager.
- Should be \c false if the constructor of the derived class generates output.
- */
- OutputListener::OutputListener(bool bRegister)
- {
- this->levelMask_ = level::none;
- this->additionalContextsLevelMask_ = level::none;
- this->additionalContextsMask_ = context::none;
-
- if (bRegister)
- OutputManager::getInstance().registerListener(this);
- }
-
- /**
- @brief Destructor, unregisters the instance from OutputManager.
- */
- OutputListener::~OutputListener()
- {
- OutputManager::getInstance().unregisterListener(this);
- }
-
- /**
- @brief Defines the level mask in a way which accepts all output up to the level \c max.
- */
- void OutputListener::setLevelMax(OutputLevel max)
- {
- this->setLevelRange(static_cast<OutputLevel>(0x1), max);
- }
-
- /**
- @brief Defines the level mask in a way which accepts all output between the levels \c min and \c max.
- */
- void OutputListener::setLevelRange(OutputLevel min, OutputLevel max)
- {
- int mask = 0;
- for (int level = min; level <= max; level = level << 1)
- mask |= level;
-
- this->setLevelMask(static_cast<OutputLevel>(mask));
- }
-
- /**
- @brief Defines the level mask.
- */
- void OutputListener::setLevelMask(OutputLevel mask)
- {
- this->levelMask_ = mask;
-
- OutputManager::getInstance().updateCombinedLevelMask();
- }
-
- /**
- @brief Defines the level mask of additional contexts in a way which accepts all output up to the level \c max.
- */
- void OutputListener::setAdditionalContextsLevelMax(OutputLevel max)
- {
- this->setAdditionalContextsLevelRange(static_cast<OutputLevel>(0x1), max);
- }
-
- /**
- @brief Defines the level mask of additional contexts in a way which accepts all output between the levels \c min and \c max.
- */
- void OutputListener::setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max)
- {
- int mask = 0;
- for (int level = min; level <= max; level = level << 1)
- mask |= level;
-
- this->setAdditionalContextsLevelMask(static_cast<OutputLevel>(mask));
- }
-
- /**
- @brief Defines the level mask of additional contexts.
- */
- void OutputListener::setAdditionalContextsLevelMask(OutputLevel mask)
- {
- this->additionalContextsLevelMask_ = mask;
-
- OutputManager::getInstance().updateCombinedAdditionalContextsLevelMask();
- }
-
- /**
- @brief Defines the mask of additional contexts.
- */
- void OutputListener::setAdditionalContextsMask(OutputContextMask mask)
- {
- this->additionalContextsMask_ = mask;
-
- OutputManager::getInstance().updateCombinedAdditionalContextsMask();
- }
-
- /**
- @brief Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks.
- */
- bool OutputListener::acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
- {
- // check if the output level is accepted by the level mask (independent of the context)
- if (this->levelMask_ & level)
- return true;
-
- // check if the output context is accepted by the additional context mask and if the level matches as well
- if ((this->additionalContextsMask_ & context.mask) && (this->additionalContextsLevelMask_ & level))
- return true;
-
- // otherwise we don't accept the output
- return false;
- }
-}
Copied: code/trunk/src/libraries/util/output/OutputListener.cc (from rev 8857, code/branches/output/src/libraries/util/output/OutputListener.cc)
===================================================================
--- code/trunk/src/libraries/util/output/OutputListener.cc (rev 0)
+++ code/trunk/src/libraries/util/output/OutputListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,149 @@
+/*
+ * 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
+ @brief Implementation of the OutputListener class.
+*/
+
+#include "OutputListener.h"
+
+#include "OutputManager.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor, initializes the values and registers the instance at OutputManager if requested.
+ @param bRegister If \c true, the instance is automatically registered at OutputManager.
+ Should be \c false if the constructor of the derived class generates output.
+ */
+ OutputListener::OutputListener(bool bRegister)
+ {
+ this->levelMask_ = level::none;
+ this->additionalContextsLevelMask_ = level::none;
+ this->additionalContextsMask_ = context::none;
+
+ if (bRegister)
+ OutputManager::getInstance().registerListener(this);
+ }
+
+ /**
+ @brief Destructor, unregisters the instance from OutputManager.
+ */
+ OutputListener::~OutputListener()
+ {
+ OutputManager::getInstance().unregisterListener(this);
+ }
+
+ /**
+ @brief Defines the level mask in a way which accepts all output up to the level \c max.
+ */
+ void OutputListener::setLevelMax(OutputLevel max)
+ {
+ this->setLevelRange(static_cast<OutputLevel>(0x1), max);
+ }
+
+ /**
+ @brief Defines the level mask in a way which accepts all output between the levels \c min and \c max.
+ */
+ void OutputListener::setLevelRange(OutputLevel min, OutputLevel max)
+ {
+ int mask = 0;
+ for (int level = min; level <= max; level = level << 1)
+ mask |= level;
+
+ this->setLevelMask(static_cast<OutputLevel>(mask));
+ }
+
+ /**
+ @brief Defines the level mask.
+ */
+ void OutputListener::setLevelMask(OutputLevel mask)
+ {
+ this->levelMask_ = mask;
+
+ OutputManager::getInstance().updateCombinedLevelMask();
+ }
+
+ /**
+ @brief Defines the level mask of additional contexts in a way which accepts all output up to the level \c max.
+ */
+ void OutputListener::setAdditionalContextsLevelMax(OutputLevel max)
+ {
+ this->setAdditionalContextsLevelRange(static_cast<OutputLevel>(0x1), max);
+ }
+
+ /**
+ @brief Defines the level mask of additional contexts in a way which accepts all output between the levels \c min and \c max.
+ */
+ void OutputListener::setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max)
+ {
+ int mask = 0;
+ for (int level = min; level <= max; level = level << 1)
+ mask |= level;
+
+ this->setAdditionalContextsLevelMask(static_cast<OutputLevel>(mask));
+ }
+
+ /**
+ @brief Defines the level mask of additional contexts.
+ */
+ void OutputListener::setAdditionalContextsLevelMask(OutputLevel mask)
+ {
+ this->additionalContextsLevelMask_ = mask;
+
+ OutputManager::getInstance().updateCombinedAdditionalContextsLevelMask();
+ }
+
+ /**
+ @brief Defines the mask of additional contexts.
+ */
+ void OutputListener::setAdditionalContextsMask(OutputContextMask mask)
+ {
+ this->additionalContextsMask_ = mask;
+
+ OutputManager::getInstance().updateCombinedAdditionalContextsMask();
+ }
+
+ /**
+ @brief Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks.
+ */
+ bool OutputListener::acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
+ {
+ // check if the output level is accepted by the level mask (independent of the context)
+ if (this->levelMask_ & level)
+ return true;
+
+ // check if the output context is accepted by the additional context mask and if the level matches as well
+ if ((this->additionalContextsMask_ & context.mask) && (this->additionalContextsLevelMask_ & level))
+ return true;
+
+ // otherwise we don't accept the output
+ return false;
+ }
+}
Deleted: code/trunk/src/libraries/util/output/OutputListener.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputListener.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,174 +0,0 @@
-/*
- * 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 OutputListener interface which receives output
- from orxonox::OutputManager.
-*/
-
-#ifndef _OutputListener_H__
-#define _OutputListener_H__
-
-#include "util/UtilPrereqs.h"
-
-#include <vector>
-
-#include "OutputDefinitions.h"
-
-namespace orxonox
-{
- /**
- @brief OutputListener is an interface which is used to receive output of a certain level and context from OutputManager.
- */
- // See below the class declaration for a more detailed description.
- class _UtilExport OutputListener
- {
- public:
- OutputListener(bool bRegister = true);
- virtual ~OutputListener();
-
- void setLevelMax(OutputLevel max);
- void setLevelRange(OutputLevel min, OutputLevel max);
- void setLevelMask(OutputLevel mask);
-
- void setAdditionalContextsLevelMax(OutputLevel max);
- void setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max);
- void setAdditionalContextsLevelMask(OutputLevel mask);
-
- void setAdditionalContextsMask(OutputContextMask mask);
-
- /// @brief Returns the level mask.
- inline OutputLevel getLevelMask() const
- { return this->levelMask_; }
- /// @brief Returns the additional contexts mask.
- inline OutputContextMask getAdditionalContextsMask() const
- { return this->additionalContextsMask_; }
- /// @brief Returns the additional contexts level mask.
- inline OutputLevel getAdditionalContextsLevelMask() const
- { return this->additionalContextsLevelMask_; }
-
- 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)
- { 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;
-
- 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
- };
-
- /**
- @class OutputListener
-
- An instance of OutputListener registers itself at OutputManager and
- declares the desired output levels and contexts. OutputManager will
- then send output to it by calling the output() function.
-
- OutputListener has 3 masks to define the desired output. These masks
- can be used in two different ways (or as a combination of both):
- \li 1. By defining the \a "level mask": The OutputListener will then
- receive all output of these levels independent of the context.
- \li 2. By defining the \a "additional contexts mask" and the
- \a "additional contexts level mask": This way the listener
- receives only output of a particular context and level.
- \li 3. By using all 3 masks which combines the output defined by the
- first two ways.
-
- This can be illustrated as follows:
-
- 1. Only level mask:
- \li level-mask = error | warning;
-
- @verbatim
- | Contexts: |
- | A | B | C | D |
- --------|---|---|---|---|
- debug | - | - | - | - |
- --------|---|---|---|---|
- error | x | x | x | x |
- --------|---|---|---|---| [x] Receives output
- warning | x | x | x | x | [-] Does not receive output
- --------|---|---|---|---|
- status | - | - | - | - |
- --------|---|---|---|---|
- verbose | - | - | - | - |
- --------|---|---|---|---|
- @endverbatim
-
- 2. Only additional contexts:
- \li additional-contexts-mask = B | D;
- \li additional-contexts-level-mask = debug | verbose;
-
- @verbatim
- | Contexts: |
- | A | B | C | D |
- --------|---|---|---|---|
- debug | - | x | - | x |
- --------|---|---|---|---|
- error | - | - | - | - |
- --------|---|---|---|---| [x] Receives output
- warning | - | - | - | - | [-] Does not receive output
- --------|---|---|---|---|
- status | - | - | - | - |
- --------|---|---|---|---|
- verbose | - | x | - | x |
- --------|---|---|---|---|
- @endverbatim
-
- 3. Both level mask plus additional contexts:
- \li level-mask = error | warning;
- \li additional-contexts-mask = B | D;
- \li additional-contexts-level-mask = debug | verbose;
-
- @verbatim
- | Contexts: |
- | A | B | C | D |
- --------|---|---|---|---|
- debug | - | x | - | x |
- --------|---|---|---|---|
- error | x | x | x | x |
- --------|---|---|---|---| [x] Receives output
- warning | x | x | x | x | [-] Does not receive output
- --------|---|---|---|---|
- status | - | - | - | - |
- --------|---|---|---|---|
- verbose | - | x | - | x |
- --------|---|---|---|---|
- @endverbatim
- */
-}
-
-#endif /* _OutputListener_H__ */
Copied: code/trunk/src/libraries/util/output/OutputListener.h (from rev 8857, code/branches/output/src/libraries/util/output/OutputListener.h)
===================================================================
--- code/trunk/src/libraries/util/output/OutputListener.h (rev 0)
+++ code/trunk/src/libraries/util/output/OutputListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,174 @@
+/*
+ * 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 OutputListener interface which receives output
+ from orxonox::OutputManager.
+*/
+
+#ifndef _OutputListener_H__
+#define _OutputListener_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <vector>
+
+#include "OutputDefinitions.h"
+
+namespace orxonox
+{
+ /**
+ @brief OutputListener is an interface which is used to receive output of a certain level and context from OutputManager.
+ */
+ // See below the class declaration for a more detailed description.
+ class _UtilExport OutputListener
+ {
+ public:
+ OutputListener(bool bRegister = true);
+ virtual ~OutputListener();
+
+ void setLevelMax(OutputLevel max);
+ void setLevelRange(OutputLevel min, OutputLevel max);
+ void setLevelMask(OutputLevel mask);
+
+ void setAdditionalContextsLevelMax(OutputLevel max);
+ void setAdditionalContextsLevelRange(OutputLevel min, OutputLevel max);
+ void setAdditionalContextsLevelMask(OutputLevel mask);
+
+ void setAdditionalContextsMask(OutputContextMask mask);
+
+ /// @brief Returns the level mask.
+ inline OutputLevel getLevelMask() const
+ { return this->levelMask_; }
+ /// @brief Returns the additional contexts mask.
+ inline OutputContextMask getAdditionalContextsMask() const
+ { return this->additionalContextsMask_; }
+ /// @brief Returns the additional contexts level mask.
+ inline OutputLevel getAdditionalContextsLevelMask() const
+ { return this->additionalContextsLevelMask_; }
+
+ 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)
+ { 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;
+
+ 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
+ };
+
+ /**
+ @class OutputListener
+
+ An instance of OutputListener registers itself at OutputManager and
+ declares the desired output levels and contexts. OutputManager will
+ then send output to it by calling the output() function.
+
+ OutputListener has 3 masks to define the desired output. These masks
+ can be used in two different ways (or as a combination of both):
+ \li 1. By defining the \a "level mask": The OutputListener will then
+ receive all output of these levels independent of the context.
+ \li 2. By defining the \a "additional contexts mask" and the
+ \a "additional contexts level mask": This way the listener
+ receives only output of a particular context and level.
+ \li 3. By using all 3 masks which combines the output defined by the
+ first two ways.
+
+ This can be illustrated as follows:
+
+ 1. Only level mask:
+ \li level-mask = error | warning;
+
+ @verbatim
+ | Contexts: |
+ | A | B | C | D |
+ --------|---|---|---|---|
+ debug | - | - | - | - |
+ --------|---|---|---|---|
+ error | x | x | x | x |
+ --------|---|---|---|---| [x] Receives output
+ warning | x | x | x | x | [-] Does not receive output
+ --------|---|---|---|---|
+ status | - | - | - | - |
+ --------|---|---|---|---|
+ verbose | - | - | - | - |
+ --------|---|---|---|---|
+ @endverbatim
+
+ 2. Only additional contexts:
+ \li additional-contexts-mask = B | D;
+ \li additional-contexts-level-mask = debug | verbose;
+
+ @verbatim
+ | Contexts: |
+ | A | B | C | D |
+ --------|---|---|---|---|
+ debug | - | x | - | x |
+ --------|---|---|---|---|
+ error | - | - | - | - |
+ --------|---|---|---|---| [x] Receives output
+ warning | - | - | - | - | [-] Does not receive output
+ --------|---|---|---|---|
+ status | - | - | - | - |
+ --------|---|---|---|---|
+ verbose | - | x | - | x |
+ --------|---|---|---|---|
+ @endverbatim
+
+ 3. Both level mask plus additional contexts:
+ \li level-mask = error | warning;
+ \li additional-contexts-mask = B | D;
+ \li additional-contexts-level-mask = debug | verbose;
+
+ @verbatim
+ | Contexts: |
+ | A | B | C | D |
+ --------|---|---|---|---|
+ debug | - | x | - | x |
+ --------|---|---|---|---|
+ error | x | x | x | x |
+ --------|---|---|---|---| [x] Receives output
+ warning | x | x | x | x | [-] Does not receive output
+ --------|---|---|---|---|
+ status | - | - | - | - |
+ --------|---|---|---|---|
+ verbose | - | x | - | x |
+ --------|---|---|---|---|
+ @endverbatim
+ */
+}
+
+#endif /* _OutputListener_H__ */
Deleted: code/trunk/src/libraries/util/output/OutputManager.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,277 +0,0 @@
-/*
- * 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
- @brief Implementation of the OutputManager singleton.
-*/
-
-#include "OutputManager.h"
-
-#include "MemoryWriter.h"
-#include "ConsoleWriter.h"
-#include "LogWriter.h"
-#include "util/Output.h"
-#include "util/StringUtils.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor, initializes all values.
- */
- OutputManager::OutputManager()
- {
- this->combinedLevelMask_ = level::none;
- this->combinedAdditionalContextsLevelMask_ = level::none;
- this->combinedAdditionalContextsMask_ = context::none;
-
- this->subcontextCounter_ = 0;
- }
-
- /**
- @brief Destructor.
- */
- OutputManager::~OutputManager()
- {
- }
-
- /**
- @brief Returns the only existing instance of the OutputManager singleton.
- */
- /*static*/ OutputManager& OutputManager::getInstance()
- {
- static OutputManager instance;
- return instance;
- }
-
- /**
- @brief Returns the only existing instance of the OutputManager singleton
- and ensures that the most important output listeners exist.
-
- You should use this function if you send output to OutputManager and want
- to be sure that the most important output listeners exist. Don't use it
- elsewhere inside the output system to avoid circular calls.
- */
- /*static*/ OutputManager& OutputManager::getInstanceAndCreateListeners()
- {
- static OutputManager& instance = OutputManager::getInstance();
-
- static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
- static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
- static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
-
- return instance;
- }
-
- /**
- @brief Sends an output message to all output listeners.
- @param level The level of the message
- @param context The context of the message
- @param message The output message (may contain '\\n')
-
- This function splits the message into lines (if it contains '\\n') and
- sends it to the output listeners. They may ignore the message if it
- doesn't match their level- and context-masks.
- */
- void OutputManager::pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message)
- {
- std::vector<std::string> lines;
- vectorize(message, '\n', &lines);
-
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->listeners_[i]->unfilteredOutput(level, context, lines);
- }
-
- /**
- @brief Adds an output listener to the list of listeners.
- */
- void OutputManager::registerListener(OutputListener* listener)
- {
- this->listeners_.push_back(listener);
- this->updateMasks();
- }
-
- /**
- @brief Removes an output listener from the list of listeners.
- */
- void OutputManager::unregisterListener(OutputListener* listener)
- {
- for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
- {
- if (*it == listener)
- {
- this->listeners_.erase(it);
- break;
- }
- }
- this->updateMasks();
- }
-
- /**
- @brief Updates all three combined level- and context-masks.
- */
- void OutputManager::updateMasks()
- {
- this->updateCombinedLevelMask();
- this->updateCombinedAdditionalContextsLevelMask();
- this->updateCombinedAdditionalContextsMask();
- }
-
- /**
- @brief Updates the combined level mask. The masks of all listeners are ORed to form the combined mask.
- */
- void OutputManager::updateCombinedLevelMask()
- {
- int mask = 0;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- mask |= this->listeners_[i]->getLevelMask();
- this->combinedLevelMask_ = static_cast<OutputLevel>(mask);
- }
-
- /**
- @brief Updates the combined additional contexts level mask. The masks of all listeners are ORed to form the combined mask.
- */
- void OutputManager::updateCombinedAdditionalContextsLevelMask()
- {
- int mask = 0;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- mask |= this->listeners_[i]->getAdditionalContextsLevelMask();
- this->combinedAdditionalContextsLevelMask_ = static_cast<OutputLevel>(mask);
- }
-
- /**
- @brief Updates the combined additional contexts mask. The masks of all listeners are ORed to form the combined mask.
- */
- void OutputManager::updateCombinedAdditionalContextsMask()
- {
- this->combinedAdditionalContextsMask_ = 0;
- for (size_t i = 0; i < this->listeners_.size(); ++i)
- this->combinedAdditionalContextsMask_ |= this->listeners_[i]->getAdditionalContextsMask();
- }
-
- /**
- @brief Registers a context (or sub-context) and returns the container which identifies the context.
- @param name The name of the context
- @param subname The name of the sub-context (or "" if it is not a sub-context)
-
- If the context doesn't exist, it gets created. Otherwise the existing instance is returned.
- */
- const OutputContextContainer& OutputManager::registerContext(const std::string& name, const std::string& subname)
- {
- // the full name of a context is a combination of name and subname with "::" in between
- std::string full_name = name;
- if (subname != "")
- full_name += "::" + subname;
-
- // check if the context already exists (and return it if it does)
- std::map<std::string, OutputContextContainer>::iterator it_container = this->contextContainers_.find(full_name);
- if (it_container != this->contextContainers_.end())
- return it_container->second;
-
- // create a new context container
- OutputContextContainer container;
- container.name = full_name;
-
- // check if the mask of the main-context already exists
- std::map<std::string, OutputContextMask>::iterator it_mask = this->contextMasks_.find(name);
- if (it_mask != this->contextMasks_.end())
- {
- // the mask exists, assign it to the container
- container.mask = it_mask->second;
- }
- else
- {
- // the mask doesn't exist, create it. It's a binary mask. The n-th main-context is defined by the n-th bit in the mask.
- container.mask = static_cast<OutputContextMask>(0x1) << this->contextMasks_.size();
- this->contextMasks_[name] = container.mask;
-
- if (container.mask == 0)
- orxout(internal_warning) << "More than " << sizeof(OutputContextMask) * 8 << " output contexts defined. Context '" << name << "' might not get filtered correctly" << endl;
- }
-
- // if the context is a sub-context, assign a unique ID.
- if (subname == "")
- container.sub_id = context::no_subcontext;
- else
- container.sub_id = ++this->subcontextCounter_; // start with 1
-
- // add the new context to the map and return it
- return (this->contextContainers_[full_name] = container);
- }
-
- /**
- @brief Static function, shortcut to OutputManager::registerContext().
- The function is declared in OutputDefinitions.h.
- */
- const OutputContextContainer& registerContext(const std::string& name, const std::string& subname)
- {
- return OutputManager::getInstance().registerContext(name, subname);
- }
-
- /**
- @brief Returns a human readable string for each output level.
- */
- const std::string& OutputManager::getLevelName(OutputLevel level) const
- {
- switch (level)
- {
- // using static cache variables for speed
- case level::none: { static std::string name = "None"; return name; }
- case level::message: { static std::string name = "Message"; return name; }
- case level::debug_output: { static std::string name = "Debug"; return name; }
- case level::user_error: { static std::string name = "Error"; return name; }
- case level::user_warning: { static std::string name = "Warning"; return name; }
- case level::user_status: { static std::string name = "Status"; return name; }
- case level::user_info: { static std::string name = "Info"; return name; }
- case level::internal_error: { static std::string name = "Error (internal)"; return name; }
- case level::internal_warning: { static std::string name = "Warning (internal)"; return name; }
- case level::internal_status: { static std::string name = "Status (internal)"; return name; }
- case level::internal_info: { static std::string name = "Info (internal)"; return name; }
- case level::verbose: { static std::string name = "Verbose"; return name; }
- case level::verbose_more: { static std::string name = "Verbose (more)"; return name; }
- case level::verbose_ultra: { static std::string name = "Verbose (ultra)"; return name; }
- default: { static std::string name = ""; return name; }
- }
- }
-
- /**
- @brief Returns a string containing the name of the level and the context (if any) which
- can be prepended to an output message if it is written to the console or the log file.
- */
- 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;
-
- std::string prefix = this->getLevelName(level) + ": ";
- if (context.mask != undefined_mask)
- prefix += "[" + context.name + "] ";
-
- return prefix;
- }
-}
Copied: code/trunk/src/libraries/util/output/OutputManager.cc (from rev 8857, code/branches/output/src/libraries/util/output/OutputManager.cc)
===================================================================
--- code/trunk/src/libraries/util/output/OutputManager.cc (rev 0)
+++ code/trunk/src/libraries/util/output/OutputManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,277 @@
+/*
+ * 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
+ @brief Implementation of the OutputManager singleton.
+*/
+
+#include "OutputManager.h"
+
+#include "MemoryWriter.h"
+#include "ConsoleWriter.h"
+#include "LogWriter.h"
+#include "util/Output.h"
+#include "util/StringUtils.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor, initializes all values.
+ */
+ OutputManager::OutputManager()
+ {
+ this->combinedLevelMask_ = level::none;
+ this->combinedAdditionalContextsLevelMask_ = level::none;
+ this->combinedAdditionalContextsMask_ = context::none;
+
+ this->subcontextCounter_ = 0;
+ }
+
+ /**
+ @brief Destructor.
+ */
+ OutputManager::~OutputManager()
+ {
+ }
+
+ /**
+ @brief Returns the only existing instance of the OutputManager singleton.
+ */
+ /*static*/ OutputManager& OutputManager::getInstance()
+ {
+ static OutputManager instance;
+ return instance;
+ }
+
+ /**
+ @brief Returns the only existing instance of the OutputManager singleton
+ and ensures that the most important output listeners exist.
+
+ You should use this function if you send output to OutputManager and want
+ to be sure that the most important output listeners exist. Don't use it
+ elsewhere inside the output system to avoid circular calls.
+ */
+ /*static*/ OutputManager& OutputManager::getInstanceAndCreateListeners()
+ {
+ static OutputManager& instance = OutputManager::getInstance();
+
+ static MemoryWriter& memoryWriterInstance = MemoryWriter::getInstance(); (void)memoryWriterInstance;
+ static ConsoleWriter& consoleWriterInstance = ConsoleWriter::getInstance(); (void)consoleWriterInstance;
+ static LogWriter& logWriterInstance = LogWriter::getInstance(); (void)logWriterInstance;
+
+ return instance;
+ }
+
+ /**
+ @brief Sends an output message to all output listeners.
+ @param level The level of the message
+ @param context The context of the message
+ @param message The output message (may contain '\\n')
+
+ This function splits the message into lines (if it contains '\\n') and
+ sends it to the output listeners. They may ignore the message if it
+ doesn't match their level- and context-masks.
+ */
+ void OutputManager::pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message)
+ {
+ std::vector<std::string> lines;
+ vectorize(message, '\n', &lines);
+
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ this->listeners_[i]->unfilteredOutput(level, context, lines);
+ }
+
+ /**
+ @brief Adds an output listener to the list of listeners.
+ */
+ void OutputManager::registerListener(OutputListener* listener)
+ {
+ this->listeners_.push_back(listener);
+ this->updateMasks();
+ }
+
+ /**
+ @brief Removes an output listener from the list of listeners.
+ */
+ void OutputManager::unregisterListener(OutputListener* listener)
+ {
+ for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+ {
+ if (*it == listener)
+ {
+ this->listeners_.erase(it);
+ break;
+ }
+ }
+ this->updateMasks();
+ }
+
+ /**
+ @brief Updates all three combined level- and context-masks.
+ */
+ void OutputManager::updateMasks()
+ {
+ this->updateCombinedLevelMask();
+ this->updateCombinedAdditionalContextsLevelMask();
+ this->updateCombinedAdditionalContextsMask();
+ }
+
+ /**
+ @brief Updates the combined level mask. The masks of all listeners are ORed to form the combined mask.
+ */
+ void OutputManager::updateCombinedLevelMask()
+ {
+ int mask = 0;
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ mask |= this->listeners_[i]->getLevelMask();
+ this->combinedLevelMask_ = static_cast<OutputLevel>(mask);
+ }
+
+ /**
+ @brief Updates the combined additional contexts level mask. The masks of all listeners are ORed to form the combined mask.
+ */
+ void OutputManager::updateCombinedAdditionalContextsLevelMask()
+ {
+ int mask = 0;
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ mask |= this->listeners_[i]->getAdditionalContextsLevelMask();
+ this->combinedAdditionalContextsLevelMask_ = static_cast<OutputLevel>(mask);
+ }
+
+ /**
+ @brief Updates the combined additional contexts mask. The masks of all listeners are ORed to form the combined mask.
+ */
+ void OutputManager::updateCombinedAdditionalContextsMask()
+ {
+ this->combinedAdditionalContextsMask_ = 0;
+ for (size_t i = 0; i < this->listeners_.size(); ++i)
+ this->combinedAdditionalContextsMask_ |= this->listeners_[i]->getAdditionalContextsMask();
+ }
+
+ /**
+ @brief Registers a context (or sub-context) and returns the container which identifies the context.
+ @param name The name of the context
+ @param subname The name of the sub-context (or "" if it is not a sub-context)
+
+ If the context doesn't exist, it gets created. Otherwise the existing instance is returned.
+ */
+ const OutputContextContainer& OutputManager::registerContext(const std::string& name, const std::string& subname)
+ {
+ // the full name of a context is a combination of name and subname with "::" in between
+ std::string full_name = name;
+ if (subname != "")
+ full_name += "::" + subname;
+
+ // check if the context already exists (and return it if it does)
+ std::map<std::string, OutputContextContainer>::iterator it_container = this->contextContainers_.find(full_name);
+ if (it_container != this->contextContainers_.end())
+ return it_container->second;
+
+ // create a new context container
+ OutputContextContainer container;
+ container.name = full_name;
+
+ // check if the mask of the main-context already exists
+ std::map<std::string, OutputContextMask>::iterator it_mask = this->contextMasks_.find(name);
+ if (it_mask != this->contextMasks_.end())
+ {
+ // the mask exists, assign it to the container
+ container.mask = it_mask->second;
+ }
+ else
+ {
+ // the mask doesn't exist, create it. It's a binary mask. The n-th main-context is defined by the n-th bit in the mask.
+ container.mask = static_cast<OutputContextMask>(0x1) << this->contextMasks_.size();
+ this->contextMasks_[name] = container.mask;
+
+ if (container.mask == 0)
+ orxout(internal_warning) << "More than " << sizeof(OutputContextMask) * 8 << " output contexts defined. Context '" << name << "' might not get filtered correctly" << endl;
+ }
+
+ // if the context is a sub-context, assign a unique ID.
+ if (subname == "")
+ container.sub_id = context::no_subcontext;
+ else
+ container.sub_id = ++this->subcontextCounter_; // start with 1
+
+ // add the new context to the map and return it
+ return (this->contextContainers_[full_name] = container);
+ }
+
+ /**
+ @brief Static function, shortcut to OutputManager::registerContext().
+ The function is declared in OutputDefinitions.h.
+ */
+ const OutputContextContainer& registerContext(const std::string& name, const std::string& subname)
+ {
+ return OutputManager::getInstance().registerContext(name, subname);
+ }
+
+ /**
+ @brief Returns a human readable string for each output level.
+ */
+ const std::string& OutputManager::getLevelName(OutputLevel level) const
+ {
+ switch (level)
+ {
+ // using static cache variables for speed
+ case level::none: { static std::string name = "None"; return name; }
+ case level::message: { static std::string name = "Message"; return name; }
+ case level::debug_output: { static std::string name = "Debug"; return name; }
+ case level::user_error: { static std::string name = "Error"; return name; }
+ case level::user_warning: { static std::string name = "Warning"; return name; }
+ case level::user_status: { static std::string name = "Status"; return name; }
+ case level::user_info: { static std::string name = "Info"; return name; }
+ case level::internal_error: { static std::string name = "Error (internal)"; return name; }
+ case level::internal_warning: { static std::string name = "Warning (internal)"; return name; }
+ case level::internal_status: { static std::string name = "Status (internal)"; return name; }
+ case level::internal_info: { static std::string name = "Info (internal)"; return name; }
+ case level::verbose: { static std::string name = "Verbose"; return name; }
+ case level::verbose_more: { static std::string name = "Verbose (more)"; return name; }
+ case level::verbose_ultra: { static std::string name = "Verbose (ultra)"; return name; }
+ default: { static std::string name = ""; return name; }
+ }
+ }
+
+ /**
+ @brief Returns a string containing the name of the level and the context (if any) which
+ can be prepended to an output message if it is written to the console or the log file.
+ */
+ 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;
+
+ std::string prefix = this->getLevelName(level) + ": ";
+ if (context.mask != undefined_mask)
+ prefix += "[" + context.name + "] ";
+
+ return prefix;
+ }
+}
Deleted: code/trunk/src/libraries/util/output/OutputManager.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputManager.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,114 +0,0 @@
-/*
- * 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 OutputManager class which receives output from orxonox::OutputStream
- and distributes it to all instances of orxonox::OutputListener.
-*/
-
-#ifndef _OutputManager_H__
-#define _OutputManager_H__
-
-#include "util/UtilPrereqs.h"
-
-#include <vector>
-#include <map>
-
-#include "OutputDefinitions.h"
-
-namespace orxonox
-{
- /**
- @brief OutputManager acts as the center of the output system and is implemented as a singleton.
-
- All instances of OutputStream (and hence also the orxout() function)
- send their buffered output to OutputManager. OutputManager then
- distributes this output to all registered instances of OutputListener.
-
- For each listener OutputManager checks if it wants to receive output
- with the given level and context. OutputManager itself also maintains
- masks that define the accepted levels and concept. They are a
- combination of the masks of all output listeners. See the description
- of OutputListener for a more conclusive description of these masks.
-
- Additionally OutputManager is used to register output contexts.
- */
- class _UtilExport OutputManager
- {
- public:
- static OutputManager& getInstance();
- static OutputManager& getInstanceAndCreateListeners();
-
- void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
-
- void registerListener(OutputListener* listener);
- void unregisterListener(OutputListener* listener);
-
- void updateMasks();
- void updateCombinedLevelMask();
- void updateCombinedAdditionalContextsLevelMask();
- void updateCombinedAdditionalContextsMask();
-
- /**
- @brief Returns true if at least one of the output listeners will accept output with the given level and context.
-
- For the sake of performance, output messages with levels or
- contexts that are not accepted should be ignored or, even
- better, not generated at all.
- */
- inline bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
- {
- return (this->combinedLevelMask_ & level) ||
- ((this->combinedAdditionalContextsLevelMask_ & level) && (this->combinedAdditionalContextsMask_ & context.mask));
- }
-
- const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
-
- const std::string& getLevelName(OutputLevel level) const;
- std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
-
- private:
- OutputManager();
- OutputManager(const OutputManager&);
- ~OutputManager();
-
- std::vector<OutputListener*> listeners_; ///< List of all registered output listeners
-
- OutputLevel combinedLevelMask_; ///< The combined mask of accepted levels of all listeners
- OutputLevel combinedAdditionalContextsLevelMask_; ///< The combined mask of accepted additional contexts levels of all listeners
- OutputContextMask combinedAdditionalContextsMask_; ///< The combined mask of accepted additional contexts of all listeners
-
- 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)
- };
-}
-
-#endif /* _OutputManager_H__ */
Copied: code/trunk/src/libraries/util/output/OutputManager.h (from rev 8857, code/branches/output/src/libraries/util/output/OutputManager.h)
===================================================================
--- code/trunk/src/libraries/util/output/OutputManager.h (rev 0)
+++ code/trunk/src/libraries/util/output/OutputManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,114 @@
+/*
+ * 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 OutputManager class which receives output from orxonox::OutputStream
+ and distributes it to all instances of orxonox::OutputListener.
+*/
+
+#ifndef _OutputManager_H__
+#define _OutputManager_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <vector>
+#include <map>
+
+#include "OutputDefinitions.h"
+
+namespace orxonox
+{
+ /**
+ @brief OutputManager acts as the center of the output system and is implemented as a singleton.
+
+ All instances of OutputStream (and hence also the orxout() function)
+ send their buffered output to OutputManager. OutputManager then
+ distributes this output to all registered instances of OutputListener.
+
+ For each listener OutputManager checks if it wants to receive output
+ with the given level and context. OutputManager itself also maintains
+ masks that define the accepted levels and concept. They are a
+ combination of the masks of all output listeners. See the description
+ of OutputListener for a more conclusive description of these masks.
+
+ Additionally OutputManager is used to register output contexts.
+ */
+ class _UtilExport OutputManager
+ {
+ public:
+ static OutputManager& getInstance();
+ static OutputManager& getInstanceAndCreateListeners();
+
+ void pushMessage(OutputLevel level, const OutputContextContainer& context, const std::string& message);
+
+ void registerListener(OutputListener* listener);
+ void unregisterListener(OutputListener* listener);
+
+ void updateMasks();
+ void updateCombinedLevelMask();
+ void updateCombinedAdditionalContextsLevelMask();
+ void updateCombinedAdditionalContextsMask();
+
+ /**
+ @brief Returns true if at least one of the output listeners will accept output with the given level and context.
+
+ For the sake of performance, output messages with levels or
+ contexts that are not accepted should be ignored or, even
+ better, not generated at all.
+ */
+ inline bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
+ {
+ return (this->combinedLevelMask_ & level) ||
+ ((this->combinedAdditionalContextsLevelMask_ & level) && (this->combinedAdditionalContextsMask_ & context.mask));
+ }
+
+ const OutputContextContainer& registerContext(const std::string& name, const std::string& subname = "");
+
+ const std::string& getLevelName(OutputLevel level) const;
+ std::string getDefaultPrefix(OutputLevel level, const OutputContextContainer& context) const;
+
+ private:
+ OutputManager();
+ OutputManager(const OutputManager&);
+ ~OutputManager();
+
+ std::vector<OutputListener*> listeners_; ///< List of all registered output listeners
+
+ OutputLevel combinedLevelMask_; ///< The combined mask of accepted levels of all listeners
+ OutputLevel combinedAdditionalContextsLevelMask_; ///< The combined mask of accepted additional contexts levels of all listeners
+ OutputContextMask combinedAdditionalContextsMask_; ///< The combined mask of accepted additional contexts of all listeners
+
+ 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)
+ };
+}
+
+#endif /* _OutputManager_H__ */
Deleted: code/trunk/src/libraries/util/output/OutputStream.cc
===================================================================
--- code/branches/output/src/libraries/util/output/OutputStream.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputStream.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,86 +0,0 @@
-/*
- * 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
- @brief Implementation of the non-generic functions of the OutputStream class.
-*/
-
-#include "OutputStream.h"
-
-#include "OutputManager.h"
-
-namespace orxonox
-{
- /**
- @brief Default constructor, initializes level and context with default values.
- */
- OutputStream::OutputStream()
- {
- this->setOutputAttributes(level::debug_output, context::undefined());
- }
-
- /**
- @brief Constructor, initializes level and context with the provided values.
- */
- OutputStream::OutputStream(OutputLevel level, const OutputContextContainer& context)
- {
- this->setOutputAttributes(level, context);
- }
-
- /**
- @brief Destructor, sends remaining output to OutputManager (if any).
- */
- OutputStream::~OutputStream()
- {
- if (this->str() != "")
- *this << " [missing endl]" << std::endl;
- }
-
- /**
- @brief Sends the buffered message to OutputManager together with the stored level and context.
- Additionally empties the buffer.
- */
- void OutputStream::sendMessage()
- {
- OutputManager::getInstanceAndCreateListeners().pushMessage(this->level_, *this->context_, this->str());
- this->str("");
- }
-
- /**
- @brief Defines level and context of the following output.
- Also sets the bAcceptsOutput_ flag according to the masks defined in OutputManager.
- */
- void OutputStream::setOutputAttributes(OutputLevel level, const OutputContextContainer& context)
- {
- this->level_ = level;
- this->context_ = &context;
-
- this->bAcceptsOutput_ = OutputManager::getInstanceAndCreateListeners().acceptsOutput(level, context);
- }
-}
Copied: code/trunk/src/libraries/util/output/OutputStream.cc (from rev 8857, code/branches/output/src/libraries/util/output/OutputStream.cc)
===================================================================
--- code/trunk/src/libraries/util/output/OutputStream.cc (rev 0)
+++ code/trunk/src/libraries/util/output/OutputStream.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,86 @@
+/*
+ * 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
+ @brief Implementation of the non-generic functions of the OutputStream class.
+*/
+
+#include "OutputStream.h"
+
+#include "OutputManager.h"
+
+namespace orxonox
+{
+ /**
+ @brief Default constructor, initializes level and context with default values.
+ */
+ OutputStream::OutputStream()
+ {
+ this->setOutputAttributes(level::debug_output, context::undefined());
+ }
+
+ /**
+ @brief Constructor, initializes level and context with the provided values.
+ */
+ OutputStream::OutputStream(OutputLevel level, const OutputContextContainer& context)
+ {
+ this->setOutputAttributes(level, context);
+ }
+
+ /**
+ @brief Destructor, sends remaining output to OutputManager (if any).
+ */
+ OutputStream::~OutputStream()
+ {
+ if (this->str() != "")
+ *this << " [missing endl]" << std::endl;
+ }
+
+ /**
+ @brief Sends the buffered message to OutputManager together with the stored level and context.
+ Additionally empties the buffer.
+ */
+ void OutputStream::sendMessage()
+ {
+ OutputManager::getInstanceAndCreateListeners().pushMessage(this->level_, *this->context_, this->str());
+ this->str("");
+ }
+
+ /**
+ @brief Defines level and context of the following output.
+ Also sets the bAcceptsOutput_ flag according to the masks defined in OutputManager.
+ */
+ void OutputStream::setOutputAttributes(OutputLevel level, const OutputContextContainer& context)
+ {
+ this->level_ = level;
+ this->context_ = &context;
+
+ this->bAcceptsOutput_ = OutputManager::getInstanceAndCreateListeners().acceptsOutput(level, context);
+ }
+}
Deleted: code/trunk/src/libraries/util/output/OutputStream.h
===================================================================
--- code/branches/output/src/libraries/util/output/OutputStream.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/OutputStream.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,122 +0,0 @@
-/*
- * 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 OutputStream class which is used to send output to orxonox::OutputManager.
-*/
-
-#ifndef _OutputStream_H__
-#define _OutputStream_H__
-
-#include "util/UtilPrereqs.h"
-
-#include <sstream>
-
-#include "OutputDefinitions.h"
-
-namespace orxonox
-{
- /**
- @brief This class is used to buffer output and send it to OutputManager whenever std::endl is passed to it.
-
- OutputStream inherits from std::ostringstream and acts like std::cout.
- This means you can use the << operator to write output to the stream.
- This class is used by the orxout() function.
-
- @attention
- You must end an output message with std::endl, otherwise the message
- won't be flushed. '\\n' only adds a new line to the message.
-
- The following code samples are all equivalent:
- @code
- OutputStream stream;
- stream.setOutputAttributes(user_info, context::example());
- stream << "Hello World" << endl;
- @endcode
-
- @code
- OutputStream stream(user_info, context::example());
- stream << "Hello World" << endl;
- @endcode
-
- @code
- orxout(user_info, context::example) << "Hello World" << endl;
- @endcode
- */
- class OutputStream : public std::ostringstream
- {
- typedef std::ostream& (*EndlType)(std::ostream&);
-
- public:
- _UtilExport OutputStream();
- _UtilExport OutputStream(OutputLevel level, const OutputContextContainer& context);
- _UtilExport ~OutputStream();
-
- void _UtilExport setOutputAttributes(OutputLevel level, const OutputContextContainer& context);
-
- /// @brief Generic << operator which adds output to the stream.
- template <class T>
- inline OutputStream& operator<<(const T& val) { return this->output(val); }
- /// @brief Sends a manipulator to the output stream.
- inline OutputStream& operator<<(std::ios_base& (*manipulator)(std::ios_base&)) { return this->output(manipulator); }
- /// @brief Sends a manipulator to the output stream.
- inline OutputStream& operator<<(std::ios& (*manipulator)(std::ios&)) { return this->output(manipulator); }
- /// @brief Sends a manipulator to the output stream and flushes the message if the manipulator is std::endl.
- inline OutputStream& operator<<(std::ostream& (*manipulator)(std::ostream&))
- {
- if (this->bAcceptsOutput_)
- {
- if (manipulator == static_cast<EndlType>(std::endl))
- this->sendMessage(); // send the message to OutputManager
- else
- return this->output(manipulator); // apply the manipulator
- }
- return *this;
- }
-
- private:
- /// @brief Generic function to add values to the output stream, using the inherited << operator from std::ostringstream.
- template <class T>
- inline OutputStream& output(const T& val)
- {
- if (this->bAcceptsOutput_)
- static_cast<std::ostringstream&>(*this) << val;
- return *this;
- }
-
- void _UtilExport sendMessage();
-
- OutputLevel level_; ///< The output level of the current message
- const OutputContextContainer* context_; ///< The output context of the current message
- bool bAcceptsOutput_; ///< After defining level and context of the following message, this flag is set according to the masks defined in OutputManager. If it is false, the OutputStream will throw away every output sent using the << operator.
- };
-}
-
-#endif /* _OutputStream_H__ */
Copied: code/trunk/src/libraries/util/output/OutputStream.h (from rev 8857, code/branches/output/src/libraries/util/output/OutputStream.h)
===================================================================
--- code/trunk/src/libraries/util/output/OutputStream.h (rev 0)
+++ code/trunk/src/libraries/util/output/OutputStream.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,122 @@
+/*
+ * 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 OutputStream class which is used to send output to orxonox::OutputManager.
+*/
+
+#ifndef _OutputStream_H__
+#define _OutputStream_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <sstream>
+
+#include "OutputDefinitions.h"
+
+namespace orxonox
+{
+ /**
+ @brief This class is used to buffer output and send it to OutputManager whenever std::endl is passed to it.
+
+ OutputStream inherits from std::ostringstream and acts like std::cout.
+ This means you can use the << operator to write output to the stream.
+ This class is used by the orxout() function.
+
+ @attention
+ You must end an output message with std::endl, otherwise the message
+ won't be flushed. '\\n' only adds a new line to the message.
+
+ The following code samples are all equivalent:
+ @code
+ OutputStream stream;
+ stream.setOutputAttributes(user_info, context::example());
+ stream << "Hello World" << endl;
+ @endcode
+
+ @code
+ OutputStream stream(user_info, context::example());
+ stream << "Hello World" << endl;
+ @endcode
+
+ @code
+ orxout(user_info, context::example) << "Hello World" << endl;
+ @endcode
+ */
+ class OutputStream : public std::ostringstream
+ {
+ typedef std::ostream& (*EndlType)(std::ostream&);
+
+ public:
+ _UtilExport OutputStream();
+ _UtilExport OutputStream(OutputLevel level, const OutputContextContainer& context);
+ _UtilExport ~OutputStream();
+
+ void _UtilExport setOutputAttributes(OutputLevel level, const OutputContextContainer& context);
+
+ /// @brief Generic << operator which adds output to the stream.
+ template <class T>
+ inline OutputStream& operator<<(const T& val) { return this->output(val); }
+ /// @brief Sends a manipulator to the output stream.
+ inline OutputStream& operator<<(std::ios_base& (*manipulator)(std::ios_base&)) { return this->output(manipulator); }
+ /// @brief Sends a manipulator to the output stream.
+ inline OutputStream& operator<<(std::ios& (*manipulator)(std::ios&)) { return this->output(manipulator); }
+ /// @brief Sends a manipulator to the output stream and flushes the message if the manipulator is std::endl.
+ inline OutputStream& operator<<(std::ostream& (*manipulator)(std::ostream&))
+ {
+ if (this->bAcceptsOutput_)
+ {
+ if (manipulator == static_cast<EndlType>(std::endl))
+ this->sendMessage(); // send the message to OutputManager
+ else
+ return this->output(manipulator); // apply the manipulator
+ }
+ return *this;
+ }
+
+ private:
+ /// @brief Generic function to add values to the output stream, using the inherited << operator from std::ostringstream.
+ template <class T>
+ inline OutputStream& output(const T& val)
+ {
+ if (this->bAcceptsOutput_)
+ static_cast<std::ostringstream&>(*this) << val;
+ return *this;
+ }
+
+ void _UtilExport sendMessage();
+
+ OutputLevel level_; ///< The output level of the current message
+ const OutputContextContainer* context_; ///< The output context of the current message
+ bool bAcceptsOutput_; ///< After defining level and context of the following message, this flag is set according to the masks defined in OutputManager. If it is false, the OutputStream will throw away every output sent using the << operator.
+ };
+}
+
+#endif /* _OutputStream_H__ */
Deleted: code/trunk/src/libraries/util/output/SubcontextOutputListener.cc
===================================================================
--- code/branches/output/src/libraries/util/output/SubcontextOutputListener.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/SubcontextOutputListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,118 +0,0 @@
-/*
- * 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
- @brief Implementation of the SubcontextOutputListener interface.
-*/
-
-#include "SubcontextOutputListener.h"
-
-namespace orxonox
-{
- /**
- @brief Constructor, initializes the context masks.
- */
- SubcontextOutputListener::SubcontextOutputListener(bool bRegister) : OutputListener(bRegister)
- {
- this->subcontextsCheckMask_ = context::none;
- this->subcontextsNoCheckMask_ = context::none;
- }
-
- /**
- @brief Destructor.
- */
- SubcontextOutputListener::~SubcontextOutputListener()
- {
- }
-
- /**
- @brief Overwritten implementation of the function defined by OutputListener.
-
- Contexts defined with this function are accepted independent of the
- sub-context. The "final" mask of additional contexts is defined by the
- combination of this mask and the masks of all accepted sub-contexts.
- */
- void SubcontextOutputListener::setAdditionalContextsMask(OutputContextMask mask)
- {
- this->subcontextsNoCheckMask_ = mask;
-
- OutputListener::setAdditionalContextsMask(this->subcontextsCheckMask_ | this->subcontextsNoCheckMask_);
- }
-
- /**
- @brief Defines the set of accepted sub-contexts.
-
- The masks of sub-contexts in this set are added to the mask of
- additional contexts, but output is only accepted if the exact
- sub-context exists in this set.
- */
- void SubcontextOutputListener::setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts)
- {
- this->subcontextsCheckMask_ = context::none;
- this->subcontexts_.clear();
-
- // compose the mask of subcontexts and build the set of sub-context-IDs
- for (std::set<const OutputContextContainer*>::const_iterator it = subcontexts.begin(); it != subcontexts.end(); ++it)
- {
- this->subcontextsCheckMask_ |= (*it)->mask;
- this->subcontexts_.insert((*it)->sub_id);
- }
-
- OutputListener::setAdditionalContextsMask(this->subcontextsCheckMask_ | this->subcontextsNoCheckMask_);
- }
-
- /**
- @brief Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks, as well as the set of accepted sub-contexts.
- */
- bool SubcontextOutputListener::acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
- {
- // check if the output level is accepted by the level mask (independent of the context)
- if (this->getLevelMask() & level)
- return true;
-
- // check if the output level is accepted by the additional contexts level mask
- if (this->getAdditionalContextsLevelMask() & level)
- {
- // check if the output context is accepted by the "no check" mask
- if (this->subcontextsNoCheckMask_ & context.mask)
- return true;
-
- // check if the output context is accepted by the "check" mask
- if (this->subcontextsCheckMask_ & context.mask)
- {
- // check if the output's subcontext is in the set of accepted sub-context
- if (this->subcontexts_.find(context.sub_id) != this->subcontexts_.end())
- return true;
- }
- }
-
- // otherwise we don't accept the output
- return false;
- }
-}
Copied: code/trunk/src/libraries/util/output/SubcontextOutputListener.cc (from rev 8857, code/branches/output/src/libraries/util/output/SubcontextOutputListener.cc)
===================================================================
--- code/trunk/src/libraries/util/output/SubcontextOutputListener.cc (rev 0)
+++ code/trunk/src/libraries/util/output/SubcontextOutputListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,118 @@
+/*
+ * 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
+ @brief Implementation of the SubcontextOutputListener interface.
+*/
+
+#include "SubcontextOutputListener.h"
+
+namespace orxonox
+{
+ /**
+ @brief Constructor, initializes the context masks.
+ */
+ SubcontextOutputListener::SubcontextOutputListener(bool bRegister) : OutputListener(bRegister)
+ {
+ this->subcontextsCheckMask_ = context::none;
+ this->subcontextsNoCheckMask_ = context::none;
+ }
+
+ /**
+ @brief Destructor.
+ */
+ SubcontextOutputListener::~SubcontextOutputListener()
+ {
+ }
+
+ /**
+ @brief Overwritten implementation of the function defined by OutputListener.
+
+ Contexts defined with this function are accepted independent of the
+ sub-context. The "final" mask of additional contexts is defined by the
+ combination of this mask and the masks of all accepted sub-contexts.
+ */
+ void SubcontextOutputListener::setAdditionalContextsMask(OutputContextMask mask)
+ {
+ this->subcontextsNoCheckMask_ = mask;
+
+ OutputListener::setAdditionalContextsMask(this->subcontextsCheckMask_ | this->subcontextsNoCheckMask_);
+ }
+
+ /**
+ @brief Defines the set of accepted sub-contexts.
+
+ The masks of sub-contexts in this set are added to the mask of
+ additional contexts, but output is only accepted if the exact
+ sub-context exists in this set.
+ */
+ void SubcontextOutputListener::setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts)
+ {
+ this->subcontextsCheckMask_ = context::none;
+ this->subcontexts_.clear();
+
+ // compose the mask of subcontexts and build the set of sub-context-IDs
+ for (std::set<const OutputContextContainer*>::const_iterator it = subcontexts.begin(); it != subcontexts.end(); ++it)
+ {
+ this->subcontextsCheckMask_ |= (*it)->mask;
+ this->subcontexts_.insert((*it)->sub_id);
+ }
+
+ OutputListener::setAdditionalContextsMask(this->subcontextsCheckMask_ | this->subcontextsNoCheckMask_);
+ }
+
+ /**
+ @brief Returns true if this listener accepts output of the given level and context, based on the levels and contexts masks, as well as the set of accepted sub-contexts.
+ */
+ bool SubcontextOutputListener::acceptsOutput(OutputLevel level, const OutputContextContainer& context) const
+ {
+ // check if the output level is accepted by the level mask (independent of the context)
+ if (this->getLevelMask() & level)
+ return true;
+
+ // check if the output level is accepted by the additional contexts level mask
+ if (this->getAdditionalContextsLevelMask() & level)
+ {
+ // check if the output context is accepted by the "no check" mask
+ if (this->subcontextsNoCheckMask_ & context.mask)
+ return true;
+
+ // check if the output context is accepted by the "check" mask
+ if (this->subcontextsCheckMask_ & context.mask)
+ {
+ // check if the output's subcontext is in the set of accepted sub-context
+ if (this->subcontexts_.find(context.sub_id) != this->subcontexts_.end())
+ return true;
+ }
+ }
+
+ // otherwise we don't accept the output
+ return false;
+ }
+}
Deleted: code/trunk/src/libraries/util/output/SubcontextOutputListener.h
===================================================================
--- code/branches/output/src/libraries/util/output/SubcontextOutputListener.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/libraries/util/output/SubcontextOutputListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,87 +0,0 @@
-/*
- * 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 SubcontextOutputListener interface which adds the ability to filter sub-contexts to OutputListener.
-*/
-
-#ifndef _SubcontextOutputListener_H__
-#define _SubcontextOutputListener_H__
-
-#include "util/UtilPrereqs.h"
-
-#include <set>
-
-#include "OutputListener.h"
-
-namespace orxonox
-{
- /**
- @brief This class extends the basic OutputListener interface and adds the ability to filter sub-contexts.
-
- Defining additional contexts with setAdditionalContextsMask() enables
- all sub-contexts of these additional contexts. To accept only some
- particular sub-contexts, setAdditionalSubcontexts() has to be used.
- Note that this requires a set, since a mask is not possible with
- sub-contexts.
-
- The "final" context mask which will be seen by OutputManager is the
- combination of all regular contexts plus the masks of all sub-contexts.
-
- @remark
- It would have been possible to implement filtering of sub-contexts
- directly in OutputListener and even to make OutputManager aware of
- sub-contexts. This would reduce the amount of unnecessarily generated
- output, but also increase the complexity of the checks whether some
- output is needed.
- On the other hand, filtering of sub-contexts makes the whole concept
- more complicated, as it adds another mask and a set. So to keep it
- clean and simple I figured it's best to put sub-context filtering into
- a seaparate class.
- */
- class _UtilExport SubcontextOutputListener : public OutputListener
- {
- public:
- SubcontextOutputListener(bool bRegister = true);
- virtual ~SubcontextOutputListener();
-
- void setAdditionalContextsMask(OutputContextMask mask);
- void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
-
- virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
-
- 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
- std::set<OutputContextSubID> subcontexts_; ///< The set of accepted sub-contexts
- };
-}
-
-#endif /* _SubcontextOutputListener_H__ */
Copied: code/trunk/src/libraries/util/output/SubcontextOutputListener.h (from rev 8857, code/branches/output/src/libraries/util/output/SubcontextOutputListener.h)
===================================================================
--- code/trunk/src/libraries/util/output/SubcontextOutputListener.h (rev 0)
+++ code/trunk/src/libraries/util/output/SubcontextOutputListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,87 @@
+/*
+ * 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 SubcontextOutputListener interface which adds the ability to filter sub-contexts to OutputListener.
+*/
+
+#ifndef _SubcontextOutputListener_H__
+#define _SubcontextOutputListener_H__
+
+#include "util/UtilPrereqs.h"
+
+#include <set>
+
+#include "OutputListener.h"
+
+namespace orxonox
+{
+ /**
+ @brief This class extends the basic OutputListener interface and adds the ability to filter sub-contexts.
+
+ Defining additional contexts with setAdditionalContextsMask() enables
+ all sub-contexts of these additional contexts. To accept only some
+ particular sub-contexts, setAdditionalSubcontexts() has to be used.
+ Note that this requires a set, since a mask is not possible with
+ sub-contexts.
+
+ The "final" context mask which will be seen by OutputManager is the
+ combination of all regular contexts plus the masks of all sub-contexts.
+
+ @remark
+ It would have been possible to implement filtering of sub-contexts
+ directly in OutputListener and even to make OutputManager aware of
+ sub-contexts. This would reduce the amount of unnecessarily generated
+ output, but also increase the complexity of the checks whether some
+ output is needed.
+ On the other hand, filtering of sub-contexts makes the whole concept
+ more complicated, as it adds another mask and a set. So to keep it
+ clean and simple I figured it's best to put sub-context filtering into
+ a seaparate class.
+ */
+ class _UtilExport SubcontextOutputListener : public OutputListener
+ {
+ public:
+ SubcontextOutputListener(bool bRegister = true);
+ virtual ~SubcontextOutputListener();
+
+ void setAdditionalContextsMask(OutputContextMask mask);
+ void setAdditionalSubcontexts(const std::set<const OutputContextContainer*>& subcontexts);
+
+ virtual bool acceptsOutput(OutputLevel level, const OutputContextContainer& context) const;
+
+ 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
+ std::set<OutputContextSubID> subcontexts_; ///< The set of accepted sub-contexts
+ };
+}
+
+#endif /* _SubcontextOutputListener_H__ */
Modified: code/trunk/src/modules/designtools/ScreenshotManager.cc
===================================================================
--- code/trunk/src/modules/designtools/ScreenshotManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/designtools/ScreenshotManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -152,10 +152,10 @@
// Save it.
finalImage->save(PathConfig::getInstance().getLogPathString() + "screenshot_" + getTimestamp() + this->fileExtension_);
delete finalImage;
- COUT(3) << "Finished taking " << this->gridSize_*this->windowWidth_ << "x" << this->gridSize_*this->windowHeight_ << " pixel HD screenshot. Storing in log/." << endl;
+ orxout(user_info) << "Finished taking " << this->gridSize_*this->windowWidth_ << "x" << this->gridSize_*this->windowHeight_ << " pixel HD screenshot. Storing in log/." << endl;
}
else
- COUT(1) << "There needs to be an active camera to make screenshots." << endl;
+ orxout(user_error) << "There needs to be an active camera to make screenshots." << endl;
this->cleanup();
}
@@ -256,7 +256,7 @@
// Place the tempBuffer content at the right position
this->buffer_->blitToMemory(this->finalPicturePB_->getSubVolume(subBox));
- COUT(4) << "Created screenshot number " << nbScreenshots << " for multi grid HD screenshot." << endl;
+ orxout(internal_info) << "Created screenshot number " << nbScreenshots << " for multi grid HD screenshot." << endl;
}
Modified: code/trunk/src/modules/designtools/SkyboxGenerator.cc
===================================================================
--- code/trunk/src/modules/designtools/SkyboxGenerator.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/designtools/SkyboxGenerator.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -148,7 +148,7 @@
entity = HumanController::getLocalControllerSingleton()->getControllableEntity();
else
{
- COUT(1) << "You must be in a level to generate a skybox." << endl;
+ orxout(user_error) << "You must be in a level to generate a skybox." << endl;
this->bGenerateSkybox_ = false;
return;
}
@@ -174,7 +174,7 @@
// Add the log path to the standard resource group.
Ogre::ResourceGroupManager::getSingleton().addResourceLocation(PathConfig::getInstance().getLogPathString(), "FileSystem", Resource::getDefaultResourceGroup());
- COUT(4) << "Setting up SkyboxGenerator..." << endl;
+ orxout(internal_status) << "Setting up SkyboxGenerator..." << endl;
this->bSetup_ = false;
this->bWait_ = true;
@@ -193,7 +193,7 @@
if(rotate.second != 0)
entity->pitch(Degree((float)rotate.second));
- COUT(4) << "Created face number " << this->faceCounter_ << "." << endl;
+ orxout(internal_info) << "Created face number " << this->faceCounter_ << "." << endl;
// Check whether we've generated all 6 faces.
if(++this->faceCounter_ >= 6)
this->bCreateFace_ = false;
@@ -224,7 +224,7 @@
// Unpause.
CommandExecutor::execute("pause");
- COUT(3) << "Skybox with face size " << this->size_ << "x" << this->size_ << " pixels created. Storing in log/." << endl;
+ orxout(user_info) << "Skybox with face size " << this->size_ << "x" << this->size_ << " pixels created. Storing in log/." << endl;
}
}
}
Modified: code/trunk/src/modules/docking/Dock.cc
===================================================================
--- code/trunk/src/modules/docking/Dock.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/docking/Dock.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -86,19 +86,19 @@
if(pTrigger != NULL)
{
if(!pTrigger->isForPlayer()) { // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one.
- COUT(4) << "Docking:execute PlayerTrigger was not triggered by a player.." << std::endl;
+ orxout(verbose, context::docking) << "Docking:execute PlayerTrigger was not triggered by a player.." << endl;
return false;
}
player = pTrigger->getTriggeringPlayer();
}
else
{
- COUT(4) << "Docking::execute Not a player trigger, can't extract pawn from it.." << std::endl;
+ orxout(verbose, context::docking) << "Docking::execute Not a player trigger, can't extract pawn from it.." << endl;
return false;
}
if(player == NULL)
{
- COUT(4) << "Docking::execute Can't retrieve PlayerInfo from Trigger. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+ orxout(verbose, context::docking) << "Docking::execute Can't retrieve PlayerInfo from Trigger. (" << trigger->getIdentifier()->getName() << ")" << endl;
return false;
}
@@ -167,7 +167,7 @@
// Check if player is a candidate
if(candidates_.find(player) == candidates_.end())
{
- COUT(2) << "Dock::dock Player is not a candidate!" << std::endl;
+ orxout(internal_warning, context::docking) << "Dock::dock Player is not a candidate!" << endl;
return false;
}
@@ -186,7 +186,7 @@
{
if(docked_.find(player) == docked_.end())
{
- COUT(2) << "Dock::dockingAnimationFinished Player is not currently docked." << std::endl;
+ orxout(internal_warning, context::docking) << "Dock::dockingAnimationFinished Player is not currently docked." << endl;
return false;
}
@@ -199,7 +199,7 @@
// Check if player is docked to this Dock
if(docked_.find(player) == docked_.end())
{
- COUT(2) << "Dock::undock Player is not docked to this Dock." << std::endl;
+ orxout(internal_warning, context::docking) << "Dock::undock Player is not docked to this Dock." << endl;
return false;
}
@@ -217,7 +217,7 @@
}
bool Dock::undockingAnimationFinished(PlayerInfo* player) {
- COUT(4) << "Dock::undockingAnimationFinished executed" << std::endl;
+ orxout(verbose, context::docking) << "Dock::undockingAnimationFinished executed" << endl;
return true;
}
Modified: code/trunk/src/modules/docking/DockToShip.cc
===================================================================
--- code/trunk/src/modules/docking/DockToShip.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/docking/DockToShip.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -42,7 +42,7 @@
DockToShip::DockToShip(BaseObject* creator) : DockingEffect(creator)
{
RegisterObject(DockToShip);
- COUT(4) << "DockToShip instance created.." << endl;
+ orxout(verbose, context::docking) << "DockToShip instance created.." << endl;
}
DockToShip::~DockToShip()
@@ -68,17 +68,17 @@
bool DockToShip::docking(PlayerInfo* player)
{
- COUT(4) << "DockToShip::attach" << endl;
+ orxout(verbose, context::docking) << "DockToShip::attach" << endl;
DockingTarget *target = DockingEffect::findTarget(this->target_);
if (target == NULL) {
- COUT(0) << "Can't retrieve target for '" << this->target_ << "'.." << std::endl;
+ orxout(internal_warning, context::docking) << "Can't retrieve target for '" << this->target_ << "'.." << endl;
return false;
}
ControllableEntity *dockTo = (ControllableEntity*) target->getParent();
if (dockTo == NULL) {
- COUT(2) << "Parent is not a ControllableEntity.." << std::endl;
+ orxout(internal_warning, context::docking) << "Parent is not a ControllableEntity.." << endl;
return false;
}
@@ -91,7 +91,7 @@
bool DockToShip::release(PlayerInfo* player)
{
- COUT(4) << "DockToShip::release" << endl;
+ orxout(verbose, context::docking) << "DockToShip::release" << endl;
player->stopTemporaryControl();
Modified: code/trunk/src/modules/docking/DockingController.cc
===================================================================
--- code/trunk/src/modules/docking/DockingController.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/docking/DockingController.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -96,7 +96,7 @@
if (docking)
{
- COUT(4) << "DockingController::takeControl Taking over control." << std::endl;
+ orxout(verbose, context::docking) << "DockingController::takeControl Taking over control." << endl;
this->entity_->setDestroyWhenPlayerLeft(false);
this->player_->pauseControl();
@@ -107,7 +107,7 @@
void DockingController::positionReached()
{
- COUT(4) << "DockingController::positionReached() called." << std::endl;
+ orxout(verbose, context::docking) << "DockingController::positionReached() called." << endl;
assert(this->player_);
assert(this->dock_);
Modified: code/trunk/src/modules/docking/DockingTarget.cc
===================================================================
--- code/trunk/src/modules/docking/DockingTarget.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/docking/DockingTarget.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -52,7 +52,7 @@
{
SUPER(DockingTarget, XMLPort, xmlelement, mode);
- COUT(4) << "DockingTarget with name '" << this->getName() << "' created.." << std::endl;
+ orxout(verbose, context::docking) << "DockingTarget with name '" << this->getName() << "' created.." << endl;
}
}
Modified: code/trunk/src/modules/gametypes/RaceCheckPoint.cc
===================================================================
--- code/trunk/src/modules/gametypes/RaceCheckPoint.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/gametypes/RaceCheckPoint.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -28,9 +28,10 @@
#include "RaceCheckPoint.h"
+#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "util/Convert.h"
+#include "chat/ChatManager.h"
#include "SpaceRace.h"
@@ -109,9 +110,9 @@
if (gametype)
{
const std::string& message = "You have " + multi_cast<std::string>(this->bTimeLimit_)
- + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1) + "\n";
- COUT(3) << message;
+ + " seconds to reach the check point " + multi_cast<std::string>(this->bCheckpointIndex_+1);
const_cast<GametypeInfo*>(gametype->getGametypeInfo())->sendAnnounceMessage(message);
+ ChatManager::message(message);
}
}
}
Modified: code/trunk/src/modules/gametypes/SpaceRace.cc
===================================================================
--- code/trunk/src/modules/gametypes/SpaceRace.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/gametypes/SpaceRace.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,7 +29,7 @@
#include "SpaceRace.h"
#include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "util/Convert.h"
#include "util/Math.h"
@@ -53,27 +53,29 @@
{
this->clock_.capture();
int s = this->clock_.getSeconds();
- int ms = this->clock_.getMilliseconds()-1000*s;
+ int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
const std::string& message = multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms) + " seconds !!\n"
+ "You didn't reach the check point " + multi_cast<std::string>(this->checkpointsReached_+1)
+ " before the time limit. You lose!";
- COUT(3) << message;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ ChatManager::message(message);
}
else
{
this->clock_.capture();
int s = this->clock_.getSeconds();
- int ms = this->clock_.getMilliseconds()-1000*s;
+ int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
const std::string& message = "You win!! You have reached the last check point after "+ multi_cast<std::string>(s)
+ "." + multi_cast<std::string>(ms) + " seconds.";
- COUT(3) << message << std::endl;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ ChatManager::message(message);
+/*
float time = this->clock_.getSecondsPrecise();
this->scores_.insert(time);
std::set<float>::iterator it;
for (it=this->scores_.begin(); it!=this->scores_.end(); it++)
- COUT(3) << multi_cast<std::string>(*it) << std::endl;
+ orxout(level::message) << multi_cast<std::string>(*it) << endl;
+*/
}
}
@@ -82,8 +84,8 @@
Gametype::start();
std::string message("The match has started! Reach the check points as quickly as possible!");
- COUT(3) << message << std::endl;
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ ChatManager::message(message);
}
void SpaceRace::newCheckpointReached()
@@ -91,12 +93,12 @@
this->checkpointsReached_++;
this->clock_.capture();
int s = this->clock_.getSeconds();
- int ms = this->clock_.getMilliseconds()-1000*s;
+ int ms = static_cast<int>(this->clock_.getMilliseconds()-1000*s);
const std::string& message = "Checkpoint " + multi_cast<std::string>(this->getCheckpointsReached())
+ " reached after " + multi_cast<std::string>(s) + "." + multi_cast<std::string>(ms)
- + " seconds.\n";
- COUT(3) << message;
+ + " seconds.";
const_cast<GametypeInfo*>(this->getGametypeInfo())->sendAnnounceMessage(message);
+ ChatManager::message(message);
}
-}
\ No newline at end of file
+}
Modified: code/trunk/src/modules/notifications/NotificationDispatcher.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationDispatcher.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/notifications/NotificationDispatcher.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -136,7 +136,7 @@
if(!triggered || !this->isActive()) // If the NotificationDispatcher is inactive it cannot be executed.
return false;
- COUT(4) << "NotificationDispatcher (&" << this << ") triggered." << std::endl;
+ orxout(verbose, context::notifications) << "NotificationDispatcher (&" << this << ") triggered." << endl;
PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
PlayerInfo* player = NULL;
@@ -154,7 +154,7 @@
if(player == NULL)
{
- COUT(4) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+ orxout(verbose, context::notifications) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << endl;
return false;
}
Modified: code/trunk/src/modules/notifications/NotificationManager.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/notifications/NotificationManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -56,7 +56,7 @@
{
RegisterRootObject(NotificationManager);
- COUT(3) << "NotificatioManager created." << std::endl;
+ orxout(internal_info, context::notifications) << "NotificatioManager created." << endl;
}
/**
@@ -70,7 +70,7 @@
it->second->destroy();
this->allNotificationsList_.clear();
- COUT(3) << "NotificationManager destroyed." << std::endl;
+ orxout(internal_info, context::notifications) << "NotificationManager destroyed." << endl;
}
/**
@@ -131,7 +131,7 @@
}
if(commandExecuted)
- COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl;
+ orxout(internal_info, context::notifications) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl;
return commandExecuted;
}
@@ -197,7 +197,7 @@
}
}
- COUT(4) << "Notification (&" << notification << ") registered with the NotificationManager." << std::endl;
+ orxout(verbose, context::notifications) << "Notification (&" << notification << ") registered with the NotificationManager." << endl;
return true;
}
@@ -218,7 +218,7 @@
// Remove the Notification from the list of Notifications of the input NotificationQueue.
this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second));
- COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl;
+ orxout(verbose, context::notifications) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << endl;
}
/**
@@ -350,7 +350,7 @@
queue->update(); // Update the queue.
- COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl;
+ orxout(verbose, context::notifications) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << endl;
return true;
}
@@ -383,7 +383,7 @@
// Remove the Notifications list that was associated with the input NotificationQueue.
this->notificationLists_.erase(queue->getName());
- COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl;
+ orxout(verbose, context::notifications) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << endl;
}
/**
Modified: code/trunk/src/modules/notifications/NotificationQueue.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationQueue.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/notifications/NotificationQueue.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -130,11 +130,11 @@
if(!queueRegistered) // If the registration has failed.
{
this->registered_ = false;
- COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;
+ orxout(internal_error, context::notifications) << "NotificationQueue '" << this->getName() << "' could not be registered." << endl;
return;
}
- COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
+ orxout(internal_info, context::notifications) << "NotificationQueue '" << this->getName() << "' created." << endl;
}
/**
@@ -214,7 +214,7 @@
delete notifications;
- COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl;
+ orxout(verbose, context::notifications) << "NotificationQueue '" << this->getName() << "' updated." << endl;
}
/**
@@ -231,7 +231,7 @@
this->push(notification, time);
- COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << std::endl;
+ orxout(verbose, context::notifications) << "NotificationQueue '" << this->getName() << "' updated. A new Notification has been added." << endl;
}
/**
@@ -264,8 +264,8 @@
// Inform that a Notification was pushed.
this->notificationPushed(notification);
- COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
- COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl;
+ orxout(verbose_more, context::notifications) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
+ orxout(internal_info, context::notifications) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl;
}
/**
@@ -283,7 +283,7 @@
{
if(container == *it)
{
- COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" popped from NotificationQueue '" << this->getName() << "'" << endl;
+ orxout(verbose_more, context::notifications) << "Notification \"" << (*it)->notification->getMessage() << "\" popped from NotificationQueue '" << this->getName() << "'" << endl;
this->ordering_.erase(it);
break;
}
@@ -310,7 +310,7 @@
// Get the index at which the Notification is.
std::vector<NotificationContainer*>::difference_type index = it - this->notifications_.begin ();
- COUT(5) << "Notification \"" << (*it)->notification->getMessage() << "\" removed from NotificationQueue '" << this->getName() << "'" << endl;
+ orxout(verbose_more, context::notifications) << "Notification \"" << (*it)->notification->getMessage() << "\" removed from NotificationQueue '" << this->getName() << "'" << endl;
this->ordering_.erase(containerIterator);
this->notifications_.erase(it);
@@ -332,7 +332,7 @@
*/
void NotificationQueue::clear(bool noGraphics)
{
- COUT(4) << "Clearing NotificationQueue " << this->getName() << "." << endl;
+ orxout(verbose, context::notifications) << "Clearing NotificationQueue " << this->getName() << "." << endl;
this->ordering_.clear();
// Delete all NotificationContainers in the list.
for(std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++)
@@ -366,7 +366,7 @@
if(size == 0)
{
- COUT(2) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl;
+ orxout(internal_warning, context::notifications) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl;
return;
}
@@ -397,7 +397,7 @@
if(time != NotificationQueue::INF && time <= 0)
{
- COUT(2) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl;
+ orxout(internal_warning, context::notifications) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl;
}
this->displayTime_ = time;
Modified: code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc
===================================================================
--- code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -142,7 +142,7 @@
if(size.x < 0.0 || size.x > 1.0 || size.z < 0.0 || size.z > 1.0)
{
- COUT(2) << "The display size of the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative size was not in [0,1]. Aborting..." << endl;
+ orxout(internal_warning, context::notifications) << "The display size of the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative size was not in [0,1]. Aborting..." << endl;
return;
}
@@ -182,7 +182,7 @@
if(position.x < 0.0 || position.x > 1.0 || position.z < 0.0 || position.z > 1.0)
{
- COUT(2) << "The position the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative position was not in [0,1]. Aborting..." << endl;
+ orxout(internal_warning, context::notifications) << "The position the NotificationQueueCEGUI " << this->getName() << " was trying to be set, but the relative position was not in [0,1]. Aborting..." << endl;
return;
}
Modified: code/trunk/src/modules/objects/ForceField.cc
===================================================================
--- code/trunk/src/modules/objects/ForceField.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/ForceField.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -215,7 +215,7 @@
this->mode_ = forceFieldMode::newtonianGravity;
else
{
- COUT(2) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << std::endl;
+ orxout(internal_warning) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << endl;
this->mode_ = forceFieldMode::tube;
}
}
Modified: code/trunk/src/modules/objects/Planet.cc
===================================================================
--- code/trunk/src/modules/objects/Planet.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/Planet.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -72,7 +72,7 @@
if (activeCamera && this->billboard_.getBillboardSet())
{
float distance = this->getPosition().distance( activeCamera->getWorldPosition() );
- // COUT(2) << distance << std::endl;
+ // orxout(internal_warning) << distance << endl;
float planetRadius = this->getScale();
float newScale = 2 * distance / sqrt(distance*distance - planetRadius*planetRadius);
Modified: code/trunk/src/modules/objects/Script.cc
===================================================================
--- code/trunk/src/modules/objects/Script.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/Script.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -136,7 +136,7 @@
if(!triggered || !this->isActive()) // If the Script is inactive it cannot be executed.
return false;
- COUT(4) << "Script (&" << this << ") triggered." << std::endl;
+ orxout(verbose, context::misc::script) << "Script (&" << this << ") triggered." << endl;
PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
PlayerInfo* player = NULL;
@@ -154,7 +154,7 @@
if(player == NULL) //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
{
- COUT(4) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+ orxout(internal_warning) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << endl;
return false;
}
@@ -271,7 +271,7 @@
}
else
{
- COUT(2) << "Invalid mode '" << mode << "' in Script object. Setting to 'normal'." << std::endl;
+ orxout(internal_warning) << "Invalid mode '" << mode << "' in Script object. Setting to 'normal'." << endl;
this->setMode(ScriptMode::normal);
this->modeStr_ = Script::NORMAL;
}
@@ -322,7 +322,7 @@
}
else
{
- COUT(2) << "Invalid times '" << times << "' in Script. Setting to infinity." << std::endl;
+ orxout(internal_warning) << "Invalid times '" << times << "' in Script. Setting to infinity." << endl;
this->times_ = Script::INF;
this->remainingExecutions_ = Script::INF;
}
Modified: code/trunk/src/modules/objects/SpaceBoundaries.cc
===================================================================
--- code/trunk/src/modules/objects/SpaceBoundaries.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/SpaceBoundaries.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -214,7 +214,7 @@
{
distance = this->computeDistance(currentPawn);
humanItem = this->isHumanPlayer(currentPawn);
- COUT(5) << "Distance:" << distance << std::endl; // message for debugging
+// orxout() << "Distance:" << distance << endl; // message for debugging
if(distance > this->warnDistance_ && distance < this->maxDistance_) // Display warning
{
if(humanItem)
@@ -230,7 +230,7 @@
{
if( humanItem )
{
- COUT(5) << "Health should be decreasing!" << std::endl;
+// orxout() << "Health should be decreasing!" << endl;
this->displayWarning("You are out of the area now!");
}
currentPawn->removeHealth( (distance - this->maxDistance_) * this->healthDecrease_);
Modified: code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -92,7 +92,7 @@
// this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
if(!this->hasUniformScaling())
{
- CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+ orxout(internal_error) << "BoxCollisionShape: Non-uniform scaling is not yet supported." << endl;
return;
}
Modified: code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -91,7 +91,7 @@
//this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
if(!this->hasUniformScaling())
{
- CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+ orxout(internal_error) << "ConeCollisionShape: Non-uniform scaling is not yet supported." << endl;
return;
}
Modified: code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -91,7 +91,7 @@
//this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
if(!this->hasUniformScaling())
{
- CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+ orxout(internal_error) << "PlaneCollisionShape: Non-uniform scaling is not yet supported." << endl;
return;
}
Modified: code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
===================================================================
--- code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -88,7 +88,7 @@
//this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
if(!this->hasUniformScaling())
{
- CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
+ orxout(internal_error) << "SphereCollisionShape: Non-uniform scaling is not yet supported." << endl;
return;
}
Modified: code/trunk/src/modules/objects/eventsystem/EventFilter.cc
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventFilter.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/eventsystem/EventFilter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -62,7 +62,7 @@
{
if (this->bActive_)
{
- COUT(2) << "Warning: Detected Event loop in EventFilter \"" << this->getName() << '"' << std::endl;
+ orxout(internal_warning, context::events) << "Detected Event loop in EventFilter \"" << this->getName() << '"' << endl;
return;
}
Modified: code/trunk/src/modules/objects/eventsystem/EventListener.cc
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventListener.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/eventsystem/EventListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -58,11 +58,11 @@
{
if (this->bActive_)
{
- COUT(2) << "Warning: Detected Event loop in EventListener \"" << this->getName() << '"' << std::endl;
+ orxout(internal_warning, context::events) << "Detected Event loop in EventListener \"" << this->getName() << '"' << endl;
return;
}
- COUT(4) << "EventListener, processing event: originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << ")" << ", activate: " << event.activate_ << ", name: " << event.name_ << std::endl;
+ orxout(verbose, context::events) << "EventListener, processing event: originator: " << event.originator_->getIdentifier()->getName() << " (&" << event.originator_ << ")" << ", activate: " << event.activate_ << ", name: " << event.name_ << endl;
this->bActive_ = true;
//TODO: Why not this->fireEvent(event)?
Modified: code/trunk/src/modules/objects/eventsystem/EventTarget.cc
===================================================================
--- code/trunk/src/modules/objects/eventsystem/EventTarget.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/eventsystem/EventTarget.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -59,7 +59,7 @@
{
if (this->bActive_)
{
- COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << '"' << std::endl;
+ orxout(internal_warning, context::events) << "Detected Event loop in EventTarget \"" << this->getName() << '"' << endl;
return;
}
Modified: code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -246,7 +246,7 @@
else if(mode == DistanceMultiTrigger::beaconModeExlcude_s)
this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::exclude);
else
- COUT(1) << "Invalid beacon mode in DistanceMultiTrigger." << endl;
+ orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceMultiTrigger." << endl;
}
/**
Modified: code/trunk/src/modules/objects/triggers/DistanceTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/DistanceTrigger.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/triggers/DistanceTrigger.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -107,7 +107,7 @@
if (targetId == NULL)
{
- COUT(1) << "Error: \"" << targetStr << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << std::endl;
+ orxout(internal_error, context::triggers) << "\"" << targetStr << "\" is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ')' << endl;
return;
}
@@ -208,7 +208,7 @@
if(pawn != NULL)
this->setTriggeringPawn(pawn);
else
- CCOUT(2) << "Pawn was NULL." << endl;
+ orxout(internal_warning, context::triggers) << "Pawn was NULL." << endl;
}
// Add the entity to the cache.
@@ -269,7 +269,7 @@
else if(mode == DistanceTrigger::beaconModeExlcude_s)
this->setBeaconModeDirect(distanceTriggerBeaconMode::exclude);
else
- COUT(1) << "Invalid beacon mode in DistanceTrigger." << endl;
+ orxout(internal_error, context::triggers) << "Invalid beacon mode in DistanceTrigger." << endl;
}
/**
Modified: code/trunk/src/modules/objects/triggers/MultiTrigger.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/MultiTrigger.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/triggers/MultiTrigger.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -71,7 +71,7 @@
*/
MultiTrigger::~MultiTrigger()
{
- COUT(4) << "Destroying MultiTrigger &" << this << ". " << this->stateQueue_.size() << " states still in queue. Deleting." << std::endl;
+ orxout(verbose, context::triggers) << "Destroying MultiTrigger &" << this << ". " << this->stateQueue_.size() << " states still in queue. Deleting." << endl;
while(this->stateQueue_.size() > 0)
{
MultiTriggerState* state = this->stateQueue_.front().second;
@@ -93,7 +93,7 @@
XMLPortParam(MultiTrigger, "broadcast", setBroadcast, getBroadcast, xmlelement, mode);
XMLPortParamLoadOnly(MultiTrigger, "target", addTarget, xmlelement, mode).defaultValues("Pawn"); //TODO: Remove load only
- COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") created." << std::endl;
+ orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") created." << endl;
}
@@ -131,7 +131,7 @@
// If the state is NULL. (This really shouldn't happen)
if(state == NULL)
{
- COUT(1) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL. State ignored." << std::endl;
+ orxout(internal_error, context::triggers) << "In MultiTrigger '" << this->getName() << "' (&" << this << "), Error: State of new states queue was NULL. State ignored." << endl;
queue->pop();
continue;
}
@@ -240,9 +240,9 @@
{
// Print some debug output if the state has changed.
if(state->originator != NULL)
- COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << std::endl;
+ orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: " << state->originator->getIdentifier()->getName() << " (&" << state->originator << "), active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;
else
- COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: NULL, active: " << bActive << ", triggered: " << state->bTriggered << "." << std::endl;
+ orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") changed state. originator: NULL, active: " << bActive << ", triggered: " << state->bTriggered << "." << endl;
// If the MultiTrigger has a parent trigger, that is itself a MultiTrigger, it needs to call a method to notify him, that its activity has changed.
if(this->parent_ != NULL && this->parent_->isMultiTrigger())
@@ -253,7 +253,7 @@
if(this->remainingActivations_ == 0 && !bActive)
{
this->BaseObject::setActive(false);
- COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << ") ran out of activations. Setting it to inactive." << std::endl;
+ orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << ") ran out of activations. Setting it to inactive." << endl;
}
}
@@ -300,7 +300,7 @@
// If the target is not a valid class name display an error.
if (target == NULL)
{
- COUT(1) << "Error: '" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
+ orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl;
return;
}
@@ -328,7 +328,7 @@
// If the target is not a valid class name display an error.
if (target == NULL)
{
- COUT(1) << "Error: '" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << std::endl;
+ orxout(internal_error, context::triggers) << "'" << targetStr << "' is not a valid class name to include in ClassTreeMask (in " << this->getName() << ", class " << this->getIdentifier()->getName() << ")" << endl;
return;
}
@@ -446,13 +446,13 @@
if(originator == NULL)
{
this->fireEvent(status);
- COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << "): Fired event. status: " << status << "." << std::endl;
+ orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << "): Fired event. status: " << status << "." << endl;
return;
}
MultiTriggerContainer* container = new MultiTriggerContainer(this, this, originator);
this->fireEvent(status, container);
- COUT(4) << "MultiTrigger '" << this->getName() << "' (&" << this << "): Fired event. originator: " << originator->getIdentifier()->getName() << " (&" << originator << "), status: " << status << "." << std::endl;
+ orxout(verbose, context::triggers) << "MultiTrigger '" << this->getName() << "' (&" << this << "): Fired event. originator: " << originator->getIdentifier()->getName() << " (&" << originator << "), status: " << status << "." << endl;
delete container;
}
Modified: code/trunk/src/modules/objects/triggers/TriggerBase.cc
===================================================================
--- code/trunk/src/modules/objects/triggers/TriggerBase.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/objects/triggers/TriggerBase.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -127,7 +127,7 @@
else if (modeName == TriggerBase::xor_s)
this->setMode(TriggerMode::EventTriggerXOR);
else
- COUT(2) << "Invalid mode '" << modeName << "' in TriggerBase " << this->getName() << " &(" << this << "). Leaving mode at '" << this->getModeString() << "'." << std::endl;
+ orxout(internal_warning, context::triggers) << "Invalid mode '" << modeName << "' in TriggerBase " << this->getName() << " &(" << this << "). Leaving mode at '" << this->getModeString() << "'." << endl;
}
/**
Modified: code/trunk/src/modules/overlays/GUIOverlay.cc
===================================================================
--- code/trunk/src/modules/overlays/GUIOverlay.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/overlays/GUIOverlay.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -75,12 +75,12 @@
const std::string& str = multi_cast<std::string>(reinterpret_cast<long>(this));
GUIManager::getInstance().showGUIExtra(this->guiName_, str);
- COUT(4) << "Showing GUI " << this->guiName_ << std::endl;
+ orxout(verbose, context::misc::gui) << "Showing GUI " << this->guiName_ << endl;
}
else
{
GUIManager::hideGUI(this->guiName_);
- COUT(4) << "Hiding GUI " << this->guiName_ << std::endl;
+ orxout(verbose, context::misc::gui) << "Hiding GUI " << this->guiName_ << endl;
}
}
Modified: code/trunk/src/modules/overlays/hud/ChatOverlay.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/ChatOverlay.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/overlays/hud/ChatOverlay.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -66,28 +66,10 @@
SetConfigValue(displayTime_, 6.0f);
}
- void ChatOverlay::incomingChat(const std::string& message, unsigned int senderID)
+ void ChatOverlay::incomingChat(const std::string& message, const std::string& /*name*/)
{
- std::string text;
+ this->messages_.push_back(multi_cast<Ogre::DisplayString>(message));
- if (senderID != NETWORK_PEER_ID_UNKNOWN)
- {
- std::string name = "unknown";
-
- PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
- if (player)
- name = player->getName();
-
- text = name + ": " + message;
- }
- else
- {
- text = message;
- }
-
- this->messages_.push_back(multi_cast<Ogre::DisplayString>(text));
- COUT(0) << "Chat: " << text << std::endl;
-
Timer* timer = new Timer();
this->timers_.insert(timer); // store the timer in a set to destroy it in the destructor
const ExecutorPtr& executor = createExecutor(createFunctor(&ChatOverlay::dropMessage, this));
@@ -109,7 +91,7 @@
{
this->text_->setCaption("");
- for (std::list<Ogre::DisplayString>::reverse_iterator it = this->messages_.rbegin(); it != this->messages_.rend(); ++it)
+ for (std::list<Ogre::DisplayString>::iterator it = this->messages_.begin(); it != this->messages_.end(); ++it)
{
this->text_->setCaption(this->text_->getCaption() + "\n" + (*it));
}
Modified: code/trunk/src/modules/overlays/hud/ChatOverlay.h
===================================================================
--- code/trunk/src/modules/overlays/hud/ChatOverlay.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/overlays/hud/ChatOverlay.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -34,7 +34,7 @@
#include <list>
#include <OgreOverlayElement.h>
-#include "network/ChatListener.h"
+#include "chat/ChatListener.h"
#include "overlays/OverlayText.h"
namespace orxonox
@@ -48,7 +48,7 @@
void setConfigValues();
protected:
- virtual void incomingChat(const std::string& message, unsigned int senderID);
+ virtual void incomingChat(const std::string& message, const std::string& name);
std::list<Ogre::DisplayString> messages_;
Modified: code/trunk/src/modules/overlays/hud/HUDNavigation.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDNavigation.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/overlays/hud/HUDNavigation.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -104,7 +104,7 @@
const Ogre::ResourcePtr& fontPtr = Ogre::FontManager::getSingleton().getByName ( font );
if ( fontPtr.isNull() )
{
- COUT ( 2 ) << "Warning: HUDNavigation: Font '" << font << "' not found" << std::endl;
+ orxout(internal_warning) << "HUDNavigation: Font '" << font << "' not found" << endl;
return;
}
fontName_ = font;
@@ -124,7 +124,7 @@
{
if ( size <= 0.0f )
{
- COUT ( 2 ) << "Warning: HUDNavigation: Negative font size not allowed" << std::endl;
+ orxout(internal_warning) << "HUDNavigation: Negative font size not allowed" << endl;
return;
}
textSize_ = size;
Modified: code/trunk/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/trunk/src/modules/overlays/hud/HUDRadar.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/overlays/hud/HUDRadar.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -159,7 +159,7 @@
const WorldEntity* wePointer = it->first->getWorldEntity();
if( !wePointer )
{
- CCOUT(0) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
+ orxout(internal_error) << "Cannot display a non-WorldEntitiy on the radar" << endl;
assert(0);
}
bool isFocus = (it->first == focusObject);
Modified: code/trunk/src/modules/pickup/Pickup.cc
===================================================================
--- code/trunk/src/modules/pickup/Pickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/Pickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -168,7 +168,7 @@
}
else
{
- COUT(1) << "Invalid activationType '" << type << "' in pickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid activationType '" << type << "' in pickup." << endl;
}
}
@@ -190,7 +190,7 @@
}
else
{
- COUT(1) << "Invalid durationType '" << type << "' in pickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid durationType '" << type << "' in pickup." << endl;
}
}
Modified: code/trunk/src/modules/pickup/PickupManager.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/PickupManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -71,7 +71,7 @@
this->defaultRepresentation_ = new PickupRepresentation();
- COUT(3) << "PickupManager created." << std::endl;
+ orxout(internal_info, context::pickups) << "PickupManager created." << endl;
}
/**
@@ -100,7 +100,7 @@
this->indexes_.clear();
- COUT(3) << "PickupManager destroyed." << std::endl;
+ orxout(internal_info, context::pickups) << "PickupManager destroyed." << endl;
}
/**
@@ -125,7 +125,7 @@
this->representations_[identifier] = representation;
- COUT(4) << "PickupRepresentation &" << representation << " registered with the PickupManager." << std::endl;
+ orxout(verbose, context::pickups) << "PickupRepresentation &" << representation << " registered with the PickupManager." << endl;
return true;
}
@@ -150,7 +150,7 @@
this->representations_.erase(it);
- COUT(4) << "PickupRepresentation &" << representation << " unregistered with the PickupManager." << std::endl;
+ orxout(verbose, context::pickups) << "PickupRepresentation &" << representation << " unregistered with the PickupManager." << endl;
return true;
}
@@ -207,7 +207,7 @@
std::map<const PickupIdentifier*, PickupRepresentation*, PickupIdentifierCompare>::iterator it = this->representations_.find(identifier);
if(it == this->representations_.end()) // If there is no PickupRepresentation associated with the input PickupIdentifier.
{
- COUT(4) << "PickupManager::getRepresentation() returned default representation." << std::endl;
+ orxout(verbose, context::pickups) << "PickupManager::getRepresentation() returned default representation." << endl;
return this->defaultRepresentation_;
}
@@ -283,7 +283,7 @@
// If the input Pickupable (i.e its identifier) is not present in the list the PickupManager has.
if(manager.pickupInventoryContainers_.find(pickup) == manager.pickupInventoryContainers_.end())
{
- COUT(1) << "Error: Pickupable &(" << pickup << ") was not registered with PickupManager for the PickupInventory, when it changed used." << std::endl;
+ orxout(internal_error, context::pickups) << "Pickupable &(" << pickup << ") was not registered with PickupManager for the PickupInventory, when it changed used." << endl;
return;
}
Modified: code/trunk/src/modules/pickup/PickupRepresentation.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupRepresentation.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/PickupRepresentation.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -139,7 +139,7 @@
if(this->spawnerRepresentation_ != NULL)
this->spawnerRepresentation_->setVisible(false);
- COUT(4) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << std::endl;
+ orxout(verbose, context::pickups) << "PickupRepresentation created: name: '" << this->name_ << "', description: '" << this->description_ << "', spawnerTemplate: '" << this->spawnerTemplate_ << "'." << endl;
}
/**
@@ -154,10 +154,10 @@
{
if(this->spawnerRepresentation_ == NULL)
{
- COUT(4) << "PickupRepresentation: No spawner representation found." << std::endl;
+ orxout(verbose, context::pickups) << "PickupRepresentation: No spawner representation found." << endl;
if(this->spawnerTemplate_ == "")
{
- COUT(4) << "PickupRepresentation: Spawner template is empty." << std::endl;
+ orxout(verbose, context::pickups) << "PickupRepresentation: Spawner template is empty." << endl;
// If neither spawnerRepresentation nor spawnerTemplate was specified
return this->getDefaultSpawnerRepresentation(spawner);
}
Modified: code/trunk/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/trunk/src/modules/pickup/PickupSpawner.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/PickupSpawner.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -89,7 +89,7 @@
if(this->pickup_ == NULL)
{
- COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
+ orxout(internal_warning, context::pickups) << "A PickupSpawner was created without a valid Pickupable. This won't work." << endl;
this->setActive(false);
}
else
@@ -143,7 +143,7 @@
if(this->pickup_ == NULL)
{
- COUT(2) << "A PickupSpawner was created without a valid Pickupable. This won't work." << std::endl;
+ orxout(internal_warning, context::pickups) << "A PickupSpawner was created without a valid Pickupable. This won't work." << endl;
this->setActive(false);
}
else
@@ -238,7 +238,7 @@
}
else
{
- COUT(4) << "PickupSpawner (&" << this << ") empty, selfdestruct initialized." << std::endl;
+ orxout(verbose, context::pickups) << "PickupSpawner (&" << this << ") empty, selfdestruct initialized." << endl;
this->setActive(false);
this->destroy();
}
@@ -263,12 +263,12 @@
{
if(this->pickup_ != NULL)
{
- COUT(1) << "In PickupSpawner (&" << this << "): setPickupable called, with this->pickup_ already set." << std::endl;
+ orxout(internal_error, context::pickups) << "In PickupSpawner (&" << this << "): setPickupable called, with this->pickup_ already set." << endl;
return;
}
if(pickup == NULL)
{
- COUT(1) << "In PickupSpawner (&" << this << "): Argument of setPickupable is NULL." << std::endl;
+ orxout(internal_error, context::pickups) << "In PickupSpawner (&" << this << "): Argument of setPickupable is NULL." << endl;
return;
}
@@ -297,7 +297,7 @@
{
if(this->isActive()) // Checks whether PickupSpawner is active.
{
- COUT(4) << "PickupSpawner (&" << this << ") triggered and active." << std::endl;
+ orxout(verbose, context::pickups) << "PickupSpawner (&" << this << ") triggered and active." << endl;
PickupCarrier* carrier = dynamic_cast<PickupCarrier*>(pawn);
assert(carrier);
@@ -305,7 +305,7 @@
// If the Pawn isn't a target of the Pickupable.
if(!carrier->isTarget(this->pickup_))
{
- COUT(4) << "PickupSpawner (&" << this << ") triggered but Pawn wasn't a target of the Pickupable." << std::endl;
+ orxout(verbose, context::pickups) << "PickupSpawner (&" << this << ") triggered but Pawn wasn't a target of the Pickupable." << endl;
return;
}
@@ -334,7 +334,7 @@
{
if(this->spawnsRemaining_ == 0)
{
- COUT(1) << "Massive Error: PickupSpawner still alive until having spawned last item." << std::endl;
+ orxout(internal_error, context::pickups) << "Massive Error: PickupSpawner still alive until having spawned last item." << endl;
return NULL;
}
@@ -348,7 +348,7 @@
*/
void PickupSpawner::respawnTimerCallback()
{
- COUT(4) << "PickupSpawner (&" << this << ") reactivated." << std::endl;
+ orxout(verbose, context::pickups) << "PickupSpawner (&" << this << ") reactivated." << endl;
this->setActive(true);
}
Modified: code/trunk/src/modules/pickup/items/DronePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/DronePickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/DronePickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -178,7 +178,7 @@
if(pawn == NULL)
{
- COUT(1) << "Invalid PickupCarrier in DronePickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid PickupCarrier in DronePickup." << endl;
}
return pawn;
Modified: code/trunk/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/HealthPickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -168,7 +168,7 @@
pawn->addHealth(health);
break;
default:
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
}
// If all health has been transferred.
@@ -217,7 +217,7 @@
pawn->addHealth(this->getHealth());
break;
default:
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
}
// The pickup has been used up.
@@ -233,7 +233,7 @@
if(pawn == NULL)
{
- COUT(1) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << std::endl;
+ orxout(internal_error, context::pickups) << "Something went horribly wrong in Health Pickup. PickupCarrier is no Pawn." << endl;
this->Pickupable::destroy();
return;
}
@@ -267,7 +267,7 @@
if(pawn == NULL)
{
- COUT(1) << "Invalid PickupCarrier in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid PickupCarrier in HealthPickup." << endl;
}
return pawn;
@@ -311,7 +311,7 @@
case pickupHealthType::permanent:
return HealthPickup::healthTypePermanent_s;
default:
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
return BLANKSTRING;
}
}
@@ -330,7 +330,7 @@
}
else
{
- COUT(1) << "Invalid health in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid health in HealthPickup." << endl;
this->health_ = 0.0;
}
}
@@ -349,7 +349,7 @@
}
else
{
- COUT(1) << "Invalid healthSpeed in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid healthSpeed in HealthPickup." << endl;
}
}
@@ -375,7 +375,7 @@
}
else
{
- COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid healthType in HealthPickup." << endl;
}
}
Modified: code/trunk/src/modules/pickup/items/InvisiblePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/InvisiblePickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/InvisiblePickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -205,7 +205,7 @@
if(pawn == NULL)
{
- COUT(1) << "Invalid PickupCarrier in InvisiblePickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid PickupCarrier in InvisiblePickup." << endl;
}
return pawn;
}
@@ -224,7 +224,7 @@
}
else
{
- COUT(1) << "Invalid duration in InvisiblePickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid duration in InvisiblePickup." << endl;
this->duration_ = 0.0f;
}
}
Modified: code/trunk/src/modules/pickup/items/MetaPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/MetaPickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/MetaPickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -231,7 +231,7 @@
this->setMetaTypeDirect(pickupMetaType::destroyCarrier);
}
else
- COUT(2) << "Invalid metaType '" << type << "' in MetaPickup." << std::endl;
+ orxout(internal_warning, context::pickups) << "Invalid metaType '" << type << "' in MetaPickup." << endl;
}
}
Modified: code/trunk/src/modules/pickup/items/ShieldPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/ShieldPickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/ShieldPickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -180,7 +180,7 @@
if(pawn == NULL)
{
- COUT(1) << "Invalid PickupCarrier in ShieldPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid PickupCarrier in ShieldPickup." << endl;
}
return pawn;
}
@@ -219,7 +219,7 @@
}
else
{
- COUT(1) << "Invalid duration in ShieldPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid duration in ShieldPickup." << endl;
this->duration_ = 0.0f;
}
}
@@ -238,7 +238,7 @@
}
else
{
- COUT(1) << "Invalid Shieldhealth in ShieldPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid Shieldhealth in ShieldPickup." << endl;
this->shieldHealth_=0;
}
}
@@ -257,7 +257,7 @@
}
else
{
- COUT(1) << "Invalid Absorption in ShieldPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid Absorption in ShieldPickup." << endl;
this->shieldAbsorption_=0;
}
}
Modified: code/trunk/src/modules/pickup/items/ShrinkPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/ShrinkPickup.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/ShrinkPickup.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -92,7 +92,7 @@
@param factor The factor, needs to greater than 1.
*/
inline void setShrinkFactor(float factor)
- { if(factor <= 1.0f) { COUT(2) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkFactor_ = factor; }
+ { if(factor <= 1.0f) { orxout(internal_warning, context::pickups) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkFactor_ = factor; }
/**
@brief Get the duration for which the ship remains shrunken.
@return Returns the duration.
@@ -104,7 +104,7 @@
@param duration The duration, needs to be non-negative.
*/
inline void setDuration(float duration)
- { if(duration < 0.0f) { COUT(2) << "Invalid duration in ShrinkPickup. Ignoring.." << endl; return; } this->duration_ = duration; }
+ { if(duration < 0.0f) { orxout(internal_warning, context::pickups) << "Invalid duration in ShrinkPickup. Ignoring.." << endl; return; } this->duration_ = duration; }
/**
@brief Get the shrink speed.
@return Returns the shrink speed.
@@ -116,7 +116,7 @@
@param speed The shrink duration, needs to be positive.
*/
inline void setShrinkDuration(float speed)
- { if(speed <= 0.0f) { COUT(2) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkDuration_ = speed; }
+ { if(speed <= 0.0f) { orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkDuration_ = speed; }
protected:
void initializeIdentifier(void);
Modified: code/trunk/src/modules/pickup/items/SpeedPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/SpeedPickup.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pickup/items/SpeedPickup.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -179,7 +179,7 @@
if(ship == NULL)
{
- COUT(1) << "Invalid PickupCarrier in SpeedPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid PickupCarrier in SpeedPickup." << endl;
}
return ship;
@@ -220,7 +220,7 @@
}
else
{
- COUT(1) << "Invalid duration in SpeedPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid duration in SpeedPickup." << endl;
this->duration_ = 0.0f;
}
}
@@ -239,7 +239,7 @@
}
else
{
- COUT(1) << "Invalid speedAdd in SpeedPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid speedAdd in SpeedPickup." << endl;
this->speedAdd_ = 0.0f;
}
}
@@ -258,7 +258,7 @@
}
else
{
- COUT(1) << "Invalid speedMultiply in SpeedPickup." << std::endl;
+ orxout(internal_error, context::pickups) << "Invalid speedMultiply in SpeedPickup." << endl;
this->speedMultiply_ = 1.0f;
}
}
Modified: code/trunk/src/modules/pong/Pong.cc
===================================================================
--- code/trunk/src/modules/pong/Pong.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/pong/Pong.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -161,7 +161,7 @@
}
else // If no centerpoint was specified, an error is thrown and the level is exited.
{
- COUT(1) << "Error: No Centerpoint specified." << std::endl;
+ orxout(internal_error) << "Pong: No Centerpoint specified." << endl;
GSLevel::startMainMenu();
return;
}
Modified: code/trunk/src/modules/questsystem/GlobalQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/GlobalQuest.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/GlobalQuest.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -70,7 +70,7 @@
XMLPortObject(GlobalQuest, QuestEffect, "reward-effects", addRewardEffect, getRewardEffects, xmlelement, mode);
- COUT(4) << "New GlobalQuest {" << this->getId() << "} created." << std::endl;
+ orxout(verbose, context::quests) << "New GlobalQuest {" << this->getId() << "} created." << endl;
}
/**
@@ -86,7 +86,7 @@
{
if(!this->isFailable(player)) // Check whether the Quest can be failed.
{
- COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
+ orxout(verbose, context::quests) << "A non-completable quest was trying to be failed." << endl;
return false;
}
@@ -113,7 +113,7 @@
{
if(!this->isCompletable(player)) // Check whether the Quest can be completed.
{
- COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
+ orxout(verbose, context::quests) << "A non-completable quest was trying to be completed." << endl;
return false;
}
@@ -226,7 +226,7 @@
this->rewards_.push_back(effect); // Add the QuestEffect to the list.
- COUT(4) << "Reward effect was added to Quest {" << this->getId() << "}." << std::endl;
+ orxout(verbose, context::quests) << "Reward effect was added to Quest {" << this->getId() << "}." << endl;
return true;
}
Modified: code/trunk/src/modules/questsystem/LocalQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/LocalQuest.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/LocalQuest.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -68,7 +68,7 @@
{
SUPER(LocalQuest, XMLPort, xmlelement, mode);
- COUT(4) << "New LocalQuest {" << this->getId() << "} created." << std::endl;
+ orxout(verbose, context::quests) << "New LocalQuest {" << this->getId() << "} created." << endl;
}
/**
@@ -84,7 +84,7 @@
{
if(!this->isFailable(player)) // Checks whether the quest can be failed.
{
- COUT(4) << "A non-failable quest was trying to be failed." << std::endl;
+ orxout(verbose, context::quests) << "A non-failable quest was trying to be failed." << endl;
return false;
}
@@ -107,7 +107,7 @@
{
if(!this->isCompletable(player)) // Checks whether the Quest can be completed.
{
- COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
+ orxout(verbose, context::quests) << "A non-completable quest was trying to be completed." << endl;
return false;
}
Modified: code/trunk/src/modules/questsystem/Quest.cc
===================================================================
--- code/trunk/src/modules/questsystem/Quest.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/Quest.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -95,7 +95,7 @@
this->parentQuest_ = quest;
- COUT(4) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+ orxout(verbose, context::quests) << "Parent Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << endl;
return true;
}
@@ -114,7 +114,7 @@
quest->setParentQuest(this); // Sets the currentQuest (this) as parent-quest for the added sub-quest.
this->subQuests_.push_back(quest); // Adds the Quest to the end of the list of sub-quests.
- COUT(4) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+ orxout(verbose, context::quests) << "Sub Quest {" << quest->getId() << "} was added to Quest {" << this->getId() << "}." << endl;
return true;
}
@@ -134,7 +134,7 @@
hint->setQuest(this); // Sets the current Quest (this) as Quest for the added QuestHint.
this->hints_.push_back(hint); // Adds the QuestHint to the end of the list of QuestHints.
- COUT(4) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << std::endl;
+ orxout(verbose, context::quests) << "QuestHint {" << hint->getId() << "} was added to Quest {" << this->getId() << "}." << endl;
return true;
}
@@ -152,7 +152,7 @@
this->failEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of fail QuestEffects.
- COUT(4) << "A FailEffect was added to Quest {" << this->getId() << "}." << std::endl;
+ orxout(verbose, context::quests) << "A FailEffect was added to Quest {" << this->getId() << "}." << endl;
return true;
}
@@ -170,7 +170,7 @@
this->completeEffects_.push_back(effect); // Adds the QuestEffect to the end of the list of complete QuestEffects.
- COUT(4) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << std::endl;
+ orxout(verbose, context::quests) << "A CompleteEffect was added to Quest {" << this->getId() << "}." << endl;
return true;
}
@@ -340,7 +340,7 @@
QuestListener::advertiseStatusChange(this->listeners_, "fail"); // Tells the QuestListeners, that the status has changed to failed.
this->setStatus(player, QuestStatus::Failed);
- COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl;
+ orxout(verbose, context::quests) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." << endl;
this->getDescription()->sendFailQuestNotification(player);
return true;
@@ -359,7 +359,7 @@
QuestListener::advertiseStatusChange(this->listeners_, "complete"); // Tells the QuestListeners, that the status has changed to completed.
this->setStatus(player, QuestStatus::Completed);
- COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl;
+ orxout(verbose, context::quests) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." << endl;
this->getDescription()->sendCompleteQuestNotification(player);
return true;
@@ -377,11 +377,11 @@
{
if(!this->isStartable(player)) // Checks whether the quest can be started.
{
- COUT(4) << "A non-startable quest was trying to be started." << std::endl;
+ orxout(verbose, context::quests) << "A non-startable quest was trying to be started." << endl;
return false;
}
- COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl;
+ orxout(verbose, context::quests) << "Quest {" << this->getId() << "} is started for player: " << player << " ." << endl;
QuestListener::advertiseStatusChange(this->listeners_, "start"); // Tells the QuestListeners, that the status has changed to active.
Modified: code/trunk/src/modules/questsystem/QuestDescription.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestDescription.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestDescription.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -78,7 +78,7 @@
XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
- COUT(4) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
+ orxout(verbose, context::quests) << "New QuestDescription with title '" << this->getTitle() << "' created." << endl;
}
/**
@@ -108,13 +108,13 @@
message = "You successfully completed the quest: '" + this->title_ + '\'';
else
{
- COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
+ orxout(internal_warning, context::quests) << "Bad input in notificationHelper, this should not be happening!" << endl;
return false;
}
}
else
{
- COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
+ orxout(internal_warning, context::quests) << "Bad input in notificationHelper, this should not be happening!" << endl;
return false;
}
Modified: code/trunk/src/modules/questsystem/QuestEffect.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestEffect.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestEffect.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -69,7 +69,7 @@
{
bool temp = true;
- COUT(4) << "Invoking QuestEffects on player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "Invoking QuestEffects on player: " << player << " ." << endl;
for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
temp = temp && (*effect)->invoke(player);
Modified: code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestEffectBeacon.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestEffectBeacon.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -78,7 +78,7 @@
XMLPortEventSink(QuestEffectBeacon, BaseObject, "execute", execute, xmlelement, mode); //TODO: Change BaseObject to MultiTrigger as soon as MultiTrigger is the base of all triggers.
- COUT(4) << "New QuestEffectBeacon created." << std::endl;
+ orxout(verbose, context::quests) << "New QuestEffectBeacon created." << endl;
}
void QuestEffectBeacon::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -107,7 +107,7 @@
}
if(!(this->isActive())) // If the QuestEffectBeacon is inactive it cannot be executed.
{
- COUT(4) << "The QuestEffectBeacon is inactive." << std::endl;
+ orxout(verbose, context::quests) << "The QuestEffectBeacon is inactive." << endl;
return false;
}
@@ -127,11 +127,11 @@
if(player == NULL)
{
- COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
+ orxout(verbose, context::quests) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << endl;
return false;
}
- COUT(4) << "QuestEffectBeacon executed on player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "QuestEffectBeacon executed on player: " << player << " ." << endl;
bool temp = QuestEffect::invokeEffects(player, this->effects_); // Invoke the QuestEffects on the PlayerInfo.
if(temp)
@@ -220,7 +220,7 @@
this->effects_.push_back(effect);
- COUT(4) << "A QuestEffect was added to a QuestEffectBeacon." << std::endl;
+ orxout(verbose, context::quests) << "A QuestEffect was added to a QuestEffectBeacon." << endl;
return true;
}
Modified: code/trunk/src/modules/questsystem/QuestHint.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestHint.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestHint.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -73,7 +73,7 @@
QuestManager::getInstance().registerHint(this); // Registers the QuestHint with the QuestManager.
- COUT(4) << "New QuestHint {" << this->getId() << "} created." << std::endl;
+ orxout(verbose, context::quests) << "New QuestHint {" << this->getId() << "} created." << endl;
}
@@ -119,12 +119,12 @@
}
else
{
- COUT(4) << "An already active questHint was trying to get activated." << std::endl;
+ orxout(verbose, context::quests) << "An already active questHint was trying to get activated." << endl;
return false;
}
}
- COUT(4) << "A hint of a non-active quest was trying to get activated." << std::endl;
+ orxout(verbose, context::quests) << "A hint of a non-active quest was trying to get activated." << endl;
return false;
}
Modified: code/trunk/src/modules/questsystem/QuestItem.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestItem.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestItem.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -88,7 +88,7 @@
{
if(id == "") // Checks whether the id is a valid id.
{
- COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
+ orxout(internal_warning, context::quests) << "Invalid id. QuestItem id {" << id << "} could not be set." << endl;
return;
}
Modified: code/trunk/src/modules/questsystem/QuestListener.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestListener.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestListener.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -83,7 +83,7 @@
if(this->quest_ != NULL)
this->quest_->addListener(this); // Adds the QuestListener to the Quests list of listeners.
- COUT(4) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << std::endl;
+ orxout(verbose, context::quests) << "QuestListener created for quest: {" << this->quest_->getId() << "} with mode '" << this->getMode() << "'." << endl;
}
/**
@@ -145,7 +145,7 @@
this->mode_ = QuestListenerMode::Complete;
else
{
- COUT(2) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << std::endl;
+ orxout(internal_warning, context::quests) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << endl;
this->mode_ = QuestListenerMode::All;
return false;
}
Modified: code/trunk/src/modules/questsystem/QuestManager.cc
===================================================================
--- code/trunk/src/modules/questsystem/QuestManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/QuestManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -60,7 +60,7 @@
{
RegisterRootObject(QuestManager);
- COUT(3) << "QuestManager created." << std::endl;
+ orxout(internal_info, context::quests) << "QuestManager created." << endl;
}
/**
@@ -69,7 +69,7 @@
*/
QuestManager::~QuestManager()
{
- COUT(3) << "QuestManager destroyed." << std::endl;
+ orxout(internal_info, context::quests) << "QuestManager destroyed." << endl;
}
/**
@@ -102,12 +102,12 @@
if(result.second) // If inserting was a success.
{
quest->setRegistered();
- COUT(4) << "Quest with questId {" << quest->getId() << "} successfully inserted." << std::endl;
+ orxout(verbose, context::quests) << "Quest with questId {" << quest->getId() << "} successfully inserted." << endl;
return true;
}
else
{
- COUT(2) << "Quest with the same id was already present." << std::endl;
+ orxout(internal_warning, context::quests) << "Quest with the same id was already present." << endl;
return false;
}
}
@@ -140,12 +140,12 @@
if(result.second) // If inserting was a success.
{
hint->setRegistered();
- COUT(4) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << std::endl;
+ orxout(verbose, context::quests) << "QuestHint with hintId {" << hint->getId() << "} successfully inserted." << endl;
return true;
}
else
{
- COUT(2) << "QuestHint with the same id was already present." << std::endl;
+ orxout(internal_warning, context::quests) << "QuestHint with the same id was already present." << endl;
return false;
}
}
@@ -182,7 +182,7 @@
else
{
quest = NULL;
- COUT(2) << "The quest with id {" << questId << "} is nowhere to be found." << std::endl;
+ orxout(internal_warning, context::quests) << "The quest with id {" << questId << "} is nowhere to be found." << endl;
}
return quest;
@@ -211,7 +211,7 @@
else
{
hint = NULL;
- COUT(2) << "The hint with id {" << hintId << "} is nowhere to be found." << std::endl;
+ orxout(internal_warning, context::quests) << "The hint with id {" << hintId << "} is nowhere to be found." << endl;
}
return hint;
@@ -430,7 +430,7 @@
PlayerInfo* player = GUIManager::getInstance().getPlayer(guiName);
if(player == NULL)
{
- COUT(1) << "Error: GUIOverlay with name '" << guiName << "' has no player." << std::endl;
+ orxout(internal_error, context::quests) << "GUIOverlay with name '" << guiName << "' has no player." << endl;
return NULL;
}
Modified: code/trunk/src/modules/questsystem/effects/AddQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/AddQuest.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/effects/AddQuest.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -69,7 +69,7 @@
{
SUPER(AddQuest, XMLPort, xmlelement, mode);
- COUT(4) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
+ orxout(verbose, context::quests) << "New AddQuest, with target Quest {" << this->getQuestId() << "}, created." << endl;
}
/**
@@ -84,7 +84,7 @@
{
assert(player);
- COUT(5) << "AddQuest on player: " << player << " ." << std::endl;
+ orxout(verbose_more, context::quests) << "AddQuest on player: " << player << " ." << endl;
try
{
@@ -94,11 +94,11 @@
}
catch(const orxonox::Exception& ex)
{
- COUT(2) << ex.getFullDescription() << std::endl;
+ orxout(internal_warning, context::quests) << ex.getFullDescription() << endl;
return false;
}
- COUT(4) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << endl;
return true;
}
Modified: code/trunk/src/modules/questsystem/effects/AddQuestHint.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/AddQuestHint.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/effects/AddQuestHint.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -72,7 +72,7 @@
XMLPortParam(AddQuestHint, "hintId", setHintId, getHintId, xmlelement, mode);
- COUT(4) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << std::endl;
+ orxout(verbose, context::quests) << "New AddQuestHint, with target QuestHint {" << this->getHintId() << "}, created." << endl;
}
/**
@@ -87,7 +87,7 @@
{
if(id == "")
{
- COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
+ orxout(internal_warning, context::quests) << "Invalid id. QuestItem id {" << id << "} could not be set." << endl;
return false;
}
@@ -107,7 +107,7 @@
{
assert(player);
- COUT(5) << "AddQuestHint on player: " << player << " ." << std::endl;
+ orxout(verbose_more, context::quests) << "AddQuestHint on player: " << player << " ." << endl;
try
{
@@ -117,11 +117,11 @@
}
catch(const Exception& e)
{
- COUT(2) << e.getFullDescription() << std::endl;
+ orxout(internal_warning, context::quests) << e.getFullDescription() << endl;
return false;
}
- COUT(4) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << endl;
return true;
}
Modified: code/trunk/src/modules/questsystem/effects/AddReward.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/AddReward.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/effects/AddReward.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -69,7 +69,7 @@
XMLPortObject(AddReward, Rewardable, "", addRewardable, getRewardables, xmlelement, mode);
- COUT(4) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << std::endl;
+ orxout(verbose, context::quests) << "New AddReward, with " << this->rewards_.size() << " Rewardables created." << endl;
}
/**
@@ -102,13 +102,13 @@
*/
bool AddReward::invoke(PlayerInfo* player)
{
- COUT(5) << "AddReward on player: " << player << " ." << std::endl;
+ orxout(verbose_more, context::quests) << "AddReward on player: " << player << " ." << endl;
bool temp = true;
for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
temp = temp && (*reward)->reward(player);
- COUT(4) << "Rewardable successfully added to player." << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "Rewardable successfully added to player." << player << " ." << endl;
return temp;
}
Modified: code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/effects/ChangeQuestStatus.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -82,7 +82,7 @@
{
if(id == "")
{
- COUT(2) << "Invalid id. QuestItem id {" << id << "} could not be set." << std::endl;
+ orxout(internal_warning, context::quests) << "Invalid id. QuestItem id {" << id << "} could not be set." << endl;
return false;
}
Modified: code/trunk/src/modules/questsystem/effects/CompleteQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/CompleteQuest.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/effects/CompleteQuest.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -69,7 +69,7 @@
{
SUPER(CompleteQuest, XMLPort, xmlelement, mode);
- COUT(4) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
+ orxout(verbose, context::quests) << "New CompleteQuest, with target Quest {" << this->getQuestId() << "}, created." << endl;
}
/**
@@ -84,7 +84,7 @@
{
assert(player);
- COUT(5) << "CompleteQuest on player: " << player << " ." << std::endl;
+ orxout(verbose_more, context::quests) << "CompleteQuest on player: " << player << " ." << endl;
Quest* quest;
@@ -96,11 +96,11 @@
}
catch(const Exception& e)
{
- COUT(2) << e.getFullDescription() << std::endl;
+ orxout(internal_warning, context::quests) << e.getFullDescription() << endl;
return false;
}
- COUT(4) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "Quest {" << quest->getId() << "} successfully completed by player: " << player << " ." << endl;
return true;
}
Modified: code/trunk/src/modules/questsystem/effects/FailQuest.cc
===================================================================
--- code/trunk/src/modules/questsystem/effects/FailQuest.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/questsystem/effects/FailQuest.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -69,7 +69,7 @@
{
SUPER(FailQuest, XMLPort, xmlelement, mode);
- COUT(4) << "New FailQuest, with target Quest {" << this->getQuestId() << "}, created." << std::endl;
+ orxout(verbose, context::quests) << "New FailQuest, with target Quest {" << this->getQuestId() << "}, created." << endl;
}
/**
@@ -84,7 +84,7 @@
{
assert(player);
- COUT(4) << "FailQuest on player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "FailQuest on player: " << player << " ." << endl;
Quest* quest;
try
@@ -95,11 +95,11 @@
}
catch(const Exception& e)
{
- COUT(2) << e.getFullDescription() << std::endl;
+ orxout(internal_warning, context::quests) << e.getFullDescription() << endl;
return false;
}
- COUT(4) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << std::endl;
+ orxout(verbose, context::quests) << "Quest {" << quest->getId() << "} failed by player: " << player << " ." << endl;
return true;
}
Modified: code/trunk/src/modules/tetris/Tetris.cc
===================================================================
--- code/trunk/src/modules/tetris/Tetris.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/tetris/Tetris.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -164,7 +164,7 @@
}
else // If no centerpoint was specified, an error is thrown and the level is exited.
{
- COUT(1) << "Error: No Centerpoint specified." << std::endl;
+ orxout(internal_error) << "Tetris: No Centerpoint specified." << endl;
GSLevel::startMainMenu();
return;
}
Modified: code/trunk/src/modules/weapons/RocketController.cc
===================================================================
--- code/trunk/src/modules/weapons/RocketController.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/weapons/RocketController.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -47,7 +47,7 @@
RocketController::RocketController(BaseObject* creator) : Controller(creator)
{
RegisterObject(RocketController);
- COUT(5)<< "RocketController constructed\n";
+// orxout() << "RocketController constructed" << endl;
// Create a rocket for the controller.
this->rocket_ = new SimpleRocket(this);
@@ -72,7 +72,7 @@
RocketController::~RocketController()
{
- COUT(5)<< "RocketController destroyed\n";
+// orxout() << "RocketController destroyed" << endl;
}
/**
Modified: code/trunk/src/modules/weapons/projectiles/BasicProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/BasicProjectile.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/weapons/projectiles/BasicProjectile.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -63,7 +63,7 @@
@param damage The amount of damage. Must be non-negative.
*/
inline void setDamage(float damage)
- { if(damage >= 0.0f) { this->damage_ = damage; return; } COUT(1) << "The input projectile damage must be non-negative. Ignoring..." << endl; }
+ { if(damage >= 0.0f) { this->damage_ = damage; return; } orxout(internal_warning) << "The input projectile damage must be non-negative. Ignoring..." << endl; }
/**
@brief Get the normal damage done by this projectile.
Normal damage can be (partially) absorbed by shields.
@@ -78,7 +78,7 @@
@param healthdamage The amount of damage. Must be non-negative.
*/
inline void setHealthDamage(float healthdamage)
- { if(healthdamage >= 0.0f) { this->healthdamage_ = healthdamage; return; } COUT(1) << "The input projectile health-damage must be non-negative. Ignoring..." << endl; }
+ { if(healthdamage >= 0.0f) { this->healthdamage_ = healthdamage; return; } orxout(internal_warning) << "The input projectile health-damage must be non-negative. Ignoring..." << endl; }
/**
@brief Get the health-damage done by this projectile.
Health-damage cannot be absorbed by shields.
@@ -93,7 +93,7 @@
@param shielddamage The amount of damage. Must be non-negative.
*/
inline void setShieldDamage(float shielddamage)
- { if(shielddamage >= 0.0f) { this->shielddamage_ = shielddamage; return; } COUT(1) << "The input projectile shield-damage must be non-negative. Ignoring..." << endl; }
+ { if(shielddamage >= 0.0f) { this->shielddamage_ = shielddamage; return; } orxout(internal_warning) << "The input projectile shield-damage must be non-negative. Ignoring..." << endl; }
/**
@brief Get the shield-damage done by this projectile.
Shield-damage only reduces shield health.
Modified: code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -38,7 +38,6 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
-#include "util/Debug.h"
#include "controllers/Controller.h"
#include "graphics/Model.h"
Modified: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,8 +31,6 @@
PawnManager.cc
PlayerManager.cc
Radar.cc
- ChatHistory.cc
- ChatInputHandler.cc
# Test.cc
BUILD_UNIT SceneBuildUnit.cc
@@ -41,6 +39,7 @@
END_BUILD_UNIT
)
+ADD_SUBDIRECTORY(chat)
ADD_SUBDIRECTORY(collisionshapes)
ADD_SUBDIRECTORY(controllers)
ADD_SUBDIRECTORY(gamestates)
@@ -58,7 +57,7 @@
ORXONOX_ADD_LIBRARY(orxonox
FIND_HEADER_FILES
TOLUA_FILES
- ChatInputHandler.h
+ chat/ChatInputHandler.h
LevelInfo.h
LevelManager.h
MoodManager.h
Deleted: code/trunk/src/orxonox/ChatHistory.cc
===================================================================
--- code/trunk/src/orxonox/ChatHistory.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/ChatHistory.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,195 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#include "ChatHistory.h"
-#include "util/ScopedSingletonManager.h"
-
-#ifndef CHATTEST
-namespace orxonox
-{
- /* singleton */
- ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
-#endif
-
- /* constructor */
-#ifndef CHATTEST
- //ChatHistory::ChatHistory( BaseObject* creator ) : BaseObject(creator)
- ChatHistory::ChatHistory()
-#else
- ChatHistory::ChatHistory()
-#endif
- {
- /* register the object */
-#ifndef CHATTEST
- RegisterObject(ChatHistory);
-#endif
-
- this->hist_log_enabled = true;
-
- /* Read setting for logfiles */
- if( hist_log_enabled ) /* NOTE Make this a check for the logfile setting */
- { this->chat_hist_openlog();
-
- /* push starting line */
- this->chat_hist_logline( "--- Logfile opened ---" );
- }
-
- /* Read setting for maximum number of lines and set limit */
- this->hist_maxlines = 200; /* NOTE to be changed, 200 is just for testing */
- }
-
- /* destructor */
- ChatHistory::~ChatHistory()
- {
- chat_hist_closelog();
-
- /* clear list */
- this->hist_buffer.clear();
- }
-
- /* react to incoming chat */
- void ChatHistory::incomingChat(const std::string& message,
- unsigned int senderID)
- {
- /* --> a) look up the actual name of the sender */
- std::string text;
-
-#ifndef CHATTEST
- /* get sender ID and prepend it to the message */
- if (senderID != NETWORK_PEER_ID_UNKNOWN)
- {
- /* if we can't find anything, use "unknown" as default */
- std::string name = "unknown";
-
- PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
- if (player)
- name = player->getName();
-
- text = name + ": " + message;
- }
- else
- text = message;
-#else
- text = message;
-#endif
-
- /* add the line to the history */
- this->chat_hist_addline( text );
-
- /* add the line to the log */
- this->chat_hist_logline( text );
- }
-
- /* Synchronize logfile onto the hard drive */ /* MARK MARK */
- int ChatHistory::syncLog()
- {
- //if( this->hist_logfile )
- //this->hist_logfile.sync();
- return 0;
- }
-
- /* add a line to this history */
- int ChatHistory::chat_hist_addline( const std::string& toadd )
- {
- /* crop history at the end if it's too large */
- while( this->hist_buffer.size() > this->hist_maxlines+1 )
- this->hist_buffer.pop_front();
-
- /* push to the front of the history */
- this->hist_buffer.push_back( toadd );
- return 0;
- }
-
- /* log a line to a logfile */
- int ChatHistory::chat_hist_logline( const std::string& toadd )
- {
- /* output the line to the file if logging is enabled */
- if( this->hist_log_enabled )
- this->hist_logfile << toadd << std::endl;
- return 0;
- }
-
- /* open logfile */
- int ChatHistory::chat_hist_openlog()
- {
- /* TODO: find out the name of the file to log to via settings
- * and set the this->hist_logfile_path variable to it
- */
-#ifndef CHATTEST
- this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
- "chatlog.log").c_str(),
- std::fstream::out | std::fstream::app );
-#else
- this->hist_logfile.open( "/tmp/chatlog.log",
- std::fstream::out | std::fstream::app );
-#endif
-
- /* TODO check whether this works (not sure how you'd like it?) */
- if( !this->hist_logfile )
- { this->hist_log_enabled = false;
-#ifndef CHATTEST
- COUT(2) << "Warning: Could not open logfile." << std::endl;
-#endif
- }
-
- /* if it worked */
- return 0;
- }
-
- /* close logfile */
- void ChatHistory::chat_hist_closelog()
- {
- /* see if we've actually got a logfile */
- if( this->hist_logfile )
- {
- /* yes, we've got one, add a line that shows we're closing it */
- this->chat_hist_logline( "--- Logfile closed ---" );
-
- /* actually close down the file */
- this->hist_logfile.close();
- }
- }
-
- /* output history for debugging */
- void ChatHistory::debug_printhist()
- {
- /* create deque iterator */
- std::deque<std::string>::iterator it;
-
- /* output all the strings */
- for( it = this->hist_buffer.begin(); it != this->hist_buffer.end();
- ++it )
- std::cout << *it << std::endl;
-
- /* output size */
- std::cout << "Size: " << hist_buffer.size() << std::endl;
- }
-
-#ifndef CHATTEST
-}
-#endif
Deleted: code/trunk/src/orxonox/ChatHistory.h
===================================================================
--- code/trunk/src/orxonox/ChatHistory.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/ChatHistory.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,149 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#include <deque>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <cassert>
-
-/* define this if you're unit testing */
-//#define CHATTEST
-
-#ifndef CHATTEST
-#include <OrxonoxPrereqs.h>
-#include <PlayerManager.h>
-#include <infos/PlayerInfo.h>
-#include <core/BaseObject.h>
-#include <network/ChatListener.h>
-#include <core/PathConfig.h>
-#include <util/Singleton.h>
-#endif
-
-#ifndef _ChatHistory_H__
-#define _ChatHistory_H__
-
-
-/* Class to implement chat history */
-#ifndef CHATTEST
-namespace orxonox
-{
-#endif
-
- /* constructor */
-#ifndef CHATTEST
- class _OrxonoxExport ChatHistory : public ChatListener,
- public Singleton<ChatHistory>
-
-#else
- class ChatHistory
-#endif
- {
- public:
- /* constructors, destructors */
-#ifndef CHATTEST
- ChatHistory();
- friend class Singleton<ChatHistory>;
-#else
- ChatHistory();
-#endif
- virtual ~ChatHistory();
-
-
- //protected:
- /** what to do with incoming chat
- *
- * \param message The incoming message
- * \param senderID Identification number of the sender
- */
- virtual void incomingChat(const std::string& message,
- unsigned int senderID);
-
- /** Synchronize logfile onto the hard drive
- *
- * \return 0 for success, other for error
- */
- int syncLog();
-
- /** debug-print: output the whole history to stdout */
- void debug_printhist();
-
- private:
- /* FIELDS */
- /** Vector to store the history in */
- std::deque<std::string> hist_buffer;
-
- /** Maximum number of lines stored in this history */
- unsigned int hist_maxlines;
-
- /** is logging enabled? */
- bool hist_log_enabled;
-
- /** path of logfile on the file system */
- std::string hist_logfile_path;
-
- /** Output file stream for logfile */
- std::ofstream hist_logfile;
-
-#ifndef CHATTEST
- static ChatHistory* singletonPtr_s;
-#endif
-
-
-
- /* METHODS */
- /** Append line to chat history
- *
- * \param toadd The line to add to the history
- * \return 0 for success, other for error TODO: Throw exception
- */
- int chat_hist_addline( const std::string& toadd );
-
- /** Append line to logfile
- *
- * \param toadd The line to add to the logfile
- * \return 0 for success, other for error TODO: Throw exception
- */
- int chat_hist_logline( const std::string& toadd );
-
- /** open logfile to log to
- *
- * \return 0 for success,s other for error
- */
- int chat_hist_openlog();
-
-
- /** close logfile */
- void chat_hist_closelog();
- };
-
-#ifndef CHATTEST
-}
-#endif
-
-#endif /* _ChatHistory_H__ */
Deleted: code/trunk/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/trunk/src/orxonox/ChatInputHandler.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/ChatInputHandler.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,356 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#include "ChatInputHandler.h"
-
-#include <cassert>
-#include <string>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUIListbox.h>
-#include <elements/CEGUIListboxItem.h>
-#include <elements/CEGUIListboxTextItem.h>
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
-#include "core/input/InputBuffer.h"
-#include "core/input/InputManager.h"
-#include "core/input/InputState.h"
-#include "network/Host.h"
-
-#include "PlayerManager.h"
-#include "infos/PlayerInfo.h"
-
-namespace orxonox
-{
- /* singleton */
- ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
-
- /* add commands to console */
- SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
- SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
-
- /* constructor */
- ChatInputHandler::ChatInputHandler()
- {
- /* register the object */
- RegisterObject(ChatInputHandler);
-
- /* create necessary objects */
- this->inpbuf = new InputBuffer();
- this->disp_offset = 0;
- assert( this->inpbuf != NULL );
-
- /* generate chatbox ui and chatbox-inputonly ui */
- GUIManager::getInstance().loadGUI( "ChatBox" );
- GUIManager::getInstance().loadGUI( "ChatBox-inputonly" );
-
- /* setup colors */
- setupColors();
-
- /* configure the input buffer */
- configureInputBuffer();
-
- this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
- this->inputState->setKeyHandler(this->inpbuf);
- }
-
- ChatInputHandler::~ChatInputHandler()
- {
- /* Clean up */
- InputManager::getInstance().destroyState("chatinput");
- delete this->inpbuf;
- }
-
- /* configure input buffer, sub for the constructor */
- void ChatInputHandler::configureInputBuffer()
- {
- /* INSTALL CALLBACKS */
- /* input has changed */
- this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
-
- /* add a line */
- this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\r', false);
- this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\n', false);
-
- /* backspace */
- this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\b', true);
- //this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\177', true);
-
- /* exit the chatinputhandler thingy (tbd) */
- this->inpbuf->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape
-
- /* delete character */
- this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete);
-
- /* cursor movement */
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight, KeyCode::Right);
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft, KeyCode::Left);
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd, KeyCode::End);
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home);
-
- /* GET WINDOW POINTERS */
- input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
- inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
-
- /* get pointer to the history window */
- CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
-
- /* cast it to a listbox */
- lb_history = dynamic_cast<CEGUI::Listbox*>(history);
-
- /* assert wee */
- assert( lb_history );
- }
-
- /* setup the colors, sub for the constructor */
- void ChatInputHandler::setupColors()
- {
- /* auto variables */
- float red = 1.0, green = 0.5, blue = 0.5;
- int i = 0;
-
- // three loops: red tones, blue tones and green tones
- // reds
- for( i = 0; i < NumberOfColors/3; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
- green += 0.2f, blue += 0.2f;
- }
-
- // greens
- red = 0.5, green = 1, blue = 0.5;
- for( ; i < NumberOfColors*2/3; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
- red += 0.2f, blue += 0.2f;
- }
-
- // blues
- red = 0.5, green = 0.5, blue = 1;
- for( ; i < NumberOfColors; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
- red += 0.2f, green += 0.2f;
- }
- }
-
-
- /* activate, deactivate */
- void ChatInputHandler::activate_static()
- { ChatInputHandler::getInstance().activate( true ); }
-
- void ChatInputHandler::activate_small_static()
- { ChatInputHandler::getInstance().activate( false ); }
-
- void ChatInputHandler::activate( bool full )
- {
- /* start listening */
- InputManager::getInstance().enterState("chatinput");
-
- /* MARK add spawning of chat widget stuff here.*/
- if( full )
- GUIManager::getInstance().showGUI( "ChatBox" );
- else
- GUIManager::getInstance().showGUI( "ChatBox-inputonly" );
-
- this->fullchat = full;
- }
-
- void ChatInputHandler::deactivate()
- {
- /* stop listening */
- InputManager::getInstance().leaveState("chatinput");
-
- /* un-spawning of chat widget stuff */
- GUIManager::getInstance().hideGUI( "ChatBox" );
- GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
- }
-
-
- /* subs for incomingChat */
- void ChatInputHandler::sub_setcolor( CEGUI::ListboxTextItem *tocolor,
- std::string name )
- {
- /* sanity checks */
- if( !tocolor )
- COUT(2) << "Empty ListBoxTextItem given to "
- "ChatInputhandler::sub_setcolor().\n";
-
- /* "hash" the name */
- int hash = 0;
- for( int i = name.length(); i > 0; --i )
- hash += name[i-1];
- hash = hash % this->NumberOfColors;
-
- /* set the color according to the hash */
- tocolor->setTextColours( this->text_colors[ hash ] );
- }
-
- /* handle incoming chat */
- void ChatInputHandler::incomingChat(const std::string& message,
- unsigned int senderID)
- {
- /* look up the actual name of the sender */
- std::string text, name = "unknown";
-
- /* setup player name info */
- if (senderID != NETWORK_PEER_ID_UNKNOWN)
- {
- PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
- if (player)
- name = player->getName();
- }
-
- /* assemble the text */
- text = name + ": " + message;
-
- /* create item */
- CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text );
-
- /* setup colors */
- sub_setcolor( toadd, name );
-
- /* now add */
- this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
- this->lb_history->ensureItemIsVisible(
- dynamic_cast<CEGUI::ListboxItem*>(toadd) );
-
- /* make sure the history handles it */
- this->lb_history->handleUpdatedItemData();
- }
-
-
- /* sub for inputchanged */
- void ChatInputHandler::sub_adjust_dispoffset( int maxlen,
- int cursorpos,
- int inplen )
- {
- /* already start offsetting 5 characters before end */
- if( cursorpos+5 > maxlen )
- {
- /* always stay 5 characters ahead of end, looks better */
- ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0;
-
- /* enforce visibility of cursor */
- (disp_offset > cursorpos ) ? disp_offset = 0 : 1;
- }
-
- /* make sure we don't die at substr */
- if( inplen <= disp_offset ) disp_offset = 0;
- }
-
- /* callbacks for InputBuffer */
- void ChatInputHandler::inputChanged()
- {
- /* update the cursor and the window */
- std::string raw = this->inpbuf->get();
- int cursorpos = this->inpbuf->getCursorPosition();
-
- /* get string before cursor */
- std::string left = raw.substr( 0, cursorpos );
-
- /* see if there's a string after the cursor */
- std::string right = "";
- if( raw.length() >= left.length()+1 )
- right = raw.substr( cursorpos );
-
- /* set the text */
- std::string assembled = "$ " + left + "|" + right;
-
- if( this->fullchat )
- {
- /* adjust curser position - magic number 5 for font width */
- sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
- cursorpos, assembled.length() );
- this->input->setProperty( "Text", assembled.substr( disp_offset ) );
- }
- else
- {
- /* adjust curser position - magic number 5 for font width */
- sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
- cursorpos, assembled.length() );
- this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
- }
-
- /* reset display offset */
- disp_offset = 0;
- }
-
- void ChatInputHandler::addline()
- {
- /* actually do send what was input */
- /* a) get the string out of the inputbuffer */
- std::string msgtosend = this->inpbuf->get();
-
- if( msgtosend.length() == 0 )
- { this->deactivate();
- return;
- }
-
- /* b) clear the input buffer */
- if (this->inpbuf->getSize() > 0)
- this->inpbuf->clear();
-
- /* c) send the chat via some call */
- Host::Chat( msgtosend );
-
- /* d) stop listening to input - only if this is not fullchat */
- if( !this->fullchat )
- this->deactivate();
-
- }
-
- void ChatInputHandler::backspace()
- { this->inpbuf->removeBehindCursor(); }
-
- void ChatInputHandler::deleteChar()
- { this->inpbuf->removeAtCursor(); }
-
- void ChatInputHandler::cursorRight()
- { this->inpbuf->increaseCursor(); }
-
- void ChatInputHandler::cursorLeft()
- { this->inpbuf->decreaseCursor(); }
-
- void ChatInputHandler::cursorEnd()
- { this->inpbuf->setCursorToEnd(); }
-
- void ChatInputHandler::cursorHome()
- { this->inpbuf->setCursorToBegin(); }
-
- void ChatInputHandler::exit()
- {
- /* b) clear the input buffer */
- if (this->inpbuf->getSize() > 0)
- this->inpbuf->clear();
-
- /* d) stop listening to input */
- this->deactivate();
- }
-
-}
Deleted: code/trunk/src/orxonox/ChatInputHandler.h
===================================================================
--- code/trunk/src/orxonox/ChatInputHandler.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/ChatInputHandler.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,134 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _ChatInputHandler_H__
-#define _ChatInputHandler_H__
-
-#include <OrxonoxPrereqs.h>
-
-#include <string>
-#include <CEGUIForwardRefs.h>
-#include <CEGUIcolour.h>
-
-#include "util/Singleton.h"
-#include "network/ChatListener.h"
-
-namespace orxonox // tolua_export
-{ // tolua_export
- /* class to handle chat using an InputBuffer */
- class _OrxonoxExport ChatInputHandler // tolua_export
- : public Singleton<ChatInputHandler>, public ChatListener
- { // tolua_export
- private:
- /** Input buffer, to be used to catch input from the
- * keyboard
- */
- InputBuffer *inpbuf;
- int disp_offset, width;
- bool fullchat;
-
- /* colors for nickname coloring */
- static const int NumberOfColors = 10;
- CEGUI::colour text_colors[ NumberOfColors ];
-
- /** input state */
- InputState *inputState;
-
- /** setup input buffer, the constructor calls this */
- void configureInputBuffer();
-
- /** adjust display offset depending on cursor position */
- void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
-
- /** singleton pointer */
- static ChatInputHandler* singletonPtr_s;
-
- /** cegui window handles */
- CEGUI::Window *input, *inputonly;
-
- /** cegui handle for the history window */
- CEGUI::Listbox *lb_history;
-
- /* methods to deal with colors */
- void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
- std::string name );
-
- void setupColors();
-
- /* callbacks for input handler */
- void inputChanged();
- void addline();
- void backspace();
- void deleteChar();
- void cursorRight();
- void cursorLeft();
- void cursorEnd();
- void cursorHome();
- void exit();
-
- public:
- /** constructor */
- ChatInputHandler();
- ~ChatInputHandler();
- friend class Singleton<ChatInputHandler>;
-
- static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); } // tolua_export
-
- /** start listening */
- static void activate_static();
-
- /** stop listening */
- static void activate_small_static();
-
- /** \param message the message text
- * \param senderID ID of the player who sent the message
- *
- * Deal with incoming chat (which means in our case: Add it to the
- * history window of the full chat window)
- */
- void incomingChat( const std::string& message,
- unsigned int senderID );
-
- /** \param full true means show full chat window with history,
- false means show only an input line
- *
- * Show the chat window and redirect the game's keyboard input
- * into it.
- */
- void activate( bool full );
-
- /** Deactivate the chat window, meaning: hide it. */
- void deactivate(); // tolua_export
-
- }; // tolua_export
-
-
-} // tolua_export
-
-
-#endif /*_ChatInputHandler_H__*/
Modified: code/trunk/src/orxonox/Level.cc
===================================================================
--- code/trunk/src/orxonox/Level.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/Level.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -87,7 +87,7 @@
void Level::networkcallback_applyXMLFile()
{
- COUT(0) << "Loading level \"" << this->xmlfilename_ << "\"..." << std::endl;
+ orxout(user_status) << "Loading level \"" << this->xmlfilename_ << "\"..." << endl;
ClassTreeMask mask;
mask.exclude(Class(BaseObject));
@@ -114,7 +114,7 @@
if (!identifier || !identifier->isA(Class(Gametype)))
{
- COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
+ orxout(internal_error) << "\"" << gametype << "\" is not a valid gametype." << endl;
identifier = Class(Gametype);
this->gametype_ = "Gametype";
}
@@ -156,7 +156,7 @@
std::string meshName = lodInformation->getMeshName();
// this->lodInformation_.insert(std::make_pair(meshName,lodInformation));
if( this->lodInformation_.find(meshName) != this->lodInformation_.end())
- CCOUT(4) << "replacing lod information for " << meshName << endl;
+ orxout(verbose, context::lod) << "replacing lod information for " << meshName << endl;
this->lodInformation_[meshName] = lodInformation;
}
@@ -170,13 +170,13 @@
void Level::playerEntered(PlayerInfo* player)
{
- COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
+ orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
player->setGametype(this->getGametype());
}
void Level::playerLeft(PlayerInfo* player)
{
- COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
+ orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
player->setGametype(0);
}
}
Modified: code/trunk/src/orxonox/LevelInfo.cc
===================================================================
--- code/trunk/src/orxonox/LevelInfo.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/LevelInfo.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -124,7 +124,7 @@
{
if(!this->validateTag(tag))
{
- COUT(2) << "Bad LevelInfo tag '" << tag << "' in " << this->getXMLFilename() << ". Ignoring..." << std::endl;
+ orxout(internal_warning) << "Bad LevelInfo tag '" << tag << "' in " << this->getXMLFilename() << ". Ignoring..." << endl;
return false;
}
bool success = this->tags_.insert(*LevelInfoItem::possibleTags_s.find(tag)).second;
Modified: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/LevelManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -250,7 +250,7 @@
mask.include(Class(LevelInfo));
// Iterate over all the found *.oxw files
- COUT(3) << "Loading LevelInfos..." << std::endl;
+ orxout(internal_info) << "Loading LevelInfos..." << endl;
std::set<std::string> names;
for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
{
@@ -280,12 +280,12 @@
// Warn about levels with the same name.
if(!names.insert(info->getName()).second)
- COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << std::endl;
+ orxout(internal_warning) << "Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << endl;
// Warn about multiple items so that it gets fixed quickly
if(availableLevels_.find(info) != availableLevels_.end())
{
- COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl;
+ orxout(internal_warning) << "Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << endl;
// Delete LevelInfoItem to avoid a dangling pointer
delete info;
}
Modified: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/Main.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -60,10 +60,17 @@
*/
int main(const std::string& strCmdLine)
{
+ orxout(internal_status) << "entering orxonox::main()" << endl;
+ orxout(internal_info) << "command line: " << strCmdLine << endl;
+
+ orxout(internal_info) << "creating Game object:" << endl;
Game* game = new Game(strCmdLine);
+ orxout(user_status) << "Finished initialization" << endl;
if (CommandLineParser::getValue("generateDoc").getString().empty())
{
+ orxout(internal_info) << "preparing game states" << endl;
+
/* TODO make this clear */
game->setStateHierarchy(
"root"
@@ -97,6 +104,7 @@
Game::getInstance().requestStates("graphics, mainMenu");
}
+ orxout(internal_info) << "starting game" << endl;
game->run();
}
Modified: code/trunk/src/orxonox/MoodManager.cc
===================================================================
--- code/trunk/src/orxonox/MoodManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/MoodManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -53,7 +53,7 @@
if (!Resource::exists(path))
{
// TODO: Non-fatal error handling (non-critical resource missing)
- COUT(2) << "Mood Warning: Folder for default mood (" << MoodManager::defaultMood_ << ") does not exist!" << std::endl;
+ orxout(internal_warning) << "Mood Warning: Folder for default mood (" << MoodManager::defaultMood_ << ") does not exist!" << endl;
}
// @TODO
@@ -81,12 +81,12 @@
const std::string& path = "ambient/" + mood_ + "/.";
if (!Resource::exists(path))
{
- COUT(3) << "Mood " << mood_ << " does not exist. Will not change." << std::endl;
+ orxout(internal_warning) << "Mood " << mood_ << " does not exist. Will not change." << endl;
this->setMood(oldMood_);
}
else
{
- COUT(3) << "Mood changed to " << mood_ << std::endl;
+ orxout(internal_info) << "Mood changed to " << mood_ << endl;
MoodListener::changedMood(mood_);
}
}
Modified: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -77,6 +77,12 @@
class Radar;
class Scene;
+ // chat
+ class ChatHistory;
+ class ChatInputHandler;
+ class ChatListener;
+ class ChatManager;
+
// collisionshapes
class CollisionShape;
class CompoundCollisionShape;
Modified: code/trunk/src/orxonox/PlayerManager.cc
===================================================================
--- code/trunk/src/orxonox/PlayerManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/PlayerManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -56,7 +56,7 @@
if (GameMode::isMaster())
{
if (clientID != 0)
- COUT(3) << "client connected" << std::endl;
+ orxout(internal_info) << "client connected" << endl;
// create new HumanPlayer instance
HumanPlayer* player = new HumanPlayer(0);
@@ -76,7 +76,7 @@
if (GameMode::isMaster())
{
if (clientID != 0)
- COUT(3) << "client disconnected" << std::endl;
+ orxout(internal_info) << "client disconnected" << endl;
// remove from clients-map
PlayerInfo* player = this->clients_[clientID];
Modified: code/trunk/src/orxonox/Radar.cc
===================================================================
--- code/trunk/src/orxonox/Radar.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/Radar.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -194,12 +194,12 @@
void Radar::listObjects() const
{
- COUT(3) << "List of RadarObjects:\n";
+ orxout(debug_output) << "List of RadarObjects:" << endl;
// iterate through all Radar Objects
unsigned int i = 0;
for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
{
- COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
+ orxout(debug_output) << i++ << ": " << (*it)->getRVWorldPosition() << endl;
}
}
Modified: code/trunk/src/orxonox/Scene.cc
===================================================================
--- code/trunk/src/orxonox/Scene.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/Scene.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -140,13 +140,13 @@
{
if (range.length() < 10.0f)
{
- CCOUT(2) << "Warning: Setting the negative world range to a very small value: "
- << multi_cast<std::string>(range) << std::endl;
+ orxout(internal_warning) << "Setting the negative world range to a very small value: "
+ << multi_cast<std::string>(range) << endl;
}
if (this->hasPhysics())
{
- CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
- << "This causes a complete physical reload which might take some time." << std::endl;
+ orxout(internal_warning) << "Attempting to set the physical world range at run time. "
+ << "This causes a complete physical reload which might take some time." << endl;
this->setPhysicalWorld(false);
this->negativeWorldRange_ = range;
this->setPhysicalWorld(true);
@@ -159,13 +159,13 @@
{
if (range.length() < 10.0f)
{
- CCOUT(2) << "Warning: Setting the positive world range to a very small value: "
- << multi_cast<std::string>(range) << std::endl;
+ orxout(internal_warning) << "Setting the positive world range to a very small value: "
+ << multi_cast<std::string>(range) << endl;
}
if (this->hasPhysics())
{
- CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
- << "This causes a complete physical reload which might take some time." << std::endl;
+ orxout(internal_warning) << "Attempting to set the physical world range at run time. "
+ << "This causes a complete physical reload which might take some time." << endl;
this->setPhysicalWorld(false);
this->positiveWorldRange_ = range;
this->setPhysicalWorld(true);
Modified: code/trunk/src/orxonox/Test.cc
===================================================================
--- code/trunk/src/orxonox/Test.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/Test.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -126,7 +126,7 @@
// temp = mem;
// mt2.importData( temp );
// assert( temp-mem == mt1.getNetworkSize() );
- // COUT(0) << mt2 << endl;
+ // orxout() << mt2 << endl;
// if(!Core::isMaster())
// call2(0, "bal", "a", "n", "ce");
// callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
@@ -134,19 +134,19 @@
void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
{
- COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
+ orxout() << s1 << s2 << s3 << s4 << s5 << endl;
}
- void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
- void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
- void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
- void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
+ void Test::checkU1(){ orxout() << "U1 changed: " << u1 << endl; }
+ void Test::checkU2(){ orxout() << "U2 changed: " << u2 << endl; }
+ void Test::checkU3(){ orxout() << "U3 changed: " << u3 << endl; }
+ void Test::checkU4(){ orxout() << "U4 changed: " << u4 << endl; }
- void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
- void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
- void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
- void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
+ void Test::checkS1(){ orxout() << "S1 changed: " << s1 << endl; }
+ void Test::checkS2(){ orxout() << "S2 changed: " << s2 << endl; }
+ void Test::checkS3(){ orxout() << "S3 changed: " << s3 << endl; }
+ void Test::checkS4(){ orxout() << "S4 changed: " << s4 << endl; }
- void Test::printPointer(){ CCOUT(1) << "pointer: " << this->pointer_ << endl; }
+ void Test::printPointer(){ orxout() << "pointer: " << this->pointer_ << endl; }
}
Modified: code/trunk/src/orxonox/Test.h
===================================================================
--- code/trunk/src/orxonox/Test.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/Test.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -107,7 +107,7 @@
{ mySet_.insert(2); }
void blub2()
- { for( std::set<uint32_t>::iterator it=mySet_.begin(); it!=mySet_.end(); ++it ) COUT(0) << *it << endl; }
+ { for( std::set<uint32_t>::iterator it=mySet_.begin(); it!=mySet_.end(); ++it ) orxout() << *it << endl; }
};
}
Deleted: code/trunk/src/orxonox/chat/CMakeLists.txt
===================================================================
--- code/branches/output/src/orxonox/chat/CMakeLists.txt 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,5 +0,0 @@
-ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- ChatHistory.cc
- ChatInputHandler.cc
- ChatManager.cc
-)
Copied: code/trunk/src/orxonox/chat/CMakeLists.txt (from rev 8857, code/branches/output/src/orxonox/chat/CMakeLists.txt)
===================================================================
--- code/trunk/src/orxonox/chat/CMakeLists.txt (rev 0)
+++ code/trunk/src/orxonox/chat/CMakeLists.txt 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,5 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ ChatHistory.cc
+ ChatInputHandler.cc
+ ChatManager.cc
+)
Deleted: code/trunk/src/orxonox/chat/ChatHistory.cc
===================================================================
--- code/branches/output/src/orxonox/chat/ChatHistory.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatHistory.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,172 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#include "ChatHistory.h"
-#include "util/ScopedSingletonManager.h"
-
-#ifndef CHATTEST
-namespace orxonox
-{
- /* singleton */
- ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
-#endif
-
- /* constructor */
-#ifndef CHATTEST
- //ChatHistory::ChatHistory( BaseObject* creator ) : BaseObject(creator)
- ChatHistory::ChatHistory()
-#else
- ChatHistory::ChatHistory()
-#endif
- {
- /* register the object */
-#ifndef CHATTEST
- RegisterObject(ChatHistory);
-#endif
-
- this->hist_log_enabled = true;
-
- /* Read setting for logfiles */
- if( hist_log_enabled ) /* NOTE Make this a check for the logfile setting */
- { this->chat_hist_openlog();
-
- /* push starting line */
- this->chat_hist_logline( "--- Logfile opened ---" );
- }
-
- /* Read setting for maximum number of lines and set limit */
- this->hist_maxlines = 200; /* NOTE to be changed, 200 is just for testing */
- }
-
- /* destructor */
- ChatHistory::~ChatHistory()
- {
- chat_hist_closelog();
-
- /* clear list */
- this->hist_buffer.clear();
- }
-
- /* react to incoming chat */
- void ChatHistory::incomingChat(const std::string& message, const std::string& /*name*/)
- {
- /* add the line to the history */
- this->chat_hist_addline( message );
-
- /* add the line to the log */
- this->chat_hist_logline( message );
- }
-
- /* Synchronize logfile onto the hard drive */ /* MARK MARK */
- int ChatHistory::syncLog()
- {
- //if( this->hist_logfile )
- //this->hist_logfile.sync();
- return 0;
- }
-
- /* add a line to this history */
- int ChatHistory::chat_hist_addline( const std::string& toadd )
- {
- /* crop history at the end if it's too large */
- while( this->hist_buffer.size() > this->hist_maxlines+1 )
- this->hist_buffer.pop_front();
-
- /* push to the front of the history */
- this->hist_buffer.push_back( toadd );
- return 0;
- }
-
- /* log a line to a logfile */
- int ChatHistory::chat_hist_logline( const std::string& toadd )
- {
- /* output the line to the file if logging is enabled */
- if( this->hist_log_enabled )
- this->hist_logfile << toadd << endl;
- return 0;
- }
-
- /* open logfile */
- int ChatHistory::chat_hist_openlog()
- {
- /* TODO: find out the name of the file to log to via settings
- * and set the this->hist_logfile_path variable to it
- */
-#ifndef CHATTEST
- this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
- "chatlog.log").c_str(),
- std::fstream::out | std::fstream::app );
-#else
- this->hist_logfile.open( "/tmp/chatlog.log",
- std::fstream::out | std::fstream::app );
-#endif
-
- /* TODO check whether this works (not sure how you'd like it?) */
- if( !this->hist_logfile )
- { this->hist_log_enabled = false;
-#ifndef CHATTEST
- orxout(internal_warning) << "Could not open logfile." << endl;
-#endif
- }
-
- /* if it worked */
- return 0;
- }
-
- /* close logfile */
- void ChatHistory::chat_hist_closelog()
- {
- /* see if we've actually got a logfile */
- if( this->hist_logfile )
- {
- /* yes, we've got one, add a line that shows we're closing it */
- this->chat_hist_logline( "--- Logfile closed ---" );
-
- /* actually close down the file */
- this->hist_logfile.close();
- }
- }
-
- /* output history for debugging */
- void ChatHistory::debug_printhist()
- {
- /* create deque iterator */
- std::deque<std::string>::iterator it;
-
- /* output all the strings */
- for( it = this->hist_buffer.begin(); it != this->hist_buffer.end();
- ++it )
- orxout(debug_output) << *it << endl;
-
- /* output size */
- orxout(debug_output) << "Size: " << hist_buffer.size() << endl;
- }
-
-#ifndef CHATTEST
-}
-#endif
Copied: code/trunk/src/orxonox/chat/ChatHistory.cc (from rev 8857, code/branches/output/src/orxonox/chat/ChatHistory.cc)
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.cc (rev 0)
+++ code/trunk/src/orxonox/chat/ChatHistory.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,172 @@
+/*
+ * 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:
+ * Sandro 'smerkli' Merkli
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "ChatHistory.h"
+#include "util/ScopedSingletonManager.h"
+
+#ifndef CHATTEST
+namespace orxonox
+{
+ /* singleton */
+ ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
+#endif
+
+ /* constructor */
+#ifndef CHATTEST
+ //ChatHistory::ChatHistory( BaseObject* creator ) : BaseObject(creator)
+ ChatHistory::ChatHistory()
+#else
+ ChatHistory::ChatHistory()
+#endif
+ {
+ /* register the object */
+#ifndef CHATTEST
+ RegisterObject(ChatHistory);
+#endif
+
+ this->hist_log_enabled = true;
+
+ /* Read setting for logfiles */
+ if( hist_log_enabled ) /* NOTE Make this a check for the logfile setting */
+ { this->chat_hist_openlog();
+
+ /* push starting line */
+ this->chat_hist_logline( "--- Logfile opened ---" );
+ }
+
+ /* Read setting for maximum number of lines and set limit */
+ this->hist_maxlines = 200; /* NOTE to be changed, 200 is just for testing */
+ }
+
+ /* destructor */
+ ChatHistory::~ChatHistory()
+ {
+ chat_hist_closelog();
+
+ /* clear list */
+ this->hist_buffer.clear();
+ }
+
+ /* react to incoming chat */
+ void ChatHistory::incomingChat(const std::string& message, const std::string& /*name*/)
+ {
+ /* add the line to the history */
+ this->chat_hist_addline( message );
+
+ /* add the line to the log */
+ this->chat_hist_logline( message );
+ }
+
+ /* Synchronize logfile onto the hard drive */ /* MARK MARK */
+ int ChatHistory::syncLog()
+ {
+ //if( this->hist_logfile )
+ //this->hist_logfile.sync();
+ return 0;
+ }
+
+ /* add a line to this history */
+ int ChatHistory::chat_hist_addline( const std::string& toadd )
+ {
+ /* crop history at the end if it's too large */
+ while( this->hist_buffer.size() > this->hist_maxlines+1 )
+ this->hist_buffer.pop_front();
+
+ /* push to the front of the history */
+ this->hist_buffer.push_back( toadd );
+ return 0;
+ }
+
+ /* log a line to a logfile */
+ int ChatHistory::chat_hist_logline( const std::string& toadd )
+ {
+ /* output the line to the file if logging is enabled */
+ if( this->hist_log_enabled )
+ this->hist_logfile << toadd << endl;
+ return 0;
+ }
+
+ /* open logfile */
+ int ChatHistory::chat_hist_openlog()
+ {
+ /* TODO: find out the name of the file to log to via settings
+ * and set the this->hist_logfile_path variable to it
+ */
+#ifndef CHATTEST
+ this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
+ "chatlog.log").c_str(),
+ std::fstream::out | std::fstream::app );
+#else
+ this->hist_logfile.open( "/tmp/chatlog.log",
+ std::fstream::out | std::fstream::app );
+#endif
+
+ /* TODO check whether this works (not sure how you'd like it?) */
+ if( !this->hist_logfile )
+ { this->hist_log_enabled = false;
+#ifndef CHATTEST
+ orxout(internal_warning) << "Could not open logfile." << endl;
+#endif
+ }
+
+ /* if it worked */
+ return 0;
+ }
+
+ /* close logfile */
+ void ChatHistory::chat_hist_closelog()
+ {
+ /* see if we've actually got a logfile */
+ if( this->hist_logfile )
+ {
+ /* yes, we've got one, add a line that shows we're closing it */
+ this->chat_hist_logline( "--- Logfile closed ---" );
+
+ /* actually close down the file */
+ this->hist_logfile.close();
+ }
+ }
+
+ /* output history for debugging */
+ void ChatHistory::debug_printhist()
+ {
+ /* create deque iterator */
+ std::deque<std::string>::iterator it;
+
+ /* output all the strings */
+ for( it = this->hist_buffer.begin(); it != this->hist_buffer.end();
+ ++it )
+ orxout(debug_output) << *it << endl;
+
+ /* output size */
+ orxout(debug_output) << "Size: " << hist_buffer.size() << endl;
+ }
+
+#ifndef CHATTEST
+}
+#endif
Deleted: code/trunk/src/orxonox/chat/ChatHistory.h
===================================================================
--- code/branches/output/src/orxonox/chat/ChatHistory.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatHistory.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,149 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#include <deque>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <cassert>
-
-/* define this if you're unit testing */
-//#define CHATTEST
-
-#ifndef CHATTEST
-#include "OrxonoxPrereqs.h"
-
-#include "util/Singleton.h"
-#include "core/BaseObject.h"
-#include "core/PathConfig.h"
-#include "chat/ChatListener.h"
-#include "infos/PlayerInfo.h"
-#include "PlayerManager.h"
-#endif
-
-#ifndef _ChatHistory_H__
-#define _ChatHistory_H__
-
-
-/* Class to implement chat history */
-#ifndef CHATTEST
-namespace orxonox
-{
-#endif
-
- /* constructor */
-#ifndef CHATTEST
- class _OrxonoxExport ChatHistory : public ChatListener,
- public Singleton<ChatHistory>
-
-#else
- class ChatHistory
-#endif
- {
- public:
- /* constructors, destructors */
-#ifndef CHATTEST
- ChatHistory();
- friend class Singleton<ChatHistory>;
-#else
- ChatHistory();
-#endif
- virtual ~ChatHistory();
-
-
- //protected:
- /** what to do with incoming chat
- *
- * \param message The incoming message
- * \param senderID Identification number of the sender
- */
- virtual void incomingChat(const std::string& message, const std::string& name);
-
- /** Synchronize logfile onto the hard drive
- *
- * \return 0 for success, other for error
- */
- int syncLog();
-
- /** debug-print: output the whole history to stdout */
- void debug_printhist();
-
- private:
- /* FIELDS */
- /** Vector to store the history in */
- std::deque<std::string> hist_buffer;
-
- /** Maximum number of lines stored in this history */
- unsigned int hist_maxlines;
-
- /** is logging enabled? */
- bool hist_log_enabled;
-
- /** path of logfile on the file system */
- std::string hist_logfile_path;
-
- /** Output file stream for logfile */
- std::ofstream hist_logfile;
-
-#ifndef CHATTEST
- static ChatHistory* singletonPtr_s;
-#endif
-
-
-
- /* METHODS */
- /** Append line to chat history
- *
- * \param toadd The line to add to the history
- * \return 0 for success, other for error TODO: Throw exception
- */
- int chat_hist_addline( const std::string& toadd );
-
- /** Append line to logfile
- *
- * \param toadd The line to add to the logfile
- * \return 0 for success, other for error TODO: Throw exception
- */
- int chat_hist_logline( const std::string& toadd );
-
- /** open logfile to log to
- *
- * \return 0 for success,s other for error
- */
- int chat_hist_openlog();
-
-
- /** close logfile */
- void chat_hist_closelog();
- };
-
-#ifndef CHATTEST
-}
-#endif
-
-#endif /* _ChatHistory_H__ */
Copied: code/trunk/src/orxonox/chat/ChatHistory.h (from rev 8857, code/branches/output/src/orxonox/chat/ChatHistory.h)
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.h (rev 0)
+++ code/trunk/src/orxonox/chat/ChatHistory.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,149 @@
+/*
+ * 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:
+ * Sandro 'smerkli' Merkli
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include <deque>
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+/* define this if you're unit testing */
+//#define CHATTEST
+
+#ifndef CHATTEST
+#include "OrxonoxPrereqs.h"
+
+#include "util/Singleton.h"
+#include "core/BaseObject.h"
+#include "core/PathConfig.h"
+#include "chat/ChatListener.h"
+#include "infos/PlayerInfo.h"
+#include "PlayerManager.h"
+#endif
+
+#ifndef _ChatHistory_H__
+#define _ChatHistory_H__
+
+
+/* Class to implement chat history */
+#ifndef CHATTEST
+namespace orxonox
+{
+#endif
+
+ /* constructor */
+#ifndef CHATTEST
+ class _OrxonoxExport ChatHistory : public ChatListener,
+ public Singleton<ChatHistory>
+
+#else
+ class ChatHistory
+#endif
+ {
+ public:
+ /* constructors, destructors */
+#ifndef CHATTEST
+ ChatHistory();
+ friend class Singleton<ChatHistory>;
+#else
+ ChatHistory();
+#endif
+ virtual ~ChatHistory();
+
+
+ //protected:
+ /** what to do with incoming chat
+ *
+ * \param message The incoming message
+ * \param senderID Identification number of the sender
+ */
+ virtual void incomingChat(const std::string& message, const std::string& name);
+
+ /** Synchronize logfile onto the hard drive
+ *
+ * \return 0 for success, other for error
+ */
+ int syncLog();
+
+ /** debug-print: output the whole history to stdout */
+ void debug_printhist();
+
+ private:
+ /* FIELDS */
+ /** Vector to store the history in */
+ std::deque<std::string> hist_buffer;
+
+ /** Maximum number of lines stored in this history */
+ unsigned int hist_maxlines;
+
+ /** is logging enabled? */
+ bool hist_log_enabled;
+
+ /** path of logfile on the file system */
+ std::string hist_logfile_path;
+
+ /** Output file stream for logfile */
+ std::ofstream hist_logfile;
+
+#ifndef CHATTEST
+ static ChatHistory* singletonPtr_s;
+#endif
+
+
+
+ /* METHODS */
+ /** Append line to chat history
+ *
+ * \param toadd The line to add to the history
+ * \return 0 for success, other for error TODO: Throw exception
+ */
+ int chat_hist_addline( const std::string& toadd );
+
+ /** Append line to logfile
+ *
+ * \param toadd The line to add to the logfile
+ * \return 0 for success, other for error TODO: Throw exception
+ */
+ int chat_hist_logline( const std::string& toadd );
+
+ /** open logfile to log to
+ *
+ * \return 0 for success,s other for error
+ */
+ int chat_hist_openlog();
+
+
+ /** close logfile */
+ void chat_hist_closelog();
+ };
+
+#ifndef CHATTEST
+}
+#endif
+
+#endif /* _ChatHistory_H__ */
Deleted: code/trunk/src/orxonox/chat/ChatInputHandler.cc
===================================================================
--- code/branches/output/src/orxonox/chat/ChatInputHandler.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,342 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#include "ChatInputHandler.h"
-
-#include <cassert>
-#include <string>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUIListbox.h>
-#include <elements/CEGUIListboxItem.h>
-#include <elements/CEGUIListboxTextItem.h>
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
-#include "core/input/InputBuffer.h"
-#include "core/input/InputManager.h"
-#include "core/input/InputState.h"
-
-#include "chat/ChatManager.h"
-#include "PlayerManager.h"
-#include "infos/PlayerInfo.h"
-
-namespace orxonox
-{
- /* singleton */
- ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
-
- /* add commands to console */
- SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
- SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
-
- /* constructor */
- ChatInputHandler::ChatInputHandler()
- {
- /* register the object */
- RegisterObject(ChatInputHandler);
-
- /* create necessary objects */
- this->inpbuf = new InputBuffer();
- this->disp_offset = 0;
- assert( this->inpbuf != NULL );
-
- /* generate chatbox ui and chatbox-inputonly ui */
- GUIManager::getInstance().loadGUI( "ChatBox" );
- GUIManager::getInstance().loadGUI( "ChatBox-inputonly" );
-
- /* setup colors */
- setupColors();
-
- /* configure the input buffer */
- configureInputBuffer();
-
- this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
- this->inputState->setKeyHandler(this->inpbuf);
- }
-
- ChatInputHandler::~ChatInputHandler()
- {
- /* Clean up */
- InputManager::getInstance().destroyState("chatinput");
- delete this->inpbuf;
- }
-
- /* configure input buffer, sub for the constructor */
- void ChatInputHandler::configureInputBuffer()
- {
- /* INSTALL CALLBACKS */
- /* input has changed */
- this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
-
- /* add a line */
- this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\r', false);
- this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\n', false);
-
- /* backspace */
- this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\b', true);
- //this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\177', true);
-
- /* exit the chatinputhandler thingy (tbd) */
- this->inpbuf->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape
-
- /* delete character */
- this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete);
-
- /* cursor movement */
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight, KeyCode::Right);
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft, KeyCode::Left);
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd, KeyCode::End);
- this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home);
-
- /* GET WINDOW POINTERS */
- input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
- inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
-
- /* get pointer to the history window */
- CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
-
- /* cast it to a listbox */
- lb_history = dynamic_cast<CEGUI::Listbox*>(history);
-
- /* assert wee */
- assert( lb_history );
- }
-
- /* setup the colors, sub for the constructor */
- void ChatInputHandler::setupColors()
- {
- /* auto variables */
- float red = 1.0, green = 0.5, blue = 0.5;
- int i = 0;
-
- // three loops: red tones, blue tones and green tones
- // reds
- for( i = 0; i < NumberOfColors/3; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
- green += 0.2f, blue += 0.2f;
- }
-
- // greens
- red = 0.5, green = 1, blue = 0.5;
- for( ; i < NumberOfColors*2/3; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
- red += 0.2f, blue += 0.2f;
- }
-
- // blues
- red = 0.5, green = 0.5, blue = 1;
- for( ; i < NumberOfColors; ++i )
- { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
- red += 0.2f, green += 0.2f;
- }
- }
-
-
- /* activate, deactivate */
- void ChatInputHandler::activate_static()
- { ChatInputHandler::getInstance().activate( true ); }
-
- void ChatInputHandler::activate_small_static()
- { ChatInputHandler::getInstance().activate( false ); }
-
- void ChatInputHandler::activate( bool full )
- {
- /* start listening */
- InputManager::getInstance().enterState("chatinput");
-
- /* MARK add spawning of chat widget stuff here.*/
- if( full )
- GUIManager::getInstance().showGUI( "ChatBox" );
- else
- GUIManager::getInstance().showGUI( "ChatBox-inputonly" );
-
- this->fullchat = full;
- }
-
- void ChatInputHandler::deactivate()
- {
- /* stop listening */
- InputManager::getInstance().leaveState("chatinput");
-
- /* un-spawning of chat widget stuff */
- GUIManager::getInstance().hideGUI( "ChatBox" );
- GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
- }
-
-
- /* subs for incomingChat */
- void ChatInputHandler::sub_setcolor( CEGUI::ListboxTextItem *tocolor,
- std::string name )
- {
- /* sanity checks */
- if( !tocolor )
- orxout(internal_warning) << "Empty ListBoxTextItem given to "
- "ChatInputhandler::sub_setcolor()." << endl;
-
- /* "hash" the name */
- int hash = 0;
- for( int i = name.length(); i > 0; --i )
- hash += name[i-1];
- hash = hash % this->NumberOfColors;
-
- /* set the color according to the hash */
- tocolor->setTextColours( this->text_colors[ hash ] );
- }
-
- /* handle incoming chat */
- void ChatInputHandler::incomingChat(const std::string& message, const std::string& name)
- {
- /* create item */
- CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( message );
-
- /* setup colors */
- if (name != "")
- sub_setcolor( toadd, name );
-
- /* now add */
- this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
- this->lb_history->ensureItemIsVisible(
- dynamic_cast<CEGUI::ListboxItem*>(toadd) );
-
- /* make sure the history handles it */
- this->lb_history->handleUpdatedItemData();
- }
-
-
- /* sub for inputchanged */
- void ChatInputHandler::sub_adjust_dispoffset( int maxlen,
- int cursorpos,
- int inplen )
- {
- /* already start offsetting 5 characters before end */
- if( cursorpos+5 > maxlen )
- {
- /* always stay 5 characters ahead of end, looks better */
- ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0;
-
- /* enforce visibility of cursor */
- (disp_offset > cursorpos ) ? disp_offset = 0 : 1;
- }
-
- /* make sure we don't die at substr */
- if( inplen <= disp_offset ) disp_offset = 0;
- }
-
- /* callbacks for InputBuffer */
- void ChatInputHandler::inputChanged()
- {
- /* update the cursor and the window */
- std::string raw = this->inpbuf->get();
- int cursorpos = this->inpbuf->getCursorPosition();
-
- /* get string before cursor */
- std::string left = raw.substr( 0, cursorpos );
-
- /* see if there's a string after the cursor */
- std::string right = "";
- if( raw.length() >= left.length()+1 )
- right = raw.substr( cursorpos );
-
- /* set the text */
- std::string assembled = "$ " + left + "|" + right;
-
- if( this->fullchat )
- {
- /* adjust curser position - magic number 5 for font width */
- sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
- cursorpos, assembled.length() );
- this->input->setProperty( "Text", assembled.substr( disp_offset ) );
- }
- else
- {
- /* adjust curser position - magic number 5 for font width */
- sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
- cursorpos, assembled.length() );
- this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
- }
-
- /* reset display offset */
- disp_offset = 0;
- }
-
- void ChatInputHandler::addline()
- {
- /* actually do send what was input */
- /* a) get the string out of the inputbuffer */
- std::string msgtosend = this->inpbuf->get();
-
- if( msgtosend.length() == 0 )
- { this->deactivate();
- return;
- }
-
- /* b) clear the input buffer */
- if (this->inpbuf->getSize() > 0)
- this->inpbuf->clear();
-
- /* c) send the chat via some call */
- ChatManager::chat( msgtosend );
-
- /* d) stop listening to input - only if this is not fullchat */
- if( !this->fullchat )
- this->deactivate();
-
- }
-
- void ChatInputHandler::backspace()
- { this->inpbuf->removeBehindCursor(); }
-
- void ChatInputHandler::deleteChar()
- { this->inpbuf->removeAtCursor(); }
-
- void ChatInputHandler::cursorRight()
- { this->inpbuf->increaseCursor(); }
-
- void ChatInputHandler::cursorLeft()
- { this->inpbuf->decreaseCursor(); }
-
- void ChatInputHandler::cursorEnd()
- { this->inpbuf->setCursorToEnd(); }
-
- void ChatInputHandler::cursorHome()
- { this->inpbuf->setCursorToBegin(); }
-
- void ChatInputHandler::exit()
- {
- /* b) clear the input buffer */
- if (this->inpbuf->getSize() > 0)
- this->inpbuf->clear();
-
- /* d) stop listening to input */
- this->deactivate();
- }
-
-}
Copied: code/trunk/src/orxonox/chat/ChatInputHandler.cc (from rev 8857, code/branches/output/src/orxonox/chat/ChatInputHandler.cc)
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.cc (rev 0)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,342 @@
+/*
+ * 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:
+ * Sandro 'smerkli' Merkli
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "ChatInputHandler.h"
+
+#include <cassert>
+#include <string>
+#include <CEGUIWindow.h>
+#include <CEGUIWindowManager.h>
+#include <elements/CEGUIListbox.h>
+#include <elements/CEGUIListboxItem.h>
+#include <elements/CEGUIListboxTextItem.h>
+
+#include "util/ScopedSingletonManager.h"
+#include "core/CoreIncludes.h"
+#include "core/GUIManager.h"
+#include "core/command/ConsoleCommand.h"
+#include "core/input/InputBuffer.h"
+#include "core/input/InputManager.h"
+#include "core/input/InputState.h"
+
+#include "chat/ChatManager.h"
+#include "PlayerManager.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ /* singleton */
+ ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
+
+ /* add commands to console */
+ SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
+ SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
+
+ /* constructor */
+ ChatInputHandler::ChatInputHandler()
+ {
+ /* register the object */
+ RegisterObject(ChatInputHandler);
+
+ /* create necessary objects */
+ this->inpbuf = new InputBuffer();
+ this->disp_offset = 0;
+ assert( this->inpbuf != NULL );
+
+ /* generate chatbox ui and chatbox-inputonly ui */
+ GUIManager::getInstance().loadGUI( "ChatBox" );
+ GUIManager::getInstance().loadGUI( "ChatBox-inputonly" );
+
+ /* setup colors */
+ setupColors();
+
+ /* configure the input buffer */
+ configureInputBuffer();
+
+ this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
+ this->inputState->setKeyHandler(this->inpbuf);
+ }
+
+ ChatInputHandler::~ChatInputHandler()
+ {
+ /* Clean up */
+ InputManager::getInstance().destroyState("chatinput");
+ delete this->inpbuf;
+ }
+
+ /* configure input buffer, sub for the constructor */
+ void ChatInputHandler::configureInputBuffer()
+ {
+ /* INSTALL CALLBACKS */
+ /* input has changed */
+ this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
+
+ /* add a line */
+ this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\r', false);
+ this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\n', false);
+
+ /* backspace */
+ this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\b', true);
+ //this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\177', true);
+
+ /* exit the chatinputhandler thingy (tbd) */
+ this->inpbuf->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape
+
+ /* delete character */
+ this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete);
+
+ /* cursor movement */
+ this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight, KeyCode::Right);
+ this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft, KeyCode::Left);
+ this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd, KeyCode::End);
+ this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home);
+
+ /* GET WINDOW POINTERS */
+ input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
+ inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
+
+ /* get pointer to the history window */
+ CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
+
+ /* cast it to a listbox */
+ lb_history = dynamic_cast<CEGUI::Listbox*>(history);
+
+ /* assert wee */
+ assert( lb_history );
+ }
+
+ /* setup the colors, sub for the constructor */
+ void ChatInputHandler::setupColors()
+ {
+ /* auto variables */
+ float red = 1.0, green = 0.5, blue = 0.5;
+ int i = 0;
+
+ // three loops: red tones, blue tones and green tones
+ // reds
+ for( i = 0; i < NumberOfColors/3; ++i )
+ { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+ green += 0.2f, blue += 0.2f;
+ }
+
+ // greens
+ red = 0.5, green = 1, blue = 0.5;
+ for( ; i < NumberOfColors*2/3; ++i )
+ { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+ red += 0.2f, blue += 0.2f;
+ }
+
+ // blues
+ red = 0.5, green = 0.5, blue = 1;
+ for( ; i < NumberOfColors; ++i )
+ { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+ red += 0.2f, green += 0.2f;
+ }
+ }
+
+
+ /* activate, deactivate */
+ void ChatInputHandler::activate_static()
+ { ChatInputHandler::getInstance().activate( true ); }
+
+ void ChatInputHandler::activate_small_static()
+ { ChatInputHandler::getInstance().activate( false ); }
+
+ void ChatInputHandler::activate( bool full )
+ {
+ /* start listening */
+ InputManager::getInstance().enterState("chatinput");
+
+ /* MARK add spawning of chat widget stuff here.*/
+ if( full )
+ GUIManager::getInstance().showGUI( "ChatBox" );
+ else
+ GUIManager::getInstance().showGUI( "ChatBox-inputonly" );
+
+ this->fullchat = full;
+ }
+
+ void ChatInputHandler::deactivate()
+ {
+ /* stop listening */
+ InputManager::getInstance().leaveState("chatinput");
+
+ /* un-spawning of chat widget stuff */
+ GUIManager::getInstance().hideGUI( "ChatBox" );
+ GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
+ }
+
+
+ /* subs for incomingChat */
+ void ChatInputHandler::sub_setcolor( CEGUI::ListboxTextItem *tocolor,
+ std::string name )
+ {
+ /* sanity checks */
+ if( !tocolor )
+ orxout(internal_warning) << "Empty ListBoxTextItem given to "
+ "ChatInputhandler::sub_setcolor()." << endl;
+
+ /* "hash" the name */
+ int hash = 0;
+ for( int i = name.length(); i > 0; --i )
+ hash += name[i-1];
+ hash = hash % this->NumberOfColors;
+
+ /* set the color according to the hash */
+ tocolor->setTextColours( this->text_colors[ hash ] );
+ }
+
+ /* handle incoming chat */
+ void ChatInputHandler::incomingChat(const std::string& message, const std::string& name)
+ {
+ /* create item */
+ CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( message );
+
+ /* setup colors */
+ if (name != "")
+ sub_setcolor( toadd, name );
+
+ /* now add */
+ this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+ this->lb_history->ensureItemIsVisible(
+ dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+
+ /* make sure the history handles it */
+ this->lb_history->handleUpdatedItemData();
+ }
+
+
+ /* sub for inputchanged */
+ void ChatInputHandler::sub_adjust_dispoffset( int maxlen,
+ int cursorpos,
+ int inplen )
+ {
+ /* already start offsetting 5 characters before end */
+ if( cursorpos+5 > maxlen )
+ {
+ /* always stay 5 characters ahead of end, looks better */
+ ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0;
+
+ /* enforce visibility of cursor */
+ (disp_offset > cursorpos ) ? disp_offset = 0 : 1;
+ }
+
+ /* make sure we don't die at substr */
+ if( inplen <= disp_offset ) disp_offset = 0;
+ }
+
+ /* callbacks for InputBuffer */
+ void ChatInputHandler::inputChanged()
+ {
+ /* update the cursor and the window */
+ std::string raw = this->inpbuf->get();
+ int cursorpos = this->inpbuf->getCursorPosition();
+
+ /* get string before cursor */
+ std::string left = raw.substr( 0, cursorpos );
+
+ /* see if there's a string after the cursor */
+ std::string right = "";
+ if( raw.length() >= left.length()+1 )
+ right = raw.substr( cursorpos );
+
+ /* set the text */
+ std::string assembled = "$ " + left + "|" + right;
+
+ if( this->fullchat )
+ {
+ /* adjust curser position - magic number 5 for font width */
+ sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
+ cursorpos, assembled.length() );
+ this->input->setProperty( "Text", assembled.substr( disp_offset ) );
+ }
+ else
+ {
+ /* adjust curser position - magic number 5 for font width */
+ sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
+ cursorpos, assembled.length() );
+ this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
+ }
+
+ /* reset display offset */
+ disp_offset = 0;
+ }
+
+ void ChatInputHandler::addline()
+ {
+ /* actually do send what was input */
+ /* a) get the string out of the inputbuffer */
+ std::string msgtosend = this->inpbuf->get();
+
+ if( msgtosend.length() == 0 )
+ { this->deactivate();
+ return;
+ }
+
+ /* b) clear the input buffer */
+ if (this->inpbuf->getSize() > 0)
+ this->inpbuf->clear();
+
+ /* c) send the chat via some call */
+ ChatManager::chat( msgtosend );
+
+ /* d) stop listening to input - only if this is not fullchat */
+ if( !this->fullchat )
+ this->deactivate();
+
+ }
+
+ void ChatInputHandler::backspace()
+ { this->inpbuf->removeBehindCursor(); }
+
+ void ChatInputHandler::deleteChar()
+ { this->inpbuf->removeAtCursor(); }
+
+ void ChatInputHandler::cursorRight()
+ { this->inpbuf->increaseCursor(); }
+
+ void ChatInputHandler::cursorLeft()
+ { this->inpbuf->decreaseCursor(); }
+
+ void ChatInputHandler::cursorEnd()
+ { this->inpbuf->setCursorToEnd(); }
+
+ void ChatInputHandler::cursorHome()
+ { this->inpbuf->setCursorToBegin(); }
+
+ void ChatInputHandler::exit()
+ {
+ /* b) clear the input buffer */
+ if (this->inpbuf->getSize() > 0)
+ this->inpbuf->clear();
+
+ /* d) stop listening to input */
+ this->deactivate();
+ }
+
+}
Deleted: code/trunk/src/orxonox/chat/ChatInputHandler.h
===================================================================
--- code/branches/output/src/orxonox/chat/ChatInputHandler.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,133 +0,0 @@
-/*
- * 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:
- * Sandro 'smerkli' Merkli
- * Co-authors:
- * ...
- *
- */
-
-#ifndef _ChatInputHandler_H__
-#define _ChatInputHandler_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-#include <CEGUIForwardRefs.h>
-#include <CEGUIcolour.h>
-
-#include "util/Singleton.h"
-#include "chat/ChatListener.h"
-
-namespace orxonox // tolua_export
-{ // tolua_export
- /* class to handle chat using an InputBuffer */
- class _OrxonoxExport ChatInputHandler // tolua_export
- : public Singleton<ChatInputHandler>, public ChatListener
- { // tolua_export
- private:
- /** Input buffer, to be used to catch input from the
- * keyboard
- */
- InputBuffer *inpbuf;
- int disp_offset, width;
- bool fullchat;
-
- /* colors for nickname coloring */
- static const int NumberOfColors = 10;
- CEGUI::colour text_colors[ NumberOfColors ];
-
- /** input state */
- InputState *inputState;
-
- /** setup input buffer, the constructor calls this */
- void configureInputBuffer();
-
- /** adjust display offset depending on cursor position */
- void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
-
- /** singleton pointer */
- static ChatInputHandler* singletonPtr_s;
-
- /** cegui window handles */
- CEGUI::Window *input, *inputonly;
-
- /** cegui handle for the history window */
- CEGUI::Listbox *lb_history;
-
- /* methods to deal with colors */
- void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
- std::string name );
-
- void setupColors();
-
- /* callbacks for input handler */
- void inputChanged();
- void addline();
- void backspace();
- void deleteChar();
- void cursorRight();
- void cursorLeft();
- void cursorEnd();
- void cursorHome();
- void exit();
-
- public:
- /** constructor */
- ChatInputHandler();
- ~ChatInputHandler();
- friend class Singleton<ChatInputHandler>;
-
- static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); } // tolua_export
-
- /** start listening */
- static void activate_static();
-
- /** stop listening */
- static void activate_small_static();
-
- /** \param message the message text
- * \param senderID ID of the player who sent the message
- *
- * Deal with incoming chat (which means in our case: Add it to the
- * history window of the full chat window)
- */
- void incomingChat(const std::string& message, const std::string& name);
-
- /** \param full true means show full chat window with history,
- false means show only an input line
- *
- * Show the chat window and redirect the game's keyboard input
- * into it.
- */
- void activate( bool full );
-
- /** Deactivate the chat window, meaning: hide it. */
- void deactivate(); // tolua_export
-
- }; // tolua_export
-
-
-} // tolua_export
-
-
-#endif /*_ChatInputHandler_H__*/
Copied: code/trunk/src/orxonox/chat/ChatInputHandler.h (from rev 8857, code/branches/output/src/orxonox/chat/ChatInputHandler.h)
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.h (rev 0)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,133 @@
+/*
+ * 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:
+ * Sandro 'smerkli' Merkli
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _ChatInputHandler_H__
+#define _ChatInputHandler_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <CEGUIForwardRefs.h>
+#include <CEGUIcolour.h>
+
+#include "util/Singleton.h"
+#include "chat/ChatListener.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+ /* class to handle chat using an InputBuffer */
+ class _OrxonoxExport ChatInputHandler // tolua_export
+ : public Singleton<ChatInputHandler>, public ChatListener
+ { // tolua_export
+ private:
+ /** Input buffer, to be used to catch input from the
+ * keyboard
+ */
+ InputBuffer *inpbuf;
+ int disp_offset, width;
+ bool fullchat;
+
+ /* colors for nickname coloring */
+ static const int NumberOfColors = 10;
+ CEGUI::colour text_colors[ NumberOfColors ];
+
+ /** input state */
+ InputState *inputState;
+
+ /** setup input buffer, the constructor calls this */
+ void configureInputBuffer();
+
+ /** adjust display offset depending on cursor position */
+ void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
+
+ /** singleton pointer */
+ static ChatInputHandler* singletonPtr_s;
+
+ /** cegui window handles */
+ CEGUI::Window *input, *inputonly;
+
+ /** cegui handle for the history window */
+ CEGUI::Listbox *lb_history;
+
+ /* methods to deal with colors */
+ void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
+ std::string name );
+
+ void setupColors();
+
+ /* callbacks for input handler */
+ void inputChanged();
+ void addline();
+ void backspace();
+ void deleteChar();
+ void cursorRight();
+ void cursorLeft();
+ void cursorEnd();
+ void cursorHome();
+ void exit();
+
+ public:
+ /** constructor */
+ ChatInputHandler();
+ ~ChatInputHandler();
+ friend class Singleton<ChatInputHandler>;
+
+ static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); } // tolua_export
+
+ /** start listening */
+ static void activate_static();
+
+ /** stop listening */
+ static void activate_small_static();
+
+ /** \param message the message text
+ * \param senderID ID of the player who sent the message
+ *
+ * Deal with incoming chat (which means in our case: Add it to the
+ * history window of the full chat window)
+ */
+ void incomingChat(const std::string& message, const std::string& name);
+
+ /** \param full true means show full chat window with history,
+ false means show only an input line
+ *
+ * Show the chat window and redirect the game's keyboard input
+ * into it.
+ */
+ void activate( bool full );
+
+ /** Deactivate the chat window, meaning: hide it. */
+ void deactivate(); // tolua_export
+
+ }; // tolua_export
+
+
+} // tolua_export
+
+
+#endif /*_ChatInputHandler_H__*/
Deleted: code/trunk/src/orxonox/chat/ChatListener.h
===================================================================
--- code/branches/output/src/orxonox/chat/ChatListener.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,60 +0,0 @@
-/*
- * 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:
- * ...
- *
- */
-
-#ifndef _ChatListener_H__
-#define _ChatListener_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
- /**
- @brief Classes inheriting from this interface get a notification whenever a chat
- message was sent through ChatManager.
- */
- class _OrxonoxExport ChatListener : virtual public OrxonoxClass
- {
- friend class ChatManager;
-
- public:
- ChatListener(); // implemented in ChatManager.cc
- virtual ~ChatListener() {}
-
- protected:
- /**
- @brief Gets called whenever a chat message was sent through ChatManager.
- @param message The whole message (including name of the sender if available)
- @param name The name of the sender (if available, otherwise "")
- */
- virtual void incomingChat(const std::string& message, const std::string& name) = 0;
- };
-}
-
-#endif /* _ChatListener_H__ */
Copied: code/trunk/src/orxonox/chat/ChatListener.h (from rev 8857, code/branches/output/src/orxonox/chat/ChatListener.h)
===================================================================
--- code/trunk/src/orxonox/chat/ChatListener.h (rev 0)
+++ code/trunk/src/orxonox/chat/ChatListener.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -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:
+ * ...
+ *
+ */
+
+#ifndef _ChatListener_H__
+#define _ChatListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ /**
+ @brief Classes inheriting from this interface get a notification whenever a chat
+ message was sent through ChatManager.
+ */
+ class _OrxonoxExport ChatListener : virtual public OrxonoxClass
+ {
+ friend class ChatManager;
+
+ public:
+ ChatListener(); // implemented in ChatManager.cc
+ virtual ~ChatListener() {}
+
+ protected:
+ /**
+ @brief Gets called whenever a chat message was sent through ChatManager.
+ @param message The whole message (including name of the sender if available)
+ @param name The name of the sender (if available, otherwise "")
+ */
+ virtual void incomingChat(const std::string& message, const std::string& name) = 0;
+ };
+}
+
+#endif /* _ChatListener_H__ */
Deleted: code/trunk/src/orxonox/chat/ChatManager.cc
===================================================================
--- code/branches/output/src/orxonox/chat/ChatManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,120 +0,0 @@
-/*
- * 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:
- * ...
- *
- */
-
-#include "ChatManager.h"
-#include "ChatListener.h"
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "core/command/ConsoleCommand.h"
-#include "network/Host.h"
-
-#include "PlayerManager.h"
-#include "infos/PlayerInfo.h"
-
-namespace orxonox
-{
- ManageScopedSingleton(ChatManager, ScopeID::Root, false);
-
- SetConsoleCommand("chat", &ChatManager::chat).defaultValue(1, NETWORK_PEER_ID_BROADCAST);
-
- ChatManager::ChatManager()
- {
- RegisterObject(ChatManager);
- }
-
- /**
- @brief Sends a message (usually gameplay related) without explicit sender to the chat.
- @param message The message
- @param targetID The client ID (network) of the receiver. Usually the broadcast ID
- */
- /*static*/ void ChatManager::message(const std::string& message, unsigned int targetID)
- {
- unsigned int sourceID = NETWORK_PEER_ID_UNKNOWN;
-
- // only the server should send gameplay messages through the network. otherwise display the message locally
- if (GameMode::isServer())
- Host::sendChat(message, sourceID, targetID);
- else
- ChatManager::getInstance().incomingChat(message, sourceID);
- }
-
- /**
- @brief Sends a chat message with the client as its sender to the chat.
- @param message The message
- @param targetID The client ID (network) of the receiver. Usually the broadcast ID
- */
- /*static*/ void ChatManager::chat(const std::string& message, unsigned int targetID)
- {
- unsigned int sourceID = Host::getPlayerID();
-
- // if connected to the network, send chat messages online. otherwise display chat locally
- if (GameMode::isServer() || GameMode::isClient())
- Host::sendChat(message, sourceID, targetID);
- else
- ChatManager::getInstance().incomingChat(message, sourceID);
- }
-
- /**
- @brief Inherited callback from NetworkChatListener, but gets also called directly
- by ChatManager itself if the client is offline. Distributes an incoming chat message
- to all ChatListeners.
- @param message The message
- @param sourceID The client ID (network) of the sender
- */
- void ChatManager::incomingChat(const std::string& message, unsigned int sourceID)
- {
- std::string text = message;
- std::string name;
-
- // get the name of the sender and prepend it to the text message
- if (sourceID != NETWORK_PEER_ID_UNKNOWN)
- {
- PlayerInfo* player = PlayerManager::getInstance().getClient(sourceID);
- if (player)
- {
- name = player->getName();
- text = name + ": " + message;
- }
- }
-
- // notify all listeners
- for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
- it->incomingChat(text, name);
- }
-
-
- //////////////////////////////////////////////////////////////////////////
- // ChatListener //
- //////////////////////////////////////////////////////////////////////////
-
- ChatListener::ChatListener()
- {
- RegisterRootObject(ChatListener);
- }
-}
Copied: code/trunk/src/orxonox/chat/ChatManager.cc (from rev 8857, code/branches/output/src/orxonox/chat/ChatManager.cc)
===================================================================
--- code/trunk/src/orxonox/chat/ChatManager.cc (rev 0)
+++ code/trunk/src/orxonox/chat/ChatManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,120 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#include "ChatManager.h"
+#include "ChatListener.h"
+
+#include "util/ScopedSingletonManager.h"
+#include "core/CoreIncludes.h"
+#include "core/command/ConsoleCommand.h"
+#include "network/Host.h"
+
+#include "PlayerManager.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+ ManageScopedSingleton(ChatManager, ScopeID::Root, false);
+
+ SetConsoleCommand("chat", &ChatManager::chat).defaultValue(1, NETWORK_PEER_ID_BROADCAST);
+
+ ChatManager::ChatManager()
+ {
+ RegisterObject(ChatManager);
+ }
+
+ /**
+ @brief Sends a message (usually gameplay related) without explicit sender to the chat.
+ @param message The message
+ @param targetID The client ID (network) of the receiver. Usually the broadcast ID
+ */
+ /*static*/ void ChatManager::message(const std::string& message, unsigned int targetID)
+ {
+ unsigned int sourceID = NETWORK_PEER_ID_UNKNOWN;
+
+ // only the server should send gameplay messages through the network. otherwise display the message locally
+ if (GameMode::isServer())
+ Host::sendChat(message, sourceID, targetID);
+ else
+ ChatManager::getInstance().incomingChat(message, sourceID);
+ }
+
+ /**
+ @brief Sends a chat message with the client as its sender to the chat.
+ @param message The message
+ @param targetID The client ID (network) of the receiver. Usually the broadcast ID
+ */
+ /*static*/ void ChatManager::chat(const std::string& message, unsigned int targetID)
+ {
+ unsigned int sourceID = Host::getPlayerID();
+
+ // if connected to the network, send chat messages online. otherwise display chat locally
+ if (GameMode::isServer() || GameMode::isClient())
+ Host::sendChat(message, sourceID, targetID);
+ else
+ ChatManager::getInstance().incomingChat(message, sourceID);
+ }
+
+ /**
+ @brief Inherited callback from NetworkChatListener, but gets also called directly
+ by ChatManager itself if the client is offline. Distributes an incoming chat message
+ to all ChatListeners.
+ @param message The message
+ @param sourceID The client ID (network) of the sender
+ */
+ void ChatManager::incomingChat(const std::string& message, unsigned int sourceID)
+ {
+ std::string text = message;
+ std::string name;
+
+ // get the name of the sender and prepend it to the text message
+ if (sourceID != NETWORK_PEER_ID_UNKNOWN)
+ {
+ PlayerInfo* player = PlayerManager::getInstance().getClient(sourceID);
+ if (player)
+ {
+ name = player->getName();
+ text = name + ": " + message;
+ }
+ }
+
+ // notify all listeners
+ for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
+ it->incomingChat(text, name);
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////
+ // ChatListener //
+ //////////////////////////////////////////////////////////////////////////
+
+ ChatListener::ChatListener()
+ {
+ RegisterRootObject(ChatListener);
+ }
+}
Deleted: code/trunk/src/orxonox/chat/ChatManager.h
===================================================================
--- code/branches/output/src/orxonox/chat/ChatManager.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/chat/ChatManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,63 +0,0 @@
-/*
- * 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:
- * ...
- *
- */
-
-#ifndef _ChatManager_H__
-#define _ChatManager_H__
-
-#include "OrxonoxPrereqs.h"
-#include "util/Singleton.h"
-#include "network/NetworkChatListener.h"
-
-namespace orxonox
-{
- /**
- @brief This class collects and distributes chat messages. If the client is online,
- all chat messages are sent and received through the network. Otherwise chat is handled
- directly by this class.
- */
- class _OrxonoxExport ChatManager : public Singleton<ChatManager>, public NetworkChatListener
- {
- friend class Singleton<ChatManager>;
-
- public:
- ChatManager();
- virtual ~ChatManager() {}
-
- static void message(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST);
- static void chat(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST);
-
- protected:
- ChatManager(const ChatManager&);
-
- virtual void incomingChat(const std::string& message, unsigned int sourceID);
-
- static ChatManager* singletonPtr_s;
- };
-}
-
-#endif /* _ChatManager_H__ */
Copied: code/trunk/src/orxonox/chat/ChatManager.h (from rev 8857, code/branches/output/src/orxonox/chat/ChatManager.h)
===================================================================
--- code/trunk/src/orxonox/chat/ChatManager.h (rev 0)
+++ code/trunk/src/orxonox/chat/ChatManager.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -0,0 +1,63 @@
+/*
+ * 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:
+ * ...
+ *
+ */
+
+#ifndef _ChatManager_H__
+#define _ChatManager_H__
+
+#include "OrxonoxPrereqs.h"
+#include "util/Singleton.h"
+#include "network/NetworkChatListener.h"
+
+namespace orxonox
+{
+ /**
+ @brief This class collects and distributes chat messages. If the client is online,
+ all chat messages are sent and received through the network. Otherwise chat is handled
+ directly by this class.
+ */
+ class _OrxonoxExport ChatManager : public Singleton<ChatManager>, public NetworkChatListener
+ {
+ friend class Singleton<ChatManager>;
+
+ public:
+ ChatManager();
+ virtual ~ChatManager() {}
+
+ static void message(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST);
+ static void chat(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST);
+
+ protected:
+ ChatManager(const ChatManager&);
+
+ virtual void incomingChat(const std::string& message, unsigned int sourceID);
+
+ static ChatManager* singletonPtr_s;
+ };
+}
+
+#endif /* _ChatManager_H__ */
Modified: code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CollisionShape.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/collisionshapes/CollisionShape.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -202,7 +202,7 @@
// If the vectors are not in the same direction, then this is no longer a uniform scaling.
if(scale_.crossProduct(scale).squaredLength() != 0.0f)
{
- CCOUT(2) << "Warning: Non-uniform scaling is not yet supported." << endl;
+ orxout(internal_warning) << "Non-uniform scaling is not yet supported." << endl;
return;
}
Modified: code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -97,7 +97,7 @@
if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
{
- CCOUT(2) << "Warning: Attaching a CollisionShape twice is not yet supported." << std::endl;
+ orxout(internal_warning) << "Attaching a CollisionShape twice is not yet supported." << endl;
return;
}
@@ -138,7 +138,7 @@
this->updatePublicShape();
}
else
- CCOUT(2) << "Warning: Cannot detach non child collision shape" << std::endl;
+ orxout(internal_warning) << "Cannot detach non child collision shape" << endl;
}
/**
@@ -167,7 +167,7 @@
// Check whether the input shape belongs to this CompoundCollisionShape.
if (it == this->attachedShapes_.end())
{
- CCOUT(2) << "Warning: Cannot update child shape: Instance not a child." << std::endl;
+ orxout(internal_warning) << "Cannot update child shape: Instance not a child." << endl;
return;
}
Modified: code/trunk/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/controllers/ArtificialController.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -97,7 +97,7 @@
{
if (it->myMaster_ == this)
{
- COUT(1) << "error: " << this << " is still master in " << (*it) << std::endl;
+ orxout(internal_error) << this << " is still master in " << (*it) << endl;
it->myMaster_ = 0;
}
@@ -106,7 +106,7 @@
std::vector<ArtificialController*>::iterator it2 = std::find(it->slaves_.begin(), it->slaves_.end(), this);
if (it2 != it->slaves_.end())
{
- COUT(1) << "error: " << this << " is still slave in " << (*it) << std::endl;
+ orxout(internal_error) << this << " is still slave in " << (*it) << endl;
it->slaves_.erase(it2);
}
else
@@ -736,7 +736,7 @@
float speedDiv = this->getControllableEntity()->getVelocity().squaredLength() - this->target_->getVelocity().squaredLength();
-COUT(0) << "~follow distance: " << distance << "SpeedCounter: " << this->speedCounter_ << "~speedDiv: " << speedDiv << std::endl;
+orxout() << "~follow distance: " << distance << "SpeedCounter: " << this->speedCounter_ << "~speedDiv: " << speedDiv << endl;
if (distance < 800)
{
if (distance < 200)
Modified: code/trunk/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/controllers/HumanController.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -92,7 +92,7 @@
{
Camera* camera = HumanController::localController_s->controllableEntity_->getCamera();
if (!camera)
- COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
+ orxout(internal_warning) << "HumanController, Warning: Using a ControllableEntity without Camera" << endl;
}
}
@@ -196,7 +196,7 @@
this->boostingTimeout_.startTimer();
this->controllableEntity_->boost(this->boosting_);
- COUT(4) << "Start boosting" << endl;
+// orxout() << "Start boosting" << endl;
}
}
@@ -210,7 +210,7 @@
this->boostingTimeout_.stopTimer();
this->controllableEntity_->boost(this->boosting_);
- COUT(4) << "Stop boosting" << endl;
+// orxout() << "Stop boosting" << endl;
}
void HumanController::greet()
@@ -256,8 +256,8 @@
const Vector3& position = HumanController::localController_s->controllableEntity_->getPosition();
const Quaternion& orientation = HumanController::localController_s->controllableEntity_->getOrientation();
- COUT(0) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" ";
- COUT(0) << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << std::endl;
+ orxout(message) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" "
+ << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << endl;
}
}
Modified: code/trunk/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/controllers/NewHumanController.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -387,7 +387,7 @@
Ogre::RaySceneQueryResult::iterator itr;
for (itr = result.begin(); itr != result.end(); ++itr)
{
-// CCOUT(0) << "testing object as target" << endl;
+// orxout() << "testing object as target" << endl;
if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 200)
{
// Try to cast the user pointer
Modified: code/trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gamestates/GSClient.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -28,7 +28,6 @@
#include "GSClient.h"
-#include "util/Debug.h"
#include "util/Exception.h"
#include "core/CommandLineParser.h"
#include "core/Game.h"
@@ -52,6 +51,8 @@
void GSClient::activate()
{
+ orxout(user_status) << "Starting client" << endl;
+
GameMode::setIsClient(true);
// this->client_ = new Client();
Modified: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -73,6 +73,8 @@
void GSLevel::activate()
{
+ orxout(user_status) << "Loading level" << endl;
+
if (GameMode::showsGraphics())
{
gameInputState_ = InputManager::getInstance().createInputState("game");
@@ -154,7 +156,6 @@
this->staticObjects_.insert(*it);
// call the loader
- COUT(0) << "Loading level..." << std::endl;
startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
bool loaded = Loader::open(startFile_);
@@ -168,21 +169,21 @@
Loader::unload(startFile_);
delete startFile_;
- COUT(3) << "Unloaded level. Remaining objects:" << std::endl;
+ orxout(internal_info) << "Remaining objects:" << endl;
unsigned int i = 0;
for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
{
std::set<BaseObject*>::const_iterator find = this->staticObjects_.find(*it);
if (find == this->staticObjects_.end())
{
- COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << std::endl;
+ orxout(internal_info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
}
}
- COUT(3) << i << " objects remaining.";
+ orxout(internal_info) << i << " objects remaining.";
if (i == 0)
- COUT(3) << " Well done!" << std::endl;
+ orxout(internal_info) << " Well done!" << endl;
else
- COUT(3) << " Try harder!" << std::endl;
+ orxout(internal_info) << " Try harder!" << endl;
}
/**
Modified: code/trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -94,6 +94,8 @@
void GSMainMenu::activate()
{
+ orxout(user_status) << "Loading main menu" << endl;
+
// show main menu
GraphicsManager::getInstance().setCamera(this->camera_);
GUIManager::getInstance().showGUI("MainMenu", true);
Modified: code/trunk/src/orxonox/gamestates/GSMasterServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMasterServer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gamestates/GSMasterServer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,7 +29,7 @@
#include "GSMasterServer.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "core/Game.h"
#include "core/GameMode.h"
@@ -49,12 +49,12 @@
void GSMasterServer::activate()
{
+ orxout(user_status) << "Starting masterserver" << endl;
+
/* TODO make this work for masterserver as well */
//GameMode::setIsServer(true);
this->mserver = new MasterServer();
- COUT(0) << "Loading masterserver mode" << std::endl;
-
this->mserver->run();
}
Modified: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -76,12 +76,12 @@
for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; ++it)
{
if (dynamic_cast<Synchronisable*>(*it))
- COUT(0) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << std::endl;
+ orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << endl;
else
- COUT(0) << "object: " << it->getIdentifier()->getName() << std::endl;
+ orxout(debug_output) << "object: " << it->getIdentifier()->getName() << endl;
nr++;
}
- COUT(0) << "currently got " << nr << " objects" << std::endl;
+ orxout(debug_output) << "currently got " << nr << " objects" << endl;
}
void GSRoot::activate()
Modified: code/trunk/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gamestates/GSServer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -28,7 +28,7 @@
#include "GSServer.h"
-#include "util/Debug.h"
+#include "util/Output.h"
#include "core/CommandLineParser.h"
#include "core/Game.h"
#include "core/GameMode.h"
@@ -53,10 +53,12 @@
void GSServer::activate()
{
+ orxout(user_status) << "Starting server" << endl;
+
GameMode::setIsServer(true);
this->server_ = new Server(CommandLineParser::getValue("port"));
- COUT(0) << "Loading scene in server mode" << std::endl;
+ orxout(user_status) << "Loading scene in server mode" << endl;
server_->open();
}
Modified: code/trunk/src/orxonox/gametypes/Asteroids.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Asteroids.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/Asteroids.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,7 +29,7 @@
#include "Asteroids.h"
#include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "worldentities/pawns/Pawn.h"
namespace orxonox
@@ -73,8 +73,7 @@
Gametype::start();
std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
@@ -83,7 +82,6 @@
Gametype::end();
std::string message("The match has ended.");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
}
Modified: code/trunk/src/orxonox/gametypes/Deathmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Deathmatch.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/Deathmatch.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,7 +29,7 @@
#include "Deathmatch.h"
#include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
@@ -47,8 +47,7 @@
Gametype::start();
std::string message("The match has started!");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
void Deathmatch::end()
@@ -56,8 +55,7 @@
Gametype::end();
std::string message("The match has ended.");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
void Deathmatch::playerEntered(PlayerInfo* player)
@@ -65,8 +63,7 @@
Gametype::playerEntered(player);
const std::string& message = player->getName() + " entered the game";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
bool Deathmatch::playerLeft(PlayerInfo* player)
@@ -76,8 +73,7 @@
if (valid_player)
{
const std::string& message = player->getName() + " left the game";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
return valid_player;
@@ -90,8 +86,7 @@
if (valid_player)
{
const std::string& message = player->getOldName() + " changed name to " + player->getName();
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
return valid_player;
@@ -112,8 +107,7 @@
else
message = victim->getPlayer()->getName() + " died";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
Gametype::pawnKilled(victim, killer);
@@ -126,8 +120,7 @@
if (player)
{
const std::string& message = player->getName() + " scores!";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
}
}
Modified: code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Dynamicmatch.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/Dynamicmatch.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -48,7 +48,7 @@
#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/command/Executor.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
#include "worldentities/pawns/SpaceShip.h"
@@ -341,9 +341,8 @@
playerParty_[player]=chaser; //Set playerparty
numberOf[chaser]++;
Gametype::playerEntered(player);
- const std::string& message6 = player->getName() + " entered the game";
- COUT(0) << message6 << std::endl;
- Host::Broadcast(message6);
+ const std::string& message = player->getName() + " entered the game";
+ ChatManager::message(message);
}
bool Dynamicmatch::playerLeft(PlayerInfo* player) //standardfunction
@@ -358,8 +357,7 @@
case 2: numberOf[killer]--; break;
}
const std::string& message = player->getName() + " left the game";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
//remove player from map
playerParty_.erase (player);
//adjust player parties
@@ -616,8 +614,7 @@
if (valid_player)
{
const std::string& message = player->getOldName() + " changed name to " + player->getName();
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
return valid_player;
@@ -629,8 +626,7 @@
if(!tutorial)
{
std::string message("Dynamicmatch started!");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
else if(tutorial) // Announce selectionphase
{
@@ -646,24 +642,21 @@
/*void Dynamicmatch::instructions()
{
std::string message("Earn points:\n\n\n\tIf you're red: Chase the blue player!\n\n\tIf you're blue shoot at a red player or hide.\n\n\tIf you're green: You've got the licence to kill red players!");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
callInstructions_.setTimer(10, false, createExecutor(createFunctor(&Dynamicmatch::furtherInstructions, this)));
}
void Dynamicmatch::furtherInstructions()
{
std::string message("After 3 Minutes the game is over.");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}*/
void Dynamicmatch::end()
{
Gametype::end();
std::string message("Time out. Press F2 to see the points you scored.");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
SpawnPoint* Dynamicmatch::getBestSpawnPoint(PlayerInfo* player) const
{
Modified: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -296,7 +296,7 @@
it->first->startControl(entity);
}
else
- COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl;
+ orxout(internal_warning) << "Killed Pawn was not in the playerlist" << endl;
}
}
@@ -343,7 +343,7 @@
return activeSpawnPoints[randomspawn];
}
- COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl;
+ orxout(internal_warning) << "Fallback SpawnPoint was used because there were no active SpawnPoints." << endl;
return fallbackSpawnPoint;
}
return 0;
@@ -443,7 +443,7 @@
}
else
{
- COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+ orxout(user_error) << "No SpawnPoints in current Gametype" << endl;
abort();
}
}
@@ -460,7 +460,7 @@
}
else
{
- COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+ orxout(user_error) << "No SpawnPoints in current Gametype" << endl;
abort();
}
}
Modified: code/trunk/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastManStanding.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/LastManStanding.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,7 +29,7 @@
#include "LastManStanding.h"
#include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
#include "core/ConfigValueIncludes.h"
@@ -89,7 +89,7 @@
return true;
const std::string& message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
- }
+ }
}
return true;
}
@@ -104,8 +104,7 @@
{
this->playersAlive--;
const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
return true;
@@ -127,7 +126,7 @@
void LastManStanding::end()
{
Gametype::end();
-
+
for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
{
if (it->first->getClientID() == NETWORK_PEER_ID_UNKNOWN)
@@ -147,7 +146,7 @@
else
return 0;
}
-
+
int LastManStanding::getNumPlayersAlive() const
{
return this->playersAlive;
@@ -189,7 +188,7 @@
return;
this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
this->playerDelayTime_[player]=respawnDelay;
-
+
std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
if (it != this->players_.end())
{
@@ -197,7 +196,7 @@
return;
const std::string& message = ""; // resets Camper-Warning-message
this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
- }
+ }
}
void LastManStanding::punishPlayer(PlayerInfo* player)
@@ -238,11 +237,11 @@
this->end();
}
for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
- {
+ {
if (playerGetLives(it->first)<=0)//Players without lives shouldn't be affected by time.
- continue;
+ continue;
it->second-=dt;//Decreases punishment time.
- if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
+ if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
{
playerDelayTime_[it->first]-=dt;
if (playerDelayTime_[it->first]<=0)
Modified: code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastTeamStanding.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/LastTeamStanding.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -29,8 +29,7 @@
#include "LastTeamStanding.h"
#include "core/CoreIncludes.h"
-#include "network/NetworkPrereqs.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "infos/PlayerInfo.h"
#include "worldentities/pawns/Pawn.h"
#include "core/ConfigValueIncludes.h"
@@ -118,8 +117,7 @@
if(eachTeamsPlayers[team] == 0) //last team member died
this->teamsAlive--;
const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
}
return allow;
}
Modified: code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -140,9 +140,9 @@
if (!this->hasStarted() || this->hasEnded())
return;
- COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
- if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl;
- if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) COUT(0) << "Team 2 is near victory!" << std::endl;
+ orxout(message) << "Points standing:" << '\n' << "Team 1: "<< pointsTeam1_ << '\n' << "Team 2: " << pointsTeam2_ << endl;
+ if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) orxout(message) << "Team 1 is near victory!" << endl;
+ if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) orxout(message) << "Team 2 is near victory!" << endl;
}
@@ -178,12 +178,12 @@
if (this->pointsTeam1_ > this->pointsTeam2_)
{
- COUT(0) << "Team 1 has won the match" << std::endl;
+ orxout(message) << "Team 1 has won the match" << endl;
winningteam = 0;
}
else
{
- COUT(0) << "Team 2 has won the match" << std::endl;
+ orxout(message) << "Team 2 has won the match" << endl;
winningteam = 1;
}
Modified: code/trunk/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/UnderAttack.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/gametypes/UnderAttack.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -31,7 +31,7 @@
#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
#include "worldentities/pawns/Destroyer.h"
#include "infos/PlayerInfo.h"
@@ -69,8 +69,7 @@
{
this->end(); //end gametype
std::string message("Ship destroyed! Team 0 has won!");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
this->gameEnded_ = true;
for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
@@ -152,8 +151,7 @@
this->gameEnded_ = true;
this->end();
std::string message("Time is up! Team 1 has won!");
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
{
@@ -172,8 +170,7 @@
{
const std::string& message = multi_cast<std::string>(timesequence_) + " seconds left!";
/*
- COUT(0) << message << std::endl;
- Host::Broadcast(message);
+ ChatManager::message(message);
*/
this->gtinfo_->sendAnnounceMessage(message);
Modified: code/trunk/src/orxonox/graphics/AnimatedModel.cc
===================================================================
--- code/trunk/src/orxonox/graphics/AnimatedModel.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/graphics/AnimatedModel.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -21,8 +21,9 @@
*
* Author:
* Benjamin de Capitani
+ * Co-authors:
+ * ...
*
- *
*/
#include "AnimatedModel.h"
Modified: code/trunk/src/orxonox/graphics/AnimatedModel.h
===================================================================
--- code/trunk/src/orxonox/graphics/AnimatedModel.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/graphics/AnimatedModel.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabian 'x3n' Landau
+ * Benjamin de Capitani
* Co-authors:
* ...
*
Deleted: code/trunk/src/orxonox/graphics/CEGuiSample.cc
===================================================================
--- code/trunk/src/orxonox/graphics/CEGuiSample.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/graphics/CEGuiSample.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,304 +0,0 @@
-/***********************************************************************
- filename: CEGuiSample.cpp
- created: 24/9/2004
- author: Paul D Turner
-*************************************************************************/
-/***************************************************************************
- * Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- ***************************************************************************/
-#include "CEGuiSample.h"
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-#include "CEGUISamplesConfig.h"
-
-// includes for renderer selector classes
-#if defined( __WIN32__ ) || defined( _WIN32 )
-# include "Win32CEGuiRendererSelector.h"
-#elif defined(__linux__)
-# ifdef CEGUI_SAMPLES_USE_GTK2
-# include "GTK2CEGuiRendererSelector.h"
-# else
-# include "CLICEGuiRendererSelector.h"
-# endif
-#elif defined(__APPLE__)
-# include "MacCEGuiRendererSelector.h"
-#endif
-
-// includes for application types
-#ifdef CEGUI_SAMPLES_USE_OGRE
-# include "CEGuiOgreBaseApplication.h"
-#endif
-#ifdef CEGUI_SAMPLES_USE_OPENGL
-# include "CEGuiOpenGLBaseApplication.h"
-#endif
-#ifdef CEGUI_SAMPLES_USE_IRRLICHT
-# include "CEGuiIrrlichtBaseApplication.h"
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTFB
-# include "CEGuiDirectFBBaseApplication.h"
-#endif
-#if defined( __WIN32__ ) || defined( _WIN32 )
-# ifdef CEGUI_SAMPLES_USE_DIRECTX_8
-# include "CEGuiD3D81BaseApplication.h"
-# endif
-# ifdef CEGUI_SAMPLES_USE_DIRECTX_9
-# include "CEGuiD3D9BaseApplication.h"
-# endif
-# ifdef CEGUI_SAMPLES_USE_DIRECTX_10
-# include "CEGuiD3D10BaseApplication.h"
-# endif
-#endif
-// now we include the base CEGuiBaseApplication just in case someone has managed to
-// get this far without any of the renderers. This ensures the framework will build,
-// although there will be no renderers available for selection in the samples.
-#include "CEGuiBaseApplication.h"
-
-#include "CEGUI.h"
-
-#ifdef CEGUI_WITH_XERCES
-# include "CEGUIXercesParser.h"
-#endif
-
-// Include iostream if not on windows.
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#else
-# include <iostream>
-#endif
-
-
-/*************************************************************************
- Constructor
-*************************************************************************/
-CEGuiSample::CEGuiSample() :
- d_rendererSelector(0),
- d_sampleApp(0)
-{}
-
-
-/*************************************************************************
- Destructor
-*************************************************************************/
-CEGuiSample::~CEGuiSample()
-{
- if (d_sampleApp)
- {
- d_sampleApp->cleanup();
- delete d_sampleApp;
- }
-
- if (d_rendererSelector)
- {
- delete d_rendererSelector;
- }
-
-}
-
-
-/*************************************************************************
- Application entry point
-*************************************************************************/
-int CEGuiSample::run()
-{
- try
- {
- if (initialise())
- cleanup();
- }
- catch (CEGUI::Exception& exc)
- {
- outputExceptionMessage(exc.getMessage().c_str());
- }
- catch (std::exception& exc)
- {
- outputExceptionMessage(exc.what());
- }
- catch(...)
- {
- outputExceptionMessage("Unknown exception was caught!");
- }
-
- return 0;
-}
-
-
-/*************************************************************************
- Initialise the sample application
-*************************************************************************/
-bool CEGuiSample::initialise()
-{
- // Setup renderer selection dialog for Win32
-#if defined( __WIN32__ ) || defined( _WIN32 )
- d_rendererSelector = new Win32CEGuiRendererSelector;
-
- // enable renderer types supported for Win32
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_8
- d_rendererSelector->setRendererAvailability(Direct3D81GuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_9
- d_rendererSelector->setRendererAvailability(Direct3D9GuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_10
- d_rendererSelector->setRendererAvailability(Direct3D10GuiRendererType);
-#endif
-
-#elif defined(__linux__)
- // decide which method to use for renderer selection
-# ifdef CEGUI_SAMPLES_USE_GTK2
- d_rendererSelector = new GTK2CEGuiRendererSelector();
-# else
- d_rendererSelector = new CLICEGuiRendererSelector();
-# endif
-
-#elif defined(__APPLE__)
- d_rendererSelector = new MacCEGuiRendererSelector();
-#endif
-
- // enable available renderer types
-#ifdef CEGUI_SAMPLES_USE_OGRE
- d_rendererSelector->setRendererAvailability(OgreGuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_OPENGL
- d_rendererSelector->setRendererAvailability(OpenGLGuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_IRRLICHT
- d_rendererSelector->setRendererAvailability(IrrlichtGuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTFB
- d_rendererSelector->setRendererAvailability(DirectFBGuiRendererType);
-#endif
-
- // get selection from user
- if (d_rendererSelector->invokeDialog())
- {
- // create appropriate application type based upon users selection
- switch(d_rendererSelector->getSelectedRendererType())
- {
-#ifdef CEGUI_SAMPLES_USE_OGRE
- case OgreGuiRendererType:
- d_sampleApp = new CEGuiOgreBaseApplication();
- break;
-#endif
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_8
- case Direct3D81GuiRendererType:
- d_sampleApp = new CEGuiD3D81BaseApplication();
- break;
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_9
- case Direct3D9GuiRendererType:
- d_sampleApp = new CEGuiD3D9BaseApplication();
- break;
-#endif // DX9
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_10
- case Direct3D10GuiRendererType:
- d_sampleApp = new CEGuiD3D10BaseApplication();
- break;
-#endif // DX10
-#endif // Win32
-#ifdef CEGUI_SAMPLES_USE_OPENGL
- case OpenGLGuiRendererType:
- d_sampleApp = new CEGuiOpenGLBaseApplication();
- break;
-#endif
-#ifdef CEGUI_SAMPLES_USE_IRRLICHT
- case IrrlichtGuiRendererType:
- d_sampleApp = new CEGuiIrrlichtBaseApplication();
- break;
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTFB
- case DirectFBGuiRendererType:
- d_sampleApp = new CEGuiDirectFBBaseApplication();
- break;
-#endif
-
- default:
- throw CEGUI::GenericException("No renderer was selected!");
- break;
- }
-
- // set the default resource groups to be used
- CEGUI::Imageset::setDefaultResourceGroup("imagesets");
- CEGUI::Font::setDefaultResourceGroup("fonts");
- CEGUI::Scheme::setDefaultResourceGroup("schemes");
- CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
- CEGUI::WindowManager::setDefaultResourceGroup("layouts");
- CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
-#ifdef CEGUI_WITH_XERCES
- CEGUI::XercesParser::setSchemaDefaultResourceGroup("schemas");
-#endif
-
- // execute the base application (which sets up the demo via 'this' and runs it.
- if (d_sampleApp->execute(this))
- {
- // signal that app initialised and ran
- return true;
- }
-
- // sample app did not initialise, delete the object.
- delete d_sampleApp;
- d_sampleApp = 0;
- }
-
- // delete renderer selector object
- delete d_rendererSelector;
- d_rendererSelector = 0;
-
- // signal app did not initialise and run.
- return false;
-}
-
-
-/*************************************************************************
- Cleanup the sample application.
-*************************************************************************/
-void CEGuiSample::cleanup()
-{
- if (d_sampleApp)
- {
- d_sampleApp->cleanup();
- delete d_sampleApp;
- d_sampleApp = 0;
- }
-
- if (d_rendererSelector)
- {
- delete d_rendererSelector;
- d_rendererSelector = 0;
- }
-
-}
-
-
-/*************************************************************************
- Output a message to the user in some OS independant way.
-*************************************************************************/
-void CEGuiSample::outputExceptionMessage(const char* message) const
-{
-#if defined(__WIN32__) || defined(_WIN32)
- MessageBoxA(0, message, "CEGUI - Exception", MB_OK|MB_ICONERROR);
-#else
- std::cout << "An exception was thrown within the sample framework:" << std::endl;
- std::cout << message << std::endl;
-#endif
-}
Deleted: code/trunk/src/orxonox/graphics/CEGuiSample.h
===================================================================
--- code/trunk/src/orxonox/graphics/CEGuiSample.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/graphics/CEGuiSample.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -1,130 +0,0 @@
-/***********************************************************************
- filename: CEGuiSample.h
- created: 24/9/2004
- author: Paul D Turner
-*************************************************************************/
-/***************************************************************************
- * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- ***************************************************************************/
-#ifndef _CEGuiSample_h_
-#define _CEGuiSample_h_
-
-#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined (CEGUI_STATIC)
-# ifdef CEGUISAMPLE_EXPORTS
-# define CEGUISAMPLE_API __declspec(dllexport)
-# else
-# define CEGUISAMPLE_API __declspec(dllimport)
-# endif
-#else
-# define CEGUISAMPLE_API
-#endif
-
-
-// forward declarations
-class CEGuiBaseApplication;
-class CEGuiRendererSelector;
-
-
-/*!
-\brief
- This is a base class that is intended to be used for all sample applications.
- Here we take care of common things such the renderer selection and application
- startup.
-*/
-class CEGUISAMPLE_API CEGuiSample
-{
-public:
- /*!
- \brief
- Constructor.
- */
- CEGuiSample();
-
-
- /*!
- \brief
- Destructor.
- */
- virtual ~CEGuiSample();
-
-
- /*!
- \brief
- Application entry point.
-
- \return
- code to be returned by the application.
- */
- int run();
-
-
- /*!
- \brief
- Sample specific initialisation goes here. This method is called by the application base object created
- as part of the initialise call.
-
- \return
- false if something went wrong.
- */
- virtual bool initialiseSample() = 0;
-
-
- /*!
- \brief
- Cleans up resources allocated in the initialiseSample call.
- */
- virtual void cleanupSample() = 0;
-
-
-protected:
- /*!
- \brief
- Initialises the sample system, this includes asking the user for a render to use and
- the subsequent creation of the required systems to support that renderer.
-
- \return
- false if anything went wrong.
- */
- virtual bool initialise();
-
-
- /*!
- \brief
- Cleans up all resources allocated by the initialise call.
- */
- virtual void cleanup();
-
-
- /*!
- \brief
- Output a message to the user in some OS independant way.
- */
- void outputExceptionMessage(const char* message) const;
-
- /*************************************************************************
- Data fields
- *************************************************************************/
- CEGuiRendererSelector* d_rendererSelector; //!< Points to the renderer selector object.
- CEGuiBaseApplication* d_sampleApp; //!< Pointer to the base application object.
-};
-
-#endif // end of guard _CEGuiSample_h_
Modified: code/trunk/src/orxonox/graphics/Model.cc
===================================================================
--- code/trunk/src/orxonox/graphics/Model.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/graphics/Model.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -141,7 +141,7 @@
}
if( this->numLodLevels_>10 )
{
- CCOUT(2) << "More than 10 LoD levels requested. Creating only 10." << endl;
+ orxout(internal_warning, context::lod) << "More than 10 LoD levels requested. Creating only 10." << endl;
this->numLodLevels_ = 10;
}
if( this->bLodEnabled_ )
@@ -157,9 +157,9 @@
scaleFactor *= getBiggestScale(((WorldEntity*) creatorPtr)->getScale3D());
creatorPtr = creatorPtr->getCreator();
}
- COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;
+ orxout() << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;
*/
- COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << std::endl;
+ orxout(verbose, context::lod) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << endl;
#if OGRE_VERSION >= 0x010700
Ogre::Mesh::LodValueList distList;
@@ -172,7 +172,7 @@
// float factor = scaleFactor*5/lodLevel_;
float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_;
- COUT(4) << "LodLevel set with factor: " << factor << endl;
+ orxout(verbose, context::lod) << "LodLevel set with factor: " << factor << endl;
distList.push_back(70.0f*factor);
distList.push_back(140.0f*factor);
@@ -199,11 +199,11 @@
else
what = "<0";
- COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl;
+ orxout(verbose, context::lod) << "LodLevel not set because lodLevel(" << lodLevel_ << ") was " << what << "." << endl;
}
}
else
- COUT(4) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl;
+ orxout(verbose, context::lod) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl;
}
}
}
Modified: code/trunk/src/orxonox/graphics/ParticleEmitter.cc
===================================================================
--- code/trunk/src/orxonox/graphics/ParticleEmitter.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/graphics/ParticleEmitter.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -115,8 +115,8 @@
}
catch (const std::exception& ex)
{
- COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\" because:" << std::endl
- << ex.what() << std::endl;
+ orxout(internal_error) << "Couldn't load particle effect \"" << this->source_ << "\" because:" << endl
+ << ex.what() << endl;
}
}
}
Modified: code/trunk/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/GametypeInfo.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/infos/GametypeInfo.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -195,7 +195,7 @@
this->startCountdown_ = countdown;
// Set the counter to the ceiling of the current countdown.
- this->counter_ = std::ceil(countdown);
+ this->counter_ = static_cast<unsigned int>(std::ceil(countdown));
this->changedCountdownCounter();
}
Modified: code/trunk/src/orxonox/interfaces/PickupCarrier.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -74,7 +74,7 @@
it = this->pickups_.begin();
if(it != this->pickups_.end() && temp == *it) // Infinite loop avoidance, in case the pickup wasn't removed from the carrier somewhere in the carrierDestroy() procedure.
{
- COUT(2) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << temp << ") didn't unregister itself as it should have." << std::endl;;
+ orxout(internal_warning, context::pickups) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << temp << ") didn't unregister itself as it should have." << endl;;
it++;
}
}
@@ -157,7 +157,7 @@
*/
bool PickupCarrier::addPickup(Pickupable* pickup)
{
- COUT(4) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << std::endl;
+ orxout(verbose, context::pickups) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << endl;
return this->pickups_.insert(pickup).second;
}
@@ -171,7 +171,7 @@
*/
bool PickupCarrier::removePickup(Pickupable* pickup)
{
- COUT(4) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << std::endl;
+ orxout(verbose, context::pickups) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << endl;
return this->pickups_.erase(pickup) == 1;
}
Modified: code/trunk/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/interfaces/Pickupable.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -70,7 +70,7 @@
{
if(this->pickupIdentifier_ != NULL)
{
- COUT(4) << "Pickupable (&" << this << ") destroyed." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") destroyed." << endl;
this->pickupIdentifier_->destroy();
}
}
@@ -106,7 +106,7 @@
if(!this->beingDestroyed_)
this->OrxonoxClass::destroy();
else
- COUT(2) << this->getIdentifier()->getName() << " may be unsafe. " << std::endl;
+ orxout(internal_warning, context::pickups) << this->getIdentifier()->getName() << " may be unsafe. " << endl;
}
/**
@@ -125,7 +125,7 @@
if((!this->isUsable() && used) || (!this->isUnusable() && !used)) // If either the Pickupable is requested to be used but it is not usable or the Pickupable is requested to be unused, while it is not unusable.
return false;
- COUT(4) << "Pickupable (&" << this << ") set to used " << used << "." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") set to used " << used << "." << endl;
this->used_ = used;
@@ -200,7 +200,7 @@
if(this->isTarget(target)) // If the input target is already present in the list of targets.
return false;
- COUT(4) << "Target " << target->getName() << " added to Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ")." << std::endl;
+ orxout(verbose, context::pickups) << "Target " << target->getName() << " added to Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ")." << endl;
this->targets_.push_back(target);
return true;
}
@@ -220,12 +220,12 @@
if(!this->setCarrier(carrier))
{
- COUT(3) << "A Pickupable (&" << this << ") was trying to be added to a PickupCarrier, but was already present." << std::endl;
+ orxout(internal_warning, context::pickups) << "A Pickupable (&" << this << ") was trying to be added to a PickupCarrier, but was already present." << endl;
return false;
}
this->setPickedUp(true);
- COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << endl;
return true;
}
@@ -244,9 +244,9 @@
assert(this->getCarrier()); // The Carrier cannot be NULL at this point.
if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later?
- COUT(2) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << std::endl;
+ orxout(internal_warning, context::pickups) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << endl;
- COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << endl;
this->setUsed(false);
this->setPickedUp(false);
@@ -275,7 +275,7 @@
if(this->pickedUp_ == pickedUp) // If the picked up status has not changed.
return false;
- COUT(4) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << endl;
this->pickedUp_ = pickedUp;
@@ -304,7 +304,7 @@
if(this->carrier_ == carrier) // If the PickupCarrier doesn't change.
return false;
- COUT(4) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << endl;
if(carrier != NULL && tell)
{
@@ -339,7 +339,7 @@
Pickupable* pickup = dynamic_cast<Pickupable*>(item);
- COUT(4) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << std::endl;
+ orxout(verbose, context::pickups) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << endl;
return pickup;
}
Modified: code/trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -82,7 +82,7 @@
// this->radarObjectShape_ = radar->addObjectDescription(str);
// else
// {
-// CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
+// orxout(internal_warning) << "Attempting to access the radar, but the radar is non existent." << endl;
// }
// this->radarObjectDescription_ = str;
// }
@@ -105,7 +105,7 @@
{
if (!object)
{
- COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
+ orxout(user_error) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << endl;
assert(0);
}
}
Modified: code/trunk/src/orxonox/items/Engine.cc
===================================================================
--- code/trunk/src/orxonox/items/Engine.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/items/Engine.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -260,7 +260,7 @@
{
if(!this->engineTemplate_.empty())
{
- COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n";
+ orxout(verbose, context::templates) << "Loading an engine template: " << this->engineTemplate_ << endl;
Template *temp = Template::getTemplate(this->engineTemplate_);
if(temp)
{
Modified: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -45,6 +45,7 @@
#include "util/Math.h"
#include "util/DisplayStringConversions.h"
#include "util/ScopedSingletonManager.h"
+#include "util/output/MemoryWriter.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "core/command/ConsoleCommand.h"
@@ -57,7 +58,7 @@
namespace orxonox
{
const int LINES = 30;
- const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
+ const float CHAR_WIDTH = 8.0f; // fix this please - determine the char-width dynamically
SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
SetConsoleCommand("InGameConsole", "closeConsole", &InGameConsole::closeConsole);
@@ -93,7 +94,7 @@
// Output buffering is not anymore needed. Not the best solution to do
// this here, but there isn't much of another way.
- OutputHandler::getInstance().disableMemoryLog();
+ MemoryWriter::getInstance().disable();
}
/**
@@ -261,7 +262,7 @@
// we take -1.3 because the border makes the panel bigger
this->consoleOverlayContainer_->setTop(-1.3f * this->relativeHeight);
- COUT(4) << "Info: InGameConsole initialized" << std::endl;
+ orxout(internal_info) << "InGameConsole initialized" << endl;
}
// ###############################
@@ -287,7 +288,7 @@
}
for (int i = LINES - 1; i > max; --i)
- this->print("", Shell::None, i, true);
+ this->print("", Shell::DebugOutput, i, true);
for (int i = max; i >= 1; --i)
{
@@ -297,22 +298,14 @@
}
/**
- @brief Called if only the last output-line has changed.
- */
- void InGameConsole::onlyLastLineChanged()
- {
- if (LINES > 1)
- this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
- }
-
- /**
@brief Called if a new output-line was added.
*/
void InGameConsole::lineAdded()
{
this->numLinesShifted_ = 0;
this->shiftLines();
- this->onlyLastLineChanged();
+ if (LINES > 1)
+ this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
}
/**
@@ -345,7 +338,7 @@
*/
void InGameConsole::executed()
{
- this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
+ this->shell_->addOutput(this->shell_->getInput(), Shell::Command);
}
/**
@@ -436,7 +429,7 @@
this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
// now adjust the text lines...
- this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
+ this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 24;
if (LINES > 0)
this->maxCharsPerLine_ = std::max(10U, static_cast<unsigned int>(static_cast<float>(this->desiredTextWidth_) / CHAR_WIDTH));
@@ -565,37 +558,32 @@
ColourValue colourTop, colourBottom;
switch (type)
{
- case Shell::Error: colourTop = ColourValue(0.95f, 0.25f, 0.25f, 1.00f);
- colourBottom = ColourValue(1.00f, 0.50f, 0.50f, 1.00f); break;
+ case Shell::Message:
+ case Shell::DebugOutput: colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
- case Shell::Warning: colourTop = ColourValue(0.95f, 0.50f, 0.20f, 1.00f);
- colourBottom = ColourValue(1.00f, 0.70f, 0.50f, 1.00f); break;
+ case Shell::UserError: colourTop = ColourValue(0.9f, 0.0f, 0.0f); break;
+ case Shell::UserWarning: colourTop = ColourValue(0.9f, 0.5f, 0.0f); break;
+ case Shell::UserStatus: colourTop = ColourValue(0.0f, 0.9f, 0.0f); break;
+ case Shell::UserInfo: colourTop = ColourValue(0.0f, 0.8f, 0.8f); break;
- case Shell::Info: colourTop = ColourValue(0.50f, 0.50f, 0.95f, 1.00f);
- colourBottom = ColourValue(0.80f, 0.80f, 1.00f, 1.00f); break;
+ case Shell::InternalError: colourTop = ColourValue(0.5f, 0.0f, 0.0f); break;
+ case Shell::InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break;
+ case Shell::InternalStatus: colourTop = ColourValue(0.0f, 0.5f, 0.0f); break;
+ case Shell::InternalInfo: colourTop = ColourValue(0.0f, 0.4f, 0.4f); break;
- case Shell::Debug: colourTop = ColourValue(0.65f, 0.48f, 0.44f, 1.00f);
- colourBottom = ColourValue(1.00f, 0.90f, 0.90f, 1.00f); break;
+ case Shell::Verbose: colourTop = ColourValue(0.3f, 0.3f, 0.9f); break;
+ case Shell::VerboseMore: colourTop = ColourValue(0.2f, 0.2f, 0.7f); break;
+ case Shell::VerboseUltra: colourTop = ColourValue(0.1f, 0.1f, 0.5f); break;
- case Shell::Verbose: colourTop = ColourValue(0.40f, 0.20f, 0.40f, 1.00f);
- colourBottom = ColourValue(0.80f, 0.60f, 0.80f, 1.00f); break;
+ case Shell::Command: colourTop = ColourValue(0.8f, 0.2f, 0.8f); break;
+ case Shell::Hint: colourTop = ColourValue(0.4f, 0.0f, 0.4f); break;
+ case Shell::Input: colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
- case Shell::Ultra: colourTop = ColourValue(0.21f, 0.69f, 0.21f, 1.00f);
- colourBottom = ColourValue(0.80f, 1.00f, 0.80f, 1.00f); break;
-
- case Shell::Command: colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
- colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 0.90f); break;
-
- case Shell::Hint: colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
- colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); break;
-
- case Shell::TDebug: colourTop = ColourValue(0.90f, 0.00f, 0.90f, 1.00f);
- colourBottom = ColourValue(1.00f, 0.00f, 1.00f, 1.00f); break;
-
- default: colourTop = ColourValue(0.90f, 0.90f, 0.90f, 1.00f);
- colourBottom = ColourValue(1.00f, 1.00f, 1.00f, 1.00f); break;
+ default: colourTop = ColourValue(0.5f, 0.5f, 0.5f); break;
}
+ colourBottom = ColourValue(sqrt(colourTop.r), sqrt(colourTop.g), sqrt(colourTop.b));
+
this->consoleOverlayTextAreas_[index]->setColourTop (colourTop);
this->consoleOverlayTextAreas_[index]->setColourBottom(colourBottom);
}
Modified: code/trunk/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.h 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/overlays/InGameConsole.h 2011-08-22 22:45:53 UTC (rev 8858)
@@ -63,7 +63,6 @@
void deactivate();
void linesChanged();
- void onlyLastLineChanged();
void lineAdded();
void inputChanged();
void cursorChanged();
Modified: code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -146,7 +146,7 @@
OrxonoxOverlay::overlays_s.erase(this->getOldName());
if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
- COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
+ orxout(internal_warning) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << endl;
OrxonoxOverlay::overlays_s[this->getName()] = this;
}
@@ -361,12 +361,12 @@
if(overlay->isVisible())
{
overlay->hide();
- COUT(4) << "HIDE " << name << std::endl;
+ orxout(verbose, context::misc::overlays) << "HIDE " << name << endl;
}
else
{
overlay->show();
- COUT(4) << "SHOW " << name << std::endl;
+ orxout(verbose, context::misc::overlays) << "SHOW " << name << endl;
}
}
}
Modified: code/trunk/src/orxonox/pickup/PickupIdentifier.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupIdentifier.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/pickup/PickupIdentifier.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,7 +50,7 @@
RegisterRootObject(PickupIdentifier);
if(pickup == NULL)
- COUT(1) << "Error, PickupIdentifier was created without a valid Pickupable." << std::endl;
+ orxout(internal_error, context::pickups) << "PickupIdentifier was created without a valid Pickupable." << endl;
this->pickup_ = pickup;
}
@@ -82,7 +82,7 @@
// If the two have a different number of parameters then obviously something is very wrong.
if(!(this->parameters_.size() == identifier->parameters_.size()))
{
- COUT(1) << "Something went wrong in PickupIdentifier!" << std::endl;
+ orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
return this->parameters_.size()-identifier->parameters_.size();
}
@@ -92,7 +92,7 @@
// If a parameter present in one of the identifiers is not found in the other, once again, something is very wrong.
if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
{
- COUT(1) << "Something went wrong in PickupIdentifier!" << std::endl;
+ orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
return -1;
}
if(identifier->parameters_.find(it->first)->second != it->second)
@@ -114,11 +114,11 @@
*/
bool PickupIdentifier::addParameter(std::string & name, std::string & value)
{
- COUT(4) << "PickupIdentifier " << name << ", " << value << std::endl;
+ orxout(verbose, context::pickups) << "PickupIdentifier " << name << ", " << value << endl;
if(!(this->parameters_.find(name) == this->parameters_.end()))
{
- COUT(4) << "Request for adding a parameter that already exists for the PickupIdentififer was denied. name: '" << name << "', value: '" << value << "'."<< std::endl;
+ orxout(verbose, context::pickups) << "Request for adding a parameter that already exists for the PickupIdentififer was denied. name: '" << name << "', value: '" << value << "'."<< endl;
return false;
}
Modified: code/trunk/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/AmbientSound.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/sound/AmbientSound.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -93,7 +93,7 @@
if (fileInfo != NULL)
this->setSource(path);
else
- COUT(3) << "Sound: " << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << std::endl;
+ orxout(internal_warning, context::sound) << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << endl;
}
}
Modified: code/trunk/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/BaseSound.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/sound/BaseSound.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -93,7 +93,7 @@
alSourcePlay(this->audioSource_);
if (int error = alGetError())
- COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_error, context::sound) << "Error playing sound: " << SoundManager::getALErrorString(error) << endl;
}
}
@@ -146,19 +146,19 @@
alSource3f(this->audioSource_, AL_VELOCITY, 0, 0, 0);
alSource3f(this->audioSource_, AL_DIRECTION, 0, 0, 0);
if (ALint error = alGetError())
- COUT(2) << "Sound Warning: Setting source parameters to 0 failed: "
- << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_warning, context::sound) << "Setting source parameters to 0 failed: "
+ << SoundManager::getALErrorString(error) << endl;
assert(this->soundBuffer_ != NULL);
alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
if (ALuint error = alGetError())
- COUT(1) << "Sound Error: Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_error, context::sound) << "Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << endl;
}
void BaseSound::setVolume(float vol)
{
this->volume_ = clamp(vol, 0.0f, 1.0f);
if (this->volume_ != vol)
- COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl;
+ orxout(internal_warning, context::sound) << "Volume out of range, clamping value." << endl;
this->updateVolume();
}
@@ -169,8 +169,8 @@
float volume = this->volume_ * this->getRealVolume();
alSourcef(this->audioSource_, AL_GAIN, volume);
if (int error = alGetError())
- COUT(2) << "Sound: Error setting volume to " << volume
- << ": " << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_error, context::sound) << "Error setting volume to " << volume
+ << ": " << SoundManager::getALErrorString(error) << endl;
}
}
@@ -185,7 +185,7 @@
{
if (pitch > 2 || pitch < 0.5f)
{
- COUT(2) << "Sound warning: pitch out of range, cropping value." << std::endl;
+ orxout(internal_warning, context::sound) << "Pitch out of range, cropping value." << endl;
pitch = pitch > 2.0f ? 2.0f : pitch;
pitch = pitch < 0.5f ? 0.5f : pitch;
}
@@ -194,7 +194,7 @@
{
alSourcef(this->audioSource_, AL_PITCH, pitch);
if (int error = alGetError())
- COUT(2) << "Sound: Error setting pitch: " << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_error, context::sound) << "Error setting pitch: " << SoundManager::getALErrorString(error) << endl;
}
}
@@ -239,7 +239,7 @@
alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
if (ALuint error = alGetError())
{
- COUT(1) << "Sound Error: Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_error, context::sound) << "Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << endl;
return;
}
@@ -247,7 +247,7 @@
assert(this->isPlaying() || this->isPaused());
alSourcePlay(this->audioSource_);
if (int error = alGetError())
- COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_error, context::sound) << "Error playing sound: " << SoundManager::getALErrorString(error) << endl;
if (this->isPaused())
alSourcePause(this->audioSource_);
}
Modified: code/trunk/src/orxonox/sound/SoundBuffer.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundBuffer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/sound/SoundBuffer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,7 +50,7 @@
shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(filename);
if (fileInfo == NULL)
{
- COUT(2) << "Sound: Warning: Sound file '" << filename << "' not found" << std::endl;
+ orxout(internal_error, context::sound) << "Sound file '" << filename << "' not found" << endl;
return;
}
// Open data stream
@@ -143,7 +143,7 @@
int ret = ov_open_callbacks(dataStream.get(), &vf, NULL, 0, vorbisCallbacks);
if (ret < 0)
{
- COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
+ orxout(internal_error, context::sound) << "libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << endl;
ov_clear(&vf);
ThrowException(General, "Sound Error: Ogg file loader failed when opening the bitstream");
}
@@ -159,7 +159,7 @@
}
else if (ret < 0)
{
- COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+ orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
ov_clear(&vf);
ThrowException(General, "Sound Error: Ogg file loader failed when decoding the file");
}
Modified: code/trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/sound/SoundManager.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -70,6 +70,8 @@
{
RegisterRootObject(SoundManager);
+ orxout(user_status) << "Loading sound" << endl;
+
this->bDestructorCalled_ = false;
// See whether we even want to load
@@ -88,19 +90,19 @@
strcpy(device, devices);
std::string renderDevice;
SetConfigValue(renderDevice, std::string(device)).description("Sound device used for rendering");
- COUT(4) << "Sound: Available devices: ";
+ orxout(verbose, context::sound) << "Sound: Available devices: ";
while (true)
{
this->deviceNames_.push_back(devices);
- COUT(4) << '"' << devices << "\", ";
+ orxout(verbose, context::sound) << '"' << devices << "\", ";
devices += strlen(devices) + 1;
if (*devices == '\0')
break;
}
- COUT(4) << std::endl;
+ orxout(verbose, context::sound) << endl;
// Open the selected device
- COUT(3) << "Sound: Opening device \"" << renderDevice << '\' << std::endl;
+ orxout(internal_info, context::sound) << "Sound: Opening device \"" << renderDevice << '\' << endl;
this->device_ = alcOpenDevice(renderDevice.c_str());
*/
this->device_ = alcOpenDevice(NULL);
@@ -121,13 +123,13 @@
// Get some information about the sound
if (const char* version = alGetString(AL_VERSION))
- COUT(4) << "Sound: --- OpenAL Version: " << version << std::endl;
+ orxout(internal_info, context::sound) << "Sound: --- OpenAL Version: " << version << endl;
if (const char* vendor = alGetString(AL_VENDOR))
- COUT(4) << "Sound: --- OpenAL Vendor : " << vendor << std::endl;
+ orxout(internal_info, context::sound) << "Sound: --- OpenAL Vendor : " << vendor << endl;
if (const char* types = alutGetMIMETypes(ALUT_LOADER_BUFFER))
- COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl;
+ orxout(internal_info, context::sound) << "Sound: --- Supported MIME Types: " << types << endl;
else
- COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
+ orxout(internal_warning, context::sound) << "MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << endl;
this->mute_[SoundType::All] = 1.0f;
this->mute_[SoundType::Music] = 1.0f;
@@ -151,7 +153,7 @@
desroyContextGuard.Dismiss();
resetPlaysSoundGuard.Dismiss();
- COUT(4) << "Sound: Initialisation complete" << std::endl;
+ orxout(internal_status, context::sound) << "Sound: Initialisation complete" << endl;
}
SoundManager::~SoundManager()
@@ -163,14 +165,14 @@
// If there are still used buffers around, well, that's just very bad...
if (this->soundBuffers_.size() != this->effectsPool_.size())
- COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+ orxout(internal_error, context::sound) << "Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << endl;
// Empty buffer pool and buffer list
this->effectsPool_.clear();
this->soundBuffers_.clear();
// There should not be any sources in use anymore
if (!this->usedSoundSources_.empty())
- COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+ orxout(internal_error, context::sound) << "Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << endl;
while (!this->availableSoundSources_.empty())
{
alDeleteSources(1, &this->availableSoundSources_.back());
@@ -181,23 +183,23 @@
// Relieve context to destroy it
if (!alcMakeContextCurrent(NULL))
- COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;
+ orxout(internal_error, context::sound) << "Could not unset ALC context" << endl;
alcDestroyContext(this->context_);
if (ALCenum error = alcGetError(this->device_))
{
if (error == AL_INVALID_OPERATION)
- COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;
+ orxout(internal_error, context::sound) << "Could not destroy ALC context because it is the current one" << endl;
else
- COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;
+ orxout(internal_error, context::sound) << "Could not destroy ALC context because it is invalid" << endl;
}
#ifdef AL_VERSION_1_1
if (!alcCloseDevice(this->device_))
- COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
+ orxout(internal_error, context::sound) << "Could not destroy ALC device. This might be because there are still buffers in use!" << endl;
#else
alcCloseDevice(this->device_);
#endif
if (!alutExit())
- COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
+ orxout(internal_error, context::sound) << "Closing ALUT failed: " << alutGetErrorString(alutGetError()) << endl;
}
void SoundManager::setConfigValues()
@@ -243,7 +245,7 @@
{
if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
{
- COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
+ orxout(internal_warning, context::sound) << "Fade step out of range, ignoring change." << endl;
ResetConfigValue(crossFadeStep_);
}
}
@@ -252,7 +254,7 @@
{
float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
if (clampedVolume != this->volume_[type])
- COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
+ orxout(internal_warning, context::sound) << "Volume setting (" << type << ") out of range, clamping." << endl;
this->updateVolume(type);
}
@@ -320,7 +322,7 @@
ALenum error = alGetError();
if (error == AL_INVALID_VALUE)
// @TODO: Follow this constantly appearing, nerve-racking warning
- COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl;
+ orxout(internal_error, context::sound) << "OpenAL: Invalid listener position" << endl;
}
void SoundManager::setListenerOrientation(const Quaternion& orientation)
@@ -334,7 +336,7 @@
alListenerfv(AL_ORIENTATION, orient);
ALenum error = alGetError();
if (error == AL_INVALID_VALUE)
- COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
+ orxout(internal_error, context::sound) << "OpenAL: Invalid listener orientation" << endl;
}
void SoundManager::registerAmbientSound(AmbientSound* newAmbient)
@@ -345,7 +347,7 @@
{
if (it->first == newAmbient)
{
- COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
+ orxout(internal_warning, context::sound) << "Will not play an AmbientSound twice." << endl;
return;
}
}
@@ -519,7 +521,7 @@
}
catch (const std::exception& ex)
{
- COUT(1) << ex.what() << std::endl;
+ orxout(internal_error, context::sound) << ex.what() << endl;
return buffer;
}
this->soundBuffers_[filename] = buffer;
@@ -613,7 +615,7 @@
{
alDeleteSources(1, &this->availableSoundSources_.back());
if (alGetError())
- COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;
+ orxout(internal_error, context::sound) << "Failed to delete a source --> lost forever" << endl;
this->availableSoundSources_.pop_back();
}
}
Modified: code/trunk/src/orxonox/sound/SoundStreamer.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundStreamer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/sound/SoundStreamer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -50,7 +50,7 @@
int ret = ov_open_callbacks(dataStream.get(), &vf, NULL, 0, vorbisCallbacks);
if (ret < 0)
{
- COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
+ orxout(internal_error, context::sound) << "libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << endl;
ov_clear(&vf);
return;
}
@@ -76,7 +76,7 @@
}
else if (ret < 0)
{
- COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+ orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
ov_clear(&vf);
return;
}
@@ -90,16 +90,16 @@
int processed;
alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed);
if (ALint error = alGetError())
- COUT(2) << "Sound Warning: Couldn't get number of processed buffers: "
- << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_warning, context::sound) << "Couldn't get number of processed buffers: "
+ << SoundManager::getALErrorString(error) << endl;
if(processed > 0)
{
ALuint* buffers = new ALuint[processed];
alSourceUnqueueBuffers(audioSource, processed, buffers);
if (ALint error = alGetError())
- COUT(2) << "Sound Warning: Couldn't unqueue buffers: "
- << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_warning, context::sound) << "Couldn't unqueue buffers: "
+ << SoundManager::getALErrorString(error) << endl;
for(int i = 0; i < processed; i++)
{
@@ -110,7 +110,7 @@
}
else if (ret < 0)
{
- COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+ orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
ov_clear(&vf);
return;
}
@@ -120,8 +120,8 @@
alSourceQueueBuffers(audioSource, processed, buffers);
if (ALint error = alGetError())
- COUT(2) << "Sound Warning: Couldn't queue buffers: "
- << SoundManager::getALErrorString(error) << std::endl;
+ orxout(internal_warning, context::sound) << "Couldn't queue buffers: "
+ << SoundManager::getALErrorString(error) << endl;
}
}
}
Modified: code/trunk/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/WorldSound.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/sound/WorldSound.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -93,19 +93,19 @@
alSource3f(this->audioSource_, AL_POSITION, pos.x, pos.y, pos.z);
ALenum error = alGetError();
if (error == AL_INVALID_VALUE)
- COUT(2) << "Sound: OpenAL: Invalid sound position" << std::endl;
+ orxout(internal_error, context::sound) << "OpenAL: Invalid sound position" << endl;
const Vector3& vel = this->getVelocity();
alSource3f(this->audioSource_, AL_VELOCITY, vel.x, vel.y, vel.z);
error = alGetError();
if (error == AL_INVALID_VALUE)
- COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl;
+ orxout(internal_error, context::sound) << "OpenAL: Invalid sound velocity" << endl;
const Vector3& direction = -this->getWorldOrientation().zAxis();
alSource3f(this->audioSource_, AL_DIRECTION, direction.x, direction.y, direction.z);
error = alGetError();
if (error == AL_INVALID_VALUE)
- COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl;
+ orxout(internal_error, context::sound) << "OpenAL: Invalid sound direction" << endl;
}
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -187,7 +187,7 @@
if (identifier)
this->munitiontype_ = identifier;
else
- COUT(2) << "Warning: No munition class defined in WeaponMode " << this->getName() << std::endl;
+ orxout(internal_warning) << "No munition class defined in WeaponMode " << this->getName() << endl;
this->updateMunition();
}
@@ -248,7 +248,6 @@
Vector3 muzzleDirection;
muzzleDirection = target - this->muzzlePosition_;
-// COUT(0) << "muzzleDirection " << muzzleDirection << endl;
this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
}
else
Modified: code/trunk/src/orxonox/worldentities/BigExplosion.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/BigExplosion.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/BigExplosion.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -60,7 +60,7 @@
}
catch (const std::exception& ex)
{
- COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << ex.what() << std::endl;
+ orxout(internal_error) << "Couldn't load particle effect in BigExplosion: " << ex.what() << endl;
this->initZero();
}
}
Modified: code/trunk/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -456,7 +456,7 @@
this->xmlcontroller_->setControllableEntity(this);
}
else
- COUT(2) << "Warning: ControllableEntity \"" << this->getName() << "\" already has a Controller." << std::endl;
+ orxout(internal_warning) << "ControllableEntity \"" << this->getName() << "\" already has a Controller." << endl;
}
void ControllableEntity::parentChanged()
Modified: code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ExplosionChunk.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/ExplosionChunk.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -60,7 +60,7 @@
}
catch (const std::exception& ex)
{
- COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << ex.what() << std::endl;
+ orxout(internal_error) << "Couldn't load particle effect in ExplosionChunk: " << ex.what() << endl;
this->fire_ = 0;
this->smoke_ = 0;
}
Modified: code/trunk/src/orxonox/worldentities/MobileEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/MobileEntity.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/MobileEntity.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -188,7 +188,7 @@
{
if (type == WorldEntity::Static)
{
- CCOUT(1) << "Error: Cannot tell a MobileEntity to have static collision type! Ignoring." << std::endl;
+ orxout(internal_warning) << "Cannot tell a MobileEntity to have static collision type! Ignoring." << endl;
assert(false); // Only in debug mode
return false;
}
Modified: code/trunk/src/orxonox/worldentities/SpawnPoint.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/SpawnPoint.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/SpawnPoint.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -47,7 +47,7 @@
if (this->getGametype())
this->getGametype()->registerSpawnPoint(this);
else
- COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl;
+ orxout(internal_error) << "SpawnPoint has no Gametype" << endl;
this->setSyncMode(ObjectDirection::None);
}
Modified: code/trunk/src/orxonox/worldentities/StaticEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/StaticEntity.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/StaticEntity.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -62,7 +62,7 @@
{
if (this->addedToPhysicalWorld())
{
- CCOUT(2) << "Warning: Attempting to change the position of a StaticEntity at physics run time. Ignoring change." << std::endl;
+ orxout(internal_warning) << "Attempting to change the position of a StaticEntity at physics run time. Ignoring change." << endl;
return;
}
if (this->isStatic())
@@ -79,7 +79,7 @@
{
if (this->addedToPhysicalWorld())
{
- CCOUT(2) << "Warning: Attempting to change the orientation of a StaticEntity at physics run time. Ignoring change." << std::endl;
+ orxout(internal_warning) << "Attempting to change the orientation of a StaticEntity at physics run time. Ignoring change." << endl;
return;
}
if (this->isStatic())
@@ -96,7 +96,7 @@
{
if (type == WorldEntity::Kinematic || type == WorldEntity::Dynamic)
{
- CCOUT(1) << "Error: Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << std::endl;
+ orxout(internal_warning) << "Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << endl;
assert(false); // Only in debug mode
return false;
}
Modified: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -94,7 +94,7 @@
this->collisionShape_ = new WorldEntityCollisionShape(this);
this->collisionType_ = None;
this->collisionTypeSynchronised_ = None;
- this->mass_ = 0;
+ this->mass_ = 1.0f;
this->childrenMass_ = 0;
// Using bullet default values
this->restitution_ = 0;
@@ -310,12 +310,12 @@
this->collisionTypeSynchronised_ != Static &&
this->collisionTypeSynchronised_ != None)
{
- CCOUT(1) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << std::endl;
+ orxout(internal_error) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << endl;
}
else if (this->collisionTypeSynchronised_ != collisionType_)
{
if (this->parent_)
- CCOUT(2) << "Warning: Network connection tried to set the collision type of an attached WE. Ignoring." << std::endl;
+ orxout(internal_warning) << "Network connection tried to set the collision type of an attached WE. Ignoring." << endl;
else
this->setCollisionType(this->collisionTypeSynchronised_);
}
@@ -372,7 +372,7 @@
{
if (object == this)
{
- COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl;
+ orxout(internal_warning) << "Can't attach a WorldEntity to itself." << endl;
return;
}
@@ -405,22 +405,22 @@
{
if (!newParent->hasPhysics())
{
- COUT(2) << "Warning: Cannot attach a physical object to a non physical one." << std::endl;
+ orxout(internal_warning) << " Cannot attach a physical object to a non physical one." << endl;
return false;
}
else if (this->isDynamic())
{
- COUT(2) << "Warning: Cannot attach a dynamic object to a WorldEntity." << std::endl;
+ orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
return false;
}
else if (this->isKinematic() && newParent->isDynamic())
{
- COUT(2) << "Warning: Cannot attach a kinematic object to a dynamic one." << std::endl;
+ orxout(internal_warning) << "Cannot attach a kinematic object to a dynamic one." << endl;
return false;
}
else if (this->isKinematic())
{
- COUT(2) << "Warning: Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << std::endl;
+ orxout(internal_warning) << "Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << endl;
return false;
}
}
@@ -454,7 +454,7 @@
std::set<WorldEntity*>::iterator it = this->children_.find(object);
if (it == this->children_.end())
{
- CCOUT(2) << "Warning: Cannot detach an object that is not a child." << std::endl;
+ orxout(internal_warning) << "Cannot detach an object that is not a child." << endl;
return;
}
@@ -798,7 +798,7 @@
// If we are already attached to a parent, this would be a bad idea..
if (this->parent_)
{
- CCOUT(2) << "Warning: Cannot set the collision type of a WorldEntity with a parent." << std::endl;
+ orxout(internal_warning) << "Cannot set the collision type of a WorldEntity with a parent." << endl;
return;
}
@@ -821,7 +821,7 @@
// Check whether there was some scaling applied.
if (!this->node_->getScale().positionEquals(Vector3(1, 1, 1), 0.001))
{
- CCOUT(2) << "Warning: Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << std::endl;
+ orxout(internal_warning) << "Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << endl;
return;
}
HACK HACK HACK
@@ -967,10 +967,10 @@
// Just set everything to zero
this->physicalBody_->setMassProps(0.0f, btVector3(0, 0, 0));
}
- else if ((this->mass_ + this->childrenMass_) == 0.0f)
+ else if (totalMass == 0.0f)
{
// Use default values to avoid very large or very small values
- CCOUT(4) << "Warning: Setting the internal physical mass to 1.0 because mass_ is 0.0" << std::endl;
+ orxout(internal_warning) << "Setting the internal physical mass to 1.0 because mass_ is 0.0" << endl;
btVector3 inertia(0, 0, 0);
this->collisionShape_->calculateLocalInertia(1.0f, inertia);
this->physicalBody_->setMassProps(1.0f, inertia);
Modified: code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -131,7 +131,7 @@
{
if (type != WorldEntity::Dynamic)
{
- CCOUT(1) << "Error: Cannot tell a FpsPlayer not to be dynamic! Ignoring." << std::endl;
+ orxout(internal_warning) << "Cannot tell a FpsPlayer not to be dynamic! Ignoring." << endl;
assert(false); // Only in debug mode
return false;
}
Modified: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-08-22 13:55:43 UTC (rev 8857)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc 2011-08-22 22:45:53 UTC (rev 8858)
@@ -144,7 +144,7 @@
{
if (type != WorldEntity::Dynamic)
{
- CCOUT(1) << "Error: Cannot tell a SpaceShip not to be dynamic! Ignoring." << std::endl;
+ orxout(internal_warning) << "Cannot tell a SpaceShip not to be dynamic! Ignoring." << endl;
assert(false); // Only in debug mode
return false;
}
@@ -506,7 +506,7 @@
Camera *camera = this->getCamera();
if (camera == 0)
{
- COUT(2) << "Failed to reset camera!";
+ orxout(internal_warning) << "Failed to reset camera!" << endl;
return;
}
More information about the Orxonox-commit
mailing list