Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

sedris::seIterator Class Reference

#include <seIterator.h>

List of all members.

Public Member Functions

 seIterator ()
 Default constructor.

 seIterator (const seIterator &other)
 Copies another iterator's state into this one.

virtual ~seIterator ()
 Destructor.

seIteratoroperator= (const seIterator &other)
virtual bool operator== (const seIterator &other) const
virtual bool isValid () const
virtual bool isCompleted ()
virtual unsigned int getCount (SE_DRM_Class filter=SE_DRM_CLS_NULL)
virtual bool getNext (seObject &obj, seObject &link_obj)
virtual bool getNext (seObject &obj)
virtual bool getNthNext (unsigned int nth, seObject &obj, seObject &link_obj)
virtual bool getNthNext (unsigned int nth, seObject &obj)
virtual void release ()


Detailed Description

seIterator is the generalized iterator for seObject's.
Author:
Warren Macchi (Accent Geographic)
See also:
seObject, seTransmittal


Constructor & Destructor Documentation

sedris::seIterator::seIterator  )  [inline]
 

sedris::seIterator::seIterator const seIterator other  ) 
 

virtual sedris::seIterator::~seIterator  )  [inline, virtual]
 


Member Function Documentation

virtual unsigned int sedris::seIterator::getCount SE_DRM_Class  filter = SE_DRM_CLS_NULL  )  [virtual]
 

Returns the number of objects remaining in the iterator. An optional DRM class can be used to filter the returned count. For performance reasons do not use this method as a replacement for isCompleted() or use this method as part of a loop test. For example, rather than seeing if an iterator is empty by doing

            if (iter.getCount() > 0) // NOT VERY EFFICIENT
            {
                ... process objects
            }
use instead
            if (!iter.isCompleted()) // BETTER
            {
                ... process objects
            }
And for loops use as
            unsigned int i;
            unsigned int count = iter.getCount();

            for (i=0, i < count; i++)
            {
                ... process ith object
            }
An example of using the filter type to get a count ahead of processing is:
            seIterator iter;
            seObject comp_obj, link_obj;

            poly_obj.getComponentIterator(iter);

            unsigned int vertex_count = iter.getCount(SE_DRM_CLS_VERTEX);
            // here you may allocate an array based on vertex_count

            while (iter.getNext(comp_obj, link_obj))
            {
                // process component, which may or may not be a vertex
            }
Warning:
If the iterator was created with a DRM filter type (i.e. it was not SE_DRM_CLS_NULL) and you pass in a different DRM class type to this method, the result is undefined unless the type passed in is a subclass of the type used to initialize the iterator.
Exceptions:
seException if the count could not be retrieved (due to a file failure, a failed ITR resolution, etc.)
Parameters:
filter in: DRM class to filter the current iterator set
Returns:
number of elements left

virtual bool sedris::seIterator::getNext seObject obj  )  [virtual]
 

Retrieves the next element from the iterator, ignoring the link object.

See also:
getNext(seObject, seObject)
Exceptions:
seException if an error occurs.
Parameters:
obj in/out: a handle to store the next object

virtual bool sedris::seIterator::getNext seObject obj,
seObject link_obj
[virtual]
 

Retrieves the next element and link object from the iterator. As a convenience, this method returns false when the iterator is empty. Hence, you can use code like

            seIterator iter;
            seObject comp_obj, link_obj;

            some_obj.getComponentIterator(iter);
            while (iter.getNext(comp_obj, link_obj))
            {
                ... use comp_obj and link_obj as needed
            }
However, note that the above will not let you continue the loop in the case of an exception occurring in the getNext() call. If you do want to continue the loop, then you should use isCompleted() for the loop test and call getNext() inside the loop in a try/catch statement:
            seIterator iter;
            seObject comp_obj, link_obj;

            some_obj.getComponentIterator(iter);
            while (!iter.isCompleted())
            {
                try {
                    iter.getNext(comp_obj, link_obj);
                    ... use comp_obj and link_obj as needed
                } catch ( seException& e ) {
                    ... process exception
                }
            }

The ITR behaviour of an iterator is dependent on the ITR behaviour set at the workspace level (see seWorkspace::setITRBehaviour()) when the iterator is created. Iterators are typically created by calling one of the "get" iterator methods of an seObject (for example seObject::getComponentIterator()). After the iterator is created, changing the workspace ITR behaviour has no effect on the iterator.

The ITR behaviour value is interpreted as follows:

  • If ITR behaviour is SE_ITR_BHVR_RESOLVE, then all objects returned by the API will be resolved objects. If an object cannot be resolved (for example the referenced transmittal is missing) then an exception will occur (the exception type will be dependent on the failed step, for example it could be UNRESOLVED_TRANSMITTAL, UNPUBLISHED_OBJECT, or some other exception type).
  • If ITR behaviour is SE_ITR_BHVR_REPORT, then when the iterator encounters an ITR reference it will return an unresolved object, no matter what its DRM type may be. You can call seObject::resolve() to attempt to resolve the object if you need to. Note that the current filter DRM class for the iterator is ignored for ITR references when using SE_ITR_BHVR_REPORT. Hence, you should not use seDRMBase-derived classes as parameters to getNext().
  • If ITR behaviour is SE_ITR_BHVR_IGNORE, then ITR references are skipped by the iterator and are never returned.

Note:
If there is no link object associated with the next object, the link object parameter is set to an invalid object handle (i.e. you can use seObject::isValid() to see if a link object was available).

This method respects the DRM ordering of ordered classes.

Warning:
If you use one of the seDRMBase-derived classes as parameters to this method, you must ensure that the derived type will be able to hold a reference to whatever object will be returned, or an exception will occur. If you don't know what type will be returned, you can pass in a base class (such as seObject) and then get the type of the object by using seObject::getDRMClass().
See also:
seWorkspace::setITRBehaviour(), seObject::isResolved()
Exceptions:
seException if an error occurs.
Parameters:
obj in/out: a handle to store the next object
link_obj in/out: a handle to store the next link object (if available)

virtual bool sedris::seIterator::getNthNext unsigned int  nth,
seObject obj
[virtual]
 

Retrieves the Nth next element from the iterator, ignoring the link object. This is a convenience method that skips over the iterator list and returns the next Nth element in the list. When "nth" equals 1, this method is equivalent to calling getNext().

Warning:
Since an iterator is a sequential list, once you request an nth object, calling getNthNext() with the same nth value will NOT return the same object. That is, an iterator always moves forward in its list of objects, never backward.
Note:
This method respects the DRM ordering of ordered classes.

If there is no nth element (i.e. this method returns false), no changes are made to the iterator so that you can continue iterating through its elements as if no method was called.

See also:
getNthNext(unsigned int, seObject, seObject)

virtual bool sedris::seIterator::getNthNext unsigned int  nth,
seObject obj,
seObject link_obj
[virtual]
 

Retrieves the Nth next element from the iterator. This is a convenience method that skips over the iterator list and returns the next Nth element in the list. When "nth" equals 1, this method is equivalent to calling getNext().

See also:
getNext(seObject, seObject)
Exceptions:
seException if an error occurs.
Parameters:
nth in: a number greater than or equal to 1
obj in/out: a handle to store the next object
link_obj in/out: a handle to store the next link object (if available)

virtual bool sedris::seIterator::isCompleted  )  [virtual]
 

Returns true if the iterator will not return any more objects (i.e. getNext() will return false). Sample:

            if (!iter.isCompleted())
            {
                ... process iterator objects 
            }

virtual bool sedris::seIterator::isValid  )  const [inline, virtual]
 

Returns true if this iterator handle is valid, don't confuse with isCompleted().

seIterator& sedris::seIterator::operator= const seIterator other  ) 
 

Copies another iterator's state into this one. You can use this operator to store, for example, a temporary iterator if you need to look ahead somewhat, and then return to where you left off.

Note:
After the iterators are copied, they will both return the same objects after a similar call to getNext() on them.

virtual bool sedris::seIterator::operator== const seIterator other  )  const [virtual]
 

Returns true if the iterators have the same owners, are of the same type, and they will return the same elements on getNext().

virtual void sedris::seIterator::release  )  [virtual]
 

Releases the handle to the iterator. Generally there is no need to call this method, since release() is called by any change of handle or when the object goes out of scope.


The documentation for this class was generated from the following file:
SEDRIS Transmittal Access C++ API 4.0.0 beta - 14 Jul 2004
Copyright © 2004 SEDRIS Docs by Doxygen 1.3.2