Developer

API Reference

IVectorModel_Add()

Brew Release
Brew MP 1.0.2
See Also
Model Events ListModelEvent IVectorModel Interface IVectorModel_EnsureCapacity()
Description
This function adds a new item to a vector model, adding the item at the end of the current list of stored items. The item being added to the model is referenced by a pointer to the item's contents, with the pointer (rather than the contents) actually being stored in the vector model.
Parameters
  • pif
    []:
    Pointer to the IVectorModel interface object.
  • pvItem
    []:
    Pointer to the contents of the item being added to the vector model.
Interface
Prototype
   int IVectorModel_Add(IVectorModel *pif, void *pvItem)
Return
   AEE_SUCCESS    - The item was successfully added to the vector model.
   AEE_ENOMEMORY  - The vector model was unable to allocate enough memory to accommodate the new item.
Side Effect
Adding an item to a vector model by calling IVectorModel_Add() will cause BREW to send an EVT_MDL_LIST_CHANGE ListModelEvent to any object that has registered as a listener with the model.
The fields of the ListModelEvent will contain the following information:
       pos:      The position in the vector model where the new item has been added.  When
                 adding at the end of the vector model this value will be equal to the number
                 of items in the model prior to calling IVectorModel_Add().
       oldSize:  The number of items in the vector model before calling IVectorModel_Add().
       newSize:  The number of items in the vector model after calling IVectorModel_Add().

Comment
IVectorModel_Add() will check to see if there is sufficient allocated space already available in the vector model and use that space to store the new item. If space is not available, IVectorModel_Add() will attempt to allocate storage for the new item, and any additional items as previously declared in a call to IVectorModel_EnsureCapacity().
  • Follow