7#include "Engine/Operator/Attribute.h"
9#include "tbb/concurrent_vector.h"
45 ga::AttributeType type_;
55 type_ = attribute->getType();
61 if constexpr (std::is_same<bt::intT, T>::value)
63 data_=attribute->intStore_;
67 else if constexpr (std::is_same<bt::floatT, T>::value)
69 data_=attribute->floatStore_;
73 else if constexpr (std::is_same<enzo::bt::Vector3, T>::value)
75 data_=attribute->vector3Store_;
77 else if constexpr (std::is_same<enzo::bt::boolT, T>::value)
79 data_=attribute->boolStore_;
83 throw std::runtime_error(
"Type " + std::to_string(
static_cast<int>(type_)) +
" was not properly accounted for in AttributeHandle constructor");
96 data_->push_back(value);
110 data_->reserve(newCap);
124 return {data_->begin(), data_->end()};
132 return data_->size();
143 return (*data_)[offset];
153 (*data_)[offset] = value;
174 bool readOnly_=
false;
176 std::string name_=
"";
178 std::shared_ptr<StoreContainer<T>> data_;
184using AttributeHandleInt = AttributeHandle<bt::intT>;
185using AttributeHandleFloat = AttributeHandle<bt::floatT>;
186using AttributeHandleVector3 = AttributeHandle<enzo::bt::Vector3>;
187using AttributeHandleBool = AttributeHandle<enzo::bt::boolT>;
202 type_ = attribute->getType();
208 if constexpr (std::is_same<bt::intT, T>::value)
210 data_=attribute->intStore_;
214 else if constexpr (std::is_same<bt::floatT, T>::value)
216 data_=attribute->floatStore_;
220 else if constexpr (std::is_same<enzo::bt::Vector3, T>::value)
222 data_=attribute->vector3Store_;
224 else if constexpr (std::is_same<enzo::bt::boolT, T>::value)
226 data_=attribute->boolStore_;
230 throw std::runtime_error(
"Type " + std::to_string(
static_cast<int>(type_)) +
" was not properly accounted for in AttributeHandle constructor");
238 return {data_->begin(), data_->end()};
244 return data_->size();
252 return (*data_)[pos];
271 bool readOnly_=
false;
273 std::string name_=
"";
275 std::shared_ptr<StoreContainer<T>> data_;
281using AttributeHandleInt = AttributeHandle<bt::intT>;
282using AttributeHandleFloat = AttributeHandle<bt::floatT>;
283using AttributeHandleVector3 = AttributeHandle<enzo::bt::Vector3>;
284using AttributeHandleBool = AttributeHandle<enzo::bt::boolT>;
Basic attribute, parameter, and node types for Enzo.
AttributeType
Data types available to store attribute values in.
Definition Types.h:33
Read only accessor for enzo::ga::Attribute.
Definition AttributeHandle.h:195
AttributeHandleRO(std::shared_ptr< const Attribute > attribute)
Construct a new typed handle linked to a target attribute.
Definition AttributeHandle.h:200
std::string getName() const
Returs the attribute name as a string.
Definition AttributeHandle.h:256
size_t getSize() const
Gets the number of element stored in the attribute.
Definition AttributeHandle.h:242
T getValue(size_t pos) const
Gets the value at a given offset.
Definition AttributeHandle.h:248
std::vector< T > getAllValues() const
Gets a vector containing all the values stored in this attribute.
Definition AttributeHandle.h:236
void setValue(size_t offset, const T &value)
Sets the value at a given offset.
Definition AttributeHandle.h:151
std::string getName() const
Returs the attribute name as a string.
Definition AttributeHandle.h:159
std::vector< T > getAllValues() const
Gets a vector containing all the values stored in this attribute.
Definition AttributeHandle.h:122
void addValue(T value)
Adds an element to the end of the attribute.
Definition AttributeHandle.h:93
size_t getSize() const
Gets the number of element stored in the attribute.
Definition AttributeHandle.h:130
T getValue(size_t offset) const
Gets the value at a given offset.
Definition AttributeHandle.h:141
AttributeHandle(std::shared_ptr< Attribute > attribute)
Construct a new typed handle linked to a target attribute.
Definition AttributeHandle.h:53
void reserve(std::size_t newCap)
Reserves more space in the attribute to add new elements.
Definition AttributeHandle.h:108