Files
pilotclient/src/blackmisc/sharedstate/datalink.cpp
Mat Sutcliffe 7df7de7f07 Issue #15 Added IDataLink, an interface for registering observers and mutators,
and CDataLinkLocal, an implementation for sharing state within a single process
2020-08-01 13:18:56 +01:00

45 lines
1.4 KiB
C++

/* 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);
}
}
}