QtPdCom  1.5.2
PdVariable.h
Go to the documentation of this file.
1/*****************************************************************************
2 *
3 * Copyright (C) 2018 Wilhelm Hagemeister <hm@igh.de>
4 * Florian Pose <fp@igh.de>
5 * 2024 Bjarne von Horn <vh@igh.de>
6 *
7 * This file is part of the QtPdCom library.
8 *
9 * The QtPdCom library is free software: you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License as
11 * published by the Free Software Foundation, either version 3 of the License,
12 * or (at your option) any later version.
13 *
14 * The QtPdCom library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with the QtPdCom Library. If not, see
21 * <http://www.gnu.org/licenses/>.
22 *
23 ****************************************************************************/
24
25#ifndef PD_PdVariable_H
26#define PD_PdVariable_H
27
28#include <QtPdCom1/Process.h>
29
30#include "PdConnection.h"
31
32#include <QObject>
33#include <QQmlEngine>
34#include <QVariant>
35
36#include <chrono>
37
38namespace QtPdCom {
39
40/****************************************************************************/
41
44class Q_DECL_EXPORT PdVariable: public QObject
45{
46 Q_OBJECT
47 QML_NAMED_ELEMENT(PdVariable)
48 QML_ADDED_IN_VERSION(1, 4)
49
50
69 Q_PROPERTY(QtPdCom::PdConnection connection READ getConnection WRITE
70 setConnection NOTIFY connectionChanged)
71
74 Q_PROPERTY(
75 bool connected READ getDataPresent NOTIFY dataPresentChanged)
76
79 Q_PROPERTY(QVariant value READ getValue WRITE setValue NOTIFY
80 valueChanged)
81
84 Q_PROPERTY(QString text READ getValueAsString WRITE setValueAsString
85 NOTIFY valueChanged)
86
89 Q_PROPERTY(QVariant mtime READ getMTimeToDouble NOTIFY valueUpdated)
90
91 public:
92 PdVariable(QObject * = Q_NULLPTR);
93 ~PdVariable();
94
95 void clearVariable();
96 bool hasVariable() const;
97 void clearData();
98
99 QVariant getValue() const;
100 Q_INVOKABLE void setValue(QVariant);
101 QString getValueAsString() const;
102 Q_INVOKABLE void setValueAsString(QString);
103 bool getDataPresent();
104
105 std::chrono::nanoseconds getMTime() const;
106 double getMTimeToDouble() const;
107
108 PdConnection getConnection();
109 void setConnection(PdConnection const &);
110 void updateConnection();
112 Q_INVOKABLE void inc();
113
114 signals:
115 void valueChanged();
117 void valueUpdated(std::chrono::nanoseconds mtime);
123 void pathChanged(QString);
124 void connectionChanged();
125 void dataPresentChanged(bool);
126
127 private:
128 class Q_DECL_HIDDEN Impl;
129 std::unique_ptr<Impl> impl;
130};
131
132/****************************************************************************/
133
134} // namespace QtPdCom
135
136#endif
Definition PdConnection.h:38
Definition PdVariable.cpp:262
Scalar/Vector/Matrix Variant to be used in QML applications.
Definition PdVariable.h:45
Definition BroadcastModel.h:32