44 if (!mChannels.contains(message.
mChannel))
50 if (this->testFilter(message))
56 bool MessageObserver::testFilter(
const Message &msg)
const
60 return (*mFilter)(msg);
67 mFilter = filter->clone();
81 MessageRepository::MessageRepository() :
82 mMessageHistoryMaxSize(3000)
92 mMessages.push_back(message);
93 this->limitQueueSize();
94 this->emitThroughFilter(message);
97 void MessageRepository::limitQueueSize()
99 if (mMessageHistoryMaxSize<0)
102 while (mMessages.size() > mMessageHistoryMaxSize)
103 mMessages.pop_front();
106 void MessageRepository::emitThroughFilter(
const Message& message)
108 for (
unsigned i=0; i<mObservers.size(); ++i)
110 mObservers[i]->sendMessage(message);
118 mObservers.push_back(observer);
122 for (QList<Message>::iterator i=mMessages.begin(); i!=mMessages.end(); ++i)
123 observer->sendMessage(*i);
129 if (!std::count(mObservers.begin(), mObservers.end(), observer))
131 mObservers.erase(std::find(mObservers.begin(), mObservers.end(), observer));
136 mMessageHistoryMaxSize = count;
137 this->limitQueueSize();
142 return mMessageHistoryMaxSize;
void sendMessage(const Message &message)
void uninstall(MessageObserverPtr observer)
static MessageRepositoryPtr create()
void setMessageQueueMaxSize(int count)
boost::shared_ptr< class MessageFilter > MessageFilterPtr
void setMessage(Message message)
void newChannel(QString channel)
void installFilter(MessageFilterPtr filter)
void install(MessageObserverPtr observer, bool resend)
boost::shared_ptr< class MessageObserver > MessageObserverPtr
int getMessageQueueMaxSize() const
boost::shared_ptr< class MessageRepository > MessageRepositoryPtr
void newMessage(Message message)