#pragma once #include #include #include #include #include class IRCLogBufferModel; class IRCLogBuffer : public Retainable { public: static Retained create(); ~IRCLogBuffer(); struct Message { time_t timestamp { 0 }; char prefix { 0 }; String sender; String text; Color color { Color::Black }; }; int count() const { return m_messages.size(); } const Message& at(int index) const { return m_messages.at(index); } void add_message(char prefix, const String& name, const String& text, Color = Color::Black); void add_message(const String& text, Color = Color::Black); void dump() const; const IRCLogBufferModel* model() const { return m_model.ptr(); } IRCLogBufferModel* model() { return m_model.ptr(); } private: IRCLogBuffer(); Retained m_model; CircularQueue m_messages; };