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

A void-pointer list. More...

#include <PtlVDVList.h>

Inheritance diagram for ptl::VDVList:

Public Member Functions

 VDVList (const VDVList &rList)
 
 VDVList (ListMode eMode=DEFAULT)
 
virtual ~VDVList ()
 
virtual int addElementFrom (const VDVList &rList)
 
int currentElementCache (ElementCache eWhich)
 
virtual void * get (ElementPosition eElementPos=FIRST_POS) override
 
int get (void *&prRetVal, std::size_t nPosition, DVElement *pRefElement)
 
int get (void *&prRetVal, std::size_t nPosition, SeekMode eMode)
 
virtual int insert (void *pDataObject, InsertPosition eWhere=InsertLAST, VH eBeforeBehind=BEHIND) override
 
VDVListoperator= (const VDVList &rList)
 
int remove (ElementPosition eElementPos=CURRENT_POS)
 
virtual void removeAll () override
 
int setCurrentPosition (void *pDataObject)
 
- Public Member Functions inherited from ptl::AVDVList
 AVDVList (const AVDVList &rList)
 
 AVDVList (ListMode eMode=DEFAULT)
 
virtual ~AVDVList ()
 
int getErrorCode ()
 
ListMode getListMode ()
 
std::size_t getNumberDataObjects (void *pDataObject)
 
std::size_t getSize ()
 
AVDVListoperator= (const AVDVList &rList)
 

Protected Attributes

DVElementm_pCurrentDVElement
 
DVElementm_pTempCurrentDVElement
 
- Protected Attributes inherited from ptl::AVDVList
ListMode m_eListMode
 
int m_iErrorCode
 
std::size_t m_nSize
 
DVElementm_pFirstDVElement
 
DVElementm_pLastDVElement
 

Additional Inherited Members

- Protected Member Functions inherited from ptl::AVDVList
virtual int _addElementFrom (const AVDVList &rList)
 
DVElementinsertSrc (void *pDataObject, DVElement *pReferenceDVElement, VH eBeforeBehind)
 
DVElementremoveSrc (DVElement *pDeadDVElement)
 

Detailed Description

A void-pointer list.

A VDVList consists of list elements of type DVElement, which pointers to the objects to be managed. The first, last and current element can be queried. In addition, a subsequent one can be requested, or previous element (with respect to the current element) can be selected.

An element can be inserted before or after the first, last and current element will be. This can be restricted by setting a UNIQUE list in the following way that objects may only appear once in the list.

Note
This class works with void pointers and is therefore not type-safe. It it is recommended to use the template class TDVList.
Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ VDVList() [1/2]

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

constructor with optional parameter passing. The list is empty at first. You can use the parameter UNIQUE to create a list that only takes a data object once.

Parameters
[in]eModeThe list mode

◆ ~VDVList()

virtual ptl::VDVList::~VDVList ( )
virtual

Destructor.

◆ VDVList() [2/2]

ptl::VDVList::VDVList ( const VDVList & rList)

Copy constructor.

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

Member Function Documentation

◆ addElementFrom()

virtual int ptl::VDVList::addElementFrom ( const VDVList & rList)
virtual

Copies all list elements of type DVElement from rList to this list. Also used by VDVList::operator=.

See also
AVDVList::_addElementFrom(...)
Parameters
[in]rListThe list from which the objects are taken.
Returns
A return value < 0 indicates an error.

◆ currentElementCache()

int ptl::VDVList::currentElementCache ( ElementCache eWhich)

This method allows you to cache or restore the current pointer.

See also
m_pCurrentDVElement element and m_pTempCurrentDVElement element.
Parameters
[in]eWhichSpecifies whether the pointer to the current element is cached (M) or restored (RM).
Returns
A return value < 0 indicates an error.

◆ get() [1/3]

virtual void * ptl::VDVList::get ( ElementPosition eElementPos = FIRST_POS)
overridevirtual

Returns a void pointer to the data from the position specified in the parameter.

If an element was delivered, it becomes the current element, otherwise the current element remains what it was.

Parameters
[in]eElementPosWhich data should be delivered? Possible values are FIRST_POS, LAST_POS, CURRENT_POS, NEXT_POS or PREVIOUS_POS.
Returns
The return value is the pointer to the data, otherwise NULL_PTR.

Reimplemented from ptl::AVDVList.

◆ get() [2/3]

int ptl::VDVList::get ( void *& prRetVal,
std::size_t nPosition,
DVElement * pRefElement )

Returns a void pointer to an object in prRetVal from passed position with respect to passed pointer to an element.

Parameters
[in,out]prRetValIn the passed void pointer a found object is returned.
[in]nPositionThe position relative to the transferred pRefElement
[in]pRefElementThe reference element
Returns
A return < 0 indicates an error. A return == RANGE indicates the end of the list.

◆ get() [3/3]

int ptl::VDVList::get ( void *& prRetVal,
std::size_t nPosition,
SeekMode eMode )

Returns a void pointer to an object in prRetVal from the list with respect to the transfer parameters.

You can use this method to iterate through the list.

Parameters
[in,out]prRetValIn the passed pointer a found object delivered.
[in]nPositionThe position relative to the search mode.
[in]eModeThe search mode.
Returns
A return < 0 indicates an error. A return == RANGE indicates the end of the list.

Parameter examples:

  • lPosition = 0; eMode = START -> Delivers first element from list
  • lPosition = 0; eMode = END -> Delivers last element from list
  • lPosition = 0; eMode = CURRENT -> Delivers current element from list
  • lPosition = 1; eMode = CURRENT -> Delivers next element from list
  • lPosition = 2; eMode = CURRENT -> Delivers the next but one element from the list
  • lPosition = -1; eMode = CURRENT -> Returns previous element from list

◆ insert()

virtual int ptl::VDVList::insert ( void * pDataObject,
InsertPosition eWhere = InsertLAST,
VH eBeforeBehind = BEHIND )
overridevirtual

This method inserts the void pointer to a data object in the list. The current element is set to the new element.

If the list was instantiated with parameter UNIQUE and the data object is already in the list, it is not inserted.

Parameters
[in]pDataObjectIs the void pointer to the data object.
[in]eWhereIndicates where the data object is to be inserted in the list. Possible parameters are InsertHEAD, InsertLAST and InsertCURRENT .
[in]eBeforeBehindIndicates whether the new element is 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).

Reimplemented from ptl::AVDVList.

◆ operator=()

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

Assignment operator=

During an assignment, all own DVElements are removed 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().

◆ remove()

int ptl::VDVList::remove ( ElementPosition eElementPos = CURRENT_POS)

Removes the element specified as parameter from the list.

If a subsequent element exists, it becomes the current element, otherwise the previous element, if it exists.

Parameters
[in]eElementPosPossible values are FIRST_POS, LAST_POS and CURRENT.
Returns
A return value < 0 indicates an error.

◆ removeAll()

virtual void ptl::VDVList::removeAll ( )
overridevirtual

Removes all elements from the list.

Reimplemented from ptl::AVDVList.

◆ setCurrentPosition()

int ptl::VDVList::setCurrentPosition ( void * pDataObject)

If there is a PtlDV element with the passed pointer in the list, the current pointer is set to the PtlDV element, otherwise the current pointer remains what it was.

Parameters
[in]pDataObjectThe data object you are looking for
Returns
A return value < 0 indicates an error.

Member Data Documentation

◆ m_pCurrentDVElement

DVElement* ptl::VDVList::m_pCurrentDVElement
protected

The reference to the current element in the list. If the list is empty, the current element is equal to NULL_PTR.

◆ m_pTempCurrentDVElement

DVElement* ptl::VDVList::m_pTempCurrentDVElement
protected

This attribute is a cache of the current element. It is set in the currentElementCache (...) method.


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