~jibel/autopilot-qt/make-qtabstractitemview_introspection

« back to all changes in this revision

Viewing changes to driver/qtnode.h

  • Committer: Tarmac
  • Author(s): Thomi Richards
  • Date: 2013-09-16 19:29:53 UTC
  • mfrom: (70.1.15 experimental)
  • Revision ID: tarmac-20130916192953-gfi8t8ot60cvm4ea
1.4 wire protocol changes. Fixes: https://bugs.launchpad.net/bugs/1195141, https://bugs.launchpad.net/bugs/1214128.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef QTNODE_H
2
2
#define QTNODE_H
3
3
 
 
4
#include <cstdint>
4
5
#include <QVariant>
 
6
#include <QDBusArgument>
5
7
#include <xpathselect/node.h>
6
8
 
 
9
/// A simple data structure representing the state of a single node:
 
10
struct NodeIntrospectionData
 
11
{
 
12
    QString object_path;
 
13
    QVariantMap state;
 
14
};
 
15
 
 
16
Q_DECLARE_METATYPE(NodeIntrospectionData);
 
17
Q_DECLARE_METATYPE(QList<NodeIntrospectionData>);
 
18
 
 
19
QDBusArgument &operator<<(QDBusArgument &argument, const NodeIntrospectionData &node_data);
 
20
const QDBusArgument &operator>>(const QDBusArgument &argument, NodeIntrospectionData &node_data);
 
21
 
7
22
/// Base class for all Qt-based object nodes.
8
23
///
9
24
/// QtNode wraps a single QObject pointer. It derives from xpathselect::Node and,
10
25
/// like that class, is designed to be allocated on the heap and stored in a
11
26
/// std::shared_ptr.
12
 
class QtNode: public xpathselect::Node
 
27
class QtNode: public xpathselect::Node, public std::enable_shared_from_this<QtNode>
13
28
{
14
29
public:
15
 
    typedef std::shared_ptr<QtNode> Ptr;
 
30
    typedef std::shared_ptr<const QtNode> Ptr;
16
31
 
17
 
    QtNode(QObject* object, std::string const& parent_path);
 
32
    QtNode(QObject* object, Ptr parent);
 
33
    explicit QtNode(QObject* object);
18
34
 
19
35
    QObject* getWrappedObject() const;
20
 
 
21
 
    virtual QVariant IntrospectNode() const;
22
 
    virtual qint64 GetObjectId() const;
 
36
    xpathselect::Node::Ptr GetParent() const;
 
37
 
 
38
    virtual NodeIntrospectionData GetIntrospectionData() const;
 
39
 
23
40
 
24
41
    virtual std::string GetName() const;
25
42
    virtual std::string GetPath() const;
26
 
    virtual bool MatchProperty(const std::string& name, const std::string& value) const;
27
 
    virtual xpathselect::NodeList Children() const;
 
43
    virtual int32_t GetId() const;
 
44
    virtual bool MatchStringProperty(const std::string& name, const std::string& value) const;
 
45
    virtual bool MatchIntegerProperty(const std::string& name, int32_t value) const;
 
46
    virtual bool MatchBooleanProperty(const std::string& name, bool value) const;
 
47
    virtual xpathselect::NodeVector Children() const;
28
48
private:
29
49
    QObject *object_;
30
50
    std::string full_path_;
 
51
    Ptr parent_;
31
52
};
32
53
 
33
54
#endif // QTNODE_H