Commit 72355e97 authored by Ellen Dekkers's avatar Ellen Dekkers
Browse files

OpenFlipper/BasePlugin: Bugfix base iterator

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5050 383ad7c9-94d9-4d36-a494-682f7c89f535
parent cb3766b6
...@@ -154,7 +154,7 @@ DLLEXPORT ...@@ -154,7 +154,7 @@ DLLEXPORT
bool getObject( const int _identifier , BaseObject*& _object ); bool getObject( const int _identifier , BaseObject*& _object );
/** This functions returns the object with the given id regardless of the type of object. /** This functions returns the object with the given id regardless of the type of object.
* See get_object( int _identifier , BaseObject*& _object ) for more details. * See get_object( int _identifier , ject*& _object ) for more details.
*/ */
DLLEXPORT DLLEXPORT
bool getObject( const int _identifier , BaseObjectData*& _object ); bool getObject( const int _identifier , BaseObjectData*& _object );
...@@ -451,11 +451,6 @@ class DLLEXPORT BaseObjectIterator { ...@@ -451,11 +451,6 @@ class DLLEXPORT BaseObjectIterator {
/// Restriction of the iterator /// Restriction of the iterator
IteratorRestriction restriction_; IteratorRestriction restriction_;
/** Takes an object and goes through the object tree to the next BaseObject
* It stops at the root node.
*/
inline void proceedToNextBaseObject(BaseObject*& _object);
}; };
// /// Return Iterator to Mesh End // /// Return Iterator to Mesh End
...@@ -467,7 +462,7 @@ ObjectIterator objectsEnd(); ...@@ -467,7 +462,7 @@ ObjectIterator objectsEnd();
/// Return Iterator to Object End /// Return Iterator to Object End
DLLEXPORT DLLEXPORT
ObjectIterator baseObjectsEnd(); BaseObjectIterator baseObjectsEnd();
/** @} */ /** @} */
......
...@@ -59,27 +59,26 @@ BaseObjectIterator::BaseObjectIterator( IteratorRestriction _restriction , DataT ...@@ -59,27 +59,26 @@ BaseObjectIterator::BaseObjectIterator( IteratorRestriction _restriction , DataT
// Start at the root Node // Start at the root Node
BaseObject* currentPos = objectRoot(); BaseObject* currentPos = objectRoot();
// Take the first element which is an BaseObject currentPos = currentPos->next();
proceedToNextBaseObject(currentPos);
while ( (currentPos != objectRoot()) ) { while ( (currentPos != objectRoot()) ) {
// Return only target objects if requested // Return only target objects if requested
if ( (restriction_ == TARGET_OBJECTS) && (! currentPos->target() ) ) { if ( (restriction_ == TARGET_OBJECTS) && (! currentPos->target() ) ) {
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
continue; continue;
} }
// Return only source objects if requested // Return only source objects if requested
if ( (restriction_ == SOURCE_OBJECTS) && (! currentPos->source() ) ) { if ( (restriction_ == SOURCE_OBJECTS) && (! currentPos->source() ) ) {
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
continue; continue;
} }
// Return only the right dataType // Return only the right dataType
if ( _dataType != DATA_ALL ) if ( _dataType != DATA_ALL )
if ( ! (currentPos->dataType( dataType_ ) ) ) { if ( ! (currentPos->dataType( dataType_ ) ) ) {
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
continue; continue;
} }
...@@ -121,25 +120,25 @@ BaseObjectIterator& BaseObjectIterator::operator++() { ...@@ -121,25 +120,25 @@ BaseObjectIterator& BaseObjectIterator::operator++() {
BaseObject* currentPos = dynamic_cast< BaseObject* >(pos_); BaseObject* currentPos = dynamic_cast< BaseObject* >(pos_);
// Get the next objectData element in the tree // Get the next objectData element in the tree
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
while ( (currentPos != objectRoot() ) ) { while ( (currentPos != objectRoot() ) ) {
// Return only target objects if requested // Return only target objects if requested
if ( (restriction_ == TARGET_OBJECTS) && (! currentPos->target() ) ) { if ( (restriction_ == TARGET_OBJECTS) && (! currentPos->target() ) ) {
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
continue; continue;
} }
// Return only source objects if requested // Return only source objects if requested
if ( (restriction_ == SOURCE_OBJECTS) && (! currentPos->source() ) ) { if ( (restriction_ == SOURCE_OBJECTS) && (! currentPos->source() ) ) {
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
continue; continue;
} }
// Return only the right dataType // Return only the right dataType
if ( ! (currentPos->dataType( dataType_ ) ) ) { if ( ! (currentPos->dataType( dataType_ ) ) ) {
proceedToNextBaseObject(currentPos); currentPos = currentPos->next();
continue; continue;
} }
...@@ -168,19 +167,9 @@ BaseObject* BaseObjectIterator::operator*() { ...@@ -168,19 +167,9 @@ BaseObject* BaseObjectIterator::operator*() {
} }
/// Return Iterator to Object End /// Return Iterator to Object End
BaseObjectIterator BaseObjectsEnd() { BaseObjectIterator baseObjectsEnd() {
return BaseObjectIterator(0); return BaseObjectIterator(0);
} }
void BaseObjectIterator::proceedToNextBaseObject(BaseObject*& _object) {
_object = _object->next();
// Go through the tree and stop at the root node or if we found a BaseObject Object
while ( (_object != objectRoot()) )
_object = _object->next();
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment