GlobalObjects
Loading...
Searching...
No Matches
ptl::AVDVList Class Reference

Base class for void-pointer lists. More...

#include <PtlAVDVList.h>

Inheritance diagram for ptl::AVDVList:

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)
 
AVDVListoperator= (const AVDVList &rList)
 
virtual void removeAll ()
 

Protected Member Functions

virtual int _addElementFrom (const AVDVList &rList)
 
DVElementinsertSrc (void *pDataObject, DVElement *pReferenceDVElement, VH eBeforeBehind)
 
DVElementremoveSrc (DVElement *pDeadDVElement)
 

Protected Attributes

ListMode m_eListMode
 
int m_iErrorCode
 
std::size_t m_nSize
 
DVElementm_pFirstDVElement
 
DVElementm_pLastDVElement
 

Detailed Description

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.

Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ AVDVList() [1/2]

ptl::AVDVList::AVDVList ( ListMode eMode = DEFAULT)

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.

Parameters
[in]eModeThe list mode

◆ ~AVDVList()

virtual ptl::AVDVList::~AVDVList ( )
virtual

Destructor, emptying list.

◆ AVDVList() [2/2]

ptl::AVDVList::AVDVList ( const AVDVList & rList)

Copy constructor.

Parameters
[in]rListThe list to be copied.
Exceptions
eut::ErrorNExceptionIf an error occurs, a exception is thrown.

Member Function Documentation

◆ _addElementFrom()

virtual int ptl::AVDVList::_addElementFrom ( const AVDVList & rList)
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!

Parameters
[in]rListThe list from which the elements are taken.
Returns
A return value <0 indicates an error.

◆ get()

virtual void * ptl::AVDVList::get ( ElementPosition eElementPos)
virtual

Returns a pointer to the data from passed eElementPos.

Parameters
[in]eElementPosWhich data should be delivered; that of the first or the last element. Possible values are ptl::FIRST_POS and ptl::LAST_POS.
Returns
The return value is the pointer to the data, otherwise NULL_PTR.

Example 1:

ptl::AVDVList * myVDVList = new ptl::AVDVList();
DataObject * pDataObject;
...
if ( pDataObject = static_cast<DataObject*>( myVDVList->get(ptl::FIRST_POS) ) )
{
pDataObject->MachWas();
}
Base class for void-pointer lists.
Definition PtlAVDVList.h:77
virtual void * get(ElementPosition eElementPos)
@ FIRST_POS
Definition PtlListTypes.h:107

The DataObject from the first PtlDV element from the list is delivered if it exists, otherwise NULL_PTR.

Example 2:

ptl::AVDVList * myVDVList = new ptl::AVDVList();
DataObject * pDataObject;
...
if ( pDataObject = static_cast<DataObject*>( myVDVList->get(ptl::LAST_POS) ) )
{
pDataObject->MachWas();
}
@ LAST_POS
Definition PtlListTypes.h:108

The DataObject from the last PtlDV element from the list is delivered if it exists, otherwise NULL_PTR.

See also
ElementPosition, m_pFirstDVElement und m_pLastDVElement

Reimplemented in ptl::VDVList.

◆ getErrorCode()

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.

Returns
A return value < 0 indicates an error.
See also
ERRORS

◆ getListMode()

ListMode ptl::AVDVList::getListMode ( )

Returns the List mode.

Returns
The ListMode ptl::RESPONSIBLE is only possible for template lists that use this class. A combination of the values can also be supplied.
See also
ListMode Example:
...
// if myList with UNIQUE-Bit...
if (myList.getListMode() & UNIQUE)
{
// ...do something...
}
ListMode getListMode()
const ListMode UNIQUE
Definition PtlListTypes.h:340

◆ getNumberDataObjects()

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.

Parameters
[in]pDataObjectThe pointer to the object
Returns
The frequency of occurrence of pDataObject

Example:

DataObject * pDataObject = new DataObject();
...
std::size_t nObjCopunter = myList.getNumberDataObjects(pDataObject);
std::size_t getNumberDataObjects(void *pDataObject)

◆ getSize()

std::size_t ptl::AVDVList::getSize ( )

Returns the number of elements contained in the list.

Returns
The number of elements

Example:

int iSize = myListe.getSize()
std::size_t getSize()

◆ insert()

virtual int ptl::AVDVList::insert ( void * pDataObject,
InsertPosition eWhere = InsertLAST,
VH eBeforeBehind = BEHIND )
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.

Parameters
[in]pDataObjectIs a pointer to the data object. If this parameter is NULL_PTR, nothing is inserted.
[in]eWhereShows where the data object is inserted in the list is to be. Possible parameters are InsertHEAD and InsertLAST.
[in]eBeforeBehindSpecifies whether the new element is to be placed before or after the, element specified in the eWhere parameter. Possible Parameters are BEFORE and BEHIND.
Returns
A return value < 0 indicates an error. The following errors are possible: PASSED_NO_OBJECT, INSTANTIATE_DVELEMENT and OBJECT_ALREADY_AVAILABLE (only at UNIQUE).

Example 1:

int iErr = 0;
ptl::AVDVList * myVDVList = new ptl::AVDVList();
DataObject * pDataObject = new DataObject();
iErr = myVDVList->insert(pDataObject, InsertLAST, BEHIND);
virtual int insert(void *pDataObject, InsertPosition eWhere=InsertLAST, VH eBeforeBehind=BEHIND)
@ InsertLAST
Definition PtlListTypes.h:189
@ BEHIND
Definition PtlListTypes.h:145

The DataObject is positioned at the end of the list after the last DVElement (m_pLastDVElement).

Example 2:

iErr = myVDVList->insert(pDataObject, InsertLAST, BEFORE);
@ BEFORE
Definition PtlListTypes.h:144

The DataObject is positioned at the end of the list before the last DVElement (m_pLastDVElement).

Example 3:

iErr = myVDVList->insert(pDataObject, InsertHEAD, BEHIND);
@ InsertHEAD
Definition PtlListTypes.h:188

The DataObject is positioned at the beginning of the list after the first DVElement (m_pFirstDVElement).

Example 4:

iErr = myVDVList->insert(pDataObject, InsertHEAD, BEFORE);

The DataObject is positioned at the beginning of the list before the first DVElement (m_pFirstDVElement).

Reimplemented in ptl::VDVList.

◆ insertSrc()

DVElement * ptl::AVDVList::insertSrc ( void * pDataObject,
DVElement * pReferenceDVElement,
VH eBeforeBehind )
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.

Parameters
[in]pDataObjectPointer to the data object. If this parameter is NULL_PTR, no new DVElement is inserted.
[in]pReferenceDVElementThe reference element where the new DVElement is inserted before or appended.
[in]eBeforeBehindSpecifies whether new DVElement is appended to reference element is inserted (BEFORE) or appended (BEHIND).
Returns
The DVElement with reference to the passed pDataObject

◆ operator=()

AVDVList & ptl::AVDVList::operator= ( const AVDVList & rList)

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.

Parameters
[in]rListThe list to be assigned.

It should be called after call getErrorCode().

◆ removeAll()

virtual void ptl::AVDVList::removeAll ( )
virtual

All DVElements are removed from the list and from memory.

Reimplemented in ptl::VDVList.

◆ removeSrc()

DVElement * ptl::AVDVList::removeSrc ( DVElement * pDeadDVElement)
protected

Removes passed DVElement from the list

Parameters
[in]pDeadDVElementThe DVElement to be removed
Returns
If a subsequent DVElement is present, it is returned, otherwise the previous DVElement. If the passed DVElement was the last in the list, NULL_PTR is returned.

Member Data Documentation

◆ m_eListMode

ListMode ptl::AVDVList::m_eListMode
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.

◆ m_iErrorCode

int ptl::AVDVList::m_iErrorCode
protected

An error code is stored here (e.g. if something goes wrong during instantiation).

◆ m_nSize

std::size_t ptl::AVDVList::m_nSize
protected

Number of elements contained in the list.

◆ m_pFirstDVElement

DVElement* ptl::AVDVList::m_pFirstDVElement
protected

Pointer to the first element in the list. If List is empty, this attribute equals NULL_PTR.

◆ m_pLastDVElement

DVElement* ptl::AVDVList::m_pLastDVElement
protected

Pointer to the last element in the list. If List is empty, this attribute equals NULL_PTR.


The documentation for this class was generated from the following file: