Enzo
Loading...
Searching...
No Matches
Attribute.h
1#pragma once
2#include "Engine/Types.h"
3#include <memory>
4#include <optional>
5#include <string>
6#include <string_view>
7#include <vector>
8
9namespace enzo {
10namespace ga {
11template <typename T> using StoreContainer = std::vector<T>;
12
13template <typename T> class AttributeHandle;
14
34class Attribute {
35 public:
44 Attribute(std::string name, ga::AttributeType type, bool intrinsic = false);
45 Attribute(const Attribute &other);
49 AttributeType getType() const;
53 std::string getName() const;
54
55 bt::Vector3 getVector3(Offset offset) const;
56 bt::Matrix4 getMatrix4(Offset offset) const;
57 size_t getSize() const;
61 unsigned int getTypeSize() const;
62
69 bool isIntrinsic() const;
70
74 void resize(size_t size);
75
76 template <typename T> friend class AttributeHandle;
77 template <typename T> friend class AttributeHandleRO;
78
79 private:
80 // private attributes are attributes that are hidden from the user
81 // for internal use
82 // bool private_=false;
83 // hidden attributes are user accessible attributes that the user may
84 // or may want to use
85 // bool hidden_=false;
86 // allows the user to read the attribute but not modify it
87 // bool readOnly_=false;
88 bool intrinsic_ = false;
89
91 unsigned int typeSize_ = 1;
92
93 std::string name_;
94
95 // void* data_;
96
97 // data stores
98 std::shared_ptr<StoreContainer<bt::intT>> intStore_;
99 std::shared_ptr<StoreContainer<bt::floatT>> floatStore_;
100 std::shared_ptr<StoreContainer<enzo::bt::Vector3>> vector3Store_;
101 std::shared_ptr<StoreContainer<enzo::bt::boolT>> boolStore_;
102 std::shared_ptr<StoreContainer<enzo::bt::Matrix4>> matrix4Store_;
103};
104
105using attribVector = std::vector<std::shared_ptr<ga::Attribute>>;
106} // namespace ga
107} // namespace enzo
Basic attribute, parameter, and node types for Enzo.
AttributeType
Data types available to store attribute values in.
Definition Types.h:25
Read only accessor for enzo::ga::Attribute.
Definition AttributeHandle.h:226
Read write accessor for enzo::ga::Attribute.
bool isIntrinsic() const
Returns whether the attribute is intrinsic.
Definition Attribute.cpp:76
Attribute(std::string name, ga::AttributeType type, bool intrinsic=false)
Construct a new attribute and initialize its typed storage.
Definition Attribute.cpp:10
std::string getName() const
Returns the name of this attribute.
Definition Attribute.cpp:145
AttributeType getType() const
Returns the attribute type this attribute stores.
Definition Attribute.cpp:140
unsigned int getTypeSize() const
Returns the number of components in the type (eg. StringT is 1, vectorT is 3).
void resize(size_t size)
Changes the number of elements stored.
Definition Attribute.cpp:49