Orxonox: orxonox::Core Class Reference

# orxonox::Core Class Reference

The Core class is a singleton used to configure the program basics. More...

`#include <src/core/Core.h>`

List of all members.

## Public Member Functions

| Core (int argc, char **argv)
| Determines the executable path, checks for build directory runs, creates the output directories and sets up the other core library singletons.
void | setConfigValues ()
void | update (const Clock &time)
| ~Core ()
| Sets the bool to true to avoid static functions accessing a deleted object.

## Static Public Member Functions

static const boost::filesystem::path & | getConfigPath ()
| Returns the path to the config files as boost::filesystem::path.
static std::string | getConfigPathString ()
| Returns the path to the config files as std::string.
static Core & | getInstance ()
static const std::string & | getLanguage ()
| Returns the configured language.
static const boost::filesystem::path & | getLogPath ()
| Returns the path to the log files as boost::filesystem::path.
static std::string | getLogPathString ()
| Returns the path to the log files as std::string.
static const boost::filesystem::path & | getMediaPath ()
| Returns the path to the config files as boost::filesystem::path.
static std::string | getMediaPathString ()
| Returns the path to the data files as std::string.
static int | getSoftDebugLevel (OutputHandler::OutputDevice device=OutputHandler::LD_All)
| Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).
static void | resetLanguage ()
| Sets the language in the config-file back to the default.
static void | setSoftDebugLevel (OutputHandler::OutputDevice device, int level)
| Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.
static void | tsetMediaPath (const std::string &path)

## Private Member Functions

void | checkDevBuild ()
| Checks for "orxonox_dev_build.keep_me" in the executable diretory. If found it means that this is not an installed run, hence we don't write the logs and config files to ~/.orxonox.
| Core (const Core &)
| Don't use (undefined symbol).
void | createDirectories ()
void | setExecutablePath ()
| Compares the executable path with the working directory.
void | setThreadAffinity (int limitToCPU)

## Private Attributes

ConfigFileManager * | configFileManager_
CoreConfiguration * | configuration_
bool | isDevBuild_
| True for builds in the build directory (not installed).
Language * | languageInstance_
LuaBind * | luaBind_
Shell * | shell_
SignalHandler * | signalHandler_
TclBind * | tclBind_
TclThreadManager * | tclThreadManager_

## Static Private Attributes

static Core * | singletonRef_s = 0
| Static pointer to the singleton.

## Detailed Description

The Core class is a singleton used to configure the program basics.

The class provides information about the media, config and log path. It determines those by the use of platform specific functions.

## Constructor & Destructor Documentation

orxonox::Core::Core | ( | int | argc,
|  | char ** | argv |
| ) |  |  |

Determines the executable path, checks for build directory runs, creates the output directories and sets up the other core library singletons.

Exceptions:

  | GeneralException |

References checkDevBuild(), configFileManager_, configuration_, COUT, orxonox::Factory::createClassHierarchy(), createDirectories(), orxonox::SignalHandler::doCatch(), orxonox::CoreConfiguration::executablePath_, getLogPathString(), getMediaPathString(), orxonox::OutputHandler::getOutStream(), orxonox::TclBind::getTclInterpreter(), orxonox::CommandLine::getValue(), orxonox::CoreConfiguration::initialise(), languageInstance_, luaBind_, orxonox::CommandLine::parseCommandLine(), orxonox::CommandLine::parseFile(), setExecutablePath(), orxonox::ConfigFileManager::setFilename(), orxonox::OutputHandler::setLogPath(), setThreadAffinity(), orxonox::ConfigFileType::Settings, shell_, signalHandler_, singletonRef_s, tclBind_, and tclThreadManager_.

orxonox::Core::~Core | ( |  | ) |

Sets the bool to true to avoid static functions accessing a deleted object.

References configFileManager_, configuration_, orxonox::CommandLine::destroyAllArguments(), orxonox::Identifier::destroyAllIdentifiers(), orxonox::CommandExecutor::destroyExternalCommands(), languageInstance_, luaBind_, shell_, signalHandler_, tclBind_, and tclThreadManager_.

orxonox::Core::Core | ( | const Core & |  | ) | `[private]`

Don't use (undefined symbol).

## Member Function Documentation

void orxonox::Core::checkDevBuild | ( |  | ) | `[private]`

Checks for "orxonox_dev_build.keep_me" in the executable diretory. If found it means that this is not an installed run, hence we don't write the logs and config files to ~/.orxonox.

Exceptions:

  | GeneralException |

References orxonox::CoreConfiguration::configPath_, configuration_, COUT, orxonox::CoreConfiguration::executablePath_, orxonox::CommandLine::getArgument(), orxonox::CommandLine::getValue(), isDevBuild_, orxonox::CoreConfiguration::logPath_, orxonox::CoreConfiguration::mediaPath_, orxonox::ORXONOX_CONFIG_DEV_PATH, orxonox::ORXONOX_CONFIG_INSTALL_PATH, orxonox::ORXONOX_LOG_DEV_PATH, orxonox::ORXONOX_LOG_INSTALL_PATH, orxonox::ORXONOX_MEDIA_DEV_PATH, orxonox::ORXONOX_MEDIA_INSTALL_PATH, orxonox::ORXONOX_RUNTIME_INSTALL_PATH, orxonox::CoreConfiguration::rootPath_, and ThrowException.

Referenced by Core().

void orxonox::Core::createDirectories | ( |  | ) | `[private]`

References orxonox::CoreConfiguration::configPath_, configuration_, COUT, orxonox::CoreConfiguration::logPath_, and ThrowException.

Referenced by Core().

const boost::filesystem::path & orxonox::Core::getConfigPath | ( |  | ) | `[static]`

Returns the path to the config files as boost::filesystem::path.

References orxonox::CoreConfiguration::configPath_, configuration_, and getInstance().

Referenced by orxonox::CommandLine::_parseFile(), orxonox::ConfigFile::load(), orxonox::Language::readDefaultLanguageFile(), orxonox::Language::readTranslatedLanguageFile(), orxonox::ConfigFile::save(), orxonox::GraphicsManager::setupOgre(), and orxonox::Language::writeDefaultLanguageFile().

std::string orxonox::Core::getConfigPathString | ( |  | ) | `[static]`

Returns the path to the config files as std::string.

References orxonox::CoreConfiguration::configPath_, configuration_, and getInstance().

static Core& orxonox::Core::getInstance | ( |  | ) | `[inline, static]`

References singletonRef_s.

Referenced by getConfigPath(), getConfigPathString(), getLanguage(), getLogPath(), getLogPathString(), getMediaPath(), getMediaPathString(), getSoftDebugLevel(), resetLanguage(), setSoftDebugLevel(), and tsetMediaPath().

const std::string & orxonox::Core::getLanguage | ( |  | ) | `[static]`

Returns the configured language.

References configuration_, getInstance(), and orxonox::CoreConfiguration::language_.

Referenced by orxonox::Language::readTranslatedLanguageFile().

const boost::filesystem::path & orxonox::Core::getLogPath | ( |  | ) | `[static]`

Returns the path to the log files as boost::filesystem::path.

References configuration_, getInstance(), and orxonox::CoreConfiguration::logPath_.

Referenced by orxonox::GraphicsManager::setupOgre().

std::string orxonox::Core::getLogPathString | ( |  | ) | `[static]`

Returns the path to the log files as std::string.

References configuration_, getInstance(), and orxonox::CoreConfiguration::logPath_.

Referenced by Core(), orxonox::GUIManager::initialise(), and orxonox::GraphicsManager::printScreen().

const boost::filesystem::path & orxonox::Core::getMediaPath | ( |  | ) | `[static]`

Returns the path to the config files as boost::filesystem::path.

References configuration_, getInstance(), and orxonox::CoreConfiguration::mediaPath_.

Referenced by orxonox::GSGraphics::activate(), orxonox::GraphicsManager::declareResources(), and orxonox::ConfigFile::load().

std::string orxonox::Core::getMediaPathString | ( |  | ) | `[static]`

Returns the path to the data files as std::string.

References configuration_, getInstance(), and orxonox::CoreConfiguration::mediaPath_.

Referenced by Core(), orxonox::Loader::getLevelList(), orxonox::Level::Level(), orxonox::SoundBase::loadFile(), orxonox::GSLevel::loadLevel(), orxonox::GUIManager::loadLuaCode(), orxonox::LuaBind::LuaBind(), and orxonox::Level::networkcallback_applyXMLFile().

int orxonox::Core::getSoftDebugLevel | ( | OutputHandler::OutputDevice | device = `OutputHandler::LD_All` | ) | `[static]`

Returns the softDebugLevel for the given device (returns a default-value if the class is right about to be created).

Parameters:

  | device | The device

Returns:
  The softDebugLevel

References configuration_, getInstance(), orxonox::OutputHandler::LD_All, orxonox::OutputHandler::LD_Console, orxonox::OutputHandler::LD_Logfile, orxonox::OutputHandler::LD_Shell, orxonox::CoreConfiguration::softDebugLevel_, orxonox::CoreConfiguration::softDebugLevelConsole_, orxonox::CoreConfiguration::softDebugLevelLogfile_, and orxonox::CoreConfiguration::softDebugLevelShell_.

Referenced by orxonox::GUIManager::initialise().

void orxonox::Core::resetLanguage | ( |  | ) | `[static]`

Sets the language in the config-file back to the default.

References configuration_, getInstance(), and orxonox::CoreConfiguration::resetLanguage().

Referenced by orxonox::Language::readTranslatedLanguageFile().

void orxonox::Core::setConfigValues | ( |  | ) |

void orxonox::Core::setExecutablePath | ( |  | ) | `[private]`

Compares the executable path with the working directory.

References configuration_, orxonox::CoreConfiguration::executablePath_, and ThrowException.

Referenced by Core().

void orxonox::Core::setSoftDebugLevel | ( | OutputHandler::OutputDevice | device,
|  | int | level |
| ) |  |  | `[static]`

Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.

Parameters:

  | device | The device
  | level | The level

References configuration_, getInstance(), orxonox::OutputHandler::LD_All, orxonox::OutputHandler::LD_Console, orxonox::OutputHandler::LD_Logfile, orxonox::OutputHandler::LD_Shell, orxonox::OutputHandler::setSoftDebugLevel(), orxonox::CoreConfiguration::softDebugLevel_, orxonox::CoreConfiguration::softDebugLevelConsole_, orxonox::CoreConfiguration::softDebugLevelLogfile_, and orxonox::CoreConfiguration::softDebugLevelShell_.

Referenced by orxonox::Shell::Shell().

void orxonox::Core::setThreadAffinity | ( | int | limitToCPU | ) | `[private]`

Note:
  The code of this function has been copied and adjusted from OGRE, an open source graphics engine. (Object-oriented Graphics Rendering Engine) For the latest info, see http://www.ogre3d.org/

Copyright (c) 2000-2008 Torus Knot Software Ltd

OGRE is licensed under the LGPL. For more info, see OGRE license.

Referenced by Core().

void orxonox::Core::tsetMediaPath | ( | const std::string & | path | ) | `[static]`

References configuration_, getInstance(), and orxonox::CoreConfiguration::tsetMediaPath().

void orxonox::Core::update | ( | const Clock & | time | ) |

References tclThreadManager_, and orxonox::TclThreadManager::update().

Referenced by orxonox::Game::run().

## Member Data Documentation

ConfigFileManager* orxonox::Core::configFileManager_`[private]`

Referenced by Core(), and ~Core().

CoreConfiguration* orxonox::Core::configuration_`[private]`

Referenced by checkDevBuild(), Core(), createDirectories(), getConfigPath(), getConfigPathString(), getLanguage(), getLogPath(), getLogPathString(), getMediaPath(), getMediaPathString(), getSoftDebugLevel(), resetLanguage(), setExecutablePath(), setSoftDebugLevel(), tsetMediaPath(), and ~Core().

bool orxonox::Core::isDevBuild_`[private]`

True for builds in the build directory (not installed).

Referenced by checkDevBuild().

Language* orxonox::Core::languageInstance_`[private]`

Referenced by Core(), and ~Core().

LuaBind* orxonox::Core::luaBind_`[private]`

Referenced by Core(), and ~Core().

Shell* orxonox::Core::shell_`[private]`

Referenced by Core(), and ~Core().

SignalHandler* orxonox::Core::signalHandler_`[private]`

Referenced by Core(), and ~Core().

Core * orxonox::Core::singletonRef_s = 0`[static, private]`

Static pointer to the singleton.

Referenced by Core(), and getInstance().

TclBind* orxonox::Core::tclBind_`[private]`

Referenced by Core(), and ~Core().

TclThreadManager* orxonox::Core::tclThreadManager_`[private]`

Referenced by Core(), update(), and ~Core().

The documentation for this class was generated from the following files:

- src/core/Core.h
- src/core/Core.cc