1 #pragma once
2 
3 namespace hex::dp {
4 
5     class Node;
6 
7     class Attribute {
8     public:
9         enum class Type {
10             Integer,
11             Float,
12             Buffer
13         };
14 
15         enum class IOType {
16             In, Out
17         };
18 
Attribute(IOType ioType,Type type,std::string_view unlocalizedName)19         Attribute(IOType ioType, Type type, std::string_view unlocalizedName) : m_id(SharedData::dataProcessorNodeIdCounter++), m_ioType(ioType), m_type(type), m_unlocalizedName(unlocalizedName) {
20 
21         }
22 
~Attribute()23         ~Attribute() {
24             for (auto &[linkId, attr] : this->getConnectedAttributes())
25                 attr->removeConnectedAttribute(linkId);
26         }
27 
getID() const28         [[nodiscard]] u32 getID() const { return this->m_id; }
getIOType() const29         [[nodiscard]] IOType getIOType() const { return this->m_ioType; }
getType() const30         [[nodiscard]] Type getType() const { return this->m_type; }
getUnlocalizedName() const31         [[nodiscard]] std::string_view getUnlocalizedName() const { return this->m_unlocalizedName; }
32 
addConnectedAttribute(u32 linkId,Attribute * to)33         void addConnectedAttribute(u32 linkId, Attribute *to) { this->m_connectedAttributes.insert({ linkId, to }); }
removeConnectedAttribute(u32 linkId)34         void removeConnectedAttribute(u32 linkId) { this->m_connectedAttributes.erase(linkId); }
getConnectedAttributes()35         [[nodiscard]] std::map<u32, Attribute*>& getConnectedAttributes() { return this->m_connectedAttributes; }
36 
getParentNode()37         [[nodiscard]] Node* getParentNode() { return this->m_parentNode; }
38 
getOutputData()39         [[nodiscard]] std::optional<std::vector<u8>>& getOutputData() { return this->m_outputData; }
40     private:
41         u32 m_id;
42         IOType m_ioType;
43         Type m_type;
44         std::string m_unlocalizedName;
45         std::map<u32, Attribute*> m_connectedAttributes;
46         Node *m_parentNode;
47 
48         std::optional<std::vector<u8>> m_outputData;
49 
50         friend class Node;
setParentNode(Node * node)51         void setParentNode(Node *node) { this->m_parentNode = node; }
52     };
53 
54 }