1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

use a more compact method to add and remove listeners t o all channels

This commit is contained in:
Peter Tissen 2014-06-27 09:22:00 +02:00
parent 1ad4380fab
commit ae472e9e67
3 changed files with 18 additions and 16 deletions

View File

@ -210,6 +210,20 @@ void LogManager::log(LogMessage msg)
#endif
}
void LogManager::addListener(std::shared_ptr<LogListener> listener)
{
for (auto& channel : mChannels)
{
channel.addListener(listener);
}
}
void LogManager::removeListener(std::shared_ptr<LogListener> listener)
{
for (auto& channel : mChannels)
{
channel.removeListener(listener);
}
}
LogManager& LogManager::getInstance()
{

View File

@ -113,6 +113,8 @@ namespace Log
static LogManager& getInstance();
LogChannel& getChannel(LogType type);
void log(LogMessage msg);
void addListener(std::shared_ptr<LogListener> listener);
void removeListener(std::shared_ptr<LogListener> listener);
#ifdef BUFFERED_LOGGING
void consumeLog();
#endif

View File

@ -139,14 +139,7 @@ LogFrame::LogFrame(wxWindow* parent)
m_tabs.AddPage(m_log, "Log");
m_tabs.AddPage(m_tty, "TTY");
Log::LogManager::getInstance().getChannel(Log::GENERAL).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::LOADER).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::MEMORY).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::RSX).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::HLE).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::PPU).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::SPU).addListener(listener);
Log::LogManager::getInstance().getChannel(Log::TTY).addListener(listener);
Log::LogManager::getInstance().addListener(listener);
wxBoxSizer* s_main = new wxBoxSizer(wxVERTICAL);
s_main->Add(&m_tabs, 1, wxEXPAND);
@ -158,14 +151,7 @@ LogFrame::LogFrame(wxWindow* parent)
LogFrame::~LogFrame()
{
Log::LogManager::getInstance().getChannel(Log::GENERAL).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::LOADER).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::MEMORY).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::RSX).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::HLE).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::PPU).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::SPU).removeListener(listener);
Log::LogManager::getInstance().getChannel(Log::TTY).removeListener(listener);
Log::LogManager::getInstance().removeListener(listener);
}
bool LogFrame::Close(bool force)