Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
fc7dabfd
Commit
fc7dabfd
authored
Jul 07, 2016
by
Janis Born
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add C++11 range adapter for ObjectIterator
parent
d93660cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
BasePlugin/PluginFunctions.cc
BasePlugin/PluginFunctions.cc
+4
-0
BasePlugin/PluginFunctions.hh
BasePlugin/PluginFunctions.hh
+47
-0
No files found.
BasePlugin/PluginFunctions.cc
View file @
fc7dabfd
...
...
@@ -1256,4 +1256,8 @@ void invalidatePickCaches() {
}
}
ObjectRange
objects
(
IteratorRestriction
_restriction
,
DataType
_dataType
)
{
return
ObjectRange
(
_restriction
,
_dataType
);
}
}
// End namespace PluginFunctions
BasePlugin/PluginFunctions.hh
View file @
fc7dabfd
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment