swift
swiftpluginsettings.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_SWIFTPLUGINSETTINGS_H
7 #define SWIFT_MISC_SIMULATION_SETTINGS_SWIFTPLUGINSETTINGS_H
8 
10 #include "misc/settingscache.h"
13 #include "misc/swiftmiscexport.h"
14 
15 SWIFT_DECLARE_VALUEOBJECT_MIXINS(swift::misc::simulation::Settings, CSwiftPluginSettings)
16 
17 namespace swift::misc::simulation::settings
18 {
21  {
22  public:
25  {
26  IndexEmulatedSimulator = CPropertyIndexRef::GlobalIndexCSwiftPluignSettings,
27  IndexOwnModel,
28  IndexDefaultModel,
29  IndexLoggingFunctionCalls
30  };
31 
34 
36  CSimulatorInfo getEmulatedSimulator() const { return m_emulatedSimulator; }
37 
39  void setEmulatedSimulator(const CSimulatorInfo &simulator);
40 
42  const CAircraftModel &getOwnModel() const { return m_ownModel; }
43 
45  void setOwnModel(const CAircraftModel &ownModel) { m_ownModel = ownModel; }
46 
48  const CAircraftModel &getDefaultModel() const { return m_defaultModel; }
49 
51  void setDefaultModel(const CAircraftModel &defaultModel) { m_defaultModel = defaultModel; }
52 
54  bool isLoggingFunctionCalls() const { return m_logFunctionCalls; }
55 
57  void setLoggingFunctionCalls(bool log) { m_logFunctionCalls = log; }
58 
60  QString convertToQString(bool i18n = false) const;
61 
63  QVariant propertyByIndex(CPropertyIndexRef index) const;
64 
66  void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant);
67 
68  private:
69  CSimulatorInfo m_emulatedSimulator { CSimulatorInfo::P3D }; // simulator with default value
70  CAircraftModel m_ownModel;
71  CAircraftModel m_defaultModel;
72  bool m_logFunctionCalls = true;
73 
75  CSwiftPluginSettings,
76  SWIFT_METAMEMBER(emulatedSimulator),
77  SWIFT_METAMEMBER(ownModel),
78  SWIFT_METAMEMBER(defaultModel),
79  SWIFT_METAMEMBER(logFunctionCalls));
80  };
81 
83  struct TSwiftPlugin : public swift::misc::TSettingTrait<CSwiftPluginSettings>
84  {
86  static const char *key() { return "settingsswiftplugin"; }
87 
89  static const QString &humanReadable()
90  {
91  static const QString name("swift plugin");
92  return name;
93  }
94 
96  static bool isValid(const CSwiftPluginSettings &value, QString &)
97  {
98  return value.getEmulatedSimulator().isSingleSimulator();
99  }
100  };
101 } // namespace swift::misc::simulation::settings
102 
105 
106 #endif // SWIFT_MISC_SIMULATION_SETTINGS_SWIFTPLUGINSETTINGS_H
Generic ordered container with value semantics.
Definition: collection.h:107
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
Aircraft model (used by another pilot, my models on disk)
Definition: aircraftmodel.h:71
Simple hardcoded info about the corresponding simulator.
Definition: simulatorinfo.h:41
bool isSingleSimulator() const
Single simulator selected.
const CAircraftModel & getOwnModel() const
Get own model.
void setOwnModel(const CAircraftModel &ownModel)
Set own model.
CSimulatorInfo getEmulatedSimulator() const
Emulated simualtor.
const CAircraftModel & getDefaultModel() const
Get default model.
void setDefaultModel(const CAircraftModel &defaultModel)
Set default model.
#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
Base class for traits to be used as template argument to swift::misc::CSetting.
static bool isValid(const CSwiftPluginSettings &value, QString &)
Validator function. Return true if the argument is valid, false otherwise. Default implementation jus...
static const char * key()
Key string of the value. Reimplemented in derived class.
static const QString & humanReadable()
Optional human readable name.
#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