Issue #15 Added IDataLink, an interface for registering observers and mutators,

and CDataLinkLocal, an implementation for sharing state within a single process
This commit is contained in:
Mat Sutcliffe
2019-02-26 01:51:46 +00:00
parent 741dd45f67
commit 7df7de7f07
4 changed files with 308 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
/* 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/datalink.h"
#include "blackmisc/promise.h"
#include "blackmisc/variant.h"
namespace BlackMisc
{
namespace SharedState
{
void CDataLinkConnectionWatcher::setStatus(bool status)
{
if (status != m_connected)
{
m_connected = status;
if (m_connected) { emit connected(); }
else { emit disconnected(); }
}
}
IDataLink::~IDataLink() = default;
IDataLink::IDataLink()
{
qRegisterMetaType<CPromise<CVariant>>();
}
QString IDataLink::getChannelName(const QObject *object)
{
const QMetaObject *meta = object->parent()->metaObject();
const char *info = meta->classInfo(meta->indexOfClassInfo("SharedStateChannel")).value();
const QString name = object->parent()->objectName();
return name.isEmpty() ? QString(info) : (info % QLatin1Char(':') % name);
}
}
}