Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Manipulators
Description: Manipulators for ecl streams.Keywords: ecl streams manipulators
Tutorial Level: INTERMEDIATE
Contents
Overview
Ecl manipulators are defined to enable some similar functionality to c++'s cout manipulators for ecl's streams. However they extend the concept to use class instantiations rather than functions. This provides one important advantage over the former, these manipulators can retain state. Given that they're also easy to customise, this opens up many possibilities.
The default manipulators defined in the ecl export a few global instantiations, namely
ecl::endl
ecl::clrscr
Usage
Using manipulators follows the same pattern as for standard c++ style cout manipulators.
Creating your own Manipulators
- Any manipulator that you wish to define must inherit from this parent class in the following manner:
include <ecl/streams/manipulators.hpp> class MyManipulator : public ecl::Manipulator<MyManipulator> { template <typename OutputStream> void action (OutputStream& ostream) { // ... } };