#include <asm_model_list.hxx>


Public Member Functions | |
| void | add (const asm_model_list &model_list, logical check=TRUE) |
Adds the models of an asm_model_list to this asm_model_list. | |
| int | add (asm_model *model, logical check=TRUE) |
| Adds an assembly model to the list and returns its index number. | |
| int | add_notify (asm_model *model, logical &was_added, int &list_count) |
| Adds an assembly model to the list, returns its index number and notifies if the model is new. | |
| asm_model ** | array (asm_model **model_array=NULL, int &array_count=*(int *) NULL_REF, logical tombstones=FALSE) |
| Gets an array of the assembly models in the list. | |
| asm_model_list (const asm_model_list &list_copy) | |
| C++ copy constructor, which copies the whole list (complete with deleted entries, if any), so that the indices in the copy match those in the original. | |
| asm_model_list (int count, asm_model **model_array, asm_list_options *list_opts=NULL, logical check=TRUE) | |
C++ constructor, creating an asm_model_list from an array with the behavior specified by the asm_list_options object. | |
| asm_model_list (asm_list_options *list_opts) | |
C++ constructor, creating an asm_model_list with the behavior specified by the asm_list_options object. | |
| asm_model_list (asm_hold_state state) | |
C++ constructor, creating an asm_model_list with the specified holding behavior. | |
| asm_model_list () | |
Default constructor, creating an asm_model_list. | |
| int | byte_count (logical countSelf=TRUE) const |
| Returns the size in bytes of this class. | |
| void | clear () |
| Clear all entries from the list and reset indexes and counters for reuse. | |
| int | count () const |
| Returns the number of entries in the list including the deleted ones (tombstones). | |
| int | entry_count (const asm_model *list_member) |
| Returns the number of times an entry has been added minus the number of times it has been removed. | |
| int | entry_count (int index) |
| Returns the number of times an entry has been added minus the number of times it has been removed. | |
| asm_model * | first () const |
| Returns the first undeleted (live) entry and updates the iterator correctly for the next method. | |
| void | init () const |
| Initializes the iterator, which is used by the next method, to the beginning of the list. | |
| int | iteration_count () const |
| Returns the number of live entries in the list not including deleted entries. | |
| int | lookup (const asm_model *model) const |
| Lookup the specified asmsembly model in the list and return its index. | |
| asm_model * | next () const |
| Returns the next undeleted (live) entry. | |
| asm_model * | next_from (int &index) |
Returns the next non-deleted entry after the index given without affecting the member variables used by init and next. | |
| asm_model_list & | operator= (const asm_model_list &asm_model_list) |
Assignment operator performs a full copy of the list, complete with tombstones for deleted entries so that the indices are the same. | |
| asm_model * | operator[] (int index) const |
| Returns the assembly model at the given index from the list. | |
| int | remove (int index) |
| Remove the entry at the specified index from the list and return its index. | |
| void | remove (const asm_model_list &model_list) |
| Removes asm models in the given list from the list; however, it does not free space. | |
| int | remove (const asm_model *model) |
| Remove the specified entry from the list and return its index. | |
| int | remove_notify (const asm_model *model, logical &was_removed, int &list_count) |
| Remove the specified entry from the list and return its index. | |
| void | reverse (logical compress=TRUE) |
| Reverses the order of the assembly model list. | |
| void | set_hold_state (asm_hold_state state) |
| Sets the hold state of the model list. | |
| void | sort (int(*compare_func)(const void *model1, const void *model2)) |
| Sorts the list based upon the user-supplied comparison function. | |
| ~asm_model_list () | |
C++ destructor, deleting an asm_model_list. | |
Role: This class is a list object for asm_model objects that is intended to have the look and feel of the ENTITY_LIST class. But the functionality has been extended to include holding and counting mechanisms.
If the counting mechanism is turned on, then the list keeps track of the entry count, i.e. the number of times the same entry has been added minus the number of times it has been removed. The entry is deleted from the list only if the entry count reaches zero.
When the holding state of the list is set to ASM_HOLD, the list increments the use count of each entry. This ensures that "held" entries are not deleted when the models are cleaned up. For details on cleaning up models, please refer to the documentation on the asm_model_mgr object.
The holding and counting mechanisms are specified when the asm_model_list object is constructed. Additionally, the holding state can be changed using asm_model_list::set_hold_state.
Models are added to the end of the list using asm_model_list::add which ensures that the models are not already in the list (i.e. set behavior). The asm_model_list::remove methods take entries off the list, but a tombstone remains at the position of the former entries. The asm_model_list::add_notify and asm_model_list::remove_notify methods notify the caller when the list is actually modified.
The position of current entries can be determined using asm_model_list::lookup, and the entry at a specified position may be accessed using the overloaded "[ ]" index operator. The number of entries in the list is returned by asm_model_list::count (includes tombstones) and asm_model_list::iteration_count (excludes tombstones). The preferred way of accessing the data items is through asm_model_list::init which rewinds the list and asm_model_list::next which returns the next undeleted item. The asm_model_list::first method rewinds the list and returns the first non-deleted entry.
The current implementation uses hashing so that asm_model_list::lookup is fast; it is also efficient for very short lists and for repeated lookups of the same assembly model.
When a group of assembly models must be returned, and the number of arguments is not known in advance, the system returns the arguments as an asm_model_list. For instance, when the routine api_asm_get_models is used to find every model in the model tree beow the specified assembly, the models found are put into an asm_model_list that is returned.
asm_model_list my_models; api_asm_get_models( assembly, my_models ); for ( asm_model* model = my_models.first(); model != NULL; model = my_models.next() ) { }
asm_model_list is iteration_count(). This function prevents having the list iterators skip deleted entries. Else some routines encounter arrays with uninitialized entries and unexpected results may occur. asm_model_list (including tombstones), then individual entries can be accessed with the index operator [ ]. operator [ ] does not ignore "removed" entries). asm_model_list class is a variable length associative array of asm_model pointers. When using the subscript operator, a cast is required to change the asm_model pointer into the correct type. Many ACIS internal algorithms use asm_model_list including the save, and restore algorithms. asm_model_list is also useful in ACIS components and applications. | asm_model_list::asm_model_list | ( | ) |
Default constructor, creating an asm_model_list.
Role: By default, the hold state is set to ASM_NO_HOLD and the counting mechanism is turned off.
| asm_model_list::asm_model_list | ( | asm_hold_state | state | ) |
C++ constructor, creating an asm_model_list with the specified holding behavior.
Role: By default, the counting mechanism is turned off.
| state | hold state. |
| asm_model_list::asm_model_list | ( | asm_list_options * | list_opts | ) |
C++ constructor, creating an asm_model_list with the behavior specified by the asm_list_options object.
| list_opts | pointer to assembly list options. |
| asm_model_list::~asm_model_list | ( | ) |
C++ destructor, deleting an asm_model_list.
Role: If holding is turned on, the use counts of all entries are decremented.
| asm_model_list::asm_model_list | ( | int | count, | |
| asm_model ** | model_array, | |||
| asm_list_options * | list_opts = NULL, |
|||
| logical | check = TRUE | |||
| ) |
C++ constructor, creating an asm_model_list from an array with the behavior specified by the asm_list_options object.
Role: If the check flag is set to FALSE, the elements of the array are not checked to ensure that the entries of the list are unique.
| count | size of array | |
| model_array | array of assembly models | |
| list_opts | pointer to assembly list options. | |
| check | check unique. |
| asm_model_list::asm_model_list | ( | const asm_model_list & | list_copy | ) |
C++ copy constructor, which copies the whole list (complete with deleted entries, if any), so that the indices in the copy match those in the original.
Role: If holding is turned on, the use count of all active entries is incremented. For counted lists, the entry count for each entry is also copied.
| list_copy | list to copy. |
| void asm_model_list::add | ( | const asm_model_list & | model_list, | |
| logical | check = TRUE | |||
| ) |
Adds the models of an asm_model_list to this asm_model_list.
Role:Same as asm_model_list::add for all models in the input list.
| asm_model_list | asm_model list. | |
| check | check unique. |
| int asm_model_list::add | ( | asm_model * | model, | |
| logical | check = TRUE | |||
| ) |
Adds an assembly model to the list and returns its index number.
Role: If the check flag is set to FALSE, then the lookup that assures a unique entry is skipped. If holding is turned on, the model's use count is incremented the first time it is added to the list. If the counting mechanism is turned on, the entry count for the added entry is incremented.
| model | asm_model to add. | |
| check | check unique. |
| int asm_model_list::add_notify | ( | asm_model * | model, | |
| logical & | was_added, | |||
| int & | list_count | |||
| ) |
Adds an assembly model to the list, returns its index number and notifies if the model is new.
Role: Same as asm_model_list::add, but notifies the caller if the model is added to the list for the first time and returns the entry count for the added entry.
| model | asm_model to add. | |
| was_added | notify if new on list. | |
| list_count | number of adds minus removes |
| asm_model** asm_model_list::array | ( | asm_model ** | model_array = NULL, |
|
| int & | array_count = *(int *) NULL_REF, |
|||
| logical | tombstones = FALSE | |||
| ) |
Gets an array of the assembly models in the list.
Role: The default returns an array that must be freed by using ACIS_DELETE [] STD_CAST
| model_array | pointer of array to be used if provided. | |
| array_count | number of models in array. | |
| tombstones | add tombstones to array. |
| int asm_model_list::byte_count | ( | logical | countSelf = TRUE |
) | const |
Returns the size in bytes of this class.
Role: It does not include the size of the individual asm_models themselves.
| countSelf | count self or not. |
| void asm_model_list::clear | ( | ) |
Clear all entries from the list and reset indexes and counters for reuse.
Role: If holding is turned on, the use count of all active entries of the list is decremented before being removed from the list. The holding and counting behavior of the list remains unchanged.
| int asm_model_list::count | ( | ) | const |
Returns the number of entries in the list including the deleted ones (tombstones).
| int asm_model_list::entry_count | ( | const asm_model * | list_member | ) |
Returns the number of times an entry has been added minus the number of times it has been removed.
Role: This method returns -1 if counting is turned off or the list member is not found.
| list_member | assembly model. |
| int asm_model_list::entry_count | ( | int | index | ) |
Returns the number of times an entry has been added minus the number of times it has been removed.
Role: This method returns -1 if counting is turned off, the index corresponds to a deleted entry or the index is out of range.
| index | integer. |
| asm_model* asm_model_list::first | ( | ) | const |
Returns the first undeleted (live) entry and updates the iterator correctly for the next method.
| void asm_model_list::init | ( | ) | const |
Initializes the iterator, which is used by the next method, to the beginning of the list.
| int asm_model_list::iteration_count | ( | ) | const |
Returns the number of live entries in the list not including deleted entries.
| int asm_model_list::lookup | ( | const asm_model * | model | ) | const |
Lookup the specified asmsembly model in the list and return its index.
| model | entry to lookup |
| asm_model* asm_model_list::next | ( | ) | const |
Returns the next undeleted (live) entry.
| asm_model* asm_model_list::next_from | ( | int & | index | ) |
Returns the next non-deleted entry after the index given without affecting the member variables used by init and next.
Role: This allows clients to create iterators that can be multiply instantiated and which run independently of each other. This is accomplished simply by giving the the user the appropriate variables to save themselves.
| index | integer. |
| asm_model_list& asm_model_list::operator= | ( | const asm_model_list & | asm_model_list | ) |
Assignment operator performs a full copy of the list, complete with tombstones for deleted entries so that the indices are the same.
Role: If holding is turned on, the use count of all active entries of the original list is decremented and the use count of all entries of the copied list is incremented. For counted lists, the entry count for each entry is also copied.
| asm_model_list | asm_model list. |
| asm_model* asm_model_list::operator[] | ( | int | index | ) | const |
Returns the assembly model at the given index from the list.
Role: This method returns NULL if the given index is out of range, or the constant LIST_ENTRY_DELETED if the indexed assembly model was removed from the list.
| index | integer. |
| int asm_model_list::remove | ( | int | index | ) |
Remove the entry at the specified index from the list and return its index.
Role: Same as asm_model_list::remove.
| index | index of entry to remove. |
| void asm_model_list::remove | ( | const asm_model_list & | model_list | ) |
Removes asm models in the given list from the list; however, it does not free space.
Role: Same as asm_model_list::remove for a list of models.
| model_list | asm_model list. |
| int asm_model_list::remove | ( | const asm_model * | model | ) |
Remove the specified entry from the list and return its index.
Role: If the counting mechanism is turned on and entry count of the specified entry is greater than one, then that count is decremented and the entry is not actually deleted from the list. The entry is deleted from the list only when the entry count reaches zero. When the entry is deleted from the list, a tombstone is left in its place. The count of the list is not reduced, the iteration_count, however, is. If holding is turned on, the model's use count is decremented when the object is deleted from the list.
| model | entry to remove |
| int asm_model_list::remove_notify | ( | const asm_model * | model, | |
| logical & | was_removed, | |||
| int & | list_count | |||
| ) |
Remove the specified entry from the list and return its index.
Role: Same as asm_model_list::remove, but the caller is notified if the entry is actually deleted the list and the entry count of the removed entry is returned.
| model | entry to remove | |
| was_removed | notify if deleted from list. | |
| list_count | number of adds minus removes |
| void asm_model_list::reverse | ( | logical | compress = TRUE |
) |
Reverses the order of the assembly model list.
Role: If the compress flag is TRUE, tombstones associated with deleted models are removed.
| compress | remove deleted entries. |
| void asm_model_list::set_hold_state | ( | asm_hold_state | state | ) |
Sets the hold state of the model list.
Role: If holding is turned on, the use count of all active entries of the list is incremented.
| state | hold state. |
| void asm_model_list::sort | ( | int(*)(const void *model1, const void *model2) | compare_func | ) |
Sorts the list based upon the user-supplied comparison function.
Role: Implements the runtime qsort function to sort the list and expects the input compare funcion to have the same behavior as described for qsort. The return value should be less than zero if model1 is less than model2, greater than zero if model1 is greater than model2, and zero if they are the same. Tombstones are removed bofore sorting and do not have to be considered by the compare function. The sorted list is obviously re-indexed, which may occur even when the list does not actually require sorting changes.
| compare_func | comparison function |