GlobalObjects
|
Base class for void-pointer lists. More...
#include <PtlAVDVList.h>
Public Member Functions | |
AVDVList (const AVDVList &rList) | |
AVDVList (ListMode eMode=DEFAULT) | |
virtual | ~AVDVList () |
virtual void * | get (ElementPosition eElementPos) |
int | getErrorCode () |
ListMode | getListMode () |
std::size_t | getNumberDataObjects (void *pDataObject) |
std::size_t | getSize () |
virtual int | insert (void *pDataObject, InsertPosition eWhere=InsertLAST, VH eBeforeBehind=BEHIND) |
AVDVList & | operator= (const AVDVList &rList) |
virtual void | removeAll () |
Protected Member Functions | |
virtual int | _addElementFrom (const AVDVList &rList) |
DVElement * | insertSrc (void *pDataObject, DVElement *pReferenceDVElement, VH eBeforeBehind) |
DVElement * | removeSrc (DVElement *pDeadDVElement) |
Protected Attributes | |
ListMode | m_eListMode |
int | m_iErrorCode |
std::size_t | m_nSize |
DVElement * | m_pFirstDVElement |
DVElement * | m_pLastDVElement |
Base class for void-pointer lists.
A AVDVList consists of a set of DVElements to which pointers to the objects to be managed are passed.
The first and last can be queried and deleted.
An element can be appended at the beginning or the end. With parameter UNIQUE will include the list of data objects only once.
This class is the base class for VDQueue and VDVList.
Constructor with optional parameter passing. The list is empty at first.You can use the 'UNIQUE' parameter to create a list that includes data objects only once.
[in] | eMode | The list mode |
|
virtual |
Destructor, emptying list.
ptl::AVDVList::AVDVList | ( | const AVDVList & | rList | ) |
Copy constructor.
[in] | rList | The list to be copied. |
eut::ErrorNException | If an error occurs, a exception is thrown. |
|
protectedvirtual |
Copies all list elements of parameter rList to this list.
Is used by operator=.
Data objects from subclasses can be adopted, just as the subclasses can transfer data objects among themselves.
The data objects are not duplicated!
[in] | rList | The list from which the elements are taken. |
|
virtual |
Returns a pointer to the data from passed eElementPos.
[in] | eElementPos | Which data should be delivered; that of the first or the last element. Possible values are ptl::FIRST_POS and ptl::LAST_POS. |
Example 1:
The DataObject from the first PtlDV element from the list is delivered if it exists, otherwise NULL_PTR.
Example 2:
The DataObject from the last PtlDV element from the list is delivered if it exists, otherwise NULL_PTR.
Reimplemented in ptl::VDVList.
int ptl::AVDVList::getErrorCode | ( | ) |
Returns the last error code.
Should be called after insert methods to check whether errors have occurred.
If the error INSTANTIATE_DVELEMENT occurred, the instance should be deleted if no other error handling is implemented in subclasses.
ListMode ptl::AVDVList::getListMode | ( | ) |
Returns the List mode.
std::size_t ptl::AVDVList::getNumberDataObjects | ( | void * | pDataObject | ) |
Returns the number of data objects that are equal to the passed pointer of the data object.
[in] | pDataObject | The pointer to the object |
Example:
std::size_t ptl::AVDVList::getSize | ( | ) |
Returns the number of elements contained in the list.
Example:
|
virtual |
This method inserts data objects into the list.
If the list was instantiated with parameter 'UNIQUE' and the data object is already in the list, it is not inserted.
[in] | pDataObject | Is a pointer to the data object. If this parameter is NULL_PTR, nothing is inserted. |
[in] | eWhere | Shows where the data object is inserted in the list is to be. Possible parameters are InsertHEAD and InsertLAST. |
[in] | eBeforeBehind | Specifies whether the new element is to be placed before or after the, element specified in the eWhere parameter. Possible Parameters are BEFORE and BEHIND. |
Example 1:
The DataObject is positioned at the end of the list after the last DVElement (m_pLastDVElement).
Example 2:
The DataObject is positioned at the end of the list before the last DVElement (m_pLastDVElement).
Example 3:
The DataObject is positioned at the beginning of the list after the first DVElement (m_pFirstDVElement).
Example 4:
The DataObject is positioned at the beginning of the list before the first DVElement (m_pFirstDVElement).
Reimplemented in ptl::VDVList.
|
protected |
Inserts a pDataObject before or after the passed DVElement and returns returns the new PtlDV element.
If the list was instantiated with Prameter UNIQUE, the data object is only inserted if it is not yet in the list.
The attributes m_pFirstDVElement, m_pLastDVElement and m_nSize are updated.
It should be queried via getErrorCode() to check the error code.
[in] | pDataObject | Pointer to the data object. If this parameter is NULL_PTR, no new DVElement is inserted. |
[in] | pReferenceDVElement | The reference element where the new DVElement is inserted before or appended. |
[in] | eBeforeBehind | Specifies whether new DVElement is appended to reference element is inserted (BEFORE) or appended (BEHIND). |
Assignment operator=
During an assignment, all own DVElements are destroyed and then all data objects from the assigning VDVList are transferred to new own DVElements.
[in] | rList | The list to be assigned. |
It should be called after call getErrorCode().
|
virtual |
All DVElements are removed from the list and from memory.
Reimplemented in ptl::VDVList.
|
protected |
For DVLists, whether they allow data objects more than once or only once, or whether they are the owner (responsible, or destroy also the data objects in the destructor) of these data objects.
|
protected |
An error code is stored here (e.g. if something goes wrong during instantiation).
|
protected |
Number of elements contained in the list.
|
protected |
Pointer to the first element in the list. If List is empty, this attribute equals NULL_PTR.
|
protected |
Pointer to the last element in the list. If List is empty, this attribute equals NULL_PTR.