Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/GraphicalAPI/GraphicalAPI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ namespace Polymorph

static void reloadAPI(std::string newHandler);
static void *getHandler();
static std::string getHandlerPath() const;

private:
static void _unloadModules();
Expand Down
13 changes: 13 additions & 0 deletions src/GraphicalAPI/GraphicalAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
Polymorph::GraphicalAPI::GraphicalAPI(std::string handlerPath)
{
_handlerPath = handlerPath;
if (_instance != nullptr)
throw GraphicalException("Cannot create several Graphical API instance at once.", Logger::MAJOR);
_instance = this;
}

Expand Down Expand Up @@ -87,10 +89,21 @@ void Polymorph::GraphicalAPI::reloadAPI(std::string newHandler)
_instance->_d_display = loadSymbol<DisplayUnloader, GraphicalAPI>("deleteDisplay");
_instance->_d_sprite = loadSymbol<SpriteUnloader, GraphicalAPI>("destroySprite");
_instance->_d_text = loadSymbol<TextUnloader, GraphicalAPI>("destroyText");
_instance->_handlerPath = newHandler;

_reloadModules();
}

std::string Polymorph::GraphicalAPI::getHandlerPath()
{
if (!_instance)
{
Logger::log("No Graphic API handler available to reload.", Logger::MAJOR);
return "";
}
return _instance->_handlerPath;
}

Polymorph::Text
Polymorph::GraphicalAPI::createText(std::shared_ptr<myxmlpp::Node> &data)
{
Expand Down