Hi
I want to present one of the most used and ancient objects implemented in assembler, called “Collection”.
Collections are, in first instance, repositories for any type of objects, including other collections. Mixing different type of objects in this repository is also allowed.
Collections are designed for administrative use, where very high performance is not required but a high degree of flexibility and processing capabilities. In this regard, Collections provide forward and backward searching, forward and backward iterators, stream serialization, insertion, deletion, positioning, etc. supported in the background by an automatic memory management.
Multithread synchronization is ensured, like OA32, due to the use of the low level build in synchronization call mechanism (xOCall).
There are specialized descendants of “Collection” like sorted collections, string collections, data collections, and many others for different management tasks. You can derive your own descendant, redefining the methods you want to change.
The interface of a Collection object class looks like:
Object Collection, CollectionID, Streamable
VirtualMethod Delete, POINTER
VirtualMethod DeleteAt, DWORD
VirtualMethod DeleteAll
RedefineMethod Deserialize, PDESER_INFO
DynamicMethod DeserializeItem, POINTER, PDESER_INFO
DynamicMethod DestroyItem, POINTER
VirtualMethod Dispose, POINTER
VirtualMethod DisposeAt, DWORD
VirtualMethod DisposeAll
RedefineMethod Done
VirtualMethod FirstThat, POINTER, QWORD, QWORD
VirtualMethod FirstThatNot, POINTER, QWORD, QWORD
VirtualMethod ForEach, POINTER, QWORD, QWORD
VirtualMethod ForEachRev, POINTER, QWORD, QWORD
DynamicMethod GetItem, POB_Stream, PDESER_INFO
VirtualMethod IndexOf, POINTER
RedefineMethod Init, POINTER, DWORD, DWORD, DWORD
VirtualMethod Insert, POINTER
VirtualMethod InsertAt, DWORD, POINTER
VirtualMethod ItemAt, DWORD
VirtualMethod LastThat, POINTER, QWORD, QWORD
VirtualMethod LastThatNot, POINTER, QWORD, QWORD
RedefineMethod Load, POB_Stream, PDESER_INFO
VirtualMethod PutAt, DWORD, POINTER
DynamicMethod PutItem, POB_Stream, POINTER
RedefineMethod Serialize
DynamicMethod SerializeItem, POINTER
RedefineMethod Store, POB_Stream
Private
StaticMethod SetLimit, DWORD
DefineVariable pItems, POINTER, NULL
DefineVariable dCount, DWORD, 0
DefineVariable dLimit, DWORD, 0
DefineVariable dDelta, DWORD, 0
DefineVariable dMaxCapacity, DWORD, 0
DefineVariable ObjLock, ObjectLock, {}
ObjectEnd
It can be observed on the first line, started by the keyword “Object”, 3 elements, the name of the object class (Collection), its unique ID and finally its ancestor. Deriving “Collection” from “Streamable” means, that it inherits all capabilities of a “Streamable” object. This way, we can store the whole content of the “Collection” on an arbitray “Stream”. In most cases this is a disk file (DiskStream) but it can be a memory chunk or whatever is desired.
After the first definition line follow the methods. These define the procedural capabilities of this object. I’ll not comment each one, since the names are self-explanatory. You’ll notice the different method types supported by the ObjAsm64 framework.
Finally, after the method definitions follow the internal variables that are managed by “Collection” and their initial values when created.
If very high performance is an issue, other objects should be used like Linked-Lists or Red-Black-Trees.
I hope this post give you a brief insight to this important OO assembler element.
Best regards, Biterider