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