swift
ecosystemprovider.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_MISC_NETWORK_ECOSYSTEMPROVIDER_H
7 #define SWIFT_MISC_NETWORK_ECOSYSTEMPROVIDER_H
8 
9 #include <QReadWriteLock>
10 
11 #include "misc/network/ecosystem.h"
12 #include "misc/provider.h"
13 
14 namespace swift::misc::network
15 {
18  {
19  public:
23  CEcosystem getCurrentEcosystem() const;
24 
27  CEcosystem getLastEcosystem() const;
28 
31  bool isCurrentEcosystem(const CEcosystem &system) const;
32 
35  bool isCurrentEcosystemVATSIM() const;
36 
39  bool isLastEcosystem(const CEcosystem &system) const;
40 
41  protected:
44  bool setCurrentEcosystem(const CEcosystem &ecosystem);
45 
48  bool setLastEcosystem(const CEcosystem &ecosystem);
49 
50  private:
51  CEcosystem m_currentEcoSystem;
52  CEcosystem m_lastEcoSystem;
53  mutable QReadWriteLock m_lockSystem;
54  };
55 
57  class SWIFT_MISC_EXPORT CEcosystemAware : public IProviderAware<IEcosystemProvider>
58  {
59  virtual void anchor();
60 
61  public:
63  void setEcosystemProvider(IEcosystemProvider *provider) { this->setProvider(provider); }
64 
66  CEcosystem getCurrentEcosystem() const;
67 
69  CEcosystem getLastEcosystem() const;
70 
72  bool isCurrentEcosystem(const CEcosystem &system) const;
73 
75  bool isCurrentEcosystemVATSIM() const;
76 
79  bool isNotVATSIMEcosystem() const;
80 
82  bool isLastEcosystem(const CEcosystem &system) const;
83 
85  static IEcosystemProvider *providerIfPossible(QObject *object);
86 
87  protected:
89  CEcosystemAware(IEcosystemProvider *EcosystemProvider) : IProviderAware(EcosystemProvider)
90  {
91  Q_ASSERT(EcosystemProvider);
92  }
93  };
94 } // namespace swift::misc::network
95 
96 Q_DECLARE_INTERFACE(swift::misc::network::IEcosystemProvider, "org.swift-project.misc::network::iecosystemprovider")
97 
98 #endif // SWIFT_MISC_NETWORK_ECOSYSTEMPROVIDER_H
Base class of provider aware classes.
Definition: provider.h:41
Base class for providers.
Definition: provider.h:19
Delegating class which can be directly used to access an.
void setEcosystemProvider(IEcosystemProvider *provider)
Set the provider.
CEcosystemAware(IEcosystemProvider *EcosystemProvider)
Constructor.
Ecosystem of server belonging together.
Definition: ecosystem.h:21
Direct threadsafe in memory access to current ecosystem.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.