3
@author Denis Koronchik
7
This file is part of MyGUI.
9
MyGUI is free software: you can redistribute it and/or modify
10
it under the terms of the GNU Lesser General Public License as published by
11
the Free Software Foundation, either version 3 of the License, or
12
(at your option) any later version.
14
MyGUI is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
GNU Lesser General Public License for more details.
19
You should have received a copy of the GNU Lesser General Public License
20
along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22
#include "MyGUI_Precompiled.h"
23
#include "MyGUI_DynLibManager.h"
24
#include "MyGUI_Gui.h"
25
#include "MyGUI_WidgetManager.h"
30
template <> DynLibManager* Singleton<DynLibManager>::msInstance = nullptr;
31
template <> const char* Singleton<DynLibManager>::mClassTypeName("DynLibManager");
33
DynLibManager::DynLibManager() :
38
void DynLibManager::initialise()
40
MYGUI_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
41
MYGUI_LOG(Info, "* Initialise: " << getClassTypeName());
43
Gui::getInstance().eventFrameStart += newDelegate(this, &DynLibManager::notifyEventFrameStart);
45
MYGUI_LOG(Info, getClassTypeName() << " successfully initialized");
49
void DynLibManager::shutdown()
51
MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised");
52
MYGUI_LOG(Info, "* Shutdown: " << getClassTypeName());
56
Gui::getInstance().eventFrameStart -= newDelegate(this, &DynLibManager::notifyEventFrameStart);
57
_unloadDelayDynLibs();
59
MYGUI_LOG(Info, getClassTypeName() << " successfully shutdown");
60
mIsInitialise = false;
63
DynLib* DynLibManager::load(const std::string& fileName)
65
StringDynLibMap::iterator it = mLibsMap.find(fileName);
67
if (it != mLibsMap.end())
72
DynLib* pLib = new DynLib(fileName);
79
mLibsMap[fileName] = pLib;
83
void DynLibManager::unload(DynLib* library)
85
StringDynLibMap::iterator it = mLibsMap.find(library->getName());
87
if (it != mLibsMap.end())
90
mDelayDynLib.push_back(library);
93
void DynLibManager::unloadAll()
95
// unload and delete resources
96
for (StringDynLibMap::iterator it = mLibsMap.begin(); it != mLibsMap.end(); ++it)
98
mDelayDynLib.push_back(it->second);
104
void DynLibManager::notifyEventFrameStart(float _time)
106
_unloadDelayDynLibs();
109
void DynLibManager::_unloadDelayDynLibs()
111
if (!mDelayDynLib.empty())
113
WidgetManager* manager = WidgetManager::getInstancePtr();
114
if (manager != nullptr)
115
manager->_deleteDelayWidgets();
117
for (VectorDynLib::iterator entry = mDelayDynLib.begin(); entry != mDelayDynLib.end(); ++entry)
122
mDelayDynLib.clear();
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)
7
#include "MyGUI_Precompiled.h"
8
#include "MyGUI_DynLibManager.h"
10
#include "MyGUI_WidgetManager.h"
15
template <> DynLibManager* Singleton<DynLibManager>::msInstance = nullptr;
16
template <> const char* Singleton<DynLibManager>::mClassTypeName = "DynLibManager";
18
DynLibManager::DynLibManager() :
23
void DynLibManager::initialise()
25
MYGUI_ASSERT(!mIsInitialise, getClassTypeName() << " initialised twice");
26
MYGUI_LOG(Info, "* Initialise: " << getClassTypeName());
28
Gui::getInstance().eventFrameStart += newDelegate(this, &DynLibManager::notifyEventFrameStart);
30
MYGUI_LOG(Info, getClassTypeName() << " successfully initialized");
34
void DynLibManager::shutdown()
36
MYGUI_ASSERT(mIsInitialise, getClassTypeName() << " is not initialised");
37
MYGUI_LOG(Info, "* Shutdown: " << getClassTypeName());
41
Gui::getInstance().eventFrameStart -= newDelegate(this, &DynLibManager::notifyEventFrameStart);
42
_unloadDelayDynLibs();
44
MYGUI_LOG(Info, getClassTypeName() << " successfully shutdown");
45
mIsInitialise = false;
48
DynLib* DynLibManager::load(const std::string& fileName)
50
StringDynLibMap::iterator it = mLibsMap.find(fileName);
52
if (it != mLibsMap.end())
57
DynLib* pLib = new DynLib(fileName);
64
mLibsMap[fileName] = pLib;
68
void DynLibManager::unload(DynLib* library)
70
StringDynLibMap::iterator it = mLibsMap.find(library->getName());
72
if (it != mLibsMap.end())
75
mDelayDynLib.push_back(library);
78
void DynLibManager::unloadAll()
80
// unload and delete resources
81
for (StringDynLibMap::iterator it = mLibsMap.begin(); it != mLibsMap.end(); ++it)
83
mDelayDynLib.push_back(it->second);
89
void DynLibManager::notifyEventFrameStart(float _time)
91
_unloadDelayDynLibs();
94
void DynLibManager::_unloadDelayDynLibs()
96
if (!mDelayDynLib.empty())
98
WidgetManager* manager = WidgetManager::getInstancePtr();
99
if (manager != nullptr)
100
manager->_deleteDelayWidgets();
102
for (VectorDynLib::iterator entry = mDelayDynLib.begin(); entry != mDelayDynLib.end(); ++entry)
107
mDelayDynLib.clear();