Generic array class for holding an array of DataObject's.
#include <Workspace/DataExecution/DataObjects/objectarray.h>
◆ size_type
◆ ObjectArray() [1/4]
◆ ObjectArray() [2/4]
◆ ObjectArray() [3/4]
◆ ObjectArray() [4/4]
◆ ~ObjectArray()
◆ addItem()
Convenience template to push a new object and return a reference. Similar to ObjectDictionary.
◆ back() [1/2]
- Returns
- The last item in the array.
- Precondition
- The array must not be empty.
◆ back() [2/2]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ begin() [1/2]
◆ begin() [2/2]
◆ canSerialize()
bool canSerialize |
( |
| ) |
const |
|
overridevirtual |
- Returns
- Always returns true for an ObjectArray, even if the underlying data type stored in the array does not support serialization. This is because the array itself can be serialized. If the caller needs to know if the array items can be serialized, then they have to check each one for themselves.
Implements Serialize.
◆ capacity()
- Returns
- The number of items the object array can hold before it needs to reallocate itself and therefore copy the contents to a new memory location. By definition, this will always be at least the current size of the array as returned by size().
- Note
- Because the array stores pointers to data objects, the objects themselves are not copied. Instead, only pointers to the objects have to be copied and this is a computationally cheap operation.
- See also
- reserve()
◆ clear()
Clears the array. All data owned by the data objects in the array will be deleted as well. If the data object has data it does not own, that data will continue to exist after this function returns.
◆ empty()
- Returns
- True if the array is empty.
◆ end() [1/2]
◆ end() [2/2]
◆ ensureHasData()
Ensures that all items in the array have valid data by calling each item's ensureHasData() function.
◆ erase()
- Parameters
-
index | The index of the item to remove from the array. It must be less than the result of size(). |
Erases the item at the specified index. The object at that index will be destroyed.
- See also
- insert(), pop_back()
◆ fromQVariant()
bool fromQVariant |
( |
const QVariant & |
v, |
|
|
ObjectArray *& |
data, |
|
|
bool |
deepConvert, |
|
|
bool & |
ownsData |
|
) |
| |
|
static |
◆ front() [1/2]
- Returns
- The first item in the array.
- Precondition
- The array must not be empty.
◆ front() [2/2]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ getFactoryRestriction()
◆ hasData()
- Returns
- True if all items in the array have valid data. If any data object in the array returns false for a call to its hasData() function, then this function also returns false.
◆ insert()
- Parameters
-
obj | The object to insert into the array. A clone of this object will be stored and the array takes ownership of the clone. |
index | The index of the item to insert before. It must not be greater than the result of size(). |
- Returns
- True if obj satisfies the factory restriction (if one is in place) and if obj was able to be cloned.
- See also
- erase(), push_back(), setFactoryRestriction()
◆ isAssignable()
bool isAssignable |
( |
| ) |
const |
◆ load()
- Parameters
-
item | Supplies the state to be loaded into this object group. |
This function will load the state of this object group from item. It will usually be called by an implementation of Serialize::load.
- Precondition
- The immediate children of item must all have unique tag names. Data saved by the save function is guaranteed to satisfy this.
Implements Serialize.
◆ operator!=()
◆ operator=()
◆ operator==()
◆ operator[]() [1/2]
- Parameters
-
index | The index of the object to retrieve. |
- Returns
- The array item at index. No check is made to ensure that index is valid.
◆ operator[]() [2/2]
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
◆ pop_back()
- Precondition
- The array must not be empty.
This function removes the last element of the array. The data object that is at the end of the array will be destroyed.
- See also
- push_back(), erase()
◆ push_back() [1/2]
- Parameters
-
factory | The factory to use to create a new object to be appended to the array. The object's hasData() function will usually return false because it will not normally have any underlying data created by the factory for most data types. |
The main purpose of this function is to push a new item onto the end of the array which the caller will subsequently supply data to. If you want to supply an object to copy directly, use the other overload of this function.
- Returns
- True if factory satisfies the factory restriction if one is in place.
- See also
- pop_back(), setFactoryRestriction()
◆ push_back() [2/2]
- Parameters
-
obj | The object to append into the array. A clone of this object will be stored and the array takes ownership of the clone. |
- Returns
- True if obj satisfies the factory restriction (if one is in place) and if obj was able to be cloned.
- See also
- pop_back(), insert(), setFactoryRestriction()
◆ push_back_copy()
bool push_back_copy |
( |
const T & |
obj | ) |
|
|
inline |
Push a new copy of an object (obj)
◆ push_back_new()
Convenience template to push a new object and return a reference
◆ push_back_ptr()
bool push_back_ptr |
( |
T * |
ptr, |
|
|
bool |
takeOwnership |
|
) |
| |
|
inline |
Push a pointer to existing data (ptr)
◆ reserve()
- Parameters
-
numItems | The number of items that the array must be able to store before a memory reallocation will be needed. |
If numItems is less than the result returned from capacity(), the function has no effect. Otherwise, the memory is reallocated to increase the capacity up to the specified size.
- Postcondition
- The result of size() always remains unchanged. The result of capacity() will be at least numItems.
- See also
- capacity()
◆ resize()
- Parameters
-
newSize | The new size of the array. |
factory | The data factory to use to create new items in the array if it needs to be lengthed. If a factory restriction has been set through a call to setFactoryRestriction() or through the constructor taking a factory as a parameter, then factory must match the factory restriction exactly. |
Items will be appended or deleted from the end of the array as necessary to make it have the specified size. All existing objects in the first newSize elements of the array will continue to exist unchanged, since the array stores pointers to objects and therefore does not need to copy or clone objects in order to resize the array.
◆ save()
- Parameters
-
item | Where to save the state of this array. |
This function will serialise the array by saving each object it contains to item. If an item is not serializable, it will be silently skipped. At the very least, an array will always have its size included in the serialization.
Implements Serialize.
◆ setFactoryRestriction() [1/2]
void setFactoryRestriction |
( |
| ) |
|
|
inline |
◆ setFactoryRestriction() [2/2]
void setFactoryRestriction |
( |
const DataFactory * |
factory | ) |
|
◆ size()
- Returns
- The number of objects in the array.
◆ swap()
- Parameters
-
array | The array with which to swap contents. |
Swapping the contents of two ObjectArray instances is very efficient. No actual array elements are copied. The swap is achieved by swapping the private implementation objects for both arrays, and this usually amounts to little more than assignment of three pointer values.
◆ toQVariant()