List Objects in Assembly Modeling


Because assembly modeling objects ( entity_handle, component_handle, component_entity_handle, asm_model) are not derived from ENTITY, the standard ACIS container ENTITY_LIST cannot be used to hold them. Instead, each assembly modeling object type has a corresponding list class whose interface is based upon that of ENTITY_LIST:

Each of these list classes has the same basic interface as ENTITY_LIST, along with two enhancements: counting, which is the ability to count the net number of times an object has been added to the list (including removals), and holding , which is the ability to increment the use count of objects in the list.

Topics include:

Counting

When counting is turned on in a list, the list stores an integer cardinality (or, a count) for each element of the list. Each time an element is added to the list, the cardinality is increased; each time the remove method is called on an element in the list, the cardinality is decreased. Only when the cardinality falls to zero is the element actually removed from the list.

Note:  The cardinality of an element can never drop below zero, and the counting behavior is OFF by default.

There are several new interface methods which are associated with the counting behavior:

Finally, note that the "counting" behavior of a list is determined when the list is constructed; it cannot be changed by an interface method.

Holding

When holding is turned on, the list "holds" all of its elements. (Refer to the section Use Counting and Holding for a detailed discussion of use counting and holding for assembly modeling objects.) Thus, the four assembly modeling object types for which list classes have been created are also use-counted. The use count is incremented by placing a pointer to the object in a "holder" object, which increments the use count while it holds the pointer. When a list's holding behavior is turned on, the list acts as a holder object, incrementing the use count while the object is an element of the list (and decrementing it when the object is removed from the list or the list is destructed). The holding behavior is controlled by the set_hold_state() method.

Note:  The hold state of a list can be toggled on and off after the list has been constructed, unlike the counting behavior.

Any assembly modeling list which is intended to store a set of pointers to assembly modeling objects for later use must have its holding behavior turned on. This ensures that calls to cleanup(), which deletes assembly objects with a use count of zero, do not invalidate any of the pointers in the list.


Related topics:

Handles in Assembly Modeling
Use Counting and Holding Objects in Assembly Modeling

[Top]