Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/logger.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Logger::Logger()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Logger *Logger::instance()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	static Logger _instance;
Toshihiro Shimizu 890ddd
	return &_instance;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
void Logger::add(std::wstring s)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rows.push_back(s);
Toshihiro Shimizu 890ddd
	for (int i = 0; i < (int)m_listeners.size(); i++)
Toshihiro Shimizu 890ddd
		m_listeners[i]->onAdd();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Logger::clear()
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_rows.clear();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
int Logger::getRowCount() const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	return m_rows.size();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 3bfa54
std::wstring Logger::getRow(int i) const
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (0 <= i && i < (int)m_rows.size())
Toshihiro Shimizu 890ddd
		return m_rows[i];
Toshihiro Shimizu 890ddd
	else
Toshihiro Shimizu 890ddd
		return L"";
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Logger::addListener(Listener *listener)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	if (std::find(m_listeners.begin(), m_listeners.end(), listener) == m_listeners.end())
Toshihiro Shimizu 890ddd
		m_listeners.push_back(listener);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void Logger::removeListener(Listener *listener)
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	m_listeners.erase(
Toshihiro Shimizu 890ddd
		std::remove(m_listeners.begin(), m_listeners.end(), listener),
Toshihiro Shimizu 890ddd
		m_listeners.end());
Toshihiro Shimizu 890ddd
}