GlobalObjects
Loading...
Searching...
No Matches
ptl::TDVList< T_DATA > Class Template Reference

Template list class for pointers to objects. More...

#include <PtlTDVList.h>

Inheritance diagram for ptl::TDVList< T_DATA >:

Public Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from ptl::ATDVList
VDVListm_VDVListe
 

Detailed Description

template<class T_DATA>
class ptl::TDVList< T_DATA >

Template list class for pointers to objects.

A TDVList consists of list elements, which have pointers to the objects to be managed. The first, last and current element can be queried. In addition, it is possible to select by a subsequent or previous element (with respect to the current element).

An element can be inserted before or after the first, last and current element. By setting a UNIQUE list, you can specify that objects may only appear once in the list.

You can delete the first, last or current element, whereby the data object is also deleted, if this (via setting RESPONSIBLE or UNIQUE | RESPONSIBLE) is set.

In order to establish type security, this has been a template class with aggregation on VDVList. With mostly inline methods, equivalent methods are stored in the VDVList called.

Template Parameters
<B>T_DATA</B>Type of list object pointer
Author
Helmut Jakoby

Constructor & Destructor Documentation

◆ TDVList() [1/2]

template<class T_DATA >
ptl::TDVList< T_DATA >::TDVList ( ListMode eMode = DEFAULT)

Constructor with optional parameter passing.

The list is empty at first. With parameter eMode a list can be instantiated, which includes data objects several times (no parameter or DEFAULT) or only once (UNIQUE) and/or should be the owner of the data objects (RESPONSIBLE). The values can be passed as OR-linked (e.g. UNIQUE | RESPONSIBLE).

Parameters
[in]eModeThe list mode

<"Example"?

TestObject * pMyTestObject = new TestObject();
Template list class for pointers to objects.
Definition PtlTDVList.h:98

◆ ~TDVList()

template<class T_DATA >
ptl::TDVList< T_DATA >::~TDVList ( )
virtual

Destructor, the list will be cleared.

If the list was instantiated with parameter RESPONSIBLE, all data objects are also destroyed.

◆ TDVList() [2/2]

template<class T_DATA >
ptl::TDVList< T_DATA >::TDVList ( const TDVList< T_DATA > & rList)

Copy constructor.

Parameters
[in]rListThe list whose pointers to objects are copied to this list.
Exceptions
eut::ErrorNExceptionIf an error occurs, a exception is thrown.

Member Function Documentation

◆ addElementFrom()

template<class T_DATA >
int ptl::TDVList< T_DATA >::addElementFrom ( TDVList< T_DATA > & rList)
virtual

Copies all list elements of parameter rList to this list.

You can copy data objects from subclasses, as well as subclasses can transfer data objects among themselves. There are not duplicates the data objects, but only the pointers to them.

If there was a current element, it remains what it was, otherwise the last element will be to the current element.

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

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

◆ get() [1/3]

template<class T_DATA >
T_DATA * ptl::TDVList< T_DATA >::get ( ElementPosition eElementPos = FIRST_POS)
virtual

Returns a pointer to a data object from the element 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]eElementPosFrom which position should the data object be delivered? Possible values are FIRST_POS, LAST_POS, CURRENT_POS, NEXT_POS or PREVIOUS_POS.
Returns
The pointer to the data object, otherwise NULL_PTR.

◆ get() [2/3]

template<class T_DATA >
int ptl::TDVList< T_DATA >::get ( T_DATA *& prRetVal,
std::size_t nPosition,
DVElement * pRefElement )

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

Parameters
[in,out]prRetValIn the passed 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]

template<class T_DATA >
int ptl::TDVList< T_DATA >::get ( T_DATA *& prRetVal,
std::size_t nPosition,
SeekMode eMode )

Returns a 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

◆ getListMode()

template<class T_DATA >
ListMode ptl::TDVList< T_DATA >::getListMode ( )
overridevirtual

Returns the List mode.

Returns
The ListMode which use this class. A combination of the values can also be returned.

Implements ptl::ATDVList.

◆ getNumberDataObjects()

template<class T_DATA >
size_t ptl::TDVList< T_DATA >::getNumberDataObjects ( T_DATA * pDataObject)

Returns the number of data objects that are equal to the passed data object.

Parameters
[in]pDataObjectThe pointer to the object
Returns
The frequency of occurrence of pDataObject
See also
AVDVList::getNumberDataObjects(...)

◆ insert()

template<class T_DATA >
int ptl::TDVList< T_DATA >::insert ( T_DATA * pDataObject,
InsertPosition eWhere = InsertLAST,
VH eBeforeBehind = BEHIND )
virtual

This method inserts the 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 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).

◆ operator=()

template<class T_DATA >
TDVList< T_DATA > & ptl::TDVList< T_DATA >::operator= ( const TDVList< T_DATA > & rList)

Assignment operator=

When an assignment is made, all elements are removed from this list (if the list was instantiated with the parameter RESPONSIBLE, all data objects are also destroyed) and then all data objects from the assigning list are transferred to this list.

Parameters
[in]rListThe list to be assigned.

It should be called getErrorCode() after this call.

◆ remove()

template<class T_DATA >
int ptl::TDVList< T_DATA >::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. If list has been instantiated with parameter RESPONSIBLE, the destructor is called by the removed data object.

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

◆ removeAll()

template<class T_DATA >
void ptl::TDVList< T_DATA >::removeAll ( )

Removes all elements from the list.

If the List has been instantiated with the RESPONSIBLE parameter, the destructor is called from each removed data object.

◆ setCurrentPosition()

template<class T_DATA >
int ptl::TDVList< T_DATA >::setCurrentPosition ( T_DATA * pDataObject)

If there is a PtlDV element in the list with a passed pointer, 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.

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