OOF2: The Manual
Name
IteratorP — An IndexP that can loop over a range of values
Synopses
C++ Synopsis
#include "engine/fieldindex.h"class IteratorP: , public IndexP {IteratorP(FieldIterator* iterator);
IteratorP(const IteratorP& other);
operator const FieldIndex*();
operator const FieldIterator*();
void operator++();
bool end() const;
IteratorP cloneIterator() const;
}
Python Synopsis
from oof2.SWIG.engine.fieldindex import IteratorPclass IteratorP(IndexP):def next(self)
def end(self)
def cloneIterator(self)
Description
IteratorP
is a wrapper for FieldIterator
,
just like its base class, IndexP
,
is a wrapper for FieldIterator
's
bases class, FieldIndex
.
All of the public FieldIterator
and
FieldIndex
methods are available in
IteratorP
.
Note that IteratorP
, like
IndexP
, does not
do reference counting. It's not a smart pointer class. It
just allows functions that would otherwise have to work with
a pointer to work with an object instead.
For example, the following code loops over all components of
a Field
field
and prints the value of each
component at a given node
of a
mesh
:
for(IteratorP iter=field.iterator(ALL_INDICES); !iter.end(); ++iter
) { std::cout << field.value(mesh, node, iter.integer()
)
<< std::endl; }
See IteratorP::end .
|
|
See IteratorP::operator++ .
|
|
See IndexP::integer .
|
|
See Field::value .
|
Methods
IteratorP(FieldIterator *iterator)
The IteratorP
constructor's
argument must be a pointer to a newly created instance of
a FieldIterator
subclass. The IteratorP
takes over
ownership of the FieldIterator
and
will delete it when necessary.
![]() |
Note |
---|---|
The |
IteratorP(const IteratorP& other)
The IteratorP
copy constructor
creates a copy of the underlying
FieldIterator
object as well.
operator const FieldIndex*()
This allows an IteratorP
to be used
where a FieldIndex
pointer is expected. The
FieldIndex
is set to the current
value of the IteratorP
.
For some reason lost in the mists of time, the base class
IndexP
has operator
const FieldIndex&
and
IteratorP
has operator
FieldIndex*
.
operator const FieldIterator*()
This allows an IteratorP
to be used
where a FieldIterator
pointer is expected. The
FieldIterator
is set to the current
value of the IteratorP
.
void operator++(), next()
In C++, operator++
increments an
IteratorP
, causing it to refer to
the next index in the series. In Python, the
next
function plays the same role.
bool end() const
end
returns
true
if the
IteratorP
has reached the end of
its range. The IteratorP
should
not be used afterwards.
IteratorP cloneIterator() const
cloneIterator
is a wrapper around
the copy constructor. It's useful to have an explicit
name for it in cases where one wants to clearly
distinguish between cloneIterator
and the base class function cloneIndex
.