PMObjectContainerIter Class Reference
Helperclass to iterate various container types of PMObjectPtr.
More...
#include <PMObjectContainerIter.h>
List of all members.
Detailed Description
Helperclass to iterate various container types of PMObjectPtr.
A PMObjectContainerIter allows to iterate various container classes containing PMObjectPtr or derived classes. The concrete container to iterate is passed as const & to the constructor and hidden inside a pivate helper class.
The public interface allows to iterate all PMObjectPtr stored in the container whithout need to know the concrete containers type.
Example:
void DoSomething( PMObjectContainerIter iter_r )
{
if ( iter_r.size() == 0 )
return; // container is empty
for ( iter_r.setBegin(); !iter_r.
atEnd(); iter_r.setNext() ) {
PMObjectPtr elem = *iter_r;
// do something with elem
}
}
...
{
std::list<PMObjectPtr> objlist;
std::set<PMPackagePtr> pkgset; // PMPackagePtr inherits PMObjectPtr
...
DoSomething( objlist );
DoSomething( pkgset );
...
}
Adding a new container type is quite simple.class PMObjectContainerIter::ContBase
defines the interface any helper class must provide. Create, or use an appropriate existing, helper class derived from PMObjectContainerIter::ContBase
. Provide a constructor that takes the new container type as argument, creates the helper class from it, and stores it in _cont
.
Constructor & Destructor Documentation
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::vector< PMObjectPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::list< PMObjectPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::set< PMObjectPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::vector< PMPackagePtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::list< PMPackagePtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::set< PMPackagePtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::vector< PMSelectionPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::list< PMSelectionPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::set< PMSelectionPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::vector< PMYouPatchPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::list< PMYouPatchPtr > & |
cont_r |
) |
[inline] |
|
PMObjectContainerIter::PMObjectContainerIter |
( |
const std::set< PMYouPatchPtr > & |
cont_r |
) |
[inline] |
|
Member Function Documentation
bool PMObjectContainerIter::atEnd |
( |
|
) |
const [inline] |
|
|
Return true if the iterator reached the end of the container. |
bool PMObjectContainerIter::empty |
( |
|
) |
const [inline] |
|
|
Return true if the container is empty. |
PMObjectPtr PMObjectContainerIter::operator * |
( |
|
) |
const [inline] |
|
|
Return the PMObjectPtr located at the current iterator position. If atEnd() is true, the behaviour is undefined. |
PMObjectPtr PMObjectContainerIter::operator-> |
( |
|
) |
const [inline] |
|
|
Access the PMObject referenced by the PMObjectPtr located at the current iterator position. If atEnd() is true, the behaviour is undefined. It's a shortcut for (*iter)-> .
Keep in mind that operator -> is special. The PMObjectPtr returned is in fact an intermediate result to which the base semantics of -> is then applied, yielding a result. |
void PMObjectContainerIter::setBegin |
( |
|
) |
[inline] |
|
|
Set iterator to the fist element. |
void PMObjectContainerIter::setNext |
( |
|
) |
[inline] |
|
|
Advance iterator to next element. |
unsigned PMObjectContainerIter::size |
( |
|
) |
const [inline] |
|
|
Return the containers size. |
Member Data Documentation
The documentation for this class was generated from the following file:
Generated on Fri Nov 9 14:30:32 2007 for yast2-packagemanager by
1.3.6