MyGUI 3.4.1
MyGUI_DynLibManager.cpp
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#include "MyGUI_Precompiled.h"
9#include "MyGUI_Gui.h"
10#include "MyGUI_WidgetManager.h"
11
12namespace MyGUI
13{
14
16
18 mIsInitialise(false),
19 mSingletonHolder(this)
20 {
21 }
22
24 {
25 MYGUI_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
26 MYGUI_LOG(Info, "* Initialise: " << getClassTypeName());
27
28 Gui::getInstance().eventFrameStart += newDelegate(this, &DynLibManager::notifyEventFrameStart);
29
30 MYGUI_LOG(Info, getClassTypeName() << " successfully initialized");
31 mIsInitialise = true;
32 }
33
35 {
36 MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised");
37 MYGUI_LOG(Info, "* Shutdown: " << getClassTypeName());
38
39 unloadAll();
40
41 Gui::getInstance().eventFrameStart -= newDelegate(this, &DynLibManager::notifyEventFrameStart);
43
44 MYGUI_LOG(Info, getClassTypeName() << " successfully shutdown");
45 mIsInitialise = false;
46 }
47
48 DynLib* DynLibManager::load(const std::string& fileName)
49 {
50 StringDynLibMap::iterator it = mLibsMap.find(fileName);
51
52 if (it != mLibsMap.end())
53 {
54 return it->second;
55 }
56
57 DynLib* pLib = new DynLib(fileName);
58 if (!pLib->load())
59 {
60 delete pLib;
61 return nullptr;
62 }
63
64 mLibsMap[fileName] = pLib;
65 return pLib;
66 }
67
69 {
70 StringDynLibMap::iterator it = mLibsMap.find(library->getName());
71
72 if (it != mLibsMap.end())
73 mLibsMap.erase(it);
74
75 mDelayDynLib.push_back(library);
76 }
77
79 {
80 // unload and delete resources
81 for (StringDynLibMap::iterator it = mLibsMap.begin(); it != mLibsMap.end(); ++it)
82 {
83 mDelayDynLib.push_back(it->second);
84 }
85 // Empty the list
86 mLibsMap.clear();
87 }
88
89 void DynLibManager::notifyEventFrameStart(float _time)
90 {
92 }
93
95 {
96 if (!mDelayDynLib.empty())
97 {
99 if (manager != nullptr)
100 manager->_deleteDelayWidgets();
101
102 for (VectorDynLib::iterator entry = mDelayDynLib.begin(); entry != mDelayDynLib.end(); ++entry)
103 {
104 (*entry)->unload();
105 delete (*entry);
106 }
107 mDelayDynLib.clear();
108 }
109 }
110
111} // namespace MyGUI
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_LOG(level, text)
Resource holding data about a dynamic library.
Definition: MyGUI_DynLib.h:35
std::string getName(void) const
Get the name of the library.
Manager of dynamic libraries.
void unload(DynLib *library)
Unload library.
static const char * getClassTypeName()
DynLib * load(const std::string &fileName)
Load library.
static Gui & getInstance()
EventHandle_FrameEventDelegate eventFrameStart
Definition: MyGUI_Gui.h:150
static WidgetManager * getInstancePtr()
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
MYGUI_SINGLETON_DEFINITION(ClipboardManager)