NLS Engine  v0.1
The Next Logical Step in game engine design.
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Defines
ModuleManager.h
Go to the documentation of this file.
00001 #pragma once
00002 
00014 // Standard Includes
00015 #include <string>
00016 #include <map>
00017 
00018 // Library Includes
00019 #include <boost/foreach.hpp> // Quick simple looping
00020 
00021 // Local Includes
00022 #include "../sharedbase/MessageRouter.h"
00023 #include "../sharedbase/Envelope_fwd.h"
00024 #include "../sharedbase/OSInterface_fwd.h"
00025 
00026 // Forward Declarations
00027 class PropertyMap;
00028 class ModuleInterface;
00029 class EntityList;
00030 class EventLogger;
00031 
00032 // Typedefs
00033 typedef ModuleInterface* (*ModuleInstanceFactory)(PropertyMap*, MessageRouter*, EntityList*, EventLogger*, OSInterfaceSPTR); // Used to find the address of the create system function
00034 // Preprocessor selection based on OS
00035 #ifdef _WIN32
00036 #include <Windows.h>
00037 typedef HMODULE DLLHANDLE;
00038 #else
00039 #include <dlfcn.h>
00040 typedef void* DLLHANDLE;
00041 #endif
00042 
00043 class ModuleManager {
00044 public:
00045   ModuleManager(PropertyMap*, MessageRouter*, EntityList*);
00046   void Shutdown(); // Shuts down and removes all modules and their libraries.
00047 
00048   void Load(std::string); // The name is required in order to load the new library
00049   void LoadFromMessage(EnvelopeSPTR); // The name is required in order to load the new library
00050   void Unload(std::string = "");
00051   void UnloadFromMessage(EnvelopeSPTR);
00052 
00053   void Update(double = 0.0f);
00054 
00055   void CreateEntity(EnvelopeSPTR);
00056 
00057 private:
00058   PropertyMap* gprops;
00059   MessageRouter* msgrouter;
00060   EntityList* emgr;
00061 
00062   std::map<std::string, ModuleInterface*> modules; // A mapping of each core to its given name
00063   std::map<std::string, DLLHANDLE> libraries; // A mapping of each loaded library to a given filename
00064 };