#include <GU_DetailHandle.h>
A GU_DetailHandle is designed to allow arms length references to GU_Details. It acts as a shared pointer that ensures life time of GU_Details will be properly preserved. Further, it provides access control to the GU_Detail, ensuring multiple entities do not write to it at once.
NOTE: The locking methods are historical accidents and are not enforced nor encouraged.
- Examples:
- field3d/ROP_Field3D.C, packedprim/packedprim.C, packedsphere/GU_PackedSphere.C, SIM/SIM_ForceOrbit.C, SIM/SIM_ForceOrbit.h, SIM/SIM_SolverHair.C, SIM/SNOW_Solver.C, SIM/SNOW_Solver.h, SOP/SOP_BouncyAgent.C, SOP/SOP_DualStar.C, and SOP/SOP_DualStar.h.
Definition at line 38 of file GU_DetailHandle.h.
GU_DetailHandle::GU_DetailHandle |
( |
| ) |
|
GU_DetailHandle::~GU_DetailHandle |
( |
| ) |
|
void GU_DetailHandle::addExternalReference |
( |
| ) |
|
External references should not block unload requests at the SOP level. Normally if any external GU_DetailHandles still refer to the handle, unloading is prevented.
void GU_DetailHandle::addPreserveRequest |
( |
| ) |
|
Preserve Requests: A preserve request is a request that people create a new GU_DetailHandle rather than editting the current one. It is used by SOPs to determine if it is safe to do an in place cook. Anything outside of SOPs should always respect uniqueness instead. If storing a handle that comes from SOPs, adding a preserve request will stop SOPs from re-using it.
void GU_DetailHandle::allocateAndSet |
( |
GU_Detail * |
gdp, |
|
|
bool |
own = true |
|
) |
| |
void GU_DetailHandle::clear |
( |
| ) |
|
bool GU_DetailHandle::deleteGdp |
( |
| ) |
|
Deletes the underlying gdp and sets the gdp pointer to be null. It returns true if the gdp was successfully deleted, false if not. Failure likely results from a lock being present.
This method will duplicate the geometry associated with the handle, returning a new handle.
const GU_Detail* GU_DetailHandle::gdp |
( |
| ) |
const |
Readable & writeable pointers. If acquiring a write pointer, it is expected one will ensure uniqueness prior to acquiring it.
int GU_DetailHandle::getExternalReference |
( |
| ) |
const |
int GU_DetailHandle::getLockCount |
( |
| ) |
const |
NOTE: Locking is not enforced, and no longer encouraged. Returns the number of locks made to the base handle for debugging.
int64 GU_DetailHandle::getMemoryUsage |
( |
bool |
inclusive | ) |
const |
Return the amount of memory owned by the GU_DetailHandle itself, NOT the detail. This will count the memory of the GU_DetailHandleRef, which could be shared, so only the definitive "original" handle should be counted, e.g. the one on SOP_Node.
int GU_DetailHandle::getPreserveRequest |
( |
| ) |
const |
int GU_DetailHandle::getRefCount |
( |
| ) |
const |
Returns the number of references made to the base handle.
bool GU_DetailHandle::hasActiveLock |
( |
| ) |
const |
NOTE: Locking is not enforced, and no longer encouraged. Determines if anyone has a lock on this handle.
uint GU_DetailHandle::hash |
( |
| ) |
const |
|
inline |
Compute a hash based on myHandle. This is not on the contents of the gdp!
Definition at line 61 of file GU_DetailHandle.h.
bool GU_DetailHandle::isNull |
( |
| ) |
const |
bool GU_DetailHandle::isUnique |
( |
| ) |
const |
|
inline |
bool GU_DetailHandle::isValid |
( |
| ) |
const |
|
inline |
Determine if this is a valid handle (!isNull())
Definition at line 98 of file GU_DetailHandle.h.
Ensures this is the only handle referring to the underlying geometry, ie, getRefCount() == 1. A no-op if the geometry is already unique, otherwise invokes duplicateGeometry(). For most applications, you should only modify handles that you know are unique to avoid editing geometry stored in caches.
Safe-bool operator to return whether the handle is valid.
Definition at line 101 of file GU_DetailHandle.h.
const GU_Detail* GU_DetailHandle::peekDetail |
( |
| ) |
const |
Equivalent to gdp(), peekDetail is left over from when locking was considered important.
const GU_Detail* GU_DetailHandle::readLock |
( |
| ) |
|
NOTE: Locking is not enforced, and no longer encouraged. This will acquire a read lock on the GU_Detail. The result is 0 if no lock can be acquired, or no underlying detail exists. The returned detail should be passed to unlock(). (Technically, no locking occurs on error, but unlock is a no-op with a 0 gdp)
void GU_DetailHandle::removeExternalReference |
( |
| ) |
|
void GU_DetailHandle::removePreserveRequest |
( |
| ) |
|
NOTE: Locking is not enforced, and no longer encouraged. This will unlock one layer of locking. If the passed in gdp is null, no unlocking occurs. Otherwise, the passed in gdp is asserted to match the one which myHandle points to.
NOTE: Locking is not enforced, and no longer encouraged. This will acquire a write lock on the GU_Detail. The result is 0 if no lock can be acquired, or no underlying detail is present. The returned detail should be passed to unlock() when finished. There can only be one active write lock at a time. Do not destroy or modify the pointer itself and expect the unlock to update the GU_Detail *. Instead, use one of the delete or change functions. No readlocks or write locks can be active for this to work.
The documentation for this class was generated from the following file: