| Basics of the construction and functionality of HSOK: THSBaseList and descendants |
|
| 20 June 2007 | |||||||||||||||||||||
Page 5 of 9 THSBaseList and descendantsObject lists (THSObjectList), reference lists (THSObjectRefList), strong reference lists (THSStrongRefList) and collections (THSObjectCollection) inherit from the THSBaseList class. This class defines properties and methods common to all lists and optimizes memory management. Each list is implemented as an array of pointers to the elements of the list. The memory for that list is allocated and released in portions of size depending on actual list size. In this way we avoid frequent calls to the memory manager. Besides an obvious property ListCapacity and methods GetObjectCount, GetObjects, AddObject, DeleteObject, DeleteThisObject, MoveObject, ObjectIndex THSBaseList class provides several very useful methods :
THSObjectList class represents a list of objects. It's ObjectClass method must be overridden in descendant classes to specify type of the elements of the list (look at the factory method pattern). THSObjectRefList allows creating lists of "weak" references to other objects and corresponds to a list of standard pointers. THSStrongRefList allows creating lists of "strong" references, described later. Released objects are automatically removed from such lists by HSOK. It simplifies implementation of "indices" to lists of objects (e.g. different kinds of sorting), which automatically correct their content when indexed objects are released. List of "weak" and "strong" references provide two useful methods : FindThisObject and AppendObjectIfNotFound. They use binary search by reference value. These methods may be used to create lists of references that allow quick check whether an object belongs to the list (e.g. list of selected rows in a table view, used to choose the color of the grid cell while drawing it). Collections (THSObjectCollection) allow storing in one list objects of different classes. All classes used to build a collection must be registered in the HSOK kernel object by RegisterClass method in order to be properly read from text files. You don't have to register classes which have edit functions already registered with RegisterEditFunction method. |
|||||||||||||||||||||





