swift
vatsimsetup.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_CORE_DATA_VATSIMDATA_H
7 #define SWIFT_CORE_DATA_VATSIMDATA_H
8 
9 #include <QMetaType>
10 #include <QString>
11 
12 #include "core/swiftcoreexport.h"
13 #include "misc/datacache.h"
14 #include "misc/metaclass.h"
16 #include "misc/network/url.h"
17 #include "misc/network/user.h"
18 #include "misc/propertyindex.h"
19 #include "misc/timestampbased.h"
20 #include "misc/valueobject.h"
21 #include "misc/variant.h"
22 
24 
25 namespace swift::core::data
26 {
29  public swift::misc::CValueObject<CVatsimSetup>,
31  {
32  public:
35  {
36  IndexServerFiles = swift::misc::CPropertyIndexRef::GlobalIndexCVatsimSetup,
37  IndexDataFiles,
38  IndexMetarFiles,
39  IndexFsdServers,
40  IndexCVoiceServers
41  };
42 
44  CVatsimSetup();
45 
47  const swift::misc::network::CUrl &getDataFileUrl() const { return m_dataFileUrl; }
48 
50  void setDataFileUrl(const swift::misc::network::CUrl &url) { m_dataFileUrl = url; }
51 
53  const swift::misc::network::CUrl &getServerFileUrl() const { return m_serverFileUrl; }
54 
56  void setServerFileUrl(const swift::misc::network::CUrl &url) { m_serverFileUrl = url; }
57 
59  const swift::misc::network::CUrl &getMetarFileUrl() const { return m_metarFileUrl; }
60 
62  void setMetarFileUrl(const swift::misc::network::CUrl &url) { m_metarFileUrl = url; }
63 
65  bool setUrls(const swift::misc::network::CUrl &dataFileUrl, const swift::misc::network::CUrl &serverFileUrl,
66  const swift::misc::network::CUrl &metarFileUrl);
67 
69  const swift::misc::network::CServerList &getFsdServers() const { return m_fsdServers; }
70 
72  void setFsdServers(const swift::misc::network::CServerList &servers) { m_fsdServers = servers; }
73 
75  const swift::misc::network::CServerList &getVoiceServers() const { return m_voiceServers; }
76 
78  void setVoiceServers(const swift::misc::network::CServerList &servers) { m_voiceServers = servers; }
79 
81  bool setServers(const swift::misc::network::CServerList &fsdServers,
82  const swift::misc::network::CServerList &voiceServers);
83 
85  QString convertToQString(bool i18n = false) const;
86 
88  QString convertToQString(const QString &separator, bool i18n = false) const;
89 
91  QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const;
92 
94  void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant);
95 
96  private:
97  swift::misc::network::CUrl m_serverFileUrl;
98  swift::misc::network::CUrl m_dataFileUrl;
99  swift::misc::network::CUrl m_metarFileUrl;
100  swift::misc::network::CServerList m_fsdServers;
101  swift::misc::network::CServerList m_voiceServers;
102 
104  CVatsimSetup,
105  SWIFT_METAMEMBER(serverFileUrl),
106  SWIFT_METAMEMBER(dataFileUrl),
107  SWIFT_METAMEMBER(metarFileUrl),
108  SWIFT_METAMEMBER(fsdServers),
109  SWIFT_METAMEMBER(voiceServers),
110  SWIFT_METAMEMBER(timestampMSecsSinceEpoch));
111  };
112 
114  struct TVatsimSetup : public swift::misc::TDataTrait<CVatsimSetup>
115  {
117  static const char *key() { return "vatsimsetup"; }
118 
120  static constexpr bool isPinned() { return true; }
121 
123  static const QString &humanReadable()
124  {
125  static const QString name("VATSIM setup");
126  return name;
127  }
128  };
129 
131  struct TVatsimLastServer : public swift::misc::TDataTrait<swift::misc::network::CServer>
132  {
134  static const char *key() { return "vatsimserver"; }
135 
137  static constexpr bool isPinned() { return true; }
138 
140  static const QString &humanReadable()
141  {
142  static const QString name("Last VATSIM server");
143  return name;
144  }
145  };
146 } // namespace swift::core::data
147 
148 Q_DECLARE_METATYPE(swift::core::data::CVatsimSetup)
149 
150 #endif // SWIFT_CORE_DATA_VATSIMDATA_H
VATSIM data (servers, URLs) cached as last known good setup.
Definition: vatsimsetup.h:31
const swift::misc::network::CServerList & getVoiceServers() const
Voice servers.
Definition: vatsimsetup.h:75
const swift::misc::network::CUrl & getServerFileUrl() const
Server file URL.
Definition: vatsimsetup.h:53
void setServerFileUrl(const swift::misc::network::CUrl &url)
Set server file URL.
Definition: vatsimsetup.h:56
void setDataFileUrl(const swift::misc::network::CUrl &url)
Set VATSIM data file URL.
Definition: vatsimsetup.h:50
const swift::misc::network::CServerList & getFsdServers() const
FSD servers.
Definition: vatsimsetup.h:69
void setFsdServers(const swift::misc::network::CServerList &servers)
Set FSD servers.
Definition: vatsimsetup.h:72
ColumnIndex
Properties by index.
Definition: vatsimsetup.h:35
const swift::misc::network::CUrl & getMetarFileUrl() const
METAR file URL.
Definition: vatsimsetup.h:59
void setVoiceServers(const swift::misc::network::CServerList &servers)
Set voice servers.
Definition: vatsimsetup.h:78
const swift::misc::network::CUrl & getDataFileUrl() const
VATSIM data file URL.
Definition: vatsimsetup.h:47
void setMetarFileUrl(const swift::misc::network::CUrl &url)
METAR file URL.
Definition: vatsimsetup.h:62
Non-owning reference to a CPropertyIndex with a subset of its features.
Mix of the most commonly used mixin classes.
Definition: valueobject.h:114
Entity with timestamp.
Value object encapsulating a list of servers.
Definition: serverlist.h:23
Value object encapsulating information of a location, kind of simplified CValueObject compliant versi...
Definition: url.h:27
#define SWIFT_METAMEMBER(MEMBER,...)
Macro to define an element within a metaclass.
Definition: metaclass.h:73
#define SWIFT_METACLASS(CLASS,...)
Macro to define a nested metaclass that describes the attributes of its enclosing class.
Definition: metaclass.h:53
Core data traits (aka cached values) and classes.
Trait for last (most recently) used VATSIM server and user.
Definition: vatsimsetup.h:132
static const QString & humanReadable()
Optional human readable name.
Definition: vatsimsetup.h:140
static constexpr bool isPinned()
If true, then value will be synchronously loaded when CDataCache is constructed. Good for small,...
Definition: vatsimsetup.h:137
static const char * key()
If true, then value will be synchronously loaded when CDataCache is constructed. Good for small,...
Definition: vatsimsetup.h:134
Trait for global setup data.
Definition: vatsimsetup.h:115
static const char * key()
Key string of the value. Reimplemented in derived class.
Definition: vatsimsetup.h:117
static constexpr bool isPinned()
If true, then value will be synchronously loaded when CDataCache is constructed. Good for small,...
Definition: vatsimsetup.h:120
static const QString & humanReadable()
Optional human readable name.
Definition: vatsimsetup.h:123
Base class for traits to be used as template argument to swift::misc::CData.
Definition: datacache.h:459
#define SWIFT_CORE_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