WARNING: USE THIS SOFTWARE AT YOUR OWN RISK! THIS IS EXPERIMENTAL SOFTWARE NOT INTENDED FOR PRODUCTION USE! Zuble is currently an early stage prototype. As such Zuble is minimally tested and inherently unstable. It is provided for experimental, development, and demonstration purposes only. Zuble QML Types   |  Zuble C++ Classes   |  Zuble Overview
Zuble  0.1
Zuble Framework C++/QML extension API
ZAndGate.h
Go to the documentation of this file.
1 #ifndef ZANDGATE_H
2 #define ZANDGATE_H
3 
4 #include <QObject>
5 #include <QMap>
6 
7 namespace Zbl {
8 
50 class ZAndGate : public QObject
51 {
52  Q_OBJECT
53 public:
54 
58  typedef QPair<QString,bool> proxy;
59 
67  typedef QMultiMap<QObject*, proxy> propMap;
68 
73  typedef QMutableMapIterator<QObject*, proxy> propIterator;
74 
75  //typedef QMultiMap<QObject*, QString > propMap;
76 
77  explicit ZAndGate(QObject *parent = nullptr);
78 
82  static void registerType();
83 
84 
89  Q_PROPERTY(bool output READ getValue NOTIFY outputChanged)
90 
91 
92  bool getValue();
93 
106  Q_INVOKABLE bool addInputProperty(QObject* targetObject,
107  const QString& propertyName,
108  const QString &signalName = QString());
109 
113  Q_INVOKABLE bool removeInputProperty(QObject* targetObject, const QString& propertyName);
114 
118  Q_INVOKABLE void removeAllProperties();
119 
120 
121 signals:
122 
123  void outputChanged();
124 
125 public slots:
126 
127  void onPropChanged();
128 
129 protected:
130 
131  void evaluate();
132  QVariant waitGetProperty(QObject *targetObj, const QString& name);
133 
139  propMap m_props;
140 
146  bool m_value;
147 
148 };
149 
150 
151 } // Zbl
152 
153 #endif // ZANDGATE_H
propMap m_props
A map of object property proxies, by object pointer. Each proxy identifies one property. Multiple proxies may exist per input object.
Definition: ZAndGate.h:139
A software AND gate that monitors an arbitrary number of input properties from multiple objects and p...
Definition: ZAndGate.h:50
QMutableMapIterator< QObject *, proxy > propIterator
iterator for object/propertyName/value triplet maps
Definition: ZAndGate.h:73
static void registerType()
Registers ZAndGate as a QML type.
Definition: ZAndGate.cpp:14
void evaluate()
Definition: ZAndGate.cpp:196
Q_INVOKABLE void removeAllProperties()
Removes all properties from the watched properties list.
Definition: ZAndGate.cpp:91
Q_INVOKABLE bool removeInputProperty(QObject *targetObject, const QString &propertyName)
Removes a property from the watched properties list.
Definition: ZAndGate.cpp:85
bool m_value
Current output value of the AND gate. True if all input properties are true, false otherwise...
Definition: ZAndGate.h:146
void outputChanged()
bool output
Output value of "anded" input property values.
Definition: ZAndGate.h:89
Definition: ZAndGate.cpp:6
bool getValue()
Definition: ZAndGate.cpp:22
ZAndGate(QObject *parent=nullptr)
Definition: ZAndGate.cpp:8
QPair< QString, bool > proxy
propertyName/value
Definition: ZAndGate.h:58
void onPropChanged()
Definition: ZAndGate.cpp:103
QMultiMap< QObject *, proxy > propMap
A map of object/propertyName/value triplets.
Definition: ZAndGate.h:67
QVariant waitGetProperty(QObject *targetObj, const QString &name)
Definition: ZAndGate.cpp:174
Q_INVOKABLE bool addInputProperty(QObject *targetObject, const QString &propertyName, const QString &signalName=QString())
Adds a property to the watched properties list.
Definition: ZAndGate.cpp:27