HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_ReuseStrategy Class Reference

Specify when and how to reuse an existing attribute. More...

#include <GA_ReuseStrategy.h>

Public Types

enum  CollisionStrategy { COLLISION_FAIL, COLLISION_RECYCLE, COLLISION_DEFAULT = COLLISION_RECYCLE }
 
enum  FailureStrategy {
  FAILURE_RETURN_MISMATCH, FAILURE_RETURN_INVALID, FAILURE_REPLACE, FAILURE_REPLACE_AND_COPY,
  FAILURE_DEFAULT = FAILURE_REPLACE_AND_COPY
}
 
enum  TypeStrategy { TYPE_DISALLOW, TYPE_KEEP_COMPATIBLE, TYPE_DEFAULT = TYPE_KEEP_COMPATIBLE }
 
enum  StorageStrategy {
  STORAGE_DISALLOW, STORAGE_KEEP, STORAGE_CLAMP, STORAGE_USE_BEST,
  STORAGE_DEFAULT = STORAGE_USE_BEST
}
 
enum  TupleSizeStrategy { TUPLE_SIZE_DISALLOW, TUPLE_SIZE_CLAMP, TUPLE_SIZE_USE_BEST, TUPLE_SIZE_DEFAULT = TUPLE_SIZE_USE_BEST }
 
enum  OptionsStrategy {
  OPTIONS_KEEP, OPTIONS_REPLACE, OPTIONS_OVERWRITE, OPTIONS_MERGE_MISSING,
  OPTIONS_DEFAULT = OPTIONS_MERGE_MISSING
}
 
enum  DataCopyStrategy { DATACOPY_FALSE, DATACOPY_TRUE, DATACOPY_DEFAULT = DATACOPY_TRUE }
 
enum  PointVertexCollisionStrategy { PT_VTX_COLLISION_IGNORE, PT_VTX_COLLISION_DESTROY, PT_VTX_COLLISION_INHERIT_VALUES_AND_DESTROY, PT_VTX_COLLISION_DEFAULT = PT_VTX_COLLISION_INHERIT_VALUES_AND_DESTROY }
 

Public Member Functions

 GA_ReuseStrategy (FailureStrategy fail_strategy=FAILURE_DEFAULT, TypeStrategy type_strategy=TYPE_DEFAULT, StorageStrategy storage_strategy=STORAGE_DEFAULT, TupleSizeStrategy size_strategy=TUPLE_SIZE_DEFAULT, OptionsStrategy opts_strategy=OPTIONS_DEFAULT)
 
 ~GA_ReuseStrategy ()
 
CollisionStrategy getCollisionStrategy () const
 
void setCollisionStrategy (CollisionStrategy s)
 
FailureStrategy getFailureStrategy () const
 
void setFailureStrategy (FailureStrategy s)
 
TypeStrategy getTypeStrategy () const
 
void setTypeStrategy (TypeStrategy s)
 
StorageStrategy getStorageStrategy () const
 
void setStorageStrategy (StorageStrategy s)
 
TupleSizeStrategy getTupleSizeStrategy () const
 
void setTupleSizeStrategy (TupleSizeStrategy s)
 
OptionsStrategy getOptionsStrategy () const
 
void setOptionsStrategy (OptionsStrategy s)
 
bool getRecycleOnCollision () const
 
bool getReplaceOnFailure () const
 
PointVertexCollisionStrategy getPointVertexCollisionStrategy () const
 
void setPointVertexCollisionStrategy (PointVertexCollisionStrategy s)
 
bool applyStrategiesForTuples (GA_Attribute &attrib, GA_Storage requested_storage, int requested_tuple_size, const GA_Defaults *requested_defaults, const UT_Options *requested_creation_options, const GA_AttributeOptions *requested_attribute_options, const UT_StringRef &requested_type) const
 
bool applyStrategiesForArrays (GA_Attribute &attrib, GA_Storage requested_storage, int requested_tuple_size, const UT_Options *requested_creation_options, const GA_AttributeOptions *requested_attribute_options, const UT_StringRef &requested_type) const
 
bool applyDataCopyStrategy (GA_Attribute *dest, const GA_Attribute *src) const
 
GA_AttributeOwner getPointVertexCollisionDict (GA_AttributeOwner dict) const
 
bool applyPointVertexCollisionDataCopyStrategy (GA_Attribute *dest, bool replacement, const GA_Attribute *src) const
 
int computeTupleSize (int old_size, int requested_size) const
 
GA_Storage computeNumericStorage (GA_Storage old_storage, GA_Storage requested_storage) const
 
void applyOptionsStrategy (const GA_AttributeOptions *requested_options, GA_AttributeOptions &current_options) const
 Apply getOptionsStrategy(). More...
 
static bool areEqual (const GA_Defaults &a_defaults, const GA_Defaults &b_defaults, GA_Storage storage, int size)
 Compare two defaults objects for equality. More...
 

Detailed Description

Specify when and how to reuse an existing attribute.

When attempting to create a new attribute, we may encounter an existing attribute with the same name. The GA_ReuseStrategy settings specify when and how to reuse the existing attribute instead of creating the new one.

Definition at line 32 of file GA_ReuseStrategy.h.

Member Enumeration Documentation

The high level strategy for resolving a name collision with an existing attribute.

Enumerator
COLLISION_FAIL 

Fail immediately on the collision, and resolve using the set FailureStrategy.

COLLISION_RECYCLE 

Attempt to recycle the existing attribute, failing only if the attempt fails, at which point, resolve using the FailureStrategy. The existing attribute may be partially changed on failure, so be careful when combining with FAILURE_RETURN_MISMATCH or even FAILURE_RETURN_INVALID.

COLLISION_DEFAULT 

Definition at line 37 of file GA_ReuseStrategy.h.

This enum specifies whether or not we attempt to copy values from the existing attribute in the event that we fail to reuse it.

Enumerator
DATACOPY_FALSE 
DATACOPY_TRUE 
DATACOPY_DEFAULT 

Definition at line 135 of file GA_ReuseStrategy.h.

This enum specifies how to deal with a failure when applying the CollisionStrategy.

Enumerator
FAILURE_RETURN_MISMATCH 

Return the conflicting attribute.

FAILURE_RETURN_INVALID 

Return an invalid result (NULL pointer or invalid reference)

FAILURE_REPLACE 

Replace the conflicting attribute.

FAILURE_REPLACE_AND_COPY 

Replace the conflicting attribute and attempt to copy data values to the new attribute.

FAILURE_DEFAULT 

Definition at line 55 of file GA_ReuseStrategy.h.

This enum specifies what to do with the attribute options passed to the creation method in the event that we're going to reuse an attribute.

Enumerator
OPTIONS_KEEP 

Keep existing attribute's options.

OPTIONS_REPLACE 

Replace existing attribute's options entirely.

OPTIONS_OVERWRITE 

Overwrite existing attribute's options so that options unique to the existing attribute are not lost

OPTIONS_MERGE_MISSING 

Keep any existing options, but merge in any missing options.

OPTIONS_DEFAULT 

Definition at line 118 of file GA_ReuseStrategy.h.

This enum specifies how we deal with name collisions across the point and vertex dictionaries.

Enumerator
PT_VTX_COLLISION_IGNORE 

Ignore the attribute in the other dictionary.

PT_VTX_COLLISION_DESTROY 

Destroy the attribute in the other dictionary.

PT_VTX_COLLISION_INHERIT_VALUES_AND_DESTROY 

Inherit the values from the attribute in the other dictionary, and then destroy it.

PT_VTX_COLLISION_DEFAULT 

Definition at line 145 of file GA_ReuseStrategy.h.

For attributes which have storage, this enum specifies what to do if there is a mismatch.

Enumerator
STORAGE_DISALLOW 

Disallow mis-matched storage.

STORAGE_KEEP 

Keep existing storage (if compatible)

STORAGE_CLAMP 

Reduce existing storage to that desired.

STORAGE_USE_BEST 

Use storage with greatest precision (float > int)

STORAGE_DEFAULT 

Definition at line 88 of file GA_ReuseStrategy.h.

For attributes which have a tuple size, this enum specifies what to do if there is a mis-match.

Enumerator
TUPLE_SIZE_DISALLOW 

Disallow mis-matched tuple sizes.

TUPLE_SIZE_CLAMP 

Set the new tuple size to be no larger than the old size.

TUPLE_SIZE_USE_BEST 

Use the larger of the two tuple sizes.

TUPLE_SIZE_DEFAULT 

Definition at line 104 of file GA_ReuseStrategy.h.

Typically a type mismatch will result in the existing attribute being replaced when an attribute type is explicitly requested, but when the only criteria is that the existing attribute support some expected interface, we can be less restrictive.

Enumerator
TYPE_DISALLOW 

Disallow mis-matched type.

TYPE_KEEP_COMPATIBLE 

Allow mis-matched type if compatible (only possible in generic methods like addFloatTuple(), addStringTuple(), etc where type is only implied).

TYPE_DEFAULT 

Definition at line 74 of file GA_ReuseStrategy.h.

Constructor & Destructor Documentation

GA_ReuseStrategy::GA_ReuseStrategy ( FailureStrategy  fail_strategy = FAILURE_DEFAULT,
TypeStrategy  type_strategy = TYPE_DEFAULT,
StorageStrategy  storage_strategy = STORAGE_DEFAULT,
TupleSizeStrategy  size_strategy = TUPLE_SIZE_DEFAULT,
OptionsStrategy  opts_strategy = OPTIONS_DEFAULT 
)
inline

Definition at line 159 of file GA_ReuseStrategy.h.

GA_ReuseStrategy::~GA_ReuseStrategy ( )
inline

Definition at line 170 of file GA_ReuseStrategy.h.

Member Function Documentation

bool GA_ReuseStrategy::applyDataCopyStrategy ( GA_Attribute dest,
const GA_Attribute src 
) const

Only call this method if getReplaceOnFailure() returns true. Returns true if the copy was successful, or was not needed. False otherwise.

void GA_ReuseStrategy::applyOptionsStrategy ( const GA_AttributeOptions requested_options,
GA_AttributeOptions current_options 
) const
bool GA_ReuseStrategy::applyPointVertexCollisionDataCopyStrategy ( GA_Attribute dest,
bool  replacement,
const GA_Attribute src 
) const

Only call this method if getPointVertexCollisionDict() does not return GA_ATTRIB_GLOBAL. Returns true if the copy was successful, or was not needed. False otherwise.

bool GA_ReuseStrategy::applyStrategiesForArrays ( GA_Attribute attrib,
GA_Storage  requested_storage,
int  requested_tuple_size,
const UT_Options requested_creation_options,
const GA_AttributeOptions requested_attribute_options,
const UT_StringRef requested_type 
) const

Attempt to bring the attribute to compliance as per the strategy. Our TypeStrategy determines whether we care about an exact type match

Returns true on success and false on failure. It is expected that the attribute will be replaced on failure as it may be partially modified by this method.

bool GA_ReuseStrategy::applyStrategiesForTuples ( GA_Attribute attrib,
GA_Storage  requested_storage,
int  requested_tuple_size,
const GA_Defaults requested_defaults,
const UT_Options requested_creation_options,
const GA_AttributeOptions requested_attribute_options,
const UT_StringRef requested_type 
) const

Attempt to bring the attribute to compliance as per the strategy. Our TypeStrategy determines whether we care about an exact type match or can work with a tuple AIF.

Returns true on success and false on failure. It is expected that the attribute will be replaced on failure as it may be partially modified by this method.

static bool GA_ReuseStrategy::areEqual ( const GA_Defaults a_defaults,
const GA_Defaults b_defaults,
GA_Storage  storage,
int  size 
)
static

Compare two defaults objects for equality.

GA_Storage GA_ReuseStrategy::computeNumericStorage ( GA_Storage  old_storage,
GA_Storage  requested_storage 
) const

Applies getStorageStrategy() to return the new numeric storage for the attribute or GA_STORE_INVALID if no resolution is possible. Note that GA_STORE_BOOL is considered a numeric storage type for these purposes.

int GA_ReuseStrategy::computeTupleSize ( int  old_size,
int  requested_size 
) const

Helper methods for COLLISION_RECYCLE

Applies getTupleSizeStrategy() to return the new tuple size for the attribute, or -1 if no resolution is possible.

CollisionStrategy GA_ReuseStrategy::getCollisionStrategy ( ) const
inline

Definition at line 172 of file GA_ReuseStrategy.h.

FailureStrategy GA_ReuseStrategy::getFailureStrategy ( ) const
inline

Definition at line 177 of file GA_ReuseStrategy.h.

OptionsStrategy GA_ReuseStrategy::getOptionsStrategy ( ) const
inline

Definition at line 197 of file GA_ReuseStrategy.h.

GA_AttributeOwner GA_ReuseStrategy::getPointVertexCollisionDict ( GA_AttributeOwner  dict) const
inline

Returns the dictionary that should be checked for a cross dictionary collision (GA_ATTRIB_VERTEX for GA_ATTRIB_POINT and vice versa) and GA_ATTRIB_INVALID when no check is needed.

Definition at line 284 of file GA_ReuseStrategy.h.

PointVertexCollisionStrategy GA_ReuseStrategy::getPointVertexCollisionStrategy ( ) const
inline

Definition at line 211 of file GA_ReuseStrategy.h.

bool GA_ReuseStrategy::getRecycleOnCollision ( ) const
inline

Definition at line 203 of file GA_ReuseStrategy.h.

bool GA_ReuseStrategy::getReplaceOnFailure ( ) const
inline

Definition at line 205 of file GA_ReuseStrategy.h.

StorageStrategy GA_ReuseStrategy::getStorageStrategy ( ) const
inline

Definition at line 187 of file GA_ReuseStrategy.h.

TupleSizeStrategy GA_ReuseStrategy::getTupleSizeStrategy ( ) const
inline

Definition at line 192 of file GA_ReuseStrategy.h.

TypeStrategy GA_ReuseStrategy::getTypeStrategy ( ) const
inline

Definition at line 182 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setCollisionStrategy ( CollisionStrategy  s)
inline

Definition at line 174 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setFailureStrategy ( FailureStrategy  s)
inline

Definition at line 179 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setOptionsStrategy ( OptionsStrategy  s)
inline

Definition at line 199 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setPointVertexCollisionStrategy ( PointVertexCollisionStrategy  s)
inline

Definition at line 213 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setStorageStrategy ( StorageStrategy  s)
inline

Definition at line 189 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setTupleSizeStrategy ( TupleSizeStrategy  s)
inline

Definition at line 194 of file GA_ReuseStrategy.h.

void GA_ReuseStrategy::setTypeStrategy ( TypeStrategy  s)
inline

Definition at line 184 of file GA_ReuseStrategy.h.


The documentation for this class was generated from the following file: