Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper-Free
Commits
1111cf45
Commit
1111cf45
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
964898ed
Pipeline
#2276
passed with stage
in 80 minutes and 48 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
OpenFlipper/BasePlugin/PluginFunctions.cc
OpenFlipper/BasePlugin/PluginFunctions.cc
+4
-0
OpenFlipper/BasePlugin/PluginFunctions.hh
OpenFlipper/BasePlugin/PluginFunctions.hh
+47
-0
No files found.
OpenFlipper/BasePlugin/PluginFunctions.cc
View file @
1111cf45
...
...
@@ -1256,4 +1256,8 @@ void invalidatePickCaches() {
}
}
ObjectRange
objects
(
IteratorRestriction
_restriction
,
DataType
_dataType
)
{
return
ObjectRange
(
_restriction
,
_dataType
);
}
}
// End namespace PluginFunctions
OpenFlipper/BasePlugin/PluginFunctions.hh
View file @
1111cf45
...
...
@@ -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