mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
Issue #15 Added CPassiveObserver and CPassiveMutator
These implement a many-to-many publish/subscribe pattern.
This commit is contained in:
36
src/blackmisc/sharedstate/passiveobserver.cpp
Normal file
36
src/blackmisc/sharedstate/passiveobserver.cpp
Normal 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 ¶m)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user