2021-01-30 22:39:06 +01:00
|
|
|
#pragma once
|
2021-08-29 14:18:45 +02:00
|
|
|
#include <hex.hpp>
|
|
|
|
|
2021-08-31 20:03:08 +02:00
|
|
|
#include <optional>
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <string>
|
2021-08-29 14:18:45 +02:00
|
|
|
#include <string_view>
|
2021-09-08 15:18:24 +02:00
|
|
|
#include <map>
|
2021-08-29 22:15:18 +02:00
|
|
|
#include <vector>
|
2021-01-30 22:39:06 +01:00
|
|
|
|
|
|
|
namespace hex::dp {
|
|
|
|
|
|
|
|
class Node;
|
|
|
|
|
|
|
|
class Attribute {
|
|
|
|
public:
|
|
|
|
enum class Type {
|
|
|
|
Integer,
|
|
|
|
Float,
|
|
|
|
Buffer
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class IOType {
|
2022-01-24 20:53:17 +01:00
|
|
|
In,
|
|
|
|
Out
|
2021-01-30 22:39:06 +01:00
|
|
|
};
|
|
|
|
|
2021-09-08 15:18:24 +02:00
|
|
|
Attribute(IOType ioType, Type type, std::string unlocalizedName);
|
2021-08-29 14:18:45 +02:00
|
|
|
~Attribute();
|
2021-01-30 22:39:06 +01:00
|
|
|
|
2022-10-06 09:14:46 +02:00
|
|
|
[[nodiscard]] int getId() const { return this->m_id; }
|
|
|
|
void setId(int id) { this->m_id = id; }
|
2021-05-17 23:17:58 +02:00
|
|
|
|
2021-01-30 22:39:06 +01:00
|
|
|
[[nodiscard]] IOType getIOType() const { return this->m_ioType; }
|
|
|
|
[[nodiscard]] Type getType() const { return this->m_type; }
|
2022-01-24 20:53:17 +01:00
|
|
|
[[nodiscard]] const std::string &getUnlocalizedName() const { return this->m_unlocalizedName; }
|
2021-01-30 22:39:06 +01:00
|
|
|
|
2022-10-06 09:14:46 +02:00
|
|
|
void addConnectedAttribute(int linkId, Attribute *to) { this->m_connectedAttributes.insert({ linkId, to }); }
|
|
|
|
void removeConnectedAttribute(int linkId) { this->m_connectedAttributes.erase(linkId); }
|
|
|
|
[[nodiscard]] std::map<int, Attribute *> &getConnectedAttributes() { return this->m_connectedAttributes; }
|
2021-01-30 22:39:06 +01:00
|
|
|
|
2022-01-24 20:53:17 +01:00
|
|
|
[[nodiscard]] Node *getParentNode() { return this->m_parentNode; }
|
|
|
|
|
|
|
|
[[nodiscard]] std::optional<std::vector<u8>> &getOutputData() { return this->m_outputData; }
|
2021-01-30 22:39:06 +01:00
|
|
|
|
2022-10-06 09:14:46 +02:00
|
|
|
static void setIdCounter(int id) {
|
2022-02-01 18:09:40 +01:00
|
|
|
if (id > Attribute::s_idCounter)
|
|
|
|
Attribute::s_idCounter = id;
|
|
|
|
}
|
|
|
|
|
2021-01-30 22:39:06 +01:00
|
|
|
private:
|
2022-10-06 09:14:46 +02:00
|
|
|
int m_id;
|
2021-01-30 22:39:06 +01:00
|
|
|
IOType m_ioType;
|
|
|
|
Type m_type;
|
2021-02-13 15:15:32 +01:00
|
|
|
std::string m_unlocalizedName;
|
2022-10-06 09:14:46 +02:00
|
|
|
std::map<int, Attribute *> m_connectedAttributes;
|
2021-09-08 15:18:24 +02:00
|
|
|
Node *m_parentNode = nullptr;
|
2021-01-30 22:39:06 +01:00
|
|
|
|
2021-02-04 01:14:05 +01:00
|
|
|
std::optional<std::vector<u8>> m_outputData;
|
2021-01-30 22:39:06 +01:00
|
|
|
|
|
|
|
friend class Node;
|
|
|
|
void setParentNode(Node *node) { this->m_parentNode = node; }
|
2022-02-01 18:09:40 +01:00
|
|
|
|
2022-10-06 09:14:46 +02:00
|
|
|
static int s_idCounter;
|
2021-01-30 22:39:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|