roscpp overview: Initialization and Shutdown | Basics | Advanced: Traits [ROS C Turtle] | Advanced: Custom Allocators [ROS C Turtle] | Advanced: Serialization and Adapting Types [ROS C Turtle] | Publishers and Subscribers | Services | Parameter Server | Timers (Periodic Callbacks) | NodeHandles | Callbacks and Spinning | Logging | Names and Node Information | Time | Exceptions | Compilation Options | Advanced: Internals | tf/Overview | tf/Tutorials | C++ Style Guide

Custom Container Allocators [ROS 1.1+]

Messages can now use an STL allocator of your choosing to do their container memory allocation.

Simple Use

If you have an allocator you'd like to use with the containers inside a message, the ROS_DECLARE_MESSAGE_WITH_ALLOCATOR macro will let you do it easily:

   1 ROS_DECLARE_MESSAGE_WITH_ALLOCATOR(visualization_msgs::Marker, MyMarker, MyAllocator);

This declares MyMarker as a visualization_msgs::Marker that passes MyAllocator as a template argument to any container types (currently vector and string).

   1 MyMarker marker;

Just like with an STL container, you can also pass an instance of an allocator to the messages' constructor, which will pass it along to the containers:

   1 MyAllocator a;
   2 MyMarker marker2(a);
   3 ...

Wiki: roscpp/Overview/MessagesCustomAllocators (last edited 2010-03-18 01:02:45 by JoshFaust)