swift
scalarmutator.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_SHAREDSTATE_SCALARMUTATOR_H
7 #define SWIFT_MISC_SHAREDSTATE_SCALARMUTATOR_H
8 
9 #include <QMutex>
10 #include <QObject>
11 
13 #include "misc/swiftmiscexport.h"
14 #include "misc/variant.h"
15 
17 {
18  class IDataLink;
19 
25  {
26  Q_OBJECT
27 
28  public:
30  void initialize(IDataLink *);
31 
32  protected:
34  CGenericScalarMutator(QObject *parent) : QObject(parent) {}
35 
37  void setValue(const CVariant &value);
38 
39  private:
40  QSharedPointer<CPassiveMutator> m_mutator = CPassiveMutator::create(this);
41  };
42 
48  template <typename T>
50  {
51  protected:
53  CScalarMutator(QObject *parent) : CGenericScalarMutator(parent) {}
54 
55  public:
57  void setValue(const T &value) { CGenericScalarMutator::setValue(CVariant::from(value)); }
58  };
59 } // namespace swift::misc::shared_state
60 
61 #endif // SWIFT_MISC_SHAREDSTATE_SCALARMUTATOR_H
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
Definition: variant.h:66
static CVariant from(T &&value)
Synonym for fromValue().
Definition: variant.h:147
Non-template base class for CScalarMutator.
Definition: scalarmutator.h:25
CGenericScalarMutator(QObject *parent)
Constructor.
Definition: scalarmutator.h:34
void setValue(const CVariant &value)
Set scalar value as variant.
static auto create(QObject *parent)
Factory method.
Base class for an object that shares state with a corresponding CScalarObserver subclass object.
Definition: scalarmutator.h:50
CScalarMutator(QObject *parent)
Constructor.
Definition: scalarmutator.h:53
void setValue(const T &value)
Set scalar value.
Definition: scalarmutator.h:57
Utilities for sharing state between multiple objects.
Definition: application.h:48
#define SWIFT_MISC_EXPORT
Export a class or function from the library.