File: NodeData.hpp

package info (click to toggle)
qnodeeditor 2.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 2,144 kB
  • sloc: cpp: 8,823; makefile: 3
file content (57 lines) | stat: -rw-r--r-- 1,499 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include "Export.hpp"

#include <QtCore/QString>
#include <QtCore/QStringList>
#include <memory>
namespace QtNodes
{
    using NodeDataTypeId = QString;
    class NodeDataType
    {
      public:
        NodeDataType() = default;
        virtual ~NodeDataType() = default;
        NodeDataType(const QString &id, const QString &name) : _id(id), _name(name)
        {
        }
        virtual bool operator==(const NodeDataType &other) const
        {
            return id() == other.id();
        }
        virtual bool operator!=(const NodeDataType &other) const
        {
            return !(*this == other);
        }
        virtual bool operator<(const NodeDataType &other) const
        {
            return id() < other.id();
        }
        NodeDataTypeId id() const
        {
            return _id;
        }
        QString name() const
        {
            return _name;
        }

      private:
        NodeDataTypeId _id;
        QString _name;
    };
    /// Class represents data transferred between nodes.
    /// @param type is used for comparing the types
    /// The actual data is stored in subtypes
    class NODE_EDITOR_PUBLIC NodeData
    {
      public:
        virtual ~NodeData() = default;
        virtual bool sameType(NodeData const &nodeData) const
        {
            return (this->type() == nodeData.type());
        }
        /// Type for inner use
        virtual std::shared_ptr<NodeDataType> type() const = 0;
    };
} // namespace QtNodes