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
|
template<class ObjPtr> |
| PMObjectContainerIter::PMObjectContainerIter |
( |
const std::vector< ObjPtr > & |
cont_r |
) |
[inline] |
|
|
template<class ObjPtr> |
| PMObjectContainerIter::PMObjectContainerIter |
( |
const std::list< ObjPtr > & |
cont_r |
) |
[inline] |
|
|
template<class ObjPtr> |
| PMObjectContainerIter::PMObjectContainerIter |
( |
const std::set< ObjPtr > & |
cont_r |
) |
[inline] |
|
|
template<typename Tp, class ObjPtr> |
| PMObjectContainerIter::PMObjectContainerIter |
( |
const std::map< Tp, ObjPtr > & |
cont_r |
) |
[inline] |
|
| PMObjectContainerIter::~PMObjectContainerIter |
( |
|
) |
[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 Mon Sep 12 21:52:14 2005 for yast2-packagemanager by
1.4.4