Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3280


Ignore:
Timestamp:
Jul 12, 2009, 11:58:01 PM (15 years ago)
Author:
rgrieder
Message:

Merged most of the core4 revisions back to the trunk except for:

  • orxonox_cast
  • all the radical changes in the input library
Location:
code/trunk
Files:
2 deleted
180 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/cmake/BuildConfigMSVC.cmake

    r3196 r3280  
    3535
    3636# Currently VLD has a problem with MSVC9 although it actually is supported
    37 IF(MSVC8)
     37IF(MSVC80)
    3838  OPTION(VISUAL_LEAK_DETECTOR_ENABLE "Memory leak detector" off)
    3939ENDIF()
  • code/trunk/src/core/ArgumentCompletionFunctions.cc

    r3196 r3280  
    3434
    3535#include "util/Convert.h"
    36 #include "util/String.h"
     36#include "util/StringUtils.h"
    3737#include "Identifier.h"
    3838#include "ConfigValueContainer.h"
     
    143143
    144144            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
    145                 threads.push_back(ArgumentCompletionListElement(getConvertedValue<unsigned int, std::string>(*it)));
     145                threads.push_back(ArgumentCompletionListElement(multi_cast<std::string>(*it)));
    146146
    147147            return threads;
  • code/trunk/src/core/BaseObject.cc

    r3196 r3280  
    3636#include <tinyxml/tinyxml.h>
    3737
    38 #include "util/String.h"
     38#include "util/StringUtils.h"
    3939#include "CoreIncludes.h"
    4040#include "Event.h"
  • code/trunk/src/core/CMakeLists.txt

    r3196 r3280  
    6868  TOLUA_FILES
    6969    CommandExecutor.h
    70     Game.h
    7170    LuaBind.h
    7271  DEFINE_SYMBOL
  • code/trunk/src/core/CommandEvaluation.cc

    r3196 r3280  
    3030
    3131#include "util/Debug.h"
    32 #include "util/String.h"
     32#include "util/StringUtils.h"
    3333#include "ConsoleCommand.h"
    3434#include "Identifier.h"
     
    3939    {
    4040        this->initialize("");
    41         this->state_ = CS_Uninitialized;
     41        this->state_ = CommandState::Uninitialized;
    4242    }
    4343
     
    6464
    6565        this->errorMessage_ = "";
    66         this->state_ = CS_Empty;
     66        this->state_ = CommandState::Empty;
    6767    }
    6868
     
    104104            switch (this->state_)
    105105            {
    106                 case CS_Uninitialized:
    107                     break;
    108                 case CS_Empty:
    109                     break;
    110                 case CS_ShortcutOrIdentifier:
     106                case CommandState::Uninitialized:
     107                    break;
     108                case CommandState::Empty:
     109                    break;
     110                case CommandState::ShortcutOrIdentifier:
    111111                    if (this->function_)
    112112                    {
     
    119119                        return (this->command_ = this->functionclass_->getName() + " ");
    120120                    break;
    121                 case CS_Function:
     121                case CommandState::Function:
    122122                    if (this->function_)
    123123                    {
     
    128128                    }
    129129                    break;
    130                 case CS_ParamPreparation:
    131                 case CS_Params:
     130                case CommandState::ParamPreparation:
     131                case CommandState::Params:
    132132                {
    133133                    if (this->argument_ == "" && this->possibleArgument_ == "")
     
    149149                    break;
    150150                }
    151                 case CS_Finished:
    152                     break;
    153                 case CS_Error:
     151                case CommandState::Finished:
     152                    break;
     153                case CommandState::Error:
    154154                    break;
    155155            }
     
    163163        switch (this->state_)
    164164        {
    165             case CS_Uninitialized:
    166                 break;
    167             case CS_Empty:
    168             case CS_ShortcutOrIdentifier:
     165            case CommandState::Uninitialized:
     166                break;
     167            case CommandState::Empty:
     168            case CommandState::ShortcutOrIdentifier:
    169169                if (this->listOfPossibleFunctions_.size() == 0)
    170170                    return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
     
    174174                    return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
    175175                break;
    176             case CS_Function:
     176            case CommandState::Function:
    177177                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
    178178                break;
    179             case CS_ParamPreparation:
    180             case CS_Params:
     179            case CommandState::ParamPreparation:
     180            case CommandState::Params:
    181181                if (this->listOfPossibleArguments_.size() > 0)
    182182                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
    183183                else
    184184                    return CommandEvaluation::dump(this->function_);
    185             case CS_Finished:
     185            case CommandState::Finished:
    186186                if (this->function_)
    187187                    return CommandEvaluation::dump(this->function_);
    188188                break;
    189             case CS_Error:
     189            case CommandState::Error:
    190190                return this->errorMessage_;
    191191                break;
     
    200200
    201201        for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
    202             this->param_[i] = MT_null;
     202            this->param_[i] = MT_Type::Null;
    203203
    204204        if (!this->isValid())
     
    230230            return this->param_[index];
    231231
    232         return MT_null;
     232        return MT_Type::Null;
    233233    }
    234234
     
    238238            return this->function_->hasReturnvalue();
    239239
    240         return MT_null;
     240        return MT_Type::Null;
    241241    }
    242242
  • code/trunk/src/core/CommandEvaluation.h

    r1747 r3280  
    4141namespace orxonox
    4242{
    43     enum CommandState
     43    namespace CommandState
    4444    {
    45         CS_Uninitialized,
    46         CS_Empty,
    47         CS_ShortcutOrIdentifier,
    48         CS_Function,
    49         CS_ParamPreparation,
    50         CS_Params,
    51         CS_Finished,
    52         CS_Error
    53     };
     45        enum Value
     46        {
     47            Uninitialized,
     48            Empty,
     49            ShortcutOrIdentifier,
     50            Function,
     51            ParamPreparation,
     52            Params,
     53            Finished,
     54            Error
     55        };
     56    }
    5457
    5558    class _CoreExport CommandEvaluation
     
    112115
    113116            std::string errorMessage_;
    114             CommandState state_;
     117            CommandState::Value state_;
    115118
    116119            bool bEvaluatedParams_;
  • code/trunk/src/core/CommandExecutor.cc

    r3196 r3280  
    3030
    3131#include "util/Debug.h"
    32 #include "util/String.h"
     32#include "util/StringUtils.h"
    3333#include "ConsoleCommand.h"
    3434#include "Identifier.h"
     
    141141    void CommandExecutor::parseIfNeeded(const std::string& command)
    142142    {
    143         if (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)
     143        if (CommandExecutor::getEvaluation().state_ == CommandState::Uninitialized)
    144144        {
    145145            CommandExecutor::parse(command);
     
    169169        switch (CommandExecutor::getEvaluation().state_)
    170170        {
    171             case CS_Uninitialized:
     171            case CommandState::Uninitialized:
    172172            {
    173173                // Impossible
    174174                break;
    175175            }
    176             case CS_Empty:
     176            case CommandState::Empty:
    177177            {
    178178                if (CommandExecutor::argumentsGiven() == 0)
     
    184184                else
    185185                {
    186                     CommandExecutor::getEvaluation().state_ = CS_ShortcutOrIdentifier;
     186                    CommandExecutor::getEvaluation().state_ = CommandState::ShortcutOrIdentifier;
    187187                    // Move on to next case
    188188                }
    189189            }
    190             case CS_ShortcutOrIdentifier:
     190            case CommandState::ShortcutOrIdentifier:
    191191            {
    192192                if (CommandExecutor::argumentsGiven() > 1)
     
    199199                    {
    200200                        // It's a shortcut
    201                         CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     201                        CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    202202                        CommandExecutor::getEvaluation().functionclass_ = 0;
    203203                        // Move on to next case
     
    206206                    {
    207207                        // It's a functionname
    208                         CommandExecutor::getEvaluation().state_ = CS_Function;
     208                        CommandExecutor::getEvaluation().state_ = CommandState::Function;
    209209                        CommandExecutor::getEvaluation().function_ = 0;
    210210                        // Move on to next case
     
    213213                    {
    214214                        // The first argument is bad
    215                         CommandExecutor::getEvaluation().state_ = CS_Error;
     215                        CommandExecutor::getEvaluation().state_ = CommandState::Error;
    216216                        AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
    217217                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
     
    238238                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
    239239                        }
    240                         CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     240                        CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    241241                        CommandExecutor::getEvaluation().functionclass_ = 0;
    242242                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
     
    258258                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
    259259                        }
    260                         CommandExecutor::getEvaluation().state_ = CS_Function;
     260                        CommandExecutor::getEvaluation().state_ = CommandState::Function;
    261261                        CommandExecutor::getEvaluation().function_ = 0;
    262262                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
     
    266266                    {
    267267                        // No possibilities
    268                         CommandExecutor::getEvaluation().state_ = CS_Error;
     268                        CommandExecutor::getEvaluation().state_ = CommandState::Error;
    269269                        AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
    270270                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
     
    285285                }
    286286            }
    287             case CS_Function:
     287            case CommandState::Function:
    288288            {
    289289                if (CommandExecutor::getEvaluation().functionclass_)
     
    298298                        {
    299299                            // It's a function
    300                             CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     300                            CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    301301                            // Move on to next case
    302302                        }
     
    304304                        {
    305305                            // The second argument is bad
    306                             CommandExecutor::getEvaluation().state_ = CS_Error;
     306                            CommandExecutor::getEvaluation().state_ = CommandState::Error;
    307307                            AddLanguageEntry("commandexecutorunknownsecondargument", "is not a function of");
    308308                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknownsecondargument") + " " + CommandExecutor::getEvaluation().functionclass_->getName() + ".";
     
    326326                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
    327327                            }
    328                             CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     328                            CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    329329                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
    330330                            if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
     
    338338                        {
    339339                            // No possibilities
    340                             CommandExecutor::getEvaluation().state_ = CS_Error;
     340                            CommandExecutor::getEvaluation().state_ = CommandState::Error;
    341341                            AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
    342342                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
     
    355355                else
    356356                {
    357                     // There is no classname - move on to CS_ParamPreparation
    358                 }
    359             }
    360             case CS_ParamPreparation:
     357                    // There is no classname - move on to CommandState::ParamPreparation
     358                }
     359            }
     360            case CommandState::ParamPreparation:
    361361            {
    362362                if (CommandExecutor::getEvaluation().function_->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
    363363                {
    364                     CommandExecutor::getEvaluation().state_ = CS_Finished;
     364                    CommandExecutor::getEvaluation().state_ = CommandState::Finished;
    365365                    return;
    366366                }
     
    372372
    373373                    CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
    374                     CommandExecutor::getEvaluation().state_ = CS_Params;
     374                    CommandExecutor::getEvaluation().state_ = CommandState::Params;
    375375
    376376                    if (CommandExecutor::getEvaluation().bCommandChanged_)
     
    381381                }
    382382            }
    383             case CS_Params:
     383            case CommandState::Params:
    384384            {
    385385                if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
     
    388388                    CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
    389389                    CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
    390                     CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     390                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    391391                    return;
    392392                }
     
    394394                {
    395395                    // The user tries something new - we let him do
    396                     CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     396                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    397397                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getLastArgument();
    398398                    return;
     
    409409                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleArguments_);
    410410                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
    411                     CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
     411                    CommandExecutor::getEvaluation().state_ = CommandState::ParamPreparation;
    412412                    return;
    413413                }
    414414            }
    415             case CS_Finished:
     415            case CommandState::Finished:
    416416            {
    417417                // Nothing more to do
    418418                break;
    419419            }
    420             case CS_Error:
     420            case CommandState::Error:
    421421            {
    422422                // Bad, very bad
  • code/trunk/src/core/CommandLine.cc

    r3196 r3280  
    2929#include "CommandLine.h"
    3030
     31#include <algorithm>
     32#include <sstream>
    3133#include <boost/filesystem.hpp>
    3234
     
    3436#include "util/Debug.h"
    3537#include "util/Exception.h"
    36 #include "util/String.h"
     38#include "util/StringUtils.h"
    3739#include "util/SubString.h"
    3840#include "Core.h"
     
    4042namespace orxonox
    4143{
    42     SetCommandLineArgument(optionsFile, "start.ini").shortcut("o");
     44    SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");
    4345
    4446    /**
     
    4951        so that you can have simple command line switches.
    5052    */
    51     void CommandLineArgument::parse(const std::string& value)
    52     {
    53         if (value_.getType() == MT_bool)
     53    void CommandLineArgument::parse(const std::string& value, bool bParsingFile)
     54    {
     55        if (bParsingFile && this->bCommandLineOnly_)
     56            ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files.");
     57        if (value_.getType() == MT_Type::Bool)
    5458        {
    5559            // simulate command line switch
     
    6670            }
    6771            else
    68             {
    6972                ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
    70             }
    7173        }
    7274        else
     
    126128        Vector of space separated strings.
    127129    */
    128     void CommandLine::_parse(const std::vector<std::string>& arguments)
    129     {
    130         // why this? See bFirstTimeParse_ declaration.
    131         if (bFirstTimeParse_)
    132         {
    133             // first shove all the shortcuts in a map
    134             for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
    135                 it != cmdLineArgs_.end(); ++it)
    136             {
    137                 OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
    138                     "Cannot have two command line shortcut with the same name.");
    139                 if (it->second->getShortcut() != "")
    140                     cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
    141             }
    142             bFirstTimeParse_ = false;
    143         }
    144 
    145         std::string name;
    146         std::string shortcut;
    147         std::string value;
    148         for (unsigned int i = 0; i < arguments.size(); ++i)
    149         {
    150             if (arguments[i].size() != 0)
    151             {
    152                 // sure not ""
    153                 if (arguments[i][0] == '-')
     130    void CommandLine::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
     131    {
     132        try
     133        {
     134            // why this? See bFirstTimeParse_ declaration.
     135            if (bFirstTimeParse_)
     136            {
     137                // first shove all the shortcuts in a map
     138                for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
     139                    it != cmdLineArgs_.end(); ++it)
    154140                {
    155                     // start with "-"
    156                     if (arguments[i].size() == 1)
     141                    OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
     142                        "Cannot have two command line shortcut with the same name.");
     143                    if (it->second->getShortcut() != "")
     144                        cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
     145                }
     146                bFirstTimeParse_ = false;
     147            }
     148
     149            std::string name;
     150            std::string shortcut;
     151            std::string value;
     152            for (unsigned int i = 0; i < arguments.size(); ++i)
     153            {
     154                if (arguments[i].size() != 0)
     155                {
     156                    // sure not ""
     157                    if (arguments[i][0] == '-')
    157158                    {
    158                         // argument[i] is "-", probably a minus sign
    159                         value += "- ";
    160                     }
    161                     else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
    162                     {
    163                         // negative number as a value
    164                         value += arguments[i] + " ";
     159                        // start with "-"
     160                        if (arguments[i].size() == 1)
     161                        {
     162                            // argument[i] is "-", probably a minus sign
     163                            value += "- ";
     164                        }
     165                        else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
     166                        {
     167                            // negative number as a value
     168                            value += arguments[i] + " ";
     169                        }
     170                        else
     171                        {
     172                            // can be shortcut or full name argument
     173
     174                            // save old data first
     175                            value = removeTrailingWhitespaces(value);
     176                            if (name != "")
     177                            {
     178                                checkFullArgument(name, value, bParsingFile);
     179                                name = "";
     180                                assert(shortcut == "");
     181                            }
     182                            else if (shortcut != "")
     183                            {
     184                                checkShortcut(shortcut, value, bParsingFile);
     185                                shortcut = "";
     186                                assert(name == "");
     187                            }
     188
     189                            if (arguments[i][1] == '-')
     190                            {
     191                                // full name argument with "--name"
     192                                name = arguments[i].substr(2);
     193                            }
     194                            else
     195                            {
     196                                // shortcut with "-s"
     197                                shortcut = arguments[i].substr(1);
     198                            }
     199
     200                            // reset value string
     201                            value = "";
     202                        }
    165203                    }
    166204                    else
    167205                    {
    168                         // can be shortcut or full name argument
    169 
    170                         // save old data first
    171                         value = removeTrailingWhitespaces(value);
    172                         if (name != "")
     206                        // value string
     207
     208                        if (name == "" && shortcut == "")
    173209                        {
    174                             checkFullArgument(name, value);
    175                             name = "";
    176                             assert(shortcut == "");
     210                            ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
    177211                        }
    178                         else if (shortcut != "")
    179                         {
    180                             checkShortcut(shortcut, value);
    181                             shortcut = "";
    182                             assert(name == "");
    183                         }
    184 
    185                         if (arguments[i][1] == '-')
    186                         {
    187                             // full name argument with "--name"
    188                             name = arguments[i].substr(2);
    189                         }
    190                         else
    191                         {
    192                             // shortcut with "-s"
    193                             shortcut = arguments[i].substr(1);
    194                         }
    195 
    196                         // reset value string
    197                         value = "";
     212
     213                        // Concatenate strings as long as there's no new argument by "-" or "--"
     214                        value += arguments[i] + ' ';
    198215                    }
    199216                }
    200                 else
    201                 {
    202                     // value string
    203 
    204                     if (name == "" && shortcut == "")
    205                     {
    206                         ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
    207                     }
    208 
    209                     // Concatenate strings as long as there's no new argument by "-" or "--"
    210                     value += arguments[i] + ' ';
    211                 }
    212             }
    213         }
    214 
    215         // parse last argument
    216         value = removeTrailingWhitespaces(value);
    217         if (name != "")
    218         {
    219             checkFullArgument(name, value);
    220             assert(shortcut == "");
    221         }
    222         else if (shortcut != "")
    223         {
    224             checkShortcut(shortcut, value);
    225             assert(name == "");
     217            }
     218
     219            // parse last argument
     220            value = removeTrailingWhitespaces(value);
     221            if (name != "")
     222            {
     223                checkFullArgument(name, value, bParsingFile);
     224                assert(shortcut == "");
     225            }
     226            else if (shortcut != "")
     227            {
     228                checkShortcut(shortcut, value, bParsingFile);
     229                assert(name == "");
     230            }
     231        }
     232        catch (const ArgumentException& ex)
     233        {
     234            COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;
     235            COUT(0) << CommandLine::getUsageInformation() << std::endl;
     236            throw GeneralException("");
    226237        }
    227238    }
     
    235246        String containing the value
    236247    */
    237     void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
     248    void CommandLine::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)
    238249    {
    239250        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
     
    241252            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
    242253
    243         it->second->parse(value);
     254        it->second->parse(value, bParsingFile);
    244255    }
    245256
     
    252263        String containing the value
    253264    */
    254     void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
     265    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)
    255266    {
    256267        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
     
    258269            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
    259270
    260         it->second->parse(value);
     271        it->second->parse(value, bParsingFile);
    261272    }
    262273
    263274    std::string CommandLine::getUsageInformation()
    264275    {
    265         CommandLine* inst = &_getInstance();
    266         std::string infoStr;
    267         for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin();
    268             it != inst->cmdLineArgs_.end(); ++it)
    269         {
    270             infoStr += "[--" + it->second->getName() + " " + it->second->getInformation() + "] ";
    271         }
    272         return infoStr;
     276        CommandLine& inst = _getInstance();
     277        std::ostringstream infoStr;
     278
     279        // determine maximum name size
     280        size_t maxNameSize = 0;
     281        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
     282            it != inst.cmdLineArgs_.end(); ++it)
     283        {
     284            maxNameSize = std::max(it->second->getName().size(), maxNameSize);
     285        }
     286
     287        infoStr << "Usage: orxonox [options]" << std::endl;
     288        infoStr << "Available options:" << std::endl;
     289
     290        for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin();
     291            it != inst.cmdLineArgs_.end(); ++it)
     292        {
     293            if (it->second->getShortcut() != "")
     294                infoStr << " [-" << it->second->getShortcut() << "] ";
     295            else
     296                infoStr << "      ";
     297            infoStr << "--" << it->second->getName() << " ";
     298            if (it->second->getValue().getType() != MT_Type::Bool)
     299                infoStr << "ARG ";
     300            else
     301                infoStr << "    ";
     302            // fill with the necessary amount of blanks
     303            infoStr << std::string(maxNameSize - it->second->getName().size(), ' ');
     304            infoStr << ": " << it->second->getInformation();
     305            infoStr << std::endl;
     306        }
     307        return infoStr.str();
    273308    }
    274309
     
    295330    /**
    296331    @brief
    297         Parses both command line and start.ini for CommandLineArguments.
    298     */
    299     void CommandLine::_parseAll(int argc, char** argv)
    300     {
    301         // parse command line first
     332        Parses only the command line for CommandLineArguments.
     333    */
     334    void CommandLine::_parseCommandLine(int argc, char** argv)
     335    {
    302336        std::vector<std::string> args;
    303337        for (int i = 1; i < argc; ++i)
    304338            args.push_back(argv[i]);
    305         this->_parse(args);
    306 
     339        this->_parse(args, false);
     340    }
     341
     342    /**
     343    @brief
     344        Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
     345    */
     346    void CommandLine::_parseFile()
     347    {
    307348        std::string filename = CommandLine::getValue("optionsFile").getString();
    308349        boost::filesystem::path filepath(Core::getConfigPath() / filename);
     
    312353        std::ifstream file;
    313354        file.open(filepath.string().c_str());
    314         args.clear();
     355        std::vector<std::string> args;
    315356        if (file)
    316357        {
     
    332373        }
    333374
    334         try
    335         {
    336             _parse(args);
    337         }
    338         catch (orxonox::ArgumentException& ex)
    339         {
    340             COUT(1) << "An Exception occured while parsing " << filename << std::endl;
    341             throw(ex);
    342         }
     375        _parse(args, true);
    343376    }
    344377}
  • code/trunk/src/core/CommandLine.h

    r3196 r3280  
    3838#define SetCommandLineArgument(name, defaultValue) \
    3939    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    40     = orxonox::CommandLine::addArgument(#name, defaultValue)
     40    = orxonox::CommandLine::addArgument(#name, defaultValue, false)
     41#define SetCommandLineOnlyArgument(name, defaultValue) \
     42    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
     43    = orxonox::CommandLine::addArgument(#name, defaultValue, true)
    4144#define SetCommandLineSwitch(name) \
    4245    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    43     = orxonox::CommandLine::addArgument(#name, false)
     46    = orxonox::CommandLine::addArgument(#name, false, false)
     47#define SetCommandLineOnlySwitch(name) \
     48    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
     49    = orxonox::CommandLine::addArgument(#name, false, true)
    4450
    4551
     
    7480
    7581        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
    76         //! Evaluates to "" if none there is none.
     82        //! Evaluates to "" if there is none.
    7783        const std::string& getShortcut() const { return shortcut_; }
    7884        //! Sets the shortcut for the argument
     
    9399    private:
    94100        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
    95         CommandLineArgument(const std::string& name, const MultiType& defaultValue)
     101        CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
    96102            : bHasDefaultValue_(true)
    97103            , name_(name)
    98104            , value_(defaultValue)
    99105            , defaultValue_(defaultValue)
     106            , bCommandLineOnly_(bCommandLineOnly)
    100107        { }
    101108
     
    105112
    106113        //! Parses the value string of a command line argument.
    107         void parse(const std::string& value);
     114        void parse(const std::string& value, bool bParsingFile);
    108115
    109116        //! Tells whether the value has been changed by the command line.
     
    115122        std::string usageInformation_; //!< Tells about the usage of this parameter
    116123
    117         MultiType value_;            //!< The actual value
    118         MultiType defaultValue_;     //!< Default value. Should not be changed.
     124        MultiType   value_;            //!< The actual value
     125        MultiType   defaultValue_;     //!< Default value. Should not be changed.
     126        bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
    119127    };
    120128
     
    134142
    135143        //! Parse redirection to internal member method.
    136         static void parseAll(int argc, char** argv) { _getInstance()._parseAll(argc, argv); }
     144        static void parseCommandLine(int argc, char** argv) { _getInstance()._parseCommandLine(argc, argv); }
     145        static void parseFile() { _getInstance()._parseFile(); }
    137146
    138147        static std::string getUsageInformation();
     
    146155        { return getArgument(name)->getValue(); }
    147156        template <class T>
    148         static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
     157        static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
    149158
    150159        static bool existsArgument(const std::string& name)
     
    165174        static CommandLine& _getInstance();
    166175
    167         void _parseAll(int argc, char** argv);
    168         void _parse(const std::vector<std::string>& arguments);
    169         void checkFullArgument(const std::string& name, const std::string& value);
    170         void checkShortcut(const std::string& shortcut, const std::string& value);
     176        void _parseCommandLine(int argc, char** argv);
     177        void _parseFile();
     178        void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
     179        void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
     180        void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
    171181
    172182        /**
     
    199209    */
    200210    template <class T>
    201     CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue)
     211    CommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
    202212    {
    203213        OrxAssert(!_getInstance().existsArgument(name),
    204214            "Cannot add a command line argument with name '" + name + "' twice.");
    205 
    206         return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
     215        OrxAssert(MultiType(defaultValue).getType() != MT_Type::Bool || MultiType(defaultValue).getBool() != true,
     216               "Boolean command line arguments with positive default values are not supported." << std::endl
     217            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
     218
     219        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
    207220    }
    208221}
  • code/trunk/src/core/ConfigFileManager.cc

    r3198 r3280  
    3333#include "util/Convert.h"
    3434#include "util/Math.h"
    35 #include "util/String.h"
     35#include "util/StringUtils.h"
    3636#include "ConsoleCommand.h"
    3737#include "ConfigValueContainer.h"
     
    124124    {
    125125        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
    126             return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]" + "=" + this->value_);
    127         else
    128             return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]=" + this->value_ + " " + this->additionalComment_);
     126            return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]" + "=" + this->value_);
     127        else
     128            return (this->name_ + "[" + multi_cast<std::string>(this->index_) + "]=" + this->value_ + " " + this->additionalComment_);
    129129    }
    130130
  • code/trunk/src/core/ConfigValueContainer.cc

    r3196 r3280  
    7878        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
    7979        {
    80             ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
     80            ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
    8181            this->defvalueStringVector_.push_back(this->valueVector_[i]);
    8282        }
     
    109109            if (this->tset(input))
    110110            {
    111                 ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string));
     111                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_Type::String));
    112112                return true;
    113113            }
     
    128128            if (this->tset(index, input))
    129129            {
    130                 ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string));
     130                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_Type::String));
    131131                return true;
    132132            }
     
    228228                this->valueVector_.erase(this->valueVector_.begin() + index);
    229229                for (unsigned int i = index; i < this->valueVector_.size(); i++)
    230                     ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
     230                    ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_Type::String));
    231231                ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
    232232
     
    264264    {
    265265        if (!this->bIsVector_)
    266             this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string));
     266            this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_Type::String));
    267267        else
    268268        {
     
    273273                if (i < this->defvalueStringVector_.size())
    274274                {
    275                     this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string));
     275                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_Type::String));
    276276                }
    277277                else
    278278                {
    279                     this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string));
     279                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_Type::String));
    280280                }
    281281
  • code/trunk/src/core/ConfigValueIncludes.h

    r2171 r3280  
    5252    if (!container##varname) \
    5353    { \
    54         container##varname = new orxonox::ConfigValueContainer(ConfigFileType::Settings, identifier##varname, identifier##varname->getName(), #varname, defvalue, varname); \
     54        container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue, varname); \
    5555        identifier##varname->addConfigValueContainer(#varname, container##varname); \
    5656    } \
     
    7070    if (!container##varname) \
    7171    { \
    72         container##varname = new orxonox::ConfigValueContainer(ConfigFileType::Settings, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
     72        container##varname = new orxonox::ConfigValueContainer(type, identifier##varname, identifier##varname->getName(), #varname, defvalue); \
    7373        identifier##varname->addConfigValueContainer(#varname, container##varname); \
    7474    } \
  • code/trunk/src/core/ConsoleCommand.h

    r3196 r3280  
    7171    namespace AccessLevel
    7272    {
    73         enum Level
     73        enum Value
    7474        {
    7575            None,
     
    106106                { this->Executor::setDefaultValue(index, param); return (*this); }
    107107
    108             inline ConsoleCommand& accessLevel(AccessLevel::Level level)
     108            inline ConsoleCommand& accessLevel(AccessLevel::Value level)
    109109                { this->accessLevel_ = level; return (*this); }
    110             inline AccessLevel::Level getAccessLevel() const
     110            inline AccessLevel::Value getAccessLevel() const
    111111                { return this->accessLevel_; }
    112112
     
    130130            }
    131131
    132             inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
     132            inline ConsoleCommand& keybindMode(KeybindMode::Value mode)
    133133                { this->keybindMode_ = mode; return *this; }
    134             inline KeybindMode::Enum getKeybindMode() const
     134            inline KeybindMode::Value getKeybindMode() const
    135135                { return this->keybindMode_; }
    136136
     
    141141
    142142        private:
    143             AccessLevel::Level accessLevel_;
     143            AccessLevel::Value accessLevel_;
    144144            ArgumentCompleter* argumentCompleter_[5];
    145145            ArgumentCompletionList argumentList_;
    146146
    147             KeybindMode::Enum keybindMode_;
     147            KeybindMode::Value keybindMode_;
    148148            int inputConfiguredParam_;
    149149    };
  • code/trunk/src/core/Core.cc

    r3214 r3280  
    7777namespace orxonox
    7878{
    79     //! Path to the parent directory of the ones above if program was installed with relativ pahts
    80     static boost::filesystem::path rootPath_g;
    81     static boost::filesystem::path executablePath_g;            //!< Path to the executable
    82     static boost::filesystem::path mediaPath_g;                 //!< Path to the media file folder
    83     static boost::filesystem::path configPath_g;                //!< Path to the config file folder
    84     static boost::filesystem::path logPath_g;                   //!< Path to the log file folder
    85 
    8679    //! Static pointer to the singleton
    8780    Core* Core::singletonRef_s  = 0;
    8881
    89     SetCommandLineArgument(mediaPath, "").information("PATH");
    90     SetCommandLineArgument(writingPathSuffix, "").information("DIR");
    91     SetCommandLineArgument(settingsFile, "orxonox.ini");
    92     SetCommandLineArgument(limitToCPU, 0).information("0: off | #cpu");
    93 
    94     Core::Core()
    95     {
    96         RegisterRootObject(Core);
    97 
    98         assert(Core::singletonRef_s == 0);
     82    SetCommandLineArgument(mediaPath, "").information("Path to the media/data files");
     83    SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
     84    SetCommandLineArgument(settingsFile, "orxonox.ini").information("THE configuration file");
     85#ifdef ORXONOX_PLATFORM_WINDOWS
     86    SetCommandLineArgument(limitToCPU, 0).information("Limits the program to one cpu/core (1, 2, 3, etc.). 0 turns it off (default)");
     87#endif
     88
     89    /**
     90    @brief
     91        Helper class for the Core singleton: we cannot derive
     92        Core from OrxonoxClass because we need to handle the Identifier
     93        destruction in the Core destructor.
     94    */
     95    class CoreConfiguration : public OrxonoxClass
     96    {
     97    public:
     98        CoreConfiguration()
     99        {
     100        }
     101
     102        void initialise()
     103        {
     104            RegisterRootObject(CoreConfiguration);
     105            this->setConfigValues();
     106
     107            // Possible media path override by the command line
     108            if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
     109                tsetMediaPath(CommandLine::getValue("mediaPath"));
     110        }
     111
     112        /**
     113            @brief Function to collect the SetConfigValue-macro calls.
     114        */
     115        void setConfigValues()
     116        {
     117#ifdef NDEBUG
     118            const unsigned int defaultLevelConsole = 1;
     119            const unsigned int defaultLevelLogfile = 3;
     120            const unsigned int defaultLevelShell   = 1;
     121#else
     122            const unsigned int defaultLevelConsole = 3;
     123            const unsigned int defaultLevelLogfile = 4;
     124            const unsigned int defaultLevelShell   = 3;
     125#endif
     126            SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
     127                .description("The maximal level of debug output shown in the console")
     128                .callback(this, &CoreConfiguration::debugLevelChanged);
     129            SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
     130                .description("The maximal level of debug output shown in the logfile")
     131                .callback(this, &CoreConfiguration::debugLevelChanged);
     132            SetConfigValue(softDebugLevelShell_, defaultLevelShell)
     133                .description("The maximal level of debug output shown in the ingame shell")
     134                .callback(this, &CoreConfiguration::debugLevelChanged);
     135
     136            SetConfigValue(language_, Language::getLanguage().defaultLanguage_)
     137                .description("The language of the ingame text")
     138                .callback(this, &CoreConfiguration::languageChanged);
     139            SetConfigValue(bInitializeRandomNumberGenerator_, true)
     140                .description("If true, all random actions are different each time you start the game")
     141                .callback(this, &CoreConfiguration::initializeRandomNumberGenerator);
     142
     143            SetConfigValue(mediaPathString_, mediaPath_.string())
     144                .description("Relative path to the game data.")
     145                .callback(this, &CoreConfiguration::mediaPathChanged);
     146        }
     147
     148        /**
     149            @brief Callback function if the debug level has changed.
     150        */
     151        void debugLevelChanged()
     152        {
     153            // softDebugLevel_ is the maximum of the 3 variables
     154            this->softDebugLevel_ = this->softDebugLevelConsole_;
     155            if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
     156                this->softDebugLevel_ = this->softDebugLevelLogfile_;
     157            if (this->softDebugLevelShell_ > this->softDebugLevel_)
     158                this->softDebugLevel_ = this->softDebugLevelShell_;
     159
     160            OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
     161            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
     162            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
     163            OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
     164        }
     165
     166        /**
     167            @brief Callback function if the language has changed.
     168        */
     169        void languageChanged()
     170        {
     171            // Read the translation file after the language was configured
     172            Language::getLanguage().readTranslatedLanguageFile();
     173        }
     174
     175        /**
     176        @brief
     177            Callback function if the media path has changed.
     178        */
     179        void mediaPathChanged()
     180        {
     181            mediaPath_ = boost::filesystem::path(this->mediaPathString_);
     182        }
     183
     184        /**
     185            @brief Sets the language in the config-file back to the default.
     186        */
     187        void resetLanguage()
     188        {
     189            ResetConfigValue(language_);
     190        }
     191
     192        /**
     193        @brief
     194            Temporary sets the media path
     195        @param path
     196            The new media path
     197        */
     198        void tsetMediaPath(const std::string& path)
     199        {
     200            ModifyConfigValue(mediaPathString_, tset, path);
     201        }
     202
     203        void initializeRandomNumberGenerator()
     204        {
     205            static bool bInitialized = false;
     206            if (!bInitialized && this->bInitializeRandomNumberGenerator_)
     207            {
     208                srand(static_cast<unsigned int>(time(0)));
     209                rand();
     210                bInitialized = true;
     211            }
     212        }
     213
     214        int softDebugLevel_;                            //!< The debug level
     215        int softDebugLevelConsole_;                     //!< The debug level for the console
     216        int softDebugLevelLogfile_;                     //!< The debug level for the logfile
     217        int softDebugLevelShell_;                       //!< The debug level for the ingame shell
     218        std::string language_;                          //!< The language
     219        bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
     220        std::string mediaPathString_;                   //!< Path to the data/media file folder as string
     221
     222        //! Path to the parent directory of the ones above if program was installed with relativ pahts
     223        boost::filesystem::path rootPath_;
     224        boost::filesystem::path executablePath_;        //!< Path to the executable
     225        boost::filesystem::path mediaPath_;             //!< Path to the media file folder
     226        boost::filesystem::path configPath_;            //!< Path to the config file folder
     227        boost::filesystem::path logPath_;               //!< Path to the log file folder
     228    };
     229
     230
     231    Core::Core(int argc, char** argv)
     232    {
     233        if (singletonRef_s != 0)
     234        {
     235            COUT(0) << "Error: The Core singleton cannot be recreated! Shutting down." << std::endl;
     236            abort();
     237        }
    99238        Core::singletonRef_s = this;
    100     }
    101 
    102     void Core::initialise(int argc, char** argv)
    103     {
    104         // Parse command line arguments fist
    105         try
    106         {
    107             CommandLine::parseAll(argc, argv);
    108         }
    109         catch (ArgumentException& ex)
    110         {
    111             COUT(1) << ex.what() << std::endl;
    112             COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
    113         }
    114 
     239
     240        // We need the variables very soon. But don't configure them yet!
     241        this->configuration_ = new CoreConfiguration();
     242
     243        // Parse command line arguments first
     244        CommandLine::parseCommandLine(argc, argv);
     245
     246        // Determine and set the location of the executable
     247        setExecutablePath();
     248
     249        // Determine whether we have an installed or a binary dir run
     250        // The latter occurs when simply running from the build directory
     251        checkDevBuild();
     252
     253        // Make sure the directories we write in exist or else make them
     254        createDirectories();
     255
     256        // create a signal handler (only active for linux)
     257        // This call is placed as soon as possible, but after the directories are set
     258        this->signalHandler_ = new SignalHandler();
     259        this->signalHandler_->doCatch(configuration_->executablePath_.string(), Core::getLogPathString() + "orxonox_crash.log");
     260
     261        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
     262        OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
     263
     264        // Parse additional options file now that we know its path
     265        CommandLine::parseFile();
     266
     267#ifdef ORXONOX_PLATFORM_WINDOWS
    115268        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
    116269        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
     
    118271        int limitToCPU = CommandLine::getValue("limitToCPU");
    119272        if (limitToCPU > 0)
    120             setThreadAffinity((unsigned int)limitToCPU);
    121 
    122         // Determine and set the location of the executable
    123         setExecutablePath();
    124 
    125         // Determine whether we have an installed or a binary dir run
    126         // The latter occurs when simply running from the build directory
    127         checkDevBuild();
    128 
    129         // Make sure the directories we write in exist or else make them
    130         createDirectories();
    131 
    132         // create a signal handler (only active for linux)
    133         // This call is placed as soon as possible, but after the directories are set
    134         this->signalHandler_ = new SignalHandler();
    135         this->signalHandler_->doCatch(executablePath_g.string(), Core::getLogPathString() + "orxonox_crash.log");
    136 
    137         // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% was used
    138         OutputHandler::getOutStream().setLogPath(Core::getLogPathString());
     273            setThreadAffinity(static_cast<unsigned int>(limitToCPU));
     274#endif
    139275
    140276        // Manage ini files and set the default settings file (usually orxonox.ini)
     
    143279            CommandLine::getValue("settingsFile").getString());
    144280
     281        // Required as well for the config values
    145282        this->languageInstance_ = new Language();
    146283
    147284        // Do this soon after the ConfigFileManager has been created to open up the
    148285        // possibility to configure everything below here
    149         this->setConfigValues();
    150 
    151         // Possible media path override by the command line
    152         if (!CommandLine::getArgument("mediaPath")->hasDefaultValue())
    153         {
    154             //std::string mediaPath = CommandLine::getValue("mediaPath");
    155             Core::tsetMediaPath(CommandLine::getValue("mediaPath"));
    156         }
     286        this->configuration_->initialise();
    157287
    158288        // Create the lua interface
     
    168298        // creates the class hierarchy for all classes with factories
    169299        Factory::createClassHierarchy();
    170        
    171         this->loaded_ = true;
    172300    }
    173301
     
    177305    Core::~Core()
    178306    {
    179         this->loaded_ = false;
    180 
    181307        delete this->shell_;
    182308        delete this->tclThreadManager_;
    183309        delete this->tclBind_;
    184310        delete this->luaBind_;
     311        delete this->configuration_;
    185312        delete this->languageInstance_;
    186313        delete this->configFileManager_;
     
    190317        // Also delete external console command that don't belong to an Identifier
    191318        CommandExecutor::destroyExternalCommands();
    192 
    193         assert(Core::singletonRef_s);
    194         Core::singletonRef_s = 0;
     319        // Clean up class hierarchy stuff (identifiers, XMLPort, configValues, consoleCommand)
     320        Identifier::destroyAllIdentifiers();
     321
    195322        delete this->signalHandler_;
    196     }
    197 
    198     /**
    199         @brief Function to collect the SetConfigValue-macro calls.
    200     */
    201     void Core::setConfigValues()
    202     {
    203 #ifdef NDEBUG
    204         const unsigned int defaultLevelConsole = 1;
    205         const unsigned int defaultLevelLogfile = 3;
    206         const unsigned int defaultLevelShell   = 1;
    207 #else
    208         const unsigned int defaultLevelConsole = 3;
    209         const unsigned int defaultLevelLogfile = 4;
    210         const unsigned int defaultLevelShell   = 3;
    211 #endif
    212         SetConfigValue(softDebugLevelConsole_, defaultLevelConsole)
    213             .description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
    214         SetConfigValue(softDebugLevelLogfile_, defaultLevelLogfile)
    215             .description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
    216         SetConfigValue(softDebugLevelShell_, defaultLevelShell)
    217             .description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
    218 
    219         SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
    220         SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator);
    221 
    222         SetConfigValue(mediaPathString_, mediaPath_g.string())
    223             .description("Relative path to the game data.").callback(this, &Core::mediaPathChanged);
    224     }
    225 
    226     /**
    227         @brief Callback function if the debug level has changed.
    228     */
    229     void Core::debugLevelChanged()
    230     {
    231         // softDebugLevel_ is the maximum of the 3 variables
    232         this->softDebugLevel_ = this->softDebugLevelConsole_;
    233         if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
    234             this->softDebugLevel_ = this->softDebugLevelLogfile_;
    235         if (this->softDebugLevelShell_ > this->softDebugLevel_)
    236             this->softDebugLevel_ = this->softDebugLevelShell_;
    237 
    238         OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
    239         OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
    240         OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
    241         OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
    242     }
    243 
    244     /**
    245         @brief Callback function if the language has changed.
    246     */
    247     void Core::languageChanged()
    248     {
    249         // Read the translation file after the language was configured
    250         Language::getLanguage().readTranslatedLanguageFile();
    251     }
    252 
    253     /**
    254     @brief
    255         Callback function if the media path has changed.
    256     */
    257     void Core::mediaPathChanged()
    258     {
    259         mediaPath_g = boost::filesystem::path(this->mediaPathString_);
    260     }
    261 
    262     /**
    263         @brief Returns the softDebugLevel for the given device (returns a default-value if the class ist right about to be created).
     323
     324        // Don't assign singletonRef_s with NULL! Recreation is not supported
     325    }
     326
     327    /**
     328        @brief Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).
    264329        @param device The device
    265330        @return The softDebugLevel
    266331    */
    267     int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
     332    /*static*/ int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
    268333    {
    269334        switch (device)
    270335        {
    271336        case OutputHandler::LD_All:
    272             return Core::getInstance().softDebugLevel_;
     337            return Core::getInstance().configuration_->softDebugLevel_;
    273338        case OutputHandler::LD_Console:
    274             return Core::getInstance().softDebugLevelConsole_;
     339            return Core::getInstance().configuration_->softDebugLevelConsole_;
    275340        case OutputHandler::LD_Logfile:
    276             return Core::getInstance().softDebugLevelLogfile_;
     341            return Core::getInstance().configuration_->softDebugLevelLogfile_;
    277342        case OutputHandler::LD_Shell:
    278             return Core::getInstance().softDebugLevelShell_;
     343            return Core::getInstance().configuration_->softDebugLevelShell_;
    279344        default:
    280345            assert(0);
     
    288353        @param level The level
    289354    */
    290     void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    291      {
     355    /*static*/ void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
     356    {
    292357        if (device == OutputHandler::LD_All)
    293             Core::getInstance().softDebugLevel_ = level;
     358            Core::getInstance().configuration_->softDebugLevel_ = level;
    294359        else if (device == OutputHandler::LD_Console)
    295             Core::getInstance().softDebugLevelConsole_ = level;
     360            Core::getInstance().configuration_->softDebugLevelConsole_ = level;
    296361        else if (device == OutputHandler::LD_Logfile)
    297             Core::getInstance().softDebugLevelLogfile_ = level;
     362            Core::getInstance().configuration_->softDebugLevelLogfile_ = level;
    298363        else if (device == OutputHandler::LD_Shell)
    299             Core::getInstance().softDebugLevelShell_ = level;
     364            Core::getInstance().configuration_->softDebugLevelShell_ = level;
    300365
    301366        OutputHandler::setSoftDebugLevel(device, level);
    302      }
     367    }
    303368
    304369    /**
    305370        @brief Returns the configured language.
    306371    */
    307     const std::string& Core::getLanguage()
    308     {
    309         return Core::getInstance().language_;
     372    /*static*/ const std::string& Core::getLanguage()
     373    {
     374        return Core::getInstance().configuration_->language_;
    310375    }
    311376
     
    313378        @brief Sets the language in the config-file back to the default.
    314379    */
    315     void Core::resetLanguage()
    316     {
    317         Core::getInstance().resetLanguageIntern();
    318     }
    319 
    320     /**
    321         @brief Sets the language in the config-file back to the default.
    322     */
    323     void Core::resetLanguageIntern()
    324     {
    325         ResetConfigValue(language_);
    326     }
    327 
    328     /**
    329     @brief
    330         Temporary sets the media path
    331     @param path
    332         The new media path
    333     */
    334     void Core::_tsetMediaPath(const std::string& path)
    335     {
    336         ModifyConfigValue(mediaPathString_, tset, path);
     380    /*static*/ void Core::resetLanguage()
     381    {
     382        Core::getInstance().configuration_->resetLanguage();
     383    }
     384
     385    /*static*/ void Core::tsetMediaPath(const std::string& path)
     386    {
     387        getInstance().configuration_->tsetMediaPath(path);
    337388    }
    338389
    339390    /*static*/ const boost::filesystem::path& Core::getMediaPath()
    340391    {
    341         return mediaPath_g;
     392        return getInstance().configuration_->mediaPath_;
    342393    }
    343394    /*static*/ std::string Core::getMediaPathString()
    344395    {
    345         return mediaPath_g.string() + '/';
     396        return getInstance().configuration_->mediaPath_.string() + '/';
    346397    }
    347398
    348399    /*static*/ const boost::filesystem::path& Core::getConfigPath()
    349400    {
    350         return configPath_g;
     401        return getInstance().configuration_->configPath_;
    351402    }
    352403    /*static*/ std::string Core::getConfigPathString()
    353404    {
    354         return configPath_g.string() + '/';
     405        return getInstance().configuration_->configPath_.string() + '/';
    355406    }
    356407
    357408    /*static*/ const boost::filesystem::path& Core::getLogPath()
    358409    {
    359         return logPath_g;
     410        return getInstance().configuration_->logPath_;
    360411    }
    361412    /*static*/ std::string Core::getLogPathString()
    362413    {
    363         return logPath_g.string() + '/';
    364     }
    365 
    366     void Core::initializeRandomNumberGenerator()
    367     {
    368         static bool bInitialized = false;
    369         if (!bInitialized && this->bInitializeRandomNumberGenerator_)
    370         {
    371             srand(static_cast<unsigned int>(time(0)));
    372             rand();
    373             bInitialized = true;
    374         }
    375     }
    376 
     414        return getInstance().configuration_->logPath_.string() + '/';
     415    }
    377416
    378417    /**
     
    388427    void Core::setThreadAffinity(int limitToCPU)
    389428    {
     429#ifdef ORXONOX_PLATFORM_WINDOWS
     430
    390431        if (limitToCPU <= 0)
    391432            return;
    392433
    393 #ifdef ORXONOX_PLATFORM_WINDOWS
    394434        unsigned int coreNr = limitToCPU - 1;
    395435        // Get the current process core mask
     
    465505#endif
    466506
    467         executablePath_g = boost::filesystem::path(buffer);
     507        configuration_->executablePath_ = boost::filesystem::path(buffer);
    468508#ifndef ORXONOX_PLATFORM_APPLE
    469         executablePath_g = executablePath_g.branch_path(); // remove executable name
     509        configuration_->executablePath_ = configuration_->executablePath_.branch_path(); // remove executable name
    470510#endif
    471511    }
     
    481521    void Core::checkDevBuild()
    482522    {
    483         if (boost::filesystem::exists(executablePath_g / "orxonox_dev_build.keep_me"))
     523        if (boost::filesystem::exists(configuration_->executablePath_ / "orxonox_dev_build.keep_me"))
    484524        {
    485525            COUT(1) << "Running from the build tree." << std::endl;
    486526            Core::isDevBuild_ = true;
    487             mediaPath_g  = ORXONOX_MEDIA_DEV_PATH;
    488             configPath_g = ORXONOX_CONFIG_DEV_PATH;
    489             logPath_g    = ORXONOX_LOG_DEV_PATH;
     527            configuration_->mediaPath_  = ORXONOX_MEDIA_DEV_PATH;
     528            configuration_->configPath_ = ORXONOX_CONFIG_DEV_PATH;
     529            configuration_->logPath_    = ORXONOX_LOG_DEV_PATH;
    490530        }
    491531        else
     
    494534            // Also set the root path
    495535            boost::filesystem::path relativeExecutablePath(ORXONOX_RUNTIME_INSTALL_PATH);
    496             rootPath_g = executablePath_g;
    497             while (!boost::filesystem::equivalent(rootPath_g / relativeExecutablePath, executablePath_g) && !rootPath_g.empty())
    498                 rootPath_g = rootPath_g.branch_path();
    499             if (rootPath_g.empty())
     536            configuration_->rootPath_ = configuration_->executablePath_;
     537            while (!boost::filesystem::equivalent(configuration_->rootPath_ / relativeExecutablePath, configuration_->executablePath_)
     538                   && !configuration_->rootPath_.empty())
     539                configuration_->rootPath_ = configuration_->rootPath_.branch_path();
     540            if (configuration_->rootPath_.empty())
    500541                ThrowException(General, "Could not derive a root directory. Might the binary installation directory contain '..' when taken relative to the installation prefix path?");
    501542
    502543            // Using paths relative to the install prefix, complete them
    503             mediaPath_g  = rootPath_g / ORXONOX_MEDIA_INSTALL_PATH;
    504             configPath_g = rootPath_g / ORXONOX_CONFIG_INSTALL_PATH;
    505             logPath_g    = rootPath_g / ORXONOX_LOG_INSTALL_PATH;
     544            configuration_->mediaPath_  = configuration_->rootPath_ / ORXONOX_MEDIA_INSTALL_PATH;
     545            configuration_->configPath_ = configuration_->rootPath_ / ORXONOX_CONFIG_INSTALL_PATH;
     546            configuration_->logPath_    = configuration_->rootPath_ / ORXONOX_LOG_INSTALL_PATH;
    506547#else
    507548            // There is no root path, so don't set it at all
    508549
    509             mediaPath_g  = ORXONOX_MEDIA_INSTALL_PATH;
     550            configuration_->mediaPath_  = ORXONOX_MEDIA_INSTALL_PATH;
    510551
    511552            // Get user directory
     
    520561            userDataPath /= ".orxonox";
    521562
    522             configPath_g = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
    523             logPath_g    = userDataPath / ORXONOX_LOG_INSTALL_PATH;
     563            configuration_->configPath_ = userDataPath / ORXONOX_CONFIG_INSTALL_PATH;
     564            configuration_->logPath_    = userDataPath / ORXONOX_LOG_INSTALL_PATH;
    524565#endif
    525566        }
     
    529570        {
    530571            std::string directory(CommandLine::getValue("writingPathSuffix").getString());
    531             configPath_g = configPath_g / directory;
    532             logPath_g    = logPath_g    / directory;
     572            configuration_->configPath_ = configuration_->configPath_ / directory;
     573            configuration_->logPath_    = configuration_->logPath_    / directory;
    533574        }
    534575    }
     
    544585    {
    545586        std::vector<std::pair<boost::filesystem::path, std::string> > directories;
    546         directories.push_back(std::make_pair(boost::filesystem::path(configPath_g), "config"));
    547         directories.push_back(std::make_pair(boost::filesystem::path(logPath_g), "log"));
     587        directories.push_back(std::make_pair(boost::filesystem::path(configuration_->configPath_), "config"));
     588        directories.push_back(std::make_pair(boost::filesystem::path(configuration_->logPath_), "log"));
    548589
    549590        for (std::vector<std::pair<boost::filesystem::path, std::string> >::iterator it = directories.begin();
  • code/trunk/src/core/Core.h

    r3196 r3280  
    4343
    4444#include <cassert>
    45 #include "OrxonoxClass.h"
    4645#include "util/OutputHandler.h"
    4746
    4847namespace orxonox
    4948{
     49    class CoreConfiguration;
     50
    5051    /**
    5152    @brief
     
    5556        It determines those by the use of platform specific functions.
    5657    */
    57     class _CoreExport Core : public OrxonoxClass
     58    class _CoreExport Core
    5859    {
    5960        public:
     
    6566                GeneralException
    6667            */
    67             Core();
     68            Core(int argc, char** argv);
    6869            ~Core();
    6970
    70             void initialise(int argc, char** argv);
    7171            void setConfigValues();
    7272
     
    8080            static void  resetLanguage();
    8181
    82             static void tsetMediaPath(const std::string& path)
    83             { assert(singletonRef_s); singletonRef_s->_tsetMediaPath(path); }
     82            static void tsetMediaPath(const std::string& path);
    8483            //! Returns the path to the config files as boost::filesystem::path
    8584            static const boost::filesystem::path& getMediaPath();
     
    103102            void setThreadAffinity(int limitToCPU);
    104103
    105             void resetLanguageIntern();
    106             void initializeRandomNumberGenerator();
    107             void debugLevelChanged();
    108             void languageChanged();
    109             void mediaPathChanged();
    110             void _tsetMediaPath(const std::string& path);
    111 
    112104            // Singletons
    113105            ConfigFileManager*    configFileManager_;
     
    119111            TclThreadManager*     tclThreadManager_;
    120112
    121             int softDebugLevel_;                            //!< The debug level
    122             int softDebugLevelConsole_;                     //!< The debug level for the console
    123             int softDebugLevelLogfile_;                     //!< The debug level for the logfile
    124             int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    125             std::string language_;                          //!< The language
    126             bool bInitializeRandomNumberGenerator_;         //!< If true, srand(time(0)) is called
    127             std::string mediaPathString_;                   //!< Path to the data/media file folder as string
    128113            bool isDevBuild_;                               //!< True for builds in the build directory (not installed)
    129             bool loaded_;                                   //!< Only true if constructor was interrupted
     114            CoreConfiguration*    configuration_;
    130115
    131116            static Core* singletonRef_s;
  • code/trunk/src/core/CorePrereqs.h

    r3196 r3280  
    7474    namespace KeybindMode
    7575    {
    76         enum Enum
     76        enum Value
    7777        {
    7878            OnPress,
     
    165165    // game states
    166166    class Game;
     167    struct GameStateConstrParams;
    167168    class GameState;
    168169    struct GameStateTreeNode;
  • code/trunk/src/core/Executor.cc

    r3196 r3280  
    9999
    100100            // assign all given arguments to the multitypes
    101             for (unsigned int i = 0; i < min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     101            for (unsigned int i = 0; i < std::min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
    102102                param[i] = tokens[i];
    103103
    104104            // fill the remaining multitypes with default values
    105             for (unsigned int i = tokens.size(); i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     105            for (unsigned int i = tokens.size(); i < std::min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
    106106                param[i] = this->defaultValue_[i];
    107107
    108108            // evaluate the param types through the functor
    109             for (unsigned int i = 0; i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     109            for (unsigned int i = 0; i < std::min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
    110110                this->functor_->evaluateParam(i, param[i]);
    111111
  • code/trunk/src/core/Executor.h

    r3196 r3280  
    3333#include "CorePrereqs.h"
    3434
     35#include <algorithm>
     36#include <string>
     37
    3538#include "util/Debug.h"
    3639#include "util/Math.h"
    37 #include "util/String.h"
     40#include "util/StringUtils.h"
    3841#include "util/SubString.h"
    3942#include "Functor.h"
     
    101104            COUT(5) << tokens[i]; \
    102105        } \
    103         COUT(5) << ") and " << max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
     106        COUT(5) << ") and " << std::max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
    104107        for (unsigned int i = tokens.size(); i < paramCount; i++) \
    105108        { \
     
    175178            inline bool hasReturnvalue() const
    176179                { return this->functor_->hasReturnvalue(); }
    177             inline FunctionType getType() const
     180            inline FunctionType::Value getType() const
    178181                { return this->functor_->getType(); }
    179182            inline const MultiType& getReturnvalue() const
     
    201204                    return this->defaultValue_[index];
    202205
    203                 return MT_null;
     206                return MT_Type::Null;
    204207            }
    205208
  • code/trunk/src/core/Functor.h

    r3196 r3280  
    3535#include "util/Debug.h"
    3636#include "util/MultiType.h"
    37 #include "util/String.h"
     37#include "util/StringUtils.h"
    3838
    3939namespace orxonox
     
    4141    const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
    4242
    43     enum FunctionType
     43    namespace FunctionType
    4444    {
    45         FT_MEMBER,
    46         FT_CONSTMEMBER,
    47         FT_STATIC
    48     };
     45        enum Value
     46        {
     47            Member,
     48            ConstMember,
     49            Static
     50        };
     51    }
    4952
    5053
     
    98101            virtual ~Functor() {}
    99102
    100             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;
     103            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;
    101104
    102105            inline unsigned int getParamCount() const { return this->numParams_; }
    103106            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
    104             inline FunctionType getType() const { return this->type_; }
     107            inline FunctionType::Value getType() const { return this->type_; }
    105108            inline const MultiType& getReturnvalue() const { return this->returnedValue_; }
    106109
     
    113116            unsigned int numParams_;
    114117            bool hasReturnValue_;
    115             FunctionType type_;
     118            FunctionType::Value type_;
    116119            MultiType returnedValue_;
    117120
     
    124127        public:
    125128            virtual ~FunctorStatic() {}
    126             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;
     129            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;
    127130    };
    128131
     
    139142            virtual ~FunctorMember() {}
    140143
    141             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;
    142             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;
    143 
    144             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)
     144            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;
     145            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;
     146
     147            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)
    145148            {
    146149                if (this->bConstObject_)
     
    322325                this->numParams_ = numparams; \
    323326                this->hasReturnValue_ = returnvalue; \
    324                 this->type_ = FT_STATIC; \
     327                this->type_ = FunctionType::Static; \
    325328                this->functionPointer_ = functionPointer; \
    326329                \
     
    329332            } \
    330333    \
    331             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) \
     334            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) \
    332335            { \
    333336                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
     
    363366                this->numParams_ = numparams; \
    364367                this->hasReturnValue_ = returnvalue; \
    365                 this->type_ = FT_MEMBER; \
     368                this->type_ = FunctionType::Member; \
    366369                this->functionPointer_ = functionPointer; \
    367370            } \
    368371    \
    369             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) \
     372            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) \
    370373            { \
    371374                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    372375            } \
    373376    \
    374             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) \
     377            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) \
    375378            { \
    376379                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
     
    396399                this->numParams_ = numparams; \
    397400                this->hasReturnValue_ = returnvalue; \
    398                 this->type_ = FT_CONSTMEMBER; \
     401                this->type_ = FunctionType::ConstMember; \
    399402                this->functionPointer_ = functionPointer; \
    400403            } \
    401404    \
    402             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) \
     405            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) \
    403406            { \
    404407                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    405408            } \
    406409    \
    407             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) \
     410            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) \
    408411            { \
    409412                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
  • code/trunk/src/core/Game.cc

    r3196 r3280  
    5858    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
    5959
    60     struct _CoreExport GameStateTreeNode
     60    std::map<std::string, Game::GameStateInfo> Game::gameStateDeclarations_s;
     61    Game* Game::singletonRef_s = 0;
     62
     63
     64    /**
     65    @brief
     66        Represents one node of the game state tree.
     67    */
     68    struct GameStateTreeNode
    6169    {
    6270        GameState* state_;
     
    6573    };
    6674
    67     std::map<std::string, GameState*> Game::allStates_s;
    68     Game* Game::singletonRef_s = 0;
     75
     76    /**
     77    @brief
     78        Another helper class for the Game singleton: we cannot derive
     79        Game from OrxonoxClass because we need to handle the Identifier
     80        destruction in the Core destructor.
     81    */
     82    class GameConfiguration : public OrxonoxClass
     83    {
     84    public:
     85        GameConfiguration()
     86        {
     87            RegisterRootObject(GameConfiguration);
     88            this->setConfigValues();
     89        }
     90
     91        void setConfigValues()
     92        {
     93            SetConfigValue(statisticsRefreshCycle_, 250000)
     94                .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
     95            SetConfigValue(statisticsAvgLength_, 1000000)
     96                .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
     97        }
     98
     99        unsigned int statisticsRefreshCycle_;
     100        unsigned int statisticsAvgLength_;
     101    };
     102
    69103
    70104    /**
     
    74108    Game::Game(int argc, char** argv)
    75109    {
    76         assert(singletonRef_s == 0);
     110        if (singletonRef_s != 0)
     111        {
     112            COUT(0) << "Error: The Game singleton cannot be recreated! Shutting down." << std::endl;
     113            abort();
     114        }
    77115        singletonRef_s = this;
    78116
    79         this->abort_ = false;
     117        this->bAbort_ = false;
     118        bChangingState_ = false;
     119
     120        // Create an empty root state
     121        declareGameState<GameState>("GameState", "emptyRootGameState", true, false);
    80122
    81123        // reset statistics
     
    87129        this->avgTickTime_ = 0.0f;
    88130
    89 
    90131        // Set up a basic clock to keep time
    91132        this->gameClock_ = new Clock();
    92133
    93         this->core_ = new orxonox::Core();
    94         this->core_->initialise(argc, argv);
    95 
    96         RegisterRootObject(Game);
    97         this->setConfigValues();
     134        // Create the Core
     135        this->core_ = new Core(argc, argv);
     136
     137        // After the core has been created, we can safely instantiate the GameStates
     138        for (std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.begin();
     139            it != gameStateDeclarations_s.end(); ++it)
     140        {
     141            // Only create the states appropriate for the game mode
     142            //if (GameMode::showsGraphics || !it->second.bGraphicsMode)
     143            GameStateConstrParams params = { it->second.stateName, it->second.bIgnoreTickTime };
     144            gameStates_[getLowercase(it->second.stateName)] = GameStateFactory::fabricate(it->second.className, params);
     145        }
     146
     147        // The empty root state is ALWAYS loaded!
     148        this->rootStateNode_ = shared_ptr<GameStateTreeNode>(new GameStateTreeNode());
     149        this->rootStateNode_->state_ = getState("emptyRootGameState");
     150        this->activeStateNode_ = this->rootStateNode_;
     151        this->activeStates_.push_back(this->rootStateNode_->state_);
     152
     153        // Do this after the Core creation!
     154        this->configuration_ = new GameConfiguration();
    98155    }
    99156
     
    103160    Game::~Game()
    104161    {
    105         // Destroy pretty much everyhting left
     162        // Destroy the configuration helper class instance
     163        delete this->configuration_;
     164
     165        // Destroy the GameStates (note that the nodes still point to them, but doesn't matter)
     166        for (std::map<std::string, GameState*>::const_iterator it = gameStates_.begin();
     167            it != gameStates_.end(); ++it)
     168            delete it->second;
     169
     170        // Destroy the Core and with it almost everything
    106171        delete this->core_;
    107 
    108172        delete this->gameClock_;
    109173
    110         assert(singletonRef_s);
    111         singletonRef_s = 0;
    112     }
    113 
    114     void Game::setConfigValues()
    115     {
    116         SetConfigValue(statisticsRefreshCycle_, 250000)
    117             .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
    118         SetConfigValue(statisticsAvgLength_, 1000000)
    119             .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
    120         SetConfigValue(levelName_, "presentation_dm.oxw")
    121             .description("Sets the preselection of the level in the main menu.");
    122     }
    123 
    124     void Game::setLevel(std::string levelName)
    125     {
    126         ModifyConfigValue(levelName_, set, levelName);
    127     }
    128 
    129     std::string Game::getLevel()
    130     {
    131         std::string levelName;
    132         CommandLine::getValue("level", &levelName);
    133         if (levelName == "")
    134             return levelName_;
    135         else
    136             return levelName;
     174        // Take care of the GameStateFactories
     175        GameStateFactory::destroyFactories();
     176
     177        // Don't assign singletonRef_s with NULL! Recreation is not supported
    137178    }
    138179
     
    147188    void Game::run()
    148189    {
    149         // Always start with the ROOT state
    150         this->requestedStateNodes_.push_back(this->rootStateNode_);
    151         this->activeStateNode_ = this->rootStateNode_;
    152         this->loadState(this->rootStateNode_->state_);
     190        if (this->requestedStateNodes_.empty())
     191            COUT(0) << "Warning: Starting game without requesting GameState. This automatically terminates the program." << std::endl;
    153192
    154193        // START GAME
    155194        this->gameClock_->capture(); // first delta time should be about 0 seconds
    156         while (!this->abort_ && !this->activeStates_.empty())
     195        while (!this->bAbort_ && (!this->activeStates_.empty() || this->requestedStateNodes_.size() > 0))
    157196        {
    158197            this->gameClock_->capture();
     
    160199
    161200            // STATISTICS
    162             statisticsTickInfo tickInfo = {currentTime, 0};
     201            StatisticsTickInfo tickInfo = {currentTime, 0};
    163202            statisticsTickTimes_.push_back(tickInfo);
    164203            this->periodTime_ += this->gameClock_->getDeltaTimeMicroseconds();
    165204
    166205            // UPDATE STATE STACK
    167             while (this->requestedStateNodes_.size() > 1)
    168             {
    169                 // Note: this->requestedStateNodes_.front() is the currently active state node
    170                 std::vector<shared_ptr<GameStateTreeNode> >::iterator it = this->requestedStateNodes_.begin() + 1;
    171                 if (*it == this->activeStateNode_->parent_.lock())
     206            while (this->requestedStateNodes_.size() > 0)
     207            {
     208                shared_ptr<GameStateTreeNode> requestedStateNode = this->requestedStateNodes_.front();
     209                assert(this->activeStateNode_);
     210                if (!this->activeStateNode_->parent_.expired() && requestedStateNode == this->activeStateNode_->parent_.lock())
    172211                    this->unloadState(this->activeStateNode_->state_);
    173212                else // has to be child
    174                     this->loadState((*it)->state_);
    175                 this->activeStateNode_ = *it;
     213                {
     214                    try
     215                    {
     216                        this->loadState(requestedStateNode->state_);
     217                    }
     218                    catch (const std::exception& ex)
     219                    {
     220                        COUT(1) << "Error: Loading GameState '" << requestedStateNode->state_->getName() << "' failed: " << ex.what() << std::endl;
     221                        // All scheduled operations have now been rendered inert --> flush them and issue a warning
     222                        if (this->requestedStateNodes_.size() > 1)
     223                            COUT(1) << "All " << this->requestedStateNodes_.size() - 1 << " scheduled transitions have been ignored." << std::endl;
     224                        this->requestedStateNodes_.clear();
     225                        break;
     226                    }
     227                }
     228                this->activeStateNode_ = requestedStateNode;
    176229                this->requestedStateNodes_.erase(this->requestedStateNodes_.begin());
    177230            }
    178231
    179             // UPDATE, bottom to top in the stack
    180             this->core_->update(*this->gameClock_);
    181             for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin();
     232            // UPDATE, Core first
     233            try
     234            {
     235                this->core_->update(*this->gameClock_);
     236            }
     237            catch (...)
     238            {
     239                COUT(0) << "An exception occured while ticking the Core. This should really never happen!" << std::endl;
     240                COUT(0) << "Closing the program." << std::endl;
     241                this->stop();
     242                break;
     243            }
     244
     245            // UPDATE, GameStates bottom to top in the stack
     246            // Note: The first element is the empty root state, which doesn't need ticking
     247            for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin() + 1;
    182248                it != this->activeStates_.end(); ++it)
    183249            {
    184                 // Add tick time for most of the states
    185                 uint64_t timeBeforeTick;
    186                 if ((*it)->getCountTickTime())
    187                     timeBeforeTick = this->gameClock_->getRealMicroseconds();
    188                
    189                 (*it)->update(*this->gameClock_);
    190 
    191                 if ((*it)->getCountTickTime())
    192                     this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
     250                bool threwException = false;
     251                try
     252                {
     253                    // Add tick time for most of the states
     254                    uint64_t timeBeforeTick;
     255                    if (!(*it)->ignoreTickTime())
     256                        timeBeforeTick = this->gameClock_->getRealMicroseconds();
     257                    (*it)->update(*this->gameClock_);
     258                    if (!(*it)->ignoreTickTime())
     259                        this->addTickTime(static_cast<uint32_t>(this->gameClock_->getRealMicroseconds() - timeBeforeTick));
     260                }
     261                catch (const std::exception& ex)
     262                {
     263                    threwException = true;
     264                    COUT(0) << "Exception while ticking: " << ex.what() << std::endl;
     265                }
     266                catch (...)
     267                {
     268                    threwException = true;
     269                }
     270                if (threwException)
     271                {
     272                    COUT(1) << "An exception occured while ticking GameState '" << (*it)->getName() << "'. This should really never happen!" << std::endl;
     273                    COUT(1) << "Unloading all GameStates depending on the one that crashed." << std::endl;
     274                    if ((*it)->getParent() != NULL)
     275                        this->requestState((*it)->getParent()->getName());
     276                    else
     277                        this->stop();
     278                    break;
     279                }
     280
    193281            }
    194282
    195283            // STATISTICS
    196             if (this->periodTime_ > statisticsRefreshCycle_)
    197             {
    198                 std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
     284            if (this->periodTime_ > this->configuration_->statisticsRefreshCycle_)
     285            {
     286                std::list<StatisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
    199287                assert(it != this->statisticsTickTimes_.end());
    200                 int64_t lastTime = currentTime - this->statisticsAvgLength_;
     288                int64_t lastTime = currentTime - this->configuration_->statisticsAvgLength_;
    201289                if ((int64_t)it->tickTime < lastTime)
    202290                {
    203291                    do
    204292                    {
    205                         assert(this->periodTickTime_ > it->tickLength);
     293                        assert(this->periodTickTime_ >= it->tickLength);
    206294                        this->periodTickTime_ -= it->tickLength;
    207295                        ++it;
     
    215303                this->avgTickTime_ = static_cast<float>(this->periodTickTime_) / framesPerPeriod / 1000.0f;
    216304
    217                 this->periodTime_ -= this->statisticsRefreshCycle_;
     305                this->periodTime_ -= this->configuration_->statisticsRefreshCycle_;
    218306            }
    219307        }
    220308
    221309        // UNLOAD all remaining states
    222         while (!this->activeStates_.empty())
     310        while (this->activeStates_.size() > 1)
    223311            this->unloadState(this->activeStates_.back());
    224         this->activeStateNode_.reset();
     312        this->activeStateNode_ = this->rootStateNode_;
    225313        this->requestedStateNodes_.clear();
    226314    }
     
    228316    void Game::stop()
    229317    {
    230         this->abort_ = true;
     318        this->bAbort_ = true;
    231319    }
    232320
     
    244332    {
    245333        GameState* state = this->getState(name);
    246         if (state == NULL || this->activeStateNode_ == NULL)
     334        if (state == NULL)
    247335            return;
    248336
    249         shared_ptr<GameStateTreeNode> requestedNode;
    250 
    251         // this->requestedStateNodes_.back() is the currently active state
    252         shared_ptr<GameStateTreeNode> lastRequestedNode = this->requestedStateNodes_.back();
    253 
    254         // Already the active node?
     337        //if (this->bChangingState_)
     338        //{
     339        //    COUT(2) << "Warning: Requesting GameStates while loading/unloading a GameState is illegal! Ignoring." << std::endl;
     340        //    return;
     341        //}
     342
     343        shared_ptr<GameStateTreeNode> lastRequestedNode;
     344        if (this->requestedStateNodes_.empty())
     345            lastRequestedNode = this->activeStateNode_;
     346        else
     347            lastRequestedNode = this->requestedStateNodes_.back();
    255348        if (state == lastRequestedNode->state_)
    256349        {
     
    260353
    261354        // Check children first
     355        std::vector<shared_ptr<GameStateTreeNode> > requestedNodes;
    262356        for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
    263357        {
    264358            if (lastRequestedNode->children_[i]->state_ == state)
    265359            {
    266                 requestedNode = lastRequestedNode->children_[i];
     360                requestedNodes.push_back(lastRequestedNode->children_[i]);
    267361                break;
    268362            }
    269363        }
    270364
    271         // Check parent and all its grand parents
    272         shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
    273         while (requestedNode == NULL && currentNode != NULL)
    274         {
    275             if (currentNode->state_ == state)
    276                 requestedNode = currentNode;
    277             currentNode = currentNode->parent_.lock();
    278         }
    279 
    280         if (requestedNode == NULL)
     365        if (requestedNodes.empty())
     366        {
     367            // Check parent and all its grand parents
     368            shared_ptr<GameStateTreeNode> currentNode = lastRequestedNode;
     369            while (currentNode != NULL)
     370            {
     371                if (currentNode->state_ == state)
     372                    break;
     373                currentNode = currentNode->parent_.lock();
     374                requestedNodes.push_back(currentNode);
     375            }
     376        }
     377
     378        if (requestedNodes.empty())
    281379            COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
    282380        else
    283             this->requestedStateNodes_.push_back(requestedNode);
     381            this->requestedStateNodes_.insert(requestedStateNodes_.end(), requestedNodes.begin(), requestedNodes.end());
    284382    }
    285383
     
    293391    void Game::popState()
    294392    {
    295         if (this->activeStateNode_ != NULL && this->requestedStateNodes_.back()->parent_.lock())
    296             this->requestState(this->requestedStateNodes_.back()->parent_.lock()->state_->getName());
     393        shared_ptr<GameStateTreeNode> lastRequestedNode;
     394        if (this->requestedStateNodes_.empty())
     395            lastRequestedNode = this->activeStateNode_;
    297396        else
    298             COUT(2) << "Warning: Could not pop GameState. Ignoring." << std::endl;
     397            lastRequestedNode = this->requestedStateNodes_.back();
     398        if (lastRequestedNode != this->rootStateNode_)
     399            this->requestState(lastRequestedNode->parent_.lock()->state_->getName());
     400        else
     401            COUT(2) << "Warning: Can't pop the internal dummy root GameState" << std::endl;
    299402    }
    300403
    301404    GameState* Game::getState(const std::string& name)
    302405    {
    303         std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(name));
    304         if (it != allStates_s.end())
     406        std::map<std::string, GameState*>::const_iterator it = gameStates_.find(getLowercase(name));
     407        if (it != gameStates_.end())
    305408            return it->second;
    306409        else
     
    325428            while(pos < str.size() && str[pos] != ' ')
    326429                ++pos;
    327             stateStrings.push_back(std::pair<std::string, unsigned>(
    328                 str.substr(startPos, pos - startPos), indentation));
     430            stateStrings.push_back(std::make_pair(str.substr(startPos, pos - startPos), indentation));
    329431        }
    330432        unsigned int currentLevel = 0;
    331         shared_ptr<GameStateTreeNode> currentNode;
     433        shared_ptr<GameStateTreeNode> currentNode = this->rootStateNode_;
    332434        for (std::vector<std::pair<std::string, unsigned> >::const_iterator it = stateStrings.begin(); it != stateStrings.end(); ++it)
    333435        {
    334436            std::string newStateName = it->first;
    335             unsigned newLevel = it->second;
     437            unsigned newLevel = it->second + 1; // empty root is 0
    336438            GameState* newState = this->getState(newStateName);
    337439            if (!newState)
    338                 ThrowException(GameState, std::string("GameState with name '") + newStateName + "' not found!");
    339             if (newLevel == 0)
    340             {
    341                 // root
    342                 if (this->rootStateNode_ != NULL)
    343                     ThrowException(GameState, "No two root GameStates are allowed!");
    344                 shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
    345                 newNode->state_ = newState;
    346                 this->rootStateNode_ = newNode;
    347                 currentNode = this->rootStateNode_;
    348             }
    349             else if (currentNode)
    350             {
    351                 shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
    352                 newNode->state_ = newState;
    353                 if (newLevel < currentLevel)
    354                 {
    355                     // Get down the hierarchy
    356                     do
    357                         currentNode = currentNode->parent_.lock();
    358                     while (newLevel < --currentLevel);
    359                 }
    360                 if (newLevel == currentLevel)
    361                 {
    362                     // same level
    363                     newNode->parent_ = currentNode->parent_;
    364                     newNode->parent_.lock()->children_.push_back(newNode);
    365                 }
    366                 else if (newLevel == currentLevel + 1)
    367                 {
    368                     // child
    369                     newNode->parent_ = currentNode;
    370                     currentNode->children_.push_back(newNode);
    371                 }
    372                 else
    373                     ThrowException(GameState, "Indentation error while parsing the hierarchy.");
    374                 currentNode = newNode;
    375                 currentLevel = newLevel;
     440                ThrowException(GameState, "GameState with name '" << newStateName << "' not found!");
     441            if (newState == this->rootStateNode_->state_)
     442                ThrowException(GameState, "You shouldn't use 'emptyRootGameState' in the hierarchy...");
     443            shared_ptr<GameStateTreeNode> newNode(new GameStateTreeNode);
     444            newNode->state_ = newState;
     445
     446            if (newLevel <= currentLevel)
     447            {
     448                do
     449                    currentNode = currentNode->parent_.lock();
     450                while (newLevel <= --currentLevel);
     451            }
     452            if (newLevel == currentLevel + 1)
     453            {
     454                // Add the child
     455                newNode->parent_ = currentNode;
     456                currentNode->children_.push_back(newNode);
     457                currentNode->state_->addChild(newNode->state_);
    376458            }
    377459            else
    378             {
    379                 ThrowException(GameState, "No root GameState specified!");
    380             }
     460                ThrowException(GameState, "Indentation error while parsing the hierarchy.");
     461            currentNode = newNode;
     462            currentLevel = newLevel;
    381463        }
    382464    }
     
    386468    void Game::loadState(GameState* state)
    387469    {
     470        this->bChangingState_ = true;
     471        state->activate();
    388472        if (!this->activeStates_.empty())
    389473            this->activeStates_.back()->activity_.topState = false;
    390         state->activate();
     474        this->activeStates_.push_back(state);
    391475        state->activity_.topState = true;
    392         this->activeStates_.push_back(state);
     476        this->bChangingState_ = false;
    393477    }
    394478
    395479    void Game::unloadState(orxonox::GameState* state)
    396480    {
     481        this->bChangingState_ = true;
    397482        state->activity_.topState = false;
    398         state->deactivate();
    399483        this->activeStates_.pop_back();
    400484        if (!this->activeStates_.empty())
    401485            this->activeStates_.back()->activity_.topState = true;
    402     }
    403 
    404     /*static*/ bool Game::addGameState(GameState* state)
    405     {
    406         std::map<std::string, GameState*>::const_iterator it = allStates_s.find(getLowercase(state->getName()));
    407         if (it == allStates_s.end())
    408             allStates_s[getLowercase(state->getName())] = state;
    409         else
    410             ThrowException(GameState, "Cannot add two GameStates with the same name to 'Game'.");
    411 
    412         // just a required dummy return value
    413         return true;
    414     }
    415 
    416     /*static*/ void Game::destroyStates()
    417     {
    418         // Delete all GameStates created by the macros
    419         for (std::map<std::string, GameState*>::const_iterator it = allStates_s.begin(); it != allStates_s.end(); ++it)
     486        try
     487        {
     488            state->deactivate();
     489        }
     490        catch (const std::exception& ex)
     491        {
     492            COUT(2) << "Warning: Unloading GameState '" << state->getName() << "' threw an exception: " << ex.what() << std::endl;
     493            COUT(2) << "         There might be potential resource leaks involved! To avoid this, improve exception-safety." << std::endl;
     494        }
     495        this->bChangingState_ = false;
     496    }
     497
     498    std::map<std::string, Game::GameStateFactory*> Game::GameStateFactory::factories_s;
     499
     500    /*static*/ GameState* Game::GameStateFactory::fabricate(const std::string& className, const GameStateConstrParams& params)
     501    {
     502        std::map<std::string, GameStateFactory*>::const_iterator it = factories_s.find(className);
     503        assert(it != factories_s.end());
     504        return it->second->fabricate(params);
     505    }
     506
     507    /*static*/ void Game::GameStateFactory::destroyFactories()
     508    {
     509        for (std::map<std::string, GameStateFactory*>::const_iterator it = factories_s.begin(); it != factories_s.end(); ++it)
    420510            delete it->second;
    421         allStates_s.clear();
     511        factories_s.clear();
    422512    }
    423513}
  • code/trunk/src/core/Game.h

    r3196 r3280  
    4646#include <boost/preprocessor/cat.hpp>
    4747
    48 #include "OrxonoxClass.h"
     48#include "util/Debug.h"
     49#include "util/StringUtils.h"
    4950
    5051/**
     
    5354    and every following paramter is a constructor argument (which is usually non existent)
    5455*/
    55 #define AddGameState(classname, ...) \
    56     static bool BOOST_PP_CAT(bGameStateDummy_##classname, __LINE__) = orxonox::Game::addGameState(new classname(__VA_ARGS__))
     56#define DeclareGameState(className, stateName, bIgnoreTickTime, bGraphicsMode) \
     57    static bool BOOST_PP_CAT(bGameStateDummy_##className, __LINE__) = orxonox::Game::declareGameState<className>(#className, stateName, bIgnoreTickTime, bGraphicsMode)
    5758
    58 // tolua_begin
    5959namespace orxonox
    6060{
     61    class GameConfiguration;
     62
    6163    /**
    6264    @brief
     
    6466    */
    6567    class _CoreExport Game
    66     // tolua_end
    67         : public OrxonoxClass
    68     // tolua_begin
    6968    {
    70     //tolua_end
    7169    public:
    7270        Game(int argc, char** argv);
    7371        ~Game();
    74         void setConfigValues();
    7572
    7673        void setStateHierarchy(const std::string& str);
     
    9188        void addTickTime(uint32_t length);
    9289
    93         static bool addGameState(GameState* state);
    94         static void destroyStates();
    95         static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; } //tolua_export
    96 
    97         void setLevel(std::string levelName); //tolua_export
    98         std::string getLevel(); //tolua_export
     90        template <class T>
     91        static bool declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bConsoleMode);
     92        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
    9993
    10094    private:
    101         struct statisticsTickInfo
     95        class _CoreExport GameStateFactory
     96        {
     97        public:
     98            virtual ~GameStateFactory() { }
     99            static GameState* fabricate(const std::string& className, const GameStateConstrParams& params);
     100            template <class T>
     101            static void createFactory(const std::string& className)
     102                { factories_s[className] = new TemplateGameStateFactory<T>(); }
     103            static void destroyFactories();
     104        private:
     105            virtual GameState* fabricate(const GameStateConstrParams& params) = 0;
     106            static std::map<std::string, GameStateFactory*> factories_s;
     107        };
     108        template <class T>
     109        class TemplateGameStateFactory : public GameStateFactory
     110        {
     111        public:
     112            GameState* fabricate(const GameStateConstrParams& params)
     113                { return new T(params); }
     114        };
     115
     116        struct GameStateInfo
     117        {
     118            std::string stateName;
     119            std::string className;
     120            bool bIgnoreTickTime;
     121            bool bGraphicsMode;
     122        };
     123
     124        struct StatisticsTickInfo
    102125        {
    103126            uint64_t    tickTime;
     
    110133        void unloadState(GameState* state);
    111134
    112         std::vector<GameState*>         activeStates_;
     135        std::map<std::string, GameState*>    gameStates_;
     136        std::vector<GameState*>              activeStates_;
    113137        boost::shared_ptr<GameStateTreeNode> rootStateNode_;
    114138        boost::shared_ptr<GameStateTreeNode> activeStateNode_;
     
    117141        Core*                           core_;
    118142        Clock*                          gameClock_;
     143        GameConfiguration*              configuration_;
    119144
    120         bool                            abort_;
     145        bool                            bChangingState_;
     146        bool                            bAbort_;
    121147
    122148        // variables for time statistics
    123149        uint64_t                        statisticsStartTime_;
    124         std::list<statisticsTickInfo>   statisticsTickTimes_;
     150        std::list<StatisticsTickInfo>   statisticsTickTimes_;
    125151        uint32_t                        periodTime_;
    126152        uint32_t                        periodTickTime_;
     
    128154        float                           avgTickTime_;
    129155
    130         // config values
    131         unsigned int                    statisticsRefreshCycle_;
    132         unsigned int                    statisticsAvgLength_;
    133         std::string                     levelName_;
     156        static std::map<std::string, GameStateInfo> gameStateDeclarations_s;
     157        static Game* singletonRef_s;        //!< Pointer to the Singleton
     158    };
    134159
    135         static std::map<std::string, GameState*> allStates_s;
    136         static Game* singletonRef_s;        //!< Pointer to the Singleton
    137         // tolua_begin
    138     };
     160    template <class T>
     161    /*static*/ bool Game::declareGameState(const std::string& className, const std::string& stateName, bool bIgnoreTickTime, bool bGraphicsMode)
     162    {
     163        std::map<std::string, GameStateInfo>::const_iterator it = gameStateDeclarations_s.find(getLowercase(stateName));
     164        if (it == gameStateDeclarations_s.end())
     165        {
     166            GameStateInfo& info = gameStateDeclarations_s[getLowercase(stateName)];
     167            info.stateName = stateName;
     168            info.className = className;
     169            info.bIgnoreTickTime = bIgnoreTickTime;
     170            info.bGraphicsMode = bGraphicsMode;
     171        }
     172        else
     173        {
     174            COUT(0) << "Error: Cannot declare two GameStates with the same name." << std::endl;
     175            COUT(0) << "       Ignoring second one ('" << stateName << "')." << std::endl;
     176        }
     177
     178        // Create a factory to delay GameState creation
     179        GameStateFactory::createFactory<T>(className);
     180
     181        // just a required dummy return value
     182        return true;
     183    }
    139184}
    140 //tolua_end
     185
    141186#endif /* _Game_H__ */
  • code/trunk/src/core/GameState.cc

    r3196 r3280  
    4545        Constructor only initialises variables and sets the name permanently.
    4646    */
    47     GameState::GameState(const std::string& name, bool countTickTime)
    48         : name_(name)
    49         , bCountTickTime_(countTickTime)
     47    GameState::GameState(const GameStateConstrParams& params)
     48        : name_(params.name)
     49        , bIgnoreTickTime_(params.bIgnoreTickTime)
    5050        , parent_(0)
    5151    {
  • code/trunk/src/core/GameState.h

    r3196 r3280  
    4545    /**
    4646    @brief
     47        Helper class to group construction parameters for better genericity.
     48    */
     49    struct GameStateConstrParams
     50    {
     51        std::string name;
     52        bool bIgnoreTickTime;
     53    };
     54
     55    /**
     56    @brief
    4757        An implementation of a tree to manage game states.
    4858        This leads to a certain hierarchy that is created at runtime.
     
    7787
    7888    public:
    79         GameState(const std::string& name, bool countTicktime = true);
     89        GameState(const GameStateConstrParams& params);
    8090        virtual ~GameState();
    8191
     
    8494        GameState* getParent()       const { return this->parent_; }
    8595
    86         bool getCountTickTime()      const { return this->bCountTickTime_; }
     96        bool ignoreTickTime()        const { return this->bIgnoreTickTime_; }
    8797
    8898        void addChild(GameState* state);
     
    90100
    91101    protected:
    92         virtual void activate() = 0;
    93         virtual void deactivate() = 0;
    94         virtual void update(const Clock& time) = 0;
     102        virtual void activate() { }
     103        virtual void deactivate() { }
     104        virtual void update(const Clock& time) { }
    95105
    96106    private:
     
    103113        const std::string                        name_;
    104114        State                                    activity_;
    105         const bool                               bCountTickTime_;
     115        const bool                               bIgnoreTickTime_;
    106116        GameState*                               parent_;
    107117        std::map<std::string, GameState*>        children_;
  • code/trunk/src/core/IRC.cc

    r3196 r3280  
    6868        {   COUT(1) << "Error while initializing Tcl (IRC): " << e.what();   }
    6969
    70         this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
     70        this->nickname_ = "orx" + multi_cast<std::string>(static_cast<unsigned int>(rand()));
    7171        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
    7272        TclThreadManager::execute(threadID, "source irc.tcl");
  • code/trunk/src/core/Identifier.cc

    r3196 r3280  
    3636#include <ostream>
    3737
    38 #include "util/String.h"
     38#include "util/StringUtils.h"
    3939#include "ConfigValueContainer.h"
    4040#include "ConsoleCommand.h"
  • code/trunk/src/core/Language.cc

    r3198 r3280  
    194194        @return The filename
    195195    */
    196     const std::string Language::getFilename(const std::string& language)
     196    std::string Language::getFilename(const std::string& language)
    197197    {
    198198        return std::string("translation_" + language + ".lang");
  • code/trunk/src/core/Language.h

    r2662 r3280  
    114114    class _CoreExport Language
    115115    {
    116         friend class Core;
     116        friend class CoreConfiguration;
    117117
    118118        public:
     
    130130            void readTranslatedLanguageFile();
    131131            void writeDefaultLanguageFile() const;
    132             static const std::string getFilename(const std::string& language);
     132            static std::string getFilename(const std::string& language);
    133133            LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);
    134134
  • code/trunk/src/core/LuaBind.cc

    r3198 r3280  
    3838
    3939#include "util/Debug.h"
    40 #include "util/String.h"
     40#include "util/StringUtils.h"
    4141#include "ToluaBindCore.h"
    4242#include "Core.h"
  • code/trunk/src/core/OrxonoxClass.cc

    r3196 r3280  
    7878
    7979    /** @brief Returns true if the objects class is of the given type or a derivative. */
    80     bool OrxonoxClass::isA(const SubclassIdentifier<class B>* identifier)
     80    template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B>* identifier)
    8181        { return this->getIdentifier()->isA(identifier->getIdentifier()); }
    8282    /** @brief Returns true if the objects class is exactly of the given type. */
    83     bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B>* identifier)
     83    template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B>* identifier)
    8484        { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
    8585    /** @brief Returns true if the objects class is a child of the given type. */
    86     bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B>* identifier)
     86    template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B>* identifier)
    8787        { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
    8888    /** @brief Returns true if the objects class is a direct child of the given type. */
    89     bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B>* identifier)
     89    template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B>* identifier)
    9090        { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
    9191    /** @brief Returns true if the objects class is a parent of the given type. */
    92     bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B>* identifier)
     92    template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B>* identifier)
    9393        { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
    9494    /** @brief Returns true if the objects class is a direct parent of the given type. */
    95     bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B>* identifier)
     95    template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B>* identifier)
    9696        { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
    9797
    9898
    9999    /** @brief Returns true if the objects class is of the given type or a derivative. */
    100     bool OrxonoxClass::isA(const SubclassIdentifier<class B> identifier)
     100    template <class B> bool OrxonoxClass::isA(const SubclassIdentifier<B> identifier)
    101101        { return this->getIdentifier()->isA(identifier.getIdentifier()); }
    102102    /** @brief Returns true if the objects class is exactly of the given type. */
    103     bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B> identifier)
     103    template <class B> bool OrxonoxClass::isExactlyA(const SubclassIdentifier<B> identifier)
    104104        { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
    105105    /** @brief Returns true if the objects class is a child of the given type. */
    106     bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B> identifier)
     106    template <class B> bool OrxonoxClass::isChildOf(const SubclassIdentifier<B> identifier)
    107107        { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
    108108    /** @brief Returns true if the objects class is a direct child of the given type. */
    109     bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B> identifier)
     109    template <class B> bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<B> identifier)
    110110        { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
    111111    /** @brief Returns true if the objects class is a parent of the given type. */
    112     bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B> identifier)
     112    template <class B> bool OrxonoxClass::isParentOf(const SubclassIdentifier<B> identifier)
    113113        { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
    114114    /** @brief Returns true if the objects class is a direct parent of the given type. */
    115     bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B> identifier)
     115    template <class B> bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<B> identifier)
    116116        { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
    117117
  • code/trunk/src/core/OrxonoxClass.h

    r3196 r3280  
    8080            bool isDirectParentOf(const Identifier* identifier);
    8181
    82             bool isA(const SubclassIdentifier<class B>* identifier);
    83             bool isExactlyA(const SubclassIdentifier<class B>* identifier);
    84             bool isChildOf(const SubclassIdentifier<class B>* identifier);
    85             bool isDirectChildOf(const SubclassIdentifier<class B>* identifier);
    86             bool isParentOf(const SubclassIdentifier<class B>* identifier);
    87             bool isDirectParentOf(const SubclassIdentifier<class B>* identifier);
     82            template <class B> bool isA(const SubclassIdentifier<B>* identifier);
     83            template <class B> bool isExactlyA(const SubclassIdentifier<B>* identifier);
     84            template <class B> bool isChildOf(const SubclassIdentifier<B>* identifier);
     85            template <class B> bool isDirectChildOf(const SubclassIdentifier<B>* identifier);
     86            template <class B> bool isParentOf(const SubclassIdentifier<B>* identifier);
     87            template <class B> bool isDirectParentOf(const SubclassIdentifier<B>* identifier);
    8888
    89             bool isA(const SubclassIdentifier<class B> identifier);
    90             bool isExactlyA(const SubclassIdentifier<class B> identifier);
    91             bool isChildOf(const SubclassIdentifier<class B> identifier);
    92             bool isDirectChildOf(const SubclassIdentifier<class B> identifier);
    93             bool isParentOf(const SubclassIdentifier<class B> identifier);
    94             bool isDirectParentOf(const SubclassIdentifier<class B> identifier);
     89            template <class B> bool isA(const SubclassIdentifier<B> identifier);
     90            template <class B> bool isExactlyA(const SubclassIdentifier<B> identifier);
     91            template <class B> bool isChildOf(const SubclassIdentifier<B> identifier);
     92            template <class B> bool isDirectChildOf(const SubclassIdentifier<B> identifier);
     93            template <class B> bool isParentOf(const SubclassIdentifier<B> identifier);
     94            template <class B> bool isDirectParentOf(const SubclassIdentifier<B> identifier);
    9595
    9696            bool isA(const OrxonoxClass* object);
  • code/trunk/src/core/Shell.cc

    r3196 r3280  
    7878        OutputHandler::getOutStream().setOutputBuffer(&this->outputBuffer_);
    7979
     80        // Get a config file for the command history
     81        this->commandHistoryConfigFileType_ = ConfigFileManager::getInstance().getNewConfigFileType();
     82        ConfigFileManager::getInstance().setFilename(this->commandHistoryConfigFileType_, "commandHistory.ini");
     83
    8084        this->setConfigValues();
    8185
     
    9397    void Shell::setConfigValues()
    9498    {
    95         SetConfigValue(maxHistoryLength_, 100).callback(this, &Shell::commandHistoryLengthChanged);
    96         SetConfigValue(historyOffset_, 0).callback(this, &Shell::commandHistoryOffsetChanged);
    97         SetConfigValueVector(commandHistory_, std::vector<std::string>());
     99        SetConfigValueGeneric(commandHistoryConfigFileType_, maxHistoryLength_, 100)
     100            .callback(this, &Shell::commandHistoryLengthChanged);
     101        SetConfigValueGeneric(commandHistoryConfigFileType_, historyOffset_, 0)
     102            .callback(this, &Shell::commandHistoryOffsetChanged);
     103        SetConfigValueVectorGeneric(commandHistoryConfigFileType_, commandHistory_, std::vector<std::string>());
    98104    }
    99105
  • code/trunk/src/core/Shell.h

    r3196 r3280  
    3737#include <vector>
    3838
     39#include "util/OutputBuffer.h"
     40#include "input/InputBuffer.h"
    3941#include "OrxonoxClass.h"
    40 #include "input/InputBuffer.h"
    41 #include "util/OutputBuffer.h"
     42#include "ConfigFileManager.h"
    4243
    4344namespace orxonox
     
    145146            bool bAddOutputLevel_;
    146147
     148            ConfigFileType commandHistoryConfigFileType_;
     149
    147150            static Shell* singletonRef_s;
    148151    };
  • code/trunk/src/core/TclBind.cc

    r3196 r3280  
    3434
    3535#include "util/Debug.h"
    36 #include "util/String.h"
     36#include "util/StringUtils.h"
    3737#include "CommandExecutor.h"
    3838#include "ConsoleCommand.h"
  • code/trunk/src/core/TclThreadManager.cc

    r3196 r3280  
    9494        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
    9595        TclThreadManager::getInstance().threadCounter_++;
    96         std::string name = getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().threadCounter_);
     96        std::string name = multi_cast<std::string>(TclThreadManager::getInstance().threadCounter_);
    9797
    9898        TclInterpreterBundle* bundle = new TclInterpreterBundle;
     
    192192        {
    193193            boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_);
    194             output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
     194            output += multi_cast<std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
    195195        }
    196196        output += "\t\t";
     
    201201        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it)
    202202        {
    203             std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
     203            std::string output = multi_cast<std::string>((*it).first);
    204204            output += "\t\t";
    205205            {
    206206                boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
    207                 output += getConvertedValue<unsigned int, std::string>((*it).second->queue_.size());
     207                output += multi_cast<std::string>((*it).second->queue_.size());
    208208            }
    209209            output += "\t\t";
     
    342342        else
    343343        {
    344             this->error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + " existing.");
     344            this->error("Error: No Tcl-interpreter with ID " + multi_cast<std::string>(threadID) + " existing.");
    345345            return 0;
    346346        }
     
    355355                output += " ";
    356356
    357             output += getConvertedValue<unsigned int, std::string>(*it);
     357            output += multi_cast<std::string>(*it);
    358358        }
    359359        return output;
     
    444444            if (bundle->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
    445445            {
    446                 this->error("Error: Queue of Tcl-interpreter " + getConvertedValue<unsigned int, std::string>(threadID) + " is full, couldn't add command.");
     446                this->error("Error: Queue of Tcl-interpreter " + multi_cast<std::string>(threadID) + " is full, couldn't add command.");
    447447                return;
    448448            }
     
    492492        if (std::find(target->queriers_.begin(), target->queriers_.end(), target->id_) != target->queriers_.end())
    493493        {
    494             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_) + ".");
     494            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_) + ".");
    495495            return false;
    496496        }
     
    585585                    else
    586586                    {
    587                         this->error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + ", interpreter is busy right now.");
     587                        this->error("Error: Couldn't query Tcl-interpreter with ID " + multi_cast<std::string>(threadID) + ", interpreter is busy right now.");
    588588                    }
    589589                }
     
    665665        catch (Tcl::tcl_error const &e)
    666666        {
    667             TclThreadManager::getInstance().error("Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + ") error: " + e.what());
     667            TclThreadManager::getInstance().error("Tcl (ID " + multi_cast<std::string>(interpreterBundle->id_) + ") error: " + e.what());
    668668        }
    669669        catch (std::exception const &e)
    670670        {
    671             TclThreadManager::getInstance().error("Error while executing Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + "): " + e.what());
     671            TclThreadManager::getInstance().error("Error while executing Tcl (ID " + multi_cast<std::string>(interpreterBundle->id_) + "): " + e.what());
    672672        }
    673673
  • code/trunk/src/core/input/Button.cc

    r2662 r3280  
    3737#include "util/Convert.h"
    3838#include "util/SubString.h"
    39 #include "util/String.h"
     39#include "util/StringUtils.h"
    4040#include "util/Debug.h"
    4141#include "core/ConsoleCommand.h"
     
    127127                    '\\', false, '"', false, '(', ')', false, '\0');
    128128
    129                 KeybindMode::Enum mode = KeybindMode::None;
     129                KeybindMode::Value mode = KeybindMode::None;
    130130                float paramModifier = 1.0f;
    131131                std::string commandStr = "";
  • code/trunk/src/core/input/Button.h

    r2662 r3280  
    5454        void parse();
    5555        void readConfigValue(ConfigFileType configFile);
    56         bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
     56        bool execute(KeybindMode::Value mode, float abs = 1.0f, float rel = 1.0f);
    5757
    5858        //! Container to allow for better configValue support
     
    7979    };
    8080
    81     inline bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
     81    inline bool Button::execute(KeybindMode::Value mode, float abs, float rel)
    8282    {
    8383        // execute all the parsed commands in the string
  • code/trunk/src/core/input/InputManager.cc

    r3196 r3280  
    4343#include "util/Convert.h"
    4444#include "util/Exception.h"
    45 #include "util/Debug.h"
     45#include "util/ScopeGuard.h"
    4646#include "core/Clock.h"
    4747#include "core/CoreIncludes.h"
     
    7070    SetConsoleCommand(InputManager, ungrabMouse, true);
    7171#endif
    72     SetCommandLineSwitch(keyboard_no_grab);
     72    SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard");
    7373
    7474    EmptyHandler InputManager::EMPTY_HANDLER;
     
    177177            windowHndStr << (unsigned int)windowHnd_;
    178178            paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
     179#if defined(ORXONOX_PLATFORM_WINDOWS)
    179180            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
    180181            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
    181 #if defined ORXONOX_PLATFORM_LINUX
     182            //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
     183            //paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
     184#elif defined(ORXONOX_PLATFORM_LINUX)
    182185            paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
    183186            paramList.insert(std::make_pair(std::string("x11_mouse_grab"), "true"));
     
    191194#endif
    192195
    193             inputSystem_ = OIS::InputManager::createInputSystem(paramList);
    194             CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
    195 
    196             _initialiseKeyboard();
     196            try
     197            {
     198                inputSystem_ = OIS::InputManager::createInputSystem(paramList);
     199                // Exception-safety
     200                Loki::ScopeGuard guard = Loki::MakeGuard(OIS::InputManager::destroyInputSystem, inputSystem_);
     201                CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
     202
     203                _initialiseKeyboard();
     204
     205                // Nothing below should throw anymore, dismiss the guard
     206                guard.Dismiss();
     207            }
     208            catch (OIS::Exception& ex)
     209            {
     210                ThrowException(InitialisationFailed, "Could not initialise the input system: " << ex.what());
     211            }
    197212
    198213            _initialiseMouse();
     
    200215            if (joyStickSupport)
    201216                _initialiseJoySticks();
    202             // Do this anyway to also inform everything when a joystick was detached.
     217            // Do this anyway to also inform when a joystick was detached.
    203218            _configureJoySticks();
    204219
     
    273288        else
    274289        {
    275             ThrowException(InitialisationFailed, "No keyboard found!");
     290            ThrowException(InitialisationFailed, "InputManager: No keyboard found, cannot proceed!");
    276291        }
    277292    }
     
    301316            else
    302317            {
    303                 CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
     318                CCOUT(ORX_WARNING) << "Warning: No mouse found! Proceeding without mouse support." << std::endl;
    304319            }
    305320        }
     
    307322        {
    308323            CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
    309                 << "OIS error message: \"" << ex.eText << "\"" << std::endl;
     324                << "OIS error message: \"" << ex.eText << "\"\n Proceeding without mouse support." << std::endl;
    310325            mouse_ = 0;
    311326        }
     
    345360            }
    346361        }
    347         else
    348         {
    349             //CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
    350         }
    351362    }
    352363
     
    528539        if (internalState_ != Uninitialised)
    529540        {
     541            CCOUT(3) << "Destroying ..." << std::endl;
     542
     543            // kick all active states 'nicely'
     544            for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
     545                rit != activeStates_.rend(); ++rit)
     546            {
     547                (*rit).second->onLeave();
     548            }
     549
     550            // Destroy calibrator helper handler and state
     551            delete keyDetector_;
     552            requestDestroyState("calibrator");
     553            // Destroy KeyDetector and state
     554            delete calibratorCallbackBuffer_;
     555            requestDestroyState("detector");
     556            // destroy the empty InputState
     557            _destroyState(this->stateEmpty_);
     558
     559            // destroy all user InputStates
     560            while (inputStatesByName_.size() > 0)
     561                _destroyState((*inputStatesByName_.rbegin()).second);
     562
     563            // destroy the devices
     564            _destroyKeyboard();
     565            _destroyMouse();
     566            _destroyJoySticks();
     567
    530568            try
    531569            {
    532                 CCOUT(3) << "Destroying ..." << std::endl;
    533 
    534                 // kick all active states 'nicely'
    535                 for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
    536                     rit != activeStates_.rend(); ++rit)
    537                 {
    538                     (*rit).second->onLeave();
    539                 }
    540 
    541                 // Destroy calibrator helper handler and state
    542                 delete keyDetector_;
    543                 requestDestroyState("calibrator");
    544                 // Destroy KeyDetector and state
    545                 delete calibratorCallbackBuffer_;
    546                 requestDestroyState("detector");
    547                 // destroy the empty InputState
    548                 _destroyState(this->stateEmpty_);
    549 
    550                 // destroy all user InputStates
    551                 while (inputStatesByName_.size() > 0)
    552                     _destroyState((*inputStatesByName_.rbegin()).second);
    553 
    554                 // destroy the devices
    555                 _destroyKeyboard();
    556                 _destroyMouse();
    557                 _destroyJoySticks();
    558 
    559570                OIS::InputManager::destroyInputSystem(inputSystem_);
    560 
    561                 CCOUT(3) << "Destroying done." << std::endl;
    562             }
    563             catch (OIS::Exception& ex)
    564             {
    565                 CCOUT(1) << "An exception has occured while destroying:\n" << ex.what()
    566                          << "This could lead to a possible memory/resource leak!" << std::endl;
     571            }
     572            catch (...)
     573            {
     574                CCOUT(1) << "OIS::InputManager destruction failed! Potential resource leak!" << std::endl;
    567575            }
    568576        }
     
    578586    {
    579587        assert(inputSystem_);
    580         if (keyboard_)
    581             inputSystem_->destroyInputObject(keyboard_);
    582         keyboard_ = 0;
    583         CCOUT(4) << "Keyboard destroyed." << std::endl;
     588        try
     589        {
     590            if (keyboard_)
     591                inputSystem_->destroyInputObject(keyboard_);
     592            keyboard_ = 0;
     593            CCOUT(4) << "Keyboard destroyed." << std::endl;
     594        }
     595        catch (...)
     596        {
     597            CCOUT(1) << "Keyboard destruction failed! Potential resource leak!" << std::endl;
     598        }
    584599    }
    585600
     
    591606    {
    592607        assert(inputSystem_);
    593         if (mouse_)
    594             inputSystem_->destroyInputObject(mouse_);
    595         mouse_ = 0;
    596         CCOUT(4) << "Mouse destroyed." << std::endl;
     608        try
     609        {
     610            if (mouse_)
     611                inputSystem_->destroyInputObject(mouse_);
     612            mouse_ = 0;
     613            CCOUT(4) << "Mouse destroyed." << std::endl;
     614        }
     615        catch (...)
     616        {
     617            CCOUT(1) << "Mouse destruction failed! Potential resource leak!" << std::endl;
     618        }
    597619    }
    598620
     
    607629            assert(inputSystem_);
    608630            for (unsigned int i = 0; i < joySticksSize_; i++)
    609                 if (joySticks_[i] != 0)
    610                     inputSystem_->destroyInputObject(joySticks_[i]);
     631            {
     632                try
     633                {
     634                    if (joySticks_[i] != 0)
     635                        inputSystem_->destroyInputObject(joySticks_[i]);
     636                }
     637                catch (...)
     638                {
     639                    CCOUT(1) << "Joy stick destruction failed! Potential resource leak!" << std::endl;
     640                }
     641            }
    611642
    612643            joySticks_.clear();
  • code/trunk/src/core/input/KeyBinder.cc

    r3196 r3280  
    9696        }
    9797
    98         // Get a new ConfigFileType from the ConfigFileManager
    99         this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
     98        // We might not even load any bindings at all (KeyDetector for instance)
     99        this->configFile_ = ConfigFileType::NoType;
    100100
    101101        // initialise joy sticks separatly to allow for reloading
     
    187187        for (unsigned int iDev = 0; iDev < numberOfJoySticks_; iDev++)
    188188        {
    189             std::string deviceNumber = convertToString(iDev);
     189            std::string deviceNumber = multi_cast<std::string>(iDev);
    190190            // joy stick buttons
    191191            for (unsigned int i = 0; i < JoyStickButtonCode::numberOfButtons; i++)
     
    249249        if (filename.empty())
    250250            return;
     251
     252        if (this->configFile_ == ConfigFileType::NoType)
     253        {
     254            // Get a new ConfigFileType from the ConfigFileManager
     255            this->configFile_ = ConfigFileManager::getInstance().getNewConfigFileType();
     256        }
    251257
    252258        ConfigFileManager::getInstance().setFilename(this->configFile_, filename);
  • code/trunk/src/network/NetworkPrereqs.h

    r3214 r3280  
    132132    namespace PacketFlag
    133133    {
    134       enum Enum
     134      enum Value
    135135      {
    136136        Reliable   = 1,
  • code/trunk/src/network/packet/Acknowledgement.cc

    r3214 r3280  
    3737#define PACKET_FLAGS_ACK    0
    3838#define _PACKETID           0
    39 #define _ACKID              _PACKETID + sizeof(packet::ENUM::Type)
     39#define _ACKID              _PACKETID + sizeof(packet::Type::Value)
    4040 
    4141Acknowledgement::Acknowledgement( unsigned int id, unsigned int clientID )
     
    4444  flags_ = flags_ | PACKET_FLAGS_ACK;
    4545  data_=new uint8_t[ getSize() ];
    46   *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;
     46  *(Type::Value *)(data_ + _PACKETID ) = Type::Acknowledgement;
    4747  *(uint32_t *)(data_ + _ACKID ) = id;
    4848  clientID_=clientID;
  • code/trunk/src/network/packet/Chat.cc

    r3214 r3280  
    3838#define   PACKET_FLAGS_CHAT PacketFlag::Reliable
    3939#define   _PACKETID         0
    40 const int _PLAYERID     =   _PACKETID + sizeof(ENUM::Type);
     40const int _PLAYERID     =   _PACKETID + sizeof(Type::Value);
    4141#define   _MESSAGELENGTH    _PLAYERID + sizeof(uint32_t)
    4242#define   _MESSAGE          _MESSAGELENGTH + sizeof(uint32_t)
     
    4848  messageLength_ = message.length()+1;
    4949  data_=new unsigned char[ getSize() ];
    50   *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Chat;
     50  *(Type::Value *)(data_ + _PACKETID ) = Type::Chat;
    5151  *(unsigned int *)(data_ + _PLAYERID ) = playerID;
    5252  *(unsigned int *)(data_ + _MESSAGELENGTH ) = messageLength_;
  • code/trunk/src/network/packet/ClassID.cc

    r3214 r3280  
    7474  //set the appropriate packet id
    7575  assert(this->data_);
    76   *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::ClassID;
     76  *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID;
    7777 
    7878  uint8_t *temp=data_+sizeof(uint32_t);
  • code/trunk/src/network/packet/DeleteObjects.cc

    r3214 r3280  
    3939#define PACKET_FLAG_DELETE  PacketFlag::Reliable
    4040#define _PACKETID           0
    41 #define _QUANTITY           _PACKETID + sizeof(ENUM::Type)
     41#define _QUANTITY           _PACKETID + sizeof(Type::Value)
    4242#define _OBJECTIDS          _QUANTITY + sizeof(uint32_t)
    4343 
     
    6262    return false;
    6363  COUT(4) << "sending DeleteObjects: ";
    64   unsigned int size = sizeof(ENUM::Type) + sizeof(uint32_t)*(number+1);
     64  unsigned int size = sizeof(Type::Value) + sizeof(uint32_t)*(number+1);
    6565  data_ = new uint8_t[size];
    6666  uint8_t *tdata = data_;
    67   *reinterpret_cast<ENUM::Type*>(tdata) = ENUM::DeleteObjects;
    68   tdata += sizeof(ENUM::Type);
     67  *reinterpret_cast<Type::Value*>(tdata) = Type::DeleteObjects;
     68  tdata += sizeof(Type::Value);
    6969  *(uint32_t *)tdata = number;
    7070  tdata += sizeof(uint32_t);
  • code/trunk/src/network/packet/FunctionCalls.cc

    r3214 r3280  
    4949  currentMemBlocks_ = 1;
    5050  data_=new uint8_t[ FUNCTIONCALLS_MEM_ALLOCATION ];
    51   *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::FunctionCalls;
     51  *(Type::Value *)(data_ + _PACKETID ) = Type::FunctionCalls;
    5252  *(uint32_t*)(data_+sizeof(uint32_t)) = 0; // set nrOfCalls to 0
    5353}
  • code/trunk/src/network/packet/FunctionIDs.cc

    r3214 r3280  
    6868  //set the appropriate packet id
    6969  assert(this->data_);
    70   *(ENUM::Type *)(this->data_ + _PACKETID ) = ENUM::FunctionIDs;
     70  *(Type::Value *)(this->data_ + _PACKETID ) = Type::FunctionIDs;
    7171 
    7272  uint8_t *temp=data_+sizeof(uint32_t);
  • code/trunk/src/network/packet/Gamestate.h

    r3214 r3280  
    4747class _NetworkExport GamestateHeader{
    4848  public:
    49     GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }
     49    GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = Type::Gamestate; }
    5050    GamestateHeader(uint8_t *data, GamestateHeader* h)
    5151    { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }
  • code/trunk/src/network/packet/Packet.cc

    r3214 r3280  
    6363Packet::Packet(){
    6464  flags_ = PACKET_FLAG_DEFAULT;
    65   packetDirection_ = ENUM::Outgoing;
     65  packetDirection_ = Direction::Outgoing;
    6666  clientID_=0;
    6767  data_=0;
     
    7676Packet::Packet(uint8_t *data, unsigned int clientID){
    7777  flags_ = PACKET_FLAG_DEFAULT;
    78   packetDirection_ = ENUM::Incoming;
     78  packetDirection_ = Direction::Incoming;
    7979  clientID_=clientID;
    8080  data_=data;
     
    125125
    126126bool Packet::send(){
    127   if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){
     127  if(packetDirection_ != Direction::Outgoing && packetDirection_ != Direction::Bidirectional ){
    128128    assert(0);
    129129    return false;
     
    147147  }
    148148#ifndef NDEBUG
    149   switch( *(ENUM::Type *)(data_ + _PACKETID) )
     149  switch( *(Type::Value *)(data_ + _PACKETID) )
    150150  {
    151     case ENUM::Acknowledgement:
    152     case ENUM::Chat:
    153     case ENUM::ClassID:
    154     case ENUM::Gamestate:
    155     case ENUM::Welcome:
    156     case ENUM::DeleteObjects:
    157     case ENUM::FunctionIDs:
    158     case ENUM::FunctionCalls:
     151    case Type::Acknowledgement:
     152    case Type::Chat:
     153    case Type::ClassID:
     154    case Type::Gamestate:
     155    case Type::Welcome:
     156    case Type::DeleteObjects:
     157    case Type::FunctionIDs:
     158    case Type::FunctionCalls:
    159159      break;
    160160    default:
     
    175175  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
    176176  Packet *p = 0;
    177   COUT(6) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
    178   switch( *(ENUM::Type *)(data + _PACKETID) )
     177  COUT(6) << "packet type: " << *(Type::Value *)&data[_PACKETID] << std::endl;
     178  switch( *(Type::Value *)(data + _PACKETID) )
    179179  {
    180     case ENUM::Acknowledgement:
     180    case Type::Acknowledgement:
    181181      COUT(5) << "ack" << std::endl;
    182182      p = new Acknowledgement( data, clientID );
    183183      break;
    184     case ENUM::Chat:
     184    case Type::Chat:
    185185      COUT(5) << "chat" << std::endl;
    186186      p = new Chat( data, clientID );
    187187      break;
    188     case ENUM::ClassID:
     188    case Type::ClassID:
    189189      COUT(5) << "classid" << std::endl;
    190190      p = new ClassID( data, clientID );
    191191      break;
    192     case ENUM::Gamestate:
     192    case Type::Gamestate:
    193193      COUT(5) << "gamestate" << std::endl;
    194194      // TODO: remove brackets
    195195      p = new Gamestate( data, clientID );
    196196      break;
    197     case ENUM::Welcome:
     197    case Type::Welcome:
    198198      COUT(5) << "welcome" << std::endl;
    199199      p = new Welcome( data, clientID );
    200200      break;
    201     case ENUM::DeleteObjects:
     201    case Type::DeleteObjects:
    202202      COUT(5) << "deleteobjects" << std::endl;
    203203      p = new DeleteObjects( data, clientID );
    204204      break;
    205     case ENUM::FunctionCalls:
     205    case Type::FunctionCalls:
    206206      COUT(5) << "functionCalls" << std::endl;
    207207      p = new FunctionCalls( data, clientID );
    208208      break;
    209     case ENUM::FunctionIDs:
     209    case Type::FunctionIDs:
    210210      COUT(5) << "functionIDs" << std::endl;
    211211      p = new FunctionIDs( data, clientID );
  • code/trunk/src/network/packet/Packet.h

    r3214 r3280  
    3636namespace packet{
    3737
    38 namespace ENUM{
    39   enum Direction{
     38namespace Direction{
     39  enum Value{
    4040    Incoming,
    4141    Outgoing,
    4242    Bidirectional
    4343  };
    44   enum Type{
     44}
     45namespace Type{
     46  enum Value{
    4547    Acknowledgement,
    4648    Chat,
     
    8486    uint32_t flags_;
    8587    unsigned int clientID_;
    86     ENUM::Direction packetDirection_;
     88    Direction::Value packetDirection_;
    8789    /** Pointer to the data. Be careful when deleting it because it might
    8890        point to a location that was allocated by ENet.
  • code/trunk/src/network/packet/Welcome.cc

    r3214 r3280  
    4141#define PACKET_FLAGS_CLASSID  PacketFlag::Reliable
    4242#define _PACKETID             0
    43 #define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
     43#define _CLIENTID             _PACKETID + sizeof(Type::Value)
    4444#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
    4545
     
    5151  data_=new uint8_t[ getSize() ];
    5252  assert(data_);
    53   *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
     53  *(packet::Type::Value *)(data_ + _PACKETID ) = packet::Type::Welcome;
    5454  *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID);
    5555  *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
     
    7070
    7171unsigned int Welcome::getSize() const{
    72   return sizeof(packet::ENUM::Type) + 2*sizeof(uint32_t);
     72  return sizeof(packet::Type::Value) + 2*sizeof(uint32_t);
    7373}
    7474
  • code/trunk/src/network/synchronisable/Synchronisable.cc

    r3214 r3280  
    6565    this->dataSize_ = 0;
    6666    // set standard priority
    67     this->setPriority( priority::normal );
     67    this->setPriority( Priority::Normal );
    6868
    6969    // get creator id
  • code/trunk/src/network/synchronisable/Synchronisable.h

    r3214 r3280  
    5151{
    5252
    53   namespace objectDirection{
    54     enum objectdirection{
    55       toclient=0x1,
    56       toserver=0x2,
    57       bidirectional=0x3
     53  namespace ObjectDirection{
     54    enum Value{
     55      ToClient=0x1,
     56      ToServer=0x2,
     57      Bidirectional=0x3
    5858    };
    5959  }
    6060
    61   namespace priority{
    62     enum prio{
    63       very_high   = -100,
    64       high        = -15,
    65       normal      = 0,
    66       low         = 15,
    67       very_low    = 100
     61  namespace Priority{
     62    enum Value{
     63      VeryHigh    = -100,
     64      High        = -15,
     65      Normal      = 0,
     66      Low         = 15,
     67      VeryLow     = 100
    6868    };
    6969  }
  • code/trunk/src/network/synchronisable/SynchronisableVariable.h

    r3214 r3280  
    4141namespace orxonox{
    4242 
    43   namespace variableDirection{
    44     enum syncdirection{
    45       toclient=0x1,
    46       toserver=0x2
     43  namespace VariableDirection{
     44    enum Value{
     45      ToClient=0x1,
     46      ToServer=0x2
    4747    };
    48     enum bidirectional{
    49       serverMaster=0x1,
    50       clientMaster=0x2
     48  }
     49  namespace Bidirectionality{
     50    enum Value{
     51      ServerMaster=0x1,
     52      ClientMaster=0x2
    5153    };
    5254  }
     
    6971  {
    7072    public:
    71       SynchronisableVariable(T& variable, uint8_t syncDirection=variableDirection::toclient, NetworkCallbackBase *cb=0);
     73      SynchronisableVariable(T& variable, uint8_t syncDirection=VariableDirection::ToClient, NetworkCallbackBase *cb=0);
    7274      virtual ~SynchronisableVariable();
    7375
     
    8890  {
    8991    public:
    90       SynchronisableVariableBidirectional(T& variable, uint8_t master=variableDirection::serverMaster, NetworkCallbackBase *cb=0);
     92      SynchronisableVariableBidirectional(T& variable, uint8_t master=Bidirectionality::ServerMaster, NetworkCallbackBase *cb=0);
    9193      virtual ~SynchronisableVariableBidirectional();
    9294     
  • code/trunk/src/orxonox/CMakeLists.txt

    r3204 r3280  
    4242  FIND_HEADER_FILES
    4343  TOLUA_FILES
     44    LevelManager.h
    4445    gui/GUIManager.h
    4546    objects/pickup/BaseItem.h
  • code/trunk/src/orxonox/CameraManager.cc

    r3196 r3280  
    3232#include <OgreCompositorManager.h>
    3333
    34 #include "util/String.h"
     34#include "util/StringUtils.h"
    3535#include "core/GameMode.h"
    3636#include "core/ObjectList.h"
  • code/trunk/src/orxonox/GraphicsManager.cc

    r3196 r3280  
    3838#include <fstream>
    3939#include <boost/filesystem.hpp>
     40#include <boost/shared_ptr.hpp>
    4041
    4142#include <OgreCompositorManager.h>
     
    5354#include "SpecialConfig.h"
    5455#include "util/Exception.h"
    55 #include "util/String.h"
     56#include "util/StringUtils.h"
    5657#include "util/SubString.h"
    5758#include "core/Clock.h"
     
    7071namespace orxonox
    7172{
     73    using boost::shared_ptr;
     74
    7275    class _OrxonoxExport OgreWindowEventListener : public Ogre::WindowEventListener
    7376    {
     
    8992        , renderWindow_(0)
    9093        , viewport_(0)
    91         , ogreWindowEventListener_(0)
     94        , ogreWindowEventListener_(new OgreWindowEventListener())
    9295    {
    9396        RegisterObject(GraphicsManager);
     
    9699        singletonRef_s = this;
    97100
    98         this->loaded_ = false;
    99 
    100101        this->setConfigValues();
    101     }
    102 
    103     void GraphicsManager::initialise()
    104     {
     102
    105103        // Ogre setup procedure
    106104        setupOgre();
    107         // load all the required plugins for Ogre
    108         loadOgrePlugins();
    109         // read resource declaration file
    110         this->declareResources();
    111         // Reads ogre config and creates the render window
    112         this->loadRenderer();
    113 
    114         // TODO: Spread this
    115         this->initialiseResources();
    116 
    117         // add console commands
    118         FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
    119         functor1->setObject(this);
    120         ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
    121         CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
    122 
    123         this->loaded_ = true;
     105
     106        try
     107        {
     108            // load all the required plugins for Ogre
     109            loadOgrePlugins();
     110            // read resource declaration file
     111            this->declareResources();
     112            // Reads ogre config and creates the render window
     113            this->loadRenderer();
     114
     115            // TODO: Spread this
     116            this->initialiseResources();
     117
     118            // add console commands
     119            FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
     120            functor1->setObject(this);
     121            ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
     122            CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
     123        }
     124        catch (...)
     125        {
     126            // clean up
     127            delete this->ogreRoot_;
     128            delete this->ogreLogger_;
     129            delete this->ogreWindowEventListener_;
     130            throw;
     131        }
    124132    }
    125133
     
    130138    GraphicsManager::~GraphicsManager()
    131139    {
    132         if (this->loaded_)
    133         {
    134             delete this->ccPrintScreen_;
    135 
    136             if (this->ogreWindowEventListener_)
    137             {
    138                 // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
    139                 Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this->ogreWindowEventListener_);
    140                 delete this->ogreWindowEventListener_;
    141             }
    142 
    143             // destroy render window
    144 //            Ogre::RenderSystem* renderer = this->ogreRoot_->getRenderSystem();
    145 //            renderer->destroyRenderWindow("Orxonox");
    146 
    147             // HACK! This fixes an exit crash
    148             Map::hackDestroyMap();
    149 
    150             // unload all compositors
    151             Ogre::CompositorManager::getSingleton().removeAll();
    152 
    153             // Delete OGRE main control organ
    154             delete this->ogreRoot_;
    155 
    156             // delete the ogre log and the logManager (since we have created it in the first place).
    157             this->ogreLogger_->getDefaultLog()->removeListener(this);
    158             this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    159             delete this->ogreLogger_;
    160         }
     140/*
     141        delete this->ccPrintScreen_;
     142*/
     143
     144        // HACK! This fixes an exit crash
     145        Map::hackDestroyMap();
     146        // unload all compositors (this is only necessary because we don't yet destroy all resources!)
     147        Ogre::CompositorManager::getSingleton().removeAll();
     148
     149        // Delete OGRE main control organ
     150        delete this->ogreRoot_;
     151
     152        // delete the logManager (since we have created it in the first place).
     153        delete this->ogreLogger_;
     154
     155        delete this->ogreWindowEventListener_;
    161156
    162157        assert(singletonRef_s);
     
    194189    void GraphicsManager::update(const Clock& time)
    195190    {
    196         if (this->loaded_)
    197         {
    198             Ogre::FrameEvent evt;
    199             evt.timeSinceLastFrame = time.getDeltaTime();
    200             evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway
    201 
    202             // don't forget to call _fireFrameStarted to OGRE to make sure
    203             // everything goes smoothly
    204             ogreRoot_->_fireFrameStarted(evt);
    205 
    206             // Pump messages in all registered RenderWindows
    207             // This calls the WindowEventListener objects.
    208             Ogre::WindowEventUtilities::messagePump();
    209             // make sure the window stays active even when not focused
    210             // (probably only necessary on windows)
    211             this->renderWindow_->setActive(true);
    212 
    213             // render
    214             ogreRoot_->_updateAllRenderTargets();
    215 
    216             // again, just to be sure OGRE works fine
    217             ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
    218         }
     191        Ogre::FrameEvent evt;
     192        evt.timeSinceLastFrame = time.getDeltaTime();
     193        evt.timeSinceLastEvent = time.getDeltaTime(); // note: same time, but shouldn't matter anyway
     194
     195        // don't forget to call _fireFrameStarted to OGRE to make sure
     196        // everything goes smoothly
     197        ogreRoot_->_fireFrameStarted(evt);
     198
     199        // Pump messages in all registered RenderWindows
     200        // This calls the WindowEventListener objects.
     201        Ogre::WindowEventUtilities::messagePump();
     202        // make sure the window stays active even when not focused
     203        // (probably only necessary on windows)
     204        this->renderWindow_->setActive(true);
     205
     206        // render
     207        ogreRoot_->_updateAllRenderTargets();
     208
     209        // again, just to be sure OGRE works fine
     210        ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
    219211    }
    220212
     
    248240        // create a new logManager
    249241        // Ogre::Root will detect that we've already created a Log
    250         ogreLogger_ = new Ogre::LogManager();
     242        std::auto_ptr<Ogre::LogManager> logger(new Ogre::LogManager());
    251243        COUT(4) << "Ogre LogManager created" << std::endl;
    252244
    253245        // create our own log that we can listen to
    254246        Ogre::Log *myLog;
    255         myLog = ogreLogger_->createLog(ogreLogFilepath.string(), true, false, false);
     247        myLog = logger->createLog(ogreLogFilepath.string(), true, false, false);
    256248        COUT(4) << "Ogre Log created" << std::endl;
    257249
     
    272264        // Leave plugins file empty. We're going to do that part manually later
    273265        ogreRoot_ = new Ogre::Root("", ogreConfigFilepath.string(), ogreLogFilepath.string());
     266        // In case that new Root failed the logger gets destroyed because of the std::auto_ptr
     267        ogreLogger_ = logger.release();
    274268
    275269        COUT(3) << "Ogre set up done." << std::endl;
     
    348342        if (!ogreRoot_->restoreConfig())
    349343            if (!ogreRoot_->showConfigDialog())
    350                 ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
     344                ThrowException(InitialisationFailed, "OGRE graphics configuration dialogue failed.");
    351345
    352346        CCOUT(4) << "Creating render window" << std::endl;
     
    354348        this->renderWindow_ = ogreRoot_->initialise(true, "Orxonox");
    355349
    356         this->ogreWindowEventListener_ = new OgreWindowEventListener();
    357350        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, ogreWindowEventListener_);
    358351
  • code/trunk/src/orxonox/GraphicsManager.h

    r3196 r3280  
    5757
    5858        void setConfigValues();
    59         void initialise();
    6059
    6160        void update(const Clock& time);
     
    9392
    9493    private:
    95         bool                loaded_;
    96 
    9794        Ogre::Root*         ogreRoot_;                 //!< Ogre's root
    9895        Ogre::LogManager*   ogreLogger_;
    9996        Ogre::RenderWindow* renderWindow_;             //!< the one and only render window
    10097        Ogre::Viewport*     viewport_;                 //!< default full size viewport
    101         OgreWindowEventListener* ogreWindowEventListener_;
     98        OgreWindowEventListener* ogreWindowEventListener_; //!< Pimpl to hide OgreWindowUtilities.h
    10299
    103100        // config values
  • code/trunk/src/orxonox/LevelManager.cc

    r3196 r3280  
    3030
    3131#include <map>
     32
     33#include "core/CommandLine.h"
     34#include "core/ConfigValueIncludes.h"
     35#include "core/CoreIncludes.h"
    3236#include "PlayerManager.h"
    3337#include "objects/Level.h"
     
    3640namespace orxonox
    3741{
     42    SetCommandLineArgument(level, "").shortcut("l").information("Default level file (overrides LevelManager::defaultLevelName_ configValue)");
     43
    3844    LevelManager* LevelManager::singletonRef_s = 0;
    3945
     
    4248        assert(singletonRef_s == 0);
    4349        singletonRef_s = this;
     50
     51        RegisterRootObject(LevelManager);
     52        this->setConfigValues();
     53
     54        // check override
     55        if (!CommandLine::getArgument("level")->hasDefaultValue())
     56        {
     57            ModifyConfigValue(defaultLevelName_, tset, CommandLine::getValue("level").getString());
     58        }
    4459    }
    4560
     
    4863        assert(singletonRef_s != 0);
    4964        singletonRef_s = 0;
     65    }
     66
     67    void LevelManager::setConfigValues()
     68    {
     69        SetConfigValue(defaultLevelName_, "presentation_dm.oxw")
     70            .description("Sets the preselection of the level in the main menu.");
    5071    }
    5172
     
    93114        }
    94115    }
     116
     117    void LevelManager::setDefaultLevel(const std::string& levelName)
     118    {
     119        ModifyConfigValue(defaultLevelName_, set, levelName);
     120    }
     121
     122    const std::string& LevelManager::getDefaultLevel()
     123    {
     124        return defaultLevelName_;
     125    }
    95126}
  • code/trunk/src/orxonox/LevelManager.h

    r3196 r3280  
    3434#include <cassert>
    3535#include <list>
     36#include "core/OrxonoxClass.h"
    3637
     38// tolua_begin
    3739namespace orxonox
    3840{
    3941    class _OrxonoxExport LevelManager
    40     {
     42    // tolua_end
     43        : public OrxonoxClass
     44    { // tolua_export
    4145        public:
    4246            LevelManager();
    4347            virtual ~LevelManager();
     48
     49            void setConfigValues();
    4450
    4551            void requestActivity(Level* level);
     
    4753            Level* getActiveLevel();
    4854
     55            void setDefaultLevel(const std::string& levelName); //tolua_export
     56            const std::string& getDefaultLevel(); //tolua_export
     57
    4958            static LevelManager* getInstancePtr() { return singletonRef_s; }
    50             static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
     59            static LevelManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
    5160
    5261        private:
     
    5766            std::list<Level*> levels_s;
    5867
     68            // config values
     69            std::string defaultLevelName_;
     70
    5971            static LevelManager* singletonRef_s;
    60     };
    61 }
     72    }; // tolua_export
     73} // tolua_export
    6274
    6375#endif /* _LevelManager_H__ */
  • code/trunk/src/orxonox/Main.cc

    r3196 r3280  
    3737
    3838#include "util/Debug.h"
    39 #include "core/Identifier.h"
     39#include "util/Exception.h"
    4040#include "core/Game.h"
    4141
     
    5050#endif
    5151{
     52    using namespace orxonox;
     53
     54    Game* game = 0;
     55    try
    5256    {
    53         orxonox::Game orxonox(argc, argv);
     57        game = new Game(argc, argv);
    5458
    55         orxonox.setStateHierarchy(
     59        game->setStateHierarchy(
    5660        "root"
    5761        " graphics"
     
    6872        );
    6973
    70         orxonox.run();
     74        game->requestState("root");
     75    }
     76    catch (const std::exception& ex)
     77    {
     78        COUT(0) << "Orxonox failed to initialise: " << ex.what() << std::endl;
     79        COUT(0) << "Terminating program." << std::endl;
     80        return 1;
     81    }
     82    catch (...)
     83    {
     84        COUT(0) << "Orxonox failed to initialise: " << std::endl;
     85        COUT(0) << "Terminating program." << std::endl;
     86        return 1;
     87    }
    7188
    72         // destroy the GameStates created pre-mainly
    73         orxonox::Game::destroyStates();
    74     } // orxonox gets destroyed right here!
    75 
    76     // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
    77     // Needs to be done after Game destructor because of ~OrxonoxClass
    78     orxonox::Identifier::destroyAllIdentifiers();
     89    game->run();
     90    delete game;
    7991
    8092    return 0;
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r3196 r3280  
    6565    namespace LODParticle
    6666    {
    67         enum LOD
     67        enum Value
    6868        {
    69             off = 0,
    70             low = 1,
    71             normal = 2,
    72             high = 3
     69            Off = 0,
     70            Low = 1,
     71            Normal = 2,
     72            High = 3
    7373        };
    7474    }
     
    295295{
    296296    class DefaultLogger;
     297    class Logger;
    297298    class LuaScriptModule;
    298299
  • code/trunk/src/orxonox/gamestates/GSClient.cc

    r3196 r3280  
    3838namespace orxonox
    3939{
    40     AddGameState(GSClient, "client");
     40    DeclareGameState(GSClient, "client", false, true);
    4141
    42     SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
     42    SetCommandLineArgument(ip, "127.0.0.1").information("Sever IP as strin in the form #.#.#.#");
    4343
    44     GSClient::GSClient(const std::string& name)
    45         : GameState(name)
     44    GSClient::GSClient(const GameStateConstrParams& params)
     45        : GameState(params)
    4646        , client_(0)
    4747    {
  • code/trunk/src/orxonox/gamestates/GSClient.h

    r3196 r3280  
    4040    {
    4141    public:
    42         GSClient(const std::string& name);
     42        GSClient(const GameStateConstrParams& params);
    4343        ~GSClient();
    4444
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r3205 r3280  
    5151    const unsigned int MAX_COMMAND_LENGTH = 255;
    5252   
    53     AddGameState(GSDedicated, "dedicated");
     53    DeclareGameState(GSDedicated, "dedicated", false, false);
    5454   
    5555    termios* GSDedicated::originalTerminalSettings_;
    5656
    57     GSDedicated::GSDedicated(const std::string& name)
    58         : GameState(name)
     57    GSDedicated::GSDedicated(const GameStateConstrParams& params)
     58        : GameState(params)
    5959        , server_(0)
    6060        , timeSinceLastUpdate_(0)
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r3198 r3280  
    4848    {
    4949    public:
    50         GSDedicated(const std::string& name);
     50        GSDedicated(const GameStateConstrParams& params);
    5151        ~GSDedicated();
    5252
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r3196 r3280  
    5757namespace orxonox
    5858{
    59     AddGameState(GSGraphics, "graphics", false);
    60 
    61     GSGraphics::GSGraphics(const std::string& name, bool countTickTime)
    62         : GameState(name, countTickTime)
     59    DeclareGameState(GSGraphics, "graphics", true, true);
     60
     61    GSGraphics::GSGraphics(const GameStateConstrParams& params)
     62        : GameState(params)
    6363        , inputManager_(0)
    6464        , console_(0)
     
    108108        setConfigValues();
    109109
    110         // initialise graphics manager. Doesn't load the render window yet!
     110        // Load OGRE including the render window
    111111        this->graphicsManager_ = new GraphicsManager();
    112         this->graphicsManager_->initialise();
    113112
    114113        // load debug overlay
     
    198197    void GSGraphics::toggleGUI()
    199198    {
    200             GUIManager::getInstance().executeCode("toggleGUI()");
     199        GUIManager::getInstance().executeCode("toggleGUI()");
    201200    }
    202201
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r3196 r3280  
    5252    {
    5353    public:
    54         GSGraphics(const std::string& name, bool countTickTime);
     54        GSGraphics(const GameStateConstrParams& params);
    5555        ~GSGraphics();
    5656        void setConfigValues();
  • code/trunk/src/orxonox/gamestates/GSIOConsole.cc

    r3196 r3280  
    3636namespace orxonox
    3737{
    38     AddGameState(GSIOConsole, "ioConsole");
     38    DeclareGameState(GSIOConsole, "ioConsole", false, false);
    3939
    40     GSIOConsole::GSIOConsole(const std::string& name)
    41         : GameState(name)
     40    GSIOConsole::GSIOConsole(const GameStateConstrParams& params)
     41        : GameState(params)
    4242    {
    4343    }
  • code/trunk/src/orxonox/gamestates/GSIOConsole.h

    r2896 r3280  
    3838    {
    3939    public:
    40         GSIOConsole(const std::string& name);
     40        GSIOConsole(const GameStateConstrParams& params);
    4141        ~GSIOConsole();
    4242
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r3196 r3280  
    3434#include "core/input/KeyBinder.h"
    3535#include "core/Clock.h"
    36 #include "core/CommandLine.h"
    3736#include "core/ConsoleCommand.h"
    3837#include "core/ConfigValueIncludes.h"
     
    5655namespace orxonox
    5756{
    58     AddGameState(GSLevel, "level");
    59 
    60     SetCommandLineArgument(level, "").shortcut("l");
     57    DeclareGameState(GSLevel, "level", false, true);
    6158    SetConsoleCommand(GSLevel, showIngameGUI, true);
    6259
    6360    XMLFile* GSLevel::startFile_s = NULL;
    6461
    65     GSLevel::GSLevel(const std::string& name)
    66         : GameState(name)
     62    GSLevel::GSLevel(const GameStateConstrParams& params)
     63        : GameState(params)
    6764        , keyBinder_(0)
    6865        , gameInputState_(0)
     
    7168        , radar_(0)
    7269        , cameraManager_(0)
    73         , levelManager_(0)
    7470    {
    7571        RegisterObject(GSLevel);
     
    120116        if (GameMode::isMaster())
    121117        {
    122             // create the global LevelManager
    123             this->levelManager_ = new LevelManager();
    124 
    125118            this->loadLevel();
    126119        }
     
    202195        }
    203196
    204         if (this->levelManager_)
    205         {
    206             delete this->levelManager_;
    207             this->levelManager_ = 0;
    208         }
    209 
    210197        if (this->playerManager_)
    211198        {
     
    252239        // call the loader
    253240        COUT(0) << "Loading level..." << std::endl;
    254         std::string levelName;
    255         CommandLine::getValue("level", &levelName);
    256         if (levelName == "")
    257             startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + Game::getInstance().getLevel());
    258         else
    259             startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + levelName);
     241        startFile_s = new XMLFile(Core::getMediaPathString() + "levels" + '/' + LevelManager::getInstance().getDefaultLevel());
    260242        Loader::open(startFile_s);
    261243    }
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r3196 r3280  
    4141    {
    4242    public:
    43         GSLevel(const std::string& name);
     43        GSLevel(const GameStateConstrParams& params);
    4444        ~GSLevel();
    4545        void setConfigValues();
     
    6868        Radar*                radar_;                   //!< represents the Radar (not the HUD part)
    6969        CameraManager*        cameraManager_;           //!< camera manager for this level
    70         LevelManager*         levelManager_;            //!< global level manager
    7170        PlayerManager*        playerManager_;           //!< player manager for this level
    7271        QuestManager*         questManager_;
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r3196 r3280  
    4343namespace orxonox
    4444{
    45     AddGameState(GSMainMenu, "mainMenu");
     45    DeclareGameState(GSMainMenu, "mainMenu", false, true);
    4646
    47     GSMainMenu::GSMainMenu(const std::string& name)
    48         : GameState(name)
     47    GSMainMenu::GSMainMenu(const GameStateConstrParams& params)
     48        : GameState(params)
    4949        , inputState_(0)
    5050    {
     
    6767
    6868        // show main menu
    69         GUIManager::getInstance().showGUI("mainmenu_2");
     69        GUIManager::getInstance().showGUI("mainmenu_3");
    7070        GUIManager::getInstance().setCamera(this->camera_);
    7171        GraphicsManager::getInstance().setCamera(this->camera_);
  • code/trunk/src/orxonox/gamestates/GSMainMenu.h

    r3196 r3280  
    4040    {
    4141    public:
    42         GSMainMenu(const std::string& name);
     42        GSMainMenu(const GameStateConstrParams& params);
    4343        ~GSMainMenu();
    4444
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r3196 r3280  
    3737#include "interfaces/TimeFactorListener.h"
    3838#include "interfaces/Tickable.h"
     39#include "LevelManager.h"
    3940
    4041namespace orxonox
    4142{
    42     AddGameState(GSRoot, "root", false);
    43     SetCommandLineSwitch(console);
     43    DeclareGameState(GSRoot, "root", true, false);
     44    SetCommandLineSwitch(console).information("Start in console mode (text IO only)");
    4445    // Shortcuts for easy direct loading
    45     SetCommandLineSwitch(server);
    46     SetCommandLineSwitch(client);
    47     SetCommandLineSwitch(dedicated);
    48     SetCommandLineSwitch(standalone);
    49 
    50     GSRoot::GSRoot(const std::string& name, bool countTickTime)
    51         : GameState(name, countTickTime)
     46    SetCommandLineSwitch(server).information("Start in server mode");
     47    SetCommandLineSwitch(client).information("Start in client mode");
     48    SetCommandLineSwitch(dedicated).information("Start in dedicated server mode");
     49    SetCommandLineSwitch(standalone).information("Start in standalone mode");
     50
     51    GSRoot::GSRoot(const GameStateConstrParams& params)
     52        : GameState(params)
    5253        , timeFactor_(1.0f)
    5354        , bPaused_(false)
     
    8384        }
    8485
     86        // create the global LevelManager
     87        this->levelManager_ = new LevelManager();
     88
    8589        // Load level directly?
    8690        bool loadLevel = false;
     
    129133        }
    130134*/
     135
     136        delete this->levelManager_;
    131137    }
    132138
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r3196 r3280  
    3838    {
    3939    public:
    40         GSRoot(const std::string& name, bool countTickTime);
     40        GSRoot(const GameStateConstrParams& params);
    4141        ~GSRoot();
    4242
     
    5252
    5353    private:
    54         float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
     54        float                 timeFactor_;              //!< A factor that sets the gamespeed. 1 is normal.
    5555        bool                  bPaused_;
    5656        float                 timeFactorPauseBackup_;
     57
     58        LevelManager*         levelManager_;            //!< global level manager
    5759
    5860        // console commands
  • code/trunk/src/orxonox/gamestates/GSServer.cc

    r3196 r3280  
    3737namespace orxonox
    3838{
    39     AddGameState(GSServer, "server");
     39    DeclareGameState(GSServer, "server", false, true);
    4040
    41     SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
     41    SetCommandLineArgument(port, 55556).shortcut("p").information("Network communication port to be used 0-65535 (default: 55556)");
    4242
    43     GSServer::GSServer(const std::string& name)
    44         : GameState(name)
     43    GSServer::GSServer(const GameStateConstrParams& params)
     44        : GameState(params)
    4545        , server_(0)
    4646    {
  • code/trunk/src/orxonox/gamestates/GSServer.h

    r3196 r3280  
    4040    {
    4141    public:
    42         GSServer(const std::string& name);
     42        GSServer(const GameStateConstrParams& params);
    4343        ~GSServer();
    4444
  • code/trunk/src/orxonox/gamestates/GSStandalone.cc

    r3196 r3280  
    3434namespace orxonox
    3535{
    36     AddGameState(GSStandalone, "standalone");
     36    DeclareGameState(GSStandalone, "standalone", false, true);
    3737
    38     GSStandalone::GSStandalone(const std::string& name)
    39         : GameState(name)
     38    GSStandalone::GSStandalone(const GameStateConstrParams& params)
     39        : GameState(params)
    4040    {
    4141    }
  • code/trunk/src/orxonox/gamestates/GSStandalone.h

    r2896 r3280  
    3838    {
    3939    public:
    40         GSStandalone(const std::string& name);
     40        GSStandalone(const GameStateConstrParams& params);
    4141        ~GSStandalone();
    4242
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r3196 r3280  
    5353#endif
    5454
     55#include "util/Debug.h"
    5556#include "util/Exception.h"
     57#include "util/OrxAssert.h"
    5658#include "core/Core.h"
    5759#include "core/Clock.h"
     
    6264namespace orxonox
    6365{
     66    class CEGUILogger : public CEGUI::DefaultLogger
     67    {
     68    public:
     69            void logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level = CEGUI::Standard)
     70        {
     71            int orxonoxLevel;
     72            switch (level)
     73            {
     74                case CEGUI::Errors:      orxonoxLevel = 1; break;
     75                case CEGUI::Warnings:    orxonoxLevel = 2; break;
     76                case CEGUI::Standard:    orxonoxLevel = 4; break;
     77                case CEGUI::Informative: orxonoxLevel = 5; break;
     78                case CEGUI::Insane:      orxonoxLevel = 6; break;
     79                default: OrxAssert(false, "CEGUI log level out of range, inpect immediately!");
     80            }
     81            OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
     82                << "CEGUI: " << message << std::endl;
     83
     84            CEGUI::DefaultLogger::logEvent(message, level);
     85        }
     86    };
     87
    6488    static CEGUI::MouseButton convertButton(MouseButtonCode::ByEnum button);
    6589    GUIManager* GUIManager::singletonRef_s = 0;
     
    140164
    141165                // Create our own logger to specify the filepath
    142                 this->ceguiLogger_ = new DefaultLogger();
     166                this->ceguiLogger_ = new CEGUILogger();
    143167                this->ceguiLogger_->setLogFilename(Core::getLogPathString() + "cegui.log");
    144168                // set the log level according to ours (translate by subtracting 1)
  • code/trunk/src/orxonox/gui/GUIManager.h

    r3196 r3280  
    123123        CEGUI::ResourceProvider*    resourceProvider_;  //!< CEGUI's resource provider
    124124        CEGUI::LuaScriptModule*     scriptModule_;      //!< CEGUI's script module to use Lua
    125         CEGUI::DefaultLogger*       ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
     125        CEGUI::Logger*              ceguiLogger_;       //!< CEGUI's logger to be able to log CEGUI errors in our log
    126126        CEGUI::System*              guiSystem_;         //!< CEGUI's main system
    127127        lua_State*                  luaState_;          //!< Lua state, access point to the Lua engine
  • code/trunk/src/orxonox/interfaces/RadarViewable.cc

    r3196 r3280  
    3333#include <OgreEntity.h>
    3434
    35 #include "util/String.h"
     35#include "util/StringUtils.h"
    3636#include "core/CoreIncludes.h"
    3737#include "tools/DynamicLines.h"
  • code/trunk/src/orxonox/interfaces/TeamColourable.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/GlobalShader.cc

    r3196 r3280  
    6666    void GlobalShader::registerVariables()
    6767    {
    68         registerVariable(this->bVisible_,                                         variableDirection::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
    69         registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), variableDirection::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
     68        registerVariable(this->bVisible_,                                         VariableDirection::ToClient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));
     69        registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), VariableDirection::ToClient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));
    7070    }
    7171
  • code/trunk/src/orxonox/objects/Level.cc

    r3196 r3280  
    8787    void Level::registerVariables()
    8888    {
    89         registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
    90         registerVariable(this->name_,        variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName));
    91         registerVariable(this->description_, variableDirection::toclient);
     89        registerVariable(this->xmlfilename_, VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
     90        registerVariable(this->name_,        VariableDirection::ToClient, new NetworkCallback<Level>(this, &Level::changedName));
     91        registerVariable(this->description_, VariableDirection::ToClient);
    9292    }
    9393
  • code/trunk/src/orxonox/objects/Scene.cc

    r3196 r3280  
    115115    void Scene::registerVariables()
    116116    {
    117         registerVariable(this->skybox_,             variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
    118         registerVariable(this->ambientLight_,       variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
    119         registerVariable(this->negativeWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange));
    120         registerVariable(this->positiveWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange));
    121         registerVariable(this->gravity_,            variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
    122         registerVariable(this->bHasPhysics_,        variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
    123         registerVariable(this->bShadows_,           variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
     117        registerVariable(this->skybox_,             VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
     118        registerVariable(this->ambientLight_,       VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
     119        registerVariable(this->negativeWorldRange_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange));
     120        registerVariable(this->positiveWorldRange_, VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange));
     121        registerVariable(this->gravity_,            VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
     122        registerVariable(this->bHasPhysics_,        VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
     123        registerVariable(this->bShadows_,           VariableDirection::ToClient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
    124124    }
    125125
  • code/trunk/src/orxonox/objects/collisionshapes/BoxCollisionShape.cc

    r3196 r3280  
    5757    void BoxCollisionShape::registerVariables()
    5858    {
    59         registerVariable(this->halfExtents_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     59        registerVariable(this->halfExtents_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
    6060    }
    6161
  • code/trunk/src/orxonox/objects/collisionshapes/CollisionShape.cc

    r3196 r3280  
    7777    void CollisionShape::registerVariables()
    7878    {
    79         registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
     79        registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
    8080    }
    8181
  • code/trunk/src/orxonox/objects/collisionshapes/ConeCollisionShape.cc

    r3196 r3280  
    5757    void ConeCollisionShape::registerVariables()
    5858    {
    59         registerVariable(this->radius_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
    60         registerVariable(this->height_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     59        registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     60        registerVariable(this->height_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
    6161    }
    6262
  • code/trunk/src/orxonox/objects/collisionshapes/PlaneCollisionShape.cc

    r3196 r3280  
    5858    void PlaneCollisionShape::registerVariables()
    5959    {
    60         registerVariable(this->normal_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
    61         registerVariable(this->offset_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     60        registerVariable(this->normal_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     61        registerVariable(this->offset_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
    6262    }
    6363
  • code/trunk/src/orxonox/objects/collisionshapes/SphereCollisionShape.cc

    r3196 r3280  
    5656    void SphereCollisionShape::registerVariables()
    5757    {
    58         registerVariable(this->radius_, variableDirection::toclient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
     58        registerVariable(this->radius_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::updateShape));
    5959    }
    6060
  • code/trunk/src/orxonox/objects/controllers/ArtificialController.cc

    r3196 r3280  
    208208            switch (base->getState())
    209209            {
    210                 case BaseState::controlTeam1:
     210                case BaseState::ControlTeam1:
    211211                    team1 = 0;
    212212                    break;
    213                 case BaseState::controlTeam2:
     213                case BaseState::ControlTeam2:
    214214                    team1 = 1;
    215215                    break;
    216                 case BaseState::uncontrolled:
     216                case BaseState::Uncontrolled:
    217217                default:
    218218                    team1 = -1;
     
    224224            switch (base->getState())
    225225            {
    226                 case BaseState::controlTeam1:
     226                case BaseState::ControlTeam1:
    227227                    team2 = 0;
    228228                    break;
    229                 case BaseState::controlTeam2:
     229                case BaseState::ControlTeam2:
    230230                    team2 = 1;
    231231                    break;
    232                 case BaseState::uncontrolled:
     232                case BaseState::Uncontrolled:
    233233                default:
    234234                    team2 = -1;
  • code/trunk/src/orxonox/objects/gametypes/Gametype.h

    r3196 r3280  
    4545    namespace PlayerState
    4646    {
    47         enum Enum
     47        enum Value
    4848        {
    4949            Uninitialized,
     
    5757    {
    5858        PlayerInfo* info_;
    59         PlayerState::Enum state_;
     59        PlayerState::Value state_;
    6060        int frags_;
    6161        int killed_;
  • code/trunk/src/orxonox/objects/gametypes/TeamBaseMatch.cc

    r3196 r3280  
    6666                if (teamnr == 0)
    6767                {
    68                     base->setState(BaseState::controlTeam1);
     68                    base->setState(BaseState::ControlTeam1);
    6969                    this->gtinfo_.sendAnnounceMessage("The red team captured a base");
    7070                }
    7171                if (teamnr == 1)
    7272                {
    73                     base->setState(BaseState::controlTeam2);
     73                    base->setState(BaseState::ControlTeam2);
    7474                    this->gtinfo_.sendAnnounceMessage("The blue team captured a base");
    7575                }
     
    107107            switch (base->getState())
    108108            {
    109                 case BaseState::controlTeam1:
     109                case BaseState::ControlTeam1:
    110110                    teamnrbase = 0;
    111111                    break;
    112                 case BaseState::controlTeam2:
     112                case BaseState::ControlTeam2:
    113113                    teamnrbase = 1;
    114114                    break;
    115                 case BaseState::uncontrolled:
     115                case BaseState::Uncontrolled:
    116116                default:
    117117                    teamnrbase = -1;
     
    155155        for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
    156156        {
    157             if((*it)->getState() == BaseState::controlTeam1)
     157            if((*it)->getState() == BaseState::ControlTeam1)
    158158            {
    159159                amountControlled++;
    160160            }
    161             if((*it)->getState() == BaseState::controlTeam2)
     161            if((*it)->getState() == BaseState::ControlTeam2)
    162162            {
    163163                amountControlled2++;
     
    241241        for (std::set<TeamBaseMatchBase*>::const_iterator it = this->bases_.begin(); it != this->bases_.end(); ++it)
    242242        {
    243             if ((*it)->getState() == BaseState::controlTeam1 && team == 0)
     243            if ((*it)->getState() == BaseState::ControlTeam1 && team == 0)
    244244                count++;
    245             if ((*it)->getState() == BaseState::controlTeam2 && team == 1)
     245            if ((*it)->getState() == BaseState::ControlTeam2 && team == 1)
    246246                count++;
    247247        }
     
    253253    {
    254254        this->bases_.insert(base);
    255         base->setState(BaseState::uncontrolled);
     255        base->setState(BaseState::Uncontrolled);
    256256    }
    257257
  • code/trunk/src/orxonox/objects/gametypes/UnderAttack.cc

    r3196 r3280  
    173173            if ( gameTime_ <= timesequence_ && gameTime_ > 0)
    174174            {
    175                 std::string message = convertToString(timesequence_) + " seconds left!";
     175                std::string message = multi_cast<std::string>(timesequence_) + " seconds left!";
    176176/*
    177177                COUT(0) << message << std::endl;
  • code/trunk/src/orxonox/objects/infos/GametypeInfo.cc

    r3196 r3280  
    6161    void GametypeInfo::registerVariables()
    6262    {
    63         registerVariable(this->bStarted_,               variableDirection::toclient);
    64         registerVariable(this->bEnded_,                 variableDirection::toclient);
    65         registerVariable(this->startCountdown_,         variableDirection::toclient);
    66         registerVariable(this->bStartCountdownRunning_, variableDirection::toclient);
    67         registerVariable(this->hudtemplate_,            variableDirection::toclient);
     63        registerVariable(this->bStarted_,               VariableDirection::ToClient);
     64        registerVariable(this->bEnded_,                 VariableDirection::ToClient);
     65        registerVariable(this->startCountdown_,         VariableDirection::ToClient);
     66        registerVariable(this->bStartCountdownRunning_, VariableDirection::ToClient);
     67        registerVariable(this->hudtemplate_,            VariableDirection::ToClient);
    6868    }
    6969
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.cc

    r3196 r3280  
    7979    void HumanPlayer::registerVariables()
    8080    {
    81         registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
     81        registerVariable(this->synchronize_nick_, VariableDirection::ToServer, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
    8282
    83         registerVariable(this->clientID_,           variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
    84         registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
    85         registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
     83        registerVariable(this->clientID_,           VariableDirection::ToClient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
     84        registerVariable(this->server_initialized_, VariableDirection::ToClient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
     85        registerVariable(this->client_initialized_, VariableDirection::ToServer, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
    8686    }
    8787
     
    116116
    117117            if (!GameMode::isMaster())
    118                 this->setObjectMode(objectDirection::bidirectional);
     118                this->setObjectMode(ObjectDirection::Bidirectional);
    119119            else
    120120                this->setName(this->nick_);
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.cc

    r3196 r3280  
    7777    void PlayerInfo::registerVariables()
    7878    {
    79         registerVariable(this->name_,                 variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    80         registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    81         registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
    82         registerVariable(this->gtinfoID_,             variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
     79        registerVariable(this->name_,                 VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
     80        registerVariable(this->controllableEntityID_, VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
     81        registerVariable(this->bReadyToSpawn_,        VariableDirection::ToServer);
     82        registerVariable(this->gtinfoID_,             VariableDirection::ToClient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedgtinfoID));
    8383    }
    8484
  • code/trunk/src/orxonox/objects/items/Engine.cc

    r3196 r3280  
    113113    void Engine::registerVariables()
    114114    {
    115         registerVariable(this->shipID_, variableDirection::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
    116 
    117         registerVariable(this->speedFactor_, variableDirection::toclient);
    118         registerVariable(this->boostFactor_, variableDirection::toclient);
    119 
    120         registerVariable(this->maxSpeedFront_,     variableDirection::toclient);
    121         registerVariable(this->maxSpeedBack_,      variableDirection::toclient);
    122         registerVariable(this->maxSpeedLeftRight_, variableDirection::toclient);
    123         registerVariable(this->maxSpeedUpDown_,    variableDirection::toclient);
    124 
    125         registerVariable(this->accelerationFront_,     variableDirection::toclient);
    126         registerVariable(this->accelerationBrake_,     variableDirection::toclient);
    127         registerVariable(this->accelerationBack_,      variableDirection::toclient);
    128         registerVariable(this->accelerationLeftRight_, variableDirection::toclient);
    129         registerVariable(this->accelerationUpDown_,    variableDirection::toclient);
     115        registerVariable(this->shipID_, VariableDirection::ToClient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));
     116
     117        registerVariable(this->speedFactor_, VariableDirection::ToClient);
     118        registerVariable(this->boostFactor_, VariableDirection::ToClient);
     119
     120        registerVariable(this->maxSpeedFront_,     VariableDirection::ToClient);
     121        registerVariable(this->maxSpeedBack_,      VariableDirection::ToClient);
     122        registerVariable(this->maxSpeedLeftRight_, VariableDirection::ToClient);
     123        registerVariable(this->maxSpeedUpDown_,    VariableDirection::ToClient);
     124
     125        registerVariable(this->accelerationFront_,     VariableDirection::ToClient);
     126        registerVariable(this->accelerationBrake_,     VariableDirection::ToClient);
     127        registerVariable(this->accelerationBack_,      VariableDirection::ToClient);
     128        registerVariable(this->accelerationLeftRight_, VariableDirection::ToClient);
     129        registerVariable(this->accelerationUpDown_,    VariableDirection::ToClient);
    130130    }
    131131
  • code/trunk/src/orxonox/objects/items/MultiStateEngine.cc

    r3196 r3280  
    8282    void MultiStateEngine::registerVariables()
    8383    {
    84         registerVariable(this->state_, variableDirection::toserver);
     84        registerVariable(this->state_, VariableDirection::ToServer);
    8585    }
    8686
     
    9191            if (this->getShip()->hasLocalController())
    9292            {
    93                 this->setObjectMode(objectDirection::bidirectional);
     93                this->setObjectMode(ObjectDirection::Bidirectional);
    9494
    9595                const Vector3& direction = this->getDirection();
  • code/trunk/src/orxonox/objects/pickup/ModifierPickup.cc

    r3196 r3280  
    8787        if (this->addTo(pawn))
    8888        {
    89             std::map<ModifierType::Enum, float>::iterator it;
     89            std::map<ModifierType::Value, float>::iterator it;
    9090
    9191            for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
     
    124124        if (this->removeFrom(pawn))
    125125        {
    126             std::map<ModifierType::Enum, float>::iterator it;
     126            std::map<ModifierType::Value, float>::iterator it;
    127127
    128128            for (it = this->additiveModifiers_.begin(); it != this->additiveModifiers_.end(); it++)
     
    158158        @return Returns the additive modifier for type (or 0 if not exists).
    159159    */
    160     float ModifierPickup::getAdditiveModifier(ModifierType::Enum type) const
    161     {
    162         std::map<ModifierType::Enum, float>::const_iterator it = this->additiveModifiers_.find(type);
     160    float ModifierPickup::getAdditiveModifier(ModifierType::Value type) const
     161    {
     162        std::map<ModifierType::Value, float>::const_iterator it = this->additiveModifiers_.find(type);
    163163        if (it != this->additiveModifiers_.end())
    164164            return (*it).second;
     
    171171        @return Returns the multiplicative modifier for type (or 1 if not exists).
    172172    */
    173     float ModifierPickup::getMultiplicativeModifier(ModifierType::Enum type) const
    174     {
    175         std::map<ModifierType::Enum, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
     173    float ModifierPickup::getMultiplicativeModifier(ModifierType::Value type) const
     174    {
     175        std::map<ModifierType::Value, float>::const_iterator it = this->multiplicativeModifiers_.find(type);
    176176        if (it != this->multiplicativeModifiers_.end())
    177177            return (*it).second;
     
    184184        @param value The new additive modifier for type.
    185185    */
    186     void ModifierPickup::setAdditiveModifier(ModifierType::Enum type, float value)
     186    void ModifierPickup::setAdditiveModifier(ModifierType::Value type, float value)
    187187    {
    188188        if (this->additiveModifiers_.find(type) == this->additiveModifiers_.end())
    189             this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
     189            this->additiveModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
    190190        else
    191191            this->additiveModifiers_[type] = value;
     
    196196        @param value The new multiplicative modifier for type.
    197197    */
    198     void ModifierPickup::setMultiplicativeModifier(ModifierType::Enum type, float value)
     198    void ModifierPickup::setMultiplicativeModifier(ModifierType::Value type, float value)
    199199    {
    200200        if (this->multiplicativeModifiers_.find(type) == this->multiplicativeModifiers_.end())
    201             this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
     201            this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
    202202        else
    203203            this->multiplicativeModifiers_[type] = value;
  • code/trunk/src/orxonox/objects/pickup/ModifierPickup.h

    r3196 r3280  
    130130        void timerCallback(Pawn* pawn);     //!< Method called when the timer runs out.
    131131    private:
    132         float getAdditiveModifier(ModifierType::Enum type) const;               //!< Get the additive modifier for a given ModifierType.
    133         float getMultiplicativeModifier(ModifierType::Enum type) const;         //!< Get the multiplicative modifier for a given ModifierType.
    134         void setAdditiveModifier(ModifierType::Enum type, float value);         //!< Set the additive modifier for a given ModifierType.
    135         void setMultiplicativeModifier(ModifierType::Enum type, float value);   //!< Set the multiplicative modifier for a given ModifierType
     132        float getAdditiveModifier(ModifierType::Value type) const;               //!< Get the additive modifier for a given ModifierType.
     133        float getMultiplicativeModifier(ModifierType::Value type) const;         //!< Get the multiplicative modifier for a given ModifierType.
     134        void setAdditiveModifier(ModifierType::Value type, float value);         //!< Set the additive modifier for a given ModifierType.
     135        void setMultiplicativeModifier(ModifierType::Value type, float value);   //!< Set the multiplicative modifier for a given ModifierType
    136136
    137         std::map<ModifierType::Enum, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType.
    138         std::map<ModifierType::Enum, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType.
     137        std::map<ModifierType::Value, float> additiveModifiers_;                 //!< Map of additive modifiers, indexed by ModifierType.
     138        std::map<ModifierType::Value, float> multiplicativeModifiers_;           //!< Map of multiplicative modifiers, indexed by ModifierType.
    139139
    140140        float duration_;                                                        //!< Duration of this pickup's effect (0 for unlimited).
  • code/trunk/src/orxonox/objects/pickup/ModifierType.h

    r3196 r3280  
    4444            @brief Gives the available types for modifiers.
    4545        */
    46         enum Enum
     46        enum Value
    4747        {
    4848            Unknown = 0,
  • code/trunk/src/orxonox/objects/pickup/PickupCollection.cc

    r3196 r3280  
    4242{
    4343    typedef std::pair<std::multimap<std::string, BaseItem*>::iterator, std::multimap<std::string, BaseItem*>::iterator> item_range;
    44     typedef std::pair<std::multimap<ModifierType::Enum, float>::iterator, std::multimap<ModifierType::Enum, float>::iterator> modifier_range;
     44    typedef std::pair<std::multimap<ModifierType::Value, float>::iterator, std::multimap<ModifierType::Value, float>::iterator> modifier_range;
    4545
    4646    //! Constructor
     
    200200        @param value Value for the modifier.
    201201    */
    202     void PickupCollection::addAdditiveModifier(ModifierType::Enum type, float value)
    203     {
    204         this->additiveModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
     202    void PickupCollection::addAdditiveModifier(ModifierType::Value type, float value)
     203    {
     204        this->additiveModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
    205205    }
    206206    /**
     
    209209        @return Returns the sum of the additive modifiers of the type.
    210210    */
    211     float PickupCollection::getAdditiveModifier(ModifierType::Enum type)
     211    float PickupCollection::getAdditiveModifier(ModifierType::Value type)
    212212    {
    213213        float v = 0.0f;
     
    215215        modifier_range range = this->additiveModifiers_.equal_range(type);
    216216
    217         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
     217        for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
    218218        {
    219219            v += (*it).second;
     
    227227        @param value Value which is to be removed.
    228228    */
    229     void PickupCollection::removeAdditiveModifier(ModifierType::Enum type, float value)
     229    void PickupCollection::removeAdditiveModifier(ModifierType::Value type, float value)
    230230    {
    231231        modifier_range range = this->additiveModifiers_.equal_range(type);
    232         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
     232        for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->additiveModifiers_.end(); it++)
    233233        {
    234234            if ((*it).second == value)
     
    244244        @param value Value for the modifier.
    245245    */
    246     void PickupCollection::addMultiplicativeModifier(ModifierType::Enum type, float value)
    247     {
    248         this->multiplicativeModifiers_.insert( std::pair<ModifierType::Enum, float>(type, value) );
     246    void PickupCollection::addMultiplicativeModifier(ModifierType::Value type, float value)
     247    {
     248        this->multiplicativeModifiers_.insert( std::pair<ModifierType::Value, float>(type, value) );
    249249    }
    250250    /**
     
    253253        @return Returns the product of the multiplicative modifiers of the type.
    254254    */
    255     float PickupCollection::getMultiplicativeModifier(ModifierType::Enum type)
     255    float PickupCollection::getMultiplicativeModifier(ModifierType::Value type)
    256256    {
    257257        float v = 1.0f;
    258258
    259259        modifier_range range = this->multiplicativeModifiers_.equal_range(type);
    260         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
     260        for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
    261261        {
    262262            v *= (*it).second;
     
    270270        @param value Value which is to be removed.
    271271    */
    272     void PickupCollection::removeMultiplicativeModifier(ModifierType::Enum type, float value)
     272    void PickupCollection::removeMultiplicativeModifier(ModifierType::Value type, float value)
    273273    {
    274274        modifier_range range = this->multiplicativeModifiers_.equal_range(type);
    275         for (std::multimap<ModifierType::Enum, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
     275        for (std::multimap<ModifierType::Value, float>::iterator it = range.first; it != range.second && it != this->multiplicativeModifiers_.end(); it++)
    276276        {
    277277            if ((*it).second == value)
     
    289289        @return Returns the value after being processed.
    290290    */
    291     float PickupCollection::processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication)
     291    float PickupCollection::processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication)
    292292    {
    293293        float outputValue = inputValue;
     
    310310        @return Returns the value after being processed.
    311311    */
    312     Vector3 PickupCollection::processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication)
     312    Vector3 PickupCollection::processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication)
    313313    {
    314314        Vector3 outputValue = inputValue;
  • code/trunk/src/orxonox/objects/pickup/PickupCollection.h

    r3196 r3280  
    6767        void useItem(UsableItem* item);                                             //!< Use a usable item.
    6868
    69         void addAdditiveModifier(ModifierType::Enum type, float value);             //!< Add an additive modifier.
    70         void addMultiplicativeModifier(ModifierType::Enum type, float value);       //!< Add a multiplicative modifier.
     69        void addAdditiveModifier(ModifierType::Value type, float value);             //!< Add an additive modifier.
     70        void addMultiplicativeModifier(ModifierType::Value type, float value);       //!< Add a multiplicative modifier.
    7171
    72         float getAdditiveModifier(ModifierType::Enum type);                         //!< Get total additive modifier.
    73         float getMultiplicativeModifier(ModifierType::Enum type);                   //!< Get total multiplicative modifier.
     72        float getAdditiveModifier(ModifierType::Value type);                         //!< Get total additive modifier.
     73        float getMultiplicativeModifier(ModifierType::Value type);                   //!< Get total multiplicative modifier.
    7474
    75         void removeAdditiveModifier(ModifierType::Enum type, float value);          //!< Remove an additive modifier.
    76         void removeMultiplicativeModifier(ModifierType::Enum type, float value);    //!< Remove a multiplicative modifier.
     75        void removeAdditiveModifier(ModifierType::Value type, float value);          //!< Remove an additive modifier.
     76        void removeMultiplicativeModifier(ModifierType::Value type, float value);    //!< Remove a multiplicative modifier.
    7777
    78         float processModifiers(ModifierType::Enum type, float inputValue, bool addBeforeMultiplication = false);        //!< Apply the modifiers to a float.
    79         Vector3 processModifiers(ModifierType::Enum type, Vector3 inputValue, bool addBeforeMultiplication = false);    //!< Apply the modifiers to a Vector3.
     78        float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false);        //!< Apply the modifiers to a float.
     79        Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false);    //!< Apply the modifiers to a Vector3.
    8080
    8181        /**
     
    113113        bool bBlockRemovals_;   //!< Whether to block direct removals through remove().
    114114
    115         std::multimap<ModifierType::Enum, float> additiveModifiers_;        //!< Contains additive modifiers (indexed by ModifierType).
    116         std::multimap<ModifierType::Enum, float> multiplicativeModifiers_;  //!< Contains multiplicative modifiers (indexed by ModifierType).
     115        std::multimap<ModifierType::Value, float> additiveModifiers_;        //!< Contains additive modifiers (indexed by ModifierType).
     116        std::multimap<ModifierType::Value, float> multiplicativeModifiers_;  //!< Contains multiplicative modifiers (indexed by ModifierType).
    117117
    118118        std::multimap<std::string, BaseItem*> items_;                       //!< Map of items in the collection (indexed by pickupIdentifier of the items).
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.cc

    r3196 r3280  
    147147            return false;
    148148        }
    149         return (this->isInactive(player) && !(this->status_ == questStatus::completed || this->status_ == questStatus::failed));
     149        return (this->isInactive(player) && !(this->status_ == QuestStatus::Completed || this->status_ == QuestStatus::Failed));
    150150    }
    151151
     
    189189        Throws an Exception if player is NULL.
    190190    */
    191     questStatus::Enum GlobalQuest::getStatus(const PlayerInfo* player) const
     191    QuestStatus::Value GlobalQuest::getStatus(const PlayerInfo* player) const
    192192    {
    193193        if(player == NULL) //!< We don't want NULL-Pointers!
     
    203203        }
    204204
    205         return questStatus::inactive;
     205        return QuestStatus::Inactive;
    206206    }
    207207
     
    217217        Returns false if player is NULL.
    218218    */
    219     bool GlobalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status)
     219    bool GlobalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
    220220    {
    221221        if(player == NULL) //!< We don't want NULL-Pointers!
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.h

    r3196 r3280  
    9797            virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
    9898
    99             virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
     99            virtual QuestStatus::Value getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
    100100           
    101             virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
     101            virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status); //!< Sets the status for a specific player.
    102102
    103103        private:
    104104            std::set<PlayerInfo*> players_; //!< The set of players which possess this Quest.
    105             questStatus::Enum status_; //!< The status of this Quest.
     105            QuestStatus::Value status_; //!< The status of this Quest.
    106106            std::list<QuestEffect*> rewards_; //!< Reward QuestEffects only invoked on the player completing the Quest.
    107107           
  • code/trunk/src/orxonox/objects/quest/LocalQuest.cc

    r3196 r3280  
    176176        Throws an Exception if player is NULL.
    177177    */
    178     questStatus::Enum LocalQuest::getStatus(const PlayerInfo* player) const
     178    QuestStatus::Value LocalQuest::getStatus(const PlayerInfo* player) const
    179179    {
    180180        if(player == NULL) //!< No player has no defined status.
     
    183183        }
    184184
    185         std::map<const PlayerInfo*, questStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
     185        std::map<const PlayerInfo*, QuestStatus::Value>::const_iterator it = this->playerStatus_.find(player);
    186186        if (it != this->playerStatus_.end()) //!< If there is a player in the map.
    187187        {
     
    189189        }
    190190       
    191         return questStatus::inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.
     191        return QuestStatus::Inactive; //!< If the player is not yet in the map, that means the status of the quest form him is 'inactive'.
    192192    }
    193193
     
    203203        Returns false if player is NULL.
    204204    */
    205     bool LocalQuest::setStatus(PlayerInfo* player, const questStatus::Enum & status)
     205    bool LocalQuest::setStatus(PlayerInfo* player, const QuestStatus::Value & status)
    206206    {
    207207        if(player == NULL) //!< We can't set a status for no player.
  • code/trunk/src/orxonox/objects/quest/LocalQuest.h

    r3196 r3280  
    9191            virtual bool isCompletable(const PlayerInfo* player) const; //!< Checks whether the Quest can be completed.
    9292
    93             virtual questStatus::Enum getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
    94             virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status); //!< Sets the status for a specific player.
     93            virtual QuestStatus::Value getStatus(const PlayerInfo* player) const; //!< Returns the status of the Quest for a specific player.
     94            virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status); //!< Sets the status for a specific player.
    9595
    9696        private:
    97             std::map<const PlayerInfo*, questStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
     97            std::map<const PlayerInfo*, QuestStatus::Value> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
    9898
    9999    };
  • code/trunk/src/orxonox/objects/quest/Quest.cc

    r3196 r3280  
    302302    bool Quest::isInactive(const PlayerInfo* player) const
    303303    {
    304         return this->getStatus(player) == questStatus::inactive;
     304        return this->getStatus(player) == QuestStatus::Inactive;
    305305    }
    306306
     
    318318    {
    319319
    320         return this->getStatus(player) == questStatus::active;
     320        return this->getStatus(player) == QuestStatus::Active;
    321321    }
    322322
     
    333333    bool Quest::isFailed(const PlayerInfo* player) const
    334334    {
    335         return this->getStatus(player) == questStatus::failed;
     335        return this->getStatus(player) == QuestStatus::Failed;
    336336    }
    337337
     
    348348    bool Quest::isCompleted(const PlayerInfo* player) const
    349349    {
    350         return this->getStatus(player) == questStatus::completed;
     350        return this->getStatus(player) == QuestStatus::Completed;
    351351    }
    352352   
     
    362362    {
    363363        QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed.
    364         this->setStatus(player, questStatus::failed);
     364        this->setStatus(player, QuestStatus::Failed);
    365365       
    366366        COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl;
     
    381381    {
    382382        QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed.
    383         this->setStatus(player, questStatus::completed);
     383        this->setStatus(player, QuestStatus::Completed);
    384384       
    385385        COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl;
     
    409409        QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active.
    410410       
    411         this->setStatus(player, questStatus::active);
     411        this->setStatus(player, QuestStatus::Active);
    412412       
    413413        this->getDescription()->sendAddQuestNotification();
  • code/trunk/src/orxonox/objects/quest/Quest.h

    r3196 r3280  
    4343namespace orxonox
    4444{
    45     namespace questStatus
     45    namespace QuestStatus
    4646    {
    47 
    4847        //!Different states of a Quest.
    49         enum Enum
     48        enum Value
    5049        {
    51             inactive,
    52             active,
    53             failed,
    54             completed
     50            Inactive,
     51            Active,
     52            Failed,
     53            Completed
    5554        };
    56 
    5755    }
    5856
     
    133131                { return this->completeEffects_; }
    134132
    135             virtual questStatus::Enum getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
    136             virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
     133            virtual QuestStatus::Value getStatus(const PlayerInfo* player) const = 0; //!< Returns the status of the Quest for a specific player.
     134            virtual bool setStatus(PlayerInfo* player, const QuestStatus::Value & status) = 0; //!< Changes the status for a specific player.
    137135           
    138136        private:
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r3196 r3280  
    5353        RegisterObject(QuestEffectBeacon);
    5454       
    55         this->status_ = QuestEffectBeaconStatus::active;
     55        this->status_ = QuestEffectBeaconStatus::Active;
    5656        this->times_ = INFINITE_TIME;
    5757    }
     
    162162        if(activate)
    163163        {
    164         this->status_ = QuestEffectBeaconStatus::active;
    165         return true;
    166         }
    167        
    168         this->status_ = QuestEffectBeaconStatus::inactive;
     164        this->status_ = QuestEffectBeaconStatus::Active;
     165        return true;
     166        }
     167       
     168        this->status_ = QuestEffectBeaconStatus::Inactive;
    169169        return true;
    170170    }
     
    190190        if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
    191191        {
    192             this->status_ = QuestEffectBeaconStatus::inactive;
     192            this->status_ = QuestEffectBeaconStatus::Inactive;
    193193        }
    194194       
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h

    r3196 r3280  
    4444    namespace QuestEffectBeaconStatus
    4545    {
    46 
    4746        //! The status of the beacon, can be either active or inactive.
    48         enum Enum
     47        enum Value
    4948        {
    50             inactive,
    51             active
     49            Inactive,
     50            Active
    5251        };
    53 
    5452    }
    5553
     
    9896            */
    9997            inline bool isActive(void)
    100             { return this->status_ == QuestEffectBeaconStatus::active; }
     98            { return this->status_ == QuestEffectBeaconStatus::Active; }
    10199           
    102100            bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
     
    117115            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
    118116            int times_; //!< Number of times the beacon can be exectued.
    119             QuestEffectBeaconStatus::Enum status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
     117            QuestEffectBeaconStatus::Value status_; //!< The status of the QUestEffectBeacon, Can be eighter active or inactive.
    120118           
    121119            bool setTimes(const int & n); //!< Set the number of times the QuestEffectBeacon can be executed.
  • code/trunk/src/orxonox/objects/quest/QuestHint.cc

    r3196 r3280  
    9595
    9696        //! Find the player.
    97         std::map<const PlayerInfo*, questHintStatus::Enum>::const_iterator it = this->playerStatus_.find(player);
     97        std::map<const PlayerInfo*, QuestHintStatus::Value>::const_iterator it = this->playerStatus_.find(player);
    9898        if (it != this->playerStatus_.end()) //!< If the player is in the map.
    9999        {
     
    101101        }
    102102       
    103         return questStatus::inactive;
     103        return QuestStatus::Inactive;
    104104    }
    105105
     
    118118            if(!(this->isActive(player)))  //!< If the hint is already active, activation is pointless.
    119119            {
    120                 this->playerStatus_[player] = questHintStatus::active;
     120                this->playerStatus_[player] = QuestHintStatus::Active;
    121121               
    122122                this->getDescription()->sendAddHintNotification();
  • code/trunk/src/orxonox/objects/quest/QuestHint.h

    r3196 r3280  
    4242namespace orxonox
    4343{
    44     namespace questHintStatus
     44    namespace QuestHintStatus
    4545    {
    46 
    4746        //! The state of the hint.
    48         enum Enum
     47        enum Value
    4948        {
    50             inactive,
    51             active
     49            Inactive,
     50            Active
    5251        };
    53 
    5452    }
    5553
     
    9189        private:
    9290            Quest* quest_; //!< The Quest the QuestHint belongs to.
    93             std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
     91            std::map<const PlayerInfo*, QuestHintStatus::Value> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
    9492
    9593    };
  • code/trunk/src/orxonox/objects/quest/QuestListener.cc

    r3196 r3280  
    5151        RegisterObject(QuestListener);
    5252       
    53         this->mode_ = questListenerMode::all;
     53        this->mode_ = QuestListenerMode::All;
    5454        this->quest_ = NULL;
    5555    }
     
    132132        if(mode == "all")
    133133        {
    134             this->mode_ = questListenerMode::all;
     134            this->mode_ = QuestListenerMode::All;
    135135        }
    136136        else if(mode == "start")
    137137        {
    138             this->mode_ = questListenerMode::start;
     138            this->mode_ = QuestListenerMode::Start;
    139139        }
    140140        else if(mode == "fail")
    141141        {
    142             this->mode_ = questListenerMode::fail;
     142            this->mode_ = QuestListenerMode::Fail;
    143143        }
    144144        else if(mode == "complete")
    145145        {
    146             this->mode_ = questListenerMode::complete;
     146            this->mode_ = QuestListenerMode::Complete;
    147147        }
    148148        else
    149149        {
    150150            COUT(2) << "QuestListener with invalid mode '" << mode << "' created. Mode set to 'all'." << std::endl;
    151         this->mode_ = questListenerMode::all;
     151        this->mode_ = QuestListenerMode::All;
    152152        return false;
    153153        }
     
    164164    std::string QuestListener::getMode(void)
    165165    {
    166         if(this->mode_ == questListenerMode::all)
     166        if(this->mode_ == QuestListenerMode::All)
    167167        {
    168168            return "all";
    169169        }
    170         else if(this->mode_ == questListenerMode::start)
     170        else if(this->mode_ == QuestListenerMode::Start)
    171171        {
    172172            return "start";
    173173        }
    174         else if(this->mode_ == questListenerMode::fail)
     174        else if(this->mode_ == QuestListenerMode::Fail)
    175175        {
    176176            return "fail";
    177177        }
    178         else if(this->mode_ == questListenerMode::complete)
     178        else if(this->mode_ == QuestListenerMode::Complete)
    179179        {
    180180            return "complete";
  • code/trunk/src/orxonox/objects/quest/QuestListener.h

    r3196 r3280  
    4343namespace orxonox
    4444{
    45     namespace questListenerMode
     45    namespace QuestListenerMode
    4646    {
    47 
    4847        //! The mode of the QuestListener.
    49         enum Enum
     48        enum Value
    5049        {
    51             all,
    52             start,
    53             fail,
    54             complete
     50            All,
     51            Start,
     52            Fail,
     53            Complete
    5554        };
    56 
    5755    }
    5856
     
    9391       
    9492    private:
    95         questListenerMode::Enum mode_; //!< The mode of the QuestListener.
     93        QuestListenerMode::Value mode_; //!< The mode of the QuestListener.
    9694        Quest* quest_; //!< A pointer to the Quest the QuestListener is reacting to.
    9795   
  • code/trunk/src/orxonox/objects/weaponsystem/projectiles/LightningGunProjectile.cc

    r3196 r3280  
    5656        this->materialBase_ = material;   
    5757   
    58         BillboardProjectile::setMaterial(material + convertToString(this->textureIndex_));
     58        BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
    5959    }
    6060
  • code/trunk/src/orxonox/objects/weaponsystem/projectiles/ParticleProjectile.cc

    r3196 r3280  
    4444        if (GameMode::showsGraphics())
    4545        {
    46             this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
     46            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::Normal);
    4747            this->attachOgreObject(this->particles_->getParticleSystem());
    4848            this->particles_->setKeepParticlesInLocalSpace(0);
  • code/trunk/src/orxonox/objects/worldentities/Backlight.cc

    r3196 r3280  
    2929#include "Backlight.h"
    3030
     31#include <algorithm>
    3132#include <OgreRibbonTrail.h>
    3233#include <OgreSceneManager.h>
     
    108109    void Backlight::registerVariables()
    109110    {
    110         registerVariable(this->width_,         variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
    111         registerVariable(this->lifetime_,      variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
    112         registerVariable(this->length_,        variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
    113         registerVariable(this->maxelements_,   variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
    114         registerVariable(this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
     111        registerVariable(this->width_,         VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
     112        registerVariable(this->lifetime_,      VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
     113        registerVariable(this->length_,        VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
     114        registerVariable(this->maxelements_,   VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
     115        registerVariable(this->trailmaterial_, VariableDirection::ToClient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
    115116    }
    116117
     
    175176    void Backlight::stopturnonoff()
    176177    {
    177         this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_);
     178        this->postprocessingtime_ = std::max(0.0f, this->lifetime_ - this->turnofftime_);
    178179
    179180        FadingBillboard::stopturnonoff();
  • code/trunk/src/orxonox/objects/worldentities/BigExplosion.cc

    r3196 r3280  
    5656*/
    5757        this->bStop_ = false;
    58         this->LOD_ = LODParticle::normal;
     58        this->LOD_ = LODParticle::Normal;
    5959
    6060/*      this->stf_ = "setTimeFactor ";
     
    307307    void BigExplosion::registerVariables()
    308308    {
    309         registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<BigExplosion>(this, &BigExplosion::LODchanged));
    310         registerVariable(this->bStop_,       variableDirection::toclient, new NetworkCallback<BigExplosion>(this, &BigExplosion::checkStop));
     309        registerVariable((int&)(this->LOD_), VariableDirection::ToClient, new NetworkCallback<BigExplosion>(this, &BigExplosion::LODchanged));
     310        registerVariable(this->bStop_,       VariableDirection::ToClient, new NetworkCallback<BigExplosion>(this, &BigExplosion::checkStop));
    311311    }
    312312
  • code/trunk/src/orxonox/objects/worldentities/BigExplosion.h

    r3196 r3280  
    4747            void registerVariables();
    4848
    49             inline void setLOD(LODParticle::LOD level)
     49            inline void setLOD(LODParticle::Value level)
    5050                { this->LOD_ = level; this->LODchanged(); }
    51             inline LODParticle::LOD getLOD() const
     51            inline LODParticle::Value getLOD() const
    5252                { return this->LOD_; }
    5353
     
    9898            ParticleInterface*    explosionFire_;
    9999
    100             LODParticle::LOD      LOD_;
     100            LODParticle::Value      LOD_;
    101101            Timer<BigExplosion> destroyTimer_;
    102102    };
  • code/trunk/src/orxonox/objects/worldentities/Billboard.cc

    r3196 r3280  
    6969    void Billboard::registerVariables()
    7070    {
    71         registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
    72         registerVariable(this->colour_,   variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
    73 //        registerVariable(this->rotation_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
     71        registerVariable(this->material_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
     72        registerVariable(this->colour_,   VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
     73//        registerVariable(this->rotation_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
    7474    }
    7575
  • code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc

    r3196 r3280  
    6666    void BlinkingBillboard::registerVariables()
    6767    {
    68 //        registerVariable(this->amplitude_, variableDirection::toclient);
    69 //        registerVariable(this->frequency_, variableDirection::toclient);
    70 //        registerVariable(this->phase_,     variableDirection::toclient);
     68//        registerVariable(this->amplitude_, VariableDirection::ToClient);
     69//        registerVariable(this->frequency_, VariableDirection::ToClient);
     70//        registerVariable(this->phase_,     VariableDirection::ToClient);
    7171    }
    7272
  • code/trunk/src/orxonox/objects/worldentities/Camera.cc

    r3196 r3280  
    2929#include "Camera.h"
    3030
     31#include <algorithm>
    3132#include <OgreCamera.h>
    3233#include <OgreSceneManager.h>
     
    3435
    3536#include "util/Exception.h"
    36 #include "util/String.h"
     37#include "util/StringUtils.h"
    3738#include "core/CoreIncludes.h"
    3839#include "core/ConfigValueIncludes.h"
     
    104105        {
    105106            // this stuff here may need some adjustments
    106             float coeff = min(1.0f, 15.0f * dt);
     107            float coeff = std::min(1.0f, 15.0f * dt);
    107108
    108109            Vector3 offset = this->getWorldPosition() - this->cameraNode_->_getDerivedPosition();
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc

    r3196 r3280  
    7979
    8080        this->setConfigValues();
    81         this->setPriority( priority::very_high );
     81        this->setPriority( Priority::VeryHigh );
    8282        this->registerVariables();
    8383    }
     
    238238            {
    239239                this->client_overwrite_ = this->server_overwrite_;
    240                 this->setObjectMode(objectDirection::bidirectional);
     240                this->setObjectMode(ObjectDirection::Bidirectional);
    241241            }
    242242        }
     
    254254        this->bHasLocalController_ = false;
    255255        this->bHasHumanController_ = false;
    256         this->setObjectMode(objectDirection::toclient);
     256        this->setObjectMode(ObjectDirection::ToClient);
    257257
    258258        this->changedPlayer();
     
    368368    void ControllableEntity::registerVariables()
    369369    {
    370         registerVariable(this->cameraPositionTemplate_,  variableDirection::toclient);
    371         registerVariable(this->hudtemplate_,             variableDirection::toclient);
    372 
    373         registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    374         registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
    375         registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    376         registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
    377 
    378         registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    379         registerVariable(this->client_overwrite_,        variableDirection::toserver);
    380 
    381         registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    382         registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
    383         registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    384         registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     370        registerVariable(this->cameraPositionTemplate_,  VariableDirection::ToClient);
     371        registerVariable(this->hudtemplate_,             VariableDirection::ToClient);
     372
     373        registerVariable(this->server_position_,         VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     374        registerVariable(this->server_linear_velocity_,  VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
     375        registerVariable(this->server_orientation_,      VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     376        registerVariable(this->server_angular_velocity_, VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
     377
     378        registerVariable(this->server_overwrite_,        VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     379        registerVariable(this->client_overwrite_,        VariableDirection::ToServer);
     380
     381        registerVariable(this->client_position_,         VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     382        registerVariable(this->client_linear_velocity_,  VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
     383        registerVariable(this->client_orientation_,      VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     384        registerVariable(this->client_angular_velocity_, VariableDirection::ToServer, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
    385385       
    386386
    387         registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     387        registerVariable(this->playerID_,                VariableDirection::ToClient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
    388388    }
    389389
  • code/trunk/src/orxonox/objects/worldentities/ExplosionChunk.cc

    r3196 r3280  
    4848
    4949        this->bStop_ = false;
    50         this->LOD_ = LODParticle::normal;
     50        this->LOD_ = LODParticle::Normal;
    5151
    5252        if ( GameMode::showsGraphics() )
     
    104104    void ExplosionChunk::registerVariables()
    105105    {
    106         registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
    107         registerVariable(this->bStop_,       variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
     106        registerVariable((int&)(this->LOD_), VariableDirection::ToClient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));
     107        registerVariable(this->bStop_,       VariableDirection::ToClient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));
    108108    }
    109109
  • code/trunk/src/orxonox/objects/worldentities/ExplosionChunk.h

    r3196 r3280  
    4646            void registerVariables();
    4747
    48             inline void setLOD(LODParticle::LOD level)
     48            inline void setLOD(LODParticle::Value level)
    4949                { this->LOD_ = level; this->LODchanged(); }
    50             inline LODParticle::LOD getLOD() const
     50            inline LODParticle::Value getLOD() const
    5151                { return this->LOD_; }
    5252
     
    6060            ParticleInterface*    fire_;
    6161            ParticleInterface*    smoke_;
    62             LODParticle::LOD      LOD_;
     62            LODParticle::Value      LOD_;
    6363            Timer<ExplosionChunk> destroyTimer_;
    6464    };
  • code/trunk/src/orxonox/objects/worldentities/FadingBillboard.cc

    r3196 r3280  
    6464    void FadingBillboard::registerVariables()
    6565    {
    66         registerVariable(this->turnontime_,  variableDirection::toclient);
    67         registerVariable(this->turnofftime_, variableDirection::toclient);
     66        registerVariable(this->turnontime_,  VariableDirection::ToClient);
     67        registerVariable(this->turnofftime_, VariableDirection::ToClient);
    6868    }
    6969
  • code/trunk/src/orxonox/objects/worldentities/Light.cc

    r3205 r3280  
    3333#include <boost/static_assert.hpp>
    3434
    35 #include "util/String.h"
     35#include "util/StringUtils.h"
    3636#include "util/Exception.h"
    3737#include "core/CoreIncludes.h"
     
    4545
    4646    // Be sure we don't do bad conversions
    47     BOOST_STATIC_ASSERT((int)Ogre::Light::LT_POINT       == (int)Light::LT_POINT);
    48     BOOST_STATIC_ASSERT((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::LT_DIRECTIONAL);
    49     BOOST_STATIC_ASSERT((int)Ogre::Light::LT_SPOTLIGHT   == (int)Light::LT_SPOTLIGHT);
     47    BOOST_STATIC_ASSERT((int)Ogre::Light::LT_POINT       == (int)Light::Point);
     48    BOOST_STATIC_ASSERT((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Directional);
     49    BOOST_STATIC_ASSERT((int)Ogre::Light::LT_SPOTLIGHT   == (int)Light::Spotlight);
    5050
    5151    Light::Light(BaseObject* creator) : StaticEntity(creator)
     
    5656        this->diffuse_ = ColourValue::White;
    5757        this->specular_ = ColourValue::White;
    58         this->type_ = Light::LT_POINT;
     58        this->type_ = Light::Point;
    5959        this->attenuation_ = Vector4(100000, 1, 0, 0);
    6060        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
     
    106106    void Light::registerVariables()
    107107    {
    108         registerVariable((int&)this->type_,     variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType));
    109         registerVariable(this->diffuse_,        variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
    110         registerVariable(this->specular_,       variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
    111         registerVariable(this->attenuation_,    variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
    112         registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
     108        registerVariable((int&)this->type_,     VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType));
     109        registerVariable(this->diffuse_,        VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
     110        registerVariable(this->specular_,       VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
     111        registerVariable(this->attenuation_,    VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
     112        registerVariable(this->spotlightRange_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
    113113    }
    114114
     
    127127    void Light::updateAttenuation()
    128128    {
    129         if (this->light_ && this->type_ != Light::LT_DIRECTIONAL)
     129        if (this->light_ && this->type_ != Light::Directional)
    130130            this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w);
    131131    }
     
    133133    void Light::updateSpotlightRange()
    134134    {
    135         if (this->light_ && this->type_ == Light::LT_SPOTLIGHT)
     135        if (this->light_ && this->type_ == Light::Spotlight)
    136136            this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z);
    137137    }
     
    140140    {
    141141        if (type == "point")
    142             this->setType(Light::LT_POINT);
     142            this->setType(Light::Point);
    143143        else if (type == "directional")
    144             this->setType(Light::LT_DIRECTIONAL);
     144            this->setType(Light::Directional);
    145145        else if (type == "spotlight")
    146             this->setType(Light::LT_SPOTLIGHT);
     146            this->setType(Light::Spotlight);
    147147        else
    148             this->setType(Light::LT_POINT);
     148            this->setType(Light::Point);
    149149    }
    150150
     
    153153        switch (this->type_)
    154154        {
    155             case Light::LT_DIRECTIONAL:
     155            case Light::Directional:
    156156                return "directional";
    157             case Light::LT_SPOTLIGHT:
     157            case Light::Spotlight:
    158158                return "spotlight";
    159             case Light::LT_POINT:
     159            case Light::Point:
    160160            default:
    161161                return "point";
     
    169169            this->light_->setType(static_cast<Ogre::Light::LightTypes>(this->type_));
    170170
    171             if (this->type_ != Light::LT_DIRECTIONAL)
     171            if (this->type_ != Light::Directional)
    172172                this->updateAttenuation();
    173             if (this->type_ == Light::LT_SPOTLIGHT)
     173            if (this->type_ == Light::Spotlight)
    174174                this->updateSpotlightRange();
    175175        }
  • code/trunk/src/orxonox/objects/worldentities/Light.h

    r3196 r3280  
    4545            {
    4646                /// Point light sources give off light equally in all directions, so require only position not direction
    47                 LT_POINT,
     47                Point,
    4848                /// Directional lights simulate parallel light beams from a distant source, hence have direction but no position
    49                 LT_DIRECTIONAL,
     49                Directional,
    5050                /// Spotlights simulate a cone of light from a source so require position and direction, plus extra values for falloff
    51                 LT_SPOTLIGHT
     51                Spotlight
    5252            };
    5353
  • code/trunk/src/orxonox/objects/worldentities/Model.cc

    r3196 r3280  
    6565    void Model::registerVariables()
    6666    {
    67         registerVariable(this->meshSrc_,    variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
    68         registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
     67        registerVariable(this->meshSrc_,    VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedMesh));
     68        registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Model>(this, &Model::changedShadows));
    6969    }
    7070
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc

    r3196 r3280  
    5252        this->continuousResynchroTimer_ = 0;
    5353
    54         this->setPriority(priority::low);
     54        this->setPriority(Priority::Low);
    5555
    5656        this->registerVariables();
     
    8989    void MovableEntity::registerVariables()
    9090    {
    91         registerVariable(this->linearVelocity_,        variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
    92         registerVariable(this->angularVelocity_,       variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity));
     91        registerVariable(this->linearVelocity_,        VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
     92        registerVariable(this->angularVelocity_,       VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity));
    9393
    94         registerVariable(this->overwrite_position_,    variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
    95         registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
     94        registerVariable(this->overwrite_position_,    VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
     95        registerVariable(this->overwrite_orientation_, VariableDirection::ToClient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
    9696    }
    9797
  • code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r3196 r3280  
    5353
    5454        this->particles_ = 0;
    55         this->LOD_ = LODParticle::normal;
     55        this->LOD_ = LODParticle::Normal;
    5656
    5757        this->registerVariables();
     
    7171        SUPER(ParticleEmitter, XMLPort, xmlelement, mode);
    7272
    73         XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::normal);
     73        XMLPortParam(ParticleEmitter, "lod",    setLODxml, getLODxml, xmlelement, mode).defaultValues(LODParticle::Normal);
    7474        XMLPortParam(ParticleEmitter, "source", setSource, getSource, xmlelement, mode);
    7575    }
     
    7777    void ParticleEmitter::registerVariables()
    7878    {
    79         registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
    80         registerVariable((int&)(this->LOD_),    variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
     79        registerVariable(this->source_, VariableDirection::ToClient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
     80        registerVariable((int&)(this->LOD_),    VariableDirection::ToClient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
    8181    }
    8282
  • code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.h

    r3196 r3280  
    5757                { return this->source_; }
    5858
    59             inline void setLOD(LODParticle::LOD level)
     59            inline void setLOD(LODParticle::Value level)
    6060                { this->LOD_ = level; this->LODchanged(); }
    61             inline LODParticle::LOD getLOD() const
     61            inline LODParticle::Value getLOD() const
    6262                { return this->LOD_; }
    6363
    6464        protected:
    6565            inline void setLODxml(unsigned int level)
    66                 { this->LOD_ = (LODParticle::LOD)level; this->LODchanged(); }
     66                { this->LOD_ = (LODParticle::Value)level; this->LODchanged(); }
    6767            inline unsigned int getLODxml() const
    6868                { return (unsigned int)this->LOD_; }
     
    7373            ParticleInterface* particles_;
    7474            std::string        source_;
    75             LODParticle::LOD   LOD_;
     75            LODParticle::Value   LOD_;
    7676    };
    7777}
  • code/trunk/src/orxonox/objects/worldentities/Planet.cc

    r3196 r3280  
    157157    void Planet::registerVariables()
    158158    {
    159         registerVariable(this->atmosphere_, variableDirection::toclient);
    160         registerVariable(this->meshSrc_, variableDirection::toclient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
    161         registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
    162         registerVariable(this->atmosphereSize, variableDirection::toclient);
    163         registerVariable(this->imageSize, variableDirection::toclient);
     159        registerVariable(this->atmosphere_, VariableDirection::ToClient);
     160        registerVariable(this->meshSrc_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedMesh));
     161        registerVariable(this->bCastShadows_, VariableDirection::ToClient, new NetworkCallback<Planet>(this, &Planet::changedShadows));
     162        registerVariable(this->atmosphereSize, VariableDirection::ToClient);
     163        registerVariable(this->imageSize, VariableDirection::ToClient);
    164164    }
    165165
  • code/trunk/src/orxonox/objects/worldentities/PongBall.cc

    r3196 r3280  
    7272        registerVariable( this->relMercyOffset_ );
    7373        registerVariable( this->batID_[0] );
    74         registerVariable( this->batID_[1], variableDirection::toclient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
     74        registerVariable( this->batID_[1], VariableDirection::ToClient, new NetworkCallback<PongBall>( this, &PongBall::applyBats) );
    7575    }
    7676
  • code/trunk/src/orxonox/objects/worldentities/StaticEntity.cc

    r3196 r3280  
    4343        RegisterObject(StaticEntity);
    4444       
    45         this->setPriority(priority::very_low);
     45        this->setPriority(Priority::VeryLow);
    4646
    4747        this->registerVariables();
     
    5454    void StaticEntity::registerVariables()
    5555    {
    56         registerVariable(this->getPosition(),    variableDirection::toclient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
    57         registerVariable(this->getOrientation(), variableDirection::toclient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
     56        registerVariable(this->getPosition(),    VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::positionChanged));
     57        registerVariable(this->getOrientation(), VariableDirection::ToClient, new NetworkCallback<StaticEntity>(this, &StaticEntity::orientationChanged));
    5858    }
    5959
  • code/trunk/src/orxonox/objects/worldentities/WorldEntity.cc

    r3196 r3280  
    175175    void WorldEntity::registerVariables()
    176176    {
    177         registerVariable(this->mainStateName_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
    178 
    179         registerVariable(this->bActive_,        variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    180         registerVariable(this->bVisible_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
    181 
    182         registerVariable(this->getScale3D(),    variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
     177        registerVariable(this->mainStateName_,  VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
     178
     179        registerVariable(this->bActive_,        VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
     180        registerVariable(this->bVisible_,       VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     181
     182        registerVariable(this->getScale3D(),    VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
    183183
    184184        // Physics stuff
    185         registerVariable(this->mass_,           variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
    186         registerVariable(this->restitution_,    variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged));
    187         registerVariable(this->angularFactor_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged));
    188         registerVariable(this->linearDamping_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged));
    189         registerVariable(this->angularDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged));
    190         registerVariable(this->friction_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged));
     185        registerVariable(this->mass_,           VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
     186        registerVariable(this->restitution_,    VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged));
     187        registerVariable(this->angularFactor_,  VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged));
     188        registerVariable(this->linearDamping_,  VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged));
     189        registerVariable(this->angularDamping_, VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged));
     190        registerVariable(this->friction_,       VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged));
    191191        registerVariable(this->bCollisionCallbackActive_,
    192                                                 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged));
     192                                                VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged));
    193193        registerVariable(this->bCollisionResponseActive_,
    194                                                 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged));
     194                                                VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged));
    195195        registerVariable((int&)this->collisionTypeSynchronised_,
    196                                                 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
     196                                                VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
    197197        registerVariable(this->bPhysicsActiveSynchronised_,
    198                                                 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
     198                                                VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
    199199
    200200        // Attach to parent if necessary
    201         registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
     201        registerVariable(this->parentID_,       VariableDirection::ToClient, new NetworkCallback<WorldEntity>(this, &WorldEntity::networkcallback_parentChanged));
    202202    }
    203203
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r3214 r3280  
    2828
    2929#include "Pawn.h"
     30
     31#include <algorithm>
    3032
    3133#include "core/CoreIncludes.h"
     
    117119    void Pawn::registerVariables()
    118120    {
    119         registerVariable(this->bAlive_,        variableDirection::toclient);
    120         registerVariable(this->health_,        variableDirection::toclient);
    121         registerVariable(this->initialHealth_, variableDirection::toclient);
    122         registerVariable(this->bReload_,       variableDirection::toserver);
     121        registerVariable(this->bAlive_,        VariableDirection::ToClient);
     122        registerVariable(this->health_,        VariableDirection::ToClient);
     123        registerVariable(this->initialHealth_, VariableDirection::ToClient);
     124        registerVariable(this->bReload_,       VariableDirection::ToServer);
    123125    }
    124126
     
    152154    void Pawn::setHealth(float health)
    153155    {
    154         this->health_ = min(health, this->maxHealth_);
     156        this->health_ = std::min(health, this->maxHealth_);
    155157    }
    156158
  • code/trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r3196 r3280  
    9090    void SpaceShip::registerVariables()
    9191    {
    92         registerVariable(this->primaryThrust_,  variableDirection::toclient);
    93         registerVariable(this->auxilaryThrust_, variableDirection::toclient);
    94         registerVariable(this->rotationThrust_, variableDirection::toclient);
     92        registerVariable(this->primaryThrust_,  VariableDirection::ToClient);
     93        registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
     94        registerVariable(this->rotationThrust_, VariableDirection::ToClient);
    9595    }
    9696
  • code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r3196 r3280  
    9393    void Spectator::registerVariables()
    9494    {
    95         registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
    96         registerVariable(this->bGreeting_,             variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
     95        registerVariable(this->bGreetingFlareVisible_, VariableDirection::ToClient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
     96        registerVariable(this->bGreeting_,             VariableDirection::ToServer, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
    9797    }
    9898
     
    145145        ControllableEntity::setPlayer(player);
    146146
    147 //        this->setObjectMode(objectDirection::toclient);
     147//        this->setObjectMode(ObjectDirection::ToClient);
    148148    }
    149149
  • code/trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.cc

    r3196 r3280  
    4343        RegisterObject(TeamBaseMatchBase);
    4444
    45         this->state_ = BaseState::uncontrolled;
     45        this->state_ = BaseState::Uncontrolled;
    4646
    4747        TeamBaseMatch* gametype = dynamic_cast<TeamBaseMatch*>(this->getGametype());
     
    6666        switch (this->state_)
    6767        {
    68             case BaseState::controlTeam1:
     68            case BaseState::ControlTeam1:
    6969                colour = gametype->getTeamColour(0);
    7070                break;
    71             case BaseState::controlTeam2:
     71            case BaseState::ControlTeam2:
    7272                colour = gametype->getTeamColour(1);
    7373                break;
    74             case BaseState::uncontrolled:
     74            case BaseState::Uncontrolled:
    7575            default:
    7676                colour = ColourValue(0.5, 0.5, 0.5, 1.0);
  • code/trunk/src/orxonox/objects/worldentities/pawns/TeamBaseMatchBase.h

    r3196 r3280  
    3838    namespace BaseState
    3939    {
    40         enum Enum
     40        enum Value
    4141        {
    42             uncontrolled,
    43             controlTeam1,
    44             controlTeam2,
     42            Uncontrolled,
     43            ControlTeam1,
     44            ControlTeam2,
    4545        };
    4646    }
     
    5858
    5959            // Set the state of a base to whatever the argument of the function is
    60             void setState(BaseState::Enum state)
     60            void setState(BaseState::Value state)
    6161            {
    6262                this->state_ = state;
     
    6666
    6767            // Get the state of a base as a return value
    68             BaseState::Enum getState() const
     68            BaseState::Value getState() const
    6969            {
    7070                return this->state_;
     
    7575            void changeTeamColour();
    7676
    77             BaseState::Enum state_;
     77            BaseState::Value state_;
    7878    };
    7979}
  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    r3196 r3280  
    141141  }
    142142
    143   bool DistanceTrigger::isTriggered(TriggerMode mode)
     143  bool DistanceTrigger::isTriggered(TriggerMode::Value mode)
    144144  {
    145145    if (Trigger::isTriggered(mode))
  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

    r3196 r3280  
    5959
    6060    protected:
    61       virtual bool isTriggered(TriggerMode mode);
     61      virtual bool isTriggered(TriggerMode::Value mode);
    6262      virtual void notifyMaskUpdate() {}
    6363
  • code/trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.cc

    r3196 r3280  
    5454    }
    5555
    56     bool EventTrigger::isTriggered(TriggerMode mode)
     56    bool EventTrigger::isTriggered(TriggerMode::Value mode)
    5757    {
    5858        if (Trigger::isTriggered(mode))
  • code/trunk/src/orxonox/objects/worldentities/triggers/EventTrigger.h

    r3196 r3280  
    4747
    4848        protected:
    49             virtual bool isTriggered(TriggerMode mode);
     49            virtual bool isTriggered(TriggerMode::Value mode);
    5050
    5151        private:
  • code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h

    r3196 r3280  
    7070           
    7171    protected:
    72         virtual bool isTriggered(TriggerMode mode) = 0;
     72        virtual bool isTriggered(TriggerMode::Value mode) = 0;
    7373       
    7474        /**
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r3196 r3280  
    4646    RegisterObject(Trigger);
    4747
    48     this->mode_ = TM_EventTriggerAND;
     48    this->mode_ = TriggerMode::EventTriggerAND;
    4949
    5050    this->bFirstTick_ = true;
     
    163163  }
    164164
    165   bool Trigger::isTriggered(TriggerMode mode)
     165  bool Trigger::isTriggered(TriggerMode::Value mode)
    166166  {
    167167//    if (this->bUpdating_)
     
    175175      switch (mode)
    176176      {
    177         case TM_EventTriggerAND:
     177        case TriggerMode::EventTriggerAND:
    178178          returnval = checkAnd();
    179179          break;
    180         case TM_EventTriggerOR:
     180        case TriggerMode::EventTriggerOR:
    181181          returnval = checkOr();
    182182          break;
    183         case TM_EventTriggerXOR:
     183        case TriggerMode::EventTriggerXOR:
    184184          returnval = checkXor();
    185185          break;
     
    270270  {
    271271    if (modeName == "and")
    272       this->setMode(TM_EventTriggerAND);
     272      this->setMode(TriggerMode::EventTriggerAND);
    273273    else if (modeName == "or")
    274       this->setMode(TM_EventTriggerOR);
     274      this->setMode(TriggerMode::EventTriggerOR);
    275275    else if (modeName == "xor")
    276       this->setMode(TM_EventTriggerXOR);
     276      this->setMode(TriggerMode::EventTriggerXOR);
    277277  }
    278278
    279279  std::string Trigger::getModeString() const
    280280  {
    281     if (this->mode_ == TM_EventTriggerAND)
     281    if (this->mode_ == TriggerMode::EventTriggerAND)
    282282      return std::string("and");
    283     else if (this->mode_ == TM_EventTriggerOR)
     283    else if (this->mode_ == TriggerMode::EventTriggerOR)
    284284      return std::string("or");
    285     else if (this->mode_ == TM_EventTriggerXOR)
     285    else if (this->mode_ == TriggerMode::EventTriggerXOR)
    286286      return std::string("xor");
    287287    else
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h

    r3196 r3280  
    4141namespace orxonox
    4242{
    43   enum TriggerMode
     43  namespace TriggerMode
    4444  {
    45     TM_EventTriggerAND,
    46     TM_EventTriggerOR,
    47     TM_EventTriggerXOR,
    48   };
     45    enum Value
     46    {
     47      EventTriggerAND,
     48      EventTriggerOR,
     49      EventTriggerXOR,
     50    };
     51  }
    4952
    5053  class _OrxonoxExport Trigger : public StaticEntity, public Tickable
     
    6467
    6568      void setMode(const std::string& modeName);
    66       inline void setMode(TriggerMode mode)
     69      inline void setMode(TriggerMode::Value mode)
    6770        { this->mode_ = mode; }
    68       inline TriggerMode getMode() const
     71      inline TriggerMode::Value getMode() const
    6972        { return mode_; }
    7073
     
    103106    protected:
    104107      inline bool isTriggered() { return this->isTriggered(this->mode_); }
    105       virtual bool isTriggered(TriggerMode mode);
     108      virtual bool isTriggered(TriggerMode::Value mode);
    106109      virtual void triggered(bool bIsTriggered);
    107110
     
    118121      bool bFirstTick_;
    119122
    120       TriggerMode mode_;
     123      TriggerMode::Value mode_;
    121124      bool bInvertMode_;
    122125      bool bSwitch_;
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r3196 r3280  
    4242#include "util/Convert.h"
    4343#include "util/Exception.h"
    44 #include "util/String.h"
     44#include "util/StringUtils.h"
    4545#include "core/GameMode.h"
    4646#include "core/CoreIncludes.h"
     
    7272        // create the Ogre::Overlay
    7373        overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
    74             + convertToString(hudOverlayCounter_s++));
     74            + multi_cast<std::string>(hudOverlayCounter_s++));
    7575
    7676        // create background panel (can be used to show any picture)
    7777        this->background_ = static_cast<Ogre::PanelOverlayElement*>(
    7878            Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
    79             "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
     79            "OrxonoxOverlay_background_" + multi_cast<std::string>(hudOverlayCounter_s++)));
    8080        this->overlay_->add2D(this->background_);
    8181
  • code/trunk/src/orxonox/overlays/OverlayText.cc

    r3196 r3280  
    3434#include <boost/static_assert.hpp>
    3535
    36 #include "util/String.h"
     36#include "util/StringUtils.h"
    3737#include "core/CoreIncludes.h"
    3838#include "core/XMLPort.h"
  • code/trunk/src/orxonox/overlays/console/InGameConsole.cc

    r3196 r3280  
    3030#include "InGameConsole.h"
    3131
     32#include <algorithm>
    3233#include <string>
    3334#include <OgreOverlay.h>
     
    219220        for (int i = 0; i < LINES; i++)
    220221        {
    221             this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
     222            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + multi_cast<std::string>(i)));
    222223            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
    223224            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
     
    425426
    426427        if (LINES > 0)
    427             this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
     428            this->maxCharsPerLine_ = std::max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
    428429        else
    429430            this->maxCharsPerLine_ = 10;
  • code/trunk/src/orxonox/overlays/hud/GametypeStatus.cc

    r3196 r3280  
    7070            {
    7171                if (gtinfo->isStartCountdownRunning())
    72                     this->setCaption(convertToString((int)ceil(gtinfo->getStartCountdown())));
     72                    this->setCaption(multi_cast<std::string>((int)ceil(gtinfo->getStartCountdown())));
    7373                else if (ce->isA(Class(Spectator)))
    7474                    this->setCaption("Press [Fire] to respawn");
  • code/trunk/src/orxonox/overlays/hud/HUDBar.cc

    r3196 r3280  
    3838
    3939#include "util/Convert.h"
    40 #include "util/String.h"
     40#include "util/StringUtils.h"
    4141#include "core/CoreIncludes.h"
    4242#include "core/XMLPort.h"
     
    7272
    7373        // create new material
    74         std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
     74        std::string materialname = "barmaterial" + multi_cast<std::string>(materialcount_s++);
    7575        Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
    7676        material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
  • code/trunk/src/orxonox/overlays/hud/HUDHealthBar.cc

    r3196 r3280  
    8383        {
    8484            this->setValue(this->owner_->getHealth() / this->owner_->getInitialHealth());
    85             this->textoverlay_->setCaption(convertToString((int)this->owner_->getHealth()));
     85            this->textoverlay_->setCaption(multi_cast<std::string>((int)this->owner_->getHealth()));
    8686        }
    8787
  • code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc

    r3196 r3280  
    3535
    3636#include "util/Math.h"
    37 #include "util/String.h"
     37#include "util/StringUtils.h"
    3838#include "util/Convert.h"
    3939#include "core/CoreIncludes.h"
     
    142142        // set text
    143143        int dist = (int) getDist2Focus();
    144         navText_->setCaption(convertToString(dist));
    145         float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
     144        navText_->setCaption(multi_cast<std::string>(dist));
     145        float textLength = multi_cast<std::string>(dist).size() * navText_->getCharHeight() * 0.3;
    146146
    147147/*
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.cc

    r3196 r3280  
    3434
    3535#include "util/Math.h"
    36 #include "util/String.h"
     36#include "util/StringUtils.h"
    3737#include "core/CoreIncludes.h"
    3838#include "core/XMLPort.h"
  • code/trunk/src/orxonox/overlays/hud/HUDTimer.cc

    r3196 r3280  
    5959            if (gametype->getTimerIsActive())
    6060            {
    61                 this->setCaption(convertToString((int)gametype->getTime() + 1));
     61                this->setCaption(multi_cast<std::string>((int)gametype->getTime() + 1));
    6262            }
    6363        }
  • code/trunk/src/orxonox/overlays/hud/PongScore.cc

    r3196 r3280  
    8383            {
    8484                name1 = player1->getName();
    85                 score1 = convertToString(this->owner_->getScore(player1));
     85                score1 = multi_cast<std::string>(this->owner_->getScore(player1));
    8686            }
    8787
     
    8989            {
    9090                name2 = player2->getName();
    91                 score2 = convertToString(this->owner_->getScore(player2));
     91                score2 = multi_cast<std::string>(this->owner_->getScore(player2));
    9292            }
    9393
  • code/trunk/src/orxonox/overlays/hud/TeamBaseMatchScore.cc

    r3196 r3280  
    7171        if (this->owner_)
    7272        {
    73             std::string bases1 = "(" + convertToString(this->owner_->getTeamBases(0)) + ")";
    74             std::string bases2 = "(" + convertToString(this->owner_->getTeamBases(1)) + ")";
     73            std::string bases1 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(0)) + ")";
     74            std::string bases2 = "(" + multi_cast<std::string>(this->owner_->getTeamBases(1)) + ")";
    7575
    76             std::string score1 = convertToString(this->owner_->getTeamPoints(0));
    77             std::string score2 = convertToString(this->owner_->getTeamPoints(1));
     76            std::string score1 = multi_cast<std::string>(this->owner_->getTeamPoints(0));
     77            std::string score2 = multi_cast<std::string>(this->owner_->getTeamPoints(1));
    7878
    7979            std::string output1;
  • code/trunk/src/orxonox/overlays/stats/CreateLines.cc

    r3196 r3280  
    9999    //    while (textColumns_.size() < numberOfColumns)
    100100    //    {
    101     //        Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + convertToString(lineIndex) + convertToString(colIndex)));
     101    //        Ogre::TextAreaOverlayElement* tempTextArea = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "StatsLineTextArea" + getName() + multi_cast<std::string>(lineIndex) + multi_cast<std::string>(colIndex)));
    102102    //        textColumns_.push_back(tempTextArea);
    103103    //        this->background_->addChild(tempTextArea);
  • code/trunk/src/orxonox/overlays/stats/Stats.cc

    r3196 r3280  
    3333#include <OgreBorderPanelOverlayElement.h>
    3434
    35 #include "util/String.h"
     35#include "util/StringUtils.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
  • code/trunk/src/orxonox/sound/SoundManager.cc

    r3196 r3280  
    3939{
    4040    SoundManager* SoundManager::singletonRef_s = NULL;
    41     ALCdevice* SoundManager::device_s = NULL;
    4241
    4342    /**
     
    4948        singletonRef_s = this;
    5049
     50        this->device_ = NULL;
    5151        this->soundavailable_ = true;
    5252        if(!alutInitWithoutContext(NULL,NULL))
     
    5757        else
    5858        {
    59             if(SoundManager::device_s == NULL)
    60             {
    61                 COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
    62                 SoundManager::device_s = alcOpenDevice(NULL);
    63             }
     59            assert(this->device_ == NULL);
     60            COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
     61            this->device_ = alcOpenDevice(NULL);
    6462
    65             if(SoundManager::device_s == NULL)
     63            if(this->device_ == NULL)
    6664            {
    6765                COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl;
     
    7169            {
    7270                COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl;
    73                 this->context_ = alcCreateContext(SoundManager::device_s, NULL);
     71                this->context_ = alcCreateContext(this->device_, NULL);
    7472                if(this->context_ == NULL)
    7573                {
     
    9997
    10098        alcDestroyContext(this->context_);
    101         alcCloseDevice(SoundManager::device_s);
     99        alcCloseDevice(this->device_);
    102100        alutExit();
    103101    }
  • code/trunk/src/orxonox/sound/SoundManager.h

    r3196 r3280  
    5555
    5656    private:
    57         static ALCdevice* device_s;
     57        ALCdevice* device_;
    5858        ALCcontext* context_;
    5959        std::list<SoundBase*> soundlist_;
  • code/trunk/src/orxonox/tools/BillboardSet.cc

    r3196 r3280  
    3838#include "util/Convert.h"
    3939#include "util/Math.h"
    40 #include "util/String.h"
     40#include "util/StringUtils.h"
    4141#include "core/GameMode.h"
    4242
     
    7474            if (GameMode::showsGraphics())
    7575            {
    76                 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     76                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + multi_cast<std::string>(BillboardSet::billboardSetCounter_s++), count);
    7777                this->billboardSet_->createBillboard(position);
    7878                this->billboardSet_->setMaterialName(file);
     
    9797            if (GameMode::showsGraphics())
    9898            {
    99                 this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
     99                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + multi_cast<std::string>(BillboardSet::billboardSetCounter_s++), count);
    100100                this->billboardSet_->createBillboard(position, colour);
    101101                this->billboardSet_->setMaterialName(file);
  • code/trunk/src/orxonox/tools/Mesh.cc

    r3196 r3280  
    3636
    3737#include "util/Convert.h"
    38 #include "util/String.h"
     38#include "util/StringUtils.h"
    3939#include "core/GameMode.h"
    4040
     
    6868            try
    6969            {
    70                 this->entity_ = this->scenemanager_->createEntity("Mesh" + convertToString(Mesh::meshCounter_s++), meshsource);
     70                this->entity_ = this->scenemanager_->createEntity("Mesh" + multi_cast<std::string>(Mesh::meshCounter_s++), meshsource);
    7171                this->entity_->setCastShadows(this->bCastShadows_);
    7272
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r3196 r3280  
    5151    ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
    5252
    53     ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
     53    ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel)
    5454    {
    5555        RegisterObject(ParticleInterface);
     
    6969            try
    7070            {
    71                 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
     71                this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + multi_cast<std::string>(ParticleInterface::counter_s++), templateName);
    7272                this->setSpeedFactor(1.0f);
    7373            }
  • code/trunk/src/orxonox/tools/ParticleInterface.h

    r3196 r3280  
    4545    {
    4646        public:
    47             ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel);
     47            ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::Value detaillevel);
    4848            virtual ~ParticleInterface();
    4949
  • code/trunk/src/orxonox/tools/TextureGenerator.cc

    r3196 r3280  
    7272        if (it == colourMap.end())
    7373        {
    74             std::string materialName = textureName + "_Material_" + convertToString(materialCount_s++);
     74            std::string materialName = textureName + "_Material_" + multi_cast<std::string>(materialCount_s++);
    7575            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialName, "General");
    7676            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
  • code/trunk/src/util/CMakeLists.txt

    r3196 r3280  
    2929  SignalHandler.cc
    3030  Sleep.cc
    31   String.cc
     31  StringUtils.cc
    3232  SubString.cc
    3333)
  • code/trunk/src/util/Convert.h

    r3234 r3280  
    4343
    4444#include "Debug.h"
    45 #include "String.h"
     45#include "StringUtils.h"
    4646#include "TemplateUtils.h"
    4747
     
    316316    }
    317317
    318     // convert to string Shortcut
    319     template <class FromType>
    320     FORCEINLINE std::string convertToString(FromType value)
    321     {
    322         return getConvertedValue<FromType, std::string>(value);
    323     }
    324 
    325     // convert from string Shortcut
    326     template <class ToType>
    327     FORCEINLINE ToType convertFromString(std::string str)
    328     {
    329         return getConvertedValue<std::string, ToType>(str);
    330     }
    331 
    332318    ////////////////////////////////
    333319    // Special string conversions //
  • code/trunk/src/util/Exception.cc

    r3196 r3280  
    6464            std::ostringstream fullDesc;
    6565
    66             fullDesc << this->getTypeName() << "_EXCEPTION";
     66            fullDesc << this->getTypeName() << "Exception";
    6767
    6868            if (this->filename_ != "")
     
    8787        return fullDescription_;
    8888    }
     89
     90    //! Returns the error description
     91    const char* Exception::what() const throw()
     92    {
     93        return getDescription().c_str();
     94    }
    8995}
  • code/trunk/src/util/Exception.h

    r3196 r3280  
    6868        //! Needed for compatibility with std::exception
    6969        virtual ~Exception() throw() { }
     70        const char* what() const throw();
    7071
    7172        //! Returns a full description with type, line, file and function
     
    8182        //! Returns the filename in which the exception occurred.
    8283        virtual const std::string& getFilename()        const { return this->filename_; }
    83 
    84         //! Returns a full description of the error.
    85         const char* what() const throw() { return getFullDescription().c_str(); }
    8684
    8785    protected:
     
    152150    Exception description as string
    153151*/
    154 #define ThrowException(type, description, ...) \
     152#define ThrowException(type, description) \
    155153    throw orxonox::exceptionThrowerHelper(type##Exception(static_cast<std::ostringstream&>(std::ostringstream().flush() << description).str(), __LINE__, __FILE__, __FUNCTIONNAME__))
    156154
  • code/trunk/src/util/Math.h

    r3214 r3280  
    7878    {
    7979        return (x >= 0) ? 1 : -1;
    80     }
    81 
    82     /**
    83         @brief Returns the smaller of two values.
    84     */
    85     template <typename T>
    86     inline T min(T a, T b)
    87     {
    88         return (a <= b) ? a : b;
    89     }
    90 
    91     /**
    92         @brief Returns the greater of two values.
    93     */
    94     template <typename T>
    95     inline T max(T a, T b)
    96     {
    97         return (a >= b) ? a : b;
    9880    }
    9981
  • code/trunk/src/util/MultiType.cc

    r3196 r3280  
    4141        @param type The type
    4242    */
    43     bool MultiType::convert(MT_Type type)
     43    bool MultiType::convert(MT_Type::Value type)
    4444    {
    4545        switch (type)
    4646        {
    47             case MT_null:
     47            case MT_Type::Null:
    4848                this->reset(); return true;
    49             case MT_char:
     49            case MT_Type::Char:
    5050                return this->convert<char>(); break;
    51             case MT_uchar:
     51            case MT_Type::UnsignedChar:
    5252                return this->convert<unsigned char>(); break;
    53             case MT_short:
     53            case MT_Type::Short:
    5454                return this->convert<short>(); break;
    55             case MT_ushort:
     55            case MT_Type::UnsignedShort:
    5656                return this->convert<unsigned short>(); break;
    57             case MT_int:
     57            case MT_Type::Int:
    5858                return this->convert<int>(); break;
    59             case MT_uint:
     59            case MT_Type::UnsignedInt:
    6060                return this->convert<unsigned int>(); break;
    61             case MT_long:
     61            case MT_Type::Long:
    6262                return this->convert<long>(); break;
    63             case MT_ulong:
     63            case MT_Type::UnsignedLong:
    6464                return this->convert<unsigned long>(); break;
    65             case MT_longlong:
     65            case MT_Type::LongLong:
    6666                return this->convert<long long>(); break;
    67             case MT_ulonglong:
     67            case MT_Type::UnsignedLongLong:
    6868                return this->convert<unsigned long long>(); break;
    69             case MT_float:
     69            case MT_Type::Float:
    7070                return this->convert<float>(); break;
    71             case MT_double:
     71            case MT_Type::Double:
    7272                return this->convert<double>(); break;
    73             case MT_longdouble:
     73            case MT_Type::LongDouble:
    7474                return this->convert<long double>(); break;
    75             case MT_bool:
     75            case MT_Type::Bool:
    7676                return this->convert<bool>(); break;
    77             case MT_void:
     77            case MT_Type::VoidPointer:
    7878                return this->convert<void*>(); break;
    79             case MT_string:
     79            case MT_Type::String:
    8080                return this->convert<std::string>(); break;
    81             case MT_vector2:
     81            case MT_Type::Vector2:
    8282                return this->convert<orxonox::Vector2>(); break;
    83             case MT_vector3:
     83            case MT_Type::Vector3:
    8484                return this->convert<orxonox::Vector3>(); break;
    85             case MT_vector4:
     85            case MT_Type::Vector4:
    8686                return this->convert<orxonox::Vector4>(); break;
    87             case MT_colourvalue:
     87            case MT_Type::ColourValue:
    8888                return this->convert<orxonox::ColourValue>(); break;
    89             case MT_quaternion:
     89            case MT_Type::Quaternion:
    9090                return this->convert<orxonox::Quaternion>(); break;
    91             case MT_radian:
     91            case MT_Type::Radian:
    9292                return this->convert<orxonox::Radian>(); break;
    93             case MT_degree:
     93            case MT_Type::Degree:
    9494                return this->convert<orxonox::Degree>(); break;
    9595            default:
     
    104104    std::string MultiType::getTypename() const
    105105    {
    106         MT_Type type = (this->value_) ? this->value_->type_ : MT_null;
     106        MT_Type::Value type = (this->value_) ? this->value_->type_ : MT_Type::Null;
    107107
    108108        switch (type)
    109109        {
    110             case MT_char:
     110            case MT_Type::Char:
    111111                return "char"; break;
    112             case MT_uchar:
     112            case MT_Type::UnsignedChar:
    113113                return "unsigned char"; break;
    114             case MT_short:
     114            case MT_Type::Short:
    115115                return "short"; break;
    116             case MT_ushort:
     116            case MT_Type::UnsignedShort:
    117117                return "unsigned short"; break;
    118             case MT_int:
     118            case MT_Type::Int:
    119119                return "int"; break;
    120             case MT_uint:
     120            case MT_Type::UnsignedInt:
    121121                return "unsigned int"; break;
    122             case MT_long:
     122            case MT_Type::Long:
    123123                return "long"; break;
    124             case MT_ulong:
     124            case MT_Type::UnsignedLong:
    125125                return "unsigned long"; break;
    126             case MT_longlong:
     126            case MT_Type::LongLong:
    127127                return "long long"; break;
    128             case MT_ulonglong:
     128            case MT_Type::UnsignedLongLong:
    129129                return "unsigned long long"; break;
    130             case MT_float:
     130            case MT_Type::Float:
    131131                return "float"; break;
    132             case MT_double:
     132            case MT_Type::Double:
    133133                return "double"; break;
    134             case MT_longdouble:
     134            case MT_Type::LongDouble:
    135135                return "long double"; break;
    136             case MT_bool:
     136            case MT_Type::Bool:
    137137                return "bool"; break;
    138             case MT_void:
     138            case MT_Type::VoidPointer:
    139139                return "void*"; break;
    140             case MT_string:
     140            case MT_Type::String:
    141141                return "std::string"; break;
    142             case MT_vector2:
     142            case MT_Type::Vector2:
    143143                return "orxonox::Vector2"; break;
    144             case MT_vector3:
     144            case MT_Type::Vector3:
    145145                return "orxonox::Vector3"; break;
    146             case MT_vector4:
     146            case MT_Type::Vector4:
    147147                return "orxonox::Vector4"; break;
    148             case MT_colourvalue:
     148            case MT_Type::ColourValue:
    149149                return "orxonox::ColourValue"; break;
    150             case MT_quaternion:
     150            case MT_Type::Quaternion:
    151151                return "orxonox::Quaternion"; break;
    152             case MT_radian:
     152            case MT_Type::Radian:
    153153                return "orxonox::Radian"; break;
    154             case MT_degree:
     154            case MT_Type::Degree:
    155155                return "orxonox::Degree"; break;
    156156            default:
     
    159159    }
    160160
    161     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. */
    162     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. */
    163     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. */
    164     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. */
    165     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. */
    166     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. */
    167     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. */
    168     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. */
    169     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. */
    170     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. */
    171     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. */
    172     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. */
    173     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. */
    174     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. */
    175     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. */
    176     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. */
    177     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. */
    178     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. */
    179     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. */
    180     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. */
    181     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. */
    182     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. */
    183     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. */
    184 
    185     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. */
    186     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. */
    187     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. */
    188     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. */
    189     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. */
    190     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. */
    191     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. */
    192     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. */
    193     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. */
    194     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. */
    195     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. */
    196     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. */
    197     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. */
    198     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. */
    199     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. */
    200     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. */
    201     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. */
    202     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. */
    203     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. */
    204     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. */
    205     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. */
    206     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. */
    207     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. */
     161    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. */
     162    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. */
     163    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. */
     164    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. */
     165    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. */
     166    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. */
     167    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. */
     168    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. */
     169    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. */
     170    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. */
     171    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. */
     172    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. */
     173    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. */
     174    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. */
     175    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. */
     176    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. */
     177    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. */
     178    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. */
     179    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. */
     180    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. */
     181    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. */
     182    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. */
     183    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. */
     184
     185    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. */
     186    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. */
     187    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. */
     188    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. */
     189    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. */
     190    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. */
     191    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. */
     192    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. */
     193    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. */
     194    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. */
     195    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. */
     196    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. */
     197    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. */
     198    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. */
     199    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. */
     200    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. */
     201    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. */
     202    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. */
     203    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. */
     204    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. */
     205    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. */
     206    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. */
     207    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. */
    208208}
  • code/trunk/src/util/MultiType.h

    r3241 r3280  
    8484        @brief Enum of all possible types of a MultiType.
    8585    */
    86     enum MT_Type
     86    namespace MT_Type
    8787    {
    88         MT_null=0,
    89         MT_char=1,
    90         MT_uchar=2,
    91         MT_short=3,
    92         MT_ushort=4,
    93         MT_int=5,
    94         MT_uint=6,
    95         MT_long=7,
    96         MT_ulong=8,
    97         MT_longlong=9,
    98         MT_ulonglong=10,
    99         MT_float=11,
    100         MT_double=12,
    101         MT_longdouble=13,
    102         MT_bool=14,
    103         MT_void=15,
    104         MT_string=16,
    105         MT_vector2=17,
    106         MT_vector3=18,
    107         MT_vector4=19,
    108         MT_colourvalue=20,
    109         MT_quaternion=21,
    110         MT_radian=22,
    111         MT_degree=23
    112     };
     88        enum Value
     89        {
     90            Null,
     91            Char,
     92            UnsignedChar,
     93            Short,
     94            UnsignedShort,
     95            Int,
     96            UnsignedInt,
     97            Long,
     98            UnsignedLong,
     99            LongLong,
     100            UnsignedLongLong,
     101            Float,
     102            Double,
     103            LongDouble,
     104            Bool,
     105            VoidPointer,
     106            String,
     107            Vector2,
     108            Vector3,
     109            Vector4,
     110            ColourValue,
     111            Quaternion,
     112            Radian,
     113            Degree
     114        };
     115    }
    113116
    114117    /**
     
    142145        {
    143146        public:
    144             MT_ValueBase(MT_Type type) : type_(type), bHasDefaultValue_(false) {}
     147            MT_ValueBase(MT_Type::Value type) : type_(type), bHasDefaultValue_(false) {}
    145148            virtual ~MT_ValueBase() {}
    146149
     
    151154
    152155            /** @brief Returns the type of the current value. */
    153             const MT_Type& getType() const { return this->type_; }
     156            const MT_Type::Value& getType() const { return this->type_; }
    154157
    155158            /** @brief Checks whether the value is a default one. */
     
    234237            virtual uint8_t getSize() const=0;
    235238
    236             MT_Type type_;          //!< The type of the current value
     239            MT_Type::Value type_;   //!< The type of the current value
    237240            bool bHasDefaultValue_; //!< True if the last conversion wasn't successful
    238241        };
     
    265268            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. */
    266269            inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
    267             inline MultiType(MT_Type type)                      : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */
     270            inline MultiType(MT_Type::Value type)               : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */
    268271
    269272            /** @brief Destructor: Deletes the MT_Value. */
     
    273276            template <typename V> inline const MultiType& operator=(V* value)               { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
    274277            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. */
    275             inline                       const MultiType& operator=(MT_Type type)           { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
     278            inline                       const MultiType& operator=(MT_Type::Value type)    { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
    276279
    277280            inline bool                                   setValue(const char& value);
     
    312315            template <typename T> inline bool convert()                       { return this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
    313316            inline bool                       convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
    314             bool                              convert(MT_Type type);
    315 
    316             /** @brief Current content gets deleted. New type is MT_null */
     317            bool                              convert(MT_Type::Value type);
     318
     319            /** @brief Current content gets deleted. New type is MT_Type::Null */
    317320            inline void                       reset()                         { if (this->value_) delete this->value_; this->value_ = 0; }
    318321            /** @brief Current content gets overridden with default zero value */
     
    321324            template <typename T> inline void setType()                       { this->assignValue(typename TypeStripper<T>::RawType()); } /** @brief Resets the value and changes the internal type to T. */
    322325            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. */
    323             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. */
     326            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. */
    324327
    325328            /** @brief Returns the current type. */
    326             inline MT_Type                    getType()                 const { return (this->value_) ? this->value_->type_ : MT_null; }
     329            inline MT_Type::Value             getType()                   const { return (this->value_) ? this->value_->type_ : MT_Type::Null; }
    327330            /** @brief Returns true if the current type equals the given type. */
    328             inline bool                       isType(MT_Type type)      const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
     331            inline bool                       isType(MT_Type::Value type) const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_Type::Null); }
    329332            /** @brief Returns true if the current type is T. */
    330             template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
    331             std::string                       getTypename()             const;
     333            template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below
     334            std::string                       getTypename()               const;
    332335           
    333336            /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
    334             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); }
     337            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); }
    335338            /** @brief Loads the value of the MT from a bytestream (pointed at by mem) and increases mem pointer by size of MT */
    336             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); }
     339            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); }
    337340            /** @brief Saves the value of the MT to a bytestream and increases pointer to bytestream by size of MT */
    338341            inline uint8_t*&                  operator << (uint8_t*& mem) { importData(mem); return mem; }
     
    420423
    421424        private:
    422             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. */
    423             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. */
    424             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. */
    425             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. */
    426             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. */
    427             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. */
    428             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. */
    429             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. */
    430             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. */
    431             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. */
    432             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. */
    433             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. */
    434             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. */
    435             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. */
    436             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. */
    437             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. */
    438             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. */
    439             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. */
    440             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. */
    441             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. */
    442             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. */
    443             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. */
    444             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. */
     425            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. */
     426            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. */
     427            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. */
     428            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. */
     429            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. */
     430            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. */
     431            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. */
     432            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. */
     433            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. */
     434            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. */
     435            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. */
     436            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. */
     437            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. */
     438            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. */
     439            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. */
     440            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. */
     441            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. */
     442            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. */
     443            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. */
     444            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. */
     445            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. */
     446            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. */
     447            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. */
    445448
    446449            /** @brief Changes the value container. */
     
    455458    _UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
    456459
    457     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. */
    458     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. */
    459     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. */
    460     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. */
    461     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. */
    462     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. */
    463     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. */
    464     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. */
    465     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. */
    466     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. */
    467     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. */
    468     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. */
    469     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. */
    470     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. */
    471     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. */
    472     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. */
    473     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. */
    474     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. */
    475     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. */
    476     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. */
    477     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. */
    478     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. */
    479     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. */
     460    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. */
     461    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. */
     462    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. */
     463    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. */
     464    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. */
     465    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. */
     466    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. */
     467    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. */
     468    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. */
     469    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. */
     470    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. */
     471    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. */
     472    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. */
     473    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. */
     474    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. */
     475    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. */
     476    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. */
     477    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. */
     478    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. */
     479    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. */
     480    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. */
     481    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. */
     482    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. */
    480483
    481484    // Specialization to avoid ambiguities with the conversion operator
  • code/trunk/src/util/MultiTypeValue.h

    r3196 r3280  
    5454    public:
    5555        /** @brief Constructor: Assigns the value and the type identifier. */
    56         MT_Value(const T& value, MT_Type type) : MT_ValueBase(type), value_(value) {}
     56        MT_Value(const T& value, MT_Type::Value type) : MT_ValueBase(type), value_(value) {}
    5757
    5858        /** @brief Creates a copy of itself. */
     
    139139        inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    140140        inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
    141         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. */
    142         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. */
    143         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. */
    144         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. */
    145         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. */
    146         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. */
    147         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. */
    148         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. */
     141        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. */
     142        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. */
     143        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. */
     144        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. */
     145        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. */
     146        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. */
     147        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. */
     148        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. */
    149149
    150150        /** @brief Puts the current value on the stream */
  • code/trunk/src/util/StringUtils.cc

    r3251 r3280  
    4444    std::string getUniqueNumberString()
    4545    {
    46         return convertToString(getUniqueNumber());
     46        return multi_cast<std::string>(getUniqueNumber());
    4747    }
    4848
  • code/trunk/src/util/UtilPrereqs.h

    r3196 r3280  
    6060// Forward declarations
    6161//-----------------------------------------------------------------------
     62
     63namespace orxonox
     64{
     65    class Exception;
     66    class ExprParser;
     67    class IntVector2;
     68    class IntVector3;
     69    class MultiType;
     70    class OutputBuffer;
     71    class OutputBufferListener;
     72    class OutputHandler;
     73    class SignalHandler;
     74    class SubString;
     75}
     76
    6277namespace Ogre
    6378{
     
    7287    class ColourValue;
    7388}
    74 
    7589namespace orxonox
    7690{
     
    8498    using Ogre::Quaternion;
    8599    using Ogre::ColourValue;
     100}
    86101
    87     class Exception;
    88     class ExprParser;
    89     class IntVector2;
    90     class IntVector3;
    91     class MultiType;
    92     class OutputBuffer;
    93     class OutputBufferListener;
    94     class OutputHandler;
    95     class SignalHandler;
    96     class SubString;
     102namespace Loki
     103{
     104    class ScopeGuardImplBase;
     105    typedef const ScopeGuardImplBase& ScopeGuard;
    97106}
    98107
Note: See TracChangeset for help on using the changeset viewer.