Commit 891fd245 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'object-range' into 'master'

add C++11 range adapter for ObjectIterator



See merge request !122
parents 9ec64d62 1111cf45
Pipeline #2278 passed with stage
in 79 minutes and 47 seconds
......@@ -1256,4 +1256,8 @@ void invalidatePickCaches() {
}
}
ObjectRange objects(IteratorRestriction _restriction, DataType _dataType) {
return ObjectRange(_restriction, _dataType);
}
} // End namespace PluginFunctions
......@@ -521,6 +521,53 @@ class DLLEXPORT ObjectIterator {
};
/** \brief Range adapter for ObjectIterator
*
* An iterator range suitable for iterating over objects using a C++11
* range-based for loop.
*
* \note Use the PluginFunction::objects factory function as a shorthand for
* creating object ranges.
**/
class DLLEXPORT ObjectRange {
public:
explicit ObjectRange(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL) :
restriction_(_restriction),
dataType_(_dataType)
{
}
ObjectIterator begin() const {
return ObjectIterator(restriction_, dataType_);
}
ObjectIterator end() const {
return ObjectIterator(0);
}
private:
IteratorRestriction restriction_;
DataType dataType_;
};
/** \brief Iterable object range
*
* Creates an iterator range suitable for iterating over objects using a C++11
* range-based for loop.
*
* \note Iterated elements are *pointers* to objects, not object references.
* Hence, the loop header should be declared as
* \code
* for (auto* object : PluginFunctions::objects(..., ...) {
* ...
* }
* \endcode
**/
DLLEXPORT
ObjectRange objects(IteratorRestriction _restriction = ALL_OBJECTS , DataType _dataType = DATA_ALL);
/** \brief Core Data Iterator used to iterate over all objects (Including groups)
*
* This iterator is a more low level one not only returning really visible objects but also
......
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