BARE2D
LuaContextManager.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <map>
4 
5 namespace BARE2D {
6 
7  class LuaScriptContextWrapper;
8 
9  /**
10  * @class LuaContextManager
11  * @file LuaContextManager.hpp
12  * @brief NOTE: This is a singleton class. The LuaContextManager, well, manages the Lua Contexts which the ScriptEngine has created. These, generally, are scripts which are running. This class simply updates them and handles delay functions and the like.
13  */
15  {
16  public:
18  static void destroyInstance();
19 
20  /**
21  * @brief Updates all of the context wrappers, pausing, removing (if finished), or resuming them as is correct.
22  */
23  void update();
24 
25  /**
26  * @brief Adds a context wrapper to the map.
27  * @param id The ID that the ScriptQueue gave the script all those cycles ago
28  * @param context The context to insert in the map.
29  */
30  void addContext(unsigned int id, LuaScriptContextWrapper* context);
31 
32  /**
33  * @brief Gets a context wrapper from the map
34  * @param id The ID of the context, given by the LuaScriptQueue::addScript() call.
35  * @return A pointer to the wrapper, and a nullptr if it doesn't exist.
36  */
37  LuaScriptContextWrapper* getContext(unsigned int id);
38 
39  private:
42 
44 
45  /**
46  * @brief Removes a context wrapper from the map
47  * @param id The ID of the context to remove from the map.
48  */
49  void removeContext(unsigned int id);
50 
51  // All of the scripts
52  std::map<unsigned int, LuaScriptContextWrapper*> m_contexts;
53 
54  };
55 
56 }
57 
BARE2D::LuaContextManager::m_contexts
std::map< unsigned int, LuaScriptContextWrapper * > m_contexts
Definition: LuaContextManager.hpp:52
BARE2D
Definition: App.cpp:13
BARE2D::LuaContextManager
Definition: LuaContextManager.hpp:14
BARE2D::LuaScriptContextWrapper
Definition: LuaScript.hpp:31
BARE2D::LuaContextManager::getContext
LuaScriptContextWrapper * getContext(unsigned int id)
Gets a context wrapper from the map.
Definition: LuaContextManager.cpp:80
BARE2D::LuaContextManager::addContext
void addContext(unsigned int id, LuaScriptContextWrapper *context)
Adds a context wrapper to the map.
Definition: LuaContextManager.cpp:54
BARE2D::LuaContextManager::m_instance
static LuaContextManager * m_instance
Definition: LuaContextManager.hpp:43
BARE2D::LuaContextManager::removeContext
void removeContext(unsigned int id)
Removes a context wrapper from the map.
Definition: LuaContextManager.cpp:60
BARE2D::LuaContextManager::LuaContextManager
LuaContextManager()
Definition: LuaContextManager.cpp:11
BARE2D::LuaContextManager::update
void update()
Updates all of the context wrappers, pausing, removing (if finished), or resuming them as is correct.
Definition: LuaContextManager.cpp:33
BARE2D::LuaContextManager::getInstance
static LuaContextManager * getInstance()
Definition: LuaContextManager.cpp:21
BARE2D::LuaContextManager::~LuaContextManager
~LuaContextManager()
Definition: LuaContextManager.cpp:16
BARE2D::LuaContextManager::destroyInstance
static void destroyInstance()
Definition: LuaContextManager.cpp:29