swift
ecosystem.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2017 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_ECOSYSTEM_H
7 #define SWIFT_MISC_NETWORK_ECOSYSTEM_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
12 #include "misc/swiftmiscexport.h"
13 #include "misc/valueobject.h"
14 
15 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::network, CEcosystem)
16 
17 namespace swift::misc::network
18 {
20  class SWIFT_MISC_EXPORT CEcosystem : public CValueObject<CEcosystem>
21  {
22  public:
25  {
26  IndexSystem = CPropertyIndexRef::GlobalIndexCEcosystem,
27  IndexSystemString
28  };
29 
31  enum System
32  {
36  PrivateFSD
37  };
38 
40  CEcosystem() = default;
41 
43  CEcosystem(System s) : m_system(static_cast<int>(s)) {}
44 
46  System getSystem() const { return static_cast<System>(m_system); }
47 
49  bool isUnspecified() const { return this->getSystem() == Unspecified; }
50 
52  bool isSystem(System s) const { return this->getSystem() == s; }
53 
55  void setSystem(System system) { m_system = static_cast<int>(system); }
56 
58  const QString &getSystemString() const;
59 
61  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
62 
64  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
65 
67  int comparePropertyByIndex(CPropertyIndexRef index, const CEcosystem &compareValue) const;
68 
70  QString convertToQString(bool i18n = false) const;
71 
73  static const CEcosystem &unspecified();
74 
76  static const CEcosystem &vatsim();
77 
79  static const CEcosystem &privateFsd();
80 
81  private:
82  int m_system = static_cast<int>(Unspecified);
83 
85  CEcosystem,
86  SWIFT_METAMEMBER(system));
87  };
88 } // namespace swift::misc::network
89 
90 Q_DECLARE_METATYPE(swift::misc::network::CEcosystem)
92 
93 #endif // SWIFT_MISC_NETWORK_ECOSYSTEM_H
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
ColumnIndex
Base class enums.
Definition: mixinindex.h:44
Ecosystem of server belonging together.
Definition: ecosystem.h:21
CEcosystem()=default
Default constructor.
@ NoSystem
no relevant ecosystem
Definition: ecosystem.h:34
bool isUnspecified() const
Unknown system?
Definition: ecosystem.h:49
System getSystem() const
Get system.
Definition: ecosystem.h:46
bool isSystem(System s) const
Is system?
Definition: ecosystem.h:52
CEcosystem(System s)
Constructor.
Definition: ecosystem.h:43
void setSystem(System system)
Set the system.
Definition: ecosystem.h:55
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:72
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:52
#define SWIFT_MISC_EXPORT
Export a class or function from the library.
#define SWIFT_DECLARE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template declaration of mixins for a CValueObject subclass to be placed near the top of the ...
Definition: valueobject.h:65