23 QMutexLocker locker(&mMutex);
24 if (!mChannels.contains(message.
mChannel))
32 if (this->testFilter(message))
40 bool MessageObserver::testFilter(
const Message &msg)
const 44 return (*mFilter)(msg);
49 QMutexLocker locker(&mMutex);
52 mFilter = filter->clone();
66 MessageRepository::MessageRepository() :
67 mMessageHistoryMaxSize(3000)
77 mMessages.push_back(message);
78 this->limitQueueSize();
79 this->emitThroughFilter(message);
82 void MessageRepository::limitQueueSize()
84 if (mMessageHistoryMaxSize<0)
87 while (mMessages.size() > mMessageHistoryMaxSize)
88 mMessages.pop_front();
91 void MessageRepository::emitThroughFilter(
const Message& message)
93 for (
unsigned i=0; i<mObservers.size(); ++i)
95 mObservers[i]->sendMessage(message);
101 if(!this->exists(observer))
102 mObservers.push_back(observer);
106 for (
unsigned i = 0; i < mMessages.size(); ++i)
107 observer->sendMessage(mMessages[i]);
114 if (std::count(mObservers.begin(), mObservers.end(), observer))
121 if (!this->exists(observer))
123 mObservers.erase(std::find(mObservers.begin(), mObservers.end(), observer));
128 mMessageHistoryMaxSize = count;
129 this->limitQueueSize();
134 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
Namespace for all CustusX production code.
void newMessage(Message message)