HDK
|
#include <PDG_AttributeMap.h>
Classes | |
class | ScopedLock |
class | ScopedTryLock |
Public Types | |
enum | SaveType { eSaveFlatten, eSaveStatic, eSaveDynamic, eSaveAll } |
Save operation to perform. More... | |
enum | CreateWhen { eCreateNever, eCreateAlways, eCreateUpgrade } |
enum | OverwriteWhen { eOverwriteNever, eOverwriteMatch, eOverwriteAlways } |
enum | ChangeResult { eChangeNone, eChangeConstructive, eChangeDestructive } |
Enumeration of possible attribute change results during regeneration. More... | |
enum | AttribTable { eTableStatic, eTableDynamic, eTableCount } |
Enumeration of attribute tables. More... | |
Static Public Attributes | |
static const UT_StringHolder | theBuiltinPrefix |
static const UT_StringHolder | theInputFileName |
static const UT_StringHolder | theOutputFileName |
static const UT_StringHolder | theAddedFileName |
static const UT_StringHolder | theCommandStringName |
Name of the built-in command attribute. More... | |
static const UT_StringHolder | theLabelName |
Name of the built-in human readable label attribute. More... | |
static const UT_StringHolder | theCustomStateName |
Name of the built-in custom state attribute. More... | |
static const UT_StringHolder | theCookPercentName |
Name of the built-in cook percent attribute. More... | |
static const UT_StringHolder | thePartitionSizeName |
Name of the built-in partition size attribute. More... | |
static const UT_StringHolder | theAllAttribName |
static const UT_StringHolder | thePseudoAttribName |
static const uint16 | theInputFileFlags |
Flags for the standard input file attribute. More... | |
static const uint16 | theOutputFileFlags |
Flags for the standard output file attribute. More... | |
static const uint16 | theAddedFileFlags |
Flags for the standard added file attribute. More... | |
static const uint16 | theCommandStringFlags |
Flags for the standard command string attribute. More... | |
static const uint16 | theLabelFlags |
Flags for the standard label attribute. More... | |
static const uint16 | theCustomStateFlags |
Flags for the standard custom state attribute. More... | |
Map for storing, accessing and persisting PDG attribute data. Attributes are stored in a map of string value to attribute holder, which maintains a weak/strong reference to an attribute. Writing to an attrib value results in a deep copy being performed on the specified attribute (i.e. copy on write). Attribute handles are given to callers in the form of a PDG_ROAttributeRef or PDG_RWAttributeRef, depending on whether the caller requested a read only or read/write handle.
Attributes are owned by a PDG_AttributeOwner instance. In most cases this is a PDG_WorkItem, and the attributes are accessed/modified when the node creates or cooks the work item.
The attribute map maintains a separate table for static and dynamic attributes. Static attributes are any attributes created during the work item generation step, and dynamic attributes are attributes created or modified at any other point in time. If a work item attempts to modify a static attribute while cooking, including adding output files, then a copy made is in the dynamic map. The modifications are peformed on that rather than on the original static attribute. This means that when a work item is dirtied, it can easily roll back to the exact same state it was in before cooking. When a work item is being regenerated, only static values are considered. If the item is dirty then all dynamic attributes are discarded, otherwise if the item is still valid then the dynamic values are left as-is.
The various merge* methods should be used to merge attribute map data from a parent or dependency on the work item. Care should be taken to only merge static attributes during work item generation. Dynamic attributes can be merged at any point between generation and the work item being marked as cooked.
Definition at line 71 of file PDG_AttributeMap.h.
Enumeration of attribute tables.
Definition at line 198 of file PDG_AttributeMap.h.
Enumeration of possible attribute change results during regeneration.
Enumerator | |
---|---|
eChangeNone |
No changes occured. |
eChangeConstructive |
Attribute values were changed or added. |
eChangeDestructive |
At least one attribute was deleted. |
Definition at line 185 of file PDG_AttributeMap.h.
Determines when to create an attribute, for refRW method calls that can optionally create one if it does not yet exist.
Definition at line 155 of file PDG_AttributeMap.h.
Detrmines when to overwrite an attribute when requesting an RW reference to it.
Definition at line 170 of file PDG_AttributeMap.h.
Save operation to perform.
Definition at line 137 of file PDG_AttributeMap.h.
|
explicit |
PDG_AttributeMap::~PDG_AttributeMap | ( | ) |
|
inline |
Returns a read-only handle to the standard added file attribute.
Definition at line 550 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write handle to the standard input file attribute.
Definition at line 557 of file PDG_AttributeMap.h.
bool PDG_AttributeMap::attributeMatch | ( | const PDG_AttributePattern & | pattern, |
bool | include_internal | ||
) | const |
Returns true if any attributes in this map match the specified pattern.
bool PDG_AttributeMap::attributeMatch | ( | UT_ArrayStringSet & | names, |
const PDG_AttributePattern & | pattern, | ||
bool | include_internal | ||
) | const |
Returns the set of attribute names in the map that match the specified attribute pattern. Returns true if anything matches, else false.
void PDG_AttributeMap::attributeNames | ( | UT_ArrayStringSet & | names, |
PDG_AttributeType | type | ||
) | const |
Returns the set of attribute names in the map, for the specified attribute type. Values are returned back as a string set.
void PDG_AttributeMap::attributeNames | ( | UT_StringArray & | names, |
PDG_AttributeType | type | ||
) | const |
Returns the set of attribute names in the map, for the specified attribute type. Values are returned back as an array, sorted by attribute name.
int PDG_AttributeMap::attributeSize | ( | const UT_StringHolder & | name | ) | const |
Returns the size of the attribute with the specified name.
PDG_AttributeType PDG_AttributeMap::attributeType | ( | const UT_StringHolder & | name | ) | const |
Returns the type of the attribute with the specified name.
void PDG_AttributeMap::clearConcat | ( | AttribTable | table = eTableCount | ) |
Clears the contents of any owned concatenated attributes, but does not remove them
|
inline |
Utility method that clears all values from an attribute, and creates it if it does not already exist
Definition at line 947 of file PDG_AttributeMap.h.
|
inline |
Returns a read-only handle to the standard command string file attribute
Definition at line 572 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write handle to the standard input file attribute.
Definition at line 579 of file PDG_AttributeMap.h.
|
inline |
Returns a read-only handle to the standard work item cook progress attribute
Definition at line 639 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write handle to the standard work item custom state attribute
Definition at line 647 of file PDG_AttributeMap.h.
|
inline |
Copies the specified attribute into an attribute on this map.
Definition at line 765 of file PDG_AttributeMap.h.
ChangeResult PDG_AttributeMap::endChangeTracking | ( | bool | check_all | ) |
Ends tracking changes, returning true if a change made was.
PDG_AttributeRef::Error PDG_AttributeMap::erase | ( | PDG_AttributeType | type | ) |
Erases all attributes of the specified Attribute type from the map.
PDG_AttributeRef::Error PDG_AttributeMap::erase | ( | const UT_StringHolder & | name | ) |
Erases an attribute from the map by name.
PDG_AttributeRef::Error PDG_AttributeMap::eraseAll | ( | bool | include_internal | ) |
Erases all attributes in this map.
bool PDG_AttributeMap::eraseDirty | ( | bool | include_unowned | ) |
Erases any dynamic attributes, unowned attributes, or owned attributes that were formed by concatenating input attributes. Returns true if an attribute that was owned by this map is destroyed.
void PDG_AttributeMap::eraseStale | ( | ) |
Removes any stale attributes from the map from the deserialization process
|
inline |
Iterates over attributes in the map of the specified type, and invokes the input function on each matching entry. This function operates on the space of attribute names, and therefore will including parent map attributes and dynamic attributes, if permitted by the active context.
The supplied function can return true to halt iteration.
Definition at line 358 of file PDG_AttributeMap.h.
void PDG_AttributeMap::freeze | ( | ) |
Freezes the attributes in the map, which invokes a deep copy on any unowned attributes. This makes the map fully standalone, without any shallow references to external attribute maps.
int64 PDG_AttributeMap::getMemoryUsage | ( | bool | inclusive | ) | const |
Returns the memory usage of this attribute map.
bool PDG_AttributeMap::hasAttribute | ( | const UT_StringHolder & | name | ) | const |
Checks for the existance of an attribute by name. Returns true if the attribute is found, else false
bool PDG_AttributeMap::hasFlag | ( | const UT_StringHolder & | name, |
PDG_AttributeFlag | flag | ||
) | const |
Returns true if attribute has the the specified flag set, else false.
bool PDG_AttributeMap::hash | ( | SYS_HashType & | hash_val, |
AttribTable | table, | ||
bool | include_internal, | ||
bool | include_unowned, | ||
UT_WorkBuffer & | errors | ||
) | const |
Computes the hash value for attrib values, errors can occur if python objects hash() raises an exception.
bool PDG_AttributeMap::hash | ( | SYS_HashType & | hash_val, |
const UT_ArrayStringSet & | filter, | ||
AttribTable | table, | ||
bool | include_internal, | ||
bool | include_unowned, | ||
UT_WorkBuffer & | errors | ||
) | const |
Computes the hash value for the specific attribute values specified in the set of names. This is the same as the function above, but it only applies to the indicated subset of attribs.
|
inline |
Returns a read-only handle to the standard input file attribute.
Definition at line 508 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write handle to the standard input file attribute.
Definition at line 515 of file PDG_AttributeMap.h.
|
inline |
Returns a read-only handle to the standard work item label attribute
Definition at line 594 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write handle to the standard work item label attribute.
Definition at line 601 of file PDG_AttributeMap.h.
bool PDG_AttributeMap::loadV1 | ( | PDG_AttributeCollision | strategy, |
const UT_JSONValue & | value | ||
) |
Loads a V1 data format json object.
bool PDG_AttributeMap::loadV2 | ( | SaveType | save_type, |
PDG_AttributeCollision | strategy, | ||
const UT_JSONValue & | value | ||
) |
Loads a V2 data format json object.
|
inline |
Runs a functor on this map under the scoped read lock, so it's safe for concurrent access on an arbitrary thread. This holds both the global read lock and attribute map read lock, so it can always be called in order to safely iterate over attribute values. This should be used in, for example, an event handler callback in order to ensure that the attributes are not also being written to by the owner or a full-item list operation performed by another holder of the global lock.
If this map does not have an owner, or the owner does not have a global lock, the functor will be called with only the local attribute lock held.
Definition at line 330 of file PDG_AttributeMap.h.
bool PDG_AttributeMap::mergeDynamic | ( | PDG_AttributeMerge & | attrib_merge, |
const PDG_AttributeOwner * | owner | ||
) |
Merges dynamic attributes from another attribute owenr into this one.
bool PDG_AttributeMap::mergeFull | ( | PDG_AttributeMerge & | attrib_merge, |
const PDG_AttributeMap & | other, | ||
AttribTable | dst_table = eTableStatic , |
||
bool | reset = true |
||
) |
Merges all attributes from another map into this one.
bool PDG_AttributeMap::mergeFull | ( | PDG_AttributeMerge & | attrib_merge, |
const PDG_AttributeOwner * | owner, | ||
AttribTable | dst_table = eTableStatic , |
||
bool | reset = true |
||
) |
Merges all attributes from another attribute owner into this one.
bool PDG_AttributeMap::mergeStatic | ( | PDG_AttributeMerge & | attrib_merge, |
const PDG_AttributeOwner * | owner | ||
) |
Merges static attributes from another attribute owenr into this one.
int PDG_AttributeMap::numAttributes | ( | PDG_AttributeType | type | ) | const |
Returns the total number of attributes in the map, for the specified atribute type.
|
inline |
Returns a read-only handle to the standard output file attribute.
Definition at line 529 of file PDG_AttributeMap.h.
|
inline |
Returns a read-write handle to the standard output file attribute.
Definition at line 536 of file PDG_AttributeMap.h.
|
inline |
Returns the attribute owner.
Definition at line 503 of file PDG_AttributeMap.h.
|
inline |
Returns a read-only, const attribute handle. Will be invalid if the specified attribute does not exist or is of the wrong type.
Definition at line 663 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write, non-const attribute handle that permits both flag and data manipulation. Does not create the attribute, but will upgrade it from a parent map/lower table if necessary. Note that this method is intionally distinct from the version below since it uses a codepath that doesn't require a concrete Attribute type in order to create an attribute reference.
Definition at line 688 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write, non-const attribute handle that permits both flag and data manipulation. Optionally creates the attribute if it does not exist. Will be invalid if the specified attribute does not exist, is of the wrong type, or is marked as read-only.
Definition at line 717 of file PDG_AttributeMap.h.
|
inline |
Same as above, but with greater control on the creation flags.
Definition at line 734 of file PDG_AttributeMap.h.
|
inline |
Renames the specififed attribute.
Definition at line 806 of file PDG_AttributeMap.h.
void PDG_AttributeMap::resolveMergeOps | ( | PDG_AttributeMerge & | attrib_merge | ) |
Resolves any pending operations in the specified attribute merge map.
bool PDG_AttributeMap::save | ( | UT_JSONWriter & | writer, |
SaveType | save_type, | ||
bool | is_patch, | ||
bool | include_bound | ||
) | const |
Saves the attribute map to a JSON writer, in the most current data format
bool PDG_AttributeMap::save | ( | UT_JSONWriter & | writer, |
const PDG_AttributeHolder & | holder, | ||
const UT_StringHolder & | name | ||
) | const |
Saves a single attribute holder to a JSON writer, in the most current data format.
PDG_AttributeRef::Error PDG_AttributeMap::setFlag | ( | const UT_StringHolder & | name, |
PDG_AttributeFlag | flag, | ||
bool | set | ||
) |
Sets or clears a flag on the specified attribute.
bool PDG_AttributeMap::setFlagAll | ( | PDG_AttributeFlag | flag, |
bool | set | ||
) |
Sets or clears a flag on all attributes.
void PDG_AttributeMap::setParentMap | ( | PDG_AttributeOwner * | parent | ) |
Sets the parent map.
|
inline |
Utility method that sets an attribute value at a specified index, and creates it if it does not already exist
Definition at line 916 of file PDG_AttributeMap.h.
|
inline |
Utility method that sets an attribute array value, and creates it if it does not already exist
Definition at line 932 of file PDG_AttributeMap.h.
void PDG_AttributeMap::startChangeTracking | ( | ) |
Begins tracking attribute changes.
|
inline |
Returns a read-only handle to the standard work item custom state attribute
Definition at line 616 of file PDG_AttributeMap.h.
|
inline |
Returns a read/write handle to the standard work item custom state attribute
Definition at line 624 of file PDG_AttributeMap.h.
void PDG_AttributeMap::swap | ( | PDG_AttributeMap & | other | ) |
Swaps the target attribute map contents with this one.
bool PDG_AttributeMap::timeDependentAttributes | ( | UT_ArrayStringSet & | names | ) | const |
Returns the set of time dependent attributes for this map.
|
inline |
Same as above, but only try-locks. If the lock cannot be acquired the functor is not run and the method returns false. If the functor is run successfully this method returns true.
Definition at line 341 of file PDG_AttributeMap.h.
|
inline |
Utility method that looks up a value from an attribute, with a given index, and an optional flag filter
Definition at line 882 of file PDG_AttributeMap.h.
|
inline |
Utility method that looks up an array value from an attribute, with an optional flag filter
Definition at line 899 of file PDG_AttributeMap.h.
bool PDG_AttributeMap::value | ( | PDGT_Value & | value, |
const UT_StringHolder & | name, | ||
int | index, | ||
uint16 | flags = 0 |
||
) | const |
Queries a scalar value by name/index and stores it as a PDGT_Value.
|
inline |
Queries all values of the specified attribute type and returns them as a map.
Definition at line 961 of file PDG_AttributeMap.h.
bool PDG_AttributeMap::values | ( | PDGT_Value::Map & | value_map, |
uint16 | flags = 0 |
||
) | const |
Queries all values as PDGT_Values.
Flags for the standard added file attribute.
Definition at line 125 of file PDG_AttributeMap.h.
|
static |
Name of the built-in added file list attribute, which contains files explicitly added to the work item.
Definition at line 89 of file PDG_AttributeMap.h.
|
static |
Special token indicating all attributes, used when binding attributes with PDG_AttributeInfo.
Definition at line 109 of file PDG_AttributeMap.h.
|
static |
Prefix for all built-in PDG attributes that can potentially appear on work items. User-created attributes cannot begin with this prefix.
Definition at line 76 of file PDG_AttributeMap.h.
Flags for the standard command string attribute.
Definition at line 128 of file PDG_AttributeMap.h.
|
static |
Name of the built-in command attribute.
Definition at line 92 of file PDG_AttributeMap.h.
|
static |
Name of the built-in cook percent attribute.
Definition at line 101 of file PDG_AttributeMap.h.
Flags for the standard custom state attribute.
Definition at line 134 of file PDG_AttributeMap.h.
|
static |
Name of the built-in custom state attribute.
Definition at line 98 of file PDG_AttributeMap.h.
Flags for the standard input file attribute.
Definition at line 119 of file PDG_AttributeMap.h.
|
static |
Name of the built-in input file list attribute, which contains the read only list of input files to a work item
Definition at line 80 of file PDG_AttributeMap.h.
Flags for the standard label attribute.
Definition at line 131 of file PDG_AttributeMap.h.
|
static |
Name of the built-in human readable label attribute.
Definition at line 95 of file PDG_AttributeMap.h.
Flags for the standard output file attribute.
Definition at line 122 of file PDG_AttributeMap.h.
|
static |
Name of the built-in output file list attribute, which contains the list of all output files from the work item, including any outputs copied from inputs.
Definition at line 85 of file PDG_AttributeMap.h.
|
static |
Name of the built-in partition size attribute.
Definition at line 104 of file PDG_AttributeMap.h.
|
static |
Special token used to indicate a "pseudo" attribute dependency, such as the work item's index or frame. These attribute dependencies only exist because the values are accessible via expressions like a regular attribute, although the value itself is not stored as an attribute.
Definition at line 115 of file PDG_AttributeMap.h.