#pragma once #include #include #include #include #include #include "Engine/Operator/Attribute.h" #include "Engine/Types.h" #include "tbb/concurrent_vector.h" #include namespace enzo::ga{ template class AttributeHandle { public: ga::AttributeType type_; AttributeHandle(std::shared_ptr attribute) { type_ = attribute->getType(); // get attribute data pointer // TODO: check types match // TODO: add the other types // int if constexpr (std::is_same::value) { data_=attribute->intStore_; } // float else if constexpr (std::is_same::value) { data_=attribute->floatStore_; } // vector 3 else if constexpr (std::is_same::value) { data_=attribute->vector3Store_; } else if constexpr (std::is_same::value) { data_=attribute->boolStore_; } else { throw std::runtime_error("Type " + std::to_string(static_cast(type_)) + " was not properly accounted for in AttributeHandle constructor"); } } void addValue(T value) { // TODO:make this private (primitive friend classes only) data_->push_back(value); } void reserve(std::size_t newCap) { data_->reserve(newCap); } // TODO: replace with iterator std::vector getAllValues() const { return {data_->begin(), data_->end()}; } size_t getSize() const { return data_->size(); } T getValue(size_t pos) const { // TODO:protect against invalid positions // TODO: cast types return (*data_)[pos]; } void setValue(size_t pos, const T& value) { // TODO:protect against invalid positions // TODO: cast types (*data_)[pos] = value; } std::string getName() const { return name_; } private: // private attributes are attributes that are hidden from the user // for internal use bool private_=false; // hidden attributes are user accessible attributes that the user may // or may want to use bool hidden_=false; // allows the user to read the attributeHandle but not modify it bool readOnly_=false; std::string name_=""; std::shared_ptr> data_; // int typeID_; }; using AttributeHandleInt = AttributeHandle; using AttributeHandleFloat = AttributeHandle; using AttributeHandleVector3 = AttributeHandle; using AttributeHandleBool = AttributeHandle; }