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
71
74 Q_PROPERTY(
76
79 Q_PROPERTY(QVariant value READ getValue WRITE setValue NOTIFY
84 Q_PROPERTY(QString text READ getValueAsString WRITE setValueAsString
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
109 void setConnection(PdConnection const &);
110 void updateConnection();
112 Q_INVOKABLE void inc();
114 signals:
115 void valueChanged();
117 void valueUpdated(std::chrono::nanoseconds mtime);
123 void pathChanged(QString);
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
PdVariable(QObject *=Q_NULLPTR)
Constructor.
Definition PdVariable.cpp:501
Definition PdConnection.h:38
Definition PdVariable.cpp:262
QString getValueAsString() const
Definition PdVariable.cpp:690
void valueChanged()
Emitted, when the value changes, or the variable is disconnected.
void clearData()
Definition PdVariable.cpp:620
QVariant mtime
Last modification time of the process variable.
Definition PdVariable.h:85
bool hasVariable() const
Connected state.
Definition PdVariable.cpp:612
QtPdCom::PdConnection connection
Connection property which describes the variable to connect to.
Definition PdVariable.h:69
void clearVariable()
Unsubscribe from a Variable.
Definition PdVariable.cpp:597
void pathChanged(QString)
void updateConnection()
(re)connects to variable
Definition PdVariable.cpp:519
std::chrono::nanoseconds getMTime() const
Definition PdVariable.cpp:752
PdVariable(QObject *=Q_NULLPTR)
Constructor.
Definition PdVariable.cpp:501
void dataPresentChanged(bool)
Q_INVOKABLE void inc()
Increments the current value and writes it to the process.
Definition PdVariable.cpp:680
void setConnection(PdConnection const &)
Definition PdVariable.cpp:587
QVariant value
Process value.
Definition PdVariable.h:77
QVariant getValue() const
Definition PdVariable.cpp:635
bool getDataPresent()
Definition PdVariable.cpp:766
std::unique_ptr< Impl > impl
Definition PdVariable.h:125
Q_INVOKABLE void setValueAsString(QString)
Definition PdVariable.cpp:713
Q_INVOKABLE void setValue(QVariant)
Definition PdVariable.cpp:645
PdConnection getConnection()
Definition PdVariable.cpp:580
QString text
Interpret the elements of an process variable array as string.
Definition PdVariable.h:81
bool connected
Indicates that the process is connected and data is transfered.
Definition PdVariable.h:73
void valueUpdated(std::chrono::nanoseconds mtime)
Emitted also when value does not change but got an update from the msr process.
double getMTimeToDouble() const
Definition PdVariable.cpp:759
Definition BroadcastModel.h:32