11 #ifndef __APEX_COW_H__
12 #define __APEX_COW_H__
60 return (**this).append(v);
65 return (**this).append(v, check_dup);
74 return (**this).append(v, num_entries);
77 template <
typename...
S>
80 return (**this).emplace_back(
s...);
88 (**this).setCapacity(capacity);
94 T *
data() {
return (**this).data(); }
95 const T *
data()
const {
return (**this).data(); }
106 bool isEmpty()
const {
return (**this).isEmpty(); }
126 template <
typename T>
166 if (other.myIsStashed)
174 myHandle = other.myHandle;
181 if (other.myIsStashed)
189 myHandle = std::move(other.myHandle);
190 other.myIsStashed =
true;
201 if (other.myIsStashed && myLastModified)
209 else if (other.myIsStashed)
214 myLastModified =
false;
224 myHandle = other.myHandle;
226 myLastModified =
false;
238 if (other.myIsStashed && myLastModified)
246 else if (other.myIsStashed)
251 myLastModified =
false;
264 myHandle = std::move(other.myHandle);
265 other.myIsStashed =
true;
266 myLastModified =
false;
287 myLastModified =
true;
293 if (was_stashed && myHandle.
isNull())
308 utZoneScopedN(
"ApexGeometry::makeUnique::stash::allocateGeoemtry");
313 else if (!for_overwrite)
344 .removePreserveRequest();
353 return *myHandle.
gdpNC();
359 return *getStaticEmpty();
360 return *myHandle.
gdp();
366 return myHandle.
gdpNC();
373 return getStaticEmpty();
374 return myHandle.
gdp();
389 return myHandle.
gdpNC();
412 else if (!for_overwrite)
430 bool force_copy =
false,
434 return *getStaticEmptyHandle();
471 static const HandleInit theEmpty;
472 return &theEmpty.handle;
480 bool myLastModified =
false;
483 bool myIsStashed =
false;
503 #endif // header guard
ApexGeometry(GU_DetailHandle &&gdh)
Construct an ApexGeometry referencing a GU_DetailHandle.
exint append(const T &v, bool check_dup)
ApexGeometry()
Construct an empty ApexGeometry.
int getPreserveRequest() const
typename UT_Array< T >::const_reverse_iterator const_reverse_iterator
GLenum GLuint GLsizei bufsize
typename UT_Array< T >::reverse_iterator reverse_iterator
GU_Detail * gdpForOverwrite()
size_t format(char *buffer, size_t bufsize, const ApexArray< T > &v)
bool isUnique() const
Returns whether the geometry is unique - if so, asUnsafeHandle can be used safely.
static const UT_COWValue< T > & getStaticEmpty()
const_iterator begin() const
const GU_Detail * gdp() const
GU_ConstDetailHandle asConstHandle(bool force_copy=false, GA_DataIdStrategy explicit_strategy=GA_DATA_ID_CLONE) const
typename UT_Array< T >::iterator iterator
GU_DetailHandle duplicateGeometry(GA_DataIdStrategy data_id_strategy=GA_DATA_ID_BUMP) const
const GU_Detail & operator*() const
Return a const reference to the underlying GU_Detail, without ensuring uniqueness.
void setCapacity(exint capacity)
ApexGeometry(ApexGeometry &&other) noexcept
void allocateAndSet(GU_Detail *gdp, bool own=true)
void addPreserveRequest()
typename UT_Array< T >::const_iterator const_iterator
void setSize(exint newsize)
#define utZoneScopedN(name)
GU_DetailHandle & asUnsafeHandle(bool for_overwrite=false)
const GU_Detail * gdp() const
Access the underlying const GU_Detail, without ensuring uniqueness.
GU_Detail * operator->()
Access the underlying GU_Detail, ensuring uniqueness.
const GU_Detail * peekPtr() const
Access the underlying const GU_Detail *, without ensuring uniqueness.
exint emplace_back(S &&...s)
T & operator[](exint index)
GLint GLint GLsizei GLint GLenum format
ApexGeometry & operator=(const ApexGeometry &other)
GU_DetailHandle & asSafeHandle()
Access the underlying GU_DetailHandle while first ensuring it is unique.
const GU_Detail * operator->() const
Access the underlying const GU_Detail, without ensuring uniqueness.
ApexGeometry & operator=(ApexGeometry &&other) noexcept
const_iterator rend() const
static APEX_API const ApexGeometry & getStaticEmptyGeometry()
void append(const T *v, exint num_entries)
ApexGeometry(const GU_DetailHandle &gdh)
Construct an ApexGeometry referencing a GU_DetailHandle.
GU_Detail & operator*()
Return a reference to the underlying GU_Detail, ensuring uniqueness.
VULKAN_HPP_CONSTEXPR_14 VULKAN_HPP_INLINE T exchange(T &obj, U &&newValue)
const GU_Detail & peek() const
Access the underlying const GU_Detail, without ensuring uniqueness.
const T & operator[](exint index) const
SYS_DECLARE_IS_TR(apex::ApexGeometry)
ApexGeometry(const ApexGeometry &other)
exint find(const T &val, exint start=0) const
const_iterator rbegin() const
void operator=(const UT_Array< T > &other)
static const APEX_COWHandle< T > & getAPEXStaticEmpty()
void removePreserveRequest()
GU_Detail * gdp()
Access the underlying GU_Detail, ensuring uniqueness.
void makeUnique(bool for_overwrite=false)
const_iterator end() const
const UT_Array< T > & peek() const