Issue #15 Added CPassiveObserver and CPassiveMutator

These implement a many-to-many publish/subscribe pattern.
This commit is contained in:
Mat Sutcliffe
2019-02-26 01:51:39 +00:00
parent 073f1549a2
commit 333804a0e6
7 changed files with 213 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
/* Copyright (C) 2017
* swift Project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated,
* or distributed except according to the terms contained in the LICENSE file.
*/
//! \file
#include "blackmisc/sharedstate/passiveobserver.h"
namespace BlackMisc
{
namespace SharedState
{
void CPassiveObserver::setEventSubscription(const CVariant &param)
{
QMutexLocker lock(&m_eventSubscriptionMutex);
m_eventSubscription = param;
lock.unlock();
emit eventSubscriptionChanged(param);
}
CVariant CPassiveObserver::eventSubscription() const
{
QMutexLocker lock(&m_eventSubscriptionMutex);
return m_eventSubscription;
}
void CPassiveObserver::handleEvent(const CVariant& param) const
{
m_eventHandler(param);
}
}
}