swift
listmutator.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_LISTMUTATOR_H
7 #define SWIFT_MISC_SHAREDSTATE_LISTMUTATOR_H
8 
9 #include <QMutex>
10 #include <QObject>
11 
13 #include "misc/swiftmiscexport.h"
14 #include "misc/variantlist.h"
15 
17 {
18  class IDataLink;
19 
24  class SWIFT_MISC_EXPORT CGenericListMutator : public QObject
25  {
26  Q_OBJECT
27 
28  public:
30  void initialize(IDataLink *);
31 
32  protected:
34  CGenericListMutator(QObject *parent) : QObject(parent) {}
35 
37  void addElement(const CVariant &value);
38 
39  private:
40  QSharedPointer<CPassiveMutator> m_mutator = CPassiveMutator::create(this);
41  };
42 
48  template <typename T>
50  {
51  protected:
53  CListMutator(QObject *parent) : CGenericListMutator(parent) {}
54 
55  public:
57  void addElement(const typename T::value_type &value) { CGenericListMutator::addElement(CVariant::from(value)); }
58  };
59 } // namespace swift::misc::shared_state
60 
61 #endif // SWIFT_MISC_SHAREDSTATE_LISTMUTATOR_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 CListMutator.
Definition: listmutator.h:25
CGenericListMutator(QObject *parent)
Constructor.
Definition: listmutator.h:34
void addElement(const CVariant &value)
Add list element as variant.
Definition: listmutator.cpp:14
Base class for an object that shares state with a corresponding CListObserver subclass object.
Definition: listmutator.h:50
CListMutator(QObject *parent)
Constructor.
Definition: listmutator.h:53
void addElement(const typename T::value_type &value)
Add list element.
Definition: listmutator.h:57
static auto create(QObject *parent)
Factory method.
Utilities for sharing state between multiple objects.
Definition: application.h:48
#define SWIFT_MISC_EXPORT
Export a class or function from the library.