[Orxonox-commit 751] r3280 - in trunk: . cmake src/core src/core/input src/network src/network/packet src/network/synchronisable src/orxonox src/orxonox/gamestates src/orxonox/gui src/orxonox/interfaces src/orxonox/objects src/orxonox/objects/collisionshapes src/orxonox/objects/controllers src/orxonox/objects/gametypes src/orxonox/objects/infos src/orxonox/objects/items src/orxonox/objects/pickup src/orxonox/objects/quest src/orxonox/objects/weaponsystem/projectiles src/orxonox/objects/worldentities src/orxonox/objects/worldentities/pawns src/orxonox/objects/worldentities/triggers src/orxonox/overlays src/orxonox/overlays/console src/orxonox/overlays/hud src/orxonox/overlays/stats src/orxonox/sound src/orxonox/tools src/util
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Jul 12 23:58:03 CEST 2009
Author: rgrieder
Date: 2009-07-12 23:58:01 +0200 (Sun, 12 Jul 2009)
New Revision: 3280
Added:
trunk/src/util/RefToValue.h
trunk/src/util/ScopeGuard.h
trunk/src/util/StringUtils.cc
trunk/src/util/StringUtils.h
Removed:
trunk/src/util/String.cc
trunk/src/util/String.h
Modified:
trunk/
trunk/cmake/BuildConfigMSVC.cmake
trunk/src/core/ArgumentCompletionFunctions.cc
trunk/src/core/BaseObject.cc
trunk/src/core/CMakeLists.txt
trunk/src/core/CommandEvaluation.cc
trunk/src/core/CommandEvaluation.h
trunk/src/core/CommandExecutor.cc
trunk/src/core/CommandLine.cc
trunk/src/core/CommandLine.h
trunk/src/core/ConfigFileManager.cc
trunk/src/core/ConfigValueContainer.cc
trunk/src/core/ConfigValueIncludes.h
trunk/src/core/ConsoleCommand.h
trunk/src/core/Core.cc
trunk/src/core/Core.h
trunk/src/core/CorePrereqs.h
trunk/src/core/Executor.cc
trunk/src/core/Executor.h
trunk/src/core/Functor.h
trunk/src/core/Game.cc
trunk/src/core/Game.h
trunk/src/core/GameState.cc
trunk/src/core/GameState.h
trunk/src/core/IRC.cc
trunk/src/core/Identifier.cc
trunk/src/core/Language.cc
trunk/src/core/Language.h
trunk/src/core/LuaBind.cc
trunk/src/core/OrxonoxClass.cc
trunk/src/core/OrxonoxClass.h
trunk/src/core/Shell.cc
trunk/src/core/Shell.h
trunk/src/core/TclBind.cc
trunk/src/core/TclThreadManager.cc
trunk/src/core/input/Button.cc
trunk/src/core/input/Button.h
trunk/src/core/input/InputManager.cc
trunk/src/core/input/KeyBinder.cc
trunk/src/network/NetworkPrereqs.h
trunk/src/network/packet/Acknowledgement.cc
trunk/src/network/packet/Chat.cc
trunk/src/network/packet/ClassID.cc
trunk/src/network/packet/DeleteObjects.cc
trunk/src/network/packet/FunctionCalls.cc
trunk/src/network/packet/FunctionIDs.cc
trunk/src/network/packet/Gamestate.h
trunk/src/network/packet/Packet.cc
trunk/src/network/packet/Packet.h
trunk/src/network/packet/Welcome.cc
trunk/src/network/synchronisable/Synchronisable.cc
trunk/src/network/synchronisable/Synchronisable.h
trunk/src/network/synchronisable/SynchronisableVariable.h
trunk/src/orxonox/CMakeLists.txt
trunk/src/orxonox/CameraManager.cc
trunk/src/orxonox/GraphicsManager.cc
trunk/src/orxonox/GraphicsManager.h
trunk/src/orxonox/LevelManager.cc
trunk/src/orxonox/LevelManager.h
trunk/src/orxonox/Main.cc
trunk/src/orxonox/OrxonoxPrereqs.h
trunk/src/orxonox/gamestates/GSClient.cc
trunk/src/orxonox/gamestates/GSClient.h
trunk/src/orxonox/gamestates/GSDedicated.cc
trunk/src/orxonox/gamestates/GSDedicated.h
trunk/src/orxonox/gamestates/GSGraphics.cc
trunk/src/orxonox/gamestates/GSGraphics.h
trunk/src/orxonox/gamestates/GSIOConsole.cc
trunk/src/orxonox/gamestates/GSIOConsole.h
trunk/src/orxonox/gamestates/GSLevel.cc
trunk/src/orxonox/gamestates/GSLevel.h
trunk/src/orxonox/gamestates/GSMainMenu.cc
trunk/src/orxonox/gamestates/GSMainMenu.h
trunk/src/orxonox/gamestates/GSRoot.cc
trunk/src/orxonox/gamestates/GSRoot.h
trunk/src/orxonox/gamestates/GSServer.cc
trunk/src/orxonox/gamestates/GSServer.h
trunk/src/orxonox/gamestates/GSStandalone.cc
trunk/src/orxonox/gamestates/GSStandalone.h
trunk/src/orxonox/gui/GUIManager.cc
trunk/src/orxonox/gui/GUIManager.h
trunk/src/orxonox/interfaces/RadarViewable.cc
trunk/src/orxonox/interfaces/TeamColourable.h
trunk/src/orxonox/objects/GlobalShader.cc
trunk/src/orxonox/objects/Level.cc
trunk/src/orxonox/objects/Scene.cc
trunk/src/orxonox/objects/collisionshapes/BoxCollisionShape.cc
trunk/src/orxonox/objects/collisionshapes/CollisionShape.cc
trunk/src/orxonox/objects/collisionshapes/ConeCollisionShape.cc
trunk/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc
trunk/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc
trunk/src/orxonox/objects/controllers/ArtificialController.cc
trunk/src/orxonox/objects/gametypes/Gametype.h
trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
trunk/src/orxonox/objects/gametypes/UnderAttack.cc
trunk/src/orxonox/objects/infos/GametypeInfo.cc
trunk/src/orxonox/objects/infos/HumanPlayer.cc
trunk/src/orxonox/objects/infos/PlayerInfo.cc
trunk/src/orxonox/objects/items/Engine.cc
trunk/src/orxonox/objects/items/MultiStateEngine.cc
trunk/src/orxonox/objects/pickup/ModifierPickup.cc
trunk/src/orxonox/objects/pickup/ModifierPickup.h
trunk/src/orxonox/objects/pickup/ModifierType.h
trunk/src/orxonox/objects/pickup/PickupCollection.cc
trunk/src/orxonox/objects/pickup/PickupCollection.h
trunk/src/orxonox/objects/quest/GlobalQuest.cc
trunk/src/orxonox/objects/quest/GlobalQuest.h
trunk/src/orxonox/objects/quest/LocalQuest.cc
trunk/src/orxonox/objects/quest/LocalQuest.h
trunk/src/orxonox/objects/quest/Quest.cc
trunk/src/orxonox/objects/quest/Quest.h
trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc
trunk/src/orxonox/objects/quest/QuestEffectBeacon.h
trunk/src/orxonox/objects/quest/QuestHint.cc
trunk/src/orxonox/objects/quest/QuestHint.h
trunk/src/orxonox/objects/quest/QuestListener.cc
trunk/src/orxonox/objects/quest/QuestListener.h
trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.cc
trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.cc
trunk/src/orxonox/objects/worldentities/Backlight.cc
trunk/src/orxonox/objects/worldentities/BigExplosion.cc
trunk/src/orxonox/objects/worldentities/BigExplosion.h
trunk/src/orxonox/objects/worldentities/Billboard.cc
trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc
trunk/src/orxonox/objects/worldentities/Camera.cc
trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc
trunk/src/orxonox/objects/worldentities/ExplosionChunk.h
trunk/src/orxonox/objects/worldentities/FadingBillboard.cc
trunk/src/orxonox/objects/worldentities/Light.cc
trunk/src/orxonox/objects/worldentities/Light.h
trunk/src/orxonox/objects/worldentities/Model.cc
trunk/src/orxonox/objects/worldentities/MovableEntity.cc
trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc
trunk/src/orxonox/objects/worldentities/ParticleEmitter.h
trunk/src/orxonox/objects/worldentities/Planet.cc
trunk/src/orxonox/objects/worldentities/PongBall.cc
trunk/src/orxonox/objects/worldentities/StaticEntity.cc
trunk/src/orxonox/objects/worldentities/WorldEntity.cc
trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc
trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h
trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.cc
trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.h
trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
trunk/src/orxonox/overlays/OrxonoxOverlay.cc
trunk/src/orxonox/overlays/OverlayText.cc
trunk/src/orxonox/overlays/console/InGameConsole.cc
trunk/src/orxonox/overlays/hud/GametypeStatus.cc
trunk/src/orxonox/overlays/hud/HUDBar.cc
trunk/src/orxonox/overlays/hud/HUDHealthBar.cc
trunk/src/orxonox/overlays/hud/HUDNavigation.cc
trunk/src/orxonox/overlays/hud/HUDRadar.cc
trunk/src/orxonox/overlays/hud/HUDTimer.cc
trunk/src/orxonox/overlays/hud/PongScore.cc
trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc
trunk/src/orxonox/overlays/stats/CreateLines.cc
trunk/src/orxonox/overlays/stats/Stats.cc
trunk/src/orxonox/sound/SoundManager.cc
trunk/src/orxonox/sound/SoundManager.h
trunk/src/orxonox/tools/BillboardSet.cc
trunk/src/orxonox/tools/Mesh.cc
trunk/src/orxonox/tools/ParticleInterface.cc
trunk/src/orxonox/tools/ParticleInterface.h
trunk/src/orxonox/tools/TextureGenerator.cc
trunk/src/util/CMakeLists.txt
trunk/src/util/Convert.h
trunk/src/util/Exception.cc
trunk/src/util/Exception.h
trunk/src/util/Math.h
trunk/src/util/MultiType.cc
trunk/src/util/MultiType.h
trunk/src/util/MultiTypeValue.h
trunk/src/util/UtilPrereqs.h
Log:
Merged most of the core4 revisions back to the trunk except for:
- orxonox_cast
- all the radical changes in the input library
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/map:2802-3087,3090
/branches/miniprojects:2755-2825
/branches/netp2:2836-2989
/branches/netp3:2989-3083
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/particles:2830-3086
/branches/pch:3114-3195
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
+ /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/core4:3228,3235-3238,3243,3245-3251,3253-3255,3257,3260-3262,3265-3266,3269,3271,3278
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/map:2802-3087,3090
/branches/miniprojects:2755-2825
/branches/netp2:2836-2989
/branches/netp3:2989-3083
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/particles:2830-3086
/branches/pch:3114-3195
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128,2828-2916
/branches/pickups2:2108-2498,2916-3072
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
Modified: trunk/cmake/BuildConfigMSVC.cmake
===================================================================
--- trunk/cmake/BuildConfigMSVC.cmake 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/cmake/BuildConfigMSVC.cmake 2009-07-12 21:58:01 UTC (rev 3280)
@@ -34,7 +34,7 @@
######################## Options ########################
# Currently VLD has a problem with MSVC9 although it actually is supported
-IF(MSVC8)
+IF(MSVC80)
OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
ENDIF()
# Make sure the value is "on" or "off" for vld.ini
Modified: trunk/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- trunk/src/core/ArgumentCompletionFunctions.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/ArgumentCompletionFunctions.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,7 +33,7 @@
#include <boost/filesystem.hpp>
#include "util/Convert.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "Identifier.h"
#include "ConfigValueContainer.h"
#include "TclThreadManager.h"
@@ -142,7 +142,7 @@
ArgumentCompletionList threads;
for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
- threads.push_back(ArgumentCompletionListElement(getConvertedValue<unsigned int, std::string>(*it)));
+ threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
return threads;
}
Modified: trunk/src/core/BaseObject.cc
===================================================================
--- trunk/src/core/BaseObject.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/BaseObject.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -35,7 +35,7 @@
#include <tinyxml/tinyxml.h>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "CoreIncludes.h"
#include "Event.h"
#include "EventIncludes.h"
Modified: trunk/src/core/CMakeLists.txt
===================================================================
--- trunk/src/core/CMakeLists.txt 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CMakeLists.txt 2009-07-12 21:58:01 UTC (rev 3280)
@@ -67,7 +67,6 @@
FIND_HEADER_FILES
TOLUA_FILES
CommandExecutor.h
- Game.h
LuaBind.h
DEFINE_SYMBOL
"CORE_SHARED_BUILD"
Modified: trunk/src/core/CommandEvaluation.cc
===================================================================
--- trunk/src/core/CommandEvaluation.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CommandEvaluation.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -29,7 +29,7 @@
#include "CommandEvaluation.h"
#include "util/Debug.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "ConsoleCommand.h"
#include "Identifier.h"
@@ -38,7 +38,7 @@
CommandEvaluation::CommandEvaluation()
{
this->initialize("");
- this->state_ = CS_Uninitialized;
+ this->state_ = CommandState::Uninitialized;
}
void CommandEvaluation::initialize(const std::string& command)
@@ -63,7 +63,7 @@
this->argument_ = "";
this->errorMessage_ = "";
- this->state_ = CS_Empty;
+ this->state_ = CommandState::Empty;
}
bool CommandEvaluation::isValid() const
@@ -103,11 +103,11 @@
{
switch (this->state_)
{
- case CS_Uninitialized:
+ case CommandState::Uninitialized:
break;
- case CS_Empty:
+ case CommandState::Empty:
break;
- case CS_ShortcutOrIdentifier:
+ case CommandState::ShortcutOrIdentifier:
if (this->function_)
{
if (this->function_->getParamCount() == 0)
@@ -118,7 +118,7 @@
else if (this->functionclass_)
return (this->command_ = this->functionclass_->getName() + " ");
break;
- case CS_Function:
+ case CommandState::Function:
if (this->function_)
{
if (this->function_->getParamCount() == 0)
@@ -127,8 +127,8 @@
return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName() + " ");
}
break;
- case CS_ParamPreparation:
- case CS_Params:
+ case CommandState::ParamPreparation:
+ case CommandState::Params:
{
if (this->argument_ == "" && this->possibleArgument_ == "")
break;
@@ -148,9 +148,9 @@
return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + " " + this->argument_ + whitespace);
break;
}
- case CS_Finished:
+ case CommandState::Finished:
break;
- case CS_Error:
+ case CommandState::Error:
break;
}
}
@@ -162,10 +162,10 @@
{
switch (this->state_)
{
- case CS_Uninitialized:
+ case CommandState::Uninitialized:
break;
- case CS_Empty:
- case CS_ShortcutOrIdentifier:
+ case CommandState::Empty:
+ case CommandState::ShortcutOrIdentifier:
if (this->listOfPossibleFunctions_.size() == 0)
return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
else if (this->listOfPossibleIdentifiers_.size() == 0)
@@ -173,20 +173,20 @@
else
return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
break;
- case CS_Function:
+ case CommandState::Function:
return CommandEvaluation::dump(this->listOfPossibleFunctions_);
break;
- case CS_ParamPreparation:
- case CS_Params:
+ case CommandState::ParamPreparation:
+ case CommandState::Params:
if (this->listOfPossibleArguments_.size() > 0)
return CommandEvaluation::dump(this->listOfPossibleArguments_);
else
return CommandEvaluation::dump(this->function_);
- case CS_Finished:
+ case CommandState::Finished:
if (this->function_)
return CommandEvaluation::dump(this->function_);
break;
- case CS_Error:
+ case CommandState::Error:
return this->errorMessage_;
break;
}
@@ -199,7 +199,7 @@
this->bEvaluatedParams_ = false;
for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
- this->param_[i] = MT_null;
+ this->param_[i] = MT_Type::Null;
if (!this->isValid())
return;
@@ -229,7 +229,7 @@
if (index < MAX_FUNCTOR_ARGUMENTS)
return this->param_[index];
- return MT_null;
+ return MT_Type::Null;
}
bool CommandEvaluation::hasReturnvalue() const
@@ -237,7 +237,7 @@
if (this->function_)
return this->function_->hasReturnvalue();
- return MT_null;
+ return MT_Type::Null;
}
MultiType CommandEvaluation::getReturnvalue() const
Modified: trunk/src/core/CommandEvaluation.h
===================================================================
--- trunk/src/core/CommandEvaluation.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CommandEvaluation.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -40,17 +40,20 @@
namespace orxonox
{
- enum CommandState
+ namespace CommandState
{
- CS_Uninitialized,
- CS_Empty,
- CS_ShortcutOrIdentifier,
- CS_Function,
- CS_ParamPreparation,
- CS_Params,
- CS_Finished,
- CS_Error
- };
+ enum Value
+ {
+ Uninitialized,
+ Empty,
+ ShortcutOrIdentifier,
+ Function,
+ ParamPreparation,
+ Params,
+ Finished,
+ Error
+ };
+ }
class _CoreExport CommandEvaluation
{
@@ -111,7 +114,7 @@
std::string argument_;
std::string errorMessage_;
- CommandState state_;
+ CommandState::Value state_;
bool bEvaluatedParams_;
MultiType param_[5];
Modified: trunk/src/core/CommandExecutor.cc
===================================================================
--- trunk/src/core/CommandExecutor.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CommandExecutor.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -29,7 +29,7 @@
#include "CommandExecutor.h"
#include "util/Debug.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "ConsoleCommand.h"
#include "Identifier.h"
#include "Language.h"
@@ -140,7 +140,7 @@
void CommandExecutor::parseIfNeeded(const std::string& command)
{
- if (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)
+ if (CommandExecutor::getEvaluation().state_ == CommandState::Uninitialized)
{
CommandExecutor::parse(command);
}
@@ -168,12 +168,12 @@
switch (CommandExecutor::getEvaluation().state_)
{
- case CS_Uninitialized:
+ case CommandState::Uninitialized:
{
// Impossible
break;
}
- case CS_Empty:
+ case CommandState::Empty:
{
if (CommandExecutor::argumentsGiven() == 0)
{
@@ -183,11 +183,11 @@
}
else
{
- CommandExecutor::getEvaluation().state_ = CS_ShortcutOrIdentifier;
+ CommandExecutor::getEvaluation().state_ = CommandState::ShortcutOrIdentifier;
// Move on to next case
}
}
- case CS_ShortcutOrIdentifier:
+ case CommandState::ShortcutOrIdentifier:
{
if (CommandExecutor::argumentsGiven() > 1)
{
@@ -198,21 +198,21 @@
if (CommandExecutor::getEvaluation().function_)
{
// It's a shortcut
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
CommandExecutor::getEvaluation().functionclass_ = 0;
// Move on to next case
}
else if (CommandExecutor::getEvaluation().functionclass_)
{
// It's a functionname
- CommandExecutor::getEvaluation().state_ = CS_Function;
+ CommandExecutor::getEvaluation().state_ = CommandState::Function;
CommandExecutor::getEvaluation().function_ = 0;
// Move on to next case
}
else
{
// The first argument is bad
- CommandExecutor::getEvaluation().state_ = CS_Error;
+ CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
return;
@@ -237,7 +237,7 @@
// Unfinished shortcut
CommandExecutor::getEvaluation().bCommandChanged_ = true;
}
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
CommandExecutor::getEvaluation().functionclass_ = 0;
CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
@@ -257,7 +257,7 @@
// Unfinished classname
CommandExecutor::getEvaluation().bCommandChanged_ = true;
}
- CommandExecutor::getEvaluation().state_ = CS_Function;
+ CommandExecutor::getEvaluation().state_ = CommandState::Function;
CommandExecutor::getEvaluation().function_ = 0;
CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
// Move on to next case
@@ -265,7 +265,7 @@
else if (num_identifiers == 0 && num_functions == 0)
{
// No possibilities
- CommandExecutor::getEvaluation().state_ = CS_Error;
+ CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
return;
@@ -284,7 +284,7 @@
}
}
}
- case CS_Function:
+ case CommandState::Function:
{
if (CommandExecutor::getEvaluation().functionclass_)
{
@@ -297,13 +297,13 @@
if (CommandExecutor::getEvaluation().function_)
{
// It's a function
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
// Move on to next case
}
else
{
// The second argument is bad
- CommandExecutor::getEvaluation().state_ = CS_Error;
+ CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownsecondargument", "is not a function of");
CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknownsecondargument") + " " + CommandExecutor::getEvaluation().functionclass_->getName() + ".";
return;
@@ -325,7 +325,7 @@
// Unfinished function
CommandExecutor::getEvaluation().bCommandChanged_ = true;
}
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
{
@@ -337,7 +337,7 @@
else if (num_functions == 0)
{
// No possibilities
- CommandExecutor::getEvaluation().state_ = CS_Error;
+ CommandExecutor::getEvaluation().state_ = CommandState::Error;
AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
return;
@@ -354,14 +354,14 @@
}
else
{
- // There is no classname - move on to CS_ParamPreparation
+ // There is no classname - move on to CommandState::ParamPreparation
}
}
- case CS_ParamPreparation:
+ case CommandState::ParamPreparation:
{
if (CommandExecutor::getEvaluation().function_->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
{
- CommandExecutor::getEvaluation().state_ = CS_Finished;
+ CommandExecutor::getEvaluation().state_ = CommandState::Finished;
return;
}
else
@@ -371,7 +371,7 @@
argumentNumber -= 1;
CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
- CommandExecutor::getEvaluation().state_ = CS_Params;
+ CommandExecutor::getEvaluation().state_ = CommandState::Params;
if (CommandExecutor::getEvaluation().bCommandChanged_)
{
@@ -380,20 +380,20 @@
}
}
}
- case CS_Params:
+ case CommandState::Params:
{
if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
{
// There is exactly one possible argument
CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
return;
}
else if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 0)
{
// The user tries something new - we let him do
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
CommandExecutor::getEvaluation().argument_ = CommandExecutor::getLastArgument();
return;
}
@@ -408,16 +408,16 @@
CommandExecutor::getEvaluation().argument_ = CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleArguments_);
CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
- CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+ CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
return;
}
}
- case CS_Finished:
+ case CommandState::Finished:
{
// Nothing more to do
break;
}
- case CS_Error:
+ case CommandState::Error:
{
// Bad, very bad
break;
Modified: trunk/src/core/CommandLine.cc
===================================================================
--- trunk/src/core/CommandLine.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CommandLine.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -28,18 +28,20 @@
#include "CommandLine.h"
+#include <algorithm>
+#include <sstream>
#include <boost/filesystem.hpp>
#include "util/Convert.h"
#include "util/Debug.h"
#include "util/Exception.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "util/SubString.h"
#include "Core.h"
namespace orxonox
{
- SetCommandLineArgument(optionsFile, "start.ini").shortcut("o");
+ SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");
/**
@brief
@@ -48,9 +50,11 @@
Bools are treated specially. That is necessary
so that you can have simple command line switches.
*/
- void CommandLineArgument::parse(const std::string& value)
+ void CommandLineArgument::parse(const std::string& value, bool bParsingFile)
{
- if (value_.getType() == MT_bool)
+ if (bParsingFile && this->bCommandLineOnly_)
+ ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files.");
+ if (value_.getType() == MT_Type::Bool)
{
// simulate command line switch
bool temp;
@@ -65,9 +69,7 @@
this->value_ = true;
}
else
- {
ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
- }
}
else
{
@@ -125,105 +127,114 @@
@param arguments
Vector of space separated strings.
*/
- void CommandLine::_parse(const std::vector<std::string>& arguments)
+ void CommandLine::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
{
- // why this? See bFirstTimeParse_ declaration.
- if (bFirstTimeParse_)
+ try
{
- // first shove all the shortcuts in a map
- for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
- it != cmdLineArgs_.end(); ++it)
+ // why this? See bFirstTimeParse_ declaration.
+ if (bFirstTimeParse_)
{
- OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
- "Cannot have two command line shortcut with the same name.");
- if (it->second->getShortcut() != "")
- cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+ // first shove all the shortcuts in a map
+ for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+ it != cmdLineArgs_.end(); ++it)
+ {
+ OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+ "Cannot have two command line shortcut with the same name.");
+ if (it->second->getShortcut() != "")
+ cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+ }
+ bFirstTimeParse_ = false;
}
- bFirstTimeParse_ = false;
- }
- std::string name;
- std::string shortcut;
- std::string value;
- for (unsigned int i = 0; i < arguments.size(); ++i)
- {
- if (arguments[i].size() != 0)
+ std::string name;
+ std::string shortcut;
+ std::string value;
+ for (unsigned int i = 0; i < arguments.size(); ++i)
{
- // sure not ""
- if (arguments[i][0] == '-')
+ if (arguments[i].size() != 0)
{
- // start with "-"
- if (arguments[i].size() == 1)
+ // sure not ""
+ if (arguments[i][0] == '-')
{
- // argument[i] is "-", probably a minus sign
- value += "- ";
- }
- else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
- {
- // negative number as a value
- value += arguments[i] + " ";
- }
- else
- {
- // can be shortcut or full name argument
-
- // save old data first
- value = removeTrailingWhitespaces(value);
- if (name != "")
+ // start with "-"
+ if (arguments[i].size() == 1)
{
- checkFullArgument(name, value);
- name = "";
- assert(shortcut == "");
+ // argument[i] is "-", probably a minus sign
+ value += "- ";
}
- else if (shortcut != "")
+ else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
{
- checkShortcut(shortcut, value);
- shortcut = "";
- assert(name == "");
+ // negative number as a value
+ value += arguments[i] + " ";
}
+ else
+ {
+ // can be shortcut or full name argument
- if (arguments[i][1] == '-')
- {
- // full name argument with "--name"
- name = arguments[i].substr(2);
+ // save old data first
+ value = removeTrailingWhitespaces(value);
+ if (name != "")
+ {
+ checkFullArgument(name, value, bParsingFile);
+ name = "";
+ assert(shortcut == "");
+ }
+ else if (shortcut != "")
+ {
+ checkShortcut(shortcut, value, bParsingFile);
+ shortcut = "";
+ assert(name == "");
+ }
+
+ if (arguments[i][1] == '-')
+ {
+ // full name argument with "--name"
+ name = arguments[i].substr(2);
+ }
+ else
+ {
+ // shortcut with "-s"
+ shortcut = arguments[i].substr(1);
+ }
+
+ // reset value string
+ value = "";
}
- else
+ }
+ else
+ {
+ // value string
+
+ if (name == "" && shortcut == "")
{
- // shortcut with "-s"
- shortcut = arguments[i].substr(1);
+ ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
}
- // reset value string
- value = "";
+ // Concatenate strings as long as there's no new argument by "-" or "--"
+ value += arguments[i] + ' ';
}
}
- else
- {
- // value string
+ }
- if (name == "" && shortcut == "")
- {
- ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
- }
-
- // Concatenate strings as long as there's no new argument by "-" or "--"
- value += arguments[i] + ' ';
- }
+ // parse last argument
+ value = removeTrailingWhitespaces(value);
+ if (name != "")
+ {
+ checkFullArgument(name, value, bParsingFile);
+ assert(shortcut == "");
}
+ else if (shortcut != "")
+ {
+ checkShortcut(shortcut, value, bParsingFile);
+ assert(name == "");
+ }
}
-
- // parse last argument
- value = removeTrailingWhitespaces(value);
- if (name != "")
+ catch (const ArgumentException& ex)
{
- checkFullArgument(name, value);
- assert(shortcut == "");
+ COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;
+ COUT(0) << CommandLine::getUsageInformation() << std::endl;
+ throw GeneralException("");
}
- else if (shortcut != "")
- {
- checkShortcut(shortcut, value);
- assert(name == "");
- }
}
/**
@@ -234,13 +245,13 @@
@param value
String containing the value
*/
- void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
+ void CommandLine::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)
{
std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
if (it == cmdLineArgs_.end())
ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
- it->second->parse(value);
+ it->second->parse(value, bParsingFile);
}
/**
@@ -251,25 +262,49 @@
@param value
String containing the value
*/
- void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
+ void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)
{
std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
if (it == cmdLineArgsShortcut_.end())
ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
- it->second->parse(value);
+ it->second->parse(value, bParsingFile);
}
std::string CommandLine::getUsageInformation()
{
- CommandLine* inst = &_getInstance();
- std::string infoStr;
- for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin();
- it != inst->cmdLineArgs_.end(); ++it)
+ CommandLine& inst = _getInstance();
+ std::ostringstream infoStr;
+
+ // determine maximum name size
+ size_t maxNameSize = 0;
+ for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
+ it != inst.cmdLineArgs_.end(); ++it)
{
- infoStr += "[--" + it->second->getName() + " " + it->second->getInformation() + "] ";
+ maxNameSize = std::max(it->second->getName().size(), maxNameSize);
}
- return infoStr;
+
+ infoStr << "Usage: orxonox [options]" << std::endl;
+ infoStr << "Available options:" << std::endl;
+
+ for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
+ it != inst.cmdLineArgs_.end(); ++it)
+ {
+ if (it->second->getShortcut() != "")
+ infoStr << " [-" << it->second->getShortcut() << "] ";
+ else
+ infoStr << " ";
+ infoStr << "--" << it->second->getName() << " ";
+ if (it->second->getValue().getType() != MT_Type::Bool)
+ infoStr << "ARG ";
+ else
+ infoStr << " ";
+ // fill with the necessary amount of blanks
+ infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
+ infoStr << ": " << it->second->getInformation();
+ infoStr << std::endl;
+ }
+ return infoStr.str();
}
/**
@@ -294,16 +329,22 @@
/**
@brief
- Parses both command line and start.ini for CommandLineArguments.
+ Parses only the command line for CommandLineArguments.
*/
- void CommandLine::_parseAll(int argc, char** argv)
+ void CommandLine::_parseCommandLine(int argc, char** argv)
{
- // parse command line first
std::vector<std::string> args;
for (int i = 1; i < argc; ++i)
args.push_back(argv[i]);
- this->_parse(args);
+ this->_parse(args, false);
+ }
+ /**
+ @brief
+ Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
+ */
+ void CommandLine::_parseFile()
+ {
std::string filename = CommandLine::getValue("optionsFile").getString();
boost::filesystem::path filepath(Core::getConfigPath() / filename);
@@ -311,7 +352,7 @@
// They will not overwrite the arguments given directly
std::ifstream file;
file.open(filepath.string().c_str());
- args.clear();
+ std::vector<std::string> args;
if (file)
{
while (!file.eof())
@@ -331,14 +372,6 @@
file.close();
}
- try
- {
- _parse(args);
- }
- catch (orxonox::ArgumentException& ex)
- {
- COUT(1) << "An Exception occured while parsing " << filename << std::endl;
- throw(ex);
- }
+ _parse(args, true);
}
}
Modified: trunk/src/core/CommandLine.h
===================================================================
--- trunk/src/core/CommandLine.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CommandLine.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,10 +37,16 @@
#define SetCommandLineArgument(name, defaultValue) \
orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
- = orxonox::CommandLine::addArgument(#name, defaultValue)
+ = orxonox::CommandLine::addArgument(#name, defaultValue, false)
+#define SetCommandLineOnlyArgument(name, defaultValue) \
+ orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+ = orxonox::CommandLine::addArgument(#name, defaultValue, true)
#define SetCommandLineSwitch(name) \
orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
- = orxonox::CommandLine::addArgument(#name, false)
+ = orxonox::CommandLine::addArgument(#name, false, false)
+#define SetCommandLineOnlySwitch(name) \
+ orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
+ = orxonox::CommandLine::addArgument(#name, false, true)
namespace orxonox
@@ -73,7 +79,7 @@
const std::string& getName() const { return name_; }
//! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
- //! Evaluates to "" if none there is none.
+ //! Evaluates to "" if there is none.
const std::string& getShortcut() const { return shortcut_; }
//! Sets the shortcut for the argument
CommandLineArgument& shortcut(const std::string& shortcut)
@@ -92,11 +98,12 @@
private:
//! Constructor initialises both value_ and defaultValue_ with defaultValue.
- CommandLineArgument(const std::string& name, const MultiType& defaultValue)
+ CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
: bHasDefaultValue_(true)
, name_(name)
, value_(defaultValue)
, defaultValue_(defaultValue)
+ , bCommandLineOnly_(bCommandLineOnly)
{ }
//! Undefined copy constructor
@@ -104,7 +111,7 @@
~CommandLineArgument() { }
//! Parses the value string of a command line argument.
- void parse(const std::string& value);
+ void parse(const std::string& value, bool bParsingFile);
//! Tells whether the value has been changed by the command line.
bool bHasDefaultValue_;
@@ -114,8 +121,9 @@
std::string shortcut_; //!< Shortcut of the argument. @see getShortcut().
std::string usageInformation_; //!< Tells about the usage of this parameter
- MultiType value_; //!< The actual value
- MultiType defaultValue_; //!< Default value. Should not be changed.
+ MultiType value_; //!< The actual value
+ MultiType defaultValue_; //!< Default value. Should not be changed.
+ bool bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
};
@@ -133,7 +141,8 @@
public:
//! Parse redirection to internal member method.
- static void parseAll(int argc, char** argv) { _getInstance()._parseAll(argc, argv); }
+ static void parseCommandLine(int argc, char** argv) { _getInstance()._parseCommandLine(argc, argv); }
+ static void parseFile() { _getInstance()._parseFile(); }
static std::string getUsageInformation();
@@ -145,7 +154,7 @@
static MultiType getValue(const std::string& name)
{ return getArgument(name)->getValue(); }
template <class T>
- static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
+ static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
static bool existsArgument(const std::string& name)
{
@@ -164,10 +173,11 @@
static CommandLine& _getInstance();
- void _parseAll(int argc, char** argv);
- void _parse(const std::vector<std::string>& arguments);
- void checkFullArgument(const std::string& name, const std::string& value);
- void checkShortcut(const std::string& shortcut, const std::string& value);
+ void _parseCommandLine(int argc, char** argv);
+ void _parseFile();
+ void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
+ void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
+ void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
/**
Tells whether we parsed for the first time. The CommmandLineArguments are added before main().
@@ -198,12 +208,15 @@
Default value that is used when argument was not given.
*/
template <class T>
- CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue)
+ CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
{
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
+ << "Please use SetCommandLineSwitch and adjust your argument: " << name);
- return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
+ return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
}
}
Modified: trunk/src/core/ConfigFileManager.cc
===================================================================
--- trunk/src/core/ConfigFileManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/ConfigFileManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -32,7 +32,7 @@
#include "util/Convert.h"
#include "util/Math.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "ConsoleCommand.h"
#include "ConfigValueContainer.h"
#include "Core.h"
@@ -123,9 +123,9 @@
std::string ConfigFileEntryVectorValue::getFileEntry() const
{
if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
- return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]" + "=" + this->value_);
+ return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "=" + this->value_);
else
- return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]=" + this->value_ + " " + this->additionalComment_);
+ return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " " + this->additionalComment_);
}
Modified: trunk/src/core/ConfigValueContainer.cc
===================================================================
--- trunk/src/core/ConfigValueContainer.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/ConfigValueContainer.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -77,7 +77,7 @@
for (unsigned int i = 0; i < this->valueVector_.size(); i++)
{
- ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
+ ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
this->defvalueStringVector_.push_back(this->valueVector_[i]);
}
@@ -108,7 +108,7 @@
{
if (this->tset(input))
{
- ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string));
+ ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
return true;
}
}
@@ -127,7 +127,7 @@
{
if (this->tset(index, input))
{
- ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string));
+ ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
return true;
}
}
@@ -227,7 +227,7 @@
// Erase the entry from the vector, change (shift) all entries beginning with index in the config file, remove the last entry from the file
this->valueVector_.erase(this->valueVector_.begin() + index);
for (unsigned int i = index; i < this->valueVector_.size(); i++)
- ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
+ ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
return true;
@@ -263,7 +263,7 @@
void ConfigValueContainer::update()
{
if (!this->bIsVector_)
- this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string));
+ this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
else
{
this->valueVector_.clear();
@@ -272,11 +272,11 @@
{
if (i < this->defvalueStringVector_.size())
{
- this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string));
+ this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
}
else
{
- this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string));
+ this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
}
this->valueVector_.push_back(this->value_);
Modified: trunk/src/core/ConfigValueIncludes.h
===================================================================
--- trunk/src/core/ConfigValueIncludes.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/ConfigValueIncludes.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -51,7 +51,7 @@
orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
if (!container##varname) \
{ \
- container##varname = new orxonox::ConfigValueContainer(ConfigFileType::Settings, identifier##varname, identifier##varname->getName(), #varname, defvalue, varname); \
+ container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue, varname); \
identifier##varname->addConfigValueContainer(#varname, container##varname); \
} \
container##varname->getValue(&varname, this)
@@ -69,7 +69,7 @@
orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
if (!container##varname) \
{ \
- container##varname = new orxonox::ConfigValueContainer(ConfigFileType::Settings, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
+ container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
identifier##varname->addConfigValueContainer(#varname, container##varname); \
} \
container##varname->getValue(&varname, this)
Modified: trunk/src/core/ConsoleCommand.h
===================================================================
--- trunk/src/core/ConsoleCommand.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/ConsoleCommand.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -70,7 +70,7 @@
{
namespace AccessLevel
{
- enum Level
+ enum Value
{
None,
User,
@@ -105,9 +105,9 @@
inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
{ this->Executor::setDefaultValue(index, param); return (*this); }
- inline ConsoleCommand& accessLevel(AccessLevel::Level level)
+ inline ConsoleCommand& accessLevel(AccessLevel::Value level)
{ this->accessLevel_ = level; return (*this); }
- inline AccessLevel::Level getAccessLevel() const
+ inline AccessLevel::Value getAccessLevel() const
{ return this->accessLevel_; }
ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
@@ -129,9 +129,9 @@
return *this;
}
- inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
+ inline ConsoleCommand& keybindMode(KeybindMode::Value mode)
{ this->keybindMode_ = mode; return *this; }
- inline KeybindMode::Enum getKeybindMode() const
+ inline KeybindMode::Value getKeybindMode() const
{ return this->keybindMode_; }
inline ConsoleCommand& inputConfiguredParam(int index)
@@ -140,11 +140,11 @@
{ return this->inputConfiguredParam_; }
private:
- AccessLevel::Level accessLevel_;
+ AccessLevel::Value accessLevel_;
ArgumentCompleter* argumentCompleter_[5];
ArgumentCompletionList argumentList_;
- KeybindMode::Enum keybindMode_;
+ KeybindMode::Value keybindMode_;
int inputConfiguredParam_;
};
Modified: trunk/src/core/Core.cc
===================================================================
--- trunk/src/core/Core.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Core.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -76,49 +76,173 @@
namespace orxonox
{
- //! Path to the parent directory of the ones above if program was installed with relativ pahts
- static boost::filesystem::path rootPath_g;
- static boost::filesystem::path executablePath_g; //!< Path to the executable
- static boost::filesystem::path mediaPath_g; //!< Path to the media file folder
- static boost::filesystem::path configPath_g; //!< Path to the config file folder
- static boost::filesystem::path logPath_g; //!< Path to the log file folder
-
//! Static pointer to the singleton
Core* Core::singletonRef_s = 0;
- SetCommandLineArgument(mediaPath, "").information("PATH");
- SetCommandLineArgument(writingPathSuffix, "").information("DIR");
- SetCommandLineArgument(settingsFile, "orxonox.ini");
- SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
+ SetCommandLineArgument(mediaPath, "").information("Path to the media/data files");
+ SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
+ SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
+#ifdef ORXONOX_PLATFORM_WINDOWS
+ SetCommandLineArgument(limitToCPU, 0).information("Limits the program to one cpu/core (1, 2, 3, etc.). 0 turns it off (default)");
+#endif
- Core::Core()
+ /**
+ @brief
+ Helper class for the Core singleton: we cannot derive
+ Core from OrxonoxClass because we need to handle the Identifier
+ destruction in the Core destructor.
+ */
+ class CoreConfiguration : public OrxonoxClass
{
- RegisterRootObject(Core);
+ public:
+ CoreConfiguration()
+ {
+ }
- assert(Core::singletonRef_s == 0);
- Core::singletonRef_s = this;
- }
+ void initialise()
+ {
+ RegisterRootObject(CoreConfiguration);
+ this->setConfigValues();
- void Core::initialise(int argc, char** argv)
- {
- // Parse command line arguments fist
- try
+ // Possible media path override by the command line
+ if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
+ tsetMediaPath(CommandLine::getValue("mediaPath"));
+ }
+
+ /**
+ @brief Function to collect the SetConfigValue-macro calls.
+ */
+ void setConfigValues()
{
- CommandLine::parseAll(argc, argv);
+#ifdef NDEBUG
+ const unsigned int defaultLevelConsole = 1;
+ const unsigned int defaultLevelLogfile = 3;
+ const unsigned int defaultLevelShell = 1;
+#else
+ const unsigned int defaultLevelConsole = 3;
+ const unsigned int defaultLevelLogfile = 4;
+ const unsigned int defaultLevelShell = 3;
+#endif
+ SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
+ .description("The maximal level of debug output shown in the console")
+ .callback(this, &CoreConfiguration::debugLevelChanged);
+ SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
+ .description("The maximal level of debug output shown in the logfile")
+ .callback(this, &CoreConfiguration::debugLevelChanged);
+ SetConfigValue(softDebugLevelShell_, defaultLevelShell)
+ .description("The maximal level of debug output shown in the ingame shell")
+ .callback(this, &CoreConfiguration::debugLevelChanged);
+
+ SetConfigValue(language_, Language::getLanguage().defaultLanguage_)
+ .description("The language of the ingame text")
+ .callback(this, &CoreConfiguration::languageChanged);
+ SetConfigValue(bInitializeRandomNumberGenerator_, true)
+ .description("If true, all random actions are different each time you start the game")
+ .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
+
+ SetConfigValue(mediaPathString_, mediaPath_.string())
+ .description("Relative path to the game data.")
+ .callback(this, &CoreConfiguration::mediaPathChanged);
}
- catch (ArgumentException& ex)
+
+ /**
+ @brief Callback function if the debug level has changed.
+ */
+ void debugLevelChanged()
{
- COUT(1) << ex.what() << std::endl;
- COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
+ // softDebugLevel_ is the maximum of the 3 variables
+ this->softDebugLevel_ = this->softDebugLevelConsole_;
+ if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
+ this->softDebugLevel_ = this->softDebugLevelLogfile_;
+ if (this->softDebugLevelShell_ > this->softDebugLevel_)
+ this->softDebugLevel_ = this->softDebugLevelShell_;
+
+ OutputHandler::setSoftDebugLevel(OutputHandler::LD_All, this->softDebugLevel_);
+ OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
+ OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
+ OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell, this->softDebugLevelShell_);
}
- // 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
- // the timer though).
- int limitToCPU = CommandLine::getValue("limitToCPU");
- if (limitToCPU > 0)
- setThreadAffinity((unsigned int)limitToCPU);
+ /**
+ @brief Callback function if the language has changed.
+ */
+ void languageChanged()
+ {
+ // Read the translation file after the language was configured
+ Language::getLanguage().readTranslatedLanguageFile();
+ }
+ /**
+ @brief
+ Callback function if the media path has changed.
+ */
+ void mediaPathChanged()
+ {
+ mediaPath_ = boost::filesystem::path(this->mediaPathString_);
+ }
+
+ /**
+ @brief Sets the language in the config-file back to the default.
+ */
+ void resetLanguage()
+ {
+ ResetConfigValue(language_);
+ }
+
+ /**
+ @brief
+ Temporary sets the media path
+ @param path
+ The new media path
+ */
+ void tsetMediaPath(const std::string& path)
+ {
+ ModifyConfigValue(mediaPathString_, tset, path);
+ }
+
+ void initializeRandomNumberGenerator()
+ {
+ static bool bInitialized = false;
+ if (!bInitialized && this->bInitializeRandomNumberGenerator_)
+ {
+ srand(static_cast<unsigned int>(time(0)));
+ rand();
+ bInitialized = true;
+ }
+ }
+
+ int softDebugLevel_; //!< The debug level
+ int softDebugLevelConsole_; //!< The debug level for the console
+ int softDebugLevelLogfile_; //!< The debug level for the logfile
+ int softDebugLevelShell_; //!< The debug level for the ingame shell
+ std::string language_; //!< The language
+ bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called
+ std::string mediaPathString_; //!< Path to the data/media file folder as string
+
+ //! Path to the parent directory of the ones above if program was installed with relativ pahts
+ boost::filesystem::path rootPath_;
+ boost::filesystem::path executablePath_; //!< Path to the executable
+ boost::filesystem::path mediaPath_; //!< Path to the media file folder
+ boost::filesystem::path configPath_; //!< Path to the config file folder
+ boost::filesystem::path logPath_; //!< Path to the log file folder
+ };
+
+
+ Core::Core(int argc, char** argv)
+ {
+ if (singletonRef_s != 0)
+ {
+ COUT(0) << "Error: The Core singleton cannot be recreated! Shutting down." << std::endl;
+ abort();
+ }
+ Core::singletonRef_s = this;
+
+ // We need the variables very soon. But don't configure them yet!
+ this->configuration_ = new CoreConfiguration();
+
+ // Parse command line arguments first
+ CommandLine::parseCommandLine(argc, argv);
+
// Determine and set the location of the executable
setExecutablePath();
@@ -132,29 +256,35 @@
// 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(executablePath_g.string(), Core::getLogPathString() + "orxonox_crash.log");
+ this->signalHandler_->doCatch(configuration_->executablePath_.string(), Core::getLogPathString() + "orxonox_crash.log");
// Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
+ // Parse additional options file now that we know its path
+ CommandLine::parseFile();
+
+#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
+ // the timer though).
+ int limitToCPU = CommandLine::getValue("limitToCPU");
+ if (limitToCPU > 0)
+ setThreadAffinity(static_cast<unsigned int>(limitToCPU));
+#endif
+
// Manage ini files and set the default settings file (usually orxonox.ini)
this->configFileManager_ = new ConfigFileManager();
this->configFileManager_->setFilename(ConfigFileType::Settings,
CommandLine::getValue("settingsFile").getString());
+ // Required as well for the config values
this->languageInstance_ = new Language();
// Do this soon after the ConfigFileManager has been created to open up the
// possibility to configure everything below here
- this->setConfigValues();
+ this->configuration_->initialise();
- // Possible media path override by the command line
- if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
- {
- //std::string mediaPath = CommandLine::getValue("mediaPath");
- Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
- }
-
// Create the lua interface
this->luaBind_ = new LuaBind();
@@ -167,8 +297,6 @@
// creates the class hierarchy for all classes with factories
Factory::createClassHierarchy();
-
- this->loaded_ = true;
}
/**
@@ -176,12 +304,11 @@
*/
Core::~Core()
{
- this->loaded_ = false;
-
delete this->shell_;
delete this->tclThreadManager_;
delete this->tclBind_;
delete this->luaBind_;
+ delete this->configuration_;
delete this->languageInstance_;
delete this->configFileManager_;
@@ -189,93 +316,31 @@
CommandLine::destroyAllArguments();
// Also delete external console command that don't belong to an Identifier
CommandExecutor::destroyExternalCommands();
+ // Clean up class hierarchy stuff (identifiers, XMLPort, configValues, consoleCommand)
+ Identifier::destroyAllIdentifiers();
- assert(Core::singletonRef_s);
- Core::singletonRef_s = 0;
delete this->signalHandler_;
- }
- /**
- @brief Function to collect the SetConfigValue-macro calls.
- */
- void Core::setConfigValues()
- {
-#ifdef NDEBUG
- const unsigned int defaultLevelConsole = 1;
- const unsigned int defaultLevelLogfile = 3;
- const unsigned int defaultLevelShell = 1;
-#else
- const unsigned int defaultLevelConsole = 3;
- const unsigned int defaultLevelLogfile = 4;
- const unsigned int defaultLevelShell = 3;
-#endif
- SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
- .description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
- SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
- .description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
- SetConfigValue(softDebugLevelShell_, defaultLevelShell)
- .description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
-
- SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
- SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator);
-
- SetConfigValue(mediaPathString_, mediaPath_g.string())
- .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
+ // Don't assign singletonRef_s with NULL! Recreation is not supported
}
/**
- @brief Callback function if the debug level has changed.
- */
- void Core::debugLevelChanged()
- {
- // softDebugLevel_ is the maximum of the 3 variables
- this->softDebugLevel_ = this->softDebugLevelConsole_;
- if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
- this->softDebugLevel_ = this->softDebugLevelLogfile_;
- if (this->softDebugLevelShell_ > this->softDebugLevel_)
- this->softDebugLevel_ = this->softDebugLevelShell_;
-
- OutputHandler::setSoftDebugLevel(OutputHandler::LD_All, this->softDebugLevel_);
- OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
- OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
- OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell, this->softDebugLevelShell_);
- }
-
- /**
- @brief Callback function if the language has changed.
- */
- void Core::languageChanged()
- {
- // Read the translation file after the language was configured
- Language::getLanguage().readTranslatedLanguageFile();
- }
-
- /**
- @brief
- Callback function if the media path has changed.
- */
- void Core::mediaPathChanged()
- {
- mediaPath_g = boost::filesystem::path(this->mediaPathString_);
- }
-
- /**
- @brief Returns the softDebugLevel for the given device (returns a default-value if the class ist right about to be created).
+ @brief Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).
@param device The device
@return The softDebugLevel
*/
- int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
+ /*static*/ int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
{
switch (device)
{
case OutputHandler::LD_All:
- return Core::getInstance().softDebugLevel_;
+ return Core::getInstance().configuration_->softDebugLevel_;
case OutputHandler::LD_Console:
- return Core::getInstance().softDebugLevelConsole_;
+ return Core::getInstance().configuration_->softDebugLevelConsole_;
case OutputHandler::LD_Logfile:
- return Core::getInstance().softDebugLevelLogfile_;
+ return Core::getInstance().configuration_->softDebugLevelLogfile_;
case OutputHandler::LD_Shell:
- return Core::getInstance().softDebugLevelShell_;
+ return Core::getInstance().configuration_->softDebugLevelShell_;
default:
assert(0);
return 2;
@@ -287,94 +352,68 @@
@param device The device
@param level The level
*/
- void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
- {
+ /*static*/ void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
+ {
if (device == OutputHandler::LD_All)
- Core::getInstance().softDebugLevel_ = level;
+ Core::getInstance().configuration_->softDebugLevel_ = level;
else if (device == OutputHandler::LD_Console)
- Core::getInstance().softDebugLevelConsole_ = level;
+ Core::getInstance().configuration_->softDebugLevelConsole_ = level;
else if (device == OutputHandler::LD_Logfile)
- Core::getInstance().softDebugLevelLogfile_ = level;
+ Core::getInstance().configuration_->softDebugLevelLogfile_ = level;
else if (device == OutputHandler::LD_Shell)
- Core::getInstance().softDebugLevelShell_ = level;
+ Core::getInstance().configuration_->softDebugLevelShell_ = level;
OutputHandler::setSoftDebugLevel(device, level);
- }
+ }
/**
@brief Returns the configured language.
*/
- const std::string& Core::getLanguage()
+ /*static*/ const std::string& Core::getLanguage()
{
- return Core::getInstance().language_;
+ return Core::getInstance().configuration_->language_;
}
/**
@brief Sets the language in the config-file back to the default.
*/
- void Core::resetLanguage()
+ /*static*/ void Core::resetLanguage()
{
- Core::getInstance().resetLanguageIntern();
+ Core::getInstance().configuration_->resetLanguage();
}
- /**
- @brief Sets the language in the config-file back to the default.
- */
- void Core::resetLanguageIntern()
+ /*static*/ void Core::tsetMediaPath(const std::string& path)
{
- ResetConfigValue(language_);
+ getInstance().configuration_->tsetMediaPath(path);
}
- /**
- @brief
- Temporary sets the media path
- @param path
- The new media path
- */
- void Core::_tsetMediaPath(const std::string& path)
- {
- ModifyConfigValue(mediaPathString_, tset, path);
- }
-
/*static*/ const boost::filesystem::path& Core::getMediaPath()
{
- return mediaPath_g;
+ return getInstance().configuration_->mediaPath_;
}
/*static*/ std::string Core::getMediaPathString()
{
- return mediaPath_g.string() + '/';
+ return getInstance().configuration_->mediaPath_.string() + '/';
}
/*static*/ const boost::filesystem::path& Core::getConfigPath()
{
- return configPath_g;
+ return getInstance().configuration_->configPath_;
}
/*static*/ std::string Core::getConfigPathString()
{
- return configPath_g.string() + '/';
+ return getInstance().configuration_->configPath_.string() + '/';
}
/*static*/ const boost::filesystem::path& Core::getLogPath()
{
- return logPath_g;
+ return getInstance().configuration_->logPath_;
}
/*static*/ std::string Core::getLogPathString()
{
- return logPath_g.string() + '/';
+ return getInstance().configuration_->logPath_.string() + '/';
}
- void Core::initializeRandomNumberGenerator()
- {
- static bool bInitialized = false;
- if (!bInitialized && this->bInitializeRandomNumberGenerator_)
- {
- srand(static_cast<unsigned int>(time(0)));
- rand();
- bInitialized = true;
- }
- }
-
-
/**
@note
The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
@@ -387,10 +426,11 @@
*/
void Core::setThreadAffinity(int limitToCPU)
{
+#ifdef ORXONOX_PLATFORM_WINDOWS
+
if (limitToCPU <= 0)
return;
-#ifdef ORXONOX_PLATFORM_WINDOWS
unsigned int coreNr = limitToCPU - 1;
// Get the current process core mask
DWORD procMask;
@@ -464,9 +504,9 @@
buffer[ret] = 0;
#endif
- executablePath_g = boost::filesystem::path(buffer);
+ configuration_->executablePath_ = boost::filesystem::path(buffer);
#ifndef ORXONOX_PLATFORM_APPLE
- executablePath_g = executablePath_g.branch_path(); // remove executable name
+ configuration_->executablePath_ = configuration_->executablePath_.branch_path(); // remove executable name
#endif
}
@@ -480,33 +520,34 @@
*/
void Core::checkDevBuild()
{
- if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
+ if (boost::filesystem::exists(configuration_->executablePath_ / "orxonox_dev_build.keep_me"))
{
COUT(1) << "Running from the build tree." << std::endl;
Core::isDevBuild_ = true;
- mediaPath_g = ORXONOX_MEDIA_DEV_PATH;
- configPath_g = ORXONOX_CONFIG_DEV_PATH;
- logPath_g = ORXONOX_LOG_DEV_PATH;
+ configuration_->mediaPath_ = ORXONOX_MEDIA_DEV_PATH;
+ configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
+ configuration_->logPath_ = ORXONOX_LOG_DEV_PATH;
}
else
{
#ifdef INSTALL_COPYABLE // --> relative paths
// Also set the root path
boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
- rootPath_g = executablePath_g;
- while (!boost::filesystem::equivalent(rootPath_g / relativeExecutablePath, executablePath_g) && !rootPath_g.empty())
- rootPath_g = rootPath_g.branch_path();
- if (rootPath_g.empty())
+ configuration_->rootPath_ = configuration_->executablePath_;
+ while (!boost::filesystem::equivalent(configuration_->rootPath_ / relativeExecutablePath, configuration_->executablePath_)
+ && !configuration_->rootPath_.empty())
+ configuration_->rootPath_ = configuration_->rootPath_.branch_path();
+ if (configuration_->rootPath_.empty())
ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
// Using paths relative to the install prefix, complete them
- mediaPath_g = rootPath_g / ORXONOX_MEDIA_INSTALL_PATH;
- configPath_g = rootPath_g / ORXONOX_CONFIG_INSTALL_PATH;
- logPath_g = rootPath_g / ORXONOX_LOG_INSTALL_PATH;
+ configuration_->mediaPath_ = configuration_->rootPath_ / ORXONOX_MEDIA_INSTALL_PATH;
+ configuration_->configPath_ = configuration_->rootPath_ / ORXONOX_CONFIG_INSTALL_PATH;
+ configuration_->logPath_ = configuration_->rootPath_ / ORXONOX_LOG_INSTALL_PATH;
#else
// There is no root path, so don't set it at all
- mediaPath_g = ORXONOX_MEDIA_INSTALL_PATH;
+ configuration_->mediaPath_ = ORXONOX_MEDIA_INSTALL_PATH;
// Get user directory
# ifdef ORXONOX_PLATFORM_UNIX /* Apple? */
@@ -519,8 +560,8 @@
boost::filesystem::path userDataPath(userDataPathPtr);
userDataPath /= ".orxonox";
- configPath_g = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
- logPath_g = userDataPath / ORXONOX_LOG_INSTALL_PATH;
+ configuration_->configPath_ = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
+ configuration_->logPath_ = userDataPath / ORXONOX_LOG_INSTALL_PATH;
#endif
}
@@ -528,8 +569,8 @@
if (!CommandLine::getArgument("writingPathSuffix")->hasDefaultValue())
{
std::string directory(CommandLine::getValue("writingPathSuffix").getString());
- configPath_g = configPath_g / directory;
- logPath_g = logPath_g / directory;
+ configuration_->configPath_ = configuration_->configPath_ / directory;
+ configuration_->logPath_ = configuration_->logPath_ / directory;
}
}
@@ -543,8 +584,8 @@
void Core::createDirectories()
{
std::vector<std::pair<boost::filesystem::path, std::string> > directories;
- directories.push_back(std::make_pair(boost::filesystem::path(configPath_g), "config"));
- directories.push_back(std::make_pair(boost::filesystem::path(logPath_g), "log"));
+ directories.push_back(std::make_pair(boost::filesystem::path(configuration_->configPath_), "config"));
+ directories.push_back(std::make_pair(boost::filesystem::path(configuration_->logPath_), "log"));
for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
it != directories.end(); ++it)
Modified: trunk/src/core/Core.h
===================================================================
--- trunk/src/core/Core.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Core.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,11 +42,12 @@
#include "CorePrereqs.h"
#include <cassert>
-#include "OrxonoxClass.h"
#include "util/OutputHandler.h"
namespace orxonox
{
+ class CoreConfiguration;
+
/**
@brief
The Core class is a singleton used to configure the program basics.
@@ -54,7 +55,7 @@
The class provides information about the media, config and log path.
It determines those by the use of platform specific functions.
*/
- class _CoreExport Core : public OrxonoxClass
+ class _CoreExport Core
{
public:
/**
@@ -64,10 +65,9 @@
@throws
GeneralException
*/
- Core();
+ Core(int argc, char** argv);
~Core();
- void initialise(int argc, char** argv);
void setConfigValues();
void update(const Clock& time);
@@ -79,8 +79,7 @@
static const std::string& getLanguage();
static void resetLanguage();
- static void tsetMediaPath(const std::string& path)
- { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
+ static void tsetMediaPath(const std::string& path);
//! Returns the path to the config files as boost::filesystem::path
static const boost::filesystem::path& getMediaPath();
//! Returns the path to the config files as boost::filesystem::path
@@ -102,13 +101,6 @@
void createDirectories();
void setThreadAffinity(int limitToCPU);
- void resetLanguageIntern();
- void initializeRandomNumberGenerator();
- void debugLevelChanged();
- void languageChanged();
- void mediaPathChanged();
- void _tsetMediaPath(const std::string& path);
-
// Singletons
ConfigFileManager* configFileManager_;
Language* languageInstance_;
@@ -118,15 +110,8 @@
TclBind* tclBind_;
TclThreadManager* tclThreadManager_;
- int softDebugLevel_; //!< The debug level
- int softDebugLevelConsole_; //!< The debug level for the console
- int softDebugLevelLogfile_; //!< The debug level for the logfile
- int softDebugLevelShell_; //!< The debug level for the ingame shell
- std::string language_; //!< The language
- bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called
- std::string mediaPathString_; //!< Path to the data/media file folder as string
bool isDevBuild_; //!< True for builds in the build directory (not installed)
- bool loaded_; //!< Only true if constructor was interrupted
+ CoreConfiguration* configuration_;
static Core* singletonRef_s;
};
Modified: trunk/src/core/CorePrereqs.h
===================================================================
--- trunk/src/core/CorePrereqs.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/CorePrereqs.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -73,7 +73,7 @@
namespace KeybindMode
{
- enum Enum
+ enum Value
{
OnPress,
OnHold,
@@ -164,6 +164,7 @@
// game states
class Game;
+ struct GameStateConstrParams;
class GameState;
struct GameStateTreeNode;
Modified: trunk/src/core/Executor.cc
===================================================================
--- trunk/src/core/Executor.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Executor.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -98,15 +98,15 @@
return false;
// assign all given arguments to the multitypes
- for (unsigned int i = 0; i < min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+ for (unsigned int i = 0; i < std::min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
param[i] = tokens[i];
// fill the remaining multitypes with default values
- for (unsigned int i = tokens.size(); i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+ for (unsigned int i = tokens.size(); i < std::min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
param[i] = this->defaultValue_[i];
// evaluate the param types through the functor
- for (unsigned int i = 0; i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+ for (unsigned int i = 0; i < std::min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
this->functor_->evaluateParam(i, param[i]);
return true;
Modified: trunk/src/core/Executor.h
===================================================================
--- trunk/src/core/Executor.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Executor.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -32,9 +32,12 @@
#include "CorePrereqs.h"
+#include <algorithm>
+#include <string>
+
#include "util/Debug.h"
#include "util/Math.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "util/SubString.h"
#include "Functor.h"
@@ -100,7 +103,7 @@
} \
COUT(5) << tokens[i]; \
} \
- COUT(5) << ") and " << max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
+ COUT(5) << ") and " << std::max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
for (unsigned int i = tokens.size(); i < paramCount; i++) \
{ \
param[i] = this->defaultValue_[i]; \
@@ -174,7 +177,7 @@
{ return this->functor_->getParamCount(); }
inline bool hasReturnvalue() const
{ return this->functor_->hasReturnvalue(); }
- inline FunctionType getType() const
+ inline FunctionType::Value getType() const
{ return this->functor_->getType(); }
inline const MultiType& getReturnvalue() const
{ return this->functor_->getReturnvalue(); }
@@ -200,7 +203,7 @@
if (index < MAX_FUNCTOR_ARGUMENTS)
return this->defaultValue_[index];
- return MT_null;
+ return MT_Type::Null;
}
bool allDefaultValuesSet() const;
Modified: trunk/src/core/Functor.h
===================================================================
--- trunk/src/core/Functor.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Functor.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -34,18 +34,21 @@
#include "util/Debug.h"
#include "util/MultiType.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
namespace orxonox
{
const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
- enum FunctionType
+ namespace FunctionType
{
- FT_MEMBER,
- FT_CONSTMEMBER,
- FT_STATIC
- };
+ enum Value
+ {
+ Member,
+ ConstMember,
+ Static
+ };
+ }
template <class T>
@@ -97,11 +100,11 @@
Functor() {}
virtual ~Functor() {}
- virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+ virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
inline unsigned int getParamCount() const { return this->numParams_; }
inline bool hasReturnvalue() const { return this->hasReturnValue_; }
- inline FunctionType getType() const { return this->type_; }
+ inline FunctionType::Value getType() const { return this->type_; }
inline const MultiType& getReturnvalue() const { return this->returnedValue_; }
const std::string& getTypenameParam(unsigned int param) const { return (param < 5) ? this->typeParam_[param] : BLANKSTRING; }
@@ -112,7 +115,7 @@
protected:
unsigned int numParams_;
bool hasReturnValue_;
- FunctionType type_;
+ FunctionType::Value type_;
MultiType returnedValue_;
std::string typeReturnvalue_;
@@ -123,7 +126,7 @@
{
public:
virtual ~FunctorStatic() {}
- virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+ virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
};
template <class T>
@@ -138,10 +141,10 @@
}
virtual ~FunctorMember() {}
- virtual void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
- virtual void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+ virtual void operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
+ virtual void operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
- virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null)
+ virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
{
if (this->bConstObject_)
{
@@ -321,14 +324,14 @@
{ \
this->numParams_ = numparams; \
this->hasReturnValue_ = returnvalue; \
- this->type_ = FT_STATIC; \
+ this->type_ = FunctionType::Static; \
this->functionPointer_ = functionPointer; \
\
FUNCTOR_TYPENAME_PARAMS(numparams); \
FUNCTOR_TYPENAME_RETURN(returnvalue); \
} \
\
- void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+ void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
{ \
FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
} \
@@ -362,16 +365,16 @@
{ \
this->numParams_ = numparams; \
this->hasReturnValue_ = returnvalue; \
- this->type_ = FT_MEMBER; \
+ this->type_ = FunctionType::Member; \
this->functionPointer_ = functionPointer; \
} \
\
- void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+ void operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
{ \
FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
} \
\
- void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+ void operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
{ \
COUT(1) << "An error occurred in Functor.h:" << std::endl; \
COUT(1) << "Error: Function is not const." << std::endl; \
@@ -395,16 +398,16 @@
{ \
this->numParams_ = numparams; \
this->hasReturnValue_ = returnvalue; \
- this->type_ = FT_CONSTMEMBER; \
+ this->type_ = FunctionType::ConstMember; \
this->functionPointer_ = functionPointer; \
} \
\
- void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+ void operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
{ \
FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
} \
\
- void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+ void operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
{ \
FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
} \
Modified: trunk/src/core/Game.cc
===================================================================
--- trunk/src/core/Game.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Game.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -57,27 +57,69 @@
{ Game::getInstance().stop(); }
SetConsoleCommandShortcutExternAlias(stop_game, "exit");
- struct _CoreExport GameStateTreeNode
+ std::map<std::string, Game::GameStateInfo> Game::gameStateDeclarations_s;
+ Game* Game::singletonRef_s = 0;
+
+
+ /**
+ @brief
+ Represents one node of the game state tree.
+ */
+ struct GameStateTreeNode
{
GameState* state_;
weak_ptr<GameStateTreeNode> parent_;
std::vector<shared_ptr<GameStateTreeNode> > children_;
};
- std::map<std::string, GameState*> Game::allStates_s;
- Game* Game::singletonRef_s = 0;
/**
@brief
+ Another helper class for the Game singleton: we cannot derive
+ Game from OrxonoxClass because we need to handle the Identifier
+ destruction in the Core destructor.
+ */
+ class GameConfiguration : public OrxonoxClass
+ {
+ public:
+ GameConfiguration()
+ {
+ RegisterRootObject(GameConfiguration);
+ this->setConfigValues();
+ }
+
+ void setConfigValues()
+ {
+ SetConfigValue(statisticsRefreshCycle_, 250000)
+ .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+ SetConfigValue(statisticsAvgLength_, 1000000)
+ .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
+ }
+
+ unsigned int statisticsRefreshCycle_;
+ unsigned int statisticsAvgLength_;
+ };
+
+
+ /**
+ @brief
Non-initialising constructor.
*/
Game::Game(int argc, char** argv)
{
- assert(singletonRef_s == 0);
+ if (singletonRef_s != 0)
+ {
+ COUT(0) << "Error: The Game singleton cannot be recreated! Shutting down." << std::endl;
+ abort();
+ }
singletonRef_s = this;
- this->abort_ = false;
+ this->bAbort_ = false;
+ bChangingState_ = false;
+ // Create an empty root state
+ declareGameState<GameState>("GameState", "emptyRootGameState", true, false);
+
// reset statistics
this->statisticsStartTime_ = 0;
this->statisticsTickTimes_.clear();
@@ -86,15 +128,30 @@
this->avgFPS_ = 0.0f;
this->avgTickTime_ = 0.0f;
-
// Set up a basic clock to keep time
this->gameClock_ = new Clock();
- this->core_ = new orxonox::Core();
- this->core_->initialise(argc, argv);
+ // Create the Core
+ this->core_ = new Core(argc, argv);
- RegisterRootObject(Game);
- this->setConfigValues();
+ // After the core has been created, we can safely instantiate the GameStates
+ for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
+ it != gameStateDeclarations_s.end(); ++it)
+ {
+ // Only create the states appropriate for the game mode
+ //if (GameMode::showsGraphics || !it->second.bGraphicsMode)
+ GameStateConstrParams params = { it->second.stateName, it->second.bIgnoreTickTime };
+ gameStates_[getLowercase(it->second.stateName)] = GameStateFactory::fabricate(it->second.className, params);
+ }
+
+ // The empty root state is ALWAYS loaded!
+ this->rootStateNode_ = shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
+ this->rootStateNode_->state_ = getState("emptyRootGameState");
+ this->activeStateNode_ = this->rootStateNode_;
+ this->activeStates_.push_back(this->rootStateNode_->state_);
+
+ // Do this after the Core creation!
+ this->configuration_ = new GameConfiguration();
}
/**
@@ -102,40 +159,24 @@
*/
Game::~Game()
{
- // Destroy pretty much everyhting left
+ // Destroy the configuration helper class instance
+ delete this->configuration_;
+
+ // Destroy the GameStates (note that the nodes still point to them, but doesn't matter)
+ for (std::map<std::string, GameState*>::const_iterator it = gameStates_.begin();
+ it != gameStates_.end(); ++it)
+ delete it->second;
+
+ // Destroy the Core and with it almost everything
delete this->core_;
-
delete this->gameClock_;
- assert(singletonRef_s);
- singletonRef_s = 0;
- }
+ // Take care of the GameStateFactories
+ GameStateFactory::destroyFactories();
- void Game::setConfigValues()
- {
- SetConfigValue(statisticsRefreshCycle_, 250000)
- .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
- SetConfigValue(statisticsAvgLength_, 1000000)
- .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
- SetConfigValue(levelName_, "presentation_dm.oxw")
- .description("Sets the preselection of the level in the main menu.");
+ // Don't assign singletonRef_s with NULL! Recreation is not supported
}
- void Game::setLevel(std::string levelName)
- {
- ModifyConfigValue(levelName_, set, levelName);
- }
-
- std::string Game::getLevel()
- {
- std::string levelName;
- CommandLine::getValue("level", &levelName);
- if (levelName == "")
- return levelName_;
- else
- return levelName;
- }
-
/**
@brief
Main loop of the orxonox game.
@@ -146,63 +187,110 @@
*/
void Game::run()
{
- // Always start with the ROOT state
- this->requestedStateNodes_.push_back(this->rootStateNode_);
- this->activeStateNode_ = this->rootStateNode_;
- this->loadState(this->rootStateNode_->state_);
+ if (this->requestedStateNodes_.empty())
+ COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
// START GAME
this->gameClock_->capture(); // first delta time should be about 0 seconds
- while (!this->abort_ && !this->activeStates_.empty())
+ while (!this->bAbort_ && (!this->activeStates_.empty() || this->requestedStateNodes_.size() > 0))
{
this->gameClock_->capture();
uint64_t currentTime = this->gameClock_->getMicroseconds();
// STATISTICS
- statisticsTickInfo tickInfo = {currentTime, 0};
+ StatisticsTickInfo tickInfo = {currentTime, 0};
statisticsTickTimes_.push_back(tickInfo);
this->periodTime_ += this->gameClock_->getDeltaTimeMicroseconds();
// UPDATE STATE STACK
- while (this->requestedStateNodes_.size() > 1)
+ while (this->requestedStateNodes_.size() > 0)
{
- // Note: this->requestedStateNodes_.front() is the currently active state node
- std::vector<shared_ptr<GameStateTreeNode> >::iterator it = this->requestedStateNodes_.begin() + 1;
- if (*it == this->activeStateNode_->parent_.lock())
+ shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();
+ assert(this->activeStateNode_);
+ if (!this->activeStateNode_->parent_.expired() && requestedStateNode == this->activeStateNode_->parent_.lock())
this->unloadState(this->activeStateNode_->state_);
else // has to be child
- this->loadState((*it)->state_);
- this->activeStateNode_ = *it;
+ {
+ try
+ {
+ this->loadState(requestedStateNode->state_);
+ }
+ catch (const std::exception& ex)
+ {
+ COUT(1) << "Error: Loading GameState '" << requestedStateNode->state_->getName() << "' failed: " << ex.what() << std::endl;
+ // All scheduled operations have now been rendered inert --> flush them and issue a warning
+ if (this->requestedStateNodes_.size() > 1)
+ COUT(1) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
+ this->requestedStateNodes_.clear();
+ break;
+ }
+ }
+ this->activeStateNode_ = requestedStateNode;
this->requestedStateNodes_.erase(this->requestedStateNodes_.begin());
}
- // UPDATE, bottom to top in the stack
- this->core_->update(*this->gameClock_);
- for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin();
+ // UPDATE, Core first
+ try
+ {
+ this->core_->update(*this->gameClock_);
+ }
+ catch (...)
+ {
+ COUT(0) << "An exception occured while ticking the Core. This should really never happen!" << std::endl;
+ COUT(0) << "Closing the program." << std::endl;
+ this->stop();
+ break;
+ }
+
+ // UPDATE, GameStates bottom to top in the stack
+ // Note: The first element is the empty root state, which doesn't need ticking
+ for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin() + 1;
it != this->activeStates_.end(); ++it)
{
- // Add tick time for most of the states
- uint64_t timeBeforeTick;
- if ((*it)->getCountTickTime())
- timeBeforeTick = this->gameClock_->getRealMicroseconds();
-
- (*it)->update(*this->gameClock_);
+ bool threwException = false;
+ try
+ {
+ // Add tick time for most of the states
+ uint64_t timeBeforeTick;
+ if (!(*it)->ignoreTickTime())
+ timeBeforeTick = this->gameClock_->getRealMicroseconds();
+ (*it)->update(*this->gameClock_);
+ if (!(*it)->ignoreTickTime())
+ this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
+ }
+ catch (const std::exception& ex)
+ {
+ threwException = true;
+ COUT(0) << "Exception while ticking: " << ex.what() << std::endl;
+ }
+ catch (...)
+ {
+ threwException = true;
+ }
+ if (threwException)
+ {
+ COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl;
+ COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
+ if ((*it)->getParent() != NULL)
+ this->requestState((*it)->getParent()->getName());
+ else
+ this->stop();
+ break;
+ }
- if ((*it)->getCountTickTime())
- this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
}
// STATISTICS
- if (this->periodTime_ > statisticsRefreshCycle_)
+ if (this->periodTime_ > this->configuration_->statisticsRefreshCycle_)
{
- std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
+ std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
assert(it != this->statisticsTickTimes_.end());
- int64_t lastTime = currentTime - this->statisticsAvgLength_;
+ int64_t lastTime = currentTime - this->configuration_->statisticsAvgLength_;
if ((int64_t)it->tickTime < lastTime)
{
do
{
- assert(this->periodTickTime_ > it->tickLength);
+ assert(this->periodTickTime_ >= it->tickLength);
this->periodTickTime_ -= it->tickLength;
++it;
assert(it != this->statisticsTickTimes_.end());
@@ -214,20 +302,20 @@
this->avgFPS_ = static_cast<float>(framesPerPeriod) / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0f;
this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
- this->periodTime_ -= this->statisticsRefreshCycle_;
+ this->periodTime_ -= this->configuration_->statisticsRefreshCycle_;
}
}
// UNLOAD all remaining states
- while (!this->activeStates_.empty())
+ while (this->activeStates_.size() > 1)
this->unloadState(this->activeStates_.back());
- this->activeStateNode_.reset();
+ this->activeStateNode_ = this->rootStateNode_;
this->requestedStateNodes_.clear();
}
void Game::stop()
{
- this->abort_ = true;
+ this->bAbort_ = true;
}
void Game::addTickTime(uint32_t length)
@@ -243,15 +331,20 @@
void Game::requestState(const std::string& name)
{
GameState* state = this->getState(name);
- if (state == NULL || this->activeStateNode_ == NULL)
+ if (state == NULL)
return;
- shared_ptr<GameStateTreeNode> requestedNode;
+ //if (this->bChangingState_)
+ //{
+ // COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
+ // return;
+ //}
- // this->requestedStateNodes_.back() is the currently active state
- shared_ptr<GameStateTreeNode> lastRequestedNode = this->requestedStateNodes_.back();
-
- // Already the active node?
+ shared_ptr<GameStateTreeNode> lastRequestedNode;
+ if (this->requestedStateNodes_.empty())
+ lastRequestedNode = this->activeStateNode_;
+ else
+ lastRequestedNode = this->requestedStateNodes_.back();
if (state == lastRequestedNode->state_)
{
COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;
@@ -259,28 +352,33 @@
}
// Check children first
+ std::vector<shared_ptr<GameStateTreeNode> > requestedNodes;
for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
{
if (lastRequestedNode->children_[i]->state_ == state)
{
- requestedNode = lastRequestedNode->children_[i];
+ requestedNodes.push_back(lastRequestedNode->children_[i]);
break;
}
}
- // Check parent and all its grand parents
- shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
- while (requestedNode == NULL && currentNode != NULL)
+ if (requestedNodes.empty())
{
- if (currentNode->state_ == state)
- requestedNode = currentNode;
- currentNode = currentNode->parent_.lock();
+ // Check parent and all its grand parents
+ shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
+ while (currentNode != NULL)
+ {
+ if (currentNode->state_ == state)
+ break;
+ currentNode = currentNode->parent_.lock();
+ requestedNodes.push_back(currentNode);
+ }
}
- if (requestedNode == NULL)
+ if (requestedNodes.empty())
COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
else
- this->requestedStateNodes_.push_back(requestedNode);
+ this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
}
void Game::requestStates(const std::string& names)
@@ -292,16 +390,21 @@
void Game::popState()
{
- if (this->activeStateNode_ != NULL && this->requestedStateNodes_.back()->parent_.lock())
- this->requestState(this->requestedStateNodes_.back()->parent_.lock()->state_->getName());
+ shared_ptr<GameStateTreeNode> lastRequestedNode;
+ if (this->requestedStateNodes_.empty())
+ lastRequestedNode = this->activeStateNode_;
else
- COUT(2) << "Warning: Could not pop GameState. Ignoring." << std::endl;
+ lastRequestedNode = this->requestedStateNodes_.back();
+ if (lastRequestedNode != this->rootStateNode_)
+ this->requestState(lastRequestedNode->parent_.lock()->state_->getName());
+ else
+ COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;
}
GameState* Game::getState(const std::string& name)
{
- std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(name));
- if (it != allStates_s.end())
+ std::map<std::string, GameState*>::const_iterator it = gameStates_.find(getLowercase(name));
+ if (it != gameStates_.end())
return it->second;
else
{
@@ -324,60 +427,39 @@
startPos = pos;
while(pos < str.size() && str[pos] != ' ')
++pos;
- stateStrings.push_back(std::pair<std::string, unsigned>(
- str.substr(startPos, pos - startPos), indentation));
+ stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));
}
unsigned int currentLevel = 0;
- shared_ptr<GameStateTreeNode> currentNode;
+ shared_ptr<GameStateTreeNode> currentNode = this->rootStateNode_;
for (std::vector<std::pair<std::string, unsigned> >::const_iterator it = stateStrings.begin(); it != stateStrings.end(); ++it)
{
std::string newStateName = it->first;
- unsigned newLevel = it->second;
+ unsigned newLevel = it->second + 1; // empty root is 0
GameState* newState = this->getState(newStateName);
if (!newState)
- ThrowException(GameState, std::string("GameState with name '") + newStateName + "' not found!");
- if (newLevel == 0)
+ ThrowException(GameState, "GameState with name '" << newStateName << "' not found!");
+ if (newState == this->rootStateNode_->state_)
+ ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
+ shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
+ newNode->state_ = newState;
+
+ if (newLevel <= currentLevel)
{
- // root
- if (this->rootStateNode_ != NULL)
- ThrowException(GameState, "No two root GameStates are allowed!");
- shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
- newNode->state_ = newState;
- this->rootStateNode_ = newNode;
- currentNode = this->rootStateNode_;
+ do
+ currentNode = currentNode->parent_.lock();
+ while (newLevel <= --currentLevel);
}
- else if (currentNode)
+ if (newLevel == currentLevel + 1)
{
- shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
- newNode->state_ = newState;
- if (newLevel < currentLevel)
- {
- // Get down the hierarchy
- do
- currentNode = currentNode->parent_.lock();
- while (newLevel < --currentLevel);
- }
- if (newLevel == currentLevel)
- {
- // same level
- newNode->parent_ = currentNode->parent_;
- newNode->parent_.lock()->children_.push_back(newNode);
- }
- else if (newLevel == currentLevel + 1)
- {
- // child
- newNode->parent_ = currentNode;
- currentNode->children_.push_back(newNode);
- }
- else
- ThrowException(GameState, "Indentation error while parsing the hierarchy.");
- currentNode = newNode;
- currentLevel = newLevel;
+ // Add the child
+ newNode->parent_ = currentNode;
+ currentNode->children_.push_back(newNode);
+ currentNode->state_->addChild(newNode->state_);
}
else
- {
- ThrowException(GameState, "No root GameState specified!");
- }
+ ThrowException(GameState, "Indentation error while parsing the hierarchy.");
+ currentNode = newNode;
+ currentLevel = newLevel;
}
}
@@ -385,39 +467,47 @@
void Game::loadState(GameState* state)
{
+ this->bChangingState_ = true;
+ state->activate();
if (!this->activeStates_.empty())
this->activeStates_.back()->activity_.topState = false;
- state->activate();
+ this->activeStates_.push_back(state);
state->activity_.topState = true;
- this->activeStates_.push_back(state);
+ this->bChangingState_ = false;
}
void Game::unloadState(orxonox::GameState* state)
{
+ this->bChangingState_ = true;
state->activity_.topState = false;
- state->deactivate();
this->activeStates_.pop_back();
if (!this->activeStates_.empty())
this->activeStates_.back()->activity_.topState = true;
+ try
+ {
+ state->deactivate();
+ }
+ catch (const std::exception& ex)
+ {
+ COUT(2) << "Warning: Unloading GameState '" << state->getName() << "' threw an exception: " << ex.what() << std::endl;
+ COUT(2) << " There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
+ }
+ this->bChangingState_ = false;
}
- /*static*/ bool Game::addGameState(GameState* state)
+ std::map<std::string, Game::GameStateFactory*> Game::GameStateFactory::factories_s;
+
+ /*static*/ GameState* Game::GameStateFactory::fabricate(const std::string& className, const GameStateConstrParams& params)
{
- std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(state->getName()));
- if (it == allStates_s.end())
- allStates_s[getLowercase(state->getName())] = state;
- else
- ThrowException(GameState, "Cannot add two GameStates with the same name to 'Game'.");
-
- // just a required dummy return value
- return true;
+ std::map<std::string, GameStateFactory*>::const_iterator it = factories_s.find(className);
+ assert(it != factories_s.end());
+ return it->second->fabricate(params);
}
- /*static*/ void Game::destroyStates()
+ /*static*/ void Game::GameStateFactory::destroyFactories()
{
- // Delete all GameStates created by the macros
- for (std::map<std::string, GameState*>::const_iterator it = allStates_s.begin(); it != allStates_s.end(); ++it)
+ for (std::map<std::string, GameStateFactory*>::const_iterator it = factories_s.begin(); it != factories_s.end(); ++it)
delete it->second;
- allStates_s.clear();
+ factories_s.clear();
}
}
Modified: trunk/src/core/Game.h
===================================================================
--- trunk/src/core/Game.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Game.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -45,33 +45,30 @@
#include <boost/shared_ptr.hpp>
#include <boost/preprocessor/cat.hpp>
-#include "OrxonoxClass.h"
+#include "util/Debug.h"
+#include "util/StringUtils.h"
/**
@def
Adds a new GameState to the Game. The second parameter is the name as string
and every following paramter is a constructor argument (which is usually non existent)
*/
-#define AddGameState(classname, ...) \
- static bool BOOST_PP_CAT(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(__VA_ARGS__))
+#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
+ static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
-// tolua_begin
namespace orxonox
{
+ class GameConfiguration;
+
/**
@brief
Main class responsible for running the game.
*/
class _CoreExport Game
- // tolua_end
- : public OrxonoxClass
- // tolua_begin
{
- //tolua_end
public:
Game(int argc, char** argv);
~Game();
- void setConfigValues();
void setStateHierarchy(const std::string& str);
GameState* getState(const std::string& name);
@@ -90,16 +87,42 @@
void addTickTime(uint32_t length);
- static bool addGameState(GameState* state);
- static void destroyStates();
- static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; } //tolua_export
+ template <class T>
+ static bool declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bConsoleMode);
+ static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
- void setLevel(std::string levelName); //tolua_export
- std::string getLevel(); //tolua_export
-
private:
- struct statisticsTickInfo
+ class _CoreExport GameStateFactory
{
+ public:
+ virtual ~GameStateFactory() { }
+ static GameState* fabricate(const std::string& className, const GameStateConstrParams& params);
+ template <class T>
+ static void createFactory(const std::string& className)
+ { factories_s[className] = new TemplateGameStateFactory<T>(); }
+ static void destroyFactories();
+ private:
+ virtual GameState* fabricate(const GameStateConstrParams& params) = 0;
+ static std::map<std::string, GameStateFactory*> factories_s;
+ };
+ template <class T>
+ class TemplateGameStateFactory : public GameStateFactory
+ {
+ public:
+ GameState* fabricate(const GameStateConstrParams& params)
+ { return new T(params); }
+ };
+
+ struct GameStateInfo
+ {
+ std::string stateName;
+ std::string className;
+ bool bIgnoreTickTime;
+ bool bGraphicsMode;
+ };
+
+ struct StatisticsTickInfo
+ {
uint64_t tickTime;
uint32_t tickLength;
};
@@ -109,33 +132,55 @@
void loadState(GameState* state);
void unloadState(GameState* state);
- std::vector<GameState*> activeStates_;
+ std::map<std::string, GameState*> gameStates_;
+ std::vector<GameState*> activeStates_;
boost::shared_ptr<GameStateTreeNode> rootStateNode_;
boost::shared_ptr<GameStateTreeNode> activeStateNode_;
std::vector<boost::shared_ptr<GameStateTreeNode> > requestedStateNodes_;
Core* core_;
Clock* gameClock_;
+ GameConfiguration* configuration_;
- bool abort_;
+ bool bChangingState_;
+ bool bAbort_;
// variables for time statistics
uint64_t statisticsStartTime_;
- std::list<statisticsTickInfo> statisticsTickTimes_;
+ std::list<StatisticsTickInfo> statisticsTickTimes_;
uint32_t periodTime_;
uint32_t periodTickTime_;
float avgFPS_;
float avgTickTime_;
- // config values
- unsigned int statisticsRefreshCycle_;
- unsigned int statisticsAvgLength_;
- std::string levelName_;
-
- static std::map<std::string, GameState*> allStates_s;
+ static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
static Game* singletonRef_s; //!< Pointer to the Singleton
- // tolua_begin
};
+
+ template <class T>
+ /*static*/ bool Game::declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bGraphicsMode)
+ {
+ std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(getLowercase(stateName));
+ if (it == gameStateDeclarations_s.end())
+ {
+ GameStateInfo& info = gameStateDeclarations_s[getLowercase(stateName)];
+ info.stateName = stateName;
+ info.className = className;
+ info.bIgnoreTickTime = bIgnoreTickTime;
+ info.bGraphicsMode = bGraphicsMode;
+ }
+ else
+ {
+ COUT(0) << "Error: Cannot declare two GameStates with the same name." << std::endl;
+ COUT(0) << " Ignoring second one ('" << stateName << "')." << std::endl;
+ }
+
+ // Create a factory to delay GameState creation
+ GameStateFactory::createFactory<T>(className);
+
+ // just a required dummy return value
+ return true;
+ }
}
-//tolua_end
+
#endif /* _Game_H__ */
Modified: trunk/src/core/GameState.cc
===================================================================
--- trunk/src/core/GameState.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/GameState.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -44,9 +44,9 @@
@brief
Constructor only initialises variables and sets the name permanently.
*/
- GameState::GameState(const std::string& name, bool countTickTime)
- : name_(name)
- , bCountTickTime_(countTickTime)
+ GameState::GameState(const GameStateConstrParams& params)
+ : name_(params.name)
+ , bIgnoreTickTime_(params.bIgnoreTickTime)
, parent_(0)
{
this->activity_.activating = false;
Modified: trunk/src/core/GameState.h
===================================================================
--- trunk/src/core/GameState.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/GameState.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -44,6 +44,16 @@
{
/**
@brief
+ Helper class to group construction parameters for better genericity.
+ */
+ struct GameStateConstrParams
+ {
+ std::string name;
+ bool bIgnoreTickTime;
+ };
+
+ /**
+ @brief
An implementation of a tree to manage game states.
This leads to a certain hierarchy that is created at runtime.
To actually use the structure, you will have to derive from it and
@@ -76,22 +86,22 @@
};
public:
- GameState(const std::string& name, bool countTicktime = true);
+ GameState(const GameStateConstrParams& params);
virtual ~GameState();
const std::string& getName() const { return name_; }
State getActivity() const { return this->activity_; }
GameState* getParent() const { return this->parent_; }
- bool getCountTickTime() const { return this->bCountTickTime_; }
+ bool ignoreTickTime() const { return this->bIgnoreTickTime_; }
void addChild(GameState* state);
void removeChild(GameState* state);
protected:
- virtual void activate() = 0;
- virtual void deactivate() = 0;
- virtual void update(const Clock& time) = 0;
+ virtual void activate() { }
+ virtual void deactivate() { }
+ virtual void update(const Clock& time) { }
private:
void setParent(GameState* state) { this->parent_ = state; }
@@ -102,7 +112,7 @@
const std::string name_;
State activity_;
- const bool bCountTickTime_;
+ const bool bIgnoreTickTime_;
GameState* parent_;
std::map<std::string, GameState*> children_;
};
Modified: trunk/src/core/IRC.cc
===================================================================
--- trunk/src/core/IRC.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/IRC.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -67,7 +67,7 @@
catch (std::exception const &e)
{ COUT(1) << "Error while initializing Tcl (IRC): " << e.what(); }
- this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
+ this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
TclThreadManager::execute(threadID, "source irc.tcl");
}
Modified: trunk/src/core/Identifier.cc
===================================================================
--- trunk/src/core/Identifier.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Identifier.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -35,7 +35,7 @@
#include <ostream>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "ConfigValueContainer.h"
#include "ConsoleCommand.h"
#include "Factory.h"
Modified: trunk/src/core/Language.cc
===================================================================
--- trunk/src/core/Language.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Language.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -193,7 +193,7 @@
@param language The name of the language
@return The filename
*/
- const std::string Language::getFilename(const std::string& language)
+ std::string Language::getFilename(const std::string& language)
{
return std::string("translation_" + language + ".lang");
}
Modified: trunk/src/core/Language.h
===================================================================
--- trunk/src/core/Language.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Language.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -113,7 +113,7 @@
//! The Language class manges the language files and entries and stores the LanguageEntry objects in a map.
class _CoreExport Language
{
- friend class Core;
+ friend class CoreConfiguration;
public:
Language();
@@ -129,7 +129,7 @@
void readDefaultLanguageFile();
void readTranslatedLanguageFile();
void writeDefaultLanguageFile() const;
- static const std::string getFilename(const std::string& language);
+ static std::string getFilename(const std::string& language);
LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);
std::string defaultLanguage_; //!< The default language
Modified: trunk/src/core/LuaBind.cc
===================================================================
--- trunk/src/core/LuaBind.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/LuaBind.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
#include <boost/filesystem.hpp>
#include "util/Debug.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "ToluaBindCore.h"
#include "Core.h"
Modified: trunk/src/core/OrxonoxClass.cc
===================================================================
--- trunk/src/core/OrxonoxClass.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/OrxonoxClass.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -77,42 +77,42 @@
/** @brief Returns true if the objects class is of the given type or a derivative. */
- bool OrxonoxClass::isA(const SubclassIdentifier<class B>* identifier)
+ template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B>* identifier)
{ return this->getIdentifier()->isA(identifier->getIdentifier()); }
/** @brief Returns true if the objects class is exactly of the given type. */
- bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B>* identifier)
+ template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B>* identifier)
{ return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
/** @brief Returns true if the objects class is a child of the given type. */
- bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B>* identifier)
+ template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B>* identifier)
{ return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
/** @brief Returns true if the objects class is a direct child of the given type. */
- bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B>* identifier)
+ template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B>* identifier)
{ return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
/** @brief Returns true if the objects class is a parent of the given type. */
- bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B>* identifier)
+ template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B>* identifier)
{ return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
/** @brief Returns true if the objects class is a direct parent of the given type. */
- bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B>* identifier)
+ template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B>* identifier)
{ return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
/** @brief Returns true if the objects class is of the given type or a derivative. */
- bool OrxonoxClass::isA(const SubclassIdentifier<class B> identifier)
+ template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B> identifier)
{ return this->getIdentifier()->isA(identifier.getIdentifier()); }
/** @brief Returns true if the objects class is exactly of the given type. */
- bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B> identifier)
+ template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B> identifier)
{ return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
/** @brief Returns true if the objects class is a child of the given type. */
- bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B> identifier)
+ template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B> identifier)
{ return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
/** @brief Returns true if the objects class is a direct child of the given type. */
- bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B> identifier)
+ template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B> identifier)
{ return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
/** @brief Returns true if the objects class is a parent of the given type. */
- bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B> identifier)
+ template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B> identifier)
{ return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
/** @brief Returns true if the objects class is a direct parent of the given type. */
- bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B> identifier)
+ template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B> identifier)
{ return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
Modified: trunk/src/core/OrxonoxClass.h
===================================================================
--- trunk/src/core/OrxonoxClass.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/OrxonoxClass.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -79,19 +79,19 @@
bool isParentOf(const Identifier* identifier);
bool isDirectParentOf(const Identifier* identifier);
- bool isA(const SubclassIdentifier<class B>* identifier);
- bool isExactlyA(const SubclassIdentifier<class B>* identifier);
- bool isChildOf(const SubclassIdentifier<class B>* identifier);
- bool isDirectChildOf(const SubclassIdentifier<class B>* identifier);
- bool isParentOf(const SubclassIdentifier<class B>* identifier);
- bool isDirectParentOf(const SubclassIdentifier<class B>* identifier);
+ template <class B> bool isA(const SubclassIdentifier<B>* identifier);
+ template <class B> bool isExactlyA(const SubclassIdentifier<B>* identifier);
+ template <class B> bool isChildOf(const SubclassIdentifier<B>* identifier);
+ template <class B> bool isDirectChildOf(const SubclassIdentifier<B>* identifier);
+ template <class B> bool isParentOf(const SubclassIdentifier<B>* identifier);
+ template <class B> bool isDirectParentOf(const SubclassIdentifier<B>* identifier);
- bool isA(const SubclassIdentifier<class B> identifier);
- bool isExactlyA(const SubclassIdentifier<class B> identifier);
- bool isChildOf(const SubclassIdentifier<class B> identifier);
- bool isDirectChildOf(const SubclassIdentifier<class B> identifier);
- bool isParentOf(const SubclassIdentifier<class B> identifier);
- bool isDirectParentOf(const SubclassIdentifier<class B> identifier);
+ template <class B> bool isA(const SubclassIdentifier<B> identifier);
+ template <class B> bool isExactlyA(const SubclassIdentifier<B> identifier);
+ template <class B> bool isChildOf(const SubclassIdentifier<B> identifier);
+ template <class B> bool isDirectChildOf(const SubclassIdentifier<B> identifier);
+ template <class B> bool isParentOf(const SubclassIdentifier<B> identifier);
+ template <class B> bool isDirectParentOf(const SubclassIdentifier<B> identifier);
bool isA(const OrxonoxClass* object);
bool isExactlyA(const OrxonoxClass* object);
Modified: trunk/src/core/Shell.cc
===================================================================
--- trunk/src/core/Shell.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Shell.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -77,6 +77,10 @@
this->outputBuffer_.registerListener(this);
OutputHandler::getOutStream().setOutputBuffer(&this->outputBuffer_);
+ // Get a config file for the command history
+ this->commandHistoryConfigFileType_ = ConfigFileManager::getInstance().getNewConfigFileType();
+ ConfigFileManager::getInstance().setFilename(this->commandHistoryConfigFileType_, "commandHistory.ini");
+
this->setConfigValues();
Core::setSoftDebugLevel(OutputHandler::LD_Shell, level);
@@ -92,9 +96,11 @@
void Shell::setConfigValues()
{
- SetConfigValue(maxHistoryLength_, 100).callback(this, &Shell::commandHistoryLengthChanged);
- SetConfigValue(historyOffset_, 0).callback(this, &Shell::commandHistoryOffsetChanged);
- SetConfigValueVector(commandHistory_, std::vector<std::string>());
+ SetConfigValueGeneric(commandHistoryConfigFileType_, maxHistoryLength_, 100)
+ .callback(this, &Shell::commandHistoryLengthChanged);
+ SetConfigValueGeneric(commandHistoryConfigFileType_, historyOffset_, 0)
+ .callback(this, &Shell::commandHistoryOffsetChanged);
+ SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>());
}
void Shell::commandHistoryOffsetChanged()
Modified: trunk/src/core/Shell.h
===================================================================
--- trunk/src/core/Shell.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/Shell.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -36,9 +36,10 @@
#include <string>
#include <vector>
+#include "util/OutputBuffer.h"
+#include "input/InputBuffer.h"
#include "OrxonoxClass.h"
-#include "input/InputBuffer.h"
-#include "util/OutputBuffer.h"
+#include "ConfigFileManager.h"
namespace orxonox
{
@@ -144,6 +145,8 @@
unsigned int historyOffset_;
bool bAddOutputLevel_;
+ ConfigFileType commandHistoryConfigFileType_;
+
static Shell* singletonRef_s;
};
}
Modified: trunk/src/core/TclBind.cc
===================================================================
--- trunk/src/core/TclBind.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/TclBind.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,7 +33,7 @@
#include <cpptcl/cpptcl.h>
#include "util/Debug.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "CommandExecutor.h"
#include "ConsoleCommand.h"
#include "TclThreadManager.h"
Modified: trunk/src/core/TclThreadManager.cc
===================================================================
--- trunk/src/core/TclThreadManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/TclThreadManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -93,7 +93,7 @@
{
boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
TclThreadManager::getInstance().threadCounter_++;
- std::string name = getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().threadCounter_);
+ std::string name = multi_cast<std::string>(TclThreadManager::getInstance().threadCounter_);
TclInterpreterBundle* bundle = new TclInterpreterBundle;
bundle->id_ = TclThreadManager::getInstance().threadCounter_;
@@ -191,7 +191,7 @@
output += "\t\t";
{
boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_);
- output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
+ output += multi_cast<std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
}
output += "\t\t";
output += "busy";
@@ -200,11 +200,11 @@
boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it)
{
- std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
+ std::string output = multi_cast<std::string>((*it).first);
output += "\t\t";
{
boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
- output += getConvertedValue<unsigned int, std::string>((*it).second->queue_.size());
+ output += multi_cast<std::string>((*it).second->queue_.size());
}
output += "\t\t";
{
@@ -341,7 +341,7 @@
}
else
{
- this->error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + " existing.");
+ this->error("Error: No Tcl-interpreter with ID " + multi_cast<std::string>(threadID) + " existing.");
return 0;
}
}
@@ -354,7 +354,7 @@
if (it != list.begin())
output += " ";
- output += getConvertedValue<unsigned int, std::string>(*it);
+ output += multi_cast<std::string>(*it);
}
return output;
}
@@ -443,7 +443,7 @@
boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
if (bundle->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
{
- this->error("Error: Queue of Tcl-interpreter " + getConvertedValue<unsigned int, std::string>(threadID) + " is full, couldn't add command.");
+ this->error("Error: Queue of Tcl-interpreter " + multi_cast<std::string>(threadID) + " is full, couldn't add command.");
return;
}
@@ -491,7 +491,7 @@
if (std::find(target->queriers_.begin(), target->queriers_.end(), target->id_) != target->queriers_.end())
{
- this->error("Error: Circular query (" + this->dumpList(target->queriers_) + " -> " + getConvertedValue<unsigned int, std::string>(target->id_) + "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target->id_) + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(querier->id_) + ".");
+ this->error("Error: Circular query (" + this->dumpList(target->queriers_) + " -> " + multi_cast<std::string>(target->id_) + "), couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(target->id_) + " from other interpreter with ID " + multi_cast<std::string>(querier->id_) + ".");
return false;
}
@@ -584,7 +584,7 @@
}
else
{
- this->error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + ", interpreter is busy right now.");
+ this->error("Error: Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(threadID) + ", interpreter is busy right now.");
}
}
@@ -664,11 +664,11 @@
}
catch (Tcl::tcl_error const &e)
{
- TclThreadManager::getInstance().error("Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + ") error: " + e.what());
+ TclThreadManager::getInstance().error("Tcl (ID " + multi_cast<std::string>(interpreterBundle->id_) + ") error: " + e.what());
}
catch (std::exception const &e)
{
- TclThreadManager::getInstance().error("Error while executing Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + "): " + e.what());
+ TclThreadManager::getInstance().error("Error while executing Tcl (ID " + multi_cast<std::string>(interpreterBundle->id_) + "): " + e.what());
}
boost::mutex::scoped_lock finished_lock(interpreterBundle->finishedMutex_);
Modified: trunk/src/core/input/Button.cc
===================================================================
--- trunk/src/core/input/Button.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/input/Button.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -36,7 +36,7 @@
#include "util/Convert.h"
#include "util/SubString.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "util/Debug.h"
#include "core/ConsoleCommand.h"
#include "core/CommandEvaluation.h"
@@ -126,7 +126,7 @@
SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
'\\', false, '"', false, '(', ')', false, '\0');
- KeybindMode::Enum mode = KeybindMode::None;
+ KeybindMode::Value mode = KeybindMode::None;
float paramModifier = 1.0f;
std::string commandStr = "";
Modified: trunk/src/core/input/Button.h
===================================================================
--- trunk/src/core/input/Button.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/input/Button.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -53,7 +53,7 @@
virtual bool addParamCommand(ParamCommand* command) { return false; }
void parse();
void readConfigValue(ConfigFileType configFile);
- bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
+ bool execute(KeybindMode::Value mode, float abs = 1.0f, float rel = 1.0f);
//! Container to allow for better configValue support
ConfigValueContainer* configContainer_;
@@ -78,7 +78,7 @@
void parseError(std::string message, bool serious);
};
- inline bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
+ inline bool Button::execute(KeybindMode::Value mode, float abs, float rel)
{
// execute all the parsed commands in the string
for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
Modified: trunk/src/core/input/InputManager.cc
===================================================================
--- trunk/src/core/input/InputManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/input/InputManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,7 +42,7 @@
#include "util/Convert.h"
#include "util/Exception.h"
-#include "util/Debug.h"
+#include "util/ScopeGuard.h"
#include "core/Clock.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
@@ -69,7 +69,7 @@
SetConsoleCommand(InputManager, grabMouse, true);
SetConsoleCommand(InputManager, ungrabMouse, true);
#endif
- SetCommandLineSwitch(keyboard_no_grab);
+ SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard");
EmptyHandler InputManager::EMPTY_HANDLER;
InputManager* InputManager::singletonRef_s = 0;
@@ -176,9 +176,12 @@
// Fill parameter list
windowHndStr << (unsigned int)windowHnd_;
paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+#if defined(ORXONOX_PLATFORM_WINDOWS)
//paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
//paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
-#if defined ORXONOX_PLATFORM_LINUX
+ //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
+ //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
+#elif defined(ORXONOX_PLATFORM_LINUX)
paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
paramList.insert(std::make_pair(std::string("x11_mouse_hide"), "true"));
@@ -190,16 +193,28 @@
paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("true")));
#endif
- inputSystem_ = OIS::InputManager::createInputSystem(paramList);
- CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+ try
+ {
+ inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+ // Exception-safety
+ Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, inputSystem_);
+ CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
- _initialiseKeyboard();
+ _initialiseKeyboard();
+ // Nothing below should throw anymore, dismiss the guard
+ guard.Dismiss();
+ }
+ catch (OIS::Exception& ex)
+ {
+ ThrowException(InitialisationFailed, "Could not initialise the input system: " << ex.what());
+ }
+
_initialiseMouse();
if (joyStickSupport)
_initialiseJoySticks();
- // Do this anyway to also inform everything when a joystick was detached.
+ // Do this anyway to also inform when a joystick was detached.
_configureJoySticks();
// Set mouse/joystick region
@@ -272,7 +287,7 @@
}
else
{
- ThrowException(InitialisationFailed, "No keyboard found!");
+ ThrowException(InitialisationFailed, "InputManager: No keyboard found, cannot proceed!");
}
}
@@ -300,13 +315,13 @@
}
else
{
- CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
+ CCOUT(ORX_WARNING) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;
}
}
catch (OIS::Exception ex)
{
CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
- << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+ << "OIS error message: \"" << ex.eText << "\"\n Proceeding without mouse support." << std::endl;
mouse_ = 0;
}
}
@@ -344,10 +359,6 @@
}
}
}
- else
- {
- //CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
- }
}
/**
@@ -527,43 +538,40 @@
{
if (internalState_ != Uninitialised)
{
- try
+ CCOUT(3) << "Destroying ..." << std::endl;
+
+ // kick all active states 'nicely'
+ for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
+ rit != activeStates_.rend(); ++rit)
{
- CCOUT(3) << "Destroying ..." << std::endl;
+ (*rit).second->onLeave();
+ }
- // kick all active states 'nicely'
- for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
- rit != activeStates_.rend(); ++rit)
- {
- (*rit).second->onLeave();
- }
+ // Destroy calibrator helper handler and state
+ delete keyDetector_;
+ requestDestroyState("calibrator");
+ // Destroy KeyDetector and state
+ delete calibratorCallbackBuffer_;
+ requestDestroyState("detector");
+ // destroy the empty InputState
+ _destroyState(this->stateEmpty_);
- // Destroy calibrator helper handler and state
- delete keyDetector_;
- requestDestroyState("calibrator");
- // Destroy KeyDetector and state
- delete calibratorCallbackBuffer_;
- requestDestroyState("detector");
- // destroy the empty InputState
- _destroyState(this->stateEmpty_);
+ // destroy all user InputStates
+ while (inputStatesByName_.size() > 0)
+ _destroyState((*inputStatesByName_.rbegin()).second);
- // destroy all user InputStates
- while (inputStatesByName_.size() > 0)
- _destroyState((*inputStatesByName_.rbegin()).second);
+ // destroy the devices
+ _destroyKeyboard();
+ _destroyMouse();
+ _destroyJoySticks();
- // destroy the devices
- _destroyKeyboard();
- _destroyMouse();
- _destroyJoySticks();
-
+ try
+ {
OIS::InputManager::destroyInputSystem(inputSystem_);
-
- CCOUT(3) << "Destroying done." << std::endl;
}
- catch (OIS::Exception& ex)
+ catch (...)
{
- CCOUT(1) << "An exception has occured while destroying:\n" << ex.what()
- << "This could lead to a possible memory/resource leak!" << std::endl;
+ CCOUT(1) << "OIS::InputManager destruction failed! Potential resource leak!" << std::endl;
}
}
@@ -577,10 +585,17 @@
void InputManager::_destroyKeyboard()
{
assert(inputSystem_);
- if (keyboard_)
- inputSystem_->destroyInputObject(keyboard_);
- keyboard_ = 0;
- CCOUT(4) << "Keyboard destroyed." << std::endl;
+ try
+ {
+ if (keyboard_)
+ inputSystem_->destroyInputObject(keyboard_);
+ keyboard_ = 0;
+ CCOUT(4) << "Keyboard destroyed." << std::endl;
+ }
+ catch (...)
+ {
+ CCOUT(1) << "Keyboard destruction failed! Potential resource leak!" << std::endl;
+ }
}
/**
@@ -590,10 +605,17 @@
void InputManager::_destroyMouse()
{
assert(inputSystem_);
- if (mouse_)
- inputSystem_->destroyInputObject(mouse_);
- mouse_ = 0;
- CCOUT(4) << "Mouse destroyed." << std::endl;
+ try
+ {
+ if (mouse_)
+ inputSystem_->destroyInputObject(mouse_);
+ mouse_ = 0;
+ CCOUT(4) << "Mouse destroyed." << std::endl;
+ }
+ catch (...)
+ {
+ CCOUT(1) << "Mouse destruction failed! Potential resource leak!" << std::endl;
+ }
}
/**
@@ -606,8 +628,17 @@
{
assert(inputSystem_);
for (unsigned int i = 0; i < joySticksSize_; i++)
- if (joySticks_[i] != 0)
- inputSystem_->destroyInputObject(joySticks_[i]);
+ {
+ try
+ {
+ if (joySticks_[i] != 0)
+ inputSystem_->destroyInputObject(joySticks_[i]);
+ }
+ catch (...)
+ {
+ CCOUT(1) << "Joy stick destruction failed! Potential resource leak!" << std::endl;
+ }
+ }
joySticks_.clear();
// don't use _configureNumberOfJoySticks(), might mess with registered handler if
Modified: trunk/src/core/input/KeyBinder.cc
===================================================================
--- trunk/src/core/input/KeyBinder.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/core/input/KeyBinder.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -95,8 +95,8 @@
mouseAxes_[i].groupName_ = "MouseAxes";
}
- // Get a new ConfigFileType from the ConfigFileManager
- this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
+ // We might not even load any bindings at all (KeyDetector for instance)
+ this->configFile_ = ConfigFileType::NoType;
// initialise joy sticks separatly to allow for reloading
numberOfJoySticks_ = InputManager::getInstance().numberOfJoySticks();
@@ -186,7 +186,7 @@
// reinitialise all joy stick binings (doesn't overwrite the old ones)
for (unsigned int iDev = 0; iDev < numberOfJoySticks_; iDev++)
{
- std::string deviceNumber = convertToString(iDev);
+ std::string deviceNumber = multi_cast<std::string>(iDev);
// joy stick buttons
for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
{
@@ -249,6 +249,12 @@
if (filename.empty())
return;
+ if (this->configFile_ == ConfigFileType::NoType)
+ {
+ // Get a new ConfigFileType from the ConfigFileManager
+ this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
+ }
+
ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
// Parse bindings and create the ConfigValueContainers if necessary
Modified: trunk/src/network/NetworkPrereqs.h
===================================================================
--- trunk/src/network/NetworkPrereqs.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/NetworkPrereqs.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -131,7 +131,7 @@
namespace PacketFlag
{
- enum Enum
+ enum Value
{
Reliable = 1,
Unsequence = 2,
Modified: trunk/src/network/packet/Acknowledgement.cc
===================================================================
--- trunk/src/network/packet/Acknowledgement.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/Acknowledgement.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -36,14 +36,14 @@
#define PACKET_FLAGS_ACK 0
#define _PACKETID 0
-#define _ACKID _PACKETID + sizeof(packet::ENUM::Type)
+#define _ACKID _PACKETID + sizeof(packet::Type::Value)
Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
: Packet()
{
flags_ = flags_ | PACKET_FLAGS_ACK;
data_=new uint8_t[ getSize() ];
- *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;
+ *(Type::Value *)(data_ + _PACKETID ) = Type::Acknowledgement;
*(uint32_t *)(data_ + _ACKID ) = id;
clientID_=clientID;
}
Modified: trunk/src/network/packet/Chat.cc
===================================================================
--- trunk/src/network/packet/Chat.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/Chat.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
#define PACKET_FLAGS_CHAT PacketFlag::Reliable
#define _PACKETID 0
-const int _PLAYERID = _PACKETID + sizeof(ENUM::Type);
+const int _PLAYERID = _PACKETID + sizeof(Type::Value);
#define _MESSAGELENGTH _PLAYERID + sizeof(uint32_t)
#define _MESSAGE _MESSAGELENGTH + sizeof(uint32_t)
@@ -47,7 +47,7 @@
flags_ = flags_ | PACKET_FLAGS_CHAT;
messageLength_ = message.length()+1;
data_=new unsigned char[ getSize() ];
- *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Chat;
+ *(Type::Value *)(data_ + _PACKETID ) = Type::Chat;
*(unsigned int *)(data_ + _PLAYERID ) = playerID;
*(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
memcpy( data_+_MESSAGE, (void *)message.c_str(), messageLength_ );
Modified: trunk/src/network/packet/ClassID.cc
===================================================================
--- trunk/src/network/packet/ClassID.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/ClassID.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -73,7 +73,7 @@
this->data_=new uint8_t[ packetSize ];
//set the appropriate packet id
assert(this->data_);
- *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::ClassID;
+ *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID;
uint8_t *temp=data_+sizeof(uint32_t);
// save the number of all classes
Modified: trunk/src/network/packet/DeleteObjects.cc
===================================================================
--- trunk/src/network/packet/DeleteObjects.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/DeleteObjects.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -38,7 +38,7 @@
#define PACKET_FLAG_DELETE PacketFlag::Reliable
#define _PACKETID 0
-#define _QUANTITY _PACKETID + sizeof(ENUM::Type)
+#define _QUANTITY _PACKETID + sizeof(Type::Value)
#define _OBJECTIDS _QUANTITY + sizeof(uint32_t)
DeleteObjects::DeleteObjects()
@@ -61,11 +61,11 @@
if(number==0)
return false;
COUT(4) << "sending DeleteObjects: ";
- unsigned int size = sizeof(ENUM::Type) + sizeof(uint32_t)*(number+1);
+ unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1);
data_ = new uint8_t[size];
uint8_t *tdata = data_;
- *reinterpret_cast<ENUM::Type*>(tdata) = ENUM::DeleteObjects;
- tdata += sizeof(ENUM::Type);
+ *reinterpret_cast<Type::Value*>(tdata) = Type::DeleteObjects;
+ tdata += sizeof(Type::Value);
*(uint32_t *)tdata = number;
tdata += sizeof(uint32_t);
for(unsigned int i=0; i<number; i++){
Modified: trunk/src/network/packet/FunctionCalls.cc
===================================================================
--- trunk/src/network/packet/FunctionCalls.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/FunctionCalls.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -48,7 +48,7 @@
nrOfCalls_ = 0;
currentMemBlocks_ = 1;
data_=new uint8_t[ FUNCTIONCALLS_MEM_ALLOCATION ];
- *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::FunctionCalls;
+ *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls;
*(uint32_t*)(data_+sizeof(uint32_t)) = 0; // set nrOfCalls to 0
}
Modified: trunk/src/network/packet/FunctionIDs.cc
===================================================================
--- trunk/src/network/packet/FunctionIDs.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/FunctionIDs.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -67,7 +67,7 @@
this->data_=new uint8_t[ packetSize ];
//set the appropriate packet id
assert(this->data_);
- *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::FunctionIDs;
+ *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs;
uint8_t *temp=data_+sizeof(uint32_t);
// save the number of all classes
Modified: trunk/src/network/packet/Gamestate.h
===================================================================
--- trunk/src/network/packet/Gamestate.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/Gamestate.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -46,7 +46,7 @@
class _NetworkExport GamestateHeader{
public:
- GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }
+ GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; }
GamestateHeader(uint8_t *data, GamestateHeader* h)
{ assert(data); data_=data; memcpy(data_, h->data_, getSize()); }
static inline uint32_t getSize()
Modified: trunk/src/network/packet/Packet.cc
===================================================================
--- trunk/src/network/packet/Packet.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/Packet.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -62,7 +62,7 @@
Packet::Packet(){
flags_ = PACKET_FLAG_DEFAULT;
- packetDirection_ = ENUM::Outgoing;
+ packetDirection_ = Direction::Outgoing;
clientID_=0;
data_=0;
enetPacket_=0;
@@ -75,7 +75,7 @@
Packet::Packet(uint8_t *data, unsigned int clientID){
flags_ = PACKET_FLAG_DEFAULT;
- packetDirection_ = ENUM::Incoming;
+ packetDirection_ = Direction::Incoming;
clientID_=clientID;
data_=data;
enetPacket_=0;
@@ -124,7 +124,7 @@
}
bool Packet::send(){
- if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){
+ if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){
assert(0);
return false;
}
@@ -146,16 +146,16 @@
}
}
#ifndef NDEBUG
- switch( *(ENUM::Type *)(data_ + _PACKETID) )
+ switch( *(Type::Value *)(data_ + _PACKETID) )
{
- case ENUM::Acknowledgement:
- case ENUM::Chat:
- case ENUM::ClassID:
- case ENUM::Gamestate:
- case ENUM::Welcome:
- case ENUM::DeleteObjects:
- case ENUM::FunctionIDs:
- case ENUM::FunctionCalls:
+ case Type::Acknowledgement:
+ case Type::Chat:
+ case Type::ClassID:
+ case Type::Gamestate:
+ case Type::Welcome:
+ case Type::DeleteObjects:
+ case Type::FunctionIDs:
+ case Type::FunctionCalls:
break;
default:
assert(0); //there was some error, if this is the case
@@ -174,39 +174,39 @@
assert(ClientInformation::findClient(&peer->address)->getID() != (unsigned int)-2 || !Host::isServer());
unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
Packet *p = 0;
- COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
- switch( *(ENUM::Type *)(data + _PACKETID) )
+ COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
+ switch( *(Type::Value *)(data + _PACKETID) )
{
- case ENUM::Acknowledgement:
+ case Type::Acknowledgement:
COUT(5) << "ack" << std::endl;
p = new Acknowledgement( data, clientID );
break;
- case ENUM::Chat:
+ case Type::Chat:
COUT(5) << "chat" << std::endl;
p = new Chat( data, clientID );
break;
- case ENUM::ClassID:
+ case Type::ClassID:
COUT(5) << "classid" << std::endl;
p = new ClassID( data, clientID );
break;
- case ENUM::Gamestate:
+ case Type::Gamestate:
COUT(5) << "gamestate" << std::endl;
// TODO: remove brackets
p = new Gamestate( data, clientID );
break;
- case ENUM::Welcome:
+ case Type::Welcome:
COUT(5) << "welcome" << std::endl;
p = new Welcome( data, clientID );
break;
- case ENUM::DeleteObjects:
+ case Type::DeleteObjects:
COUT(5) << "deleteobjects" << std::endl;
p = new DeleteObjects( data, clientID );
break;
- case ENUM::FunctionCalls:
+ case Type::FunctionCalls:
COUT(5) << "functionCalls" << std::endl;
p = new FunctionCalls( data, clientID );
break;
- case ENUM::FunctionIDs:
+ case Type::FunctionIDs:
COUT(5) << "functionIDs" << std::endl;
p = new FunctionIDs( data, clientID );
break;
Modified: trunk/src/network/packet/Packet.h
===================================================================
--- trunk/src/network/packet/Packet.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/Packet.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -35,13 +35,15 @@
namespace packet{
-namespace ENUM{
- enum Direction{
+namespace Direction{
+ enum Value{
Incoming,
Outgoing,
Bidirectional
};
- enum Type{
+}
+namespace Type{
+ enum Value{
Acknowledgement,
Chat,
ClassID,
@@ -83,7 +85,7 @@
uint32_t flags_;
unsigned int clientID_;
- ENUM::Direction packetDirection_;
+ Direction::Value packetDirection_;
/** Pointer to the data. Be careful when deleting it because it might
point to a location that was allocated by ENet.
See bDataENetAllocated_ */
Modified: trunk/src/network/packet/Welcome.cc
===================================================================
--- trunk/src/network/packet/Welcome.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/packet/Welcome.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -40,7 +40,7 @@
#define PACKET_FLAGS_CLASSID PacketFlag::Reliable
#define _PACKETID 0
-#define _CLIENTID _PACKETID + sizeof(ENUM::Type)
+#define _CLIENTID _PACKETID + sizeof(Type::Value)
#define _ENDIANTEST _CLIENTID + sizeof(uint32_t)
Welcome::Welcome( uint32_t clientID, uint32_t shipID )
@@ -50,7 +50,7 @@
assert(getSize());
data_=new uint8_t[ getSize() ];
assert(data_);
- *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
+ *(packet::Type::Value *)(data_ + _PACKETID ) = packet::Type::Welcome;
*(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID);
*(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
}
@@ -69,7 +69,7 @@
}
unsigned int Welcome::getSize() const{
- return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t);
+ return sizeof(packet::Type::Value) + 2*sizeof(uint32_t);
}
bool Welcome::process(){
Modified: trunk/src/network/synchronisable/Synchronisable.cc
===================================================================
--- trunk/src/network/synchronisable/Synchronisable.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/synchronisable/Synchronisable.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -64,7 +64,7 @@
// set dataSize to 0
this->dataSize_ = 0;
// set standard priority
- this->setPriority( priority::normal );
+ this->setPriority( Priority::Normal );
// get creator id
this->creatorID = OBJECTID_UNKNOWN;
Modified: trunk/src/network/synchronisable/Synchronisable.h
===================================================================
--- trunk/src/network/synchronisable/Synchronisable.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/synchronisable/Synchronisable.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -50,21 +50,21 @@
namespace orxonox
{
- namespace objectDirection{
- enum objectdirection{
- toclient=0x1,
- toserver=0x2,
- bidirectional=0x3
+ namespace ObjectDirection{
+ enum Value{
+ ToClient=0x1,
+ ToServer=0x2,
+ Bidirectional=0x3
};
}
- namespace priority{
- enum prio{
- very_high = -100,
- high = -15,
- normal = 0,
- low = 15,
- very_low = 100
+ namespace Priority{
+ enum Value{
+ VeryHigh = -100,
+ High = -15,
+ Normal = 0,
+ Low = 15,
+ VeryLow = 100
};
}
Modified: trunk/src/network/synchronisable/SynchronisableVariable.h
===================================================================
--- trunk/src/network/synchronisable/SynchronisableVariable.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/network/synchronisable/SynchronisableVariable.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -40,14 +40,16 @@
namespace orxonox{
- namespace variableDirection{
- enum syncdirection{
- toclient=0x1,
- toserver=0x2
+ namespace VariableDirection{
+ enum Value{
+ ToClient=0x1,
+ ToServer=0x2
};
- enum bidirectional{
- serverMaster=0x1,
- clientMaster=0x2
+ }
+ namespace Bidirectionality{
+ enum Value{
+ ServerMaster=0x1,
+ ClientMaster=0x2
};
}
@@ -68,7 +70,7 @@
class SynchronisableVariable: public SynchronisableVariableBase
{
public:
- SynchronisableVariable(T& variable, uint8_t syncDirection=variableDirection::toclient, NetworkCallbackBase *cb=0);
+ SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=0);
virtual ~SynchronisableVariable();
virtual inline uint8_t getMode(){ return mode_; }
@@ -87,7 +89,7 @@
class SynchronisableVariableBidirectional: public SynchronisableVariable<T>
{
public:
- SynchronisableVariableBidirectional(T& variable, uint8_t master=variableDirection::serverMaster, NetworkCallbackBase *cb=0);
+ SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
virtual ~SynchronisableVariableBidirectional();
virtual inline uint8_t getMode(){ return 0x3; } //this basically is a hack ^^
Modified: trunk/src/orxonox/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/CMakeLists.txt 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/CMakeLists.txt 2009-07-12 21:58:01 UTC (rev 3280)
@@ -41,6 +41,7 @@
ORXONOX_ADD_EXECUTABLE(orxonox
FIND_HEADER_FILES
TOLUA_FILES
+ LevelManager.h
gui/GUIManager.h
objects/pickup/BaseItem.h
objects/pickup/PickupInventory.h
Modified: trunk/src/orxonox/CameraManager.cc
===================================================================
--- trunk/src/orxonox/CameraManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/CameraManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -31,7 +31,7 @@
#include <OgreViewport.h>
#include <OgreCompositorManager.h>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/GameMode.h"
#include "core/ObjectList.h"
#include "tools/Shader.h"
Modified: trunk/src/orxonox/GraphicsManager.cc
===================================================================
--- trunk/src/orxonox/GraphicsManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/GraphicsManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,6 +37,7 @@
#include <fstream>
#include <boost/filesystem.hpp>
+#include <boost/shared_ptr.hpp>
#include <OgreCompositorManager.h>
#include <OgreConfigFile.h>
@@ -52,7 +53,7 @@
#include "SpecialConfig.h"
#include "util/Exception.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "util/SubString.h"
#include "core/Clock.h"
#include "core/ConsoleCommand.h"
@@ -69,6 +70,8 @@
namespace orxonox
{
+ using boost::shared_ptr;
+
class _OrxonoxExport OgreWindowEventListener : public Ogre::WindowEventListener
{
void windowResized (Ogre::RenderWindow* rw);
@@ -88,39 +91,44 @@
, ogreLogger_(0)
, renderWindow_(0)
, viewport_(0)
- , ogreWindowEventListener_(0)
+ , ogreWindowEventListener_(new OgreWindowEventListener())
{
RegisterObject(GraphicsManager);
assert(singletonRef_s == 0);
singletonRef_s = this;
- this->loaded_ = false;
-
this->setConfigValues();
- }
- void GraphicsManager::initialise()
- {
// Ogre setup procedure
setupOgre();
- // load all the required plugins for Ogre
- loadOgrePlugins();
- // read resource declaration file
- this->declareResources();
- // Reads ogre config and creates the render window
- this->loadRenderer();
- // TODO: Spread this
- this->initialiseResources();
+ try
+ {
+ // load all the required plugins for Ogre
+ loadOgrePlugins();
+ // read resource declaration file
+ this->declareResources();
+ // Reads ogre config and creates the render window
+ this->loadRenderer();
- // add console commands
- FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
- functor1->setObject(this);
- ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
- CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
+ // TODO: Spread this
+ this->initialiseResources();
- this->loaded_ = true;
+ // add console commands
+ FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
+ functor1->setObject(this);
+ ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
+ CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
+ }
+ catch (...)
+ {
+ // clean up
+ delete this->ogreRoot_;
+ delete this->ogreLogger_;
+ delete this->ogreWindowEventListener_;
+ throw;
+ }
}
/**
@@ -129,36 +137,23 @@
*/
GraphicsManager::~GraphicsManager()
{
- if (this->loaded_)
- {
- delete this->ccPrintScreen_;
+/*
+ delete this->ccPrintScreen_;
+*/
- if (this->ogreWindowEventListener_)
- {
- // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
- Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this->ogreWindowEventListener_);
- delete this->ogreWindowEventListener_;
- }
+ // HACK! This fixes an exit crash
+ Map::hackDestroyMap();
+ // unload all compositors (this is only necessary because we don't yet destroy all resources!)
+ Ogre::CompositorManager::getSingleton().removeAll();
- // destroy render window
-// Ogre::RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
-// renderer->destroyRenderWindow("Orxonox");
+ // Delete OGRE main control organ
+ delete this->ogreRoot_;
- // HACK! This fixes an exit crash
- Map::hackDestroyMap();
+ // delete the logManager (since we have created it in the first place).
+ delete this->ogreLogger_;
- // unload all compositors
- Ogre::CompositorManager::getSingleton().removeAll();
+ delete this->ogreWindowEventListener_;
- // Delete OGRE main control organ
- delete this->ogreRoot_;
-
- // delete the ogre log and the logManager (since we have created it in the first place).
- this->ogreLogger_->getDefaultLog()->removeListener(this);
- this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
- delete this->ogreLogger_;
- }
-
assert(singletonRef_s);
singletonRef_s = 0;
}
@@ -193,29 +188,26 @@
void GraphicsManager::update(const Clock& time)
{
- if (this->loaded_)
- {
- Ogre::FrameEvent evt;
- evt.timeSinceLastFrame = time.getDeltaTime();
- evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway
+ Ogre::FrameEvent evt;
+ evt.timeSinceLastFrame = time.getDeltaTime();
+ evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway
- // don't forget to call _fireFrameStarted to OGRE to make sure
- // everything goes smoothly
- ogreRoot_->_fireFrameStarted(evt);
+ // don't forget to call _fireFrameStarted to OGRE to make sure
+ // everything goes smoothly
+ ogreRoot_->_fireFrameStarted(evt);
- // Pump messages in all registered RenderWindows
- // This calls the WindowEventListener objects.
- Ogre::WindowEventUtilities::messagePump();
- // make sure the window stays active even when not focused
- // (probably only necessary on windows)
- this->renderWindow_->setActive(true);
+ // Pump messages in all registered RenderWindows
+ // This calls the WindowEventListener objects.
+ Ogre::WindowEventUtilities::messagePump();
+ // make sure the window stays active even when not focused
+ // (probably only necessary on windows)
+ this->renderWindow_->setActive(true);
- // render
- ogreRoot_->_updateAllRenderTargets();
+ // render
+ ogreRoot_->_updateAllRenderTargets();
- // again, just to be sure OGRE works fine
- ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
- }
+ // again, just to be sure OGRE works fine
+ ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
}
void GraphicsManager::setCamera(Ogre::Camera* camera)
@@ -247,12 +239,12 @@
// create a new logManager
// Ogre::Root will detect that we've already created a Log
- ogreLogger_ = new Ogre::LogManager();
+ std::auto_ptr<Ogre::LogManager> logger(new Ogre::LogManager());
COUT(4) << "Ogre LogManager created" << std::endl;
// create our own log that we can listen to
Ogre::Log *myLog;
- myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
+ myLog = logger->createLog(ogreLogFilepath.string(), true, false, false);
COUT(4) << "Ogre Log created" << std::endl;
myLog->setLogDetail(Ogre::LL_BOREME);
@@ -271,6 +263,8 @@
// Leave plugins file empty. We're going to do that part manually later
ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
+ // In case that new Root failed the logger gets destroyed because of the std::auto_ptr
+ ogreLogger_ = logger.release();
COUT(3) << "Ogre set up done." << std::endl;
}
@@ -347,13 +341,12 @@
if (!ogreRoot_->restoreConfig())
if (!ogreRoot_->showConfigDialog())
- ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
+ ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue failed.");
CCOUT(4) << "Creating render window" << std::endl;
this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
- this->ogreWindowEventListener_ = new OgreWindowEventListener();
Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, ogreWindowEventListener_);
Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
Modified: trunk/src/orxonox/GraphicsManager.h
===================================================================
--- trunk/src/orxonox/GraphicsManager.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/GraphicsManager.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -56,7 +56,6 @@
~GraphicsManager();
void setConfigValues();
- void initialise();
void update(const Clock& time);
@@ -92,13 +91,11 @@
void printScreen();
private:
- bool loaded_;
-
Ogre::Root* ogreRoot_; //!< Ogre's root
Ogre::LogManager* ogreLogger_;
Ogre::RenderWindow* renderWindow_; //!< the one and only render window
Ogre::Viewport* viewport_; //!< default full size viewport
- OgreWindowEventListener* ogreWindowEventListener_;
+ OgreWindowEventListener* ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
// config values
unsigned int detailLevelParticle_; //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
Modified: trunk/src/orxonox/LevelManager.cc
===================================================================
--- trunk/src/orxonox/LevelManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/LevelManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -29,18 +29,33 @@
#include "LevelManager.h"
#include <map>
+
+#include "core/CommandLine.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
#include "PlayerManager.h"
#include "objects/Level.h"
#include "objects/infos/HumanPlayer.h"
namespace orxonox
{
+ SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
+
LevelManager* LevelManager::singletonRef_s = 0;
LevelManager::LevelManager()
{
assert(singletonRef_s == 0);
singletonRef_s = this;
+
+ RegisterRootObject(LevelManager);
+ this->setConfigValues();
+
+ // check override
+ if (!CommandLine::getArgument("level")->hasDefaultValue())
+ {
+ ModifyConfigValue(defaultLevelName_, tset, CommandLine::getValue("level").getString());
+ }
}
LevelManager::~LevelManager()
@@ -49,6 +64,12 @@
singletonRef_s = 0;
}
+ void LevelManager::setConfigValues()
+ {
+ SetConfigValue(defaultLevelName_, "presentation_dm.oxw")
+ .description("Sets the preselection of the level in the main menu.");
+ }
+
void LevelManager::requestActivity(Level* level)
{
this->levels_s.push_back(level);
@@ -92,4 +113,14 @@
this->levels_s.front()->playerEntered(it->second);
}
}
+
+ void LevelManager::setDefaultLevel(const std::string& levelName)
+ {
+ ModifyConfigValue(defaultLevelName_, set, levelName);
+ }
+
+ const std::string& LevelManager::getDefaultLevel()
+ {
+ return defaultLevelName_;
+ }
}
Modified: trunk/src/orxonox/LevelManager.h
===================================================================
--- trunk/src/orxonox/LevelManager.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/LevelManager.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,21 +33,30 @@
#include <cassert>
#include <list>
+#include "core/OrxonoxClass.h"
+// tolua_begin
namespace orxonox
{
class _OrxonoxExport LevelManager
- {
+ // tolua_end
+ : public OrxonoxClass
+ { // tolua_export
public:
LevelManager();
virtual ~LevelManager();
+ void setConfigValues();
+
void requestActivity(Level* level);
void releaseActivity(Level* level);
Level* getActiveLevel();
+ void setDefaultLevel(const std::string& levelName); //tolua_export
+ const std::string& getDefaultLevel(); //tolua_export
+
static LevelManager* getInstancePtr() { return singletonRef_s; }
- static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+ static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
private:
LevelManager(const LevelManager&);
@@ -56,8 +65,11 @@
std::list<Level*> levels_s;
+ // config values
+ std::string defaultLevelName_;
+
static LevelManager* singletonRef_s;
- };
-}
+ }; // tolua_export
+} // tolua_export
#endif /* _LevelManager_H__ */
Modified: trunk/src/orxonox/Main.cc
===================================================================
--- trunk/src/orxonox/Main.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/Main.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -36,7 +36,7 @@
#include "OrxonoxPrereqs.h"
#include "util/Debug.h"
-#include "core/Identifier.h"
+#include "util/Exception.h"
#include "core/Game.h"
/*
@@ -49,10 +49,14 @@
int main(int argc, char** argv)
#endif
{
+ using namespace orxonox;
+
+ Game* game = 0;
+ try
{
- orxonox::Game orxonox(argc, argv);
+ game = new Game(argc, argv);
- orxonox.setStateHierarchy(
+ game->setStateHierarchy(
"root"
" graphics"
" mainMenu"
@@ -67,15 +71,23 @@
" ioConsole"
);
- orxonox.run();
+ game->requestState("root");
+ }
+ catch (const std::exception& ex)
+ {
+ COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
+ COUT(0) << "Terminating program." << std::endl;
+ return 1;
+ }
+ catch (...)
+ {
+ COUT(0) << "Orxonox failed to initialise: " << std::endl;
+ COUT(0) << "Terminating program." << std::endl;
+ return 1;
+ }
- // destroy the GameStates created pre-mainly
- orxonox::Game::destroyStates();
- } // orxonox gets destroyed right here!
+ game->run();
+ delete game;
- // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
- // Needs to be done after Game destructor because of ~OrxonoxClass
- orxonox::Identifier::destroyAllIdentifiers();
-
return 0;
}
Modified: trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- trunk/src/orxonox/OrxonoxPrereqs.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/OrxonoxPrereqs.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -64,12 +64,12 @@
{
namespace LODParticle
{
- enum LOD
+ enum Value
{
- off = 0,
- low = 1,
- normal = 2,
- high = 3
+ Off = 0,
+ Low = 1,
+ Normal = 2,
+ High = 3
};
}
@@ -294,6 +294,7 @@
namespace CEGUI
{
class DefaultLogger;
+ class Logger;
class LuaScriptModule;
class OgreCEGUIRenderer;
Modified: trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSClient.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSClient.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,12 +37,12 @@
namespace orxonox
{
- AddGameState(GSClient, "client");
+ DeclareGameState(GSClient, "client", false, true);
- SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
+ SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as strin in the form #.#.#.#");
- GSClient::GSClient(const std::string& name)
- : GameState(name)
+ GSClient::GSClient(const GameStateConstrParams& params)
+ : GameState(params)
, client_(0)
{
}
Modified: trunk/src/orxonox/gamestates/GSClient.h
===================================================================
--- trunk/src/orxonox/gamestates/GSClient.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSClient.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -39,7 +39,7 @@
class _OrxonoxExport GSClient : public GameState
{
public:
- GSClient(const std::string& name);
+ GSClient(const GameStateConstrParams& params);
~GSClient();
void activate();
Modified: trunk/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSDedicated.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSDedicated.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -50,12 +50,12 @@
{
const unsigned int MAX_COMMAND_LENGTH = 255;
- AddGameState(GSDedicated, "dedicated");
+ DeclareGameState(GSDedicated, "dedicated", false, false);
termios* GSDedicated::originalTerminalSettings_;
- GSDedicated::GSDedicated(const std::string& name)
- : GameState(name)
+ GSDedicated::GSDedicated(const GameStateConstrParams& params)
+ : GameState(params)
, server_(0)
, timeSinceLastUpdate_(0)
, closeThread_(false)
Modified: trunk/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- trunk/src/orxonox/gamestates/GSDedicated.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSDedicated.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -47,7 +47,7 @@
class _OrxonoxExport GSDedicated : public GameState
{
public:
- GSDedicated(const std::string& name);
+ GSDedicated(const GameStateConstrParams& params);
~GSDedicated();
void activate();
Modified: trunk/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSGraphics.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSGraphics.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -56,10 +56,10 @@
namespace orxonox
{
- AddGameState(GSGraphics, "graphics", false);
+ DeclareGameState(GSGraphics, "graphics", true, true);
- GSGraphics::GSGraphics(const std::string& name, bool countTickTime)
- : GameState(name, countTickTime)
+ GSGraphics::GSGraphics(const GameStateConstrParams& params)
+ : GameState(params)
, inputManager_(0)
, console_(0)
, guiManager_(0)
@@ -107,9 +107,8 @@
setConfigValues();
- // initialise graphics manager. Doesn't load the render window yet!
+ // Load OGRE including the render window
this->graphicsManager_ = new GraphicsManager();
- this->graphicsManager_->initialise();
// load debug overlay
COUT(3) << "Loading Debug Overlay..." << std::endl;
@@ -197,7 +196,7 @@
*/
void GSGraphics::toggleGUI()
{
- GUIManager::getInstance().executeCode("toggleGUI()");
+ GUIManager::getInstance().executeCode("toggleGUI()");
}
/**
Modified: trunk/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- trunk/src/orxonox/gamestates/GSGraphics.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSGraphics.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -51,7 +51,7 @@
class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
{
public:
- GSGraphics(const std::string& name, bool countTickTime);
+ GSGraphics(const GameStateConstrParams& params);
~GSGraphics();
void setConfigValues();
Modified: trunk/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSIOConsole.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSIOConsole.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -35,10 +35,10 @@
namespace orxonox
{
- AddGameState(GSIOConsole, "ioConsole");
+ DeclareGameState(GSIOConsole, "ioConsole", false, false);
- GSIOConsole::GSIOConsole(const std::string& name)
- : GameState(name)
+ GSIOConsole::GSIOConsole(const GameStateConstrParams& params)
+ : GameState(params)
{
}
Modified: trunk/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- trunk/src/orxonox/gamestates/GSIOConsole.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSIOConsole.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
class _OrxonoxExport GSIOConsole : public GameState
{
public:
- GSIOConsole(const std::string& name);
+ GSIOConsole(const GameStateConstrParams& params);
~GSIOConsole();
void activate();
Modified: trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSLevel.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSLevel.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,7 +33,6 @@
#include "core/input/SimpleInputState.h"
#include "core/input/KeyBinder.h"
#include "core/Clock.h"
-#include "core/CommandLine.h"
#include "core/ConsoleCommand.h"
#include "core/ConfigValueIncludes.h"
#include "core/CoreIncludes.h"
@@ -55,22 +54,19 @@
namespace orxonox
{
- AddGameState(GSLevel, "level");
-
- SetCommandLineArgument(level, "").shortcut("l");
+ DeclareGameState(GSLevel, "level", false, true);
SetConsoleCommand(GSLevel, showIngameGUI, true);
XMLFile* GSLevel::startFile_s = NULL;
- GSLevel::GSLevel(const std::string& name)
- : GameState(name)
+ GSLevel::GSLevel(const GameStateConstrParams& params)
+ : GameState(params)
, keyBinder_(0)
, gameInputState_(0)
, guiMouseOnlyInputState_(0)
, guiKeysOnlyInputState_(0)
, radar_(0)
, cameraManager_(0)
- , levelManager_(0)
{
RegisterObject(GSLevel);
@@ -119,9 +115,6 @@
if (GameMode::isMaster())
{
- // create the global LevelManager
- this->levelManager_ = new LevelManager();
-
this->loadLevel();
}
@@ -201,12 +194,6 @@
this->cameraManager_ = 0;
}
- if (this->levelManager_)
- {
- delete this->levelManager_;
- this->levelManager_ = 0;
- }
-
if (this->playerManager_)
{
delete this->playerManager_;
@@ -251,12 +238,7 @@
{
// call the loader
COUT(0) << "Loading level..." << std::endl;
- std::string levelName;
- CommandLine::getValue("level", &levelName);
- if (levelName == "")
- startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + Game::getInstance().getLevel());
- else
- startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName);
+ startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + LevelManager::getInstance().getDefaultLevel());
Loader::open(startFile_s);
}
Modified: trunk/src/orxonox/gamestates/GSLevel.h
===================================================================
--- trunk/src/orxonox/gamestates/GSLevel.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSLevel.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -40,7 +40,7 @@
class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
{
public:
- GSLevel(const std::string& name);
+ GSLevel(const GameStateConstrParams& params);
~GSLevel();
void setConfigValues();
@@ -67,7 +67,6 @@
SimpleInputState* guiKeysOnlyInputState_; //!< input state if we only need the keys to use the GUI
Radar* radar_; //!< represents the Radar (not the HUD part)
CameraManager* cameraManager_; //!< camera manager for this level
- LevelManager* levelManager_; //!< global level manager
PlayerManager* playerManager_; //!< player manager for this level
QuestManager* questManager_;
NotificationManager* notificationManager_;
Modified: trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSMainMenu.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSMainMenu.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,10 +42,10 @@
namespace orxonox
{
- AddGameState(GSMainMenu, "mainMenu");
+ DeclareGameState(GSMainMenu, "mainMenu", false, true);
- GSMainMenu::GSMainMenu(const std::string& name)
- : GameState(name)
+ GSMainMenu::GSMainMenu(const GameStateConstrParams& params)
+ : GameState(params)
, inputState_(0)
{
}
@@ -66,7 +66,7 @@
this->camera_ = this->scene_->getSceneManager()->createCamera("mainMenu/Camera");
// show main menu
- GUIManager::getInstance().showGUI("mainmenu_2");
+ GUIManager::getInstance().showGUI("mainmenu_3");
GUIManager::getInstance().setCamera(this->camera_);
GraphicsManager::getInstance().setCamera(this->camera_);
Modified: trunk/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- trunk/src/orxonox/gamestates/GSMainMenu.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSMainMenu.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -39,7 +39,7 @@
class _OrxonoxExport GSMainMenu : public GameState
{
public:
- GSMainMenu(const std::string& name);
+ GSMainMenu(const GameStateConstrParams& params);
~GSMainMenu();
void activate();
Modified: trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSRoot.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSRoot.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -36,19 +36,20 @@
#include "tools/Timer.h"
#include "interfaces/TimeFactorListener.h"
#include "interfaces/Tickable.h"
+#include "LevelManager.h"
namespace orxonox
{
- AddGameState(GSRoot, "root", false);
- SetCommandLineSwitch(console);
+ DeclareGameState(GSRoot, "root", true, false);
+ SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
// Shortcuts for easy direct loading
- SetCommandLineSwitch(server);
- SetCommandLineSwitch(client);
- SetCommandLineSwitch(dedicated);
- SetCommandLineSwitch(standalone);
+ SetCommandLineSwitch(server).information("Start in server mode");
+ SetCommandLineSwitch(client).information("Start in client mode");
+ SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
+ SetCommandLineSwitch(standalone).information("Start in standalone mode");
- GSRoot::GSRoot(const std::string& name, bool countTickTime)
- : GameState(name, countTickTime)
+ GSRoot::GSRoot(const GameStateConstrParams& params)
+ : GameState(params)
, timeFactor_(1.0f)
, bPaused_(false)
, timeFactorPauseBackup_(1.0f)
@@ -82,6 +83,9 @@
CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
}
+ // create the global LevelManager
+ this->levelManager_ = new LevelManager();
+
// Load level directly?
bool loadLevel = false;
if (CommandLine::getValue("standalone").getBool())
@@ -128,6 +132,8 @@
this->ccPause_ = 0;
}
*/
+
+ delete this->levelManager_;
}
void GSRoot::update(const Clock& time)
Modified: trunk/src/orxonox/gamestates/GSRoot.h
===================================================================
--- trunk/src/orxonox/gamestates/GSRoot.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSRoot.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
class _OrxonoxExport GSRoot : public GameState
{
public:
- GSRoot(const std::string& name, bool countTickTime);
+ GSRoot(const GameStateConstrParams& params);
~GSRoot();
void activate();
@@ -51,10 +51,12 @@
float getTimeFactor() { return this->timeFactor_; }
private:
- float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.
+ float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.
bool bPaused_;
float timeFactorPauseBackup_;
+ LevelManager* levelManager_; //!< global level manager
+
// console commands
ConsoleCommand* ccSetTimeFactor_;
ConsoleCommand* ccPause_;
Modified: trunk/src/orxonox/gamestates/GSServer.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSServer.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSServer.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -36,12 +36,12 @@
namespace orxonox
{
- AddGameState(GSServer, "server");
+ DeclareGameState(GSServer, "server", false, true);
- SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
+ SetCommandLineArgument(port, 55556).shortcut("p").information("Network communication port to be used 0-65535 (default: 55556)");
- GSServer::GSServer(const std::string& name)
- : GameState(name)
+ GSServer::GSServer(const GameStateConstrParams& params)
+ : GameState(params)
, server_(0)
{
}
Modified: trunk/src/orxonox/gamestates/GSServer.h
===================================================================
--- trunk/src/orxonox/gamestates/GSServer.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSServer.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -39,7 +39,7 @@
class _OrxonoxExport GSServer : public GameState
{
public:
- GSServer(const std::string& name);
+ GSServer(const GameStateConstrParams& params);
~GSServer();
void activate();
Modified: trunk/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSStandalone.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSStandalone.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,10 +33,10 @@
namespace orxonox
{
- AddGameState(GSStandalone, "standalone");
+ DeclareGameState(GSStandalone, "standalone", false, true);
- GSStandalone::GSStandalone(const std::string& name)
- : GameState(name)
+ GSStandalone::GSStandalone(const GameStateConstrParams& params)
+ : GameState(params)
{
}
Modified: trunk/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- trunk/src/orxonox/gamestates/GSStandalone.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gamestates/GSStandalone.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
class _OrxonoxExport GSStandalone : public GameState
{
public:
- GSStandalone(const std::string& name);
+ GSStandalone(const GameStateConstrParams& params);
~GSStandalone();
void activate();
Modified: trunk/src/orxonox/gui/GUIManager.cc
===================================================================
--- trunk/src/orxonox/gui/GUIManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gui/GUIManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -52,7 +52,9 @@
# include <CEGUILua.h>
#endif
+#include "util/Debug.h"
#include "util/Exception.h"
+#include "util/OrxAssert.h"
#include "core/Core.h"
#include "core/Clock.h"
#include "ToluaBindCore.h"
@@ -61,6 +63,28 @@
namespace orxonox
{
+ class CEGUILogger : public CEGUI::DefaultLogger
+ {
+ public:
+ void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
+ {
+ int orxonoxLevel;
+ 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;
+ default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!");
+ }
+ OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+ << "CEGUI: " << message << std::endl;
+
+ CEGUI::DefaultLogger::logEvent(message, level);
+ }
+ };
+
static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
GUIManager* GUIManager::singletonRef_s = 0;
@@ -139,7 +163,7 @@
this->luaState_ = this->scriptModule_->getLuaState();
// Create our own logger to specify the filepath
- this->ceguiLogger_ = new DefaultLogger();
+ this->ceguiLogger_ = new CEGUILogger();
this->ceguiLogger_->setLogFilename(Core::getLogPathString() + "cegui.log");
// set the log level according to ours (translate by subtracting 1)
this->ceguiLogger_->setLoggingLevel(
Modified: trunk/src/orxonox/gui/GUIManager.h
===================================================================
--- trunk/src/orxonox/gui/GUIManager.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/gui/GUIManager.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -122,7 +122,7 @@
CEGUI::OgreCEGUIRenderer* guiRenderer_; //!< CEGUI's interface to the Ogre Engine
CEGUI::ResourceProvider* resourceProvider_; //!< CEGUI's resource provider
CEGUI::LuaScriptModule* scriptModule_; //!< CEGUI's script module to use Lua
- CEGUI::DefaultLogger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
+ CEGUI::Logger* ceguiLogger_; //!< CEGUI's logger to be able to log CEGUI errors in our log
CEGUI::System* guiSystem_; //!< CEGUI's main system
lua_State* luaState_; //!< Lua state, access point to the Lua engine
Modified: trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- trunk/src/orxonox/interfaces/RadarViewable.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/interfaces/RadarViewable.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -32,7 +32,7 @@
#include <OgreSceneNode.h>
#include <OgreEntity.h>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "tools/DynamicLines.h"
#include "objects/worldentities/WorldEntity.h"
Property changes on: trunk/src/orxonox/interfaces/TeamColourable.h
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/buildsystem/src/orxonox/interfaces/Teamcolourable.h:1875-2277,2279-2401
/branches/buildsystem2/src/orxonox/interfaces/Teamcolourable.h:2507-2659
/branches/buildsystem3/src/orxonox/interfaces/Teamcolourable.h:2663-2709
/branches/ceguilua/src/orxonox/interfaces/Teamcolourable.h:1803-1809
/branches/core3/src/orxonox/interfaces/Teamcolourable.h:1573-1740
/branches/gametypes/src/orxonox/interfaces/Teamcolourable.h:2827-3032
/branches/gcc43/src/orxonox/interfaces/Teamcolourable.h:1581
/branches/gui/src/orxonox/interfaces/Teamcolourable.h:1636-1724,2796-2895
/branches/input/src/orxonox/interfaces/Teamcolourable.h:1630-1637
/branches/lodfinal/src/orxonox/interfaces/Teamcolourable.h:2373-2412
/branches/map/src/orxonox/interfaces/Teamcolourable.h:2802-3087,3090
/branches/miniprojects/src/orxonox/interfaces/Teamcolourable.h:2755-2825
/branches/netp2/src/orxonox/interfaces/Teamcolourable.h:2836-2989
/branches/netp3/src/orxonox/interfaces/Teamcolourable.h:2989-3083
/branches/network/src/orxonox/interfaces/Teamcolourable.h:2357
/branches/network64/src/orxonox/interfaces/Teamcolourable.h:2211-2356
/branches/objecthierarchy/src/orxonox/interfaces/Teamcolourable.h:1912-2086,2101,2111-2170
/branches/objecthierarchy2/src/orxonox/interfaces/Teamcolourable.h:2172-2480
/branches/overlay/src/orxonox/interfaces/Teamcolourable.h:2118-2386
/branches/particles/src/orxonox/interfaces/Teamcolourable.h:2830-3086
/branches/physics/src/orxonox/interfaces/Teamcolourable.h:1913-2056,2108-2440
/branches/physics_merge/src/orxonox/interfaces/Teamcolourable.h:2437-2458
/branches/pickups/src/orxonox/interfaces/Teamcolourable.h:1927-2087,2128,2828-2916
/branches/pickups2/src/orxonox/interfaces/Teamcolourable.h:2108-2498,2916-3072
/branches/presentation/src/orxonox/interfaces/Teamcolourable.h:2370-2653,2655-2661
/branches/questsystem/src/orxonox/interfaces/Teamcolourable.h:1895-2089
/branches/questsystem2/src/orxonox/interfaces/Teamcolourable.h:2108-2260
/branches/questsystem5/src/orxonox/interfaces/Teamcolourable.h:2777-2906
/branches/script_trigger/src/orxonox/interfaces/Teamcolourable.h:1296-1954,1956
/branches/sound/src/orxonox/interfaces/Teamcolourable.h:2830-3011
/branches/weapon/src/orxonox/interfaces/Teamcolourable.h:1926-2095
/branches/weapon2/src/orxonox/interfaces/Teamcolourable.h:2108-2489
/branches/weapons/src/orxonox/interfaces/Teamcolourable.h:2898-3052
/branches/weaponsystem/src/orxonox/interfaces/Teamcolourable.h:2743-2891
+ /branches/buildsystem/src/orxonox/interfaces/Teamcolourable.h:1875-2277,2279-2401
/branches/buildsystem2/src/orxonox/interfaces/Teamcolourable.h:2507-2659
/branches/buildsystem3/src/orxonox/interfaces/Teamcolourable.h:2663-2709
/branches/ceguilua/src/orxonox/interfaces/Teamcolourable.h:1803-1809
/branches/core3/src/orxonox/interfaces/Teamcolourable.h:1573-1740
/branches/core4/src/orxonox/interfaces/TeamColourable.h:3228,3235-3238,3243,3245-3251,3253-3255,3257,3260-3262,3265-3266,3269,3271,3278
/branches/gametypes/src/orxonox/interfaces/Teamcolourable.h:2827-3032
/branches/gcc43/src/orxonox/interfaces/Teamcolourable.h:1581
/branches/gui/src/orxonox/interfaces/Teamcolourable.h:1636-1724,2796-2895
/branches/input/src/orxonox/interfaces/Teamcolourable.h:1630-1637
/branches/lodfinal/src/orxonox/interfaces/Teamcolourable.h:2373-2412
/branches/map/src/orxonox/interfaces/Teamcolourable.h:2802-3087,3090
/branches/miniprojects/src/orxonox/interfaces/Teamcolourable.h:2755-2825
/branches/netp2/src/orxonox/interfaces/Teamcolourable.h:2836-2989
/branches/netp3/src/orxonox/interfaces/Teamcolourable.h:2989-3083
/branches/network/src/orxonox/interfaces/Teamcolourable.h:2357
/branches/network64/src/orxonox/interfaces/Teamcolourable.h:2211-2356
/branches/objecthierarchy/src/orxonox/interfaces/Teamcolourable.h:1912-2086,2101,2111-2170
/branches/objecthierarchy2/src/orxonox/interfaces/Teamcolourable.h:2172-2480
/branches/overlay/src/orxonox/interfaces/Teamcolourable.h:2118-2386
/branches/particles/src/orxonox/interfaces/Teamcolourable.h:2830-3086
/branches/physics/src/orxonox/interfaces/Teamcolourable.h:1913-2056,2108-2440
/branches/physics_merge/src/orxonox/interfaces/Teamcolourable.h:2437-2458
/branches/pickups/src/orxonox/interfaces/Teamcolourable.h:1927-2087,2128,2828-2916
/branches/pickups2/src/orxonox/interfaces/Teamcolourable.h:2108-2498,2916-3072
/branches/presentation/src/orxonox/interfaces/Teamcolourable.h:2370-2653,2655-2661
/branches/questsystem/src/orxonox/interfaces/Teamcolourable.h:1895-2089
/branches/questsystem2/src/orxonox/interfaces/Teamcolourable.h:2108-2260
/branches/questsystem5/src/orxonox/interfaces/Teamcolourable.h:2777-2906
/branches/script_trigger/src/orxonox/interfaces/Teamcolourable.h:1296-1954,1956
/branches/sound/src/orxonox/interfaces/Teamcolourable.h:2830-3011
/branches/weapon/src/orxonox/interfaces/Teamcolourable.h:1926-2095
/branches/weapon2/src/orxonox/interfaces/Teamcolourable.h:2108-2489
/branches/weapons/src/orxonox/interfaces/Teamcolourable.h:2898-3052
/branches/weaponsystem/src/orxonox/interfaces/Teamcolourable.h:2743-2891
Modified: trunk/src/orxonox/objects/GlobalShader.cc
===================================================================
--- trunk/src/orxonox/objects/GlobalShader.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/GlobalShader.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -65,8 +65,8 @@
void GlobalShader::registerVariables()
{
- registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
- registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), variableDirection::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
+ registerVariable(this->bVisible_, VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
+ registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
}
void GlobalShader::changedVisibility()
Modified: trunk/src/orxonox/objects/Level.cc
===================================================================
--- trunk/src/orxonox/objects/Level.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/Level.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -86,9 +86,9 @@
void Level::registerVariables()
{
- registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
- registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName));
- registerVariable(this->description_, variableDirection::toclient);
+ registerVariable(this->xmlfilename_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
+ registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::changedName));
+ registerVariable(this->description_, VariableDirection::ToClient);
}
void Level::networkcallback_applyXMLFile()
Modified: trunk/src/orxonox/objects/Scene.cc
===================================================================
--- trunk/src/orxonox/objects/Scene.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/Scene.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -114,13 +114,13 @@
void Scene::registerVariables()
{
- registerVariable(this->skybox_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
- registerVariable(this->ambientLight_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
- registerVariable(this->negativeWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange));
- registerVariable(this->positiveWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange));
- registerVariable(this->gravity_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
- registerVariable(this->bHasPhysics_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
- registerVariable(this->bShadows_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
+ registerVariable(this->skybox_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
+ registerVariable(this->ambientLight_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
+ registerVariable(this->negativeWorldRange_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange));
+ registerVariable(this->positiveWorldRange_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange));
+ registerVariable(this->gravity_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
+ registerVariable(this->bHasPhysics_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
+ registerVariable(this->bShadows_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
}
void Scene::setNegativeWorldRange(const Vector3& range)
Modified: trunk/src/orxonox/objects/collisionshapes/BoxCollisionShape.cc
===================================================================
--- trunk/src/orxonox/objects/collisionshapes/BoxCollisionShape.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/collisionshapes/BoxCollisionShape.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -56,7 +56,7 @@
void BoxCollisionShape::registerVariables()
{
- registerVariable(this->halfExtents_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
+ registerVariable(this->halfExtents_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
}
void BoxCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Modified: trunk/src/orxonox/objects/collisionshapes/CollisionShape.cc
===================================================================
--- trunk/src/orxonox/objects/collisionshapes/CollisionShape.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/collisionshapes/CollisionShape.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -76,7 +76,7 @@
void CollisionShape::registerVariables()
{
- registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
+ registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
}
void CollisionShape::parentChanged()
Modified: trunk/src/orxonox/objects/collisionshapes/ConeCollisionShape.cc
===================================================================
--- trunk/src/orxonox/objects/collisionshapes/ConeCollisionShape.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/collisionshapes/ConeCollisionShape.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -56,8 +56,8 @@
void ConeCollisionShape::registerVariables()
{
- registerVariable(this->radius_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- registerVariable(this->height_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
+ registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
+ registerVariable(this->height_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
}
void ConeCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Modified: trunk/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc
===================================================================
--- trunk/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -57,8 +57,8 @@
void PlaneCollisionShape::registerVariables()
{
- registerVariable(this->normal_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
- registerVariable(this->offset_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
+ registerVariable(this->normal_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
+ registerVariable(this->offset_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
}
void PlaneCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Modified: trunk/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc
===================================================================
--- trunk/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -55,7 +55,7 @@
void SphereCollisionShape::registerVariables()
{
- registerVariable(this->radius_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
+ registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
}
void SphereCollisionShape::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Modified: trunk/src/orxonox/objects/controllers/ArtificialController.cc
===================================================================
--- trunk/src/orxonox/objects/controllers/ArtificialController.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/controllers/ArtificialController.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -207,13 +207,13 @@
{
switch (base->getState())
{
- case BaseState::controlTeam1:
+ case BaseState::ControlTeam1:
team1 = 0;
break;
- case BaseState::controlTeam2:
+ case BaseState::ControlTeam2:
team1 = 1;
break;
- case BaseState::uncontrolled:
+ case BaseState::Uncontrolled:
default:
team1 = -1;
}
@@ -223,13 +223,13 @@
{
switch (base->getState())
{
- case BaseState::controlTeam1:
+ case BaseState::ControlTeam1:
team2 = 0;
break;
- case BaseState::controlTeam2:
+ case BaseState::ControlTeam2:
team2 = 1;
break;
- case BaseState::uncontrolled:
+ case BaseState::Uncontrolled:
default:
team2 = -1;
}
Modified: trunk/src/orxonox/objects/gametypes/Gametype.h
===================================================================
--- trunk/src/orxonox/objects/gametypes/Gametype.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/gametypes/Gametype.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -44,7 +44,7 @@
{
namespace PlayerState
{
- enum Enum
+ enum Value
{
Uninitialized,
Joined,
@@ -56,7 +56,7 @@
struct Player
{
PlayerInfo* info_;
- PlayerState::Enum state_;
+ PlayerState::Value state_;
int frags_;
int killed_;
};
Modified: trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -65,12 +65,12 @@
int teamnr = this->getTeam(originator->getPlayer());
if (teamnr == 0)
{
- base->setState(BaseState::controlTeam1);
+ base->setState(BaseState::ControlTeam1);
this->gtinfo_.sendAnnounceMessage("The red team captured a base");
}
if (teamnr == 1)
{
- base->setState(BaseState::controlTeam2);
+ base->setState(BaseState::ControlTeam2);
this->gtinfo_.sendAnnounceMessage("The blue team captured a base");
}
}
@@ -106,13 +106,13 @@
switch (base->getState())
{
- case BaseState::controlTeam1:
+ case BaseState::ControlTeam1:
teamnrbase = 0;
break;
- case BaseState::controlTeam2:
+ case BaseState::ControlTeam2:
teamnrbase = 1;
break;
- case BaseState::uncontrolled:
+ case BaseState::Uncontrolled:
default:
teamnrbase = -1;
}
@@ -154,11 +154,11 @@
for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
{
- if((*it)->getState() == BaseState::controlTeam1)
+ if((*it)->getState() == BaseState::ControlTeam1)
{
amountControlled++;
}
- if((*it)->getState() == BaseState::controlTeam2)
+ if((*it)->getState() == BaseState::ControlTeam2)
{
amountControlled2++;
}
@@ -240,9 +240,9 @@
for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
{
- if ((*it)->getState() == BaseState::controlTeam1 && team == 0)
+ if ((*it)->getState() == BaseState::ControlTeam1 && team == 0)
count++;
- if ((*it)->getState() == BaseState::controlTeam2 && team == 1)
+ if ((*it)->getState() == BaseState::ControlTeam2 && team == 1)
count++;
}
@@ -252,7 +252,7 @@
void TeamBaseMatch::addBase(TeamBaseMatchBase* base)
{
this->bases_.insert(base);
- base->setState(BaseState::uncontrolled);
+ base->setState(BaseState::Uncontrolled);
}
TeamBaseMatchBase* TeamBaseMatch::getBase(unsigned int index) const
Modified: trunk/src/orxonox/objects/gametypes/UnderAttack.cc
===================================================================
--- trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/gametypes/UnderAttack.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -172,7 +172,7 @@
//prints gametime
if ( gameTime_ <= timesequence_ && gameTime_ > 0)
{
- std::string message = convertToString(timesequence_) + " seconds left!";
+ std::string message = multi_cast<std::string>(timesequence_) + " seconds left!";
/*
COUT(0) << message << std::endl;
Host::Broadcast(message);
Modified: trunk/src/orxonox/objects/infos/GametypeInfo.cc
===================================================================
--- trunk/src/orxonox/objects/infos/GametypeInfo.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/infos/GametypeInfo.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -60,11 +60,11 @@
void GametypeInfo::registerVariables()
{
- registerVariable(this->bStarted_, variableDirection::toclient);
- registerVariable(this->bEnded_, variableDirection::toclient);
- registerVariable(this->startCountdown_, variableDirection::toclient);
- registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
- registerVariable(this->hudtemplate_, variableDirection::toclient);
+ registerVariable(this->bStarted_, VariableDirection::ToClient);
+ registerVariable(this->bEnded_, VariableDirection::ToClient);
+ registerVariable(this->startCountdown_, VariableDirection::ToClient);
+ registerVariable(this->bStartCountdownRunning_, VariableDirection::ToClient);
+ registerVariable(this->hudtemplate_, VariableDirection::ToClient);
}
void GametypeInfo::sendAnnounceMessage(const std::string& message)
Modified: trunk/src/orxonox/objects/infos/HumanPlayer.cc
===================================================================
--- trunk/src/orxonox/objects/infos/HumanPlayer.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/infos/HumanPlayer.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -78,11 +78,11 @@
void HumanPlayer::registerVariables()
{
- registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
+ registerVariable(this->synchronize_nick_, VariableDirection::ToServer, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
- registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
- registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
- registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
+ registerVariable(this->clientID_, VariableDirection::ToClient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
+ registerVariable(this->server_initialized_, VariableDirection::ToClient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
+ registerVariable(this->client_initialized_, VariableDirection::ToServer, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
}
void HumanPlayer::configvaluecallback_changednick()
@@ -115,7 +115,7 @@
this->client_initialized_ = true;
if (!GameMode::isMaster())
- this->setObjectMode(objectDirection::bidirectional);
+ this->setObjectMode(ObjectDirection::Bidirectional);
else
this->setName(this->nick_);
Modified: trunk/src/orxonox/objects/infos/PlayerInfo.cc
===================================================================
--- trunk/src/orxonox/objects/infos/PlayerInfo.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/infos/PlayerInfo.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -76,10 +76,10 @@
void PlayerInfo::registerVariables()
{
- registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
- registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
- registerVariable(this->bReadyToSpawn_, variableDirection::toserver);
- registerVariable(this->gtinfoID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
+ registerVariable(this->name_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
+ registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
+ registerVariable(this->bReadyToSpawn_, VariableDirection::ToServer);
+ registerVariable(this->gtinfoID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
}
void PlayerInfo::changedName()
Modified: trunk/src/orxonox/objects/items/Engine.cc
===================================================================
--- trunk/src/orxonox/objects/items/Engine.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/items/Engine.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -112,21 +112,21 @@
void Engine::registerVariables()
{
- registerVariable(this->shipID_, variableDirection::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
+ registerVariable(this->shipID_, VariableDirection::ToClient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
- registerVariable(this->speedFactor_, variableDirection::toclient);
- registerVariable(this->boostFactor_, variableDirection::toclient);
+ registerVariable(this->speedFactor_, VariableDirection::ToClient);
+ registerVariable(this->boostFactor_, VariableDirection::ToClient);
- registerVariable(this->maxSpeedFront_, variableDirection::toclient);
- registerVariable(this->maxSpeedBack_, variableDirection::toclient);
- registerVariable(this->maxSpeedLeftRight_, variableDirection::toclient);
- registerVariable(this->maxSpeedUpDown_, variableDirection::toclient);
+ registerVariable(this->maxSpeedFront_, VariableDirection::ToClient);
+ registerVariable(this->maxSpeedBack_, VariableDirection::ToClient);
+ registerVariable(this->maxSpeedLeftRight_, VariableDirection::ToClient);
+ registerVariable(this->maxSpeedUpDown_, VariableDirection::ToClient);
- registerVariable(this->accelerationFront_, variableDirection::toclient);
- registerVariable(this->accelerationBrake_, variableDirection::toclient);
- registerVariable(this->accelerationBack_, variableDirection::toclient);
- registerVariable(this->accelerationLeftRight_, variableDirection::toclient);
- registerVariable(this->accelerationUpDown_, variableDirection::toclient);
+ registerVariable(this->accelerationFront_, VariableDirection::ToClient);
+ registerVariable(this->accelerationBrake_, VariableDirection::ToClient);
+ registerVariable(this->accelerationBack_, VariableDirection::ToClient);
+ registerVariable(this->accelerationLeftRight_, VariableDirection::ToClient);
+ registerVariable(this->accelerationUpDown_, VariableDirection::ToClient);
}
void Engine::networkcallback_shipID()
Modified: trunk/src/orxonox/objects/items/MultiStateEngine.cc
===================================================================
--- trunk/src/orxonox/objects/items/MultiStateEngine.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/items/MultiStateEngine.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -81,7 +81,7 @@
void MultiStateEngine::registerVariables()
{
- registerVariable(this->state_, variableDirection::toserver);
+ registerVariable(this->state_, VariableDirection::ToServer);
}
void MultiStateEngine::tick(float dt)
@@ -90,7 +90,7 @@
{
if (this->getShip()->hasLocalController())
{
- this->setObjectMode(objectDirection::bidirectional);
+ this->setObjectMode(ObjectDirection::Bidirectional);
const Vector3& direction = this->getDirection();
const Vector3& velocity = this->getShip()->getLocalVelocity();
Modified: trunk/src/orxonox/objects/pickup/ModifierPickup.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/ModifierPickup.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/pickup/ModifierPickup.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -86,7 +86,7 @@
{
if (this->addTo(pawn))
{
- std::map<ModifierType::Enum, float>::iterator it;
+ std::map<ModifierType::Value, float>::iterator it;
for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
{
@@ -123,7 +123,7 @@
{
if (this->removeFrom(pawn))
{
- std::map<ModifierType::Enum, float>::iterator it;
+ std::map<ModifierType::Value, float>::iterator it;
for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
{
@@ -157,9 +157,9 @@
@param type ModifierType for which to return the modifier.
@return Returns the additive modifier for type (or 0 if not exists).
*/
- float ModifierPickup::getAdditiveModifier(ModifierType::Enum type) const
+ float ModifierPickup::getAdditiveModifier(ModifierType::Value type) const
{
- std::map<ModifierType::Enum, float>::const_iterator it = this->additiveModifiers_.find(type);
+ std::map<ModifierType::Value, float>::const_iterator it = this->additiveModifiers_.find(type);
if (it != this->additiveModifiers_.end())
return (*it).second;
else
@@ -170,9 +170,9 @@
@param type ModifierType for which to return the modifier.
@return Returns the multiplicative modifier for type (or 1 if not exists).
*/
- float ModifierPickup::getMultiplicativeModifier(ModifierType::Enum type) const
+ float ModifierPickup::getMultiplicativeModifier(ModifierType::Value type) const
{
- std::map<ModifierType::Enum, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
+ std::map<ModifierType::Value, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
if (it != this->multiplicativeModifiers_.end())
return (*it).second;
else
@@ -183,10 +183,10 @@
@param type ModifierType for which to return the modifier.
@param value The new additive modifier for type.
*/
- void ModifierPickup::setAdditiveModifier(ModifierType::Enum type, float value)
+ void ModifierPickup::setAdditiveModifier(ModifierType::Value type, float value)
{
if (this->additiveModifiers_.find(type) == this->additiveModifiers_.end())
- this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ this->additiveModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
else
this->additiveModifiers_[type] = value;
}
@@ -195,10 +195,10 @@
@param type ModifierType for which to return the modifier.
@param value The new multiplicative modifier for type.
*/
- void ModifierPickup::setMultiplicativeModifier(ModifierType::Enum type, float value)
+ void ModifierPickup::setMultiplicativeModifier(ModifierType::Value type, float value)
{
if (this->multiplicativeModifiers_.find(type) == this->multiplicativeModifiers_.end())
- this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
else
this->multiplicativeModifiers_[type] = value;
}
Modified: trunk/src/orxonox/objects/pickup/ModifierPickup.h
===================================================================
--- trunk/src/orxonox/objects/pickup/ModifierPickup.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/pickup/ModifierPickup.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -129,13 +129,13 @@
void timerCallback(Pawn* pawn); //!< Method called when the timer runs out.
private:
- float getAdditiveModifier(ModifierType::Enum type) const; //!< Get the additive modifier for a given ModifierType.
- float getMultiplicativeModifier(ModifierType::Enum type) const; //!< Get the multiplicative modifier for a given ModifierType.
- void setAdditiveModifier(ModifierType::Enum type, float value); //!< Set the additive modifier for a given ModifierType.
- void setMultiplicativeModifier(ModifierType::Enum type, float value); //!< Set the multiplicative modifier for a given ModifierType
+ float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType.
+ float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType.
+ void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType.
+ void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType
- std::map<ModifierType::Enum, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.
- std::map<ModifierType::Enum, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.
+ std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.
+ std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.
float duration_; //!< Duration of this pickup's effect (0 for unlimited).
Timer<ModifierPickup> timer_; //!< Timer used if the pickup's effect has a time limit.
Modified: trunk/src/orxonox/objects/pickup/ModifierType.h
===================================================================
--- trunk/src/orxonox/objects/pickup/ModifierType.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/pickup/ModifierType.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -43,7 +43,7 @@
/**
@brief Gives the available types for modifiers.
*/
- enum Enum
+ enum Value
{
Unknown = 0,
Damage,
Modified: trunk/src/orxonox/objects/pickup/PickupCollection.cc
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupCollection.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/pickup/PickupCollection.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -41,7 +41,7 @@
namespace orxonox
{
typedef std::pair<std::multimap<std::string, BaseItem*>::iterator, std::multimap<std::string, BaseItem*>::iterator> item_range;
- typedef std::pair<std::multimap<ModifierType::Enum, float>::iterator, std::multimap<ModifierType::Enum, float>::iterator> modifier_range;
+ typedef std::pair<std::multimap<ModifierType::Value, float>::iterator, std::multimap<ModifierType::Value, float>::iterator> modifier_range;
//! Constructor
PickupCollection::PickupCollection()
@@ -199,22 +199,22 @@
@param type ModifierType to add.
@param value Value for the modifier.
*/
- void PickupCollection::addAdditiveModifier(ModifierType::Enum type, float value)
+ void PickupCollection::addAdditiveModifier(ModifierType::Value type, float value)
{
- this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ this->additiveModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
}
/**
@brief Get the total amount of an additive modifier.
@param type Type for which to get the total.
@return Returns the sum of the additive modifiers of the type.
*/
- float PickupCollection::getAdditiveModifier(ModifierType::Enum type)
+ float PickupCollection::getAdditiveModifier(ModifierType::Value type)
{
float v = 0.0f;
modifier_range range = this->additiveModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
+ for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
{
v += (*it).second;
}
@@ -226,10 +226,10 @@
@param type Type of modifier.
@param value Value which is to be removed.
*/
- void PickupCollection::removeAdditiveModifier(ModifierType::Enum type, float value)
+ void PickupCollection::removeAdditiveModifier(ModifierType::Value type, float value)
{
modifier_range range = this->additiveModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
+ for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
{
if ((*it).second == value)
{
@@ -243,21 +243,21 @@
@param type ModifierType to add.
@param value Value for the modifier.
*/
- void PickupCollection::addMultiplicativeModifier(ModifierType::Enum type, float value)
+ void PickupCollection::addMultiplicativeModifier(ModifierType::Value type, float value)
{
- this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
+ this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
}
/**
@brief Get the total amount of a multiplicative modifier.
@param type Type for which to get the total.
@return Returns the product of the multiplicative modifiers of the type.
*/
- float PickupCollection::getMultiplicativeModifier(ModifierType::Enum type)
+ float PickupCollection::getMultiplicativeModifier(ModifierType::Value type)
{
float v = 1.0f;
modifier_range range = this->multiplicativeModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
+ for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
{
v *= (*it).second;
}
@@ -269,10 +269,10 @@
@param type Type of modifier.
@param value Value which is to be removed.
*/
- void PickupCollection::removeMultiplicativeModifier(ModifierType::Enum type, float value)
+ void PickupCollection::removeMultiplicativeModifier(ModifierType::Value type, float value)
{
modifier_range range = this->multiplicativeModifiers_.equal_range(type);
- for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
+ for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
{
if ((*it).second == value)
{
@@ -288,7 +288,7 @@
@param addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
@return Returns the value after being processed.
*/
- float PickupCollection::processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication)
+ float PickupCollection::processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication)
{
float outputValue = inputValue;
@@ -309,7 +309,7 @@
@param addBeforeMultiplication Whether to apply the additive modifier before the multiplicative one (default: false).
@return Returns the value after being processed.
*/
- Vector3 PickupCollection::processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication)
+ Vector3 PickupCollection::processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication)
{
Vector3 outputValue = inputValue;
Modified: trunk/src/orxonox/objects/pickup/PickupCollection.h
===================================================================
--- trunk/src/orxonox/objects/pickup/PickupCollection.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/pickup/PickupCollection.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -66,17 +66,17 @@
void useItem(); //!< Use the first usable item.
void useItem(UsableItem* item); //!< Use a usable item.
- void addAdditiveModifier(ModifierType::Enum type, float value); //!< Add an additive modifier.
- void addMultiplicativeModifier(ModifierType::Enum type, float value); //!< Add a multiplicative modifier.
+ void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier.
+ void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier.
- float getAdditiveModifier(ModifierType::Enum type); //!< Get total additive modifier.
- float getMultiplicativeModifier(ModifierType::Enum type); //!< Get total multiplicative modifier.
+ float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier.
+ float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier.
- void removeAdditiveModifier(ModifierType::Enum type, float value); //!< Remove an additive modifier.
- void removeMultiplicativeModifier(ModifierType::Enum type, float value); //!< Remove a multiplicative modifier.
+ void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier.
+ void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier.
- float processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.
- Vector3 processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.
+ float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.
+ Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.
/**
@brief Get the map of contained items.
@@ -112,8 +112,8 @@
bool bBlockRemovals_; //!< Whether to block direct removals through remove().
- std::multimap<ModifierType::Enum, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).
- std::multimap<ModifierType::Enum, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).
+ std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).
+ std::multimap<ModifierType::Value, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).
std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items).
};
Modified: trunk/src/orxonox/objects/quest/GlobalQuest.cc
===================================================================
--- trunk/src/orxonox/objects/quest/GlobalQuest.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/GlobalQuest.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -146,7 +146,7 @@
{
return false;
}
- return (this->isInactive(player) && !(this->status_ == questStatus::completed || this->status_ == questStatus::failed));
+ return (this->isInactive(player) && !(this->status_ == QuestStatus::Completed || this->status_ == QuestStatus::Failed));
}
/**
@@ -188,7 +188,7 @@
@throws
Throws an Exception if player is NULL.
*/
- questStatus::Enum GlobalQuest::getStatus(const PlayerInfo* player) const
+ QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const
{
if(player == NULL) //!< We don't want NULL-Pointers!
{
@@ -202,7 +202,7 @@
return this->status_;
}
- return questStatus::inactive;
+ return QuestStatus::Inactive;
}
/**
@@ -216,7 +216,7 @@
@return
Returns false if player is NULL.
*/
- bool GlobalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status)
+ bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
{
if(player == NULL) //!< We don't want NULL-Pointers!
{
Modified: trunk/src/orxonox/objects/quest/GlobalQuest.h
===================================================================
--- trunk/src/orxonox/objects/quest/GlobalQuest.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/GlobalQuest.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -96,13 +96,13 @@
virtual bool isFailable(const PlayerInfo* player) const; //!< Checks whether the Quest can be failed.
virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
- virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
+ virtual QuestStatus::Value getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
- virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
+ virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status); //!< Sets the status for a specific player.
private:
std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest.
- questStatus::Enum status_; //!< The status of this Quest.
+ QuestStatus::Value status_; //!< The status of this Quest.
std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
bool addRewardEffect(QuestEffect* effect); //!< Adds a reward QuestEffect to the list of reward QuestEffects.
Modified: trunk/src/orxonox/objects/quest/LocalQuest.cc
===================================================================
--- trunk/src/orxonox/objects/quest/LocalQuest.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/LocalQuest.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -175,20 +175,20 @@
@throws
Throws an Exception if player is NULL.
*/
- questStatus::Enum LocalQuest::getStatus(const PlayerInfo* player) const
+ QuestStatus::Value LocalQuest::getStatus(const PlayerInfo* player) const
{
if(player == NULL) //!< No player has no defined status.
{
ThrowException(Argument, "The input PlayerInfo* is NULL.");
}
- std::map<const PlayerInfo*, questStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
+ std::map<const PlayerInfo*, QuestStatus::Value>::const_iterator it = this->playerStatus_.find(player);
if (it != this->playerStatus_.end()) //!< If there is a player in the map.
{
return it->second;
}
- return questStatus::inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.
+ return QuestStatus::Inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.
}
/**
@@ -202,7 +202,7 @@
@return
Returns false if player is NULL.
*/
- bool LocalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status)
+ bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
{
if(player == NULL) //!< We can't set a status for no player.
{
Modified: trunk/src/orxonox/objects/quest/LocalQuest.h
===================================================================
--- trunk/src/orxonox/objects/quest/LocalQuest.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/LocalQuest.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -90,11 +90,11 @@
virtual bool isFailable(const PlayerInfo* player) const; //!< Checks whether the Quest can be failed.
virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
- virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
- virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
+ virtual QuestStatus::Value getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
+ virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status); //!< Sets the status for a specific player.
private:
- std::map<const PlayerInfo*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
+ std::map<const PlayerInfo*, QuestStatus::Value> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
};
Modified: trunk/src/orxonox/objects/quest/Quest.cc
===================================================================
--- trunk/src/orxonox/objects/quest/Quest.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/Quest.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -301,7 +301,7 @@
*/
bool Quest::isInactive(const PlayerInfo* player) const
{
- return this->getStatus(player) == questStatus::inactive;
+ return this->getStatus(player) == QuestStatus::Inactive;
}
/**
@@ -317,7 +317,7 @@
bool Quest::isActive(const PlayerInfo* player) const
{
- return this->getStatus(player) == questStatus::active;
+ return this->getStatus(player) == QuestStatus::Active;
}
/**
@@ -332,7 +332,7 @@
*/
bool Quest::isFailed(const PlayerInfo* player) const
{
- return this->getStatus(player) == questStatus::failed;
+ return this->getStatus(player) == QuestStatus::Failed;
}
/**
@@ -347,7 +347,7 @@
*/
bool Quest::isCompleted(const PlayerInfo* player) const
{
- return this->getStatus(player) == questStatus::completed;
+ return this->getStatus(player) == QuestStatus::Completed;
}
/**
@@ -361,7 +361,7 @@
bool Quest::fail(PlayerInfo* player)
{
QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed.
- this->setStatus(player, questStatus::failed);
+ this->setStatus(player, QuestStatus::Failed);
COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl;
@@ -380,7 +380,7 @@
bool Quest::complete(PlayerInfo* player)
{
QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed.
- this->setStatus(player, questStatus::completed);
+ this->setStatus(player, QuestStatus::Completed);
COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl;
@@ -408,7 +408,7 @@
QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active.
- this->setStatus(player, questStatus::active);
+ this->setStatus(player, QuestStatus::Active);
this->getDescription()->sendAddQuestNotification();
return true;
Modified: trunk/src/orxonox/objects/quest/Quest.h
===================================================================
--- trunk/src/orxonox/objects/quest/Quest.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/Quest.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,18 +42,16 @@
namespace orxonox
{
- namespace questStatus
+ namespace QuestStatus
{
-
//!Different states of a Quest.
- enum Enum
+ enum Value
{
- inactive,
- active,
- failed,
- completed
+ Inactive,
+ Active,
+ Failed,
+ Completed
};
-
}
/**
@@ -132,8 +130,8 @@
inline std::list<QuestEffect*> & getCompleteEffectList(void)
{ return this->completeEffects_; }
- virtual questStatus::Enum getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
- virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
+ virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
+ virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
private:
Quest* parentQuest_; //!< Pointer to the parentquest.
Modified: trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc
===================================================================
--- trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -52,7 +52,7 @@
{
RegisterObject(QuestEffectBeacon);
- this->status_ = QuestEffectBeaconStatus::active;
+ this->status_ = QuestEffectBeaconStatus::Active;
this->times_ = INFINITE_TIME;
}
@@ -161,11 +161,11 @@
if(activate)
{
- this->status_ = QuestEffectBeaconStatus::active;
+ this->status_ = QuestEffectBeaconStatus::Active;
return true;
}
- this->status_ = QuestEffectBeaconStatus::inactive;
+ this->status_ = QuestEffectBeaconStatus::Inactive;
return true;
}
@@ -189,7 +189,7 @@
this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed.
if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
{
- this->status_ = QuestEffectBeaconStatus::inactive;
+ this->status_ = QuestEffectBeaconStatus::Inactive;
}
return true;
Modified: trunk/src/orxonox/objects/quest/QuestEffectBeacon.h
===================================================================
--- trunk/src/orxonox/objects/quest/QuestEffectBeacon.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/QuestEffectBeacon.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -43,14 +43,12 @@
{
namespace QuestEffectBeaconStatus
{
-
//! The status of the beacon, can be either active or inactive.
- enum Enum
+ enum Value
{
- inactive,
- active
+ Inactive,
+ Active
};
-
}
/**
@@ -97,7 +95,7 @@
@return Returns true if the QuestEffectBeacon is active, fals if not.
*/
inline bool isActive(void)
- { return this->status_ == QuestEffectBeaconStatus::active; }
+ { return this->status_ == QuestEffectBeaconStatus::Active; }
bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
@@ -116,7 +114,7 @@
std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
int times_; //!< Number of times the beacon can be exectued.
- QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
+ QuestEffectBeaconStatus::Value status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
bool addEffect(QuestEffect* effect); //!< Add a QuestEffect to the QuestEffectBeacon.
Modified: trunk/src/orxonox/objects/quest/QuestHint.cc
===================================================================
--- trunk/src/orxonox/objects/quest/QuestHint.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/QuestHint.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -94,13 +94,13 @@
}
//! Find the player.
- std::map<const PlayerInfo*, questHintStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
+ std::map<const PlayerInfo*, QuestHintStatus::Value>::const_iterator it = this->playerStatus_.find(player);
if (it != this->playerStatus_.end()) //!< If the player is in the map.
{
return it->second;
}
- return questStatus::inactive;
+ return QuestStatus::Inactive;
}
/**
@@ -117,7 +117,7 @@
{
if(!(this->isActive(player))) //!< If the hint is already active, activation is pointless.
{
- this->playerStatus_[player] = questHintStatus::active;
+ this->playerStatus_[player] = QuestHintStatus::Active;
this->getDescription()->sendAddHintNotification();
return true;
Modified: trunk/src/orxonox/objects/quest/QuestHint.h
===================================================================
--- trunk/src/orxonox/objects/quest/QuestHint.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/QuestHint.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -41,16 +41,14 @@
namespace orxonox
{
- namespace questHintStatus
+ namespace QuestHintStatus
{
-
//! The state of the hint.
- enum Enum
+ enum Value
{
- inactive,
- active
+ Inactive,
+ Active
};
-
}
/**
@@ -90,7 +88,7 @@
private:
Quest* quest_; //!< The Quest the QuestHint belongs to.
- std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
+ std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
};
Modified: trunk/src/orxonox/objects/quest/QuestListener.cc
===================================================================
--- trunk/src/orxonox/objects/quest/QuestListener.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/QuestListener.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -50,7 +50,7 @@
{
RegisterObject(QuestListener);
- this->mode_ = questListenerMode::all;
+ this->mode_ = QuestListenerMode::All;
this->quest_ = NULL;
}
@@ -131,24 +131,24 @@
{
if(mode == "all")
{
- this->mode_ = questListenerMode::all;
+ this->mode_ = QuestListenerMode::All;
}
else if(mode == "start")
{
- this->mode_ = questListenerMode::start;
+ this->mode_ = QuestListenerMode::Start;
}
else if(mode == "fail")
{
- this->mode_ = questListenerMode::fail;
+ this->mode_ = QuestListenerMode::Fail;
}
else if(mode == "complete")
{
- this->mode_ = questListenerMode::complete;
+ this->mode_ = QuestListenerMode::Complete;
}
else
{
COUT(2) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << std::endl;
- this->mode_ = questListenerMode::all;
+ this->mode_ = QuestListenerMode::All;
return false;
}
@@ -163,19 +163,19 @@
*/
std::string QuestListener::getMode(void)
{
- if(this->mode_ == questListenerMode::all)
+ if(this->mode_ == QuestListenerMode::All)
{
return "all";
}
- else if(this->mode_ == questListenerMode::start)
+ else if(this->mode_ == QuestListenerMode::Start)
{
return "start";
}
- else if(this->mode_ == questListenerMode::fail)
+ else if(this->mode_ == QuestListenerMode::Fail)
{
return "fail";
}
- else if(this->mode_ == questListenerMode::complete)
+ else if(this->mode_ == QuestListenerMode::Complete)
{
return "complete";
}
Modified: trunk/src/orxonox/objects/quest/QuestListener.h
===================================================================
--- trunk/src/orxonox/objects/quest/QuestListener.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/quest/QuestListener.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,18 +42,16 @@
namespace orxonox
{
- namespace questListenerMode
+ namespace QuestListenerMode
{
-
//! The mode of the QuestListener.
- enum Enum
+ enum Value
{
- all,
- start,
- fail,
- complete
+ All,
+ Start,
+ Fail,
+ Complete
};
-
}
/**
@@ -92,7 +90,7 @@
bool execute(void); //!< Executes the QuestListener, resp. fires an Event.
private:
- questListenerMode::Enum mode_; //!< The mode of the QuestListener.
+ QuestListenerMode::Value mode_; //!< The mode of the QuestListener.
Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
};
Modified: trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.cc
===================================================================
--- trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -55,7 +55,7 @@
{
this->materialBase_ = material;
- BillboardProjectile::setMaterial(material + convertToString(this->textureIndex_));
+ BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
}
void LightningGunProjectile::changeTexture()
Modified: trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.cc
===================================================================
--- trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -43,7 +43,7 @@
if (GameMode::showsGraphics())
{
- this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
+ this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::Normal);
this->attachOgreObject(this->particles_->getParticleSystem());
this->particles_->setKeepParticlesInLocalSpace(0);
Modified: trunk/src/orxonox/objects/worldentities/Backlight.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/Backlight.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Backlight.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -28,6 +28,7 @@
#include "Backlight.h"
+#include <algorithm>
#include <OgreRibbonTrail.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
@@ -107,11 +108,11 @@
void Backlight::registerVariables()
{
- registerVariable(this->width_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
- registerVariable(this->lifetime_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
- registerVariable(this->length_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
- registerVariable(this->maxelements_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
- registerVariable(this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
+ registerVariable(this->width_, VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
+ registerVariable(this->lifetime_, VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
+ registerVariable(this->length_, VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
+ registerVariable(this->maxelements_, VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
+ registerVariable(this->trailmaterial_, VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
}
void Backlight::changedColour()
@@ -174,7 +175,7 @@
void Backlight::stopturnonoff()
{
- this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_);
+ this->postprocessingtime_ = std::max(0.0f, this->lifetime_ - this->turnofftime_);
FadingBillboard::stopturnonoff();
Modified: trunk/src/orxonox/objects/worldentities/BigExplosion.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/BigExplosion.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/BigExplosion.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -55,7 +55,7 @@
this->firstTick_ = true;
*/
this->bStop_ = false;
- this->LOD_ = LODParticle::normal;
+ this->LOD_ = LODParticle::Normal;
/* this->stf_ = "setTimeFactor ";
this->timeFactor_ = 1;
@@ -306,8 +306,8 @@
void BigExplosion::registerVariables()
{
- registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<BigExplosion>(this, &BigExplosion::LODchanged));
- registerVariable(this->bStop_, variableDirection::toclient, new NetworkCallback<BigExplosion>(this, &BigExplosion::checkStop));
+ registerVariable((int&)(this->LOD_), VariableDirection::ToClient, new NetworkCallback<BigExplosion>(this, &BigExplosion::LODchanged));
+ registerVariable(this->bStop_, VariableDirection::ToClient, new NetworkCallback<BigExplosion>(this, &BigExplosion::checkStop));
}
void BigExplosion::LODchanged()
Modified: trunk/src/orxonox/objects/worldentities/BigExplosion.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/BigExplosion.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/BigExplosion.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -46,9 +46,9 @@
virtual void tick(float dt);
void registerVariables();
- inline void setLOD(LODParticle::LOD level)
+ inline void setLOD(LODParticle::Value level)
{ this->LOD_ = level; this->LODchanged(); }
- inline LODParticle::LOD getLOD() const
+ inline LODParticle::Value getLOD() const
{ return this->LOD_; }
private:
@@ -97,7 +97,7 @@
ParticleInterface* explosionSmoke_;
ParticleInterface* explosionFire_;
- LODParticle::LOD LOD_;
+ LODParticle::Value LOD_;
Timer<BigExplosion> destroyTimer_;
};
}
Modified: trunk/src/orxonox/objects/worldentities/Billboard.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/Billboard.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Billboard.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -68,9 +68,9 @@
void Billboard::registerVariables()
{
- registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
- registerVariable(this->colour_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
-// registerVariable(this->rotation_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
+ registerVariable(this->material_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
+ registerVariable(this->colour_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
+// registerVariable(this->rotation_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
}
void Billboard::changedMaterial()
Modified: trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -65,9 +65,9 @@
void BlinkingBillboard::registerVariables()
{
-// registerVariable(this->amplitude_, variableDirection::toclient);
-// registerVariable(this->frequency_, variableDirection::toclient);
-// registerVariable(this->phase_, variableDirection::toclient);
+// registerVariable(this->amplitude_, VariableDirection::ToClient);
+// registerVariable(this->frequency_, VariableDirection::ToClient);
+// registerVariable(this->phase_, VariableDirection::ToClient);
}
void BlinkingBillboard::tick(float dt)
Modified: trunk/src/orxonox/objects/worldentities/Camera.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/Camera.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Camera.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -28,12 +28,13 @@
#include "Camera.h"
+#include <algorithm>
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include <OgreSceneNode.h>
#include "util/Exception.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
#include "objects/Scene.h"
@@ -103,7 +104,7 @@
if (this->bDrag_)
{
// this stuff here may need some adjustments
- float coeff = min(1.0f, 15.0f * dt);
+ float coeff = std::min(1.0f, 15.0f * dt);
Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition();
this->cameraNode_->translate(coeff * offset);
Modified: trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ControllableEntity.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/ControllableEntity.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -78,7 +78,7 @@
this->setConfigValues();
- this->setPriority( priority::very_high );
+ this->setPriority( Priority::VeryHigh );
this->registerVariables();
}
@@ -237,7 +237,7 @@
if (!GameMode::isMaster())
{
this->client_overwrite_ = this->server_overwrite_;
- this->setObjectMode(objectDirection::bidirectional);
+ this->setObjectMode(ObjectDirection::Bidirectional);
}
}
@@ -253,7 +253,7 @@
this->playerID_ = OBJECTID_UNKNOWN;
this->bHasLocalController_ = false;
this->bHasHumanController_ = false;
- this->setObjectMode(objectDirection::toclient);
+ this->setObjectMode(ObjectDirection::ToClient);
this->changedPlayer();
@@ -367,24 +367,24 @@
void ControllableEntity::registerVariables()
{
- registerVariable(this->cameraPositionTemplate_, variableDirection::toclient);
- registerVariable(this->hudtemplate_, variableDirection::toclient);
+ registerVariable(this->cameraPositionTemplate_, VariableDirection::ToClient);
+ registerVariable(this->hudtemplate_, VariableDirection::ToClient);
- registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
- registerVariable(this->server_linear_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
- registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
- registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
+ registerVariable(this->server_position_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
+ registerVariable(this->server_linear_velocity_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
+ registerVariable(this->server_orientation_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
+ registerVariable(this->server_angular_velocity_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
- registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
- registerVariable(this->client_overwrite_, variableDirection::toserver);
+ registerVariable(this->server_overwrite_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
+ registerVariable(this->client_overwrite_, VariableDirection::ToServer);
- registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
- registerVariable(this->client_linear_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
- registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
- registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
+ registerVariable(this->client_position_, VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
+ registerVariable(this->client_linear_velocity_, VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
+ registerVariable(this->client_orientation_, VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
+ registerVariable(this->client_angular_velocity_, VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
- registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
+ registerVariable(this->playerID_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
}
void ControllableEntity::processServerPosition()
Modified: trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -47,7 +47,7 @@
ThrowException(AbortLoading, "Can't create ExplosionChunk, no scene or no scene manager given.");
this->bStop_ = false;
- this->LOD_ = LODParticle::normal;
+ this->LOD_ = LODParticle::Normal;
if ( GameMode::showsGraphics() )
{
@@ -103,8 +103,8 @@
void ExplosionChunk::registerVariables()
{
- registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
- registerVariable(this->bStop_, variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
+ registerVariable((int&)(this->LOD_), VariableDirection::ToClient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
+ registerVariable(this->bStop_, VariableDirection::ToClient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
}
void ExplosionChunk::LODchanged()
Modified: trunk/src/orxonox/objects/worldentities/ExplosionChunk.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ExplosionChunk.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/ExplosionChunk.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -45,9 +45,9 @@
virtual void tick(float dt);
void registerVariables();
- inline void setLOD(LODParticle::LOD level)
+ inline void setLOD(LODParticle::Value level)
{ this->LOD_ = level; this->LODchanged(); }
- inline LODParticle::LOD getLOD() const
+ inline LODParticle::Value getLOD() const
{ return this->LOD_; }
private:
@@ -59,7 +59,7 @@
bool bStop_;
ParticleInterface* fire_;
ParticleInterface* smoke_;
- LODParticle::LOD LOD_;
+ LODParticle::Value LOD_;
Timer<ExplosionChunk> destroyTimer_;
};
}
Modified: trunk/src/orxonox/objects/worldentities/FadingBillboard.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/FadingBillboard.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/FadingBillboard.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -63,8 +63,8 @@
void FadingBillboard::registerVariables()
{
- registerVariable(this->turnontime_, variableDirection::toclient);
- registerVariable(this->turnofftime_, variableDirection::toclient);
+ registerVariable(this->turnontime_, VariableDirection::ToClient);
+ registerVariable(this->turnofftime_, VariableDirection::ToClient);
}
void FadingBillboard::changedColour()
Modified: trunk/src/orxonox/objects/worldentities/Light.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/Light.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Light.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -32,7 +32,7 @@
#include <OgreLight.h>
#include <boost/static_assert.hpp>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "util/Exception.h"
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
@@ -44,9 +44,9 @@
CreateFactory(Light);
// Be sure we don't do bad conversions
- BOOST_STATIC_ASSERT((int)Ogre::Light::LT_POINT == (int)Light::LT_POINT);
- BOOST_STATIC_ASSERT((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::LT_DIRECTIONAL);
- BOOST_STATIC_ASSERT((int)Ogre::Light::LT_SPOTLIGHT == (int)Light::LT_SPOTLIGHT);
+ BOOST_STATIC_ASSERT((int)Ogre::Light::LT_POINT == (int)Light::Point);
+ BOOST_STATIC_ASSERT((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Directional);
+ BOOST_STATIC_ASSERT((int)Ogre::Light::LT_SPOTLIGHT == (int)Light::Spotlight);
Light::Light(BaseObject* creator) : StaticEntity(creator)
{
@@ -55,7 +55,7 @@
this->light_ = 0;
this->diffuse_ = ColourValue::White;
this->specular_ = ColourValue::White;
- this->type_ = Light::LT_POINT;
+ this->type_ = Light::Point;
this->attenuation_ = Vector4(100000, 1, 0, 0);
this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
@@ -105,11 +105,11 @@
void Light::registerVariables()
{
- registerVariable((int&)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType));
- registerVariable(this->diffuse_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
- registerVariable(this->specular_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
- registerVariable(this->attenuation_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
- registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
+ registerVariable((int&)this->type_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType));
+ registerVariable(this->diffuse_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
+ registerVariable(this->specular_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
+ registerVariable(this->attenuation_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
+ registerVariable(this->spotlightRange_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
}
void Light::updateDiffuseColour()
@@ -126,37 +126,37 @@
void Light::updateAttenuation()
{
- if (this->light_ && this->type_ != Light::LT_DIRECTIONAL)
+ if (this->light_ && this->type_ != Light::Directional)
this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w);
}
void Light::updateSpotlightRange()
{
- if (this->light_ && this->type_ == Light::LT_SPOTLIGHT)
+ if (this->light_ && this->type_ == Light::Spotlight)
this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z);
}
void Light::setTypeString(const std::string& type)
{
if (type == "point")
- this->setType(Light::LT_POINT);
+ this->setType(Light::Point);
else if (type == "directional")
- this->setType(Light::LT_DIRECTIONAL);
+ this->setType(Light::Directional);
else if (type == "spotlight")
- this->setType(Light::LT_SPOTLIGHT);
+ this->setType(Light::Spotlight);
else
- this->setType(Light::LT_POINT);
+ this->setType(Light::Point);
}
std::string Light::getTypeString() const
{
switch (this->type_)
{
- case Light::LT_DIRECTIONAL:
+ case Light::Directional:
return "directional";
- case Light::LT_SPOTLIGHT:
+ case Light::Spotlight:
return "spotlight";
- case Light::LT_POINT:
+ case Light::Point:
default:
return "point";
}
@@ -168,9 +168,9 @@
{
this->light_->setType(static_cast<Ogre::Light::LightTypes>(this->type_));
- if (this->type_ != Light::LT_DIRECTIONAL)
+ if (this->type_ != Light::Directional)
this->updateAttenuation();
- if (this->type_ == Light::LT_SPOTLIGHT)
+ if (this->type_ == Light::Spotlight)
this->updateSpotlightRange();
}
}
Modified: trunk/src/orxonox/objects/worldentities/Light.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/Light.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Light.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -44,11 +44,11 @@
enum LightTypes // Copy from the Ogre enum
{
/// Point light sources give off light equally in all directions, so require only position not direction
- LT_POINT,
+ Point,
/// Directional lights simulate parallel light beams from a distant source, hence have direction but no position
- LT_DIRECTIONAL,
+ Directional,
/// Spotlights simulate a cone of light from a source so require position and direction, plus extra values for falloff
- LT_SPOTLIGHT
+ Spotlight
};
public:
Modified: trunk/src/orxonox/objects/worldentities/Model.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/Model.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Model.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -64,8 +64,8 @@
void Model::registerVariables()
{
- registerVariable(this->meshSrc_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
- registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
+ registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMesh));
+ registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedShadows));
}
void Model::changedMesh()
Modified: trunk/src/orxonox/objects/worldentities/MovableEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/MovableEntity.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/MovableEntity.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -51,7 +51,7 @@
this->continuousResynchroTimer_ = 0;
- this->setPriority(priority::low);
+ this->setPriority(Priority::Low);
this->registerVariables();
}
@@ -88,11 +88,11 @@
void MovableEntity::registerVariables()
{
- registerVariable(this->linearVelocity_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
- registerVariable(this->angularVelocity_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity));
+ registerVariable(this->linearVelocity_, VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
+ registerVariable(this->angularVelocity_, VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity));
- registerVariable(this->overwrite_position_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
- registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
+ registerVariable(this->overwrite_position_, VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
+ registerVariable(this->overwrite_orientation_, VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
}
void MovableEntity::clientConnected(unsigned int clientID)
Modified: trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -52,7 +52,7 @@
ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
this->particles_ = 0;
- this->LOD_ = LODParticle::normal;
+ this->LOD_ = LODParticle::Normal;
this->registerVariables();
}
@@ -70,14 +70,14 @@
{
SUPER(ParticleEmitter, XMLPort, xmlelement, mode);
- XMLPortParam(ParticleEmitter, "lod", setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::normal);
+ XMLPortParam(ParticleEmitter, "lod", setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::Normal);
XMLPortParam(ParticleEmitter, "source", setSource, getSource, xmlelement, mode);
}
void ParticleEmitter::registerVariables()
{
- registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
- registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
+ registerVariable(this->source_, VariableDirection::ToClient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
+ registerVariable((int&)(this->LOD_), VariableDirection::ToClient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
}
void ParticleEmitter::changedVisibility()
Modified: trunk/src/orxonox/objects/worldentities/ParticleEmitter.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/ParticleEmitter.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/ParticleEmitter.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -56,14 +56,14 @@
inline const std::string& getSource() const
{ return this->source_; }
- inline void setLOD(LODParticle::LOD level)
+ inline void setLOD(LODParticle::Value level)
{ this->LOD_ = level; this->LODchanged(); }
- inline LODParticle::LOD getLOD() const
+ inline LODParticle::Value getLOD() const
{ return this->LOD_; }
protected:
inline void setLODxml(unsigned int level)
- { this->LOD_ = (LODParticle::LOD)level; this->LODchanged(); }
+ { this->LOD_ = (LODParticle::Value)level; this->LODchanged(); }
inline unsigned int getLODxml() const
{ return (unsigned int)this->LOD_; }
@@ -72,7 +72,7 @@
ParticleInterface* particles_;
std::string source_;
- LODParticle::LOD LOD_;
+ LODParticle::Value LOD_;
};
}
Modified: trunk/src/orxonox/objects/worldentities/Planet.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/Planet.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/Planet.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -156,11 +156,11 @@
void Planet::registerVariables()
{
- registerVariable(this->atmosphere_, variableDirection::toclient);
- registerVariable(this->meshSrc_, variableDirection::toclient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
- registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
- registerVariable(this->atmosphereSize, variableDirection::toclient);
- registerVariable(this->imageSize, variableDirection::toclient);
+ registerVariable(this->atmosphere_, VariableDirection::ToClient);
+ registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
+ registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
+ registerVariable(this->atmosphereSize, VariableDirection::ToClient);
+ registerVariable(this->imageSize, VariableDirection::ToClient);
}
void Planet::changedVisibility()
Modified: trunk/src/orxonox/objects/worldentities/PongBall.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/PongBall.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/PongBall.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -71,7 +71,7 @@
registerVariable( this->speed_ );
registerVariable( this->relMercyOffset_ );
registerVariable( this->batID_[0] );
- registerVariable( this->batID_[1], variableDirection::toclient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
+ registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
}
void PongBall::tick(float dt)
Modified: trunk/src/orxonox/objects/worldentities/StaticEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/StaticEntity.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/StaticEntity.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,7 +42,7 @@
{
RegisterObject(StaticEntity);
- this->setPriority(priority::very_low);
+ this->setPriority(Priority::VeryLow);
this->registerVariables();
}
@@ -53,8 +53,8 @@
void StaticEntity::registerVariables()
{
- registerVariable(this->getPosition(), variableDirection::toclient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
- registerVariable(this->getOrientation(), variableDirection::toclient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
+ registerVariable(this->getPosition(), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
+ registerVariable(this->getOrientation(), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
}
Modified: trunk/src/orxonox/objects/worldentities/WorldEntity.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/WorldEntity.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/WorldEntity.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -174,31 +174,31 @@
void WorldEntity::registerVariables()
{
- registerVariable(this->mainStateName_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
+ registerVariable(this->mainStateName_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
- registerVariable(this->bActive_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
- registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
+ registerVariable(this->bActive_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
+ registerVariable(this->bVisible_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
- registerVariable(this->getScale3D(), variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
+ registerVariable(this->getScale3D(), VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
// Physics stuff
- registerVariable(this->mass_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
- registerVariable(this->restitution_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged));
- registerVariable(this->angularFactor_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged));
- registerVariable(this->linearDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged));
- registerVariable(this->angularDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged));
- registerVariable(this->friction_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged));
+ registerVariable(this->mass_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
+ registerVariable(this->restitution_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged));
+ registerVariable(this->angularFactor_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged));
+ registerVariable(this->linearDamping_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged));
+ registerVariable(this->angularDamping_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged));
+ registerVariable(this->friction_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged));
registerVariable(this->bCollisionCallbackActive_,
- variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged));
+ VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged));
registerVariable(this->bCollisionResponseActive_,
- variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged));
+ VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged));
registerVariable((int&)this->collisionTypeSynchronised_,
- variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
+ VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
registerVariable(this->bPhysicsActiveSynchronised_,
- variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
+ VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
// Attach to parent if necessary
- registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
+ registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
}
/**
Modified: trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -28,6 +28,8 @@
#include "Pawn.h"
+#include <algorithm>
+
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
#include "core/XMLPort.h"
@@ -116,10 +118,10 @@
void Pawn::registerVariables()
{
- registerVariable(this->bAlive_, variableDirection::toclient);
- registerVariable(this->health_, variableDirection::toclient);
- registerVariable(this->initialHealth_, variableDirection::toclient);
- registerVariable(this->bReload_, variableDirection::toserver);
+ registerVariable(this->bAlive_, VariableDirection::ToClient);
+ registerVariable(this->health_, VariableDirection::ToClient);
+ registerVariable(this->initialHealth_, VariableDirection::ToClient);
+ registerVariable(this->bReload_, VariableDirection::ToServer);
}
void Pawn::tick(float dt)
@@ -151,7 +153,7 @@
void Pawn::setHealth(float health)
{
- this->health_ = min(health, this->maxHealth_);
+ this->health_ = std::min(health, this->maxHealth_);
}
void Pawn::damage(float damage, Pawn* originator)
Modified: trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -89,9 +89,9 @@
void SpaceShip::registerVariables()
{
- registerVariable(this->primaryThrust_, variableDirection::toclient);
- registerVariable(this->auxilaryThrust_, variableDirection::toclient);
- registerVariable(this->rotationThrust_, variableDirection::toclient);
+ registerVariable(this->primaryThrust_, VariableDirection::ToClient);
+ registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
+ registerVariable(this->rotationThrust_, VariableDirection::ToClient);
}
void SpaceShip::setConfigValues()
Modified: trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -92,8 +92,8 @@
void Spectator::registerVariables()
{
- registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
- registerVariable(this->bGreeting_, variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
+ registerVariable(this->bGreetingFlareVisible_, VariableDirection::ToClient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
+ registerVariable(this->bGreeting_, VariableDirection::ToServer, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
}
void Spectator::changedGreeting()
@@ -144,7 +144,7 @@
{
ControllableEntity::setPlayer(player);
-// this->setObjectMode(objectDirection::toclient);
+// this->setObjectMode(ObjectDirection::ToClient);
}
void Spectator::startLocalHumanControl()
Modified: trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,7 +42,7 @@
{
RegisterObject(TeamBaseMatchBase);
- this->state_ = BaseState::uncontrolled;
+ this->state_ = BaseState::Uncontrolled;
TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype());
if (gametype)
@@ -65,13 +65,13 @@
switch (this->state_)
{
- case BaseState::controlTeam1:
+ case BaseState::ControlTeam1:
colour = gametype->getTeamColour(0);
break;
- case BaseState::controlTeam2:
+ case BaseState::ControlTeam2:
colour = gametype->getTeamColour(1);
break;
- case BaseState::uncontrolled:
+ case BaseState::Uncontrolled:
default:
colour = ColourValue(0.5, 0.5, 0.5, 1.0);
break;
Modified: trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,11 +37,11 @@
{
namespace BaseState
{
- enum Enum
+ enum Value
{
- uncontrolled,
- controlTeam1,
- controlTeam2,
+ Uncontrolled,
+ ControlTeam1,
+ ControlTeam2,
};
}
@@ -57,7 +57,7 @@
// Set the state of a base to whatever the argument of the function is
- void setState(BaseState::Enum state)
+ void setState(BaseState::Value state)
{
this->state_ = state;
this->changeTeamColour();
@@ -65,7 +65,7 @@
// Get the state of a base as a return value
- BaseState::Enum getState() const
+ BaseState::Value getState() const
{
return this->state_;
}
@@ -74,7 +74,7 @@
protected:
void changeTeamColour();
- BaseState::Enum state_;
+ BaseState::Value state_;
};
}
Modified: trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -140,7 +140,7 @@
return false;
}
- bool DistanceTrigger::isTriggered(TriggerMode mode)
+ bool DistanceTrigger::isTriggered(TriggerMode::Value mode)
{
if (Trigger::isTriggered(mode))
{
Modified: trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -58,7 +58,7 @@
bool checkDistance();
protected:
- virtual bool isTriggered(TriggerMode mode);
+ virtual bool isTriggered(TriggerMode::Value mode);
virtual void notifyMaskUpdate() {}
ClassTreeMask targetMask_;
Modified: trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -53,7 +53,7 @@
ORXONOX_SET_EVENT(EventTrigger, "trigger", trigger, event);
}
- bool EventTrigger::isTriggered(TriggerMode mode)
+ bool EventTrigger::isTriggered(TriggerMode::Value mode)
{
if (Trigger::isTriggered(mode))
return this->bEventTriggered_;
Modified: trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -46,7 +46,7 @@
{ this->bEventTriggered_ = bTriggered; this->tick(0); }
protected:
- virtual bool isTriggered(TriggerMode mode);
+ virtual bool isTriggered(TriggerMode::Value mode);
private:
bool bEventTriggered_;
Modified: trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -69,7 +69,7 @@
{ return this->isForPlayer_; }
protected:
- virtual bool isTriggered(TriggerMode mode) = 0;
+ virtual bool isTriggered(TriggerMode::Value mode) = 0;
/**
@brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
Modified: trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -45,7 +45,7 @@
{
RegisterObject(Trigger);
- this->mode_ = TM_EventTriggerAND;
+ this->mode_ = TriggerMode::EventTriggerAND;
this->bFirstTick_ = true;
this->bActive_ = false;
@@ -162,7 +162,7 @@
this->fireEvent(bIsTriggered);
}
- bool Trigger::isTriggered(TriggerMode mode)
+ bool Trigger::isTriggered(TriggerMode::Value mode)
{
// if (this->bUpdating_)
// return this->bTriggered_;
@@ -174,13 +174,13 @@
switch (mode)
{
- case TM_EventTriggerAND:
+ case TriggerMode::EventTriggerAND:
returnval = checkAnd();
break;
- case TM_EventTriggerOR:
+ case TriggerMode::EventTriggerOR:
returnval = checkOr();
break;
- case TM_EventTriggerXOR:
+ case TriggerMode::EventTriggerXOR:
returnval = checkXor();
break;
default:
@@ -269,20 +269,20 @@
void Trigger::setMode(const std::string& modeName)
{
if (modeName == "and")
- this->setMode(TM_EventTriggerAND);
+ this->setMode(TriggerMode::EventTriggerAND);
else if (modeName == "or")
- this->setMode(TM_EventTriggerOR);
+ this->setMode(TriggerMode::EventTriggerOR);
else if (modeName == "xor")
- this->setMode(TM_EventTriggerXOR);
+ this->setMode(TriggerMode::EventTriggerXOR);
}
std::string Trigger::getModeString() const
{
- if (this->mode_ == TM_EventTriggerAND)
+ if (this->mode_ == TriggerMode::EventTriggerAND)
return std::string("and");
- else if (this->mode_ == TM_EventTriggerOR)
+ else if (this->mode_ == TriggerMode::EventTriggerOR)
return std::string("or");
- else if (this->mode_ == TM_EventTriggerXOR)
+ else if (this->mode_ == TriggerMode::EventTriggerXOR)
return std::string("xor");
else
return std::string("and");
Modified: trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
===================================================================
--- trunk/src/orxonox/objects/worldentities/triggers/Trigger.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/objects/worldentities/triggers/Trigger.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -40,12 +40,15 @@
namespace orxonox
{
- enum TriggerMode
+ namespace TriggerMode
{
- TM_EventTriggerAND,
- TM_EventTriggerOR,
- TM_EventTriggerXOR,
- };
+ enum Value
+ {
+ EventTriggerAND,
+ EventTriggerOR,
+ EventTriggerXOR,
+ };
+ }
class _OrxonoxExport Trigger : public StaticEntity, public Tickable
{
@@ -63,9 +66,9 @@
const Trigger* getTrigger(unsigned int index) const;
void setMode(const std::string& modeName);
- inline void setMode(TriggerMode mode)
+ inline void setMode(TriggerMode::Value mode)
{ this->mode_ = mode; }
- inline TriggerMode getMode() const
+ inline TriggerMode::Value getMode() const
{ return mode_; }
inline void setInvert(bool bInvert)
@@ -102,7 +105,7 @@
protected:
inline bool isTriggered() { return this->isTriggered(this->mode_); }
- virtual bool isTriggered(TriggerMode mode);
+ virtual bool isTriggered(TriggerMode::Value mode);
virtual void triggered(bool bIsTriggered);
private:
@@ -117,7 +120,7 @@
bool bTriggered_;
bool bFirstTick_;
- TriggerMode mode_;
+ TriggerMode::Value mode_;
bool bInvertMode_;
bool bSwitch_;
bool bStayActive_;
Modified: trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- trunk/src/orxonox/overlays/OrxonoxOverlay.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/OrxonoxOverlay.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -41,7 +41,7 @@
#include "util/Convert.h"
#include "util/Exception.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/GameMode.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
@@ -71,12 +71,12 @@
// create the Ogre::Overlay
overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
- + convertToString(hudOverlayCounter_s++));
+ + multi_cast<std::string>(hudOverlayCounter_s++));
// create background panel (can be used to show any picture)
this->background_ = static_cast<Ogre::PanelOverlayElement*>(
Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
- "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
+ "OrxonoxOverlay_background_" + multi_cast<std::string>(hudOverlayCounter_s++)));
this->overlay_->add2D(this->background_);
// Get aspect ratio from the render window. Later on, we get informed automatically
Modified: trunk/src/orxonox/overlays/OverlayText.cc
===================================================================
--- trunk/src/orxonox/overlays/OverlayText.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/OverlayText.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,7 +33,7 @@
#include <OgreTextAreaOverlayElement.h>
#include <boost/static_assert.hpp>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
Modified: trunk/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- trunk/src/orxonox/overlays/console/InGameConsole.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/console/InGameConsole.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -29,6 +29,7 @@
#include "InGameConsole.h"
+#include <algorithm>
#include <string>
#include <OgreOverlay.h>
#include <OgreOverlayElement.h>
@@ -218,7 +219,7 @@
this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
for (int i = 0; i < LINES; i++)
{
- this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
+ this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
this->consoleOverlayTextAreas_[i]->setCharHeight(18);
@@ -424,7 +425,7 @@
this->desiredTextWidth_ = (int) (this->windowW_ * this->relativeWidth) - 12;
if (LINES > 0)
- this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
+ this->maxCharsPerLine_ = std::max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
else
this->maxCharsPerLine_ = 10;
Modified: trunk/src/orxonox/overlays/hud/GametypeStatus.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/GametypeStatus.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/GametypeStatus.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -69,7 +69,7 @@
else if (!gtinfo->hasEnded())
{
if (gtinfo->isStartCountdownRunning())
- this->setCaption(convertToString((int)ceil(gtinfo->getStartCountdown())));
+ this->setCaption(multi_cast<std::string>((int)ceil(gtinfo->getStartCountdown())));
else if (ce->isA(Class(Spectator)))
this->setCaption("Press [Fire] to respawn");
else
Modified: trunk/src/orxonox/overlays/hud/HUDBar.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDBar.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/HUDBar.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
#include <OgrePanelOverlayElement.h>
#include "util/Convert.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
@@ -71,7 +71,7 @@
RegisterObject(HUDBar);
// create new material
- std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
+ std::string materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
Modified: trunk/src/orxonox/overlays/hud/HUDHealthBar.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDHealthBar.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/HUDHealthBar.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -82,7 +82,7 @@
if (this->owner_)
{
this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
- this->textoverlay_->setCaption(convertToString((int)this->owner_->getHealth()));
+ this->textoverlay_->setCaption(multi_cast<std::string>((int)this->owner_->getHealth()));
}
if (this->bUseBarColour_)
Modified: trunk/src/orxonox/overlays/hud/HUDNavigation.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDNavigation.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/HUDNavigation.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -34,7 +34,7 @@
#include <OgrePanelOverlayElement.h>
#include "util/Math.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "util/Convert.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
@@ -141,8 +141,8 @@
// set text
int dist = (int) getDist2Focus();
- navText_->setCaption(convertToString(dist));
- float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
+ navText_->setCaption(multi_cast<std::string>(dist));
+ float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3;
/*
Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
Modified: trunk/src/orxonox/overlays/hud/HUDRadar.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDRadar.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/HUDRadar.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -33,7 +33,7 @@
#include <OgrePanelOverlayElement.h>
#include "util/Math.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "tools/TextureGenerator.h"
Modified: trunk/src/orxonox/overlays/hud/HUDTimer.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/HUDTimer.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/HUDTimer.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -58,7 +58,7 @@
{
if (gametype->getTimerIsActive())
{
- this->setCaption(convertToString((int)gametype->getTime() + 1));
+ this->setCaption(multi_cast<std::string>((int)gametype->getTime() + 1));
}
}
}
Modified: trunk/src/orxonox/overlays/hud/PongScore.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/PongScore.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/PongScore.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -82,13 +82,13 @@
if (player1)
{
name1 = player1->getName();
- score1 = convertToString(this->owner_->getScore(player1));
+ score1 = multi_cast<std::string>(this->owner_->getScore(player1));
}
if (player2)
{
name2 = player2->getName();
- score2 = convertToString(this->owner_->getScore(player2));
+ score2 = multi_cast<std::string>(this->owner_->getScore(player2));
}
std::string output1;
Modified: trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc
===================================================================
--- trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -70,11 +70,11 @@
if (this->owner_)
{
- std::string bases1 = "(" + convertToString(this->owner_->getTeamBases(0)) + ")";
- std::string bases2 = "(" + convertToString(this->owner_->getTeamBases(1)) + ")";
+ std::string bases1 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ")";
+ std::string bases2 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ")";
- std::string score1 = convertToString(this->owner_->getTeamPoints(0));
- std::string score2 = convertToString(this->owner_->getTeamPoints(1));
+ std::string score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
+ std::string score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
std::string output1;
if (this->bShowLeftTeam_)
Modified: trunk/src/orxonox/overlays/stats/CreateLines.cc
===================================================================
--- trunk/src/orxonox/overlays/stats/CreateLines.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/stats/CreateLines.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -98,7 +98,7 @@
// while (textColumns_.size() < numberOfColumns)
// {
- // Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex) + convertToString(colIndex)));
+ // Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + multi_cast<std::string>(lineIndex) + multi_cast<std::string>(colIndex)));
// textColumns_.push_back(tempTextArea);
// this->background_->addChild(tempTextArea);
Modified: trunk/src/orxonox/overlays/stats/Stats.cc
===================================================================
--- trunk/src/orxonox/overlays/stats/Stats.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/overlays/stats/Stats.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -32,7 +32,7 @@
#include <OgreOverlayManager.h>
#include <OgreBorderPanelOverlayElement.h>
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/CoreIncludes.h"
#include "core/ConfigValueIncludes.h"
Modified: trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- trunk/src/orxonox/sound/SoundManager.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/sound/SoundManager.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -38,7 +38,6 @@
namespace orxonox
{
SoundManager* SoundManager::singletonRef_s = NULL;
- ALCdevice* SoundManager::device_s = NULL;
/**
* Default constructor
@@ -48,6 +47,7 @@
assert(singletonRef_s == NULL);
singletonRef_s = this;
+ this->device_ = NULL;
this->soundavailable_ = true;
if(!alutInitWithoutContext(NULL,NULL))
{
@@ -56,13 +56,11 @@
}
else
{
- if(SoundManager::device_s == NULL)
- {
- COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
- SoundManager::device_s = alcOpenDevice(NULL);
- }
+ assert(this->device_ == NULL);
+ COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
+ this->device_ = alcOpenDevice(NULL);
- if(SoundManager::device_s == NULL)
+ if(this->device_ == NULL)
{
COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl;
this->soundavailable_ = false;
@@ -70,7 +68,7 @@
else
{
COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl;
- this->context_ = alcCreateContext(SoundManager::device_s, NULL);
+ this->context_ = alcCreateContext(this->device_, NULL);
if(this->context_ == NULL)
{
COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl;
@@ -98,7 +96,7 @@
singletonRef_s = NULL;
alcDestroyContext(this->context_);
- alcCloseDevice(SoundManager::device_s);
+ alcCloseDevice(this->device_);
alutExit();
}
Modified: trunk/src/orxonox/sound/SoundManager.h
===================================================================
--- trunk/src/orxonox/sound/SoundManager.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/sound/SoundManager.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -54,7 +54,7 @@
static SoundManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
private:
- static ALCdevice* device_s;
+ ALCdevice* device_;
ALCcontext* context_;
std::list<SoundBase*> soundlist_;
bool soundavailable_;
Modified: trunk/src/orxonox/tools/BillboardSet.cc
===================================================================
--- trunk/src/orxonox/tools/BillboardSet.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/tools/BillboardSet.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -37,7 +37,7 @@
#include "util/Convert.h"
#include "util/Math.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/GameMode.h"
namespace orxonox
@@ -73,7 +73,7 @@
{
if (GameMode::showsGraphics())
{
- this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
+ this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + multi_cast<std::string>(BillboardSet::billboardSetCounter_s++), count);
this->billboardSet_->createBillboard(position);
this->billboardSet_->setMaterialName(file);
}
@@ -96,7 +96,7 @@
{
if (GameMode::showsGraphics())
{
- this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
+ this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + multi_cast<std::string>(BillboardSet::billboardSetCounter_s++), count);
this->billboardSet_->createBillboard(position, colour);
this->billboardSet_->setMaterialName(file);
}
Modified: trunk/src/orxonox/tools/Mesh.cc
===================================================================
--- trunk/src/orxonox/tools/Mesh.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/tools/Mesh.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -35,7 +35,7 @@
#include <OgreSceneManager.h>
#include "util/Convert.h"
-#include "util/String.h"
+#include "util/StringUtils.h"
#include "core/GameMode.h"
namespace orxonox
@@ -67,7 +67,7 @@
{
try
{
- this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
+ this->entity_ = this->scenemanager_->createEntity("Mesh" + multi_cast<std::string>(Mesh::meshCounter_s++), meshsource);
this->entity_->setCastShadows(this->bCastShadows_);
this->entity_->setNormaliseNormals(true);
Modified: trunk/src/orxonox/tools/ParticleInterface.cc
===================================================================
--- trunk/src/orxonox/tools/ParticleInterface.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/tools/ParticleInterface.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -50,7 +50,7 @@
unsigned int ParticleInterface::counter_s = 0;
ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
- ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
+ ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel)
{
RegisterObject(ParticleInterface);
@@ -68,7 +68,7 @@
{
try
{
- this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
+ this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + multi_cast<std::string>(ParticleInterface::counter_s++), templateName);
this->setSpeedFactor(1.0f);
}
catch (...)
Modified: trunk/src/orxonox/tools/ParticleInterface.h
===================================================================
--- trunk/src/orxonox/tools/ParticleInterface.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/tools/ParticleInterface.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -44,7 +44,7 @@
class _OrxonoxExport ParticleInterface : public TimeFactorListener
{
public:
- ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel);
+ ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel);
virtual ~ParticleInterface();
inline Ogre::ParticleSystem* getParticleSystem()
Modified: trunk/src/orxonox/tools/TextureGenerator.cc
===================================================================
--- trunk/src/orxonox/tools/TextureGenerator.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/orxonox/tools/TextureGenerator.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -71,7 +71,7 @@
if (it == colourMap.end())
{
- std::string materialName = textureName + "_Material_" + convertToString(materialCount_s++);
+ std::string materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialName, "General");
material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
Modified: trunk/src/util/CMakeLists.txt
===================================================================
--- trunk/src/util/CMakeLists.txt 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/CMakeLists.txt 2009-07-12 21:58:01 UTC (rev 3280)
@@ -28,7 +28,7 @@
OutputHandler.cc
SignalHandler.cc
Sleep.cc
- String.cc
+ StringUtils.cc
SubString.cc
)
Modified: trunk/src/util/Convert.h
===================================================================
--- trunk/src/util/Convert.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/Convert.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -42,7 +42,7 @@
#include <typeinfo>
#include "Debug.h"
-#include "String.h"
+#include "StringUtils.h"
#include "TemplateUtils.h"
////////////////////////////////////
@@ -315,20 +315,6 @@
return output;
}
- // convert to string Shortcut
- template <class FromType>
- FORCEINLINE std::string convertToString(FromType value)
- {
- return getConvertedValue<FromType, std::string>(value);
- }
-
- // convert from string Shortcut
- template <class ToType>
- FORCEINLINE ToType convertFromString(std::string str)
- {
- return getConvertedValue<std::string, ToType>(str);
- }
-
////////////////////////////////
// Special string conversions //
////////////////////////////////
Modified: trunk/src/util/Exception.cc
===================================================================
--- trunk/src/util/Exception.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/Exception.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -63,7 +63,7 @@
{
std::ostringstream fullDesc;
- fullDesc << this->getTypeName() << "_EXCEPTION";
+ fullDesc << this->getTypeName() << "Exception";
if (this->filename_ != "")
{
@@ -86,4 +86,10 @@
return fullDescription_;
}
+
+ //! Returns the error description
+ const char* Exception::what() const throw()
+ {
+ return getDescription().c_str();
+ }
}
Modified: trunk/src/util/Exception.h
===================================================================
--- trunk/src/util/Exception.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/Exception.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -67,6 +67,7 @@
//! Needed for compatibility with std::exception
virtual ~Exception() throw() { }
+ const char* what() const throw();
//! Returns a full description with type, line, file and function
virtual const std::string& getFullDescription() const;
@@ -81,9 +82,6 @@
//! Returns the filename in which the exception occurred.
virtual const std::string& getFilename() const { return this->filename_; }
- //! Returns a full description of the error.
- const char* what() const throw() { return getFullDescription().c_str(); }
-
protected:
std::string description_; //!< User typed text about why the exception occurred
unsigned int lineNumber_; //!< Line on which the exception occurred
@@ -151,7 +149,7 @@
@param description
Exception description as string
*/
-#define ThrowException(type, description, ...) \
+#define ThrowException(type, description) \
throw orxonox::exceptionThrowerHelper(type##Exception(static_cast<std::ostringstream&>(std::ostringstream().flush() << description).str(), __LINE__, __FILE__, __FUNCTIONNAME__))
} /* namespace orxonox */
Modified: trunk/src/util/Math.h
===================================================================
--- trunk/src/util/Math.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/Math.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -80,24 +80,6 @@
}
/**
- @brief Returns the smaller of two values.
- */
- template <typename T>
- inline T min(T a, T b)
- {
- return (a <= b) ? a : b;
- }
-
- /**
- @brief Returns the greater of two values.
- */
- template <typename T>
- inline T max(T a, T b)
- {
- return (a >= b) ? a : b;
- }
-
- /**
@brief Keeps a value between a lower and an upper limit.
@param x The value
@param min The lower limit
Modified: trunk/src/util/MultiType.cc
===================================================================
--- trunk/src/util/MultiType.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/MultiType.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -40,57 +40,57 @@
@brief Converts the current value of the MultiType to a new type.
@param type The type
*/
- bool MultiType::convert(MT_Type type)
+ bool MultiType::convert(MT_Type::Value type)
{
switch (type)
{
- case MT_null:
+ case MT_Type::Null:
this->reset(); return true;
- case MT_char:
+ case MT_Type::Char:
return this->convert<char>(); break;
- case MT_uchar:
+ case MT_Type::UnsignedChar:
return this->convert<unsigned char>(); break;
- case MT_short:
+ case MT_Type::Short:
return this->convert<short>(); break;
- case MT_ushort:
+ case MT_Type::UnsignedShort:
return this->convert<unsigned short>(); break;
- case MT_int:
+ case MT_Type::Int:
return this->convert<int>(); break;
- case MT_uint:
+ case MT_Type::UnsignedInt:
return this->convert<unsigned int>(); break;
- case MT_long:
+ case MT_Type::Long:
return this->convert<long>(); break;
- case MT_ulong:
+ case MT_Type::UnsignedLong:
return this->convert<unsigned long>(); break;
- case MT_longlong:
+ case MT_Type::LongLong:
return this->convert<long long>(); break;
- case MT_ulonglong:
+ case MT_Type::UnsignedLongLong:
return this->convert<unsigned long long>(); break;
- case MT_float:
+ case MT_Type::Float:
return this->convert<float>(); break;
- case MT_double:
+ case MT_Type::Double:
return this->convert<double>(); break;
- case MT_longdouble:
+ case MT_Type::LongDouble:
return this->convert<long double>(); break;
- case MT_bool:
+ case MT_Type::Bool:
return this->convert<bool>(); break;
- case MT_void:
+ case MT_Type::VoidPointer:
return this->convert<void*>(); break;
- case MT_string:
+ case MT_Type::String:
return this->convert<std::string>(); break;
- case MT_vector2:
+ case MT_Type::Vector2:
return this->convert<orxonox::Vector2>(); break;
- case MT_vector3:
+ case MT_Type::Vector3:
return this->convert<orxonox::Vector3>(); break;
- case MT_vector4:
+ case MT_Type::Vector4:
return this->convert<orxonox::Vector4>(); break;
- case MT_colourvalue:
+ case MT_Type::ColourValue:
return this->convert<orxonox::ColourValue>(); break;
- case MT_quaternion:
+ case MT_Type::Quaternion:
return this->convert<orxonox::Quaternion>(); break;
- case MT_radian:
+ case MT_Type::Radian:
return this->convert<orxonox::Radian>(); break;
- case MT_degree:
+ case MT_Type::Degree:
return this->convert<orxonox::Degree>(); break;
default:
this->reset(); return false; break;
@@ -103,106 +103,106 @@
*/
std::string MultiType::getTypename() const
{
- MT_Type type = (this->value_) ? this->value_->type_ : MT_null;
+ MT_Type::Value type = (this->value_) ? this->value_->type_ : MT_Type::Null;
switch (type)
{
- case MT_char:
+ case MT_Type::Char:
return "char"; break;
- case MT_uchar:
+ case MT_Type::UnsignedChar:
return "unsigned char"; break;
- case MT_short:
+ case MT_Type::Short:
return "short"; break;
- case MT_ushort:
+ case MT_Type::UnsignedShort:
return "unsigned short"; break;
- case MT_int:
+ case MT_Type::Int:
return "int"; break;
- case MT_uint:
+ case MT_Type::UnsignedInt:
return "unsigned int"; break;
- case MT_long:
+ case MT_Type::Long:
return "long"; break;
- case MT_ulong:
+ case MT_Type::UnsignedLong:
return "unsigned long"; break;
- case MT_longlong:
+ case MT_Type::LongLong:
return "long long"; break;
- case MT_ulonglong:
+ case MT_Type::UnsignedLongLong:
return "unsigned long long"; break;
- case MT_float:
+ case MT_Type::Float:
return "float"; break;
- case MT_double:
+ case MT_Type::Double:
return "double"; break;
- case MT_longdouble:
+ case MT_Type::LongDouble:
return "long double"; break;
- case MT_bool:
+ case MT_Type::Bool:
return "bool"; break;
- case MT_void:
+ case MT_Type::VoidPointer:
return "void*"; break;
- case MT_string:
+ case MT_Type::String:
return "std::string"; break;
- case MT_vector2:
+ case MT_Type::Vector2:
return "orxonox::Vector2"; break;
- case MT_vector3:
+ case MT_Type::Vector3:
return "orxonox::Vector3"; break;
- case MT_vector4:
+ case MT_Type::Vector4:
return "orxonox::Vector4"; break;
- case MT_colourvalue:
+ case MT_Type::ColourValue:
return "orxonox::ColourValue"; break;
- case MT_quaternion:
+ case MT_Type::Quaternion:
return "orxonox::Quaternion"; break;
- case MT_radian:
+ case MT_Type::Radian:
return "orxonox::Radian"; break;
- case MT_degree:
+ case MT_Type::Degree:
return "orxonox::Degree"; break;
default:
return "unknown"; break;
};
}
- MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_uchar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_ushort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_uint ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_ulong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_longlong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong ) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_void ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_string ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } /** @brief Returns the current value, converted to the requested type. */
- MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Char ) ? (static_cast<MT_Value<char> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator unsigned char() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedChar ) ? (static_cast<MT_Value<unsigned char> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Short ) ? (static_cast<MT_Value<short> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator unsigned short() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedShort ) ? (static_cast<MT_Value<unsigned short> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Int ) ? (static_cast<MT_Value<int> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator unsigned int() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedInt ) ? (static_cast<MT_Value<unsigned int> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Long ) ? (static_cast<MT_Value<long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator unsigned long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLong ) ? (static_cast<MT_Value<unsigned long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongLong ) ? (static_cast<MT_Value<long long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator unsigned long long() const { return (this->value_) ? ((this->value_->type_ == MT_Type::UnsignedLongLong) ? (static_cast<MT_Value<unsigned long long> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator float() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Float ) ? (static_cast<MT_Value<float> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Double ) ? (static_cast<MT_Value<double> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator long double() const { return (this->value_) ? ((this->value_->type_ == MT_Type::LongDouble ) ? (static_cast<MT_Value<long double> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator bool() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Bool ) ? (static_cast<MT_Value<bool> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator void*() const { return (this->value_) ? ((this->value_->type_ == MT_Type::VoidPointer ) ? (static_cast<MT_Value<void*> *>(this->value_))->value_ : (*this->value_)) : 0; } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator std::string() const { return (this->value_) ? ((this->value_->type_ == MT_Type::String ) ? (static_cast<MT_Value<std::string> *>(this->value_))->value_ : (*this->value_)) : NilValue<std::string>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::Vector2() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector2 ) ? (static_cast<MT_Value<orxonox::Vector2> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector2>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::Vector3() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector3 ) ? (static_cast<MT_Value<orxonox::Vector3> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector3>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::Vector4() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Vector4 ) ? (static_cast<MT_Value<orxonox::Vector4> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Vector4>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_Type::ColourValue ) ? (static_cast<MT_Value<orxonox::ColourValue>*>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::ColourValue>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::Quaternion() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Quaternion ) ? (static_cast<MT_Value<orxonox::Quaternion> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Quaternion>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::Radian() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Radian ) ? (static_cast<MT_Value<orxonox::Radian> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Radian>(); } /** @brief Returns the current value, converted to the requested type. */
+ MultiType::operator orxonox::Degree() const { return (this->value_) ? ((this->value_->type_ == MT_Type::Degree ) ? (static_cast<MT_Value<orxonox::Degree> *>(this->value_))->value_ : (*this->value_)) : NilValue<orxonox::Degree>(); } /** @brief Returns the current value, converted to the requested type. */
- template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_char ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_uchar ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_short ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_ushort ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_int ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_uint ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_long ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_ulong ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_longlong ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_ulonglong ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_float ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_double ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_longdouble ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_bool ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_void ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_string ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_vector2 ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_vector3 ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_vector4 ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_radian ); } /** @brief Creates a new value container for the given type. */
- template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_degree ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const char& value) { this->value_ = new MT_Value<char> (value, MT_Type::Char ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const unsigned char& value) { this->value_ = new MT_Value<unsigned char> (value, MT_Type::UnsignedChar ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const short& value) { this->value_ = new MT_Value<short> (value, MT_Type::Short ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const unsigned short& value) { this->value_ = new MT_Value<unsigned short> (value, MT_Type::UnsignedShort ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const int& value) { this->value_ = new MT_Value<int> (value, MT_Type::Int ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const unsigned int& value) { this->value_ = new MT_Value<unsigned int> (value, MT_Type::UnsignedInt ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const long& value) { this->value_ = new MT_Value<long> (value, MT_Type::Long ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const unsigned long& value) { this->value_ = new MT_Value<unsigned long> (value, MT_Type::UnsignedLong ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const long long& value) { this->value_ = new MT_Value<long long> (value, MT_Type::LongLong ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const unsigned long long& value) { this->value_ = new MT_Value<unsigned long long> (value, MT_Type::UnsignedLongLong); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const float& value) { this->value_ = new MT_Value<float> (value, MT_Type::Float ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const double& value) { this->value_ = new MT_Value<double> (value, MT_Type::Double ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const long double& value) { this->value_ = new MT_Value<long double> (value, MT_Type::LongDouble ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const bool& value) { this->value_ = new MT_Value<bool> (value, MT_Type::Bool ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer( void* const& value) { this->value_ = new MT_Value<void*> (value, MT_Type::VoidPointer ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const std::string& value) { this->value_ = new MT_Value<std::string> (value, MT_Type::String ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value) { this->value_ = new MT_Value<orxonox::Vector2> (value, MT_Type::Vector2 ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value) { this->value_ = new MT_Value<orxonox::Vector3> (value, MT_Type::Vector3 ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value) { this->value_ = new MT_Value<orxonox::Vector4> (value, MT_Type::Vector4 ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_Type::ColourValue ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value) { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_Type::Quaternion ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::Radian& value) { this->value_ = new MT_Value<orxonox::Radian> (value, MT_Type::Radian ); } /** @brief Creates a new value container for the given type. */
+ template <> void MultiType::createNewValueContainer(const orxonox::Degree& value) { this->value_ = new MT_Value<orxonox::Degree> (value, MT_Type::Degree ); } /** @brief Creates a new value container for the given type. */
}
Modified: trunk/src/util/MultiType.h
===================================================================
--- trunk/src/util/MultiType.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/MultiType.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -83,33 +83,36 @@
/**
@brief Enum of all possible types of a MultiType.
*/
- enum MT_Type
+ namespace MT_Type
{
- MT_null=0,
- MT_char=1,
- MT_uchar=2,
- MT_short=3,
- MT_ushort=4,
- MT_int=5,
- MT_uint=6,
- MT_long=7,
- MT_ulong=8,
- MT_longlong=9,
- MT_ulonglong=10,
- MT_float=11,
- MT_double=12,
- MT_longdouble=13,
- MT_bool=14,
- MT_void=15,
- MT_string=16,
- MT_vector2=17,
- MT_vector3=18,
- MT_vector4=19,
- MT_colourvalue=20,
- MT_quaternion=21,
- MT_radian=22,
- MT_degree=23
- };
+ enum Value
+ {
+ Null,
+ Char,
+ UnsignedChar,
+ Short,
+ UnsignedShort,
+ Int,
+ UnsignedInt,
+ Long,
+ UnsignedLong,
+ LongLong,
+ UnsignedLongLong,
+ Float,
+ Double,
+ LongDouble,
+ Bool,
+ VoidPointer,
+ String,
+ Vector2,
+ Vector3,
+ Vector4,
+ ColourValue,
+ Quaternion,
+ Radian,
+ Degree
+ };
+ }
/**
@brief The MultiType can hold a value of many possible types and convert them to other types.
@@ -141,7 +144,7 @@
class _UtilExport MT_ValueBase
{
public:
- MT_ValueBase(MT_Type type) : type_(type), bHasDefaultValue_(false) {}
+ MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {}
virtual ~MT_ValueBase() {}
virtual MT_ValueBase* clone() const = 0;
@@ -150,7 +153,7 @@
virtual bool assimilate(const MultiType& other) = 0;
/** @brief Returns the type of the current value. */
- const MT_Type& getType() const { return this->type_; }
+ const MT_Type::Value& getType() const { return this->type_; }
/** @brief Checks whether the value is a default one. */
bool hasDefaultValue() const { return this->bHasDefaultValue_; }
@@ -233,7 +236,7 @@
virtual void exportData( uint8_t*& mem ) const=0;
virtual uint8_t getSize() const=0;
- MT_Type type_; //!< The type of the current value
+ MT_Type::Value type_; //!< The type of the current value
bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
};
@@ -264,7 +267,7 @@
inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */
inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */
inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
- inline MultiType(MT_Type type) : value_(0) { this->setType(type); } /** @brief Constructor: Sets the type, the next assignment will determine the value. */
+ inline MultiType(MT_Type::Value type) : value_(0) { this->setType(type); } /** @brief Constructor: Sets the type, the next assignment will determine the value. */
/** @brief Destructor: Deletes the MT_Value. */
inline ~MultiType() { if (this->value_) { delete this->value_; } }
@@ -272,7 +275,7 @@
template <typename V> inline const MultiType& operator=(const V& value) { this->setValue(value); return (*this); } /** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */
template <typename V> inline const MultiType& operator=(V* value) { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
inline const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } /** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */
- inline const MultiType& operator=(MT_Type type) { this->setType(type); return (*this); } /** @brief Resets the value and changes the type. */
+ inline const MultiType& operator=(MT_Type::Value type) { this->setType(type); return (*this); } /** @brief Resets the value and changes the type. */
inline bool setValue(const char& value);
inline bool setValue(const unsigned char& value);
@@ -311,29 +314,29 @@
template <typename T> inline bool convert() { return this->setValue<T>((T)(*this)); } /** @brief Converts the current value to type T. */
inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
- bool convert(MT_Type type);
+ bool convert(MT_Type::Value type);
- /** @brief Current content gets deleted. New type is MT_null */
+ /** @brief Current content gets deleted. New type is MT_Type::Null */
inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; }
/** @brief Current content gets overridden with default zero value */
inline void resetValue() { if (this->value_) this->value_->reset(); }
template <typename T> inline void setType() { this->assignValue(typename TypeStripper<T>::RawType()); } /** @brief Resets the value and changes the internal type to T. */
inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */
- inline void setType(MT_Type type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */
+ inline void setType(MT_Type::Value type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */
/** @brief Returns the current type. */
- inline MT_Type getType() const { return (this->value_) ? this->value_->type_ : MT_null; }
+ inline MT_Type::Value getType() const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
/** @brief Returns true if the current type equals the given type. */
- inline bool isType(MT_Type type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
+ inline bool isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
/** @brief Returns true if the current type is T. */
- template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below
- std::string getTypename() const;
+ template <typename T> inline bool isType() const { return false; } // Only works for specialized values - see below
+ std::string getTypename() const;
/** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
- inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
+ inline void exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *(uint8_t*)(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
/** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
- inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type)<=8); this->setType(static_cast<MT_Type>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }
+ inline void importData(uint8_t*& mem) { assert(sizeof(MT_Type::Value)<=8); this->setType(static_cast<MT_Type::Value>(*(uint8_t*)mem)); mem+=sizeof(uint8_t); this->value_->importData(mem); }
/** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
inline uint8_t*& operator << (uint8_t*& mem) { importData(mem); return mem; }
/** @brief Loads the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
@@ -419,29 +422,29 @@
template <typename T> inline T* getPointer() const { return ((T*)this->getVoid()); } /** @brief Returns the current value, converted to a T* pointer. */
private:
- inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_uchar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_ushort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_uint) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_ulong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_longlong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_ulonglong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_longdouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_void) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_string) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
- inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const char& value) { if (this->value_ && this->value_->type_ == MT_Type::Char) { return this->value_->setValue(value); } else { this->changeValueContainer<char>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const unsigned char& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedChar) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const short& value) { if (this->value_ && this->value_->type_ == MT_Type::Short) { return this->value_->setValue(value); } else { this->changeValueContainer<short>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const unsigned short& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedShort) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const int& value) { if (this->value_ && this->value_->type_ == MT_Type::Int) { return this->value_->setValue(value); } else { this->changeValueContainer<int>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const unsigned int& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedInt) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const long& value) { if (this->value_ && this->value_->type_ == MT_Type::Long) { return this->value_->setValue(value); } else { this->changeValueContainer<long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const unsigned long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const long long& value) { if (this->value_ && this->value_->type_ == MT_Type::LongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<long long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const unsigned long long& value) { if (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong) { return this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const float& value) { if (this->value_ && this->value_->type_ == MT_Type::Float) { return this->value_->setValue(value); } else { this->changeValueContainer<float>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const double& value) { if (this->value_ && this->value_->type_ == MT_Type::Double) { return this->value_->setValue(value); } else { this->changeValueContainer<double>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const long double& value) { if (this->value_ && this->value_->type_ == MT_Type::LongDouble) { return this->value_->setValue(value); } else { this->changeValueContainer<long double>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const bool& value) { if (this->value_ && this->value_->type_ == MT_Type::Bool) { return this->value_->setValue(value); } else { this->changeValueContainer<bool>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue( void* const& value) { if (this->value_ && this->value_->type_ == MT_Type::VoidPointer) { return this->value_->setValue(value); } else { this->changeValueContainer<void*>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const std::string& value) { if (this->value_ && this->value_->type_ == MT_Type::String) { return this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::Vector2& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector2) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::Vector3& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector3) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::Vector4& value) { if (this->value_ && this->value_->type_ == MT_Type::Vector4) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_Type::ColourValue) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::Quaternion& value) { if (this->value_ && this->value_->type_ == MT_Type::Quaternion) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::Radian& value) { if (this->value_ && this->value_->type_ == MT_Type::Radian) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
+ inline bool assignValue(const orxonox::Degree& value) { if (this->value_ && this->value_->type_ == MT_Type::Degree) { return this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value); return true; } } /** @brief Assigns a new value by changing type and creating a new container. */
/** @brief Changes the value container. */
template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
@@ -454,29 +457,29 @@
/** @brief Puts the MultiType on a stream by using the native << operator of the current type. */
_UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
- template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_char); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_uchar); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_short); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_ushort); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_int); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_uint); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_long); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_ulong); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_longlong); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_ulonglong); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_float); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_double); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_longdouble); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_bool); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_void); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_string); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_vector2); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_vector3); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_vector4); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_quaternion); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_radian); } /** @brief Returns true if the current type equals the given type. */
- template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_degree); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<char>() const { return (this->value_ && this->value_->type_ == MT_Type::Char); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<unsigned char>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedChar); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<short>() const { return (this->value_ && this->value_->type_ == MT_Type::Short); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<unsigned short>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedShort); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<int>() const { return (this->value_ && this->value_->type_ == MT_Type::Int); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<unsigned int>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedInt); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<long>() const { return (this->value_ && this->value_->type_ == MT_Type::Long); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<unsigned long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLong); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<long long>() const { return (this->value_ && this->value_->type_ == MT_Type::LongLong); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<unsigned long long>() const { return (this->value_ && this->value_->type_ == MT_Type::UnsignedLongLong); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<float>() const { return (this->value_ && this->value_->type_ == MT_Type::Float); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<double>() const { return (this->value_ && this->value_->type_ == MT_Type::Double); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<long double>() const { return (this->value_ && this->value_->type_ == MT_Type::LongDouble); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<bool>() const { return (this->value_ && this->value_->type_ == MT_Type::Bool); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<void*>() const { return (this->value_ && this->value_->type_ == MT_Type::VoidPointer); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<std::string>() const { return (this->value_ && this->value_->type_ == MT_Type::String); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::Vector2>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector2); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::Vector3>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector3); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::Vector4>() const { return (this->value_ && this->value_->type_ == MT_Type::Vector4); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_Type::ColourValue); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::Quaternion>() const { return (this->value_ && this->value_->type_ == MT_Type::Quaternion); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::Radian>() const { return (this->value_ && this->value_->type_ == MT_Type::Radian); } /** @brief Returns true if the current type equals the given type. */
+ template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } /** @brief Returns true if the current type equals the given type. */
// Specialization to avoid ambiguities with the conversion operator
template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } /** @brief Converts the current value to the given type. */
Modified: trunk/src/util/MultiTypeValue.h
===================================================================
--- trunk/src/util/MultiTypeValue.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/MultiTypeValue.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -53,7 +53,7 @@
{
public:
/** @brief Constructor: Assigns the value and the type identifier. */
- MT_Value(const T& value, MT_Type type) : MT_ValueBase(type), value_(value) {}
+ MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {}
/** @brief Creates a copy of itself. */
inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
@@ -138,14 +138,14 @@
inline operator long double() const { return getConvertedValue<T, long double> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
inline operator bool() const { return getConvertedValue<T, bool> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
inline operator void*() const { return getConvertedValue<T, void*> (this->value_, 0); } /** @brief Returns the current value, converted to the requested type. */
- inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, zeroise<std::string >()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, zeroise<orxonox::Vector2 >()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, zeroise<orxonox::Vector3 >()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, zeroise<orxonox::Vector4 >()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, zeroise<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, zeroise<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, zeroise<orxonox::Radian >()); } /** @brief Returns the current value, converted to the requested type. */
- inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, zeroise<orxonox::Degree >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator std::string() const { return getConvertedValue<T, std::string> (this->value_, NilValue<std::string >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::Vector2() const { return getConvertedValue<T, orxonox::Vector2> (this->value_, NilValue<orxonox::Vector2 >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::Vector3() const { return getConvertedValue<T, orxonox::Vector3> (this->value_, NilValue<orxonox::Vector3 >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::Vector4() const { return getConvertedValue<T, orxonox::Vector4> (this->value_, NilValue<orxonox::Vector4 >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_, NilValue<orxonox::ColourValue>()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::Quaternion() const { return getConvertedValue<T, orxonox::Quaternion> (this->value_, NilValue<orxonox::Quaternion >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::Radian() const { return getConvertedValue<T, orxonox::Radian> (this->value_, NilValue<orxonox::Radian >()); } /** @brief Returns the current value, converted to the requested type. */
+ inline operator orxonox::Degree() const { return getConvertedValue<T, orxonox::Degree> (this->value_, NilValue<orxonox::Degree >()); } /** @brief Returns the current value, converted to the requested type. */
/** @brief Puts the current value on the stream */
inline void toString(std::ostream& outstream) const { outstream << this->value_; }
Copied: trunk/src/util/RefToValue.h (from rev 3238, branches/core4/src/util/RefToValue.h)
===================================================================
--- trunk/src/util/RefToValue.h (rev 0)
+++ trunk/src/util/RefToValue.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -0,0 +1,70 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2006 Richard Sposato
+// Copyright (c) 2006 Peter Kümmel
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The authors make no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_REFTOVALUE_INC_
+#define LOKI_REFTOVALUE_INC_
+
+// $Id: RefToValue.h 751 2006-10-17 19:50:37Z syntheticpp $
+
+
+namespace Loki
+{
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \class RefToValue
+ ///
+ /// \ingroup SmartPointerGroup
+ /// Transports a reference as a value
+ /// Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <class T>
+ class RefToValue
+ {
+ public:
+
+ RefToValue(T& ref) : ref_(ref)
+ {}
+
+ RefToValue(const RefToValue& rhs) : ref_(rhs.ref_)
+ {}
+
+ operator T& () const
+ {
+ return ref_;
+ }
+
+ private:
+ // Disable - not implemented
+ RefToValue();
+ RefToValue& operator=(const RefToValue&);
+
+ T& ref_;
+ };
+
+
+ ////////////////////////////////////////////////////////////////////////////////
+ /// \ingroup ExceptionGroup
+ /// RefToValue creator.
+ ////////////////////////////////////////////////////////////////////////////////
+
+ template <class T>
+ inline RefToValue<T> ByRef(T& t)
+ {
+ return RefToValue<T>(t);
+ }
+
+}
+
+
+#endif // end file guardian
+
Copied: trunk/src/util/ScopeGuard.h (from rev 3238, branches/core4/src/util/ScopeGuard.h)
===================================================================
--- trunk/src/util/ScopeGuard.h (rev 0)
+++ trunk/src/util/ScopeGuard.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -0,0 +1,666 @@
+////////////////////////////////////////////////////////////////////////////////
+// The Loki Library
+// Copyright (c) 2000 Andrei Alexandrescu
+// Copyright (c) 2000 Petru Marginean
+// Copyright (c) 2005 Joshua Lehrer
+//
+// Permission to use, copy, modify, distribute and sell this software for any
+// purpose is hereby granted without fee, provided that the above copyright
+// notice appear in all copies and that both that copyright notice and this
+// permission notice appear in supporting documentation.
+// The author makes no representations about the
+// suitability of this software for any purpose. It is provided "as is"
+// without express or implied warranty.
+////////////////////////////////////////////////////////////////////////////////
+#ifndef LOKI_SCOPEGUARD_INC_
+#define LOKI_SCOPEGUARD_INC_
+
+// $Id: ScopeGuard.h 799 2006-12-20 00:37:13Z rich_sposato $
+
+
+#include "RefToValue.h"
+
+/// \defgroup ExceptionGroup Exception-safe code
+
+namespace Loki
+{
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImplBase
+ /// \ingroup ExceptionGroup
+ ///
+ /// Base class used by all ScopeGuard implementations. All commonly used
+ /// functions are in this class (e.g. - Dismiss and SafeExecute).
+ ///
+ /// See Andrei's and Petru Marginean's CUJ article
+ /// http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm
+ ///
+ /// Changes to the original code by Joshua Lehrer:
+ /// http://www.lehrerfamily.com/scopeguard.html
+ ////////////////////////////////////////////////////////////////
+
+ class ScopeGuardImplBase
+ {
+ /// Copy-assignment operator is not implemented and private.
+ ScopeGuardImplBase& operator =(const ScopeGuardImplBase&);
+
+ protected:
+
+ ~ScopeGuardImplBase()
+ {}
+
+ /// Copy-constructor takes over responsibility from other ScopeGuard.
+ ScopeGuardImplBase(const ScopeGuardImplBase& other) throw()
+ : dismissed_(other.dismissed_)
+ {
+ other.Dismiss();
+ }
+
+ template <typename J>
+ static void SafeExecute(J& j) throw()
+ {
+ if (!j.dismissed_)
+ try
+ {
+ j.Execute();
+ }
+ catch(...)
+ {}
+ }
+
+ mutable bool dismissed_;
+
+ public:
+ ScopeGuardImplBase() throw() : dismissed_(false)
+ {}
+
+ void Dismiss() const throw()
+ {
+ dismissed_ = true;
+ }
+ };
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \typedef typedef const ScopeGuardImplBase& ScopeGuard
+ /// \ingroup ExceptionGroup
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ typedef const ScopeGuardImplBase& ScopeGuard;
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImpl0
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a standalone function or class static function
+ /// with no parameters. ScopeGuard ignores any value returned from the
+ /// call within the Execute function.
+ ///
+ /// This class has a single standalone helper function, MakeGuard which
+ /// creates and returns a ScopeGuard.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <typename F>
+ class ScopeGuardImpl0 : public ScopeGuardImplBase
+ {
+ public:
+ static ScopeGuardImpl0<F> MakeGuard(F fun)
+ {
+ return ScopeGuardImpl0<F>(fun);
+ }
+
+ ~ScopeGuardImpl0() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ fun_();
+ }
+
+ protected:
+ ScopeGuardImpl0(F fun) : fun_(fun)
+ {}
+
+ F fun_;
+ };
+
+ template <typename F>
+ inline ScopeGuardImpl0<F> MakeGuard(F fun)
+ {
+ return ScopeGuardImpl0<F>::MakeGuard(fun);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImpl1
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a standalone function or class static function
+ /// with one parameter. Each parameter is copied by value - use
+ /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+ /// any value returned from the call within the Execute function.
+ ///
+ /// This class has a single standalone helper function, MakeGuard which
+ /// creates and returns a ScopeGuard.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <typename F, typename P1>
+ class ScopeGuardImpl1 : public ScopeGuardImplBase
+ {
+ public:
+ static ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
+ {
+ return ScopeGuardImpl1<F, P1>(fun, p1);
+ }
+
+ ~ScopeGuardImpl1() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ fun_(p1_);
+ }
+
+ protected:
+ ScopeGuardImpl1(F fun, P1 p1) : fun_(fun), p1_(p1)
+ {}
+
+ F fun_;
+ const P1 p1_;
+ };
+
+ template <typename F, typename P1>
+ inline ScopeGuardImpl1<F, P1> MakeGuard(F fun, P1 p1)
+ {
+ return ScopeGuardImpl1<F, P1>::MakeGuard(fun, p1);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImpl2
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a standalone function or class static function
+ /// with two parameters. Each parameter is copied by value - use
+ /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+ /// any value returned from the call within the Execute function.
+ ///
+ /// This class has a single standalone helper function, MakeGuard which
+ /// creates and returns a ScopeGuard.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <typename F, typename P1, typename P2>
+ class ScopeGuardImpl2: public ScopeGuardImplBase
+ {
+ public:
+ static ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
+ {
+ return ScopeGuardImpl2<F, P1, P2>(fun, p1, p2);
+ }
+
+ ~ScopeGuardImpl2() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ fun_(p1_, p2_);
+ }
+
+ protected:
+ ScopeGuardImpl2(F fun, P1 p1, P2 p2) : fun_(fun), p1_(p1), p2_(p2)
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ };
+
+ template <typename F, typename P1, typename P2>
+ inline ScopeGuardImpl2<F, P1, P2> MakeGuard(F fun, P1 p1, P2 p2)
+ {
+ return ScopeGuardImpl2<F, P1, P2>::MakeGuard(fun, p1, p2);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImpl3
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a standalone function or class static function
+ /// with three parameters. Each parameter is copied by value - use
+ /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+ /// any value returned from the call within the Execute function.
+ ///
+ /// This class has a single standalone helper function, MakeGuard which
+ /// creates and returns a ScopeGuard.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <typename F, typename P1, typename P2, typename P3>
+ class ScopeGuardImpl3 : public ScopeGuardImplBase
+ {
+ public:
+ static ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
+ {
+ return ScopeGuardImpl3<F, P1, P2, P3>(fun, p1, p2, p3);
+ }
+
+ ~ScopeGuardImpl3() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ fun_(p1_, p2_, p3_);
+ }
+
+ protected:
+ ScopeGuardImpl3(F fun, P1 p1, P2 p2, P3 p3) : fun_(fun), p1_(p1), p2_(p2), p3_(p3)
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+ };
+
+ template <typename F, typename P1, typename P2, typename P3>
+ inline ScopeGuardImpl3<F, P1, P2, P3> MakeGuard(F fun, P1 p1, P2 p2, P3 p3)
+ {
+ return ScopeGuardImpl3<F, P1, P2, P3>::MakeGuard(fun, p1, p2, p3);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImpl4
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a standalone function or class static function
+ /// with four parameters. Each parameter is copied by value - use
+ /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+ /// any value returned from the call within the Execute function.
+ ///
+ /// This class has a single standalone helper function, MakeGuard which
+ /// creates and returns a ScopeGuard.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template < typename F, typename P1, typename P2, typename P3, typename P4 >
+ class ScopeGuardImpl4 : public ScopeGuardImplBase
+ {
+ public:
+ static ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard(
+ F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
+ {
+ return ScopeGuardImpl4< F, P1, P2, P3, P4 >( fun, p1, p2, p3, p4 );
+ }
+
+ ~ScopeGuardImpl4() throw()
+ {
+ SafeExecute( *this );
+ }
+
+ void Execute()
+ {
+ fun_( p1_, p2_, p3_, p4_ );
+ }
+
+ protected:
+ ScopeGuardImpl4( F fun, P1 p1, P2 p2, P3 p3, P4 p4 ) :
+ fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 )
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+ const P4 p4_;
+ };
+
+ template < typename F, typename P1, typename P2, typename P3, typename P4 >
+ inline ScopeGuardImpl4< F, P1, P2, P3, P4 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4 )
+ {
+ return ScopeGuardImpl4< F, P1, P2, P3, P4 >::MakeGuard( fun, p1, p2, p3, p4 );
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ScopeGuardImpl5
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a standalone function or class static function
+ /// with five parameters. Each parameter is copied by value - use
+ /// ::Loki::ByRef if you must use a reference instead. ScopeGuard ignores
+ /// any value returned from the call within the Execute function.
+ ///
+ /// This class has a single standalone helper function, MakeGuard which
+ /// creates and returns a ScopeGuard.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
+ class ScopeGuardImpl5 : public ScopeGuardImplBase
+ {
+ public:
+ static ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard(
+ F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
+ {
+ return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >( fun, p1, p2, p3, p4, p5 );
+ }
+
+ ~ScopeGuardImpl5() throw()
+ {
+ SafeExecute( *this );
+ }
+
+ void Execute()
+ {
+ fun_( p1_, p2_, p3_, p4_, p5_ );
+ }
+
+ protected:
+ ScopeGuardImpl5( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 ) :
+ fun_( fun ), p1_( p1 ), p2_( p2 ), p3_( p3 ), p4_( p4 ), p5_( p5 )
+ {}
+
+ F fun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+ const P4 p4_;
+ const P5 p5_;
+ };
+
+ template < typename F, typename P1, typename P2, typename P3, typename P4, typename P5 >
+ inline ScopeGuardImpl5< F, P1, P2, P3, P4, P5 > MakeGuard( F fun, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5 )
+ {
+ return ScopeGuardImpl5< F, P1, P2, P3, P4, P5 >::MakeGuard( fun, p1, p2, p3, p4, p5 );
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ObjScopeGuardImpl0
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a class per-instance member function with no
+ /// parameters. ScopeGuard ignores any value returned from the call within
+ /// the Execute function.
+ ///
+ /// This class has 3 standalone helper functions which create a ScopeGuard.
+ /// One is MakeObjGuard, which is deprecated but provided for older code.
+ /// The other two are MakeGuard overloads, one which takes a pointer to an
+ /// object, and the other which takes a reference.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <class Obj, typename MemFun>
+ class ObjScopeGuardImpl0 : public ScopeGuardImplBase
+ {
+ public:
+ static ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
+ {
+ return ObjScopeGuardImpl0<Obj, MemFun>(obj, memFun);
+ }
+
+ ~ObjScopeGuardImpl0() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ (obj_.*memFun_)();
+ }
+
+ protected:
+ ObjScopeGuardImpl0(Obj& obj, MemFun memFun) : obj_(obj), memFun_(memFun)
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ };
+
+ template <class Obj, typename MemFun>
+ inline ObjScopeGuardImpl0<Obj, MemFun> MakeObjGuard(Obj& obj, MemFun memFun)
+ {
+ return ObjScopeGuardImpl0<Obj, MemFun>::MakeObjGuard(obj, memFun);
+ }
+
+ template <typename Ret, class Obj1, class Obj2>
+ inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 &obj)
+ {
+ return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(obj,memFun);
+ }
+
+ template <typename Ret, class Obj1, class Obj2>
+ inline ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()> MakeGuard(Ret(Obj2::*memFun)(), Obj1 *obj)
+ {
+ return ObjScopeGuardImpl0<Obj1,Ret(Obj2::*)()>::MakeObjGuard(*obj,memFun);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ObjScopeGuardImpl1
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a class per-instance member function with one
+ /// parameter. The parameter is copied by value - use ::Loki::ByRef if you
+ /// must use a reference instead. ScopeGuard ignores any value returned
+ /// from the call within the Execute function.
+ ///
+ /// This class has 3 standalone helper functions which create a ScopeGuard.
+ /// One is MakeObjGuard, which is deprecated but provided for older code.
+ /// The other two are MakeGuard overloads, one which takes a pointer to an
+ /// object, and the other which takes a reference.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <class Obj, typename MemFun, typename P1>
+ class ObjScopeGuardImpl1 : public ScopeGuardImplBase
+ {
+ public:
+ static ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
+ {
+ return ObjScopeGuardImpl1<Obj, MemFun, P1>(obj, memFun, p1);
+ }
+
+ ~ObjScopeGuardImpl1() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ (obj_.*memFun_)(p1_);
+ }
+
+ protected:
+ ObjScopeGuardImpl1(Obj& obj, MemFun memFun, P1 p1) : obj_(obj), memFun_(memFun), p1_(p1)
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ const P1 p1_;
+ };
+
+ template <class Obj, typename MemFun, typename P1>
+ inline ObjScopeGuardImpl1<Obj, MemFun, P1> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1)
+ {
+ return ObjScopeGuardImpl1<Obj, MemFun, P1>::MakeObjGuard(obj, memFun, p1);
+ }
+
+ template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
+ inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 &obj, P1b p1)
+ {
+ return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(obj,memFun,p1);
+ }
+
+ template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b>
+ inline ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b> MakeGuard(Ret(Obj2::*memFun)(P1a), Obj1 *obj, P1b p1)
+ {
+ return ObjScopeGuardImpl1<Obj1,Ret(Obj2::*)(P1a),P1b>::MakeObjGuard(*obj,memFun,p1);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ObjScopeGuardImpl2
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a class per-instance member function with two
+ /// parameters. Each parameter is copied by value - use ::Loki::ByRef if you
+ /// must use a reference instead. ScopeGuard ignores any value returned
+ /// from the call within the Execute function.
+ ///
+ /// This class has 3 standalone helper functions which create a ScopeGuard.
+ /// One is MakeObjGuard, which is deprecated but provided for older code.
+ /// The other two are MakeGuard overloads, one which takes a pointer to an
+ /// object, and the other which takes a reference.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template <class Obj, typename MemFun, typename P1, typename P2>
+ class ObjScopeGuardImpl2 : public ScopeGuardImplBase
+ {
+ public:
+ static ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
+ {
+ return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>(obj, memFun, p1, p2);
+ }
+
+ ~ObjScopeGuardImpl2() throw()
+ {
+ SafeExecute(*this);
+ }
+
+ void Execute()
+ {
+ (obj_.*memFun_)(p1_, p2_);
+ }
+
+ protected:
+ ObjScopeGuardImpl2(Obj& obj, MemFun memFun, P1 p1, P2 p2) : obj_(obj), memFun_(memFun), p1_(p1), p2_(p2)
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ const P1 p1_;
+ const P2 p2_;
+ };
+
+ template <class Obj, typename MemFun, typename P1, typename P2>
+ inline ObjScopeGuardImpl2<Obj, MemFun, P1, P2> MakeObjGuard(Obj& obj, MemFun memFun, P1 p1, P2 p2)
+ {
+ return ObjScopeGuardImpl2<Obj, MemFun, P1, P2>::MakeObjGuard(obj, memFun, p1, p2);
+ }
+
+ template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
+ inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 &obj, P1b p1, P2b p2)
+ {
+ return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(obj,memFun,p1,p2);
+ }
+
+ template <typename Ret, class Obj1, class Obj2, typename P1a, typename P1b, typename P2a, typename P2b>
+ inline ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b> MakeGuard(Ret(Obj2::*memFun)(P1a,P2a), Obj1 *obj, P1b p1, P2b p2)
+ {
+ return ObjScopeGuardImpl2<Obj1,Ret(Obj2::*)(P1a,P2a),P1b,P2b>::MakeObjGuard(*obj,memFun,p1,p2);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ ///
+ /// \class ObjScopeGuardImpl3
+ /// \ingroup ExceptionGroup
+ ///
+ /// Implementation class for a class per-instance member function with three
+ /// parameters. Each parameter is copied by value - use ::Loki::ByRef if you
+ /// must use a reference instead. ScopeGuard ignores any value returned
+ /// from the call within the Execute function.
+ ///
+ /// This class has 3 standalone helper functions which create a ScopeGuard.
+ /// One is MakeObjGuard, which is deprecated but provided for older code.
+ /// The other two are MakeGuard overloads, one which takes a pointer to an
+ /// object, and the other which takes a reference.
+ ///
+ ////////////////////////////////////////////////////////////////
+
+ template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
+ class ObjScopeGuardImpl3 : public ScopeGuardImplBase
+ {
+ public:
+ static ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
+ Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
+ {
+ return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >( obj, memFun, p1, p2, p3 );
+ }
+
+ ~ObjScopeGuardImpl3() throw()
+ {
+ SafeExecute( *this );
+ }
+
+ void Execute()
+ {
+ ( obj_.*memFun_ )( p1_, p2_, p3_ );
+ }
+
+ protected:
+ ObjScopeGuardImpl3( Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 ) :
+ obj_( obj ), memFun_( memFun ), p1_( p1 ), p2_( p2 ), p3_( p3 )
+ {}
+
+ Obj& obj_;
+ MemFun memFun_;
+ const P1 p1_;
+ const P2 p2_;
+ const P3 p3_;
+ };
+
+ template < class Obj, typename MemFun, typename P1, typename P2, typename P3 >
+ inline ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 > MakeObjGuard(
+ Obj & obj, MemFun memFun, P1 p1, P2 p2, P3 p3 )
+ {
+ return ObjScopeGuardImpl3< Obj, MemFun, P1, P2, P3 >::MakeObjGuard(
+ obj, memFun, p1, p2, p3 );
+ }
+
+ template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
+ typename P2a, typename P2b, typename P3a, typename P3b >
+ inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+ MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1 & obj, P1b p1, P2b p2, P3b p3 )
+ {
+ return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+ ::MakeObjGuard( obj, memFun, p1, p2, p3 );
+ }
+
+ template < typename Ret, class Obj1, class Obj2, typename P1a, typename P1b,
+ typename P2a, typename P2b, typename P3a, typename P3b >
+ inline ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+ MakeGuard( Ret( Obj2::*memFun )( P1a, P2a, P3a ), Obj1 * obj, P1b p1, P2b p2, P3b p3 )
+ {
+ return ObjScopeGuardImpl3< Obj1, Ret( Obj2::* )( P1a, P2a, P3a ), P1b, P2b, P3b >
+ ::MakeObjGuard( *obj, memFun, p1, p2, p3 );
+ }
+
+} // namespace Loki
+
+#define LOKI_CONCATENATE_DIRECT(s1, s2) s1##s2
+#define LOKI_CONCATENATE(s1, s2) LOKI_CONCATENATE_DIRECT(s1, s2)
+#define LOKI_ANONYMOUS_VARIABLE(str) LOKI_CONCATENATE(str, __LINE__)
+
+#define LOKI_ON_BLOCK_EXIT ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeGuard
+#define LOKI_ON_BLOCK_EXIT_OBJ ::Loki::ScopeGuard LOKI_ANONYMOUS_VARIABLE(scopeGuard) = ::Loki::MakeObjGuard
+
+#endif // end file guardian
+
Deleted: trunk/src/util/String.cc
===================================================================
--- trunk/src/util/String.cc 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/String.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -1,492 +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:
- * Benjamin Grauer
- *
- */
-
-/**
- @file
- @brief Implementation of several string manipulation functions.
-*/
-
-#include "String.h"
-
-#include <cctype>
-#include "Convert.h"
-#include "Math.h"
-
-namespace orxonox
-{
- std::string BLANKSTRING("");
-
- std::string getUniqueNumberString()
- {
- return convertToString(getUniqueNumber());
- }
-
- /**
- @brief Removes all whitespaces from a string.
- @param str The string to strip
- */
- void strip(std::string* str)
- {
- size_t pos;
- while ((pos = (*str).find(" ")) < (*str).length())
- (*str).erase(pos, 1);
- while ((pos = (*str).find("\t")) < (*str).length())
- (*str).erase(pos, 1);
- while ((pos = (*str).find("\n")) < (*str).length())
- (*str).erase(pos, 1);
- }
-
- /**
- @brief Returns a copy of a string without whitespaces.
- @param str The string to strip
- @return The stripped line
- */
- std::string getStripped(const std::string& str)
- {
- std::string output = std::string(str);
- strip(&output);
- return output;
- }
-
- /**
- @brief Returns a copy of a string without trailing whitespaces.
- @param str The string
- @return The modified copy
- */
- std::string removeTrailingWhitespaces(const std::string& str)
- {
- size_t pos1 = 0;
- int pos2 = (int)(str.size() - 1);
- for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
- for (; pos2 > 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
- return str.substr(pos1, pos2 - pos1 + 1);
- }
-
- /**
- @brief Returns the position of the next quote in the string, starting with start.
- @param str The string
- @param start The startposition
- @return The position of the next quote (std::string::npos if there is no next quote)
- */
- size_t getNextQuote(const std::string& str, size_t start)
- {
- size_t quote = start - 1;
-
- while ((quote = str.find('\"', quote + 1)) != std::string::npos)
- {
- size_t backslash = quote;
- size_t numbackslashes = 0;
- for (; backslash > 0; backslash--, numbackslashes++)
- if (str[backslash - 1] != '\\')
- break;
-
- if (numbackslashes % 2 == 0)
- break;
- }
-
- return quote;
- }
-
- /**
- @brief Returns true if pos is between two quotes.
- @param str The string
- @param pos The position to check
- @return True if pos is between two quotes
- */
- bool isBetweenQuotes(const std::string& str, size_t pos)
- {
- if (pos == std::string::npos)
- return false;
-
- size_t quotecount = 0;
- size_t quote = (size_t)-1;
- while ((quote = getNextQuote(str, quote + 1)) < pos)
- {
- if (quote == pos)
- return false;
- quotecount++;
- }
-
- if (quote == std::string::npos)
- return false;
-
- return ((quotecount % 2) == 1);
- }
-
- /**
- @brief Returns true if the string contains something like '..."between quotes"...'.
- @param The string
- @return True if there is something between quotes
- */
- bool hasStringBetweenQuotes(const std::string& str)
- {
- size_t pos1 = getNextQuote(str, 0);
- size_t pos2 = getNextQuote(str, pos1 + 1);
- return (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1);
- }
-
- /**
- @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
- @param The string
- @param The string between the quotes
- */
- std::string getStringBetweenQuotes(const std::string& str)
- {
- size_t pos1 = getNextQuote(str, 0);
- size_t pos2 = getNextQuote(str, pos1 + 1);
- if (pos1 != std::string::npos && pos2 != std::string::npos)
- return str.substr(pos1, pos2 - pos1 + 1);
- else
- return "";
- }
-
- /**
- @brief Removes enclosing quotes if available (including whitespaces at the outside of the quotes).
- @brief str The string to strip
- @return The string with removed quotes
- */
- std::string stripEnclosingQuotes(const std::string& str)
- {
- size_t start = std::string::npos;
- size_t end = 0;
-
- for (size_t pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++)
- {
- if (str[pos] == '"')
- {
- start = pos;
- break;
- }
-
- if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
- return str;
- }
-
- for (size_t pos = str.size() - 1; pos < std::string::npos; pos--)
- {
- if (str[pos] == '"')
- {
- end = pos;
- break;
- }
-
- if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
- return str;
- }
-
- if ((start != std::string::npos) && (end != 0))
- return str.substr(start + 1, end - start - 1);
- else
- return str;
- }
-
- /**
- @brief Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string).
- @param str The string to strip
- @return The striped string
- */
- std::string stripEnclosingBraces(const std::string& str)
- {
- std::string output = str;
-
- while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}')
- output = output.substr(1, output.size() - 2);
-
- return output;
- }
-
- /**
- @brief Determines if a string is a comment (starts with a comment-symbol).
- @param str The string to check
- @return True = it's a comment
-
- A comment is defined by a leading '#', '%', ';' or '//'.
- */
- bool isComment(const std::string& str)
- {
- // Strip the line, whitespaces are disturbing
- std::string teststring = getStripped(str);
-
- // There are four possible comment-symbols:
- // 1) #comment in script-language style
- // 2) %comment in matlab style
- // 3) ;comment in unreal tournament config-file style
- // 4) //comment in code style
- if (teststring.size() >= 2)
- {
- if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[1] == '/'))
- return true;
- }
- else if (teststring.size() == 1)
- {
- if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';')
- return true;
- }
-
- return false;
- }
-
- /**
- @brief Determines if a string is empty (contains only whitespaces).
- @param str The string to check
- @return True = it's empty
- */
- bool isEmpty(const std::string& str)
- {
- std::string temp = getStripped(str);
- return ((temp == "") || (temp.size() == 0));
- }
-
- /**
- @brief Determines if a string contains only numbers and maximal one '.'.
- @param str The string to check
- @return True = it's a number
- */
- bool isNumeric(const std::string& str)
- {
- bool foundPoint = false;
-
- for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
- {
- if (((*it) < '0' || (*it) > '9'))
- {
- if ((*it) != '.' && !foundPoint)
- foundPoint = true;
- else
- return false;
- }
- }
-
- return true;
- }
-
- /**
- @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
- @param str The string to manipulate
- @return The string with added slashes
- */
- std::string addSlashes(const std::string& str)
- {
- std::string output = str;
-
- for (size_t pos = 0; (pos = output.find('\\', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\\"); }
- for (size_t pos = 0; (pos = output.find('\n', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\n"); }
- for (size_t pos = 0; (pos = output.find('\t', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\t"); }
- for (size_t pos = 0; (pos = output.find('\v', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\v"); }
- for (size_t pos = 0; (pos = output.find('\b', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\b"); }
- for (size_t pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\r"); }
- for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
- for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
- for (size_t pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
- for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
-
- return output;
- }
-
- /**
- @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
- @param str The string to manipulate
- @return The string with removed slashes
- */
- std::string removeSlashes(const std::string& str)
- {
- if (str.size() <= 1)
- return str;
-
- std::string output = "";
- for (size_t pos = 0; pos < str.size() - 1; )
- {
- if (str[pos] == '\\')
- {
- if (str[pos + 1] == '\\') { output += '\\'; pos += 2; continue; }
- else if (str[pos + 1] == 'n') { output += '\n'; pos += 2; continue; }
- else if (str[pos + 1] == 't') { output += '\t'; pos += 2; continue; }
- else if (str[pos + 1] == 'v') { output += '\v'; pos += 2; continue; }
- else if (str[pos + 1] == 'b') { output += '\b'; pos += 2; continue; }
- else if (str[pos + 1] == 'r') { output += '\r'; pos += 2; continue; }
- else if (str[pos + 1] == 'f') { output += '\f'; pos += 2; continue; }
- else if (str[pos + 1] == 'a') { output += '\a'; pos += 2; continue; }
- else if (str[pos + 1] == '"') { output += '"'; pos += 2; continue; }
- else if (str[pos + 1] == '0') { output += '\0'; pos += 2; continue; }
- }
- output += str[pos];
- pos++;
- if (pos == str.size() - 1)
- output += str[pos];
- }
-
- return output;
- }
-
- /**
- @brief Replaces each char between A and Z with its lowercase equivalent.
- @param str The string to convert
- */
- void lowercase(std::string* str)
- {
- for (size_t i = 0; i < str->size(); ++i)
- {
- (*str)[i] = (char)tolower((*str)[i]);
- }
- }
-
- /**
- @brief Returns a copy of the given string without uppercase chars.
- @param str The string
- @return The copy
- */
- std::string getLowercase(const std::string& str)
- {
- std::string output = std::string(str);
- lowercase(&output);
- return output;
- }
-
- /**
- @brief Replaces each char between a and z with its uppercase equivalent.
- @param str The string to convert
- */
- void uppercase(std::string* str)
- {
- for (size_t i = 0; i < str->size(); ++i)
- {
- (*str)[i] = (char)toupper((*str)[i]);
- }
- }
-
- /**
- @brief Returns a copy of the given string without lowercase chars.
- @param str The string
- @return The copy
- */
- std::string getUppercase(const std::string& str)
- {
- std::string output = std::string(str);
- uppercase(&output);
- return output;
- }
-
- /**
- @brief Compares two strings ignoring different casing.
- @param s1 First string
- @param s2 Second string
- */
- int nocaseCmp(const std::string& s1, const std::string& s2)
- {
- std::string::const_iterator it1=s1.begin();
- std::string::const_iterator it2=s2.begin();
-
- //stop when either string's end has been reached
- while ( (it1!=s1.end()) && (it2!=s2.end()) )
- {
- if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
- // return -1 to indicate smaller than, 1 otherwise
- return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
- //proceed to the next character in each string
- ++it1;
- ++it2;
- }
- size_t size1=s1.size(), size2=s2.size();// cache lengths
- //return -1,0 or 1 according to strings' lengths
- if (size1==size2)
- return 0;
- return (size1<size2) ? -1 : 1;
- }
-
-
- /**
- @brief Compares the first 'len' chars of two strings ignoring different casing.
- @param s1 First string
- @param s2 Second string
- @param len Maximal number of chars to compare
- */
- int nocaseCmp(const std::string& s1, const std::string& s2, size_t len)
- {
- if (len == 0)
- return 0;
- std::string::const_iterator it1=s1.begin();
- std::string::const_iterator it2=s2.begin();
-
- //stop when either string's end has been reached
- while ( (it1!=s1.end()) && (it2!=s2.end()) && len-- > 0)
- {
- if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
- // return -1 to indicate smaller than, 1 otherwise
- return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
- //proceed to the next character in each string
- ++it1;
- ++it2;
- }
- return 0;
- }
-
- /**
- @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
- @param str The string
- @return True if the string contains a comment
- */
- bool hasComment(const std::string& str)
- {
- return (getCommentPosition(str) != std::string::npos);
- }
-
- /**
- @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
- @param str The string
- @return The comment
- */
- std::string getComment(const std::string& str)
- {
- return str.substr(getCommentPosition(str));
- }
-
- /**
- @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
- @param str The string
- @return The position
- */
- size_t getCommentPosition(const std::string& str)
- {
- return getNextCommentPosition(str, 0);
- }
-
- /**
- @brief Returns the position of the next comment-symbol, starting with start.
- @param str The string
- @param start The startposition
- @return The position
- */
- size_t getNextCommentPosition(const std::string& str, size_t start)
- {
- for (size_t i = start; i < str.size(); i++)
- if (isComment(str.substr(i)))
- return i;
-
- return std::string::npos;
- }
-}
Deleted: trunk/src/util/String.h
===================================================================
--- trunk/src/util/String.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/String.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -1,81 +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 Declaration of several string manipulation functions, used in many parts of the game.
-*/
-
-#ifndef _Util_String_H__
-#define _Util_String_H__
-
-#include "UtilPrereqs.h"
-#include <string>
-
-namespace orxonox
-{
- extern _UtilExport std::string BLANKSTRING;
- _UtilExport std::string getUniqueNumberString();
-
- _UtilExport void strip(std::string* str);
- _UtilExport std::string getStripped(const std::string& str);
-
- _UtilExport std::string removeTrailingWhitespaces(const std::string& str);
-
- _UtilExport size_t getNextQuote(const std::string& str, size_t start);
- _UtilExport bool isBetweenQuotes(const std::string& str, size_t pos);
-
- _UtilExport bool hasStringBetweenQuotes(const std::string& str);
- _UtilExport std::string getStringBetweenQuotes(const std::string& str);
-
- _UtilExport std::string stripEnclosingQuotes(const std::string& str);
- _UtilExport std::string stripEnclosingBraces(const std::string& str);
-
- _UtilExport bool isEmpty(const std::string& str);
- _UtilExport bool isComment(const std::string& str);
- _UtilExport bool isNumeric(const std::string& str);
-
- _UtilExport std::string addSlashes(const std::string& str);
- _UtilExport std::string removeSlashes(const std::string& str);
-
- _UtilExport void lowercase(std::string* str);
- _UtilExport std::string getLowercase(const std::string& str);
-
- _UtilExport void uppercase(std::string* str);
- _UtilExport std::string getUppercase(const std::string& str);
-
- _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2);
- _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2, size_t len);
-
- _UtilExport bool hasComment(const std::string& str);
- _UtilExport std::string getComment(const std::string& str);
- _UtilExport size_t getCommentPosition(const std::string& str);
- _UtilExport size_t getNextCommentPosition(const std::string& str, size_t start = 0);
-}
-
-#endif /* _Util_String_H__ */
Copied: trunk/src/util/StringUtils.cc (from rev 3251, branches/core4/src/util/StringUtils.cc)
===================================================================
--- trunk/src/util/StringUtils.cc (rev 0)
+++ trunk/src/util/StringUtils.cc 2009-07-12 21:58:01 UTC (rev 3280)
@@ -0,0 +1,492 @@
+/*
+ * 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:
+ * Benjamin Grauer
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of several string manipulation functions.
+*/
+
+#include "StringUtils.h"
+
+#include <cctype>
+#include "Convert.h"
+#include "Math.h"
+
+namespace orxonox
+{
+ std::string BLANKSTRING("");
+
+ std::string getUniqueNumberString()
+ {
+ return multi_cast<std::string>(getUniqueNumber());
+ }
+
+ /**
+ @brief Removes all whitespaces from a string.
+ @param str The string to strip
+ */
+ void strip(std::string* str)
+ {
+ size_t pos;
+ while ((pos = (*str).find(" ")) < (*str).length())
+ (*str).erase(pos, 1);
+ while ((pos = (*str).find("\t")) < (*str).length())
+ (*str).erase(pos, 1);
+ while ((pos = (*str).find("\n")) < (*str).length())
+ (*str).erase(pos, 1);
+ }
+
+ /**
+ @brief Returns a copy of a string without whitespaces.
+ @param str The string to strip
+ @return The stripped line
+ */
+ std::string getStripped(const std::string& str)
+ {
+ std::string output = std::string(str);
+ strip(&output);
+ return output;
+ }
+
+ /**
+ @brief Returns a copy of a string without trailing whitespaces.
+ @param str The string
+ @return The modified copy
+ */
+ std::string removeTrailingWhitespaces(const std::string& str)
+ {
+ size_t pos1 = 0;
+ int pos2 = (int)(str.size() - 1);
+ for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
+ for (; pos2 > 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
+ return str.substr(pos1, pos2 - pos1 + 1);
+ }
+
+ /**
+ @brief Returns the position of the next quote in the string, starting with start.
+ @param str The string
+ @param start The startposition
+ @return The position of the next quote (std::string::npos if there is no next quote)
+ */
+ size_t getNextQuote(const std::string& str, size_t start)
+ {
+ size_t quote = start - 1;
+
+ while ((quote = str.find('\"', quote + 1)) != std::string::npos)
+ {
+ size_t backslash = quote;
+ size_t numbackslashes = 0;
+ for (; backslash > 0; backslash--, numbackslashes++)
+ if (str[backslash - 1] != '\\')
+ break;
+
+ if (numbackslashes % 2 == 0)
+ break;
+ }
+
+ return quote;
+ }
+
+ /**
+ @brief Returns true if pos is between two quotes.
+ @param str The string
+ @param pos The position to check
+ @return True if pos is between two quotes
+ */
+ bool isBetweenQuotes(const std::string& str, size_t pos)
+ {
+ if (pos == std::string::npos)
+ return false;
+
+ size_t quotecount = 0;
+ size_t quote = (size_t)-1;
+ while ((quote = getNextQuote(str, quote + 1)) < pos)
+ {
+ if (quote == pos)
+ return false;
+ quotecount++;
+ }
+
+ if (quote == std::string::npos)
+ return false;
+
+ return ((quotecount % 2) == 1);
+ }
+
+ /**
+ @brief Returns true if the string contains something like '..."between quotes"...'.
+ @param The string
+ @return True if there is something between quotes
+ */
+ bool hasStringBetweenQuotes(const std::string& str)
+ {
+ size_t pos1 = getNextQuote(str, 0);
+ size_t pos2 = getNextQuote(str, pos1 + 1);
+ return (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1);
+ }
+
+ /**
+ @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
+ @param The string
+ @param The string between the quotes
+ */
+ std::string getStringBetweenQuotes(const std::string& str)
+ {
+ size_t pos1 = getNextQuote(str, 0);
+ size_t pos2 = getNextQuote(str, pos1 + 1);
+ if (pos1 != std::string::npos && pos2 != std::string::npos)
+ return str.substr(pos1, pos2 - pos1 + 1);
+ else
+ return "";
+ }
+
+ /**
+ @brief Removes enclosing quotes if available (including whitespaces at the outside of the quotes).
+ @brief str The string to strip
+ @return The string with removed quotes
+ */
+ std::string stripEnclosingQuotes(const std::string& str)
+ {
+ size_t start = std::string::npos;
+ size_t end = 0;
+
+ for (size_t pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++)
+ {
+ if (str[pos] == '"')
+ {
+ start = pos;
+ break;
+ }
+
+ if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+ return str;
+ }
+
+ for (size_t pos = str.size() - 1; pos < std::string::npos; pos--)
+ {
+ if (str[pos] == '"')
+ {
+ end = pos;
+ break;
+ }
+
+ if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+ return str;
+ }
+
+ if ((start != std::string::npos) && (end != 0))
+ return str.substr(start + 1, end - start - 1);
+ else
+ return str;
+ }
+
+ /**
+ @brief Removes enclosing {braces} (braces must be exactly on the beginning and the end of the string).
+ @param str The string to strip
+ @return The striped string
+ */
+ std::string stripEnclosingBraces(const std::string& str)
+ {
+ std::string output = str;
+
+ while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}')
+ output = output.substr(1, output.size() - 2);
+
+ return output;
+ }
+
+ /**
+ @brief Determines if a string is a comment (starts with a comment-symbol).
+ @param str The string to check
+ @return True = it's a comment
+
+ A comment is defined by a leading '#', '%', ';' or '//'.
+ */
+ bool isComment(const std::string& str)
+ {
+ // Strip the line, whitespaces are disturbing
+ std::string teststring = getStripped(str);
+
+ // There are four possible comment-symbols:
+ // 1) #comment in script-language style
+ // 2) %comment in matlab style
+ // 3) ;comment in unreal tournament config-file style
+ // 4) //comment in code style
+ if (teststring.size() >= 2)
+ {
+ if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[1] == '/'))
+ return true;
+ }
+ else if (teststring.size() == 1)
+ {
+ if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';')
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ @brief Determines if a string is empty (contains only whitespaces).
+ @param str The string to check
+ @return True = it's empty
+ */
+ bool isEmpty(const std::string& str)
+ {
+ std::string temp = getStripped(str);
+ return ((temp == "") || (temp.size() == 0));
+ }
+
+ /**
+ @brief Determines if a string contains only numbers and maximal one '.'.
+ @param str The string to check
+ @return True = it's a number
+ */
+ bool isNumeric(const std::string& str)
+ {
+ bool foundPoint = false;
+
+ for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
+ {
+ if (((*it) < '0' || (*it) > '9'))
+ {
+ if ((*it) != '.' && !foundPoint)
+ foundPoint = true;
+ else
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
+ @param str The string to manipulate
+ @return The string with added slashes
+ */
+ std::string addSlashes(const std::string& str)
+ {
+ std::string output = str;
+
+ for (size_t pos = 0; (pos = output.find('\\', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\\"); }
+ for (size_t pos = 0; (pos = output.find('\n', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\n"); }
+ for (size_t pos = 0; (pos = output.find('\t', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\t"); }
+ for (size_t pos = 0; (pos = output.find('\v', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\v"); }
+ for (size_t pos = 0; (pos = output.find('\b', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\b"); }
+ for (size_t pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\r"); }
+ for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
+ for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
+ for (size_t pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
+ for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
+
+ return output;
+ }
+
+ /**
+ @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
+ @param str The string to manipulate
+ @return The string with removed slashes
+ */
+ std::string removeSlashes(const std::string& str)
+ {
+ if (str.size() <= 1)
+ return str;
+
+ std::string output = "";
+ for (size_t pos = 0; pos < str.size() - 1; )
+ {
+ if (str[pos] == '\\')
+ {
+ if (str[pos + 1] == '\\') { output += '\\'; pos += 2; continue; }
+ else if (str[pos + 1] == 'n') { output += '\n'; pos += 2; continue; }
+ else if (str[pos + 1] == 't') { output += '\t'; pos += 2; continue; }
+ else if (str[pos + 1] == 'v') { output += '\v'; pos += 2; continue; }
+ else if (str[pos + 1] == 'b') { output += '\b'; pos += 2; continue; }
+ else if (str[pos + 1] == 'r') { output += '\r'; pos += 2; continue; }
+ else if (str[pos + 1] == 'f') { output += '\f'; pos += 2; continue; }
+ else if (str[pos + 1] == 'a') { output += '\a'; pos += 2; continue; }
+ else if (str[pos + 1] == '"') { output += '"'; pos += 2; continue; }
+ else if (str[pos + 1] == '0') { output += '\0'; pos += 2; continue; }
+ }
+ output += str[pos];
+ pos++;
+ if (pos == str.size() - 1)
+ output += str[pos];
+ }
+
+ return output;
+ }
+
+ /**
+ @brief Replaces each char between A and Z with its lowercase equivalent.
+ @param str The string to convert
+ */
+ void lowercase(std::string* str)
+ {
+ for (size_t i = 0; i < str->size(); ++i)
+ {
+ (*str)[i] = (char)tolower((*str)[i]);
+ }
+ }
+
+ /**
+ @brief Returns a copy of the given string without uppercase chars.
+ @param str The string
+ @return The copy
+ */
+ std::string getLowercase(const std::string& str)
+ {
+ std::string output = std::string(str);
+ lowercase(&output);
+ return output;
+ }
+
+ /**
+ @brief Replaces each char between a and z with its uppercase equivalent.
+ @param str The string to convert
+ */
+ void uppercase(std::string* str)
+ {
+ for (size_t i = 0; i < str->size(); ++i)
+ {
+ (*str)[i] = (char)toupper((*str)[i]);
+ }
+ }
+
+ /**
+ @brief Returns a copy of the given string without lowercase chars.
+ @param str The string
+ @return The copy
+ */
+ std::string getUppercase(const std::string& str)
+ {
+ std::string output = std::string(str);
+ uppercase(&output);
+ return output;
+ }
+
+ /**
+ @brief Compares two strings ignoring different casing.
+ @param s1 First string
+ @param s2 Second string
+ */
+ int nocaseCmp(const std::string& s1, const std::string& s2)
+ {
+ std::string::const_iterator it1=s1.begin();
+ std::string::const_iterator it2=s2.begin();
+
+ //stop when either string's end has been reached
+ while ( (it1!=s1.end()) && (it2!=s2.end()) )
+ {
+ if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+ // return -1 to indicate smaller than, 1 otherwise
+ return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
+ //proceed to the next character in each string
+ ++it1;
+ ++it2;
+ }
+ size_t size1=s1.size(), size2=s2.size();// cache lengths
+ //return -1,0 or 1 according to strings' lengths
+ if (size1==size2)
+ return 0;
+ return (size1<size2) ? -1 : 1;
+ }
+
+
+ /**
+ @brief Compares the first 'len' chars of two strings ignoring different casing.
+ @param s1 First string
+ @param s2 Second string
+ @param len Maximal number of chars to compare
+ */
+ int nocaseCmp(const std::string& s1, const std::string& s2, size_t len)
+ {
+ if (len == 0)
+ return 0;
+ std::string::const_iterator it1=s1.begin();
+ std::string::const_iterator it2=s2.begin();
+
+ //stop when either string's end has been reached
+ while ( (it1!=s1.end()) && (it2!=s2.end()) && len-- > 0)
+ {
+ if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+ // return -1 to indicate smaller than, 1 otherwise
+ return (::toupper(*it1) < ::toupper(*it2)) ? -1 : 1;
+ //proceed to the next character in each string
+ ++it1;
+ ++it2;
+ }
+ return 0;
+ }
+
+ /**
+ @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
+ @param str The string
+ @return True if the string contains a comment
+ */
+ bool hasComment(const std::string& str)
+ {
+ return (getCommentPosition(str) != std::string::npos);
+ }
+
+ /**
+ @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
+ @param str The string
+ @return The comment
+ */
+ std::string getComment(const std::string& str)
+ {
+ return str.substr(getCommentPosition(str));
+ }
+
+ /**
+ @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
+ @param str The string
+ @return The position
+ */
+ size_t getCommentPosition(const std::string& str)
+ {
+ return getNextCommentPosition(str, 0);
+ }
+
+ /**
+ @brief Returns the position of the next comment-symbol, starting with start.
+ @param str The string
+ @param start The startposition
+ @return The position
+ */
+ size_t getNextCommentPosition(const std::string& str, size_t start)
+ {
+ for (size_t i = start; i < str.size(); i++)
+ if (isComment(str.substr(i)))
+ return i;
+
+ return std::string::npos;
+ }
+}
Copied: trunk/src/util/StringUtils.h (from rev 3251, branches/core4/src/util/StringUtils.h)
===================================================================
--- trunk/src/util/StringUtils.h (rev 0)
+++ trunk/src/util/StringUtils.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -0,0 +1,81 @@
+/*
+ * 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 Declaration of several string manipulation functions, used in many parts of the game.
+*/
+
+#ifndef _StringUtils_H__
+#define _StringUtils_H__
+
+#include "UtilPrereqs.h"
+#include <string>
+
+namespace orxonox
+{
+ extern _UtilExport std::string BLANKSTRING;
+ _UtilExport std::string getUniqueNumberString();
+
+ _UtilExport void strip(std::string* str);
+ _UtilExport std::string getStripped(const std::string& str);
+
+ _UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+
+ _UtilExport size_t getNextQuote(const std::string& str, size_t start);
+ _UtilExport bool isBetweenQuotes(const std::string& str, size_t pos);
+
+ _UtilExport bool hasStringBetweenQuotes(const std::string& str);
+ _UtilExport std::string getStringBetweenQuotes(const std::string& str);
+
+ _UtilExport std::string stripEnclosingQuotes(const std::string& str);
+ _UtilExport std::string stripEnclosingBraces(const std::string& str);
+
+ _UtilExport bool isEmpty(const std::string& str);
+ _UtilExport bool isComment(const std::string& str);
+ _UtilExport bool isNumeric(const std::string& str);
+
+ _UtilExport std::string addSlashes(const std::string& str);
+ _UtilExport std::string removeSlashes(const std::string& str);
+
+ _UtilExport void lowercase(std::string* str);
+ _UtilExport std::string getLowercase(const std::string& str);
+
+ _UtilExport void uppercase(std::string* str);
+ _UtilExport std::string getUppercase(const std::string& str);
+
+ _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2);
+ _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2, size_t len);
+
+ _UtilExport bool hasComment(const std::string& str);
+ _UtilExport std::string getComment(const std::string& str);
+ _UtilExport size_t getCommentPosition(const std::string& str);
+ _UtilExport size_t getNextCommentPosition(const std::string& str, size_t start = 0);
+}
+
+#endif /* _StringUtils_H__ */
Modified: trunk/src/util/UtilPrereqs.h
===================================================================
--- trunk/src/util/UtilPrereqs.h 2009-07-12 21:08:50 UTC (rev 3279)
+++ trunk/src/util/UtilPrereqs.h 2009-07-12 21:58:01 UTC (rev 3280)
@@ -59,6 +59,21 @@
//-----------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+ class Exception;
+ class ExprParser;
+ class IntVector2;
+ class IntVector3;
+ class MultiType;
+ class OutputBuffer;
+ class OutputBufferListener;
+ class OutputHandler;
+ class SignalHandler;
+ class SubString;
+}
+
namespace Ogre
{
class Radian;
@@ -71,7 +86,6 @@
class Quaternion;
class ColourValue;
}
-
namespace orxonox
{
using Ogre::Radian;
@@ -83,17 +97,12 @@
using Ogre::Matrix4;
using Ogre::Quaternion;
using Ogre::ColourValue;
+}
- class Exception;
- class ExprParser;
- class IntVector2;
- class IntVector3;
- class MultiType;
- class OutputBuffer;
- class OutputBufferListener;
- class OutputHandler;
- class SignalHandler;
- class SubString;
+namespace Loki
+{
+ class ScopeGuardImplBase;
+ typedef const ScopeGuardImplBase& ScopeGuard;
}
#endif /* _UtilPrereqs_H__ */
More information about the Orxonox-commit
mailing list