Leviathan  0.8.0.0
Leviathan game engine
GameModuleLoader.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2018 Henri Hyyryläinen
3 #pragma once
4 #include "Define.h"
5 // ------------------------------------ //
6 #include "GameModule.h"
7 
8 #include "Common/ThreadSafe.h"
9 
10 namespace Leviathan {
11 
17  friend GameModule;
18 
19 public:
22 
25  DLLEXPORT void Init();
26 
34  DLLEXPORT GameModule::pointer Load(const std::string& modulename, const char* requiredby);
35 
36 protected:
39 
40 private:
41  bool _LoadInfoFromModuleFile(
42  const std::string& file, std::string& modulename, std::string& errorstring);
43 
45  GameModule::pointer _LoadModuleFromFile(
46  const std::string& filename, const char* requiredby);
47 
48 private:
49  std::map<std::string, std::string> ModuleNameToPath;
50 
51  // This is a plain pointer to allow GameModules to be deleted when only us have a reference
52  // to it
53  std::map<std::string, GameModule*> LoadedModules;
54 };
55 
56 } // namespace Leviathan
Allows the inherited object to be locked.
Definition: ThreadSafe.h:137
DLLEXPORT GameModule::pointer Load(const std::string &modulename, const char *requiredby)
Returns a module by name.
DLLEXPORT void Init()
Finds the names of all modules and which files they are in. This is safe to call again if changes to ...
void GameModuleReportDestruction(GameModule &module)
Used by GameModule to report that it is going to be deleted.
#define DLLEXPORT
Definition: Include.h:84
Represents a scriptable part of a program.
Definition: GameModule.h:18
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
Manages loading GameModule objects to make sure that each is loaded only once.