mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
Ref T89, provider for ecosystem info
Also Ref T259, Ref T243
This commit is contained in:
87
src/blackmisc/network/ecosystemprovider.h
Normal file
87
src/blackmisc/network/ecosystemprovider.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* Copyright (C) 2018
|
||||
* 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 and at http://www.swift-project.org/license.html. 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
|
||||
|
||||
#ifndef BLACKMISC_NETWORK_ECOSYSTEMPROVIDER_H
|
||||
#define BLACKMISC_NETWORK_ECOSYSTEMPROVIDER_H
|
||||
|
||||
#include "ecosystem.h"
|
||||
#include "blackmisc/provider.h"
|
||||
#include <QReadWriteLock>
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
namespace Network
|
||||
{
|
||||
//! Direct threadsafe in memory access to current ecosystem
|
||||
class BLACKMISC_EXPORT IEcosystemProvider : public IProvider
|
||||
{
|
||||
public:
|
||||
//! Current ecosystem
|
||||
//! \remark CEcosystem::Unspecified if not connected with any network
|
||||
//! \threadsafe
|
||||
CEcosystem getCurrentEcosystem() const;
|
||||
|
||||
//! Last known ecosystem
|
||||
//! \threadsafe
|
||||
CEcosystem getLastEcosystem() const;
|
||||
|
||||
//! Current ecosystem?
|
||||
//! \threadsafe
|
||||
bool isCurrentEcosystem(const CEcosystem &system) const;
|
||||
|
||||
//! Last known ecosystem?
|
||||
//! \threadsafe
|
||||
bool isLastEcosystem(const CEcosystem &system) const;
|
||||
|
||||
protected:
|
||||
//! Set the current system
|
||||
//! \threadsafe
|
||||
bool setCurrentEcosystem(const CEcosystem &ecosystem);
|
||||
|
||||
//! Set the last known system
|
||||
//! \threadsafe
|
||||
bool setLastEcosystem(const CEcosystem &ecosystem);
|
||||
|
||||
private:
|
||||
CEcosystem m_currentEcoSystem;
|
||||
CEcosystem m_lastEcoSystem;
|
||||
mutable QReadWriteLock m_lockSystem; //!< lock
|
||||
};
|
||||
|
||||
//! Delegating class which can be directly used to access an \sa IEcosystemProvider instance
|
||||
class BLACKMISC_EXPORT CEcosystemAware : public IProviderAware<IEcosystemProvider>
|
||||
{
|
||||
public:
|
||||
//! Set the provider
|
||||
void setEcosystemProvider(IEcosystemProvider *provider) { this->setProvider(provider); }
|
||||
|
||||
//! \copydoc IEcosystemProvider::getCurrentEcosystem
|
||||
CEcosystem getCurrentEcosystem() const;
|
||||
|
||||
//! \copydoc IEcosystemProvider::getLastEcosystem
|
||||
CEcosystem getLastEcosystem() const;
|
||||
|
||||
//! \copydoc IEcosystemProvider::isCurrentEcosystem
|
||||
bool isCurrentEcosystem(const CEcosystem &system) const;
|
||||
|
||||
//! \copydoc IEcosystemProvider::isLastEcosystem
|
||||
bool isLastEcosystem(const CEcosystem &system) const;
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CEcosystemAware(IEcosystemProvider *EcosystemProvider) : IProviderAware(EcosystemProvider) { Q_ASSERT(EcosystemProvider); }
|
||||
};
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
Q_DECLARE_INTERFACE(BlackMisc::Network::IEcosystemProvider, "BlackMisc::Network::IEcosystemProvider")
|
||||
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user