Public Member Functions | |
bool | initializeLog (const std::string &logPath) |
void | stopEngine () |
void | runEngine () |
void | updateEngine () |
bool | initializeEngine () |
bool | loadPlugin (const std::string &path, const std::string &file, const std::string &name) |
~Engine () | |
Static Public Member Functions | |
static Log * | sLog () |
static Kernel * | sKernel () |
static Clock * | sClock () |
static Profiler * | sProfiler () |
static ResourceManager * | sResourceManager () |
static EventManager * | sEventManager () |
static ScriptEngine * | sScriptEngine () |
static PropertyManager * | sPropertyManager () |
static Engine * | instance (bool release=false) |
static Engine * | sEngine () |
static bool | valid (void *p=sSingleton.get(), char *name="Engine", bool showWarn=true) |
static void | release () |
This is our main class representing the engine itself. This class is able to create and initialize particular elements of the engine's core. So before you can use the engine you have to create an instance of this class.
The engine's core class is a singleton. We also store all subsystems as static, to be sure that they exists also only once in memory.
Definition at line 37 of file Engine.h.
nrEngine::Engine::~Engine | ( | ) |
Delete the core object and try to deinitialize and to delete all subcomponents of the engine
Definition at line 169 of file Engine.cpp.
References nrEngine::DefaultScriptingFunctions::delMethods().
bool nrEngine::Engine::initializeLog | ( | const std::string & | logPath | ) |
Initialize the log component of the engine. You have to call this function before you get using of engine's components. They all will log their work information to appropriate log files, so the log part of the engie has to be initialized before.
If you do not initilaize the logging functionality, so no log files will be written. No error will occurs.
logPath | Under this directory all log files will be created |
Definition at line 201 of file Engine.cpp.
References nrEngine::Log::initialize(), and nrEngine::OK.
void nrEngine::Engine::stopEngine | ( | ) |
Release the engine and all used memory. The call of this function will immidiately stop all kernel tasks and will stop the engine.
Call this function if you want to quit the engine.
Definition at line 207 of file Engine.cpp.
References nrEngine::Log::log(), nrEngine::Log::LOG_ENGINE, and nrEngine::Kernel::StopExecution().
void nrEngine::Engine::runEngine | ( | ) |
"Gentlemans, start your engines!" - This is the entry point for your application to start the engine. Starting of the engine will also start a kernel, which is running system + application tasks. If no more tasks is active, the kernel will be shutted down and engine will stop.
Definition at line 268 of file Engine.cpp.
References nrEngine::Kernel::Execute(), nrEngine::Log::log(), and nrEngine::Log::LOG_ENGINE.
void nrEngine::Engine::updateEngine | ( | ) |
If you do not want to run the engine in their own loop (startEngine() ) you can update the engine through this function. This function should be called each frame. This will update the kernel tasks and all engine's subsystems
Definition at line 280 of file Engine.cpp.
References nrEngine::Kernel::OneTick().
bool nrEngine::Engine::initializeEngine | ( | ) |
This method will initialize all engine's subsystems, that are essential for engine's work. Please call this function after you have intialized the logging, because there will be a lot of log information.
Definition at line 217 of file Engine.cpp.
References nrEngine::DefaultScriptingFunctions::addMethods(), nrEngine::Kernel::AddTask(), nrEngine::convertVersionToString(), nrEngine::EventManager::createChannel(), nrEngine::Log::LL_ERROR, nrEngine::Log::LOG_CONSOLE, nrEngine::Log::LOG_ENGINE, nrEngine::Log::LOG_KERNEL, nrEngine::nrEngineVersion, nrEngine::ORDER_SYS_FIRST, nrEngine::ORDER_SYS_SECOND, nrEngine::ResourceManager::registerLoader(), nrEngine::Clock::setTimeSource(), and nrEngine::TASK_SYSTEM.
bool nrEngine::Engine::loadPlugin | ( | const std::string & | path, | |
const std::string & | file, | |||
const std::string & | name | |||
) |
Load a certain plugin directly into the engine. The plugin will be loaded and the initialize subroutine will be called. If the plugin returns an invalid resulting code, so the plugin will be unloaded again.
Use this function to load certain plugins needed for your application (i.e. ScriptLoader) and let them run with certain parameters, so you are able to use the engine as you need.
path | Path where the plugin can be founded | |
file | Filename relative to the path of the plugin | |
name | Name which will be then used to access the plugin later |
Definition at line 288 of file Engine.cpp.
References nrEngine::Log::LL_ERROR, nrEngine::ResourceManager::loadResource(), and nrEngine::Log::LOG_ENGINE.
Referenced by nrEngine::ScriptFunctionDec().
Log * nrEngine::Engine::sLog | ( | ) | [static] |
Get a pointer to a log subsystem of the engine. The pointer is always not equal to NULL. By initializing of the log subsystem you just setup the log target. So you can always log to the log-system without checking whenever pointer is valid or not.
Definition at line 74 of file Engine.cpp.
References valid().
Kernel * nrEngine::Engine::sKernel | ( | ) | [static] |
Return a pointer to the kernel subsystem of the engine. Our kernel is normaly a singleton, so you can access to it, without this method.
Returned pointer is always valid.
Definition at line 81 of file Engine.cpp.
References valid().
Referenced by nrEngine::ITask::addTaskDependency(), nrEngine::IScript::execute(), and nrEngine::IScript::updateTask().
Clock * nrEngine::Engine::sClock | ( | ) | [static] |
Return a pointer to the underlying clock of the engine. The clock is a singleton, so you can access it on another way.
Returned pointer is always valid
Definition at line 88 of file Engine.cpp.
References valid().
Profiler * nrEngine::Engine::sProfiler | ( | ) | [static] |
Returns a pointer to the profiler object. The profiler is used to mess the time of execution
Definition at line 95 of file Engine.cpp.
References valid().
Referenced by nrEngine::Profile::Profile(), and nrEngine::Profile::~Profile().
ResourceManager * nrEngine::Engine::sResourceManager | ( | ) | [static] |
Returns a pointer to the ressource manager object.
Definition at line 102 of file Engine.cpp.
References valid().
Referenced by nrEngine::IResourceLoader::create(), nrEngine::ScriptEngine::execute(), nrEngine::ScriptEngine::load(), nrEngine::IResourceLoader::load(), nrEngine::IResourceLoader::notifyRemoveResource(), nrEngine::IResource::reload(), nrEngine::ScriptFunctionDec(), and nrEngine::IResource::unload().
EventManager * nrEngine::Engine::sEventManager | ( | ) | [static] |
Return an instance of the event manager class
Definition at line 109 of file Engine.cpp.
References valid().
Referenced by nrEngine::ScriptEngine::add(), nrEngine::EventActor::connect(), nrEngine::ScriptEngine::del(), nrEngine::EventActor::disconnect(), nrEngine::EventActor::emit(), nrEngine::Kernel::ResumeTask(), nrEngine::Kernel::SuspendTask(), and nrEngine::EventActor::~EventActor().
ScriptEngine * nrEngine::Engine::sScriptEngine | ( | ) | [static] |
Get a pointer to the scripting engine interface
Definition at line 116 of file Engine.cpp.
References valid().
Referenced by nrEngine::DefaultScriptingFunctions::addMethods(), nrEngine::DefaultScriptingFunctions::delMethods(), nrEngine::Script::fullRun(), nrEngine::ScriptConnector::initialize(), nrEngine::Clock::onStartTask(), nrEngine::PluginLoader::PluginLoader(), nrEngine::ScriptFunctionDec(), nrEngine::Clock::stopTask(), nrEngine::PluginLoader::~PluginLoader(), and nrEngine::ResourceManager::~ResourceManager().
PropertyManager * nrEngine::Engine::sPropertyManager | ( | ) | [static] |
Get instance to the property manager of the engine.
Definition at line 123 of file Engine.cpp.
References valid().
Referenced by nrEngine::ScriptFunctionDec().
Engine * nrEngine::Engine::instance | ( | bool | release = false |
) | [static] |
Get the singleton instance. Passing the parameter specify if the instance should be released
Definition at line 53 of file Engine.cpp.
References valid().
Referenced by nrEngine::Plugin::initialize(), and nrEngine::ScriptFunctionDec().
static Engine* nrEngine::Engine::sEngine | ( | ) | [static] |
bool nrEngine::Engine::valid | ( | void * | p = sSingleton.get() , |
|
char * | name = "Engine" , |
|||
bool | showWarn = true | |||
) | [static] |
Check whenever the engine'S singleton was created before
Definition at line 41 of file Engine.cpp.
Referenced by instance(), release(), sClock(), sEventManager(), sKernel(), sLog(), sProfiler(), sPropertyManager(), sResourceManager(), and sScriptEngine().
void nrEngine::Engine::release | ( | ) | [static] |