2021-01-30 22:39:06 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace hex::dp {
|
|
|
|
|
|
|
|
class Node;
|
|
|
|
|
|
|
|
class Attribute {
|
|
|
|
public:
|
|
|
|
enum class Type {
|
|
|
|
Integer,
|
|
|
|
Float,
|
|
|
|
Buffer
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class IOType {
|
|
|
|
In, Out
|
|
|
|
};
|
|
|
|
|
2021-05-17 23:17:58 +02:00
|
|
|
Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorAttrIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) {
|
2021-01-30 22:39:06 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
~Attribute() {
|
|
|
|
for (auto &[linkId, attr] : this->getConnectedAttributes())
|
|
|
|
attr->removeConnectedAttribute(linkId);
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] u32 getID() const { return this->m_id; }
|
2021-05-17 23:17:58 +02:00
|
|
|
void setID(u32 id) { this->m_id = id; }
|
|
|
|
|
2021-01-30 22:39:06 +01:00
|
|
|
[[nodiscard]] IOType getIOType() const { return this->m_ioType; }
|
|
|
|
[[nodiscard]] Type getType() const { return this->m_type; }
|
2021-02-13 15:15:32 +01:00
|
|
|
[[nodiscard]] std::string_view getUnlocalizedName() const { return this->m_unlocalizedName; }
|
2021-01-30 22:39:06 +01:00
|
|
|
|
|
|
|
void addConnectedAttribute(u32 linkId, Attribute *to) { this->m_connectedAttributes.insert({ linkId, to }); }
|
2021-01-30 23:02:03 +01:00
|
|
|
void removeConnectedAttribute(u32 linkId) { this->m_connectedAttributes.erase(linkId); }
|
2021-01-30 22:39:06 +01:00
|
|
|
[[nodiscard]] std::map<u32, Attribute*>& getConnectedAttributes() { return this->m_connectedAttributes; }
|
|
|
|
|
|
|
|
[[nodiscard]] Node* getParentNode() { return this->m_parentNode; }
|
|
|
|
|
2021-02-04 01:14:05 +01:00
|
|
|
[[nodiscard]] std::optional<std::vector<u8>>& getOutputData() { return this->m_outputData; }
|
2021-01-30 22:39:06 +01:00
|
|
|
private:
|
|
|
|
u32 m_id;
|
|
|
|
IOType m_ioType;
|
|
|
|
Type m_type;
|
2021-02-13 15:15:32 +01:00
|
|
|
std::string m_unlocalizedName;
|
2021-01-30 22:39:06 +01:00
|
|
|
std::map<u32, Attribute*> m_connectedAttributes;
|
|
|
|
Node *m_parentNode;
|
|
|
|
|
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; }
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|