Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8729 for code/trunk/src


Ignore:
Timestamp:
Jul 4, 2011, 2:47:44 AM (13 years ago)
Author:
rgrieder
Message:

Merged unity_build branch back to trunk.

Features:

  • Implemented fully automatic build units to speed up compilation if requested
  • Added DOUT macro for quick debug output
  • Activated text colouring in the POSIX IOConsole
  • DeclareToluaInterface is not necessary anymore

Improvements:

  • Output levels now change appropriately when switch back and forth from dev mode
  • Log level for the file output is now also correct during startup
  • Removed some header file dependencies in core and tools to speed up compilation

no more file for command line options

  • Improved util::tribool by adapting some concepts from boost::tribool

Regressions:

  • It is not possible anymore to specify command line arguments in an extra file because we've got config values for that purpose.
Location:
code/trunk
Files:
2 deleted
90 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/CMakeLists.txt

    r8420 r8729  
    6565      REMOVE_LINKER_FLAGS("-INCREMENTAL:YES" Debug)
    6666      ADD_LINKER_FLAGS   ("-INCREMENTAL:NO"  Debug)
    67     ENDIF()
    68     IF(NOT DISABLE_COMPILATIONS)
    69       # Compilations seem to generate 'memory leaks' with static variables
    70       MESSAGE("Warning: You should disable Compilations when using VLD!")
    7167    ENDIF()
    7268  ENDIF()
     
    149145################### Tolua Bind ##################
    150146
    151 # Create directory because the tolua application doesn't work otherwise
    152 IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR})
    153   FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR})
    154 ENDIF()
    155 
    156 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR})
     147# Add hook script to the lua code that generates the bindings
     148SET(TOLUA_PARSER_HOOK_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/libraries/core/ToluaInterfaceHook.lua)
     149SET(TOLUA_PARSER_DEPENDENCIES ${TOLUA_PARSER_DEPENDENCIES} ${TOLUA_PARSER_HOOK_SCRIPT})
    157150
    158151################ Sub Directories ################
  • code/trunk/src/OrxonoxConfig.cmake

    r8412 r8729  
    3434ENDIF()
    3535
    36 # Global switch to disable multiple file compilations
    37 OPTION(DISABLE_COMPILATIONS "Global multi-file compilation switch" FALSE)
     36# Global option to steer building muliple files as a single one
     37# off/false: Turn off completely
     38# partial:   Only combine files explicitly specified with BUILD_UNIT
     39# full##:    Use ## source files per orxonox library and use manual build units
     40#            for external dependencies. Example: full8 will in general use 8
     41#            source files per library, but more specifically tries to occupy
     42#            8 CPU threads.
     43#            This is configured manually in BuildUnitsConfig.cmake
     44SET(ENABLE_BUILD_UNITS "partial" CACHE STRING "Enables building multiple source files as one.")
     45IF(ENABLE_BUILD_UNITS)
     46  IF(NOT "${ENABLE_BUILD_UNITS}" STREQUAL "partial")
     47    STRING(REGEX REPLACE "^full([1-9][0-9]?)$" "\\1" _nr_of_units "${ENABLE_BUILD_UNITS}")
     48    IF("${_nr_of_units}" STREQUAL "${ENABLE_BUILD_UNITS}") # Regex match failed
     49      MESSAGE(FATAL_ERROR "Unrecognised option for ENABLE_BUILD_UNITS: ${ENABLE_BUILD_UNITS}")
     50    ELSE()
     51      SET(NR_OF_BUILD_UNITS ${_nr_of_units})
     52      IF(NOT HAVE_COUNTER_MACRO)
     53        MESSAGE(WARNING "Your compiler doesn't support the __COUNTER__ macro. Full build units might not work!")
     54      ENDIF()
     55    ENDIF()
     56  ENDIF()
     57  IF(CMAKE_COMPILER_IS_GNU)
     58    INCLUDE(BuildUnitsConfigGCC.cmake)
     59  ELSEIF(MSVC)
     60    INCLUDE(BuildUnitsConfigMSVC.cmake)
     61  ENDIF()
     62ENDIF()
    3863
    3964# Use WinMain() or main()?
  • code/trunk/src/external/bullet/BulletCollision/CMakeLists.txt

    r8393 r8729  
    11ADD_SOURCE_FILES(BULLET_FILES
    2 
    3 COMPILATION_BEGIN BulletCollisionCompilation.cpp
    42
    53        BroadphaseCollision/btAxisSweep3.cpp
     
    8482        NarrowPhaseCollision/btMinkowskiPenetrationDepthSolver.cpp
    8583        NarrowPhaseCollision/btPersistentManifold.cpp
     84        NarrowPhaseCollision/btPolyhedralContactClipping.cpp
    8685        NarrowPhaseCollision/btRaycastCallback.cpp
    8786        NarrowPhaseCollision/btSubSimplexConvexCast.cpp
    8887        NarrowPhaseCollision/btVoronoiSimplexSolver.cpp
    8988
    90 COMPILATION_END
    91 
    92     # Raises compiler errors when compiled inside the compilation
    93         NarrowPhaseCollision/btPolyhedralContactClipping.cpp
    9489
    9590        # Headers
  • code/trunk/src/external/bullet/BulletDynamics/CMakeLists.txt

    r8351 r8729  
    11ADD_SOURCE_FILES(BULLET_FILES
    2 
    3 COMPILATION_BEGIN BulletDynamicsCompilation.cpp
    42
    53        Character/btKinematicCharacterController.cpp
     
    2523        Vehicle/btRaycastVehicle.cpp
    2624        Vehicle/btWheelInfo.cpp
    27 
    28 COMPILATION_END
    2925
    3026        # Headers
  • code/trunk/src/external/bullet/CMakeLists.txt

    r8393 r8729  
    3232  VERSION
    3333    2.78
     34  EXCLUDE_FROM_BUILD_UNITS
     35    BulletCollision/NarrowPhaseCollision/btPolyhedralContactClipping.cpp
    3436  SOURCE_FILES
    3537    ${BULLET_FILES}
  • code/trunk/src/external/bullet/LinearMath/CMakeLists.txt

    r8393 r8729  
    11ADD_SOURCE_FILES(BULLET_FILES
    22
    3 COMPILATION_BEGIN BulletLinearMathCompilation.cpp
    43        btAlignedAllocator.cpp
    54        btConvexHull.cpp
    6     btConvexHullComputer.cpp
     5        btConvexHullComputer.cpp
    76        btGeometryUtil.cpp
    87        btQuickprof.cpp
    98        btSerializer.cpp
    10 COMPILATION_END
    119
    1210        # Headers
     
    1513        btAlignedObjectArray.h
    1614        btConvexHull.h
    17     btConvexHullComputer.h
     15        btConvexHullComputer.h
    1816        btDefaultMotionState.h
    1917        btGeometryUtil.h
  • code/trunk/src/external/enet/CMakeLists.txt

    r8351 r8729  
    2929    win32.h
    3030
    31 COMPILATION_BEGIN ENetCompilation.c
    3231    callbacks.c
    3332    compress.c
     
    3938    unix.c
    4039    win32.c
    41 COMPILATION_END
    4240)
    4341
  • code/trunk/src/external/ogreceguirenderer/CMakeLists.txt

    r8351 r8729  
    2323  OgreCEGUITexture.h
    2424
    25 COMPILATION_BEGIN OgreCEGUIRendererCompilation.cpp
    2625  OgreCEGUIRenderer.cpp
    2726  OgreCEGUIResourceProvider.cpp
    2827  OgreCEGUITexture.cpp
    29 COMPILATION_END
    3028)
    3129
  • code/trunk/src/external/ois/CMakeLists.txt

    r8351 r8729  
    3535  OISPrereqs.h
    3636
    37 #COMPILATION_BEGIN OISCompilation.cpp
    3837  OISEffect.cpp
    3938  OISException.cpp
     
    4342  OISKeyboard.cpp
    4443  OISObject.cpp
    45 #COMPILATION_END
    4644)
     45
    4746IF(WIN32)
    4847  ADD_SUBDIRECTORY(win32)
     
    5655IF(MINGW)
    5756  INCLUDE_DIRECTORIES(${WMI_INCLUDE_DIR})
     57ENDIF()
     58
     59# Apple has problems with OIS and build units
     60IF(APPLE)
     61  SET(USE_BUILD_UNITS NO_BUILD_UNITS)
    5862ENDIF()
    5963
     
    7276  LINK_LIBS_LINUX
    7377    X11
     78  ${USE_BUILD_UNITS}
    7479  SOURCE_FILES
    7580    ${OIS_FILES}
  • code/trunk/src/external/ois/linux/CMakeLists.txt

    r5929 r8729  
    88  LinuxPrereqs.h
    99
    10 COMPILATION_BEGIN OISLinuxCompilation.cpp
    1110  EventHelpers.cpp
    1211  LinuxForceFeedback.cpp
     
    1514  LinuxKeyboard.cpp
    1615  LinuxMouse.cpp
    17 COMPILATION_END
    1816)
  • code/trunk/src/external/ois/mac/CMakeLists.txt

    r8351 r8729  
    88  MacPrereqs.h
    99
    10 #COMPILATION_BEGIN OISMacCompilation.cpp
    1110  MacHelpers.cpp
    1211  MacHIDManager.cpp
     
    1514  MacKeyboard.cpp
    1615  MacMouse.cpp
    17 #COMPILATION_END
    1816)
  • code/trunk/src/external/ois/win32/CMakeLists.txt

    r5929 r8729  
    77  Win32Prereqs.h
    88
    9 COMPILATION_BEGIN OISWin32Compilation.cpp
    109  Win32ForceFeedback.cpp
    1110  Win32InputManager.cpp
     
    1312  Win32KeyBoard.cpp
    1413  Win32Mouse.cpp
    15 COMPILATION_END
    1614)
  • code/trunk/src/external/tinyxml/CMakeLists.txt

    r8351 r8729  
    2424  tinyxml.h
    2525
    26 COMPILATION_BEGIN TicppCompilation.cpp
    2726  ticpp.cpp
    2827  tinystr.cpp
     
    3029  tinyxmlerror.cpp
    3130  tinyxmlparser.cpp
    32 COMPILATION_END
    3331)
    3432
  • code/trunk/src/external/tolua/lua/basic.lua

    r5738 r8729  
    354354end
    355355
    356 
     356-- called after all the required C++ includes have been written
     357function post_include_hook(package_name)
     358end
  • code/trunk/src/external/tolua/lua/package.lua

    r8363 r8729  
    135135        i = i+1
    136136    end
     137
     138    post_include_hook(self.name)
    137139
    138140    output('\n')
  • code/trunk/src/libraries/core/CMakeLists.txt

    r8351 r8729  
    1919
    2020SET_SOURCE_FILES(CORE_SRC_FILES
     21
     22#BUILD_UNIT CoreStableBuildUnit.cc
     23  ClassTreeMask.cc
    2124  CommandLineParser.cc
    2225  ConfigValueContainer.cc
    23   Core.cc
    2426  DynLib.cc
    2527  DynLibManager.cc
     
    2830  GameMode.cc
    2931  GameState.cc
    30   GraphicsManager.cc
    31   GUIManager.cc
     32  Identifier.cc
    3233  Language.cc
     34  Loader.cc
    3335  LuaState.cc
     36  MetaObjectList.cc
     37  Namespace.cc
     38  NamespaceNode.cc
    3439  ObjectListBase.cc
    3540  OrxonoxClass.cc
    36   Resource.cc
    37 
    38   # hierarchy
    39   Identifier.cc
    40   MetaObjectList.cc
    41 
    42   # level
    43   BaseObject.cc
    44   ClassTreeMask.cc
    45   Loader.cc
    46   Namespace.cc
    47   NamespaceNode.cc
    4841  Template.cc
    49   XMLPort.cc
    50 
    51 COMPILATION_BEGIN ListenerCompilation.cc
    5242  ViewportEventListener.cc
    5343  WindowEventListener.cc
    5444  XMLNameListener.cc
    55 COMPILATION_END
     45  XMLPort.cc
     46#END_BUILD_UNIT
    5647
    57 COMPILATION_BEGIN FilesystemCompilation.cc
     48  BaseObject.cc
     49  Core.cc
     50
     51BUILD_UNIT OgreBuildUnit.cc
     52  GraphicsManager.cc
     53  GUIManager.cc
     54  Resource.cc
     55END_BUILD_UNIT
     56
     57BUILD_UNIT FilesystemBuildUnit.cc
    5858  command/ArgumentCompletionFunctions.cc
    5959  ConfigFileManager.cc
    6060  PathConfig.cc
    61 COMPILATION_END
     61END_BUILD_UNIT
    6262
    63   # multithreading
    64   ThreadPool.cc
    65 COMPILATION_BEGIN ThreadCompilation.cc
     63BUILD_UNIT ThreadBuildUnit.cc
    6664  command/TclThreadManager.cc
    6765  Thread.cc
    68 COMPILATION_END
     66  ThreadPool.cc
     67END_BUILD_UNIT
    6968)
    7069
  • code/trunk/src/libraries/core/CommandLineParser.cc

    r7401 r8729  
    4141namespace orxonox
    4242{
    43     SetCommandLineOnlyArgument(optionsFile, "start.ini").shortcut("o");
    44 
    4543    /**
    4644    @brief
     
    5048        so that you can have simple command line switches.
    5149    */
    52     void CommandLineArgument::parse(const std::string& value, bool bParsingFile)
    53     {
    54         if (bParsingFile && this->bCommandLineOnly_)
    55             ThrowException(Argument, "Command line argument '" + getName() + "' is not allowed in files.");
     50    void CommandLineArgument::parse(const std::string& value)
     51    {
    5652        if (value_.getType() == MT_Type::Bool)
    5753        {
     
    116112    }
    117113
    118     /**
    119     @brief
    120         Reads the command line parses the values of each argument.
    121         It is then stored in the corresponding CommandLineArgument.
     114    /** Parses the command line string for arguments and stores these.
    122115    @note
    123116        The reason that you have to provide the string to be parsed as
    124         space separted list is because of argc and argv. If you only have
     117        space separated list is because of argc and argv. If you only have
    125118        a whole string, simply use getAllStrings() of SubString.
    126     @param arguments
    127         Vector of space separated strings.
    128     @param bParsingFile
    129         Parsing a file or the command line itself
    130     */
    131     void CommandLineParser::_parse(const std::vector<std::string>& arguments, bool bParsingFile)
    132     {
     119    @param cmdLine
     120        Command line string WITHOUT the execution path.
     121    */
     122    void CommandLineParser::_parse(const std::string& cmdLine)
     123    {
     124        std::vector<std::string> arguments;
     125        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
     126        for (unsigned i = 0; i < tokens.size(); ++i)
     127            arguments.push_back(tokens[i]);
     128
    133129        try
    134130        {
     
    177173                            if (!name.empty())
    178174                            {
    179                                 checkFullArgument(name, value, bParsingFile);
     175                                checkFullArgument(name, value);
    180176                                name.clear();
    181177                                assert(shortcut.empty());
     
    183179                            else if (!shortcut.empty())
    184180                            {
    185                                 checkShortcut(shortcut, value, bParsingFile);
     181                                checkShortcut(shortcut, value);
    186182                                shortcut.clear();
    187183                                assert(name.empty());
     
    222218            if (!name.empty())
    223219            {
    224                 checkFullArgument(name, value, bParsingFile);
     220                checkFullArgument(name, value);
    225221                assert(shortcut.empty());
    226222            }
    227223            else if (!shortcut.empty())
    228224            {
    229                 checkShortcut(shortcut, value, bParsingFile);
     225                checkShortcut(shortcut, value);
    230226                assert(name.empty());
    231227            }
     
    233229        catch (const ArgumentException& ex)
    234230        {
    235             COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl;
     231            COUT(0) << "Could not parse command line: " << ex.what() << std::endl;
    236232            COUT(0) << CommandLineParser::getUsageInformation() << std::endl;
    237233            throw GeneralException("");
     
    249245        Parsing a file or the command line itself
    250246    */
    251     void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile)
     247    void CommandLineParser::checkFullArgument(const std::string& name, const std::string& value)
    252248    {
    253249        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
     
    255251            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
    256252
    257         it->second->parse(value, bParsingFile);
     253        it->second->parse(value);
    258254    }
    259255
     
    268264        Parsing a file or the command line itself
    269265    */
    270     void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile)
     266    void CommandLineParser::checkShortcut(const std::string& shortcut, const std::string& value)
    271267    {
    272268        std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
     
    274270            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
    275271
    276         it->second->parse(value, bParsingFile);
     272        it->second->parse(value);
    277273    }
    278274
     
    342338        }
    343339    }
    344 
    345     /**
    346     @brief
    347         Parses only the command line for CommandLineArguments.
    348     */
    349     void CommandLineParser::_parseCommandLine(const std::string& cmdLine)
    350     {
    351         std::vector<std::string> args;
    352         SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
    353         for (unsigned i = 0; i < tokens.size(); ++i)
    354             args.push_back(tokens[i]);
    355         this->_parse(args, false);
    356     }
    357 
    358     /**
    359     @brief
    360         Parses start.ini (or the file specified with --optionsFile) for CommandLineArguments.
    361     */
    362     void CommandLineParser::_parseFile()
    363     {
    364         const std::string& filename = CommandLineParser::getValue("optionsFile").getString();
    365 
    366         // look for additional arguments in given file or start.ini as default
    367         // They will not overwrite the arguments given directly
    368         std::ifstream file;
    369         file.open((PathConfig::getConfigPathString() + filename).c_str());
    370         std::vector<std::string> args;
    371         if (file)
    372         {
    373             while (!file.eof())
    374             {
    375                 std::string line;
    376                 std::getline(file, line);
    377                 line = removeTrailingWhitespaces(line);
    378                 //if (!(line[0] == '#' || line[0] == '%'))
    379                 //{
    380                 SubString tokens(line, " ", " ", false, '\\', true, '"', true, '\0', '\0', false, '#');
    381                 for (unsigned i = 0; i < tokens.size(); ++i)
    382                     if (tokens[i][0] != '#')
    383                         args.push_back(tokens[i]);
    384                 //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
    385                 //}
    386             }
    387             file.close();
    388         }
    389 
    390         _parse(args, true);
    391     }
    392340}
  • code/trunk/src/libraries/core/CommandLineParser.h

    r7401 r8729  
    5151#define SetCommandLineArgument(name, defaultValue) \
    5252    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    53     = orxonox::CommandLineParser::addArgument(#name, defaultValue, false)
    54 #define SetCommandLineOnlyArgument(name, defaultValue) \
    55     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    56     = orxonox::CommandLineParser::addArgument(#name, defaultValue, true)
     53    = orxonox::CommandLineParser::addArgument(#name, defaultValue)
    5754#define SetCommandLineSwitch(name) \
    5855    orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    59     = orxonox::CommandLineParser::addArgument(#name, false, false)
    60 #define SetCommandLineOnlySwitch(name) \
    61     orxonox::CommandLineArgument& CmdArgumentDummyBoolVar##name \
    62     = orxonox::CommandLineParser::addArgument(#name, false, true)
    63 
     56    = orxonox::CommandLineParser::addArgument(#name, false)
    6457
    6558namespace orxonox
     
    10699
    107100        //! Returns the actual value of the argument. Can be equal to default value.
    108         MultiType getValue() const { return value_; }
     101        const MultiType& getValue() const { return value_; }
    109102        //! Returns the given default value as type T.
    110         MultiType getDefaultValue() const { return defaultValue_; }
     103        const MultiType& getDefaultValue() const { return defaultValue_; }
    111104
    112105    private:
    113106        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
    114         CommandLineArgument(const std::string& name, const MultiType& defaultValue, bool bCommandLineOnly)
     107        CommandLineArgument(const std::string& name, const MultiType& defaultValue)
    115108            : bHasDefaultValue_(true)
    116109            , name_(name)
    117110            , value_(defaultValue)
    118111            , defaultValue_(defaultValue)
    119             , bCommandLineOnly_(bCommandLineOnly)
    120112        { }
    121113
     
    125117
    126118        //! Parses the value string of a command line argument.
    127         void parse(const std::string& value, bool bParsingFile);
     119        void parse(const std::string& value);
    128120
    129121        //! Tells whether the value has been changed by the command line.
     
    137129        MultiType   value_;            //!< The actual value
    138130        MultiType   defaultValue_;     //!< Default value. Should not be changed.
    139         bool        bCommandLineOnly_; //!< Whether you cannot specify the value in a text file
    140131    };
    141132
     
    155146
    156147        //! Parse redirection to internal member method.
    157         static void parseCommandLine(const std::string& cmdLine) { _getInstance()._parseCommandLine(cmdLine); }
    158         static void parseFile() { _getInstance()._parseFile(); }
     148        static void parse(const std::string& cmdLine)
     149        { _getInstance()._parse(cmdLine); }
    159150
    160151        static std::string getUsageInformation();
     
    165156        static void getValue(const std::string& name, T* value)
    166157        { *value = (T)(getArgument(name)->getValue()); }
    167         static MultiType getValue(const std::string& name)
     158        static const MultiType& getValue(const std::string& name)
    168159        { return getArgument(name)->getValue(); }
    169160        template <class T>
    170         static CommandLineArgument& addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly);
     161        static CommandLineArgument& addArgument(const std::string& name, T defaultValue);
    171162
    172163        static bool existsArgument(const std::string& name)
     
    189180        static CommandLineParser& _getInstance();
    190181
    191         void _parseCommandLine(const std::string& cmdLine);
    192         void _parseFile();
    193         void _parse(const std::vector<std::string>& arguments, bool bParsingFile);
    194         void checkFullArgument(const std::string& name, const std::string& value, bool bParsingFile);
    195         void checkShortcut(const std::string& shortcut, const std::string& value, bool bParsingFile);
     182        void _parse(const std::string& cmdLine);
     183        void checkFullArgument(const std::string& name, const std::string& value);
     184        void checkShortcut(const std::string& shortcut, const std::string& value);
    196185
    197186        /**
     
    222211    @param defaultValue
    223212        Default value that is used when argument was not given.
    224     @param bCommandLineOnly
    225         Parsing a file or the command line itself
    226213    */
    227214    template <class T>
    228     CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue, bool bCommandLineOnly)
     215    CommandLineArgument& CommandLineParser::addArgument(const std::string& name, T defaultValue)
    229216    {
    230217        OrxAssert(!_getInstance().existsArgument(name),
     
    234221            << "Please use SetCommandLineSwitch and adjust your argument: " << name);
    235222
    236         return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue, bCommandLineOnly));
     223        return *(_getInstance().cmdLineArgs_[name] = new CommandLineArgument(name, defaultValue));
    237224    }
    238225}
  • code/trunk/src/libraries/core/ConfigValueIncludes.h

    r7401 r8729  
    255255    ModifyConfigValueGeneric(this, &varname, #varname, modifier, __VA_ARGS__)
    256256
     257/** Modifies a runtime configurable value by using a modifier and some arguments.
     258    If the container for the value doesn't yet exist, a warning is displayed.
     259    Also, the @a variable argument will be modified and set to the current value.
     260@param variable
     261    Pointer to the variable where the value should be written to
     262@param entryName
     263    Name of the entry in the ini file (e.g. [MySection] myValue)
     264@param modifier
     265    On of these functions: set, tset, add, remove, reset, update
     266@param ...
     267    Arguments for the modifier function
     268*/
     269#define ModifyConfigValueExternal(variable, entryName, modifier, ...) \
     270    ModifyConfigValueGeneric(this, &variable, entryName, modifier, __VA_ARGS__)
     271
    257272#endif /* _ConfigValueIncludes_H__ */
  • code/trunk/src/libraries/core/Core.cc

    r8505 r8729  
    6969#include "Language.h"
    7070#include "LuaState.h"
     71#include "ObjectList.h"
    7172#include "command/ConsoleCommand.h"
    7273#include "command/IOConsole.h"
     
    131132
    132133        // Parse command line arguments AFTER the modules have been loaded (static code!)
    133         CommandLineParser::parseCommandLine(cmdLine);
     134        CommandLineParser::parse(cmdLine);
    134135
    135136        // Set configurable paths like log, config and media
     
    143144        // Set the correct log path. Before this call, /tmp (Unix) or %TEMP% (Windows) was used
    144145        OutputHandler::getInstance().setLogPath(PathConfig::getLogPathString());
    145 
    146         // Parse additional options file now that we know its path
    147         CommandLineParser::parseFile();
    148146
    149147#ifdef ORXONOX_PLATFORM_WINDOWS
     
    168166        RegisterRootObject(Core);
    169167        this->setConfigValues();
     168        // Rewrite the log file with the correct log levels
     169        OutputHandler::getInstance().rewriteLogFile();
    170170
    171171#if !defined(ORXONOX_PLATFORM_APPLE) && !defined(ORXONOX_USE_WINMAIN)
     
    230230    }
    231231
     232    namespace DefaultLevelLogFile
     233    {
     234        const OutputLevel::Value Dev  = OutputLevel::Debug;
     235        const OutputLevel::Value User = OutputLevel::Info;
     236    }
     237
    232238    //! Function to collect the SetConfigValue-macro calls.
    233239    void Core::setConfigValues()
    234240    {
    235 #ifdef ORXONOX_RELEASE
    236         const unsigned int defaultLevelLogFile = 3;
    237 #else
    238         const unsigned int defaultLevelLogFile = 4;
    239 #endif
    240         SetConfigValueExternal(softDebugLevelLogFile_, "OutputHandler", "softDebugLevelLogFile", defaultLevelLogFile)
    241             .description("The maximum level of debug output shown in the log file");
    242         OutputHandler::getInstance().setSoftDebugLevel(OutputHandler::logFileOutputListenerName_s, this->softDebugLevelLogFile_);
     241        // Choose the default level according to the path Orxonox was started (build directory or not)
     242        OutputLevel::Value defaultLogLevel = (PathConfig::buildDirectoryRun() ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
     243
     244        SetConfigValueExternal(debugLevelLogFile_, "OutputHandler", "debugLevelLogFile", defaultLogLevel)
     245            .description("The maximum level of debug output written to the log file");
     246        OutputHandler::getInstance().setSoftDebugLevel("LogFile", debugLevelLogFile_);
    243247
    244248        SetConfigValue(bDevMode_, PathConfig::buildDirectoryRun())
    245             .description("Developer mode. If not set, hides some things from the user to not confuse him.");
     249            .description("Developer mode. If not set, hides some things from the user to not confuse him.")
     250            .callback(this, &Core::devModeChanged);
    246251        SetConfigValue(language_, Language::getInstance().defaultLanguage_)
    247252            .description("The language of the in game text")
     
    258263    }
    259264
     265    /** Callback function for changes in the dev mode that affect debug levels.
     266        The function behaves according to these rules:
     267        - 'normal' mode is defined based on where the program was launched: if
     268          the launch path was the build directory, development mode \c on is
     269          normal, otherwise normal means development mode \c off.
     270        - Debug levels should not be hard configured (\c config instead of
     271          \c tconfig) in non 'normal' mode to avoid strange behaviour.
     272        - Changing the development mode from 'normal' to the other state will
     273          immediately change the debug levels to predefined values which can be
     274          reconfigured with \c tconfig.
     275    @note
     276        The debug levels for the IOConsole and the InGameConsole can be found
     277        in the Shell class. The same rules apply.
     278    */
     279    void Core::devModeChanged()
     280    {
     281        bool isNormal = (bDevMode_ == PathConfig::buildDirectoryRun());
     282        if (isNormal)
     283        {
     284            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", update);
     285        }
     286        else
     287        {
     288            OutputLevel::Value level = (bDevMode_ ? DefaultLevelLogFile::Dev : DefaultLevelLogFile::User);
     289            ModifyConfigValueExternal(debugLevelLogFile_, "debugLevelLogFile", tset, level);
     290        }
     291
     292        // Inform listeners
     293        ObjectList<DevModeListener>::iterator it = ObjectList<DevModeListener>::begin();
     294        for (; it != ObjectList<DevModeListener>::end(); ++it)
     295            it->devModeChanged(bDevMode_);
     296    }
     297
    260298    //! Callback function if the language has changed.
    261299    void Core::languageChanged()
     
    440478        ModifyConfigValue(ogreConfigTimestamp_, set, static_cast<long long>(time(NULL)));
    441479    }
     480
     481
     482    DevModeListener::DevModeListener()
     483    {
     484        RegisterRootObject(DevModeListener);
     485    }
    442486}
  • code/trunk/src/libraries/core/Core.h

    r8423 r8729  
    4545
    4646#include <string>
    47 #include <loki/ScopeGuard.h>
    48 
    4947#include "util/DestructionHelper.h"
    5048#include "util/Singleton.h"
     
    5351namespace orxonox
    5452{
     53    //! Informs about changes in the Development Mode.
     54    class DevModeListener : virtual public OrxonoxClass
     55    {
     56    public:
     57        DevModeListener();
     58        virtual ~DevModeListener() {}
     59        virtual void devModeChanged(bool value) = 0;
     60    };
     61
    5562    /**
    5663    @brief
     
    101108            Core(const Core&); //!< Don't use (undefined symbol)
    102109
     110            void devModeChanged();
    103111            void languageChanged();
    104112            void initRandomNumberGenerator();
     
    128136
    129137            bool                      bGraphicsLoaded_;
    130             int                       softDebugLevelLogFile_;      //!< The debug level for the log file (belongs to OutputHandler)
     138            int                       debugLevelLogFile_;          //!< The debug level for the log file (belongs to OutputHandler)
    131139            std::string               language_;                   //!< The language
    132140            bool                      bInitRandomNumberGenerator_; //!< If true, srand(time(0)) is called
  • code/trunk/src/libraries/core/CoreIncludes.h

    r8706 r8729  
    8080#include "util/Debug.h"
    8181#include "Identifier.h"
    82 #include "SubclassIdentifier.h"
    8382#include "ClassFactory.h"
    8483#include "ObjectList.h"
  • code/trunk/src/libraries/core/EventIncludes.h

    r7401 r8729  
    3737
    3838#include "CorePrereqs.h"
     39
     40#include "Event.h"
    3941#include "XMLPort.h"
    4042#include "command/Executor.h"
  • code/trunk/src/libraries/core/GUIManager.cc

    r8706 r8729  
    490490    }
    491491
    492     const std::string& GUIManager::createInputState(const std::string& name, TriBool::Value showCursor, TriBool::Value useKeyboard, bool bBlockJoyStick)
     492    const std::string& GUIManager::createInputState(const std::string& name, tribool showCursor, tribool useKeyboard, bool bBlockJoyStick)
    493493    {
    494494        InputState* state = InputManager::getInstance().createInputState(name);
     
    506506#ifdef ORXONOX_PLATFORM_APPLE
    507507        // There is no non exclusive mode on OS X yet
    508         state->setMouseExclusive(TriBool::True);
    509 #else
    510         if (showCursor == TriBool::Dontcare)
    511             state->setMouseExclusive(TriBool::Dontcare);
    512         else if (GraphicsManager::getInstance().isFullScreen() || showCursor == TriBool::False)
    513             state->setMouseExclusive(TriBool::True);
     508        state->setMouseExclusive(true);
     509#else
     510        if (showCursor == dontcare)
     511            state->setMouseExclusive(dontcare);
     512        else if (GraphicsManager::getInstance().isFullScreen() || showCursor == false)
     513            state->setMouseExclusive(true);
    514514        else
    515             state->setMouseExclusive(TriBool::False);
    516 #endif
    517 
    518         if (showCursor == TriBool::True)
     515            state->setMouseExclusive(false);
     516#endif
     517
     518        if (showCursor == true)
    519519            state->setMouseHandler(this);
    520         else if (showCursor == TriBool::False)
     520        else if (showCursor == false)
    521521            state->setMouseHandler(&InputHandler::EMPTY);
    522522
    523         if (useKeyboard == TriBool::True)
     523        if (useKeyboard == true)
    524524            state->setKeyHandler(this);
    525         else if (useKeyboard == TriBool::False)
     525        else if (useKeyboard == false)
    526526            state->setKeyHandler(&InputHandler::EMPTY);
    527527
     
    717717    }
    718718
     719    /** Helper method to get the developer's mode without having to export Core.h.
     720    @see Core::inDevMode
     721    */
     722    /*static*/ bool GUIManager::inDevMode()
     723    {
     724         return Core::getInstance().inDevMode();
     725    }
     726
    719727    /**
    720728        @brief Callback of window event listener, called if the window is resized. Sets the display size of CEGUI.
  • code/trunk/src/libraries/core/GUIManager.h

    r8706 r8729  
    3939
    4040#include <map>
    41 #include <set>
    4241#include <string>
    4342#include <CEGUIForwardRefs.h>
     
    4746#include "util/DestructionHelper.h"
    4847#include "util/OgreForwardRefs.h"
    49 #include "util/TriBool.h"
     48#include "util/tribool.h"
    5049#include "util/Singleton.h"
    5150#include "input/InputHandler.h"
    52 #include "Core.h"
    5351#include "OrxonoxClass.h"
    5452#include "WindowEventListener.h"
    55 
    56 // Tolua includes (have to be relative to the current directory)
    57 /*
    58 $cfile "../util/TriBool.h" // tolua_export
    59 */
    6053
    6154#if CEGUI_VERSION_MAJOR < 1 && CEGUI_VERSION_MINOR < 7
     
    6659{ // tolua_export
    6760    class PlayerInfo; // Forward declaration
     61
     62    // Acquaint Tolua with tribool
     63    /* tolua_begin
     64    struct dontcare_keyword_t
     65    {
     66        dontcare_keyword_t();
     67    };
     68    class tribool
     69    {
     70        tribool(bool value);
     71        tribool(dontcare_keyword_t);
     72        bool operator==(tribool);
     73    };
     74    tolua_end */
    6875
    6976    /**
     
    104111        void setBackgroundImage(const std::string& image);
    105112
    106         /**
    107         @brief Helper method to get the developer's mode without having to export Core.h.
    108         @see Core::inDevMode
    109         */
    110         static bool inDevMode(void) { return Core::getInstance().inDevMode(); } // tolua_export
     113        static bool inDevMode(void); // tolua_export
    111114
    112115        //! Creates a new InputState to be used with a GUI Sheet
    113         const std::string& createInputState(const std::string& name, TriBool::Value showCursor = TriBool::True, TriBool::Value useKeyboard = TriBool::True, bool bBlockJoyStick = false); // tolua_export
     116        const std::string& createInputState(const std::string& name, tribool showCursor = tribool(true), tribool useKeyboard = tribool(true), bool bBlockJoyStick = false); // tolua_export
    114117        LuaState* getLuaState(void)
    115118            { return this->luaState_; }
  • code/trunk/src/libraries/core/Game.cc

    r8706 r8729  
    109109
    110110        // Do this after the Core creation!
    111         ClassIdentifier<Game>::getIdentifier("Game")->initialiseObject(this, "Game", true);
     111        RegisterRootObject(Game);
    112112        this->setConfigValues();
    113113
  • code/trunk/src/libraries/core/LuaState.cc

    r8351 r8729  
    4040#include "util/Exception.h"
    4141#include "Resource.h"
    42 #include "ToluaBindCore.h"
    4342#include "command/IOConsole.h"
    4443
    4544namespace orxonox
    4645{
    47     LuaState::ToluaInterfaceMap LuaState::toluaInterfaces_s;
    48     std::vector<LuaState*> LuaState::instances_s;
    49 
    5046    const std::string LuaState::ERROR_HANDLER_NAME = "errorHandler";
    51 
    52     // Do this after declaring toluaInterfaces_s and instances_s to avoid larger problems
    53     DeclareToluaInterface(Core);
    5447
    5548    LuaState::LuaState()
     
    277270    }
    278271
     272    /*static*/ LuaState::ToluaInterfaceMap& LuaState::getToluaInterfaces()
     273    {
     274        static ToluaInterfaceMap p;
     275        return p;
     276    }
     277
     278    /*static*/ std::vector<LuaState*>& LuaState::getInstances()
     279    {
     280        static std::vector<LuaState*> p;
     281        return p;
     282    }
     283
    279284    /*static*/ bool LuaState::addToluaInterface(int (*function)(lua_State*), const std::string& name)
    280285    {
    281         for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)
     286        for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
    282287        {
    283288            if (it->first == name || it->second == function)
     
    287292            }
    288293        }
    289         toluaInterfaces_s[name] = function;
     294        getToluaInterfaces()[name] = function;
    290295
    291296        // Open interface in all LuaStates
    292         for (std::vector<LuaState*>::const_iterator it = instances_s.begin(); it != instances_s.end(); ++it)
     297        for (std::vector<LuaState*>::const_iterator it = getInstances().begin(); it != getInstances().end(); ++it)
    293298            (*function)((*it)->luaState_);
    294299
     
    299304    /*static*/ bool LuaState::removeToluaInterface(const std::string& name)
    300305    {
    301         ToluaInterfaceMap::iterator it = toluaInterfaces_s.find(name);
    302         if (it == toluaInterfaces_s.end())
     306        ToluaInterfaceMap::iterator it = getToluaInterfaces().find(name);
     307        if (it == getToluaInterfaces().end())
    303308        {
    304309            COUT(2) << "Warning: Cannot remove Tolua interface '" << name << "': Not found" << std::endl;
     
    307312
    308313        // Close interface in all LuaStates
    309         for (std::vector<LuaState*>::const_iterator itState = instances_s.begin(); itState != instances_s.end(); ++itState)
     314        for (std::vector<LuaState*>::const_iterator itState = getInstances().begin(); itState != getInstances().end(); ++itState)
    310315        {
    311316            lua_pushnil((*itState)->luaState_);
     
    314319
    315320        // Remove entry
    316         toluaInterfaces_s.erase(it);
     321        getToluaInterfaces().erase(it);
    317322
    318323        // Return dummy bool
     
    322327    /*static*/ void LuaState::openToluaInterfaces(lua_State* state)
    323328    {
    324         for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)
     329        for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
    325330            (*it->second)(state);
    326331    }
     
    328333    /*static*/ void LuaState::closeToluaInterfaces(lua_State* state)
    329334    {
    330         for (ToluaInterfaceMap::const_iterator it = toluaInterfaces_s.begin(); it != toluaInterfaces_s.end(); ++it)
     335        for (ToluaInterfaceMap::const_iterator it = getToluaInterfaces().begin(); it != getToluaInterfaces().end(); ++it)
    331336        {
    332337            lua_pushnil(state);
  • code/trunk/src/libraries/core/LuaState.h

    r8351 r8729  
    4848#include <vector>
    4949#include <boost/shared_ptr.hpp>
    50 #include <loki/ScopeGuard.h>
    51 
    52 #include "ToluaInterface.h"
    5350
    5451namespace orxonox // tolua_export
     
    121118
    122119        typedef std::map<std::string, int (*)(lua_State *L)> ToluaInterfaceMap;
    123         static ToluaInterfaceMap toluaInterfaces_s;
    124         static std::vector<LuaState*> instances_s;
     120        static ToluaInterfaceMap& getToluaInterfaces();
     121        static std::vector<LuaState*>& getInstances();
    125122    }; // tolua_export
     123
     124
     125    //! Helper class that registers/unregisters tolua bindings
     126    class ToluaBindingsHelper
     127    {
     128    public:
     129        ToluaBindingsHelper(int (*function)(lua_State*), const std::string& libraryName)
     130            : libraryName_(libraryName)
     131        {
     132            LuaState::addToluaInterface(function, libraryName_);
     133        }
     134        ~ToluaBindingsHelper()
     135        {
     136            LuaState::removeToluaInterface(libraryName_);
     137        }
     138    private:
     139        std::string libraryName_;
     140    };
    126141} // tolua_export
    127142
  • code/trunk/src/libraries/core/ObjectListBase.h

    r7401 r8729  
    4141
    4242#include "CorePrereqs.h"
    43 
    4443#include <vector>
    45 #include "OrxonoxClass.h"
    4644
    4745namespace orxonox
  • code/trunk/src/libraries/core/OrxonoxClass.h

    r8351 r8729  
    4545
    4646#include "CorePrereqs.h"
    47 #include "Super.h"
    4847
    4948#include <set>
    5049#include <vector>
     50#include "Super.h"
    5151
    5252/**
  • code/trunk/src/libraries/core/PathConfig.cc

    r8366 r8729  
    7474
    7575    SetCommandLineArgument(externalDataPath, "").information("Path to the external data files");
    76     SetCommandLineOnlyArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
     76    SetCommandLineArgument(writingPathSuffix, "").information("Additional subfolder for config and log files");
    7777
    7878    PathConfig::PathConfig()
  • code/trunk/src/libraries/core/Super.h

    r8706 r8729  
    7373
    7474#include "CorePrereqs.h"
    75 
    7675#include "util/Debug.h"
    77 #include "Event.h"
    7876
    7977///////////////////////
  • code/trunk/src/libraries/core/ViewportEventListener.h

    r8079 r8729  
    3030#define _ViewportEventListener_H__
    3131
     32#include "CorePrereqs.h"
     33
    3234#include "util/OgreForwardRefs.h"
    33 
    34 #include "CorePrereqs.h"
    3535#include "OrxonoxClass.h"
    3636
  • code/trunk/src/libraries/core/command/Functor.h

    r8706 r8729  
    114114#define _Functor_H__
    115115
     116#include "core/CorePrereqs.h"
     117
    116118#include <typeinfo>
    117 
    118 #include "core/CorePrereqs.h"
    119119
    120120#include "util/Debug.h"
  • code/trunk/src/libraries/core/command/IOConsolePOSIX.cc

    r7422 r8729  
    236236    void IOConsole::printOutputLine(const std::string& text, Shell::LineType type)
    237237    {
    238 /*
    239238        // Colour line
    240239        switch (type)
    241240        {
    242         case Shell::None:    this->cout_ << "\033[37m"; break;
    243241        case Shell::Error:   this->cout_ << "\033[91m"; break;
    244         case Shell::Warning: this->cout_ << "\033[31m"; break;
    245         case Shell::Info:    this->cout_ << "\033[34m"; break;
    246         case Shell::Debug:   this->cout_ << "\033[36m"; break;
    247         case Shell::Verbose: this->cout_ << "\033[35m"; break;
    248         case Shell::Ultra:   this->cout_ << "\033[37m"; break;
     242        case Shell::Warning: this->cout_ << "\033[93m"; break;
     243        case Shell::Info:    this->cout_ << "\033[90m"; break;
     244        case Shell::Debug:   this->cout_ << "\033[90m"; break;
     245        case Shell::Verbose: this->cout_ << "\033[90m"; break;
     246        case Shell::Ultra:   this->cout_ << "\033[90m"; break;
     247        case Shell::Command: this->cout_ << "\033[36m"; break;
     248        case Shell::Hint:    this->cout_ << "\033[33m"; break;
     249        case Shell::TDebug:  this->cout_ << "\033[95m"; break;
    249250        default: break;
    250251        }
    251 */
    252252
    253253        // Print output line
    254254        this->cout_ << text;
    255255
    256         // Reset colour to white
    257 //        this->cout_ << "\033[37m";
     256        // Reset colour atributes
     257        this->cout_ << "\033[0m";
    258258    }
    259259
  • code/trunk/src/libraries/core/command/IOConsoleWindows.cc

    r7287 r8729  
    208208        case Shell::Command: colour =                        FOREGROUND_GREEN                  | FOREGROUND_BLUE; break;
    209209        case Shell::Hint:    colour =                        FOREGROUND_GREEN | FOREGROUND_RED                  ; break;
     210        case Shell::TDebug:  colour = FOREGROUND_INTENSITY                    | FOREGROUND_RED | FOREGROUND_BLUE; break;
    210211        default:             colour =                        FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE; break;
    211212        }
  • code/trunk/src/libraries/core/command/IOConsoleWindows.h

    r7401 r8729  
    3939#include <sstream>
    4040#include <string>
    41 #include <vector>
    4241#include "util/Singleton.h"
    4342#include "Shell.h"
  • code/trunk/src/libraries/core/command/Shell.cc

    r8706 r8729  
    3434#include "Shell.h"
    3535
     36#include "util/Math.h"
    3637#include "util/OutputHandler.h"
    3738#include "util/StringUtils.h"
     
    4041#include "core/ConfigFileManager.h"
    4142#include "core/ConfigValueIncludes.h"
     43#include "core/PathConfig.h"
     44#include "core/input/InputBuffer.h"
    4245#include "CommandExecutor.h"
    4346#include "ConsoleCommand.h"
     
    8487
    8588        // Get the previous output and add it to the Shell
    86         for (OutputHandler::OutputVectorIterator it = OutputHandler::getInstance().getOutputVectorBegin();
    87             it != OutputHandler::getInstance().getOutputVectorEnd(); ++it)
    88         {
    89             if (it->first <= this->getSoftDebugLevel())
     89        OutputHandler::OutputVector::const_iterator it = OutputHandler::getInstance().getOutput().begin();
     90        for (;it != OutputHandler::getInstance().getOutput().end(); ++it)
     91        {
     92            if (it->first <= debugLevel_)
    9093            {
    9194                this->outputBuffer_ << it->second;
     
    9699        // Register the shell as output listener
    97100        OutputHandler::getInstance().registerOutputListener(this);
     101        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
    98102    }
    99103
     
    105109        OutputHandler::getInstance().unregisterOutputListener(this);
    106110        this->inputBuffer_->destroy();
     111    }
     112
     113    namespace DefaultLogLevel
     114    {
     115        const OutputLevel::Value Dev  = OutputLevel::Info;
     116        const OutputLevel::Value User = OutputLevel::Error;
    107117    }
    108118
     
    119129        SetConfigValue(cacheSize_s, 32);
    120130
    121 #ifdef ORXONOX_RELEASE
    122         const unsigned int defaultLevel = 1;
    123 #else
    124         const unsigned int defaultLevel = 3;
    125 #endif
    126         SetConfigValueExternal(softDebugLevel_, "OutputHandler", "softDebugLevel" + this->consoleName_, defaultLevel)
    127             .description("The maximal level of debug output shown in the Shell");
    128         this->setSoftDebugLevel(this->softDebugLevel_);
     131        // Choose the default level according to the path Orxonox was started (build directory or not)
     132        OutputLevel::Value defaultDebugLevel = (PathConfig::buildDirectoryRun() ? DefaultLogLevel::Dev : DefaultLogLevel::User);
     133        SetConfigValueExternal(debugLevel_, "OutputHandler", "debugLevel" + consoleName_, defaultDebugLevel)
     134            .description("The maximum level of debug output shown in the " + consoleName_);
     135        OutputHandler::getInstance().setSoftDebugLevel(consoleName_, debugLevel_);
    129136    }
    130137
     
    150157            this->commandHistory_.erase(this->commandHistory_.begin() + index);
    151158            ModifyConfigValue(commandHistory_, remove, index);
     159        }
     160    }
     161
     162    /** Called upon changes in the development mode (by Core)
     163        Behaviour details see Core::devModeChanged.
     164    */
     165    void Shell::devModeChanged(bool value)
     166    {
     167        bool isNormal = (value == PathConfig::buildDirectoryRun());
     168        if (isNormal)
     169        {
     170            ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, update);
     171        }
     172        else
     173        {
     174            OutputLevel::Value level = (value ? DefaultLogLevel::Dev : DefaultLogLevel::User);
     175            ModifyConfigValueExternal(debugLevel_, "debugLevel" + consoleName_, tset, level);
    152176        }
    153177    }
     
    215239    }
    216240
     241    /// Returns the current position of the cursor in the input buffer.
     242    unsigned int Shell::getCursorPosition() const
     243    {
     244        return this->inputBuffer_->getCursorPosition();
     245    }
     246
     247    /// Returns the current content of the input buffer (the text which was entered by the user)
     248    const std::string& Shell::getInput() const
     249    {
     250        return this->inputBuffer_->get();
     251    }
     252
    217253    /**
    218254        @brief Sends output to the internal output buffer.
  • code/trunk/src/libraries/core/command/Shell.h

    r7401 r8729  
    4949
    5050#include "util/OutputHandler.h"
     51#include "core/Core.h"
    5152#include "core/OrxonoxClass.h"
    52 #include "core/input/InputBuffer.h"
    5353
    5454namespace orxonox
     
    8585        Different graphical consoles build upon a Shell, for example InGameConsole and IOConsole.
    8686    */
    87     class _CoreExport Shell : virtual public OrxonoxClass, public OutputListener
     87    class _CoreExport Shell : public OutputListener, public DevModeListener
    8888    {
    8989        public:
     
    9191            enum LineType
    9292            {
     93                TDebug  = OutputLevel::TDebug,
    9394                None    = OutputLevel::None,
    9495                Warning = OutputLevel::Warning,
     
    118119
    119120            void setCursorPosition(unsigned int cursor);
    120             /// Returns the current position of the cursor in the input buffer.
    121             inline unsigned int getCursorPosition() const
    122                 { return this->inputBuffer_->getCursorPosition(); }
    123 
    124             /// Returns the current content of the input buffer (the text which was entered by the user)
    125             inline const std::string& getInput() const
    126                 { return this->inputBuffer_->get(); }
     121            unsigned int getCursorPosition() const;
     122
     123            const std::string& getInput() const;
    127124
    128125            typedef std::list<std::pair<std::string, LineType> > LineList;
     
    146143        private:
    147144            Shell(const Shell& other);
     145
     146            // DevModeListener
     147            void devModeChanged(bool value);
    148148
    149149            void addToHistory(const std::string& command);
     
    197197            unsigned int              historyOffset_;       ///< The command history is a circular buffer, this variable defines the current write-offset
    198198            std::vector<std::string>  commandHistory_;      ///< The history of commands that were entered by the user
    199             int                       softDebugLevel_;      ///< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
     199            int                       debugLevel_;          //!< The maximum level of output that is displayed in the shell (will be passed to OutputListener to filter output)
    200200            static unsigned int       cacheSize_s;          ///< The maximum cache size of the CommandExecutor - this is stored here for better readability of the config file and because CommandExecutor is no OrxonoxClass
    201201    };
  • code/trunk/src/libraries/core/input/InputHandler.h

    r6746 r8729  
    3131
    3232#include "InputPrereqs.h"
    33 #include "util/Math.h"
    3433
    3534namespace orxonox
    3635{
     36    /// A Vector class containing two integers @a x and @a y.
     37    class IntVector2
     38    {
     39    public:
     40        IntVector2() : x(0), y(0) { }
     41        IntVector2(int _x, int _y) : x(_x), y(_y) { }
     42        int x;
     43        int y;
     44    };
     45
    3746    namespace ButtonEvent
    3847    {
  • code/trunk/src/libraries/core/input/InputManager.cc

    r8351 r8729  
    9494        , oisInputManager_(0)
    9595        , devices_(2)
    96         , exclusiveMouse_(TriBool::False)
     96        , exclusiveMouse_(false)
    9797        , emptyState_(0)
    9898        , calibratorCallbackHandler_(0)
     
    108108
    109109        if (GraphicsManager::getInstance().isFullScreen())
    110             exclusiveMouse_ = TriBool::True;
     110            exclusiveMouse_ = true;
    111111        this->loadDevices();
    112112
     
    161161        paramList.insert(StringPair("w32_keyboard", "DISCL_FOREGROUND"));
    162162        paramList.insert(StringPair("w32_mouse", "DISCL_FOREGROUND"));
    163         if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
     163        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    164164        {
    165165            // Disable Windows key plus special keys (like play, stop, next, etc.)
     
    174174        paramList.insert(StringPair("XAutoRepeatOn", "true"));
    175175
    176         if (exclusiveMouse_ == TriBool::True || GraphicsManager::getInstance().isFullScreen())
     176        if (exclusiveMouse_ || GraphicsManager::getInstance().isFullScreen())
    177177        {
    178178            if (CommandLineParser::getValue("keyboard_no_grab").getBool())
     
    447447
    448448        // Check whether we have to change the mouse mode
    449         TriBool::Value requestedMode = TriBool::Dontcare;
     449        tribool requestedMode = dontcare;
    450450        std::vector<InputState*>& mouseStates = devices_[InputDeviceEnumerator::Mouse]->getStateListRef();
    451451        if (mouseStates.empty())
    452             requestedMode = TriBool::False;
     452            requestedMode = false;
    453453        else
    454454            requestedMode = mouseStates.front()->getMouseExclusive();
    455         if (requestedMode != TriBool::Dontcare && exclusiveMouse_ != requestedMode)
    456         {
    457             exclusiveMouse_ = requestedMode;
     455        if (requestedMode != dontcare && exclusiveMouse_ != requestedMode)
     456        {
     457            assert(requestedMode != dontcare);
     458            exclusiveMouse_ = (requestedMode == true);
    458459            if (!GraphicsManager::getInstance().isFullScreen())
    459460                this->reloadInternal();
     
    644645    }
    645646
    646     bool InputManager::setMouseExclusive(const std::string& name, TriBool::Value value)
     647    bool InputManager::setMouseExclusive(const std::string& name, tribool value)
    647648    {
    648649        if (name == "empty")
  • code/trunk/src/libraries/core/input/InputManager.h

    r8079 r8729  
    3333
    3434#include <map>
    35 #include <set>
    3635#include <string>
    3736#include <vector>
     
    3938
    4039#include "util/Singleton.h"
    41 #include "util/TriBool.h"
     40#include "util/tribool.h"
    4241#include "core/WindowEventListener.h"
    4342
     
    169168            True if the call was successful, fals if the name was not found
    170169        */
    171         bool setMouseExclusive(const std::string& name, TriBool::Value value); // tolua_export
     170        bool setMouseExclusive(const std::string& name, tribool value); // tolua_export
    172171
    173172        //-------------------------------
     
    215214        OIS::InputManager*                  oisInputManager_;      //!< OIS input manager
    216215        std::vector<InputDevice*>           devices_;              //!< List of all input devices (keyboard, mouse, joy sticks)
    217         TriBool::Value                      exclusiveMouse_;       //!< Currently applied mouse mode
     216        bool                                exclusiveMouse_;       //!< Currently applied mouse mode
    218217
    219218        // some internally handled states and handlers
  • code/trunk/src/libraries/core/input/InputPrereqs.h

    r6746 r8729  
    4141#include <ois/OISKeyboard.h>
    4242#include <ois/OISMouse.h>
    43 #include <ois/OISJoyStick.h>
    4443#include "util/OrxEnum.h"
    4544
  • code/trunk/src/libraries/core/input/InputState.cc

    r7284 r8729  
    3737        , bAlwaysGetsInput_(bAlwaysGetsInput)
    3838        , bTransparent_(bTransparent)
    39         , exclusiveMouse_(TriBool::Dontcare)
     39        , exclusiveMouse_(dontcare)
    4040        , bExpired_(true)
    4141        , handlers_(2)
  • code/trunk/src/libraries/core/input/InputState.h

    r8351 r8729  
    3838#include <boost/bind.hpp>
    3939
    40 #include "util/TriBool.h"
     40#include "util/tribool.h"
    4141#include "InputHandler.h"
    4242#include "InputManager.h"
     
    112112        void setHandler        (InputHandler* handler);
    113113
    114         void setMouseExclusive(TriBool::Value value) { exclusiveMouse_ = value; this->bExpired_ = true; }
    115         TriBool::Value getMouseExclusive() const { return exclusiveMouse_; }
     114        void setMouseExclusive(tribool value) { exclusiveMouse_ = value; this->bExpired_ = true; }
     115        tribool getMouseExclusive() const { return exclusiveMouse_; }
    116116
    117117        //! Returns the name of the state (which is unique!)
     
    166166        const bool                  bAlwaysGetsInput_;      //!< See class declaration for explanation
    167167        const bool                  bTransparent_;          //!< See class declaration for explanation
    168         TriBool::Value              exclusiveMouse_;        //!< See class declaration for explanation
     168        tribool                     exclusiveMouse_;        //!< See class declaration for explanation
    169169        int                         priority_;              //!< Current priority (might change)
    170170        bool                        bExpired_;              //!< See hasExpired()
  • code/trunk/src/libraries/core/input/JoyStick.h

    r7809 r8729  
    3434#include <string>
    3535#include <vector>
     36#include <ois/OISJoyStick.h>
    3637#include "InputDevice.h"
    3738
  • code/trunk/src/libraries/core/input/JoyStickQuantityListener.h

    r6417 r8729  
    3636
    3737#include "InputPrereqs.h"
     38
     39#include <vector>
    3840#include "core/OrxonoxClass.h"
    3941
  • code/trunk/src/libraries/core/input/KeyBinderManager.h

    r7284 r8729  
    3434#include <map>
    3535#include <string>
    36 #include <boost/shared_ptr.hpp>
    3736
    3837#include "util/Singleton.h"
  • code/trunk/src/libraries/core/input/KeyDetector.h

    r7284 r8729  
    3232#include "InputPrereqs.h"
    3333
    34 #include <boost/shared_ptr.hpp>
    3534#include "util/Singleton.h"
    3635#include "KeyBinder.h"
  • code/trunk/src/libraries/core/input/Keyboard.h

    r8079 r8729  
    3131
    3232#include "InputPrereqs.h"
    33 
    34 #include "InputHandler.h"
    3533#include "InputDevice.h"
    3634
  • code/trunk/src/libraries/core/input/Mouse.cc

    r7284 r8729  
    3737// include this as last, X11 seems to define some macros...
    3838#include <ois/linux/LinuxMouse.h>
     39#undef Success
    3940#endif
    4041
  • code/trunk/src/libraries/network/WANDiscoverable.h

    r8351 r8729  
    2828
    2929#include "NetworkPrereqs.h"
    30 // #include "core/OrxonoxClass.h"
     30#include "core/OrxonoxClass.h"
    3131#include "core/CoreIncludes.h"
    3232#include "MasterServerComm.h"
  • code/trunk/src/libraries/network/packet/CMakeLists.txt

    r7314 r8729  
    11ADD_SOURCE_FILES(NETWORK_SRC_FILES
    2 COMPILATION_BEGIN PacketCompilation.cc
     2
     3BUILD_UNIT PacketBuildUnit.cc
    34  Acknowledgement.cc
    45  Chat.cc
     
    1011  Packet.cc
    1112  Welcome.cc
    12 COMPILATION_END
     13END_BUILD_UNIT
     14
    1315  ServerInformation.cc
    1416)
  • code/trunk/src/libraries/tools/CMakeLists.txt

    r8351 r8729  
    11SET_SOURCE_FILES(TOOLS_SRC_FILES
    2 COMPILATION_BEGIN ResourceCompilation.cc
     2
     3BUILD_UNIT ResourceBuildUnit.cc
    34  ResourceCollection.cc
    45  ResourceLocation.cc
    5 COMPILATION_END
     6END_BUILD_UNIT
     7
    68  TextureGenerator.cc
    79  Timer.cc
    8 COMPILATION_BEGIN OgreCompilation.cc
     10
     11BUILD_UNIT OgreBuildUnit.cc
    912  BillboardSet.cc
    1013  DynamicLines.cc
     
    1316  ParticleInterface.cc
    1417  Shader.cc
    15 COMPILATION_END
     18END_BUILD_UNIT
    1619)
     20
    1721#ADD_SUBDIRECTORY(bsp)
    1822ADD_SUBDIRECTORY(interfaces)
  • code/trunk/src/libraries/tools/Shader.h

    r8079 r8729  
    3232#include "tools/ToolsPrereqs.h"
    3333
    34 #include <map>
     34#include <list>
    3535#include <string>
    36 #include <vector>
    37 
    3836#include <OgreCompositorInstance.h>
    3937
    4038#include "util/MultiType.h"
    41 #include "util/OgreForwardRefs.h"
    4239#include "core/ViewportEventListener.h"
    4340
  • code/trunk/src/libraries/tools/Timer.cc

    r8079 r8729  
    4242#include "core/command/ConsoleCommand.h"
    4343#include "core/command/CommandExecutor.h"
     44#include "core/command/Executor.h"
    4445#include "core/command/Functor.h"
    4546#include "tools/interfaces/TimeFactorListener.h"
     
    175176    {
    176177        return TimeFactorListener::getTimeFactor();
     178    }
     179
     180    /**
     181        @brief Initializes and starts the timer, which will call an executor after some time.
     182        @param interval         The timer-interval in seconds
     183        @param bLoop            If true, the executor gets called every @a interval seconds
     184        @param executor         The executor that will be called
     185        @param bKillAfterCall   If true, the timer will be deleted after the executor was called
     186    */
     187    void Timer::setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall)
     188    {
     189        this->setInterval(interval);
     190        this->bLoop_ = bLoop;
     191        this->executor_ = executor;
     192        this->bActive_ = true;
     193
     194        this->time_ = this->interval_;
     195        this->bKillAfterCall_ = bKillAfterCall;
     196
     197        executor->getFunctor()->setSafeMode(true);
    177198    }
    178199
  • code/trunk/src/libraries/tools/Timer.h

    r8079 r8729  
    8080
    8181#include "core/OrxonoxClass.h"
    82 #include "core/command/Executor.h"
     82#include "core/command/ExecutorPtr.h"
    8383
    8484namespace orxonox
     
    109109            Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
    110110
    111             /**
    112                 @brief Initializes and starts the timer, which will call an executor after some time.
    113                 @param interval         The timer-interval in seconds
    114                 @param bLoop            If true, the executor gets called every @a interval seconds
    115                 @param executor         The executor that will be called
    116                 @param bKillAfterCall   If true, the timer will be deleted after the executor was called
    117             */
    118             void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false)
    119             {
    120                 this->setInterval(interval);
    121                 this->bLoop_ = bLoop;
    122                 this->executor_ = executor;
    123                 this->bActive_ = true;
    124 
    125                 this->time_ = this->interval_;
    126                 this->bKillAfterCall_ = bKillAfterCall;
    127 
    128                 executor->getFunctor()->setSafeMode(true);
    129             }
     111            void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false);
    130112
    131113            void run();
  • code/trunk/src/libraries/util/CMakeLists.txt

    r8351 r8729  
    1919
    2020SET_SOURCE_FILES(UTIL_SRC_FILES
    21 COMPILATION_BEGIN StableCompilation.cc
     21
     22BUILD_UNIT StableBuildUnit.cc
    2223  Clipboard.cc
    2324  Clock.cc
     
    3233  SmallObjectAllocator.cc
    3334  SubString.cc
    34 COMPILATION_END
     35END_BUILD_UNIT
    3536
    3637  MultiType.cc
     
    4041  StringUtils.cc
    4142)
    42 
    43 IF(MSVC)
    44   # Simply using #pragma warning(disable:4244) doesn't really disable it
    45   # if the warning occurs in a template in another file
    46   # Hence promote it manually to a higher warning level (4)
    47   SET_SOURCE_FILES_PROPERTIES(MultiType.cc PROPERTIES COMPILE_FLAGS "-w44244")
    48 ENDIF()
    4943
    5044ORXONOX_ADD_LIBRARY(util
  • code/trunk/src/libraries/util/Convert.h

    r8706 r8729  
    133133#include "ImplicitConversion.h"
    134134
     135// disable warnings about possible loss of data
     136#ifdef ORXONOX_COMPILER_MSVC
     137#  pragma warning(push)
     138#  pragma warning(disable:4244)
     139#endif
     140
    135141namespace orxonox
    136142{
     
    471477}
    472478
     479// Reinstate warnings
     480#ifdef ORXONOX_COMPILER_MSVC
     481#  pragma warning(pop)
     482#endif
     483
    473484#endif /* _Convert_H__ */
  • code/trunk/src/libraries/util/Debug.h

    r7401 r8729  
    8383#ifdef ORXONOX_RELEASE
    8484    const int hardDebugLevel = OutputLevel::Verbose;
    85 #elif defined(NDEBUG)
    86     const int hardDebugLevel = OutputLevel::Verbose;
    8785#else
    8886    //! Maximum level for debug output that should be even processed at run time
     
    125123            orxonox::OutputHandler::getOutStream(level)
    126124
     125/** Logs debug output: You can use DOUT exactly like @c std::cout.
     126    Use this macro to produce temporary debug output that will be removed later on.
     127    The console output shall have a special colour if available.
     128*/
     129#define DOUT orxonox::OutputHandler::getOutStream(-1) << "+++ "
     130
    127131#endif /* _Util_Debug_H__ */
  • code/trunk/src/libraries/util/Math.h

    r8706 r8729  
    299299
    300300    _UtilExport unsigned long getUniqueNumber();
    301 
    302     /**
    303         @brief A Vector class containing two integers @a x and @a y.
    304     */
    305     class IntVector2
    306     {
    307     public:
    308         IntVector2() : x(0), y(0) { }
    309         IntVector2(int _x, int _y) : x(_x), y(_y) { }
    310         int x;
    311         int y;
    312     };
    313 
    314     /**
    315         @brief A Vector class containing three integers @a x, @a y, and @a z.
    316     */
    317     class IntVector3
    318     {
    319     public:
    320         IntVector3() : x(0), y(0), z(0) { }
    321         IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
    322         int x;
    323         int y;
    324         int z;
    325     };
    326301}
    327302
  • code/trunk/src/libraries/util/OutputHandler.cc

    r7401 r8729  
    6969        */
    7070        LogFileWriter()
    71             : OutputListener(OutputHandler::logFileOutputListenerName_s)
     71            : OutputListener("LogFile")
    7272        {
    7373            // Get path for a temporary file
     
    8585            timeinfo = localtime(&rawtime);
    8686
    87             this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
    88             this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl;
    89             this->logFile_.flush();
    90 
    91             this->outputStream_ = &this->logFile_;
     87            this->openFile();
     88            if (this->logFile_.is_open())
     89            {
     90                this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl;
     91                this->logFile_.flush();
     92            }
    9293        }
    9394
     
    9596        ~LogFileWriter()
    9697        {
    97             this->logFile_ << "Closed log" << std::endl;
    98             this->logFile_.close();
     98            if (this->logFile_.is_open())
     99            {
     100                this->logFile_ << "Closed log" << std::endl;
     101                this->logFile_.close();
     102            }
    99103        }
    100104
     
    102106        void setLogPath(const std::string& path)
    103107        {
    104             this->logFile_.close();
    105             // Read old file into a buffer
    106             std::ifstream old(this->logFilename_.c_str());
     108            if (this->logFile_.is_open())
     109                this->logFile_.close();
     110
     111            // Open the new file
    107112            this->logFilename_ = path + logFileBaseName_g;
    108             // Open the new file and feed it the content of the old one
     113            this->openFile();
     114        }
     115
     116        //! Erases the log file
     117        void clearFile()
     118        {
     119            if (this->logFile_.is_open())
     120            {
     121                this->logFile_.close();
     122                this->openFile();
     123            }
     124        }
     125
     126    private:
     127        void openFile()
     128        {
    109129            this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
    110             this->logFile_ << old.rdbuf();
    111             this->logFile_.flush();
    112             old.close();
    113         }
    114 
    115     private:
     130
     131            if (this->logFile_.is_open())
     132                this->outputStream_ = &this->logFile_;
     133            else
     134            {
     135                COUT(2) << "Warning: Failed to open log file. File logging disabled." << std::endl;
     136                this->outputStream_ = NULL;
     137            }
     138        }
     139
    116140        std::ofstream logFile_;     //!< File handle for the log file
    117141        std::string   logFilename_; //!< Filename of the log file
     
    133157        //! Only assigns the output stream with std::cout
    134158        ConsoleWriter()
    135             : OutputListener("consoleLog")
     159            : OutputListener("Console")
    136160        {
    137161            this->outputStream_ = &std::cout;
     
    147171        OutputListener that writes all the output piece by piece to an array
    148172        associated with the corresponding output level.
     173        Used as buffer until all output devices have been initialised.
    149174    @note
    150         Only output below or equal to the current soft debug level is written
    151         to minimise huge arrays for the normal run.
     175        At some point, OutputHandler::disableMemoryLog() has to be called in
     176        order to avoid large memory footprints of this class.
    152177    */
    153178    class MemoryLogWriter : public OutputListener
     
    156181        friend class OutputHandler;
    157182
    158         /**
    159         @brief
    160             Sets the right soft debug level and registers itself
    161         */
    162183        MemoryLogWriter()
    163184            : OutputListener("memoryLog")
     
    166187        }
    167188
    168         //! Pushed the just written output to the internal array
     189        //! Push the just written output to the internal array
    169190        void outputChanged(int level)
    170191        {
     
    180201
    181202    private:
    182         std::ostringstream                        buffer_; //!< Stream object used to process the output
    183         std::vector<std::pair<int, std::string> > output_; //!< Vector containing ALL output
     203        std::ostringstream          buffer_; //!< Stream object used to process the output
     204        OutputHandler::OutputVector output_; //!< Vector containing ALL output
    184205    };
    185206
     
    188209    ///// OutputHandler /////
    189210    /////////////////////////
    190     const std::string OutputHandler::logFileOutputListenerName_s = "logFile";
    191           int         OutputHandler::softDebugLevel_s = hardDebugLevel;
     211    int OutputHandler::softDebugLevel_s = hardDebugLevel;
    192212
    193213    //! Creates the LogFileWriter and the MemoryLogWriter
     
    195215        : outputLevel_(OutputLevel::Verbose)
    196216    {
     217        // Note: These levels only concern startup before orxonox.ini is read.
    197218#ifdef ORXONOX_RELEASE
    198         const OutputLevel::Value defaultLevelConsole = OutputLevel::Error;
    199         const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info;
     219        const OutputLevel::Value initialLevelConsole = OutputLevel::Error;
    200220#else
    201         const OutputLevel::Value defaultLevelConsole = OutputLevel::Info;
    202         const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug;
     221        const OutputLevel::Value initialLevelConsole = OutputLevel::Info;
    203222#endif
     223        // Use high log level because we rewrite the log file anyway with the
     224        // correct level. But if Orxonox were to crash before that, we might be
     225        // grateful to have a high debug level, esp. for releases.
     226        const OutputLevel::Value intialLevelLogFile = OutputLevel::Debug;
    204227
    205228        this->logFile_ = new LogFileWriter();
    206229        // Use default level until we get the configValue from the Core
    207         this->logFile_->softDebugLevel_ = defaultLevelLogFile;
     230        this->logFile_->softDebugLevel_ = intialLevelLogFile;
    208231        this->registerOutputListener(this->logFile_);
    209232
    210233        this->consoleWriter_ = new ConsoleWriter();
    211         this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
     234        this->consoleWriter_->softDebugLevel_ = initialLevelConsole;
    212235        this->registerOutputListener(this->consoleWriter_);
    213236
    214         this->output_ = new MemoryLogWriter();
    215         // We capture as much input as the listener with the highest level
    216         this->output_->softDebugLevel_ = getSoftDebugLevel();
    217         this->registerOutputListener(this->output_);
     237        this->memoryBuffer_ = new MemoryLogWriter();
     238        // Write everything, e.g. use hardDebugLevel
     239        this->memoryBuffer_->softDebugLevel_ = hardDebugLevel;
     240        this->registerOutputListener(this->memoryBuffer_);
    218241    }
    219242
     
    223246        delete this->logFile_;
    224247        delete this->consoleWriter_;
    225         delete this->output_;
     248        delete this->memoryBuffer_; // Might already be NULL
    226249    }
    227250
     
    234257    void OutputHandler::registerOutputListener(OutputListener* listener)
    235258    {
    236         for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     259        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    237260        {
    238261            if ((*it)->name_ == listener->name_)
     
    243266        }
    244267        this->listeners_.push_back(listener);
    245         // Update global soft debug level
    246         this->setSoftDebugLevel(listener->getOutputListenerName(), listener->getSoftDebugLevel());
     268        this->updateGlobalDebugLevel();
    247269    }
    248270
    249271    void OutputHandler::unregisterOutputListener(OutputListener* listener)
    250272    {
    251         this->listeners_.remove(listener);
     273        for (std::vector<OutputListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     274        {
     275            if ((*it)->name_ == listener->name_)
     276            {
     277                this->listeners_.erase(it);
     278                break;
     279            }
     280        }
     281        this->updateGlobalDebugLevel();
    252282    }
    253283
     
    255285    {
    256286        this->logFile_->setLogPath(path);
     287        this->rewriteLogFile();
     288    }
     289
     290    void OutputHandler::rewriteLogFile()
     291    {
     292        logFile_->clearFile();
     293
     294        if (logFile_->outputStream_ == NULL)
     295            return;
     296
     297        for (OutputVector::const_iterator it = this->getOutput().begin(); it != this->getOutput().end(); ++it)
     298        {
     299            if (it->first <= logFile_->softDebugLevel_)
     300                (*logFile_->outputStream_) << it->second;
     301        }
     302        logFile_->outputStream_->flush();
    257303    }
    258304
     
    267313    }
    268314
    269     OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorBegin() const
    270     {
    271         return this->output_->output_.begin();
    272     }
    273 
    274     OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorEnd() const
    275     {
    276         return this->output_->output_.end();
     315    void OutputHandler::disableMemoryLog()
     316    {
     317        this->unregisterOutputListener(this->memoryBuffer_);
     318        // Only clear the buffer so we can still reference the vector
     319        this->memoryBuffer_->output_.clear();
     320    }
     321
     322    const OutputHandler::OutputVector& OutputHandler::getOutput() const
     323    {
     324        return this->memoryBuffer_->output_;
    277325    }
    278326
    279327    int OutputHandler::getSoftDebugLevel(const std::string& name) const
    280328    {
    281         for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     329        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    282330        {
    283331            if ((*it)->name_ == name)
     
    289337    void OutputHandler::setSoftDebugLevel(const std::string& name, int level)
    290338    {
    291         int globalSoftDebugLevel = -1;
    292         for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     339        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    293340        {
    294341            if ((*it)->name_ == name)
    295342                (*it)->softDebugLevel_ = level;
    296             if ((*it)->softDebugLevel_ > globalSoftDebugLevel)
    297                 globalSoftDebugLevel = (*it)->softDebugLevel_;
    298         }
    299         // Update global soft debug level
     343        }
     344        this->updateGlobalDebugLevel();
     345    }
     346
     347    void OutputHandler::updateGlobalDebugLevel()
     348    {
     349        int globalSoftDebugLevel = -1;
     350        std::vector<OutputListener*>::const_iterator it = this->listeners_.begin();
     351        for (; it != this->listeners_.end(); ++it)
     352            globalSoftDebugLevel = std::max(globalSoftDebugLevel, (*it)->softDebugLevel_);
     353
    300354        OutputHandler::softDebugLevel_s = globalSoftDebugLevel;
    301355    }
  • code/trunk/src/libraries/util/OutputHandler.h

    r7401 r8729  
    3939#include "UtilPrereqs.h"
    4040
    41 #include <list>
    4241#include <ostream>
    4342#include <string>
     
    6362        enum Value
    6463        {
     64            TDebug  = -1,
    6565            None    = 0,
    6666            Error   = 1,
     
    103103                { return OutputHandler::getInstance().setOutputLevel(level); }
    104104
    105             typedef std::vector<std::pair<int, std::string> >::const_iterator OutputVectorIterator;
    106             //! Returns an iterator to the beginning of the all-output vector
    107             OutputVectorIterator getOutputVectorBegin() const;
    108             //! Returns an iterator to the end of the all-output vector
    109             OutputVectorIterator getOutputVectorEnd() const;
     105            typedef std::vector<std::pair<int, std::string> > OutputVector;
     106            //! Returns all output written so far (empty if disableMemoryLog() was called)
     107            const OutputVector& getOutput() const;
    110108
    111109            //! Writes to all output devices
     
    136134            //! Set the log path once the program has been properly initialised
    137135            void setLogPath(const std::string& path);
     136            /** Rewrites the log file (completely respects the current debug level).
     137                Once disableMemoryLog() has been called, this function will do nothing.
     138            */
     139            void rewriteLogFile();
     140
    138141            //! Disables the std::cout stream for output
    139142            void disableCout();
    140143            //! Enables the std::cout stream for output (startup behaviour)
    141144            void enableCout();
     145            //! Stop writing to the memory buffer (call this as soon as possible to minimise memory usage)
     146            void disableMemoryLog();
    142147
    143148            //! Sets the level of the incoming output and returns the OutputHandler
     
    213218            inline operator int() const { return 0; }
    214219
    215             //! Name of the OutputListener that writes to the log file
    216             static const std::string logFileOutputListenerName_s;
    217 
    218220        private:
    219221            OutputHandler();
     
    221223            OutputHandler(const OutputHandler& rhs);      //!< Copy-constructor: Unused and undefined
    222224
    223             std::list<OutputListener*> listeners_;        //!< Array with all registered output listeners
    224             int                        outputLevel_;      //!< The level of the incoming output
    225             LogFileWriter*             logFile_;          //!< Listener that writes to the log file
    226             ConsoleWriter*             consoleWriter_;    //!< Listener for std::cout (just program beginning)
    227             MemoryLogWriter*           output_;           //!< Listener that Stores ALL output below the current soft debug level
    228             static int                 softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
     225            /// Evaluates the maximum global log level
     226            void updateGlobalDebugLevel();
     227
     228            std::vector<OutputListener*> listeners_;        //!< Array with all registered output listeners
     229            int                          outputLevel_;      //!< The level of the incoming output
     230            LogFileWriter*               logFile_;          //!< Writes output to the log file
     231            ConsoleWriter*               consoleWriter_;    //!< Writes to std::cout (can be disabled)
     232            MemoryLogWriter*             memoryBuffer_;     //!< Writes to memory as a buffer (can/must be stopped at some time)
     233            static int                   softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
    229234    };
    230235
     
    251256        //! Returns the name of this output listener
    252257        const std::string& getOutputListenerName() const { return this->name_; }
    253         //! Returns the soft debug level of the listener
    254         int getSoftDebugLevel() const { return this->softDebugLevel_; }
    255         //! Sets the soft debug level of the listener
    256         void setSoftDebugLevel(int level)
    257         {
    258             this->softDebugLevel_ = level;
    259             OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
    260         }
    261258
    262259    protected:
     
    271268    inline OutputHandler& OutputHandler::output(const T& output)
    272269    {
    273         for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
     270        for (std::vector<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    274271        {
    275272            if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
  • code/trunk/src/libraries/util/UtilPrereqs.h

    r8351 r8729  
    8787    class Exception;
    8888    class ExprParser;
    89     class IntVector2;
    90     class IntVector3;
    9189    class MultiType;
    9290    class OutputHandler;
  • code/trunk/src/modules/docking/Dock.cc

    r8706 r8729  
    4444#include "worldentities/pawns/Pawn.h"
    4545
    46 #include "ToluaBindDocking.h"
    47 
    4846namespace orxonox
    4947{
    50     // Register tolua_open function when loading the library
    51     DeclareToluaInterface(Docking);
    52 
    5348    CreateFactory(Dock);
    5449
  • code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc

    r8706 r8729  
    4343#include "util/Convert.h"
    4444
    45 #include "ToluaBindNotifications.h"
    46 
    4745namespace orxonox
    4846{
    4947
    5048    CreateFactory(NotificationQueueCEGUI);
    51 
    52     // Register tolua_open function when loading the library.
    53     DeclareToluaInterface(Notifications);
    5449
    5550    /*static*/ const std::string NotificationQueueCEGUI::NOTIFICATION_LAYER("NotificationLayer");
  • code/trunk/src/modules/objects/eventsystem/EventFilter.cc

    r6417 r8729  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/Event.h"
    3233#include "core/XMLPort.h"
    3334#include "EventName.h"
  • code/trunk/src/modules/objects/eventsystem/EventListener.cc

    r7163 r8729  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/Event.h"
    3233#include "core/XMLPort.h"
    3334
  • code/trunk/src/modules/overlays/hud/GametypeFadingMessage.h

    r7163 r8729  
    2727 */
    2828
    29 #ifndef _GametypeInfoMessage_H__
    30 #define _GametypeInfoMessage_H__
     29#ifndef _GametypeFadingMessage_H__
     30#define _GametypeFadingMessage_H__
    3131
    3232#include "overlays/OverlaysPrereqs.h"
  • code/trunk/src/modules/pickup/PickupCollectionIdentifier.h

    r7533 r8729  
    3434
    3535#ifndef _PickupCollectionIdentifier_H__
    36 #define _PickupCollectionIdentifier_H_
     36#define _PickupCollectionIdentifier_H__
    3737
    3838#include "PickupPrereqs.h"
     
    7575}
    7676
    77 #endif // _PickupCollectionIdentifier_H_
     77#endif // _PickupCollectionIdentifier_H__
  • code/trunk/src/modules/pickup/PickupManager.cc

    r7801 r8729  
    4949#include "PickupRepresentation.h"
    5050
    51 #include "ToluaBindPickup.h"
    52 
    5351namespace orxonox
    5452{
    55     // Register tolua_open function when loading the library
    56     DeclareToluaInterface(Pickup);
    57 
    5853    ManageScopedSingleton(PickupManager, ScopeID::Root, false);
    5954
  • code/trunk/src/modules/pong/CMakeLists.txt

    r7163 r8729  
    11SET_SOURCE_FILES(PONG_SRC_FILES
    2 COMPILATION_BEGIN PongCompilation.cc
     2BUILD_UNIT PongBuildUnit.cc
    33  Pong.cc
    44  PongAI.cc
     
    88  PongCenterpoint.cc
    99  PongScore.cc
    10 COMPILATION_END
     10END_BUILD_UNIT
    1111)
    1212
  • code/trunk/src/modules/pong/PongAI.cc

    r8108 r8729  
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     38#include "core/command/Executor.h"
    3839#include "tools/Timer.h"
    3940
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r8706 r8729  
    4747#include "QuestItem.h"
    4848
    49 #include "ToluaBindQuestsystem.h"
    50 
    5149namespace orxonox
    5250{
    53     // Register tolua_open function when loading the library
    54     DeclareToluaInterface(Questsystem);
    55 
    5651    ManageScopedSingleton(QuestManager, ScopeID::Root, false);
    5752
  • code/trunk/src/modules/weapons/munitions/ReplenishingMunition.cc

    r5929 r8729  
    2828
    2929#include "ReplenishingMunition.h"
     30
    3031#include "core/CoreIncludes.h"
     32#include "core/command/Executor.h"
    3133
    3234namespace orxonox
  • code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc

    r6417 r8729  
    3131#include "util/Convert.h"
    3232#include "core/CoreIncludes.h"
     33#include "core/command/Executor.h"
    3334
    3435namespace orxonox
  • code/trunk/src/orxonox/CMakeLists.txt

    r8351 r8729  
    3535  ChatInputHandler.cc
    3636#  Test.cc
    37 COMPILATION_BEGIN SceneCompilation.cc
     37
     38BUILD_UNIT SceneBuildUnit.cc
    3839  CameraManager.cc
    3940  Scene.cc
    40 COMPILATION_END
     41END_BUILD_UNIT
    4142)
    4243
  • code/trunk/src/orxonox/Main.cc

    r7801 r8729  
    3939#include "core/Game.h"
    4040#include "core/LuaState.h"
    41 #include "ToluaBindOrxonox.h"
    42 #include "ToluaBindNetwork.h"
    43 
    44 DeclareToluaInterface(Orxonox);
    45 DeclareToluaInterface(Network);
    4641
    4742namespace orxonox
  • code/trunk/src/orxonox/controllers/AIController.cc

    r7284 r8729  
    3737namespace orxonox
    3838{
    39     static const float ACTION_INTERVAL = 1.0f;
     39    const float AIController::ACTION_INTERVAL = 1.0f;
    4040
    4141    CreateFactory(AIController);
  • code/trunk/src/orxonox/controllers/AIController.h

    r5929 r8729  
    5050
    5151        private:
     52            static const float ACTION_INTERVAL;
     53
    5254            Timer actionTimer_;
    5355    };
  • code/trunk/src/orxonox/controllers/DroneController.cc

    r7284 r8729  
    4343    CreateFactory(DroneController);
    4444
    45     static const float ACTION_INTERVAL = 1.0f;
     45    const float DroneController::ACTION_INTERVAL = 1.0f;
    4646
    4747    DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
  • code/trunk/src/orxonox/controllers/DroneController.h

    r7163 r8729  
    6969
    7070        private:
     71            static const float ACTION_INTERVAL;
     72
    7173            Timer actionTimer_;
    7274            WeakPtr<Pawn> owner_;
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r8079 r8729  
    7777        {
    7878            gameInputState_ = InputManager::getInstance().createInputState("game");
    79             gameInputState_->setMouseExclusive(TriBool::True);
     79            gameInputState_->setMouseExclusive(true);
    8080            gameInputState_->setHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
    8181            KeyBinderManager::getInstance().setToDefault();
    8282
    8383            guiMouseOnlyInputState_ = InputManager::getInstance().createInputState("guiMouseOnly");
    84             guiMouseOnlyInputState_->setMouseExclusive(TriBool::True);
     84            guiMouseOnlyInputState_->setMouseExclusive(true);
    8585            guiMouseOnlyInputState_->setMouseHandler(&GUIManager::getInstance());
    8686
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r8727 r8729  
    4848#include "util/Convert.h"
    4949#include "core/CoreIncludes.h"
     50#include "core/command/Executor.h"
    5051#include "network/Host.h"
    5152#include "infos/PlayerInfo.h"
  • code/trunk/src/orxonox/graphics/CMakeLists.txt

    r7163 r8729  
    99  ParticleEmitter.cc
    1010  ParticleSpawner.cc
    11 COMPILATION_BEGIN GraphicsCompilation.cc
     11
     12BUILD_UNIT GraphicsBuildUnit.cc
    1213  Backlight.cc
    1314  Camera.cc
    1415  Light.cc
    15 COMPILATION_END
     16END_BUILD_UNIT
    1617)
  • code/trunk/src/orxonox/overlays/InGameConsole.cc

    r8484 r8729  
    9191        this->setConfigValues();
    9292        this->initialise();
     93
     94        // Output buffering is not anymore needed. Not the best solution to do
     95        // this here, but there isn't much of another way.
     96        OutputHandler::getInstance().disableMemoryLog();
    9397    }
    9498
     
    586590                          colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); break;
    587591
     592        case Shell::TDebug:  colourTop = ColourValue(0.90f, 0.00f, 0.90f, 1.00f);
     593                          colourBottom = ColourValue(1.00f, 0.00f, 1.00f, 1.00f); break;
     594
    588595        default:             colourTop = ColourValue(0.90f, 0.90f, 0.90f, 1.00f);
    589596                          colourBottom = ColourValue(1.00f, 1.00f, 1.00f, 1.00f); break;
  • code/trunk/src/orxonox/sound/BaseSound.cc

    r8521 r8729  
    6161    BaseSound::~BaseSound()
    6262    {
    63         this->stop();
     63        if (this->state_ != Stopped)
     64            this->stop();
    6465        // Release buffer
    6566        if (this->soundBuffer_ != NULL)
  • code/trunk/src/orxonox/weaponsystem/Munition.cc

    r8706 r8729  
    2929
    3030#include "Munition.h"
     31
    3132#include "core/CoreIncludes.h"
     33#include "core/command/Executor.h"
    3234
    3335namespace orxonox
  • code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc

    r7183 r8729  
    3030
    3131#include "core/CoreIncludes.h"
     32#include "core/SubclassIdentifier.h"
    3233#include "worldentities/pawns/Pawn.h"
    3334
Note: See TracChangeset for help on using the changeset viewer.