swift
Loading...
Searching...
No Matches
fgswiftbussettings.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_SIMULATION_SETTINGS_FGSWIFTBUSSETTINGS_H
7#define SWIFT_MISC_SIMULATION_SETTINGS_FGSWIFTBUSSETTINGS_H
8
9#include <QString>
10
11#include "misc/dbusserver.h"
12#include "misc/settingscache.h"
13#include "misc/valueobject.h"
14
15SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::simulation::Settings, CFGSwiftBusSettings)
16
17namespace swift::misc::simulation::settings
18{
20 class SWIFT_MISC_EXPORT CFGSwiftBusSettings final : public CValueObject<CFGSwiftBusSettings>
21 {
22 public:
25 {
26 IndexDBusServerAddress = CPropertyIndexRef::GlobalIndexCFGSwiftBusSettings,
27 };
28
31
34
37
39 QString convertToQString(bool i18n = false) const;
40
42 QString getDBusServerAddress() const { return m_dBusServerAddress; }
43
45 void setDBusServerAddress(const QString &dBusServer) { m_dBusServerAddress = dBusServer; }
46
47 private:
48 QString m_dBusServerAddress { "tcp:host=127.0.0.1,port=45003" };
49
51 CFGSwiftBusSettings,
52 SWIFT_METAMEMBER(dBusServerAddress));
53 };
54
58 struct TFGSwiftBusServer : public swift::misc::TSettingTrait<CFGSwiftBusSettings>
59 {
61 static const char *key() { return "fgswiftbus/settings"; }
62
64 static const QString &humanReadable()
65 {
66 static const QString name("FGSwiftBus");
67 return name;
68 }
69
71 static CFGSwiftBusSettings defaultValue() { return {}; }
72
74 static bool isValid(const CFGSwiftBusSettings &settings, QString &)
75 {
76 return swift::misc::CDBusServer::isSessionOrSystemAddress(settings.getDBusServerAddress()) ||
77 swift::misc::CDBusServer::isQtDBusAddress(settings.getDBusServerAddress());
78 }
79 };
80} // namespace swift::misc::simulation::settings
81
83
84#endif // SWIFT_MISC_SIMULATION_SETTINGS_FGSWIFTBUSSETTINGS_H
static bool isSessionOrSystemAddress(const QString &address)
True if address is session or system bus address.
static bool isQtDBusAddress(const QString &address)
True if a valid Qt DBus address, e.g. "unix:tmpdir=/tmp", "tcp:host=127.0.0.1,port=45000".
Non-owning reference to a CPropertyIndex with a subset of its features.
QString convertToQString(bool i18n=false) const
Cast as QString.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setDBusServerAddress(const QString &dBusServer)
Set DBus server.
#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
Base class for traits to be used as template argument to swift::misc::CSetting.
static CFGSwiftBusSettings defaultValue()
Return the value to use in case the supplied value does not satisfy the validator....
static const char * key()
Key string of the value. Reimplemented in derived class.
static bool isValid(const CFGSwiftBusSettings &settings, QString &)
Validator function. Return true if the argument is valid, false otherwise. Default implementation jus...
#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