Clock.h | Clock.h | |||
---|---|---|---|---|
/* auto-generated by genmsg_cpp from /home/andrey/install/ros-1.0-boxturtle | /* Auto-generated by genmsg_cpp for file /home/andrey/install/ros-2.0-cturt | |||
/ros/core/roslib/msg/Clock.msg. Do not edit! */ | le/ros/core/roslib/msg/Clock.msg */ | |||
#ifndef ROSLIB_CLOCK_H | #ifndef ROSLIB_MESSAGE_CLOCK_H | |||
#define ROSLIB_CLOCK_H | #define ROSLIB_MESSAGE_CLOCK_H | |||
#include <string> | #include <string> | |||
#include <vector> | #include <vector> | |||
#include <ostream> | ||||
#include "ros/serialization.h" | ||||
#include "ros/builtin_message_traits.h" | ||||
#include "ros/message_operations.h" | ||||
#include "ros/message.h" | #include "ros/message.h" | |||
#include "ros/debug.h" | ||||
#include "ros/assert.h" | ||||
#include "ros/time.h" | #include "ros/time.h" | |||
namespace roslib | namespace roslib | |||
{ | { | |||
template <class ContainerAllocator> | ||||
struct Clock_ : public ros::Message | ||||
{ | ||||
typedef Clock_<ContainerAllocator> Type; | ||||
//! \htmlinclude Clock.msg.html | Clock_() | |||
: clock() | ||||
{ | ||||
} | ||||
class Clock : public ros::Message | Clock_(const ContainerAllocator& _alloc) | |||
{ | : clock() | |||
public: | { | |||
typedef boost::shared_ptr<Clock> Ptr; | } | |||
typedef boost::shared_ptr<Clock const> ConstPtr; | ||||
typedef ros::Time _clock_type; | typedef ros::Time _clock_type; | |||
ros::Time clock; | ros::Time clock; | |||
Clock() : ros::Message() | private: | |||
static const char* __s_getDataType_() { return "roslib/Clock"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getDataType() { return __s | ||||
_getDataType_(); } | ||||
ROSCPP_DEPRECATED const std::string __getDataType() const { return __s_ge | ||||
tDataType_(); } | ||||
private: | ||||
static const char* __s_getMD5Sum_() { return "a9c97c1d230cfc112e270351a94 | ||||
4ee47"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getMD5Sum() { return __s_g | ||||
etMD5Sum_(); } | ||||
ROSCPP_DEPRECATED const std::string __getMD5Sum() const { return __s_getM | ||||
D5Sum_(); } | ||||
private: | ||||
static const char* __s_getMessageDefinition_() { return "# roslib/Clock i | ||||
s used for publishing simulated time in ROS. \n\ | ||||
# This message simply communicates the current time.\n\ | ||||
# For more information, see http://www.ros.org/wiki/Clock\n\ | ||||
time clock\n\ | ||||
\n\ | ||||
"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getMessageDefinition() { r | ||||
eturn __s_getMessageDefinition_(); } | ||||
ROSCPP_DEPRECATED const std::string __getMessageDefinition() const { retu | ||||
rn __s_getMessageDefinition_(); } | ||||
ROSCPP_DEPRECATED virtual uint8_t *serialize(uint8_t *write_ptr, uint32_t | ||||
seq) const | ||||
{ | { | |||
ros::serialization::OStream stream(write_ptr, 1000000000); | ||||
ros::serialization::serialize(stream, clock); | ||||
return stream.getData(); | ||||
} | } | |||
Clock(const Clock ©) : ros::Message(), | ||||
clock(copy.clock) | ROSCPP_DEPRECATED virtual uint8_t *deserialize(uint8_t *read_ptr) | |||
{ | { | |||
(void)copy; | ros::serialization::IStream stream(read_ptr, 1000000000); | |||
ros::serialization::deserialize(stream, clock); | ||||
return stream.getData(); | ||||
} | } | |||
Clock &operator =(const Clock ©) | ||||
ROSCPP_DEPRECATED virtual uint32_t serializationLength() const | ||||
{ | { | |||
if (this == ©) | uint32_t size = 0; | |||
return *this; | size += ros::serialization::serializationLength(clock); | |||
clock = copy.clock; | return size; | |||
return *this; | ||||
} | } | |||
virtual ~Clock() | ||||
typedef boost::shared_ptr< ::roslib::Clock_<ContainerAllocator> > Ptr; | ||||
typedef boost::shared_ptr< ::roslib::Clock_<ContainerAllocator> const> C | ||||
onstPtr; | ||||
}; // struct Clock | ||||
typedef ::roslib::Clock_<std::allocator<void> > Clock; | ||||
typedef boost::shared_ptr< ::roslib::Clock> ClockPtr; | ||||
typedef boost::shared_ptr< ::roslib::Clock const> ClockConstPtr; | ||||
template<typename ContainerAllocator> | ||||
std::ostream& operator<<(std::ostream& s, const ::roslib::Clock_<Container | ||||
Allocator> & v) | ||||
{ | ||||
ros::message_operations::Printer< ::roslib::Clock_<ContainerAllocator> >: | ||||
:stream(s, "", v); | ||||
return s;} | ||||
} // namespace roslib | ||||
namespace ros | ||||
{ | ||||
namespace message_traits | ||||
{ | ||||
template<class ContainerAllocator> | ||||
struct MD5Sum< ::roslib::Clock_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
return "a9c97c1d230cfc112e270351a944ee47"; | ||||
} | } | |||
inline static std::string __s_getDataType() { return std::string("roslib/ | ||||
Clock"); } | static const char* value(const ::roslib::Clock_<ContainerAllocator> &) { | |||
inline static std::string __s_getMD5Sum() { return std::string("a9c97c1d2 | return value(); } | |||
30cfc112e270351a944ee47"); } | static const uint64_t static_value1 = 0xa9c97c1d230cfc11ULL; | |||
inline static std::string __s_getMessageDefinition() | static const uint64_t static_value2 = 0x2e270351a944ee47ULL; | |||
}; | ||||
template<class ContainerAllocator> | ||||
struct DataType< ::roslib::Clock_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
return std::string( | return "roslib/Clock"; | |||
"# roslib/Clock is used for publishing simulated time in ROS. \n" | ||||
"# This message simply communicates the current time.\n" | ||||
"# For more information, see http://www.ros.org/wiki/Clock\n" | ||||
"time clock\n" | ||||
"\n" | ||||
"\n" | ||||
); | ||||
} | } | |||
inline virtual const std::string __getDataType() const { return __s_getDa | ||||
taType(); } | static const char* value(const ::roslib::Clock_<ContainerAllocator> &) { | |||
inline virtual const std::string __getMD5Sum() const { return __s_getMD5S | return value(); } | |||
um(); } | }; | |||
inline virtual const std::string __getMessageDefinition() const { return | ||||
__s_getMessageDefinition(); } | template<class ContainerAllocator> | |||
inline uint32_t serializationLength() const | struct Definition< ::roslib::Clock_<ContainerAllocator> > { | |||
static const char* value() | ||||
{ | { | |||
unsigned __l = 0; | return "# roslib/Clock is used for publishing simulated time in ROS. \n | |||
__l += 8; // clock | \ | |||
return __l; | # This message simply communicates the current time.\n\ | |||
# For more information, see http://www.ros.org/wiki/Clock\n\ | ||||
time clock\n\ | ||||
\n\ | ||||
"; | ||||
} | } | |||
virtual uint8_t *serialize(uint8_t *write_ptr, | ||||
#if defined(__GNUC__) | static const char* value(const ::roslib::Clock_<ContainerAllocator> &) { | |||
__attribute__((unused)) uint32_t seq) const | return value(); } | |||
#else | }; | |||
uint32_t seq) const | ||||
#endif | template<class ContainerAllocator> struct IsFixedSize< ::roslib::Clock_<Con | |||
tainerAllocator> > : public TrueType {}; | ||||
} // namespace message_traits | ||||
} // namespace ros | ||||
namespace ros | ||||
{ | ||||
namespace serialization | ||||
{ | ||||
template<class ContainerAllocator> struct Serializer< ::roslib::Clock_<Cont | ||||
ainerAllocator> > | ||||
{ | ||||
template<typename Stream, typename T> inline static void allInOne(Stream& | ||||
stream, T m) | ||||
{ | { | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, clock.sec); | stream.next(m.clock); | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, clock.nsec); | ||||
return write_ptr; | ||||
} | } | |||
virtual uint8_t *deserialize(uint8_t *read_ptr) | ||||
ROS_DECLARE_ALLINONE_SERIALIZER; | ||||
}; // struct Clock_ | ||||
} // namespace serialization | ||||
} // namespace ros | ||||
namespace ros | ||||
{ | ||||
namespace message_operations | ||||
{ | ||||
template<class ContainerAllocator> | ||||
struct Printer< ::roslib::Clock_<ContainerAllocator> > | ||||
{ | ||||
template<typename Stream> static void stream(Stream& s, const std::string | ||||
& indent, const ::roslib::Clock_<ContainerAllocator> & v) | ||||
{ | { | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, clock.sec); | s << indent << "clock: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, clock.nsec); | Printer<ros::Time>::stream(s, indent + " ", v.clock); | |||
return read_ptr; | ||||
} | } | |||
}; | }; | |||
typedef boost::shared_ptr<Clock> ClockPtr; | } // namespace message_operations | |||
typedef boost::shared_ptr<Clock const> ClockConstPtr; | } // namespace ros | |||
} | ||||
#endif | #endif // ROSLIB_MESSAGE_CLOCK_H | |||
End of changes. 25 change blocks. | ||||
64 lines changed or deleted | 164 lines changed or added | |||
Header.h | Header.h | |||
---|---|---|---|---|
/* auto-generated by genmsg_cpp from /home/andrey/install/ros-1.0-boxturtle | /* Auto-generated by genmsg_cpp for file /home/andrey/install/ros-2.0-cturt | |||
/ros/core/roslib/msg/Header.msg. Do not edit! */ | le/ros/core/roslib/msg/Header.msg */ | |||
#ifndef ROSLIB_HEADER_H | #ifndef ROSLIB_MESSAGE_HEADER_H | |||
#define ROSLIB_HEADER_H | #define ROSLIB_MESSAGE_HEADER_H | |||
#include <string> | #include <string> | |||
#include <vector> | #include <vector> | |||
#include <ostream> | ||||
#include "ros/serialization.h" | ||||
#include "ros/builtin_message_traits.h" | ||||
#include "ros/message_operations.h" | ||||
#include "ros/message.h" | #include "ros/message.h" | |||
#include "ros/debug.h" | ||||
#include "ros/assert.h" | ||||
#include "ros/time.h" | #include "ros/time.h" | |||
namespace roslib | namespace roslib | |||
{ | { | |||
template <class ContainerAllocator> | ||||
struct Header_ : public ros::Message | ||||
{ | ||||
typedef Header_<ContainerAllocator> Type; | ||||
//! \htmlinclude Header.msg.html | Header_() | |||
: seq(0) | ||||
, stamp() | ||||
, frame_id() | ||||
{ | ||||
} | ||||
class Header : public ros::Message | Header_(const ContainerAllocator& _alloc) | |||
{ | : seq(0) | |||
public: | , stamp() | |||
typedef boost::shared_ptr<Header> Ptr; | , frame_id(_alloc) | |||
typedef boost::shared_ptr<Header const> ConstPtr; | { | |||
} | ||||
typedef uint32_t _seq_type; | typedef uint32_t _seq_type; | |||
typedef ros::Time _stamp_type; | ||||
typedef std::string _frame_id_type; | ||||
uint32_t seq; | uint32_t seq; | |||
typedef ros::Time _stamp_type; | ||||
ros::Time stamp; | ros::Time stamp; | |||
std::string frame_id; | ||||
Header() : ros::Message(), | typedef std::basic_string<char, std::char_traits<char>, typename Containe | |||
seq(0) | rAllocator::template rebind<char>::other > _frame_id_type; | |||
std::basic_string<char, std::char_traits<char>, typename ContainerAllocat | ||||
or::template rebind<char>::other > frame_id; | ||||
private: | ||||
static const char* __s_getDataType_() { return "roslib/Header"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getDataType() { return __s | ||||
_getDataType_(); } | ||||
ROSCPP_DEPRECATED const std::string __getDataType() const { return __s_ge | ||||
tDataType_(); } | ||||
private: | ||||
static const char* __s_getMD5Sum_() { return "2176decaecbce78abc3b96ef049 | ||||
fabed"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getMD5Sum() { return __s_g | ||||
etMD5Sum_(); } | ||||
ROSCPP_DEPRECATED const std::string __getMD5Sum() const { return __s_getM | ||||
D5Sum_(); } | ||||
private: | ||||
static const char* __s_getMessageDefinition_() { return "# Standard metad | ||||
ata for higher-level stamped data types.\n\ | ||||
# This is generally used to communicate timestamped data \n\ | ||||
# in a particular coordinate frame.\n\ | ||||
# \n\ | ||||
# sequence ID: consecutively increasing ID \n\ | ||||
uint32 seq\n\ | ||||
#Two-integer timestamp that is expressed as:\n\ | ||||
# * stamp.secs: seconds (stamp_secs) since epoch\n\ | ||||
# * stamp.nsecs: nanoseconds since stamp_secs\n\ | ||||
# time-handling sugar is provided by the client library\n\ | ||||
time stamp\n\ | ||||
#Frame this data is associated with\n\ | ||||
# 0: no frame\n\ | ||||
# 1: global frame\n\ | ||||
string frame_id\n\ | ||||
\n\ | ||||
"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getMessageDefinition() { r | ||||
eturn __s_getMessageDefinition_(); } | ||||
ROSCPP_DEPRECATED const std::string __getMessageDefinition() const { retu | ||||
rn __s_getMessageDefinition_(); } | ||||
ROSCPP_DEPRECATED virtual uint8_t *serialize(uint8_t *write_ptr, uint32_t | ||||
seq) const | ||||
{ | { | |||
ros::serialization::OStream stream(write_ptr, 1000000000); | ||||
ros::serialization::serialize(stream, seq); | ||||
ros::serialization::serialize(stream, stamp); | ||||
ros::serialization::serialize(stream, frame_id); | ||||
return stream.getData(); | ||||
} | } | |||
Header(const Header ©) : ros::Message(), | ||||
seq(copy.seq), | ROSCPP_DEPRECATED virtual uint8_t *deserialize(uint8_t *read_ptr) | |||
stamp(copy.stamp), | ||||
frame_id(copy.frame_id) | ||||
{ | { | |||
(void)copy; | ros::serialization::IStream stream(read_ptr, 1000000000); | |||
ros::serialization::deserialize(stream, seq); | ||||
ros::serialization::deserialize(stream, stamp); | ||||
ros::serialization::deserialize(stream, frame_id); | ||||
return stream.getData(); | ||||
} | } | |||
Header &operator =(const Header ©) | ||||
ROSCPP_DEPRECATED virtual uint32_t serializationLength() const | ||||
{ | { | |||
if (this == ©) | uint32_t size = 0; | |||
return *this; | size += ros::serialization::serializationLength(seq); | |||
seq = copy.seq; | size += ros::serialization::serializationLength(stamp); | |||
stamp = copy.stamp; | size += ros::serialization::serializationLength(frame_id); | |||
frame_id = copy.frame_id; | return size; | |||
return *this; | ||||
} | } | |||
virtual ~Header() | ||||
typedef boost::shared_ptr< ::roslib::Header_<ContainerAllocator> > Ptr; | ||||
typedef boost::shared_ptr< ::roslib::Header_<ContainerAllocator> const> | ||||
ConstPtr; | ||||
}; // struct Header | ||||
typedef ::roslib::Header_<std::allocator<void> > Header; | ||||
typedef boost::shared_ptr< ::roslib::Header> HeaderPtr; | ||||
typedef boost::shared_ptr< ::roslib::Header const> HeaderConstPtr; | ||||
template<typename ContainerAllocator> | ||||
std::ostream& operator<<(std::ostream& s, const ::roslib::Header_<Containe | ||||
rAllocator> & v) | ||||
{ | ||||
ros::message_operations::Printer< ::roslib::Header_<ContainerAllocator> > | ||||
::stream(s, "", v); | ||||
return s;} | ||||
} // namespace roslib | ||||
namespace ros | ||||
{ | ||||
namespace message_traits | ||||
{ | ||||
template<class ContainerAllocator> | ||||
struct MD5Sum< ::roslib::Header_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
return "2176decaecbce78abc3b96ef049fabed"; | ||||
} | } | |||
inline static std::string __s_getDataType() { return std::string("roslib/ | ||||
Header"); } | static const char* value(const ::roslib::Header_<ContainerAllocator> &) | |||
inline static std::string __s_getMD5Sum() { return std::string("2176decae | { return value(); } | |||
cbce78abc3b96ef049fabed"); } | static const uint64_t static_value1 = 0x2176decaecbce78aULL; | |||
inline static std::string __s_getMessageDefinition() | static const uint64_t static_value2 = 0xbc3b96ef049fabedULL; | |||
}; | ||||
template<class ContainerAllocator> | ||||
struct DataType< ::roslib::Header_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
return std::string( | return "roslib/Header"; | |||
"# Standard metadata for higher-level stamped data types.\n" | ||||
"# This is generally used to communicate timestamped data \n" | ||||
"# in a particular coordinate frame.\n" | ||||
"# \n" | ||||
"# sequence ID: consecutively increasing ID \n" | ||||
"uint32 seq\n" | ||||
"#Two-integer timestamp that is expressed as:\n" | ||||
"# * stamp.secs: seconds (stamp_secs) since epoch\n" | ||||
"# * stamp.nsecs: nanoseconds since stamp_secs\n" | ||||
"# time-handling sugar is provided by the client library\n" | ||||
"time stamp\n" | ||||
"#Frame this data is associated with\n" | ||||
"# 0: no frame\n" | ||||
"# 1: global frame\n" | ||||
"string frame_id\n" | ||||
"\n" | ||||
"\n" | ||||
); | ||||
} | } | |||
inline virtual const std::string __getDataType() const { return __s_getDa | ||||
taType(); } | static const char* value(const ::roslib::Header_<ContainerAllocator> &) | |||
inline virtual const std::string __getMD5Sum() const { return __s_getMD5S | { return value(); } | |||
um(); } | }; | |||
inline virtual const std::string __getMessageDefinition() const { return | ||||
__s_getMessageDefinition(); } | template<class ContainerAllocator> | |||
inline uint32_t serializationLength() const | struct Definition< ::roslib::Header_<ContainerAllocator> > { | |||
static const char* value() | ||||
{ | { | |||
unsigned __l = 0; | return "# Standard metadata for higher-level stamped data types.\n\ | |||
__l += 4; // seq | # This is generally used to communicate timestamped data \n\ | |||
__l += 8; // stamp | # in a particular coordinate frame.\n\ | |||
__l += 4 + frame_id.length(); // frame_id | # \n\ | |||
return __l; | # sequence ID: consecutively increasing ID \n\ | |||
uint32 seq\n\ | ||||
#Two-integer timestamp that is expressed as:\n\ | ||||
# * stamp.secs: seconds (stamp_secs) since epoch\n\ | ||||
# * stamp.nsecs: nanoseconds since stamp_secs\n\ | ||||
# time-handling sugar is provided by the client library\n\ | ||||
time stamp\n\ | ||||
#Frame this data is associated with\n\ | ||||
# 0: no frame\n\ | ||||
# 1: global frame\n\ | ||||
string frame_id\n\ | ||||
\n\ | ||||
"; | ||||
} | } | |||
virtual uint8_t *serialize(uint8_t *write_ptr, | ||||
#if defined(__GNUC__) | static const char* value(const ::roslib::Header_<ContainerAllocator> &) | |||
__attribute__((unused)) uint32_t seq) const | { return value(); } | |||
#else | }; | |||
uint32_t seq) const | ||||
#endif | } // namespace message_traits | |||
} // namespace ros | ||||
namespace ros | ||||
{ | ||||
namespace serialization | ||||
{ | ||||
template<class ContainerAllocator> struct Serializer< ::roslib::Header_<Con | ||||
tainerAllocator> > | ||||
{ | ||||
template<typename Stream, typename T> inline static void allInOne(Stream& | ||||
stream, T m) | ||||
{ | { | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, seq); | stream.next(m.seq); | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, stamp.sec); | stream.next(m.stamp); | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, stamp.nsec); | stream.next(m.frame_id); | |||
unsigned __ros_frame_id_len = frame_id.length(); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __ros_frame_id_len); | ||||
SROS_SERIALIZE_BUFFER(write_ptr, frame_id.c_str(), __ros_frame_id_len); | ||||
return write_ptr; | ||||
} | } | |||
virtual uint8_t *deserialize(uint8_t *read_ptr) | ||||
ROS_DECLARE_ALLINONE_SERIALIZER; | ||||
}; // struct Header_ | ||||
} // namespace serialization | ||||
} // namespace ros | ||||
namespace ros | ||||
{ | ||||
namespace message_operations | ||||
{ | ||||
template<class ContainerAllocator> | ||||
struct Printer< ::roslib::Header_<ContainerAllocator> > | ||||
{ | ||||
template<typename Stream> static void stream(Stream& s, const std::string | ||||
& indent, const ::roslib::Header_<ContainerAllocator> & v) | ||||
{ | { | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, seq); | s << indent << "seq: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, stamp.sec); | Printer<uint32_t>::stream(s, indent + " ", v.seq); | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, stamp.nsec); | s << indent << "stamp: "; | |||
unsigned __ros_frame_id_len; | Printer<ros::Time>::stream(s, indent + " ", v.stamp); | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __ros_frame_id_len); | s << indent << "frame_id: "; | |||
frame_id = std::string((const char *)read_ptr, __ros_frame_id_len); | Printer<std::basic_string<char, std::char_traits<char>, typename Contai | |||
read_ptr += __ros_frame_id_len; | nerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v. | |||
return read_ptr; | frame_id); | |||
} | } | |||
}; | }; | |||
typedef boost::shared_ptr<Header> HeaderPtr; | } // namespace message_operations | |||
typedef boost::shared_ptr<Header const> HeaderConstPtr; | } // namespace ros | |||
} | ||||
#endif | #endif // ROSLIB_MESSAGE_HEADER_H | |||
End of changes. 27 change blocks. | ||||
94 lines changed or deleted | 208 lines changed or added | |||
Log.h | Log.h | |||
---|---|---|---|---|
/* auto-generated by genmsg_cpp from /home/andrey/install/ros-1.0-boxturtle | /* Auto-generated by genmsg_cpp for file /home/andrey/install/ros-2.0-cturt | |||
/ros/core/roslib/msg/Log.msg. Do not edit! */ | le/ros/core/roslib/msg/Log.msg */ | |||
#ifndef ROSLIB_LOG_H | #ifndef ROSLIB_MESSAGE_LOG_H | |||
#define ROSLIB_LOG_H | #define ROSLIB_MESSAGE_LOG_H | |||
#include <string> | #include <string> | |||
#include <vector> | #include <vector> | |||
#include <ostream> | ||||
#include "ros/serialization.h" | ||||
#include "ros/builtin_message_traits.h" | ||||
#include "ros/message_operations.h" | ||||
#include "ros/message.h" | #include "ros/message.h" | |||
#include "ros/debug.h" | ||||
#include "ros/assert.h" | ||||
#include "ros/time.h" | #include "ros/time.h" | |||
#include "roslib/Header.h" | #include "roslib/Header.h" | |||
namespace roslib | namespace roslib | |||
{ | { | |||
template <class ContainerAllocator> | ||||
struct Log_ : public ros::Message | ||||
{ | ||||
typedef Log_<ContainerAllocator> Type; | ||||
//! \htmlinclude Log.msg.html | Log_() | |||
: header() | ||||
, level(0) | ||||
, name() | ||||
, msg() | ||||
, file() | ||||
, function() | ||||
, line(0) | ||||
, topics() | ||||
{ | ||||
} | ||||
class Log : public ros::Message | Log_(const ContainerAllocator& _alloc) | |||
{ | : header(_alloc) | |||
public: | , level(0) | |||
typedef boost::shared_ptr<Log> Ptr; | , name(_alloc) | |||
typedef boost::shared_ptr<Log const> ConstPtr; | , msg(_alloc) | |||
, file(_alloc) | ||||
, function(_alloc) | ||||
, line(0) | ||||
, topics(_alloc) | ||||
{ | ||||
} | ||||
typedef roslib::Header _header_type; | typedef ::roslib::Header_<ContainerAllocator> _header_type; | |||
typedef int8_t _level_type; | ::roslib::Header_<ContainerAllocator> header; | |||
typedef std::string _name_type; | ||||
typedef std::string _msg_type; | ||||
typedef std::string _file_type; | ||||
typedef std::string _function_type; | ||||
typedef uint32_t _line_type; | ||||
typedef std::vector<std::string> _topics_type; | ||||
const static int8_t DEBUG = 1; | typedef int8_t _level_type; | |||
const static int8_t INFO = 2; | ||||
const static int8_t WARN = 4; | ||||
const static int8_t ERROR = 8; | ||||
const static int8_t FATAL = 16; | ||||
roslib::Header header; | ||||
int8_t level; | int8_t level; | |||
std::string name; | ||||
std::string msg; | typedef std::basic_string<char, std::char_traits<char>, typename Containe | |||
std::string file; | rAllocator::template rebind<char>::other > _name_type; | |||
std::string function; | std::basic_string<char, std::char_traits<char>, typename ContainerAllocat | |||
or::template rebind<char>::other > name; | ||||
typedef std::basic_string<char, std::char_traits<char>, typename Containe | ||||
rAllocator::template rebind<char>::other > _msg_type; | ||||
std::basic_string<char, std::char_traits<char>, typename ContainerAllocat | ||||
or::template rebind<char>::other > msg; | ||||
typedef std::basic_string<char, std::char_traits<char>, typename Containe | ||||
rAllocator::template rebind<char>::other > _file_type; | ||||
std::basic_string<char, std::char_traits<char>, typename ContainerAllocat | ||||
or::template rebind<char>::other > file; | ||||
typedef std::basic_string<char, std::char_traits<char>, typename Containe | ||||
rAllocator::template rebind<char>::other > _function_type; | ||||
std::basic_string<char, std::char_traits<char>, typename ContainerAllocat | ||||
or::template rebind<char>::other > function; | ||||
typedef uint32_t _line_type; | ||||
uint32_t line; | uint32_t line; | |||
std::vector<std::string> topics; | ||||
Log() : ros::Message(), | typedef std::vector<std::basic_string<char, std::char_traits<char>, typen | |||
level(0), | ame ContainerAllocator::template rebind<char>::other > , typename Container | |||
line(0) | Allocator::template rebind<std::basic_string<char, std::char_traits<char>, | |||
{ | typename ContainerAllocator::template rebind<char>::other > >::other > _to | |||
} | pics_type; | |||
Log(const Log ©) : ros::Message(), | std::vector<std::basic_string<char, std::char_traits<char>, typename Cont | |||
header(copy.header), | ainerAllocator::template rebind<char>::other > , typename ContainerAllocato | |||
level(copy.level), | r::template rebind<std::basic_string<char, std::char_traits<char>, typename | |||
name(copy.name), | ContainerAllocator::template rebind<char>::other > >::other > topics; | |||
msg(copy.msg), | ||||
file(copy.file), | enum { DEBUG = 1 }; | |||
function(copy.function), | enum { INFO = 2 }; | |||
line(copy.line) | enum { WARN = 4 }; | |||
{ | enum { ERROR = 8 }; | |||
(void)copy; | enum { FATAL = 16 }; | |||
topics = copy.topics; | ||||
} | ROSCPP_DEPRECATED uint32_t get_topics_size() const { return (uint32_t)top | |||
Log &operator =(const Log ©) | ics.size(); } | |||
{ | ROSCPP_DEPRECATED void set_topics_size(uint32_t size) { topics.resize((si | |||
if (this == ©) | ze_t)size); } | |||
return *this; | ROSCPP_DEPRECATED void get_topics_vec(std::vector<std::basic_string<char, | |||
topics.clear(); | std::char_traits<char>, typename ContainerAllocator::template rebind<char> | |||
header = copy.header; | ::other > , typename ContainerAllocator::template rebind<std::basic_string< | |||
level = copy.level; | char, std::char_traits<char>, typename ContainerAllocator::template rebind< | |||
name = copy.name; | char>::other > >::other > & vec) const { vec = this->topics; } | |||
msg = copy.msg; | ROSCPP_DEPRECATED void set_topics_vec(const std::vector<std::basic_string | |||
file = copy.file; | <char, std::char_traits<char>, typename ContainerAllocator::template rebind | |||
function = copy.function; | <char>::other > , typename ContainerAllocator::template rebind<std::basic_s | |||
line = copy.line; | tring<char, std::char_traits<char>, typename ContainerAllocator::template r | |||
topics = copy.topics; | ebind<char>::other > >::other > & vec) { this->topics = vec; } | |||
return *this; | private: | |||
} | static const char* __s_getDataType_() { return "roslib/Log"; } | |||
virtual ~Log() | public: | |||
{ | ROSCPP_DEPRECATED static const std::string __s_getDataType() { return __s | |||
topics.clear(); | _getDataType_(); } | |||
} | ||||
inline static std::string __s_getDataType() { return std::string("roslib/ | ROSCPP_DEPRECATED const std::string __getDataType() const { return __s_ge | |||
Log"); } | tDataType_(); } | |||
inline static std::string __s_getMD5Sum() { return std::string("acffd30cd | ||||
6b6de30f120938c17c593fb"); } | private: | |||
inline static std::string __s_getMessageDefinition() | static const char* __s_getMD5Sum_() { return "acffd30cd6b6de30f120938c17c | |||
593fb"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getMD5Sum() { return __s_g | ||||
etMD5Sum_(); } | ||||
ROSCPP_DEPRECATED const std::string __getMD5Sum() const { return __s_getM | ||||
D5Sum_(); } | ||||
private: | ||||
static const char* __s_getMessageDefinition_() { return "##\n\ | ||||
## Severity level constants\n\ | ||||
##\n\ | ||||
byte DEBUG=1 #debug level\n\ | ||||
byte INFO=2 #general level\n\ | ||||
byte WARN=4 #warning level\n\ | ||||
byte ERROR=8 #error level\n\ | ||||
byte FATAL=16 #fatal/critical level\n\ | ||||
##\n\ | ||||
## Fields\n\ | ||||
##\n\ | ||||
Header header\n\ | ||||
byte level\n\ | ||||
string name # name of the node\n\ | ||||
string msg # message \n\ | ||||
string file # file the message came from\n\ | ||||
string function # function the message came from\n\ | ||||
uint32 line # line the message came from\n\ | ||||
string[] topics # topic names that the node publishes\n\ | ||||
\n\ | ||||
=========================================================================== | ||||
=====\n\ | ||||
MSG: roslib/Header\n\ | ||||
# Standard metadata for higher-level stamped data types.\n\ | ||||
# This is generally used to communicate timestamped data \n\ | ||||
# in a particular coordinate frame.\n\ | ||||
# \n\ | ||||
# sequence ID: consecutively increasing ID \n\ | ||||
uint32 seq\n\ | ||||
#Two-integer timestamp that is expressed as:\n\ | ||||
# * stamp.secs: seconds (stamp_secs) since epoch\n\ | ||||
# * stamp.nsecs: nanoseconds since stamp_secs\n\ | ||||
# time-handling sugar is provided by the client library\n\ | ||||
time stamp\n\ | ||||
#Frame this data is associated with\n\ | ||||
# 0: no frame\n\ | ||||
# 1: global frame\n\ | ||||
string frame_id\n\ | ||||
\n\ | ||||
"; } | ||||
public: | ||||
ROSCPP_DEPRECATED static const std::string __s_getMessageDefinition() { r | ||||
eturn __s_getMessageDefinition_(); } | ||||
ROSCPP_DEPRECATED const std::string __getMessageDefinition() const { retu | ||||
rn __s_getMessageDefinition_(); } | ||||
ROSCPP_DEPRECATED virtual uint8_t *serialize(uint8_t *write_ptr, uint32_t | ||||
seq) const | ||||
{ | { | |||
return std::string( | ros::serialization::OStream stream(write_ptr, 1000000000); | |||
"##\n" | ros::serialization::serialize(stream, header); | |||
"## Severity level constants\n" | ros::serialization::serialize(stream, level); | |||
"##\n" | ros::serialization::serialize(stream, name); | |||
"byte DEBUG=1 #debug level\n" | ros::serialization::serialize(stream, msg); | |||
"byte INFO=2 #general level\n" | ros::serialization::serialize(stream, file); | |||
"byte WARN=4 #warning level\n" | ros::serialization::serialize(stream, function); | |||
"byte ERROR=8 #error level\n" | ros::serialization::serialize(stream, line); | |||
"byte FATAL=16 #fatal/critical level\n" | ros::serialization::serialize(stream, topics); | |||
"##\n" | return stream.getData(); | |||
"## Fields\n" | ||||
"##\n" | ||||
"Header header\n" | ||||
"byte level\n" | ||||
"string name # name of the node\n" | ||||
"string msg # message \n" | ||||
"string file # file the message came from\n" | ||||
"string function # function the message came from\n" | ||||
"uint32 line # line the message came from\n" | ||||
"string[] topics # topic names that the node publishes\n" | ||||
"\n" | ||||
"====================================================================== | ||||
==========\n" | ||||
"MSG: roslib/Header\n" | ||||
"# Standard metadata for higher-level stamped data types.\n" | ||||
"# This is generally used to communicate timestamped data \n" | ||||
"# in a particular coordinate frame.\n" | ||||
"# \n" | ||||
"# sequence ID: consecutively increasing ID \n" | ||||
"uint32 seq\n" | ||||
"#Two-integer timestamp that is expressed as:\n" | ||||
"# * stamp.secs: seconds (stamp_secs) since epoch\n" | ||||
"# * stamp.nsecs: nanoseconds since stamp_secs\n" | ||||
"# time-handling sugar is provided by the client library\n" | ||||
"time stamp\n" | ||||
"#Frame this data is associated with\n" | ||||
"# 0: no frame\n" | ||||
"# 1: global frame\n" | ||||
"string frame_id\n" | ||||
"\n" | ||||
"\n" | ||||
); | ||||
} | } | |||
inline virtual const std::string __getDataType() const { return __s_getDa | ||||
taType(); } | ROSCPP_DEPRECATED virtual uint8_t *deserialize(uint8_t *read_ptr) | |||
inline virtual const std::string __getMD5Sum() const { return __s_getMD5S | ||||
um(); } | ||||
inline virtual const std::string __getMessageDefinition() const { return | ||||
__s_getMessageDefinition(); } | ||||
void set_topics_size(uint32_t __ros_new_size) | ||||
{ | { | |||
this->topics.resize(__ros_new_size); | ros::serialization::IStream stream(read_ptr, 1000000000); | |||
ros::serialization::deserialize(stream, header); | ||||
ros::serialization::deserialize(stream, level); | ||||
ros::serialization::deserialize(stream, name); | ||||
ros::serialization::deserialize(stream, msg); | ||||
ros::serialization::deserialize(stream, file); | ||||
ros::serialization::deserialize(stream, function); | ||||
ros::serialization::deserialize(stream, line); | ||||
ros::serialization::deserialize(stream, topics); | ||||
return stream.getData(); | ||||
} | } | |||
inline uint32_t get_topics_size() const { return topics.size(); } | ||||
uint32_t calc_topics_array_serialization_len() const | ROSCPP_DEPRECATED virtual uint32_t serializationLength() const | |||
{ | { | |||
uint32_t l = 0; | uint32_t size = 0; | |||
uint32_t topics_size = topics.size(); | size += ros::serialization::serializationLength(header); | |||
for (size_t i = 0; i < topics_size; i++) | size += ros::serialization::serializationLength(level); | |||
l += 4 + topics[i].length(); | size += ros::serialization::serializationLength(name); | |||
return l; | size += ros::serialization::serializationLength(msg); | |||
size += ros::serialization::serializationLength(file); | ||||
size += ros::serialization::serializationLength(function); | ||||
size += ros::serialization::serializationLength(line); | ||||
size += ros::serialization::serializationLength(topics); | ||||
return size; | ||||
} | } | |||
inline void get_topics_vec (std::vector<std::string> &__ros_vec) const | ||||
typedef boost::shared_ptr< ::roslib::Log_<ContainerAllocator> > Ptr; | ||||
typedef boost::shared_ptr< ::roslib::Log_<ContainerAllocator> const> Con | ||||
stPtr; | ||||
}; // struct Log | ||||
typedef ::roslib::Log_<std::allocator<void> > Log; | ||||
typedef boost::shared_ptr< ::roslib::Log> LogPtr; | ||||
typedef boost::shared_ptr< ::roslib::Log const> LogConstPtr; | ||||
template<typename ContainerAllocator> | ||||
std::ostream& operator<<(std::ostream& s, const ::roslib::Log_<ContainerAl | ||||
locator> & v) | ||||
{ | ||||
ros::message_operations::Printer< ::roslib::Log_<ContainerAllocator> >::s | ||||
tream(s, "", v); | ||||
return s;} | ||||
} // namespace roslib | ||||
namespace ros | ||||
{ | ||||
namespace message_traits | ||||
{ | ||||
template<class ContainerAllocator> | ||||
struct MD5Sum< ::roslib::Log_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
__ros_vec = this->topics; | return "acffd30cd6b6de30f120938c17c593fb"; | |||
} | } | |||
inline void set_topics_vec(const std::vector<std::string> &__ros_vec) | ||||
static const char* value(const ::roslib::Log_<ContainerAllocator> &) { r | ||||
eturn value(); } | ||||
static const uint64_t static_value1 = 0xacffd30cd6b6de30ULL; | ||||
static const uint64_t static_value2 = 0xf120938c17c593fbULL; | ||||
}; | ||||
template<class ContainerAllocator> | ||||
struct DataType< ::roslib::Log_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
this->topics = __ros_vec; | return "roslib/Log"; | |||
} | } | |||
inline uint32_t serializationLength() const | ||||
static const char* value(const ::roslib::Log_<ContainerAllocator> &) { r | ||||
eturn value(); } | ||||
}; | ||||
template<class ContainerAllocator> | ||||
struct Definition< ::roslib::Log_<ContainerAllocator> > { | ||||
static const char* value() | ||||
{ | { | |||
unsigned __l = 0; | return "##\n\ | |||
__l += 0; // DEBUG | ## Severity level constants\n\ | |||
__l += 0; // INFO | ##\n\ | |||
__l += 0; // WARN | byte DEBUG=1 #debug level\n\ | |||
__l += 0; // ERROR | byte INFO=2 #general level\n\ | |||
__l += 0; // FATAL | byte WARN=4 #warning level\n\ | |||
__l += header.serializationLength(); // header | byte ERROR=8 #error level\n\ | |||
__l += 1; // level | byte FATAL=16 #fatal/critical level\n\ | |||
__l += 4 + name.length(); // name | ##\n\ | |||
__l += 4 + msg.length(); // msg | ## Fields\n\ | |||
__l += 4 + file.length(); // file | ##\n\ | |||
__l += 4 + function.length(); // function | Header header\n\ | |||
__l += 4; // line | byte level\n\ | |||
__l += 4 + calc_topics_array_serialization_len(); // topics | string name # name of the node\n\ | |||
return __l; | string msg # message \n\ | |||
string file # file the message came from\n\ | ||||
string function # function the message came from\n\ | ||||
uint32 line # line the message came from\n\ | ||||
string[] topics # topic names that the node publishes\n\ | ||||
\n\ | ||||
=========================================================================== | ||||
=====\n\ | ||||
MSG: roslib/Header\n\ | ||||
# Standard metadata for higher-level stamped data types.\n\ | ||||
# This is generally used to communicate timestamped data \n\ | ||||
# in a particular coordinate frame.\n\ | ||||
# \n\ | ||||
# sequence ID: consecutively increasing ID \n\ | ||||
uint32 seq\n\ | ||||
#Two-integer timestamp that is expressed as:\n\ | ||||
# * stamp.secs: seconds (stamp_secs) since epoch\n\ | ||||
# * stamp.nsecs: nanoseconds since stamp_secs\n\ | ||||
# time-handling sugar is provided by the client library\n\ | ||||
time stamp\n\ | ||||
#Frame this data is associated with\n\ | ||||
# 0: no frame\n\ | ||||
# 1: global frame\n\ | ||||
string frame_id\n\ | ||||
\n\ | ||||
"; | ||||
} | } | |||
virtual uint8_t *serialize(uint8_t *write_ptr, | ||||
uint32_t seq) const | static const char* value(const ::roslib::Log_<ContainerAllocator> &) { r | |||
eturn value(); } | ||||
}; | ||||
template<class ContainerAllocator> struct HasHeader< ::roslib::Log_<Contain | ||||
erAllocator> > : public TrueType {}; | ||||
} // namespace message_traits | ||||
} // namespace ros | ||||
namespace ros | ||||
{ | ||||
namespace serialization | ||||
{ | ||||
template<class ContainerAllocator> struct Serializer< ::roslib::Log_<Contai | ||||
nerAllocator> > | ||||
{ | ||||
template<typename Stream, typename T> inline static void allInOne(Stream& | ||||
stream, T m) | ||||
{ | { | |||
roslib::Header _ser_header = header; | stream.next(m.header); | |||
bool __reset_seq = (header.seq == 0); | stream.next(m.level); | |||
if (__reset_seq) _ser_header.seq = seq; | stream.next(m.name); | |||
write_ptr = _ser_header.serialize(write_ptr, seq); | stream.next(m.msg); | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, level); | stream.next(m.file); | |||
unsigned __ros_name_len = name.length(); | stream.next(m.function); | |||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __ros_name_len); | stream.next(m.line); | |||
SROS_SERIALIZE_BUFFER(write_ptr, name.c_str(), __ros_name_len); | stream.next(m.topics); | |||
unsigned __ros_msg_len = msg.length(); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __ros_msg_len); | ||||
SROS_SERIALIZE_BUFFER(write_ptr, msg.c_str(), __ros_msg_len); | ||||
unsigned __ros_file_len = file.length(); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __ros_file_len); | ||||
SROS_SERIALIZE_BUFFER(write_ptr, file.c_str(), __ros_file_len); | ||||
unsigned __ros_function_len = function.length(); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __ros_function_len); | ||||
SROS_SERIALIZE_BUFFER(write_ptr, function.c_str(), __ros_function_len); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, line); | ||||
uint32_t __topics_size = topics.size(); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __topics_size); | ||||
for (size_t i = 0; i < __topics_size; i++) | ||||
{ | ||||
unsigned __ros_topics_i__len = topics[i].length(); | ||||
SROS_SERIALIZE_PRIMITIVE(write_ptr, __ros_topics_i__len); | ||||
SROS_SERIALIZE_BUFFER(write_ptr, topics[i].c_str(), __ros_topics_i__len | ||||
); | ||||
} | ||||
return write_ptr; | ||||
} | } | |||
virtual uint8_t *deserialize(uint8_t *read_ptr) | ||||
ROS_DECLARE_ALLINONE_SERIALIZER; | ||||
}; // struct Log_ | ||||
} // namespace serialization | ||||
} // namespace ros | ||||
namespace ros | ||||
{ | ||||
namespace message_operations | ||||
{ | ||||
template<class ContainerAllocator> | ||||
struct Printer< ::roslib::Log_<ContainerAllocator> > | ||||
{ | ||||
template<typename Stream> static void stream(Stream& s, const std::string | ||||
& indent, const ::roslib::Log_<ContainerAllocator> & v) | ||||
{ | { | |||
read_ptr = header.deserialize(read_ptr); | s << indent << "header: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, level); | s << std::endl; | |||
unsigned __ros_name_len; | Printer< ::roslib::Header_<ContainerAllocator> >::stream(s, indent + " | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __ros_name_len); | ", v.header); | |||
name = std::string((const char *)read_ptr, __ros_name_len); | s << indent << "level: "; | |||
read_ptr += __ros_name_len; | Printer<int8_t>::stream(s, indent + " ", v.level); | |||
unsigned __ros_msg_len; | s << indent << "name: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __ros_msg_len); | Printer<std::basic_string<char, std::char_traits<char>, typename Contai | |||
msg = std::string((const char *)read_ptr, __ros_msg_len); | nerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v. | |||
read_ptr += __ros_msg_len; | name); | |||
unsigned __ros_file_len; | s << indent << "msg: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __ros_file_len); | Printer<std::basic_string<char, std::char_traits<char>, typename Contai | |||
file = std::string((const char *)read_ptr, __ros_file_len); | nerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v. | |||
read_ptr += __ros_file_len; | msg); | |||
unsigned __ros_function_len; | s << indent << "file: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __ros_function_len); | Printer<std::basic_string<char, std::char_traits<char>, typename Contai | |||
function = std::string((const char *)read_ptr, __ros_function_len); | nerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v. | |||
read_ptr += __ros_function_len; | file); | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, line); | s << indent << "function: "; | |||
uint32_t __topics_size; | Printer<std::basic_string<char, std::char_traits<char>, typename Contai | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __topics_size); | nerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v. | |||
set_topics_size(__topics_size); | function); | |||
for (size_t i = 0; i < __topics_size; i++) | s << indent << "line: "; | |||
Printer<uint32_t>::stream(s, indent + " ", v.line); | ||||
s << indent << "topics[]" << std::endl; | ||||
for (size_t i = 0; i < v.topics.size(); ++i) | ||||
{ | { | |||
unsigned __ros_topics_i__len; | s << indent << " topics[" << i << "]: "; | |||
SROS_DESERIALIZE_PRIMITIVE(read_ptr, __ros_topics_i__len); | Printer<std::basic_string<char, std::char_traits<char>, typename Cont | |||
topics[i] = std::string((const char *)read_ptr, __ros_topics_i__len); | ainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", | |||
read_ptr += __ros_topics_i__len; | v.topics[i]); | |||
} | } | |||
return read_ptr; | ||||
} | } | |||
}; | }; | |||
typedef boost::shared_ptr<Log> LogPtr; | } // namespace message_operations | |||
typedef boost::shared_ptr<Log const> LogConstPtr; | } // namespace ros | |||
} | ||||
#endif | #endif // ROSLIB_MESSAGE_LOG_H | |||
End of changes. 30 change blocks. | ||||
213 lines changed or deleted | 355 lines changed or added | |||
advertise_options.h | advertise_options.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_ADVERTISE_OPTIONS_H | #ifndef ROSCPP_ADVERTISE_OPTIONS_H | |||
#define ROSCPP_ADVERTISE_OPTIONS_H | #define ROSCPP_ADVERTISE_OPTIONS_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/message_traits.h" | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Encapsulates all options available for creating a Publisher | * \brief Encapsulates all options available for creating a Publisher | |||
*/ | */ | |||
struct AdvertiseOptions | struct AdvertiseOptions | |||
{ | { | |||
AdvertiseOptions() | AdvertiseOptions() | |||
skipping to change at line 69 | skipping to change at line 70 | |||
const SubscriberStatusCallback& _disconnect_cb = Subscri berStatusCallback()) | const SubscriberStatusCallback& _disconnect_cb = Subscri berStatusCallback()) | |||
: topic(_topic) | : topic(_topic) | |||
, queue_size(_queue_size) | , queue_size(_queue_size) | |||
, md5sum(_md5sum) | , md5sum(_md5sum) | |||
, datatype(_datatype) | , datatype(_datatype) | |||
, message_definition(_message_definition) | , message_definition(_message_definition) | |||
, connect_cb(_connect_cb) | , connect_cb(_connect_cb) | |||
, disconnect_cb(_disconnect_cb) | , disconnect_cb(_disconnect_cb) | |||
, callback_queue(0) | , callback_queue(0) | |||
, latch(false) | , latch(false) | |||
, has_header(false) | ||||
{} | {} | |||
/** | /** | |||
* \brief templated helper function for automatically filling out md5sum, datatype and message definition | * \brief templated helper function for automatically filling out md5sum, datatype and message definition | |||
* | * | |||
* \param M [template] Message type | * \param M [template] Message type | |||
* \param _topic Topic to publish on | * \param _topic Topic to publish on | |||
* \param _queue_size Maximum number of outgoing messages to be queued fo r delivery to subscribers | * \param _queue_size Maximum number of outgoing messages to be queued fo r delivery to subscribers | |||
* \param _connect_cb Function to call when a subscriber connects to this topic | * \param _connect_cb Function to call when a subscriber connects to this topic | |||
* \param _disconnect_cb Function to call when a subscriber disconnects f rom this topic | * \param _disconnect_cb Function to call when a subscriber disconnects f rom this topic | |||
*/ | */ | |||
template <class M> | template <class M> | |||
void init(const std::string& _topic, uint32_t _queue_size, | void init(const std::string& _topic, uint32_t _queue_size, | |||
const SubscriberStatusCallback& _connect_cb = SubscriberStatusC allback(), | const SubscriberStatusCallback& _connect_cb = SubscriberStatusC allback(), | |||
const SubscriberStatusCallback& _disconnect_cb = SubscriberStat usCallback()) | const SubscriberStatusCallback& _disconnect_cb = SubscriberStat usCallback()) | |||
{ | { | |||
topic = _topic; | topic = _topic; | |||
queue_size = _queue_size; | queue_size = _queue_size; | |||
connect_cb = _connect_cb; | connect_cb = _connect_cb; | |||
disconnect_cb = _disconnect_cb; | disconnect_cb = _disconnect_cb; | |||
md5sum = M::__s_getMD5Sum(); | md5sum = message_traits::md5sum<M>(); | |||
datatype = M::__s_getDataType(); | datatype = message_traits::datatype<M>(); | |||
message_definition = M::__s_getMessageDefinition(); | message_definition = message_traits::definition<M>(); | |||
has_header = message_traits::hasHeader<M>(); | ||||
} | } | |||
std::string topic; ///< Th e topic to publish on | std::string topic; ///< Th e topic to publish on | |||
uint32_t queue_size; ///< Th e maximum number of outgoing messages to be queued for delivery to subscrib ers | uint32_t queue_size; ///< Th e maximum number of outgoing messages to be queued for delivery to subscrib ers | |||
std::string md5sum; ///< Th e md5sum of the message datatype published on this topic | std::string md5sum; ///< Th e md5sum of the message datatype published on this topic | |||
std::string datatype; ///< Th e datatype of the message published on this topic (eg. "std_msgs/String") | std::string datatype; ///< Th e datatype of the message published on this topic (eg. "std_msgs/String") | |||
std::string message_definition; ///< Th e full definition of the message published on this topic | std::string message_definition; ///< Th e full definition of the message published on this topic | |||
SubscriberStatusCallback connect_cb; ///< Th e function to call when a subscriber connects to this topic | SubscriberStatusCallback connect_cb; ///< Th e function to call when a subscriber connects to this topic | |||
skipping to change at line 116 | skipping to change at line 119 | |||
/** | /** | |||
* \brief An object whose destruction will prevent the callbacks associat ed with this advertisement from being called | * \brief An object whose destruction will prevent the callbacks associat ed with this advertisement from being called | |||
* | * | |||
* A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | * A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | |||
* and if the reference count goes to 0 the subscriber callbacks will not get called. | * and if the reference count goes to 0 the subscriber callbacks will not get called. | |||
* | * | |||
* \note Note that setting this will cause a new reference to be added to the object before the | * \note Note that setting this will cause a new reference to be added to the object before the | |||
* callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | * callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | |||
* thread) that the callback is invoked from. | * thread) that the callback is invoked from. | |||
*/ | */ | |||
VoidPtr tracked_object; | VoidConstPtr tracked_object; | |||
/** | /** | |||
* \brief Whether or not this publication should "latch". A latching pub lication will automatically send out the last published message | * \brief Whether or not this publication should "latch". A latching pub lication will automatically send out the last published message | |||
* to any new subscribers. | * to any new subscribers. | |||
*/ | */ | |||
bool latch; | bool latch; | |||
/** \brief Tells whether or not the message has a header. If it does, th | ||||
e sequence number will be written directly into the | ||||
* serialized bytes after the message has been serialized. | ||||
*/ | ||||
bool has_header; | ||||
/** | /** | |||
* \brief Templated helper function for creating an AdvertiseOptions for a message type with most options. | * \brief Templated helper function for creating an AdvertiseOptions for a message type with most options. | |||
* | * | |||
* \param M [template] Message type | * \param M [template] Message type | |||
* \param topic Topic to publish on | * \param topic Topic to publish on | |||
* \param queue_size Maximum number of outgoing messages to be queued for delivery to subscribers | * \param queue_size Maximum number of outgoing messages to be queued for delivery to subscribers | |||
* \param connect_cb Function to call when a subscriber connects to this topic | * \param connect_cb Function to call when a subscriber connects to this topic | |||
* \param disconnect_cb Function to call when a subscriber disconnects fr om this topic | * \param disconnect_cb Function to call when a subscriber disconnects fr om this topic | |||
* \param tracked_object tracked object to use (see AdvertiseOptions::tra cked_object) | * \param tracked_object tracked object to use (see AdvertiseOptions::tra cked_object) | |||
* \param queue The callback queue to use (see AdvertiseOptions::callback _queue) | * \param queue The callback queue to use (see AdvertiseOptions::callback _queue) | |||
* | * | |||
* \return an AdvertiseOptions which embodies the parameters | * \return an AdvertiseOptions which embodies the parameters | |||
*/ | */ | |||
template<class M> | template<class M> | |||
static AdvertiseOptions create(const std::string& topic, uint32_t queue_s ize, | static AdvertiseOptions create(const std::string& topic, uint32_t queue_s ize, | |||
const SubscriberStatusCallback& connect_cb, | const SubscriberStatusCallback& connect_cb, | |||
const SubscriberStatusCallback& disconnect_cb, | const SubscriberStatusCallback& disconnect_cb, | |||
const VoidPtr& tracked_object, | const VoidConstPtr& tracked_object, | |||
CallbackQueueInterface* queue) | CallbackQueueInterface* queue) | |||
{ | { | |||
AdvertiseOptions ops; | AdvertiseOptions ops; | |||
ops.init<M>(topic, queue_size, connect_cb, disconnect_cb); | ops.init<M>(topic, queue_size, connect_cb, disconnect_cb); | |||
ops.tracked_object = tracked_object; | ops.tracked_object = tracked_object; | |||
ops.callback_queue = queue; | ops.callback_queue = queue; | |||
return ops; | return ops; | |||
} | } | |||
}; | }; | |||
End of changes. 6 change blocks. | ||||
5 lines changed or deleted | 14 lines changed or added | |||
advertise_service_options.h | advertise_service_options.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_ADVERTISE_SERVICE_OPTIONS_H | #ifndef ROSCPP_ADVERTISE_SERVICE_OPTIONS_H | |||
#define ROSCPP_ADVERTISE_SERVICE_OPTIONS_H | #define ROSCPP_ADVERTISE_SERVICE_OPTIONS_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/service_message_helper.h" | #include "ros/service_callback_helper.h" | |||
#include "ros/service_traits.h" | ||||
#include "ros/message_traits.h" | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Encapsulates all options available for creating a ServiceServer | * \brief Encapsulates all options available for creating a ServiceServer | |||
*/ | */ | |||
struct AdvertiseServiceOptions | struct AdvertiseServiceOptions | |||
{ | { | |||
AdvertiseServiceOptions() | AdvertiseServiceOptions() | |||
: callback_queue(0) | : callback_queue(0) | |||
{ | { | |||
} | } | |||
/** | /** | |||
* \brief Constructor | ||||
* \param _service Service name to advertise on | ||||
* \param _helper Helper object used for creating messages and calling ca | ||||
llbacks | ||||
*/ | ||||
AdvertiseServiceOptions(const std::string& _service, const ServiceMessage | ||||
HelperPtr& _helper) | ||||
: service(_service) | ||||
, md5sum(_helper->getMD5Sum()) | ||||
, datatype(_helper->getDataType()) | ||||
, req_datatype(_helper->getRequestDataType()) | ||||
, res_datatype(_helper->getResponseDataType()) | ||||
, helper(_helper) | ||||
, callback_queue(0) | ||||
{} | ||||
/** | ||||
* \brief Templated convenience method for filling out md5sum/etc. based on the service request/response types | * \brief Templated convenience method for filling out md5sum/etc. based on the service request/response types | |||
* \param _service Service name to advertise on | * \param _service Service name to advertise on | |||
* \param _callback Callback to call when this service is called | * \param _callback Callback to call when this service is called | |||
*/ | */ | |||
template<class MReq, class MRes> | template<class MReq, class MRes> | |||
void init(const std::string& _service, const boost::function<bool(MReq&, MRes&)>& _callback) | void init(const std::string& _service, const boost::function<bool(MReq&, MRes&)>& _callback) | |||
{ | { | |||
if (MReq::__s_getServerMD5Sum() != MRes::__s_getServerMD5Sum()) | namespace st = service_traits; | |||
namespace mt = message_traits; | ||||
if (st::md5sum<MReq>() != st::md5sum<MRes>()) | ||||
{ | { | |||
ROS_FATAL("woah! the request and response parameters to the server " | ROS_FATAL("the request and response parameters to the server " | |||
"callback function must be autogenerated from the same " | "callback function must be autogenerated from the same " | |||
"server definition file (.srv). your advertise_servce " | "server definition file (.srv). your advertise_servce " | |||
"call for %s appeared to use request/response types " | "call for %s appeared to use request/response types " | |||
"from different .srv files.", service.c_str()); | "from different .srv files.", service.c_str()); | |||
ROS_BREAK(); | ROS_BREAK(); | |||
} | } | |||
service = _service; | service = _service; | |||
md5sum = MReq::__s_getServerMD5Sum(); | md5sum = st::md5sum<MReq>(); | |||
datatype = MReq::__s_getServiceDataType(); | datatype = st::datatype<MReq>(); | |||
req_datatype = MReq::__s_getDataType(); | req_datatype = mt::datatype<MReq>(); | |||
res_datatype = MRes::__s_getDataType(); | res_datatype = mt::datatype<MRes>(); | |||
helper = ServiceMessageHelperPtr(new ServiceMessageHelperT<MReq, MRes>( | helper = ServiceCallbackHelperPtr(new ServiceCallbackHelperT<ServiceSpe | |||
_callback)); | c<MReq, MRes> >(_callback)); | |||
} | } | |||
/** | /** | |||
* \brief Templated convenience method for filling out md5sum/etc. based on the service type | * \brief Templated convenience method for filling out md5sum/etc. based on the service type | |||
* \param _service Service name to advertise on | * \param _service Service name to advertise on | |||
* \param _callback Callback to call when this service is called | * \param _callback Callback to call when this service is called | |||
*/ | */ | |||
template<class Service> | template<class Service> | |||
void init(const std::string& _service, const boost::function<bool(typenam e Service::Request&, typename Service::Response&)>& _callback) | void init(const std::string& _service, const boost::function<bool(typenam e Service::Request&, typename Service::Response&)>& _callback) | |||
{ | { | |||
namespace st = service_traits; | ||||
namespace mt = message_traits; | ||||
typedef typename Service::Request Request; | typedef typename Service::Request Request; | |||
typedef typename Service::Response Response; | typedef typename Service::Response Response; | |||
service = _service; | service = _service; | |||
md5sum = Service::getMD5Sum(); | md5sum = st::md5sum<Service>(); | |||
datatype = Service::getDataType(); | datatype = st::datatype<Service>(); | |||
req_datatype = Request::__s_getDataType(); | req_datatype = mt::datatype<Request>(); | |||
res_datatype = Request::__s_getDataType(); | res_datatype = mt::datatype<Response>(); | |||
helper = ServiceMessageHelperPtr(new ServiceMessageHelperT<Request, Res | helper = ServiceCallbackHelperPtr(new ServiceCallbackHelperT<ServiceSpe | |||
ponse>(_callback)); | c<Request, Response> >(_callback)); | |||
} | ||||
/** | ||||
* \brief Templated convenience method for filling out md5sum/etc. based | ||||
on the service spec type | ||||
* \param _service Service name to advertise on | ||||
* \param _callback Callback to call when this service is called | ||||
*/ | ||||
template<class Spec> | ||||
void initBySpecType(const std::string& _service, const typename Spec::Cal | ||||
lbackType& _callback) | ||||
{ | ||||
namespace st = service_traits; | ||||
namespace mt = message_traits; | ||||
typedef typename Spec::RequestType Request; | ||||
typedef typename Spec::ResponseType Response; | ||||
service = _service; | ||||
md5sum = st::md5sum<Request>(); | ||||
datatype = st::datatype<Request>(); | ||||
req_datatype = mt::datatype<Request>(); | ||||
res_datatype = mt::datatype<Response>(); | ||||
helper = ServiceCallbackHelperPtr(new ServiceCallbackHelperT<Spec>(_cal | ||||
lback)); | ||||
} | } | |||
std::string service; ///< Service name | std::string service; ///< Service name | |||
std::string md5sum; ///< MD5 of the service | std::string md5sum; ///< MD5 of the service | |||
std::string datatype; ///< Datatype of the service | std::string datatype; ///< Datatype of the service | |||
std::string req_datatype; ///< Request message datatype | std::string req_datatype; ///< Request message datatype | |||
std::string res_datatype; ///< Response message datatype | std::string res_datatype; ///< Response message datatype | |||
ServiceMessageHelperPtr helper; ///< Helper object used for creating messages and calling callbacks | ServiceCallbackHelperPtr helper; ///< Helper object used for creating messages and calling callbacks | |||
CallbackQueueInterface* callback_queue; ///< Queue to add callbacks to. If NULL, the global callback queue will be used | CallbackQueueInterface* callback_queue; ///< Queue to add callbacks to. If NULL, the global callback queue will be used | |||
/** | /** | |||
* \brief An object whose destruction will prevent the callback associate d with this service from being called | * \brief An object whose destruction will prevent the callback associate d with this service from being called | |||
* | * | |||
* A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | * A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | |||
* and if the reference count goes to 0 the subscriber callbacks will not get called. | * and if the reference count goes to 0 the subscriber callbacks will not get called. | |||
* | * | |||
* \note Note that setting this will cause a new reference to be added to the object before the | * \note Note that setting this will cause a new reference to be added to the object before the | |||
* callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | * callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | |||
* thread) that the callback is invoked from. | * thread) that the callback is invoked from. | |||
*/ | */ | |||
VoidPtr tracked_object; | VoidConstPtr tracked_object; | |||
/** | /** | |||
* \brief Templated helper function for creating an AdvertiseServiceOptio ns with all of its options | * \brief Templated helper function for creating an AdvertiseServiceOptio ns with all of its options | |||
* \param service Service name to advertise on | * \param service Service name to advertise on | |||
* \param callback The callback to invoke when the service is called | * \param callback The callback to invoke when the service is called | |||
* \param tracked_object The tracked object to use (see AdvertiseServiceO ptions::tracked_object) | * \param tracked_object The tracked object to use (see AdvertiseServiceO ptions::tracked_object) | |||
* \param queue The callback queue to use (see AdvertiseServiceOptions::c allback_queue) | * \param queue The callback queue to use (see AdvertiseServiceOptions::c allback_queue) | |||
*/ | */ | |||
template<class Service> | template<class Service> | |||
static AdvertiseServiceOptions create(const std::string& service, | static AdvertiseServiceOptions create(const std::string& service, | |||
const boost::function<bool(typename Servic e::Request&, typename Service::Response&)>& callback, | const boost::function<bool(typename Servic e::Request&, typename Service::Response&)>& callback, | |||
const VoidPtr& tracked_object, | const VoidConstPtr& tracked_object, | |||
CallbackQueueInterface* queue) | CallbackQueueInterface* queue) | |||
{ | { | |||
AdvertiseServiceOptions ops; | AdvertiseServiceOptions ops; | |||
ops.init<typename Service::Request, typename Service::Response>(service , callback); | ops.init<typename Service::Request, typename Service::Response>(service , callback); | |||
ops.tracked_object = tracked_object; | ops.tracked_object = tracked_object; | |||
ops.callback_queue = queue; | ops.callback_queue = queue; | |||
return ops; | return ops; | |||
} | } | |||
}; | }; | |||
End of changes. 10 change blocks. | ||||
35 lines changed or deleted | 47 lines changed or added | |||
assert.h | assert.h | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
// Author: Josh Faust | // Author: Josh Faust | |||
#ifndef ROSCONSOLE_ROSASSERT_H | #ifndef ROSCONSOLE_ROSASSERT_H | |||
#define ROSCONSOLE_ROSASSERT_H | #define ROSCONSOLE_ROSASSERT_H | |||
#include "ros/console.h" | #include "ros/console.h" | |||
#include "ros/static_assert.h" | ||||
/** \file */ | /** \file */ | |||
/** \def ROS_ASSERT(cond) | /** \def ROS_ASSERT(cond) | |||
* \brief Asserts that the provided condition evaluates to true. | * \brief Asserts that the provided condition evaluates to true. | |||
* | * | |||
* If it is false, program execution will abort, with an informative | * If it is false, program execution will abort, with an informative | |||
* statement about which assertion failed, in what file. Use ROS_ASSERT | * statement about which assertion failed, in what file. Use ROS_ASSERT | |||
* instead of assert() itself. | * instead of assert() itself. | |||
* | * | |||
skipping to change at line 102 | skipping to change at line 103 | |||
# define ROS_ISSUE_BREAK() __debugbreak(); | # define ROS_ISSUE_BREAK() __debugbreak(); | |||
#elif defined(__powerpc64__) | #elif defined(__powerpc64__) | |||
# define ROS_ISSUE_BREAK() asm volatile ("tw 31,1,1"); | # define ROS_ISSUE_BREAK() asm volatile ("tw 31,1,1"); | |||
#elif defined(__i386__) || defined(__ia64__) || defined(__x86_64__) | #elif defined(__i386__) || defined(__ia64__) || defined(__x86_64__) | |||
# define ROS_ISSUE_BREAK() asm("int $3"); | # define ROS_ISSUE_BREAK() asm("int $3"); | |||
#else | #else | |||
# include <cassert> | # include <cassert> | |||
# define ROS_ISSUE_BREAK() assert(false); | # define ROS_ISSUE_BREAK() assert(false); | |||
#endif | #endif | |||
/** | ||||
* \def ROS_COMPILE_ASSERT(cond) | ||||
* \brief Compile-time assert. | ||||
* | ||||
* Only works with compile time statements, ie: | ||||
@verbatim | ||||
struct A | ||||
{ | ||||
uint32_t a; | ||||
}; | ||||
ROS_COMPILE_ASSERT(sizeof(A) == 4); | ||||
@endverbatim | ||||
*/ | ||||
#define ROS_COMPILE_ASSERT(cond) typedef char __ROS_COMPILE_ASSERT__[(cond) | ||||
?1:-1] | ||||
#ifndef NDEBUG | #ifndef NDEBUG | |||
#define ROS_ASSERT_ENABLED | #define ROS_ASSERT_ENABLED | |||
#endif | #endif | |||
#ifdef ROS_ASSERT_ENABLED | #ifdef ROS_ASSERT_ENABLED | |||
#define ROS_BREAK() \ | #define ROS_BREAK() \ | |||
do { \ | do { \ | |||
ROS_FATAL("BREAKPOINT HIT\n\tfile = %s\n\tline=%d\n", __FILE__, __LINE_ _); \ | ROS_FATAL("BREAKPOINT HIT\n\tfile = %s\n\tline=%d\n", __FILE__, __LINE_ _); \ | |||
ROS_ISSUE_BREAK() \ | ROS_ISSUE_BREAK() \ | |||
} while (0) | } while (0) | |||
End of changes. 2 change blocks. | ||||
16 lines changed or deleted | 1 lines changed or added | |||
callback_queue.h | callback_queue.h | |||
---|---|---|---|---|
skipping to change at line 48 | skipping to change at line 48 | |||
#include "ros/callback_queue_interface.h" | #include "ros/callback_queue_interface.h" | |||
#include "ros/time.h" | #include "ros/time.h" | |||
#include <boost/shared_ptr.hpp> | #include <boost/shared_ptr.hpp> | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/thread/shared_mutex.hpp> | #include <boost/thread/shared_mutex.hpp> | |||
#include <boost/thread/condition_variable.hpp> | #include <boost/thread/condition_variable.hpp> | |||
#include <boost/thread/tss.hpp> | #include <boost/thread/tss.hpp> | |||
#include <list> | #include <list> | |||
#include <deque> | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief This is the default implementation of the ros::CallbackQueueInter face | * \brief This is the default implementation of the ros::CallbackQueueInter face | |||
*/ | */ | |||
class CallbackQueue : public CallbackQueueInterface | class CallbackQueue : public CallbackQueueInterface | |||
{ | { | |||
public: | public: | |||
CallbackQueue(bool enabled = true); | CallbackQueue(bool enabled = true); | |||
virtual ~CallbackQueue(); | virtual ~CallbackQueue(); | |||
virtual void addCallback(const CallbackInterfacePtr& callback, uint64_t r emoval_id = 0); | virtual void addCallback(const CallbackInterfacePtr& callback, uint64_t r emoval_id = 0); | |||
virtual void removeByID(uint64_t removal_id); | virtual void removeByID(uint64_t removal_id); | |||
enum CallOneResult | ||||
{ | ||||
Called, | ||||
TryAgain, | ||||
Disabled, | ||||
Empty, | ||||
}; | ||||
/** | /** | |||
* \brief Pop a single callback off the front of the queue and invoke it. If the callback was not ready to be called, | * \brief Pop a single callback off the front of the queue and invoke it. If the callback was not ready to be called, | |||
* pushes it back onto the queue. | * pushes it back onto the queue. | |||
*/ | */ | |||
void callOne() | CallOneResult callOne() | |||
{ | { | |||
callOne(ros::WallDuration()); | return callOne(ros::WallDuration()); | |||
} | } | |||
/** | /** | |||
* \brief Pop a single callback off the front of the queue and invoke it. If the callback was not ready to be called, | * \brief Pop a single callback off the front of the queue and invoke it. If the callback was not ready to be called, | |||
* pushes it back onto the queue. This version includes a timeout which lets you specify the amount of time to wait for | * pushes it back onto the queue. This version includes a timeout which lets you specify the amount of time to wait for | |||
* a callback to be available before returning. | * a callback to be available before returning. | |||
* | * | |||
* \param timeout The amount of time to wait for a callback to be availab le. If there is already a callback available, | * \param timeout The amount of time to wait for a callback to be availab le. If there is already a callback available, | |||
* this parameter does nothing. | * this parameter does nothing. | |||
*/ | */ | |||
void callOne(ros::WallDuration timeout); | CallOneResult callOne(ros::WallDuration timeout); | |||
/** | /** | |||
* \brief Invoke all callbacks currently in the queue. If a callback was not ready to be called, pushes it back onto the queue. | * \brief Invoke all callbacks currently in the queue. If a callback was not ready to be called, pushes it back onto the queue. | |||
*/ | */ | |||
void callAvailable() | void callAvailable() | |||
{ | { | |||
callAvailable(ros::WallDuration()); | callAvailable(ros::WallDuration()); | |||
} | } | |||
/** | /** | |||
* \brief Invoke all callbacks currently in the queue. If a callback was not ready to be called, pushes it back onto the queue. This version | * \brief Invoke all callbacks currently in the queue. If a callback was not ready to be called, pushes it back onto the queue. This version | |||
skipping to change at line 128 | skipping to change at line 137 | |||
*/ | */ | |||
void disable(); | void disable(); | |||
/** | /** | |||
* \brief Returns whether or not this queue is enabled | * \brief Returns whether or not this queue is enabled | |||
*/ | */ | |||
bool isEnabled(); | bool isEnabled(); | |||
protected: | protected: | |||
void setupTLS(); | void setupTLS(); | |||
struct TLS; | ||||
CallOneResult callOneCB(TLS* tls); | ||||
struct IDInfo | struct IDInfo | |||
{ | { | |||
uint64_t id; | uint64_t id; | |||
boost::shared_mutex calling_rw_mutex; | boost::shared_mutex calling_rw_mutex; | |||
}; | }; | |||
typedef boost::shared_ptr<IDInfo> IDInfoPtr; | typedef boost::shared_ptr<IDInfo> IDInfoPtr; | |||
typedef std::map<uint64_t, IDInfoPtr> M_IDInfo; | typedef std::map<uint64_t, IDInfoPtr> M_IDInfo; | |||
IDInfoPtr getIDInfo(uint64_t id); | IDInfoPtr getIDInfo(uint64_t id); | |||
skipping to change at line 149 | skipping to change at line 161 | |||
{ | { | |||
CallbackInfo() | CallbackInfo() | |||
: removal_id(0) | : removal_id(0) | |||
, marked_for_removal(false) | , marked_for_removal(false) | |||
{} | {} | |||
CallbackInterfacePtr callback; | CallbackInterfacePtr callback; | |||
uint64_t removal_id; | uint64_t removal_id; | |||
bool marked_for_removal; | bool marked_for_removal; | |||
}; | }; | |||
typedef std::list<CallbackInfo> L_CallbackInfo; | typedef std::list<CallbackInfo> L_CallbackInfo; | |||
L_CallbackInfo callbacks_; | typedef std::deque<CallbackInfo> D_CallbackInfo; | |||
D_CallbackInfo callbacks_; | ||||
size_t calling_; | ||||
boost::mutex mutex_; | boost::mutex mutex_; | |||
boost::condition_variable condition_; | boost::condition_variable condition_; | |||
boost::mutex id_info_mutex_; | boost::mutex id_info_mutex_; | |||
M_IDInfo id_info_; | M_IDInfo id_info_; | |||
struct TLS | struct TLS | |||
{ | { | |||
TLS() | TLS() | |||
: calling_in_this_thread(0xffffffffffffffffULL) | : calling_in_this_thread(0xffffffffffffffffULL) | |||
, cb_it(callbacks.end()) | ||||
{} | {} | |||
uint64_t calling_in_this_thread; | uint64_t calling_in_this_thread; | |||
L_CallbackInfo callbacks; | D_CallbackInfo callbacks; | |||
D_CallbackInfo::iterator cb_it; | ||||
}; | }; | |||
boost::thread_specific_ptr<TLS> tls_; | boost::thread_specific_ptr<TLS> tls_; | |||
bool enabled_; | bool enabled_; | |||
}; | }; | |||
typedef boost::shared_ptr<CallbackQueue> CallbackQueuePtr; | typedef boost::shared_ptr<CallbackQueue> CallbackQueuePtr; | |||
} | } | |||
#endif | #endif | |||
End of changes. 9 change blocks. | ||||
5 lines changed or deleted | 21 lines changed or added | |||
callback_queue_interface.h | callback_queue_interface.h | |||
---|---|---|---|---|
skipping to change at line 40 | skipping to change at line 40 | |||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_CALLBACK_QUEUE_INTERFACE_H | #ifndef ROSCPP_CALLBACK_QUEUE_INTERFACE_H | |||
#define ROSCPP_CALLBACK_QUEUE_INTERFACE_H | #define ROSCPP_CALLBACK_QUEUE_INTERFACE_H | |||
#include <boost/shared_ptr.hpp> | #include <boost/shared_ptr.hpp> | |||
#include "types.h" | #include "ros/types.h" | |||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Abstract interface for items which can be added to a CallbackQueu eInterface | * \brief Abstract interface for items which can be added to a CallbackQueu eInterface | |||
*/ | */ | |||
class CallbackInterface | class CallbackInterface | |||
{ | { | |||
public: | public: | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
common.h | common.h | |||
---|---|---|---|---|
skipping to change at line 38 | skipping to change at line 38 | |||
#ifndef ROSCPP_COMMON_H | #ifndef ROSCPP_COMMON_H | |||
#define ROSCPP_COMMON_H | #define ROSCPP_COMMON_H | |||
#include <stdint.h> | #include <stdint.h> | |||
#include <assert.h> | #include <assert.h> | |||
#include <stddef.h> | #include <stddef.h> | |||
#include <string> | #include <string> | |||
#include "ros/assert.h" | #include "ros/assert.h" | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/serialized_message.h" | ||||
#include <boost/shared_array.hpp> | #include <boost/shared_array.hpp> | |||
#define ROS_VERSION_MAJOR 1 | #define ROS_VERSION_MAJOR 1 | |||
#define ROS_VERSION_MINOR 0 | #define ROS_VERSION_MINOR 2 | |||
#define ROS_VERSION_PATCH 5 | #define ROS_VERSION_PATCH 6 | |||
#define ROS_VERSION_COMBINED(major, minor, patch) (((major) << 20) | ((mino r) << 10) | (patch)) | #define ROS_VERSION_COMBINED(major, minor, patch) (((major) << 20) | ((mino r) << 10) | (patch)) | |||
#define ROS_VERSION ROS_VERSION_COMBINED(ROS_VERSION_MAJOR, ROS_VERSION_MIN OR, ROS_VERSION_PATCH) | #define ROS_VERSION ROS_VERSION_COMBINED(ROS_VERSION_MAJOR, ROS_VERSION_MIN OR, ROS_VERSION_PATCH) | |||
#define ROS_VERSION_GE(major1, minor1, patch1, major2, minor2, patch2) (ROS _VERSION_COMBINED(major1, minor1, patch1) >= ROS_VERSION_COMBINED(major2, m inor2, patch2)) | #define ROS_VERSION_GE(major1, minor1, patch1, major2, minor2, patch2) (ROS _VERSION_COMBINED(major1, minor1, patch1) >= ROS_VERSION_COMBINED(major2, m inor2, patch2)) | |||
#define ROS_VERSION_MINIMUM(major, minor, patch) ROS_VERSION_GE(ROS_VERSION _MAJOR, ROS_VERSION_MINOR, ROS_VERSION_PATCH, major, minor, patch) | #define ROS_VERSION_MINIMUM(major, minor, patch) ROS_VERSION_GE(ROS_VERSION _MAJOR, ROS_VERSION_MINOR, ROS_VERSION_PATCH, major, minor, patch) | |||
namespace ros | namespace ros | |||
{ | { | |||
void disableAllSignalsInThisThread(); | void disableAllSignalsInThisThread(); | |||
class SerializedMessage | ||||
{ | ||||
public: | ||||
boost::shared_array<uint8_t> buf; | ||||
size_t num_bytes; | ||||
SerializedMessage() | ||||
: buf(boost::shared_array<uint8_t>()) | ||||
, num_bytes(0) | ||||
{} | ||||
SerializedMessage(boost::shared_array<uint8_t> buf, size_t num_bytes) | ||||
: buf(buf), num_bytes(num_bytes) { } | ||||
}; | ||||
} | } | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
17 lines changed or deleted | 3 lines changed or added | |||
connection.h | connection.h | |||
---|---|---|---|---|
skipping to change at line 71 | skipping to change at line 71 | |||
/** | /** | |||
* \brief Encapsulates a connection to a remote host, independent of the tr ansport type | * \brief Encapsulates a connection to a remote host, independent of the tr ansport type | |||
* | * | |||
* Connection provides automatic header negotiation, as well as easy ways o f reading and writing | * Connection provides automatic header negotiation, as well as easy ways o f reading and writing | |||
* arbitrary amounts of data without having to set up your own state machin es. | * arbitrary amounts of data without having to set up your own state machin es. | |||
*/ | */ | |||
class Connection : public boost::enable_shared_from_this<Connection> | class Connection : public boost::enable_shared_from_this<Connection> | |||
{ | { | |||
public: | public: | |||
enum DropReason | ||||
{ | ||||
TransportDisconnect, | ||||
HeaderError, | ||||
Destructing, | ||||
}; | ||||
Connection(); | Connection(); | |||
~Connection(); | ~Connection(); | |||
/** | /** | |||
* \brief Initialize this connection. | * \brief Initialize this connection. | |||
*/ | */ | |||
void initialize(const TransportPtr& transport, bool is_server, const Head erReceivedFunc& header_func); | void initialize(const TransportPtr& transport, bool is_server, const Head erReceivedFunc& header_func); | |||
/** | /** | |||
* \brief Drop this connection. Anything added as a drop listener throug h addDropListener will get called back when this connection has | * \brief Drop this connection. Anything added as a drop listener throug h addDropListener will get called back when this connection has | |||
* been dropped. | * been dropped. | |||
*/ | */ | |||
void drop(); | void drop(DropReason reason); | |||
/** | /** | |||
* \brief Returns whether or not this connection has been dropped | * \brief Returns whether or not this connection has been dropped | |||
*/ | */ | |||
bool isDropped(); | bool isDropped(); | |||
/** | /** | |||
* \brief Returns true if we're currently sending a header error (and wil | ||||
l be automatically dropped when it's finished) | ||||
*/ | ||||
bool isSendingHeaderError() { return sending_header_error_; } | ||||
/** | ||||
* \brief Send a header error message, of the form "error=<message>". Dr ops the connection once the data has written successfully (or fails to writ e) | * \brief Send a header error message, of the form "error=<message>". Dr ops the connection once the data has written successfully (or fails to writ e) | |||
* \param error_message The error message | * \param error_message The error message | |||
*/ | */ | |||
void sendHeaderError(const std::string& error_message); | void sendHeaderError(const std::string& error_message); | |||
/** | /** | |||
* \brief Send a list of string key/value pairs as a header message. | * \brief Send a list of string key/value pairs as a header message. | |||
* \param key_vals The values to send. Neither keys nor values can have any newlines in them | * \param key_vals The values to send. Neither keys nor values can have any newlines in them | |||
* \param finished_callback The function to call when the header has fini shed writing | * \param finished_callback The function to call when the header has fini shed writing | |||
*/ | */ | |||
void writeHeader(const M_string& key_vals, const WriteFinishedFunc& finis hed_callback); | void writeHeader(const M_string& key_vals, const WriteFinishedFunc& finis hed_callback); | |||
skipping to change at line 133 | skipping to change at line 145 | |||
* \note The finished callback may be called from within this call to wri te() if the data can be written immediately | * \note The finished callback may be called from within this call to wri te() if the data can be written immediately | |||
* | * | |||
* \param buffer The buffer of data to write | * \param buffer The buffer of data to write | |||
* \param size The size of the buffer, in bytes | * \param size The size of the buffer, in bytes | |||
* \param finished_callback The function to call when the write has finis hed | * \param finished_callback The function to call when the write has finis hed | |||
* \param immediate Whether to immediately try to write as much data as p ossible to the socket or to pass | * \param immediate Whether to immediately try to write as much data as p ossible to the socket or to pass | |||
* the data off to the server thread | * the data off to the server thread | |||
*/ | */ | |||
void write(const boost::shared_array<uint8_t>& buffer, uint32_t size, con st WriteFinishedFunc& finished_callback, bool immedate = true); | void write(const boost::shared_array<uint8_t>& buffer, uint32_t size, con st WriteFinishedFunc& finished_callback, bool immedate = true); | |||
typedef boost::signal<void(const ConnectionPtr&)> DropSignal; | typedef boost::signal<void(const ConnectionPtr&, DropReason reason)> Drop | |||
typedef boost::function<void(const ConnectionPtr&)> DropFunc; | Signal; | |||
typedef boost::function<void(const ConnectionPtr&, DropReason reason)> Dr | ||||
opFunc; | ||||
/** | /** | |||
* \brief Add a callback to be called when this connection has dropped | * \brief Add a callback to be called when this connection has dropped | |||
*/ | */ | |||
boost::signals::connection addDropListener(const DropFunc& slot); | boost::signals::connection addDropListener(const DropFunc& slot); | |||
void removeDropListener(const boost::signals::connection& c); | ||||
/** | /** | |||
* \brief Set the header receipt callback | * \brief Set the header receipt callback | |||
*/ | */ | |||
void setHeaderReceivedCallback(const HeaderReceivedFunc& func); | void setHeaderReceivedCallback(const HeaderReceivedFunc& func); | |||
/** | /** | |||
* \brief Get the Transport associated with this connection | * \brief Get the Transport associated with this connection | |||
*/ | */ | |||
const TransportPtr& getTransport() { return transport_; } | const TransportPtr& getTransport() { return transport_; } | |||
skipping to change at line 204 | skipping to change at line 217 | |||
bool is_server_; | bool is_server_; | |||
/// Have we dropped? | /// Have we dropped? | |||
bool dropped_; | bool dropped_; | |||
/// Incoming header | /// Incoming header | |||
Header header_; | Header header_; | |||
/// Transport associated with us | /// Transport associated with us | |||
TransportPtr transport_; | TransportPtr transport_; | |||
/// Function that handles the incoming header | /// Function that handles the incoming header | |||
HeaderReceivedFunc header_func_; | HeaderReceivedFunc header_func_; | |||
/** | ||||
* If there is data available to read, we always try to read into our fix | ||||
ed read buffer, even if a read request | ||||
* has not been made. | ||||
*/ | ||||
uint8_t fixed_read_buffer_[READ_BUFFER_SIZE]; | ||||
uint32_t fixed_read_filled_; | ||||
/// Read buffer that ends up being passed to the read callback | /// Read buffer that ends up being passed to the read callback | |||
boost::shared_array<uint8_t> read_buffer_; | boost::shared_array<uint8_t> read_buffer_; | |||
/// Amount of data currently in the read buffer, in bytes | /// Amount of data currently in the read buffer, in bytes | |||
uint32_t read_filled_; | uint32_t read_filled_; | |||
/// Size of the read buffer, in bytes | /// Size of the read buffer, in bytes | |||
uint32_t read_size_; | uint32_t read_size_; | |||
/// Function to call when the read is finished | /// Function to call when the read is finished | |||
ReadFinishedFunc read_callback_; | ReadFinishedFunc read_callback_; | |||
/// Mutex used for protecting reading. Recursive because a read can imme diately cause another read through the callback. | /// Mutex used for protecting reading. Recursive because a read can imme diately cause another read through the callback. | |||
boost::recursive_mutex read_mutex_; | boost::recursive_mutex read_mutex_; | |||
skipping to change at line 254 | skipping to change at line 260 | |||
volatile uint32_t has_write_callback_; | volatile uint32_t has_write_callback_; | |||
/// Function to call when the outgoing header has finished writing | /// Function to call when the outgoing header has finished writing | |||
WriteFinishedFunc header_written_callback_; | WriteFinishedFunc header_written_callback_; | |||
/// Signal raised when this connection is dropped | /// Signal raised when this connection is dropped | |||
DropSignal drop_signal_; | DropSignal drop_signal_; | |||
/// Synchronizes drop() calls | /// Synchronizes drop() calls | |||
boost::recursive_mutex drop_mutex_; | boost::recursive_mutex drop_mutex_; | |||
/// If we're sending a header error we disable most other calls | ||||
bool sending_header_error_; | ||||
}; | }; | |||
typedef boost::shared_ptr<Connection> ConnectionPtr; | typedef boost::shared_ptr<Connection> ConnectionPtr; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_CONNECTION_H | #endif // ROSCPP_CONNECTION_H | |||
End of changes. 7 change blocks. | ||||
11 lines changed or deleted | 22 lines changed or added | |||
connection_manager.h | connection_manager.h | |||
---|---|---|---|---|
skipping to change at line 29 | skipping to change at line 29 | |||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#include "forwards.h" | #include "forwards.h" | |||
#include "connection.h" | ||||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/signals/connection.hpp> | #include <boost/signals/connection.hpp> | |||
namespace ros | namespace ros | |||
{ | { | |||
class PollManager; | class PollManager; | |||
typedef boost::shared_ptr<PollManager> PollManagerPtr; | typedef boost::shared_ptr<PollManager> PollManagerPtr; | |||
skipping to change at line 60 | skipping to change at line 61 | |||
/** @brief Get a new connection ID | /** @brief Get a new connection ID | |||
*/ | */ | |||
uint32_t getNewConnectionID(); | uint32_t getNewConnectionID(); | |||
/** @brief Add a connection to be tracked by the node. Will automaticall y remove them if they've been dropped, but from inside the ros thread | /** @brief Add a connection to be tracked by the node. Will automaticall y remove them if they've been dropped, but from inside the ros thread | |||
* | * | |||
* @param The connection to add | * @param The connection to add | |||
*/ | */ | |||
void addConnection(const ConnectionPtr& connection); | void addConnection(const ConnectionPtr& connection); | |||
void clear(); | void clear(Connection::DropReason reason); | |||
uint32_t getTCPPort(); | uint32_t getTCPPort(); | |||
uint32_t getUDPPort(); | uint32_t getUDPPort(); | |||
const TransportTCPPtr& getTCPServerTransport() { return tcpserver_transpo rt_; } | const TransportTCPPtr& getTCPServerTransport() { return tcpserver_transpo rt_; } | |||
const TransportUDPPtr& getUDPServerTransport() { return udpserver_transpo rt_; } | const TransportUDPPtr& getUDPServerTransport() { return udpserver_transpo rt_; } | |||
void udprosIncomingConnection(const TransportUDPPtr& transport, Header& h eader); | void udprosIncomingConnection(const TransportUDPPtr& transport, Header& h eader); | |||
void start(); | void start(); | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 2 lines changed or added | |||
console.h | console.h | |||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
// Author: Josh Faust | // Author: Josh Faust | |||
#ifndef ROSCONSOLE_ROSCONSOLE_H | #ifndef ROSCONSOLE_ROSCONSOLE_H | |||
#define ROSCONSOLE_ROSCONSOLE_H | #define ROSCONSOLE_ROSCONSOLE_H | |||
#include "log4cxx/logger.h" | ||||
#include <cstdio> | #include <cstdio> | |||
#include <sstream> | ||||
#include <ros/time.h> | ||||
// TODO: this header is no longer needed to be included here, but removing | ||||
it will break various code that incorrectly does not itself include log4cxx | ||||
/logger.h | ||||
// We should vet all the code using log4cxx directly and make sure the incl | ||||
udes/link flags are used in those packages, and then we can remove this inc | ||||
lude | ||||
#include <log4cxx/logger.h> | ||||
#ifdef __GNUC__ | #ifdef __GNUC__ | |||
#if __GNUC__ >= 3 | #if __GNUC__ >= 3 | |||
#define ROSCONSOLE_PRINTF_ATTRIBUTE(a, b) __attribute__ ((__format__ (__pri ntf__, a, b))); | #define ROSCONSOLE_PRINTF_ATTRIBUTE(a, b) __attribute__ ((__format__ (__pri ntf__, a, b))); | |||
#endif | #endif | |||
#endif | #endif | |||
#ifndef ROSCONSOLE_PRINTF_ATTRIBUTE | #ifndef ROSCONSOLE_PRINTF_ATTRIBUTE | |||
#define ROSCONSOLE_PRINTF_ATTRIBUTE(a, b) | #define ROSCONSOLE_PRINTF_ATTRIBUTE(a, b) | |||
#endif | #endif | |||
// log4cxx forward declarations | ||||
namespace log4cxx | ||||
{ | ||||
namespace helpers | ||||
{ | ||||
template<typename T> class ObjectPtrT; | ||||
} // namespace helpers | ||||
class Level; | ||||
typedef helpers::ObjectPtrT<Level> LevelPtr; | ||||
class Logger; | ||||
typedef helpers::ObjectPtrT<Logger> LoggerPtr; | ||||
} // namespace log4cxx | ||||
namespace boost | ||||
{ | ||||
template<typename T> class shared_array; | ||||
} | ||||
namespace ros | namespace ros | |||
{ | { | |||
namespace console | namespace console | |||
{ | { | |||
namespace levels | namespace levels | |||
{ | { | |||
enum Level | enum Level | |||
{ | { | |||
Debug, | Debug, | |||
skipping to change at line 83 | skipping to change at line 108 | |||
extern bool g_initialized; | extern bool g_initialized; | |||
/** | /** | |||
* \brief Don't call this directly. Performs any required initialization/c onfiguration. Happens automatically when using the macro API. | * \brief Don't call this directly. Performs any required initialization/c onfiguration. Happens automatically when using the macro API. | |||
* | * | |||
* If you're going to be using log4cxx or any of the ros::console functions , and need the system to be initialized, use the | * If you're going to be using log4cxx or any of the ros::console functions , and need the system to be initialized, use the | |||
* ROSCONSOLE_AUTOINIT macro. | * ROSCONSOLE_AUTOINIT macro. | |||
*/ | */ | |||
void initialize(); | void initialize(); | |||
struct FilterBase; | ||||
/** | /** | |||
* \brief Don't call this directly. Use the ROS_LOG() macro instead. | * \brief Don't call this directly. Use the ROS_LOG() macro instead. | |||
* @param level Logging level | * @param level Logging level | |||
* @param file File this logging statement is from (usually generated with __FILE__) | * @param file File this logging statement is from (usually generated with __FILE__) | |||
* @param line Line of code this logging statement is from (usually generat ed with __LINE__) | * @param line Line of code this logging statement is from (usually generat ed with __LINE__) | |||
* @param fmt Format string | * @param fmt Format string | |||
*/ | */ | |||
void print(log4cxx::LoggerPtr& logger, const log4cxx::LevelPtr& level, cons | void print(FilterBase* filter, log4cxx::Logger* logger, Level level, const | |||
t log4cxx::spi::LocationInfo& location, const char* fmt, ...) ROSCONSOLE_PR | char* file, int line, const char* function, const char* fmt, ...) ROSCONSOL | |||
INTF_ATTRIBUTE(4, 5); | E_PRINTF_ATTRIBUTE(7, 8); | |||
void print(FilterBase* filter, log4cxx::Logger* logger, Level level, const | ||||
std::stringstream& str, const char* file, int line, const char* function); | ||||
struct LogLocation; | struct LogLocation; | |||
/** | /** | |||
* \brief Registers a logging location with the system. | * \brief Registers a logging location with the system. | |||
* | * | |||
* This is used for the case where a logger's verbosity level changes, and we need to reset the enabled status of | * This is used for the case where a logger's verbosity level changes, and we need to reset the enabled status of | |||
* all the logging statements. | * all the logging statements. | |||
* @param loc The location to add | * @param loc The location to add | |||
*/ | */ | |||
skipping to change at line 113 | skipping to change at line 141 | |||
/** | /** | |||
* \brief Tells the system that a logger's level has changed | * \brief Tells the system that a logger's level has changed | |||
* | * | |||
* This must be called if a log4cxx::Logger's level has been changed in the middle of an application run. | * This must be called if a log4cxx::Logger's level has been changed in the middle of an application run. | |||
* Because of the way the static guard for enablement works, if a logger's level is changed and this | * Because of the way the static guard for enablement works, if a logger's level is changed and this | |||
* function is not called, only logging statements which are first hit *aft er* the change will be correct wrt | * function is not called, only logging statements which are first hit *aft er* the change will be correct wrt | |||
* that logger. | * that logger. | |||
*/ | */ | |||
void notifyLoggerLevelsChanged(); | void notifyLoggerLevelsChanged(); | |||
struct LogLocation | void setFixedFilterToken(const std::string& key, const std::string& val); | |||
/** | ||||
* \brief Parameter structure passed to FilterBase::isEnabled(...);. Inclu | ||||
des both input and output parameters | ||||
*/ | ||||
struct FilterParams | ||||
{ | { | |||
inline void initialize(const std::string& name) | // input parameters | |||
{ | const char* file; ///< [input] File the message c | |||
logger_ = log4cxx::Logger::getLogger(name); | ame from | |||
level_ = levels::Count; | int line; ///< [input] Line the message c | |||
logger_enabled_ = false; | ame from | |||
const char* function; ///< [input] Function the messa | ||||
ge came from | ||||
const char* message; ///< [input] The formatted mess | ||||
age that will be output | ||||
registerLogLocation(this); | // input/output parameters | |||
} | log4cxx::LoggerPtr logger; ///< [input/output] Logger that | |||
this message will be output to. If changed, uses the new logger | ||||
Level level; ///< [input/output] Severity le | ||||
vel. If changed, uses the new level | ||||
inline void setLevel(Level level) | // output parameters | |||
{ | std::string out_message; ///< [output] If set, writes th | |||
level_ = level; | is message instead of the original | |||
log4cxx_level_ = &g_level_lookup[level]; | }; | |||
} | ||||
inline void checkEnabled() | /** | |||
* \brief Base-class for filters. Filters allow full user-defined control | ||||
over whether or not a message should print. | ||||
* The ROS_X_FILTER... macros provide the filtering functionality. | ||||
* | ||||
* Filters get a chance to veto the message from printing at two times: fir | ||||
st before the message arguments are | ||||
* evaluated and the message is formatted, and then once the message is for | ||||
matted before it is printed. It is also possible | ||||
* to change the message, logger and severity level at this stage (see the | ||||
FilterParams struct for more details). | ||||
* | ||||
* When a ROS_X_FILTER... macro is called, here is the high-level view of h | ||||
ow it uses the filter passed in: | ||||
\verbatim | ||||
if (<logging level is enabled> && filter->isEnabled()) | ||||
{ | ||||
<format message> | ||||
<fill out FilterParams> | ||||
if (filter->isEnabled(params)) | ||||
{ | { | |||
logger_enabled_ = logger_->isEnabledFor(*log4cxx_level_); | <print message> | |||
} | } | |||
} | ||||
\endverbatim | ||||
*/ | ||||
class FilterBase | ||||
{ | ||||
public: | ||||
virtual ~FilterBase() {} | ||||
/** | ||||
* \brief Returns whether or not the log statement should be printed. Ca | ||||
lled before the log arguments are evaluated | ||||
* and the message is formatted. | ||||
*/ | ||||
inline virtual bool isEnabled() { return true; } | ||||
/** | ||||
* \brief Returns whether or not the log statement should be printed. Ca | ||||
lled once the message has been formatted, | ||||
* and allows you to change the message, logger and severity level if nec | ||||
essary. | ||||
*/ | ||||
inline virtual bool isEnabled(FilterParams& params) { return true; } | ||||
}; | ||||
log4cxx::LoggerPtr logger_; | struct LogLocation; | |||
/** | ||||
* \brief Internal | ||||
*/ | ||||
void initializeLogLocation(LogLocation* loc, const std::string& name, Level | ||||
level); | ||||
/** | ||||
* \brief Internal | ||||
*/ | ||||
void setLogLocationLevel(LogLocation* loc, Level level); | ||||
/** | ||||
* \brief Internal | ||||
*/ | ||||
void checkLogLocationEnabled(LogLocation* loc); | ||||
/** | ||||
* \brief Internal | ||||
*/ | ||||
struct LogLocation | ||||
{ | ||||
bool initialized_; | ||||
bool logger_enabled_; | bool logger_enabled_; | |||
ros::console::Level level_; | ros::console::Level level_; | |||
log4cxx::LevelPtr* log4cxx_level_; | log4cxx::Logger* logger_; | |||
}; | }; | |||
void vformatToBuffer(boost::shared_array<char>& buffer, size_t& buffer_size | ||||
, const char* fmt, va_list args); | ||||
void formatToBuffer(boost::shared_array<char>& buffer, size_t& buffer_size, | ||||
const char* fmt, ...); | ||||
std::string formatToString(const char* fmt, ...); | ||||
} // namespace console | } // namespace console | |||
} // namespace ros | } // namespace ros | |||
#ifdef WIN32 | #ifdef WIN32 | |||
#define ROS_LIKELY(x) (x) | #define ROS_LIKELY(x) (x) | |||
#define ROS_UNLIKELY(x) (x) | #define ROS_UNLIKELY(x) (x) | |||
#else | #else | |||
#define ROS_LIKELY(x) __builtin_expect((x),1) | #define ROS_LIKELY(x) __builtin_expect((x),1) | |||
#define ROS_UNLIKELY(x) __builtin_expect((x),0) | #define ROS_UNLIKELY(x) __builtin_expect((x),0) | |||
#endif | #endif | |||
#if defined(MSVC) | ||||
#define __ROSCONSOLE_FUNCTION__ __FUNCSIG__ | ||||
#elif defined(__GNUC__) | ||||
#define __ROSCONSOLE_FUNCTION__ __PRETTY_FUNCTION__ | ||||
#else | ||||
#define __ROSCONSOLE_FUNCTION__ "" | ||||
#endif | ||||
#ifdef ROS_PACKAGE_NAME | #ifdef ROS_PACKAGE_NAME | |||
#define ROSCONSOLE_PACKAGE_NAME ROS_PACKAGE_NAME | #define ROSCONSOLE_PACKAGE_NAME ROS_PACKAGE_NAME | |||
#else | #else | |||
#define ROSCONSOLE_PACKAGE_NAME "unknown_package" | #define ROSCONSOLE_PACKAGE_NAME "unknown_package" | |||
#endif | #endif | |||
#define ROSCONSOLE_ROOT_LOGGER_NAME "ros" | #define ROSCONSOLE_ROOT_LOGGER_NAME "ros" | |||
#define ROSCONSOLE_NAME_PREFIX ROSCONSOLE_ROOT_LOGGER_NAME "." ROSCONSOLE_P ACKAGE_NAME | #define ROSCONSOLE_NAME_PREFIX ROSCONSOLE_ROOT_LOGGER_NAME "." ROSCONSOLE_P ACKAGE_NAME | |||
#define ROSCONSOLE_DEFAULT_NAME ROSCONSOLE_NAME_PREFIX | #define ROSCONSOLE_DEFAULT_NAME ROSCONSOLE_NAME_PREFIX | |||
skipping to change at line 193 | skipping to change at line 288 | |||
#define ROSCONSOLE_AUTOINIT \ | #define ROSCONSOLE_AUTOINIT \ | |||
do \ | do \ | |||
{ \ | { \ | |||
if (ROS_UNLIKELY(!ros::console::g_initialized)) \ | if (ROS_UNLIKELY(!ros::console::g_initialized)) \ | |||
{ \ | { \ | |||
ros::console::initialize(); \ | ros::console::initialize(); \ | |||
} \ | } \ | |||
} while(0) | } while(0) | |||
#define ROSCONSOLE_DEFINE_LOCATION(cond, level, name) \ | #define ROSCONSOLE_DEFINE_LOCATION(cond, level, name) \ | |||
static ros::console::LogLocation loc; \ | ROSCONSOLE_AUTOINIT; \ | |||
if (ROS_UNLIKELY(loc.logger_ == NULL)) \ | static ros::console::LogLocation loc = {false, false, ros::console::level | |||
s::Count, 0}; /* Initialized at compile-time */ \ | ||||
if (ROS_UNLIKELY(!loc.initialized_)) \ | ||||
{ \ | { \ | |||
loc.initialize(name); \ | initializeLogLocation(&loc, name, level); \ | |||
} \ | } \ | |||
if (ROS_UNLIKELY(loc.level_ != level)) \ | if (ROS_UNLIKELY(loc.level_ != level)) \ | |||
{ \ | { \ | |||
loc.setLevel(level); \ | setLogLocationLevel(&loc, level); \ | |||
loc.checkEnabled(); \ | checkLogLocationEnabled(&loc); \ | |||
} \ | } \ | |||
bool enabled = loc.logger_enabled_ && (cond); | bool enabled = loc.logger_enabled_ && (cond); | |||
#define ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(filter, ...) \ | ||||
ros::console::print(filter, loc.logger_, loc.level_, __FILE__, __LINE__ | ||||
, __ROSCONSOLE_FUNCTION__, __VA_ARGS__) | ||||
#define ROSCONSOLE_PRINT_AT_LOCATION(...) \ | ||||
ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(0, __VA_ARGS__) | ||||
#define ROSCONSOLE_PRINT_STREAM_AT_LOCATION_WITH_FILTER(filter, args) \ | ||||
do \ | ||||
{ \ | ||||
std::stringstream ss; \ | ||||
ss << args; \ | ||||
ros::console::print(filter, loc.logger_, loc.level_, ss, __FILE__, __LI | ||||
NE__, __ROSCONSOLE_FUNCTION__); \ | ||||
} while (0) | ||||
#define ROSCONSOLE_PRINT_STREAM_AT_LOCATION(args) \ | ||||
ROSCONSOLE_PRINT_STREAM_AT_LOCATION_WITH_FILTER(0, args) | ||||
/** | /** | |||
* \brief Log to a given named logger at a given verbosity level, only if a given condition has been met, with printf-style formatting | * \brief Log to a given named logger at a given verbosity level, only if a given condition has been met, with printf-style formatting | |||
* | * | |||
* \note The condition will only be evaluated if this logging statement is enabled | * \note The condition will only be evaluated if this logging statement is enabled | |||
* | * | |||
* \param cond Boolean condition to be evaluated | * \param cond Boolean condition to be evaluated | |||
* \param level One of the levels specified in ros::console::levels::Level | * \param level One of the levels specified in ros::console::levels::Level | |||
* \param name Name of the logger. Note that this is the fully qualified n ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM E if you would like to use the default name. | * \param name Name of the logger. Note that this is the fully qualified n ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM E if you would like to use the default name. | |||
*/ | */ | |||
#define ROS_LOG_COND(cond, level, name, ...) \ | #define ROS_LOG_COND(cond, level, name, ...) \ | |||
do \ | do \ | |||
{ \ | { \ | |||
ROSCONSOLE_AUTOINIT; \ | ||||
ROSCONSOLE_DEFINE_LOCATION(cond, level, name); \ | ROSCONSOLE_DEFINE_LOCATION(cond, level, name); \ | |||
\ | \ | |||
if (ROS_UNLIKELY(enabled)) \ | if (ROS_UNLIKELY(enabled)) \ | |||
{ \ | { \ | |||
ros::console::print( loc.logger_, *loc.log4cxx_level_, LOG4CXX_LOCATI ON, __VA_ARGS__); \ | ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \ | |||
} \ | } \ | |||
} while(0) | } while(0) | |||
/** | /** | |||
* \brief Log to a given named logger at a given verbosity level, only if a given condition has been met, with stream-style formatting | * \brief Log to a given named logger at a given verbosity level, only if a given condition has been met, with stream-style formatting | |||
* | * | |||
* \note The condition will only be evaluated if this logging statement is enabled | * \note The condition will only be evaluated if this logging statement is enabled | |||
* | * | |||
* \param cond Boolean condition to be evaluated | * \param cond Boolean condition to be evaluated | |||
* \param level One of the levels specified in ros::console::levels::Level | * \param level One of the levels specified in ros::console::levels::Level | |||
* \param name Name of the logger. Note that this is the fully qualified n ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM E if you would like to use the default name. | * \param name Name of the logger. Note that this is the fully qualified n ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM E if you would like to use the default name. | |||
*/ | */ | |||
#define ROS_LOG_STREAM_COND(cond, level, name, args) \ | #define ROS_LOG_STREAM_COND(cond, level, name, args) \ | |||
do \ | do \ | |||
{ \ | { \ | |||
ROSCONSOLE_AUTOINIT; \ | ||||
ROSCONSOLE_DEFINE_LOCATION(cond, level, name); \ | ROSCONSOLE_DEFINE_LOCATION(cond, level, name); \ | |||
if (ROS_UNLIKELY(enabled)) \ | if (ROS_UNLIKELY(enabled)) \ | |||
{ \ | { \ | |||
log4cxx::helpers::MessageBuffer oss_; \ | ROSCONSOLE_PRINT_STREAM_AT_LOCATION(args); \ | |||
try \ | } \ | |||
{ \ | } while(0) | |||
loc.logger_->forcedLog(*loc.log4cxx_level_, oss_.str(oss_ << args), | ||||
LOG4CXX_LOCATION); \ | /** | |||
} \ | * \brief Log to a given named logger at a given verbosity level, only the | |||
catch (std::exception& e) \ | first time it is hit when enabled, with printf-style formatting | |||
{ \ | * | |||
fprintf(stderr, "Caught exception while logging: [%s]\n", e.what()); | * \param level One of the levels specified in ros::console::levels::Level | |||
\ | * \param name Name of the logger. Note that this is the fully qualified n | |||
} \ | ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM | |||
E if you would like to use the default name. | ||||
*/ | ||||
#define ROS_LOG_ONCE(level, name, ...) \ | ||||
do \ | ||||
{ \ | ||||
ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ | ||||
static bool hit = false; \ | ||||
if (ROS_UNLIKELY(enabled) && ROS_UNLIKELY(!hit)) \ | ||||
{ \ | ||||
hit = true; \ | ||||
ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \ | ||||
} \ | ||||
} while(0) | ||||
/** | ||||
* \brief Log to a given named logger at a given verbosity level, only the | ||||
first time it is hit when enabled, with printf-style formatting | ||||
* | ||||
* \param level One of the levels specified in ros::console::levels::Level | ||||
* \param name Name of the logger. Note that this is the fully qualified n | ||||
ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM | ||||
E if you would like to use the default name. | ||||
*/ | ||||
#define ROS_LOG_STREAM_ONCE(level, name, args) \ | ||||
do \ | ||||
{ \ | ||||
ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ | ||||
static bool hit = false; \ | ||||
if (ROS_UNLIKELY(enabled) && ROS_UNLIKELY(!hit)) \ | ||||
{ \ | ||||
hit = true; \ | ||||
ROSCONSOLE_PRINT_STREAM_AT_LOCATION(args); \ | ||||
} \ | ||||
} while(0) | ||||
/** | ||||
* \brief Log to a given named logger at a given verbosity level, limited t | ||||
o a specific rate of printing, with printf-style formatting | ||||
* | ||||
* \param level One of the levels specified in ros::console::levels::Level | ||||
* \param name Name of the logger. Note that this is the fully qualified n | ||||
ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM | ||||
E if you would like to use the default name. | ||||
* \param rate The rate it should actually trigger at | ||||
*/ | ||||
#define ROS_LOG_THROTTLE(rate, level, name, ...) \ | ||||
do \ | ||||
{ \ | ||||
ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ | ||||
static double last_hit = 0.0; \ | ||||
ros::Time now = ros::Time::now(); \ | ||||
if (ROS_UNLIKELY(enabled) && ROS_UNLIKELY(last_hit + rate <= now.toSec( | ||||
))) \ | ||||
{ \ | ||||
last_hit = now.toSec(); \ | ||||
ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \ | ||||
} \ | ||||
} while(0) | ||||
/** | ||||
* \brief Log to a given named logger at a given verbosity level, limited t | ||||
o a specific rate of printing, with printf-style formatting | ||||
* | ||||
* \param level One of the levels specified in ros::console::levels::Level | ||||
* \param name Name of the logger. Note that this is the fully qualified n | ||||
ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM | ||||
E if you would like to use the default name. | ||||
* \param rate The rate it should actually trigger at | ||||
*/ | ||||
#define ROS_LOG_STREAM_THROTTLE(rate, level, name, args) \ | ||||
do \ | ||||
{ \ | ||||
ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ | ||||
static double last_hit = 0.0; \ | ||||
ros::Time now = ros::Time::now(); \ | ||||
if (ROS_UNLIKELY(enabled) && ROS_UNLIKELY(last_hit + rate <= now.toSec( | ||||
))) \ | ||||
{ \ | ||||
last_hit = now.toSec(); \ | ||||
ROSCONSOLE_PRINT_STREAM_AT_LOCATION(args); \ | ||||
} \ | ||||
} while(0) | ||||
/** | ||||
* \brief Log to a given named logger at a given verbosity level, with user | ||||
-defined filtering, with printf-style formatting | ||||
* | ||||
* \param filter pointer to the filter to be used | ||||
* \param level One of the levels specified in ros::console::levels::Level | ||||
* \param name Name of the logger. Note that this is the fully qualified n | ||||
ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM | ||||
E if you would like to use the default name. | ||||
*/ | ||||
#define ROS_LOG_FILTER(filter, level, name, ...) \ | ||||
do \ | ||||
{ \ | ||||
ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ | ||||
if (ROS_UNLIKELY(enabled) && (filter)->isEnabled()) \ | ||||
{ \ | ||||
ROSCONSOLE_PRINT_AT_LOCATION_WITH_FILTER(filter, __VA_ARGS__); \ | ||||
} \ | ||||
} while(0) | ||||
/** | ||||
* \brief Log to a given named logger at a given verbosity level, with user | ||||
-defined filtering, with stream-style formatting | ||||
* | ||||
* \param cond Boolean condition to be evaluated | ||||
* \param level One of the levels specified in ros::console::levels::Level | ||||
* \param name Name of the logger. Note that this is the fully qualified n | ||||
ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM | ||||
E if you would like to use the default name. | ||||
*/ | ||||
#define ROS_LOG_STREAM_FILTER(filter, level, name, args) \ | ||||
do \ | ||||
{ \ | ||||
ROSCONSOLE_DEFINE_LOCATION(true, level, name); \ | ||||
if (ROS_UNLIKELY(enabled) && (filter)->isEnabled()) \ | ||||
{ \ | ||||
ROSCONSOLE_PRINT_STREAM_AT_LOCATION_WITH_FILTER(filter, args); \ | ||||
} \ | } \ | |||
} while(0) | } while(0) | |||
/** | /** | |||
* \brief Log to a given named logger at a given verbosity level, with prin tf-style formatting | * \brief Log to a given named logger at a given verbosity level, with prin tf-style formatting | |||
* | * | |||
* \param level One of the levels specified in ros::console::levels::Level | * \param level One of the levels specified in ros::console::levels::Level | |||
* \param name Name of the logger. Note that this is the fully qualified n ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM E if you would like to use the default name. | * \param name Name of the logger. Note that this is the fully qualified n ame, and does NOT include "ros.<package_name>". Use ROSCONSOLE_DEFAULT_NAM E if you would like to use the default name. | |||
*/ | */ | |||
#define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS __) | #define ROS_LOG(level, name, ...) ROS_LOG_COND(true, level, name, __VA_ARGS __) | |||
End of changes. 24 change blocks. | ||||
40 lines changed or deleted | 298 lines changed or added | |||
exceptions.h | exceptions.h | |||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_EXCEPTIONS_H | #ifndef ROSCPP_EXCEPTIONS_H | |||
#define ROSCPP_EXCEPTIONS_H | #define ROSCPP_EXCEPTIONS_H | |||
#include <stdexcept> | #include <ros/exception.h> | |||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Base class for all exceptions thrown by roscpp | ||||
*/ | ||||
class Exception : public std::runtime_error | ||||
{ | ||||
public: | ||||
Exception(const std::string& what) | ||||
: std::runtime_error(what) | ||||
{} | ||||
}; | ||||
/** | ||||
* \brief Thrown when an invalid node name is specified to ros::init() | * \brief Thrown when an invalid node name is specified to ros::init() | |||
*/ | */ | |||
class InvalidNodeNameException : public ros::Exception | class InvalidNodeNameException : public ros::Exception | |||
{ | { | |||
public: | public: | |||
InvalidNodeNameException(const std::string& name, const std::string& reas on) | InvalidNodeNameException(const std::string& name, const std::string& reas on) | |||
: Exception("Invalid node name [" + name + "]: " + reason) | : Exception("Invalid node name [" + name + "]: " + reason) | |||
{} | {} | |||
}; | }; | |||
skipping to change at line 70 | skipping to change at line 59 | |||
* function. | * function. | |||
*/ | */ | |||
class InvalidNameException : public ros::Exception | class InvalidNameException : public ros::Exception | |||
{ | { | |||
public: | public: | |||
InvalidNameException(const std::string& msg) | InvalidNameException(const std::string& msg) | |||
: Exception(msg) | : Exception(msg) | |||
{} | {} | |||
}; | }; | |||
/** | ||||
* \brief Thrown when a second (third,...) subscription is attempted with c | ||||
onflicting | ||||
* arguments. | ||||
*/ | ||||
class ConflictingSubscriptionException : public ros::Exception | ||||
{ | ||||
public: | ||||
ConflictingSubscriptionException(const std::string& msg) | ||||
: Exception(msg) | ||||
{} | ||||
}; | ||||
/** | ||||
* \brief Thrown when an invalid parameter is passed to a method | ||||
*/ | ||||
class InvalidParameterException : public ros::Exception | ||||
{ | ||||
public: | ||||
InvalidParameterException(const std::string& msg) | ||||
: Exception(msg) | ||||
{} | ||||
}; | ||||
/** | ||||
* \brief Thrown when an invalid port is specified | ||||
*/ | ||||
class InvalidPortException : public ros::Exception | ||||
{ | ||||
public: | ||||
InvalidPortException(const std::string& msg) | ||||
: Exception(msg) | ||||
{} | ||||
}; | ||||
} // namespace ros | } // namespace ros | |||
#endif | #endif | |||
End of changes. 3 change blocks. | ||||
12 lines changed or deleted | 36 lines changed or added | |||
file_log.h | file_log.h | |||
---|---|---|---|---|
skipping to change at line 55 | skipping to change at line 55 | |||
} | } | |||
#define ROSCPP_LOG_DEBUG(...) \ | #define ROSCPP_LOG_DEBUG(...) \ | |||
do \ | do \ | |||
{ \ | { \ | |||
ROSCONSOLE_AUTOINIT; \ | ROSCONSOLE_AUTOINIT; \ | |||
ROSCONSOLE_DEFINE_LOCATION(true, ros::console::levels::Debug, ROSCONS OLE_DEFAULT_NAME); \ | ROSCONSOLE_DEFINE_LOCATION(true, ros::console::levels::Debug, ROSCONS OLE_DEFAULT_NAME); \ | |||
\ | \ | |||
if (ROS_UNLIKELY(enabled)) \ | if (ROS_UNLIKELY(enabled)) \ | |||
{ \ | { \ | |||
ros::console::print( loc.logger_, *loc.log4cxx_level_, LOG4CXX_LOCA TION, __VA_ARGS__); \ | ROSCONSOLE_PRINT_AT_LOCATION(__VA_ARGS__); \ | |||
} \ | } \ | |||
else if (log4cxx::LoggerPtr logger = ros::file_log::getFileOnlyLogger ()) \ | else if (log4cxx::LoggerPtr logger = ros::file_log::getFileOnlyLogger ()) \ | |||
{ \ | { \ | |||
ros::console::print(logger, ros::file_log::getDebugLevel(), LOG4CXX _LOCATION, __VA_ARGS__); \ | ros::console::print(0, logger, ros::console::levels::Debug, __FILE_ _, __LINE__, __ROSCONSOLE_FUNCTION__, __VA_ARGS__); \ | |||
} \ | } \ | |||
} while(0) | } while(0) | |||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief internal | * \brief internal | |||
*/ | */ | |||
namespace file_log | namespace file_log | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added | |||
forwards.h | forwards.h | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
#include <ros/time.h> | #include <ros/time.h> | |||
#include "macros.h" | #include "macros.h" | |||
#include "exceptions.h" | #include "exceptions.h" | |||
namespace ros | namespace ros | |||
{ | { | |||
typedef boost::shared_ptr<void> VoidPtr; | typedef boost::shared_ptr<void> VoidPtr; | |||
typedef boost::weak_ptr<void> VoidWPtr; | typedef boost::weak_ptr<void> VoidWPtr; | |||
typedef boost::shared_ptr<void const> VoidConstPtr; | ||||
typedef boost::weak_ptr<void const> VoidConstWPtr; | ||||
class Header; | class Header; | |||
class Transport; | class Transport; | |||
typedef boost::shared_ptr<Transport> TransportPtr; | typedef boost::shared_ptr<Transport> TransportPtr; | |||
class TransportTCP; | class TransportTCP; | |||
typedef boost::shared_ptr<TransportTCP> TransportTCPPtr; | typedef boost::shared_ptr<TransportTCP> TransportTCPPtr; | |||
class TransportUDP; | class TransportUDP; | |||
typedef boost::shared_ptr<TransportUDP> TransportUDPPtr; | typedef boost::shared_ptr<TransportUDP> TransportUDPPtr; | |||
class Connection; | class Connection; | |||
typedef boost::shared_ptr<Connection> ConnectionPtr; | typedef boost::shared_ptr<Connection> ConnectionPtr; | |||
skipping to change at line 107 | skipping to change at line 109 | |||
class CallbackQueue; | class CallbackQueue; | |||
class CallbackQueueInterface; | class CallbackQueueInterface; | |||
class CallbackInterface; | class CallbackInterface; | |||
typedef boost::shared_ptr<CallbackInterface> CallbackInterfacePtr; | typedef boost::shared_ptr<CallbackInterface> CallbackInterfacePtr; | |||
struct SubscriberCallbacks | struct SubscriberCallbacks | |||
{ | { | |||
SubscriberCallbacks(const SubscriberStatusCallback& connect = SubscriberS tatusCallback(), | SubscriberCallbacks(const SubscriberStatusCallback& connect = SubscriberS tatusCallback(), | |||
const SubscriberStatusCallback& disconnect = Subscrib erStatusCallback(), | const SubscriberStatusCallback& disconnect = Subscrib erStatusCallback(), | |||
const VoidPtr& tracked_object = VoidPtr(), | const VoidConstPtr& tracked_object = VoidConstPtr(), | |||
CallbackQueueInterface* callback_queue = 0) | CallbackQueueInterface* callback_queue = 0) | |||
: connect_(connect) | : connect_(connect) | |||
, disconnect_(disconnect) | , disconnect_(disconnect) | |||
, callback_queue_(callback_queue) | , callback_queue_(callback_queue) | |||
{ | { | |||
has_tracked_object_ = false; | has_tracked_object_ = false; | |||
if (tracked_object) | if (tracked_object) | |||
{ | { | |||
has_tracked_object_ = true; | has_tracked_object_ = true; | |||
tracked_object_ = tracked_object; | tracked_object_ = tracked_object; | |||
} | } | |||
} | } | |||
SubscriberStatusCallback connect_; | SubscriberStatusCallback connect_; | |||
SubscriberStatusCallback disconnect_; | SubscriberStatusCallback disconnect_; | |||
bool has_tracked_object_; | bool has_tracked_object_; | |||
VoidWPtr tracked_object_; | VoidConstWPtr tracked_object_; | |||
CallbackQueueInterface* callback_queue_; | CallbackQueueInterface* callback_queue_; | |||
}; | }; | |||
typedef boost::shared_ptr<SubscriberCallbacks> SubscriberCallbacksPtr; | typedef boost::shared_ptr<SubscriberCallbacks> SubscriberCallbacksPtr; | |||
/** | /** | |||
* \brief Structure passed as a parameter to the callback invoked by a ros: :Timer | * \brief Structure passed as a parameter to the callback invoked by a ros: :Timer | |||
*/ | */ | |||
struct TimerEvent | struct TimerEvent | |||
{ | { | |||
Time last_expected; ///< In a perfect world, this is when the last callback should have happened | Time last_expected; ///< In a perfect world, this is when the last callback should have happened | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added | |||
init.h | init.h | |||
---|---|---|---|---|
skipping to change at line 205 | skipping to change at line 205 | |||
CallbackQueue* getGlobalCallbackQueue(); | CallbackQueue* getGlobalCallbackQueue(); | |||
/** | /** | |||
* \brief returns a vector of program arguments that do not include any ROS remapping arguments. Useful if you need | * \brief returns a vector of program arguments that do not include any ROS remapping arguments. Useful if you need | |||
* to parse your arguments to determine your node name | * to parse your arguments to determine your node name | |||
* | * | |||
* \param argc the number of command-line arguments | * \param argc the number of command-line arguments | |||
* \param argv the command-line arguments | * \param argv the command-line arguments | |||
* \param [out] args_out Output args, stripped of any ROS args | * \param [out] args_out Output args, stripped of any ROS args | |||
*/ | */ | |||
void removeROSArgs(int argc, const char** argv, V_string& args_out); | void removeROSArgs(int argc, const char* const* argv, V_string& args_out); | |||
} | } | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
intraprocess_publisher_link.h | intraprocess_publisher_link.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_INTRAPROCESS_PUBLISHER_LINK_H | #ifndef ROSCPP_INTRAPROCESS_PUBLISHER_LINK_H | |||
#define ROSCPP_INTRAPROCESS_PUBLISHER_LINK_H | #define ROSCPP_INTRAPROCESS_PUBLISHER_LINK_H | |||
#include "publisher_link.h" | #include "publisher_link.h" | |||
#include <boost/thread/recursive_mutex.hpp> | ||||
namespace ros | namespace ros | |||
{ | { | |||
class Subscription; | class Subscription; | |||
typedef boost::shared_ptr<Subscription> SubscriptionPtr; | typedef boost::shared_ptr<Subscription> SubscriptionPtr; | |||
typedef boost::weak_ptr<Subscription> SubscriptionWPtr; | typedef boost::weak_ptr<Subscription> SubscriptionWPtr; | |||
class IntraProcessSubscriberLink; | class IntraProcessSubscriberLink; | |||
typedef boost::shared_ptr<IntraProcessSubscriberLink> IntraProcessSubscribe rLinkPtr; | typedef boost::shared_ptr<IntraProcessSubscriberLink> IntraProcessSubscribe rLinkPtr; | |||
/** | /** | |||
skipping to change at line 60 | skipping to change at line 62 | |||
virtual ~IntraProcessPublisherLink(); | virtual ~IntraProcessPublisherLink(); | |||
void setPublisher(const IntraProcessSubscriberLinkPtr& publisher); | void setPublisher(const IntraProcessSubscriberLinkPtr& publisher); | |||
virtual std::string getTransportType(); | virtual std::string getTransportType(); | |||
virtual void drop(); | virtual void drop(); | |||
/** | /** | |||
* \brief Handles handing off a received message to the subscription, whe re it will be deserialized and called back | * \brief Handles handing off a received message to the subscription, whe re it will be deserialized and called back | |||
*/ | */ | |||
virtual void handleMessage(const boost::shared_array<uint8_t>& buffer, si | virtual void handleMessage(const SerializedMessage& m, bool ser, bool noc | |||
ze_t num_bytes); | opy); | |||
void getPublishTypes(bool& ser, bool& nocopy, const std::type_info& ti); | ||||
private: | private: | |||
IntraProcessSubscriberLinkPtr publisher_; | IntraProcessSubscriberLinkPtr publisher_; | |||
bool dropped_; | bool dropped_; | |||
boost::recursive_mutex drop_mutex_; | ||||
}; | }; | |||
typedef boost::shared_ptr<IntraProcessPublisherLink> IntraProcessPublisherL inkPtr; | typedef boost::shared_ptr<IntraProcessPublisherLink> IntraProcessPublisherL inkPtr; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_INTRAPROCESS_PUBLISHER_LINK_H | #endif // ROSCPP_INTRAPROCESS_PUBLISHER_LINK_H | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 7 lines changed or added | |||
intraprocess_subscriber_link.h | intraprocess_subscriber_link.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_INTRAPROCESS_SUBSCRIBER_LINK_H | #ifndef ROSCPP_INTRAPROCESS_SUBSCRIBER_LINK_H | |||
#define ROSCPP_INTRAPROCESS_SUBSCRIBER_LINK_H | #define ROSCPP_INTRAPROCESS_SUBSCRIBER_LINK_H | |||
#include "subscriber_link.h" | #include "subscriber_link.h" | |||
#include <boost/thread/recursive_mutex.hpp> | ||||
namespace ros | namespace ros | |||
{ | { | |||
class IntraProcessPublisherLink; | class IntraProcessPublisherLink; | |||
typedef boost::shared_ptr<IntraProcessPublisherLink> IntraProcessPublisherL inkPtr; | typedef boost::shared_ptr<IntraProcessPublisherLink> IntraProcessPublisherL inkPtr; | |||
/** | /** | |||
* \brief SubscriberLink handles broadcasting messages to a single subscrib er on a single topic | * \brief SubscriberLink handles broadcasting messages to a single subscrib er on a single topic | |||
*/ | */ | |||
class IntraProcessSubscriberLink : public SubscriberLink | class IntraProcessSubscriberLink : public SubscriberLink | |||
{ | { | |||
public: | public: | |||
IntraProcessSubscriberLink(const PublicationPtr& parent); | IntraProcessSubscriberLink(const PublicationPtr& parent); | |||
virtual ~IntraProcessSubscriberLink(); | virtual ~IntraProcessSubscriberLink(); | |||
void setSubscriber(const IntraProcessPublisherLinkPtr& subscriber); | void setSubscriber(const IntraProcessPublisherLinkPtr& subscriber); | |||
bool isLatching(); | bool isLatching(); | |||
virtual bool publish(const Message& m); | virtual void enqueueMessage(const SerializedMessage& m, bool ser, bool no | |||
virtual void enqueueMessage(const SerializedMessage& m); | copy); | |||
virtual void drop(); | virtual void drop(); | |||
virtual std::string getTransportType(); | virtual std::string getTransportType(); | |||
virtual bool isIntraprocess() { return true; } | ||||
virtual void getPublishTypes(bool& ser, bool& nocopy, const std::type_inf | ||||
o& ti); | ||||
private: | private: | |||
IntraProcessPublisherLinkPtr subscriber_; | IntraProcessPublisherLinkPtr subscriber_; | |||
bool dropped_; | bool dropped_; | |||
boost::recursive_mutex drop_mutex_; | ||||
}; | }; | |||
typedef boost::shared_ptr<IntraProcessSubscriberLink> IntraProcessSubscribe rLinkPtr; | typedef boost::shared_ptr<IntraProcessSubscriberLink> IntraProcessSubscribe rLinkPtr; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_INTRAPROCESS_SUBSCRIBER_LINK_H | #endif // ROSCPP_INTRAPROCESS_SUBSCRIBER_LINK_H | |||
End of changes. 4 change blocks. | ||||
2 lines changed or deleted | 8 lines changed or added | |||
macros.h | macros.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_MACROS_H | #ifndef ROSCPP_MACROS_H | |||
#define ROSCPP_MACROS_H | #define ROSCPP_MACROS_H | |||
#if defined(__GNUC__) | #if defined(__GNUC__) | |||
#define ROSCPP_DEPRECATED __attribute__((deprecated)) | #define ROSCPP_DEPRECATED __attribute__((deprecated)) | |||
#define ROSCPP_FORCEINLINE __attribute__((always_inline)) | ||||
#elif defined(MSVC) | ||||
#define ROSCPP_DEPRECATED | ||||
#define ROSCPP_FORCEINLINE __forceinline | ||||
#else | #else | |||
#define ROSCPP_DEPRECATED | #define ROSCPP_DEPRECATED | |||
#define ROSCPP_FORCEINLINE | ||||
#endif | #endif | |||
#endif | #endif | |||
End of changes. 2 change blocks. | ||||
0 lines changed or deleted | 5 lines changed or added | |||
macros_generated.h | macros_generated.h | |||
---|---|---|---|---|
skipping to change at line 41 | skipping to change at line 41 | |||
#if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_DEBUG) | #if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_DEBUG) | |||
#define ROS_DEBUG(...) | #define ROS_DEBUG(...) | |||
#define ROS_DEBUG_STREAM(args) | #define ROS_DEBUG_STREAM(args) | |||
#define ROS_DEBUG_NAMED(name, ...) | #define ROS_DEBUG_NAMED(name, ...) | |||
#define ROS_DEBUG_STREAM_NAMED(name, args) | #define ROS_DEBUG_STREAM_NAMED(name, args) | |||
#define ROS_DEBUG_COND(cond, ...) | #define ROS_DEBUG_COND(cond, ...) | |||
#define ROS_DEBUG_STREAM_COND(cond, args) | #define ROS_DEBUG_STREAM_COND(cond, args) | |||
#define ROS_DEBUG_COND_NAMED(cond, name, ...) | #define ROS_DEBUG_COND_NAMED(cond, name, ...) | |||
#define ROS_DEBUG_STREAM_COND_NAMED(cond, name, args) | #define ROS_DEBUG_STREAM_COND_NAMED(cond, name, args) | |||
#define ROS_DEBUG_ONCE(...) | ||||
#define ROS_DEBUG_STREAM_ONCE(args) | ||||
#define ROS_DEBUG_ONCE_NAMED(name, ...) | ||||
#define ROS_DEBUG_STREAM_ONCE_NAMED(name, args) | ||||
#define ROS_DEBUG_THROTTLE(rate, ...) | ||||
#define ROS_DEBUG_STREAM_THROTTLE(rate, args) | ||||
#define ROS_DEBUG_THROTTLE_NAMED(rate, name, ...) | ||||
#define ROS_DEBUG_STREAM_THROTTLE_NAMED(rate, name, args) | ||||
#define ROS_DEBUG_FILTER(filter, ...) | ||||
#define ROS_DEBUG_STREAM_FILTER(filter, args) | ||||
#define ROS_DEBUG_FILTER_NAMED(filter, name, ...) | ||||
#define ROS_DEBUG_STREAM_FILTER_NAMED(filter, name, args) | ||||
#else | #else | |||
#define ROS_DEBUG(...) ROS_LOG(ros::console::levels::Debug, ROSCONSOLE_DEFA ULT_NAME, __VA_ARGS__) | #define ROS_DEBUG(...) ROS_LOG(ros::console::levels::Debug, ROSCONSOLE_DEFA ULT_NAME, __VA_ARGS__) | |||
#define ROS_DEBUG_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Debug, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_DEBUG_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Debug, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_DEBUG_NAMED(name, ...) ROS_LOG(ros::console::levels::Debug, std ::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | #define ROS_DEBUG_NAMED(name, ...) ROS_LOG(ros::console::levels::Debug, std ::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | |||
#define ROS_DEBUG_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::lev els::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_DEBUG_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::lev els::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_DEBUG_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels:: Debug, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | #define ROS_DEBUG_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels:: Debug, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | |||
#define ROS_DEBUG_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::co nsole::levels::Debug, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_DEBUG_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::co nsole::levels::Debug, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_DEBUG_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::conso le::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_A RGS__) | #define ROS_DEBUG_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::conso le::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_A RGS__) | |||
#define ROS_DEBUG_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(c ond, ros::console::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_DEBUG_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(c ond, ros::console::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_DEBUG_ONCE(...) ROS_LOG_ONCE(ros::console::levels::Debug, ROSCO | ||||
NSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_DEBUG_STREAM_ONCE(args) ROS_LOG_STREAM_ONCE(ros::console::level | ||||
s::Debug, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_DEBUG_ONCE_NAMED(name, ...) ROS_LOG_ONCE(ros::console::levels:: | ||||
Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | ||||
#define ROS_DEBUG_STREAM_ONCE_NAMED(name, args) ROS_LOG_STREAM_ONCE(ros::co | ||||
nsole::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, arg | ||||
s) | ||||
#define ROS_DEBUG_THROTTLE(rate, ...) ROS_LOG_THROTTLE(rate, ros::console:: | ||||
levels::Debug, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_DEBUG_STREAM_THROTTLE(rate, args) ROS_LOG_STREAM_THROTTLE(rate, | ||||
ros::console::levels::Debug, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_DEBUG_THROTTLE_NAMED(rate, name, ...) ROS_LOG_THROTTLE(rate, ro | ||||
s::console::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name | ||||
, __VA_ARGS__) | ||||
#define ROS_DEBUG_STREAM_THROTTLE_NAMED(rate, name, args) ROS_LOG_STREAM_TH | ||||
ROTTLE(rate, ros::console::levels::Debug, std::string(ROSCONSOLE_NAME_PREFI | ||||
X) + "." + name, args) | ||||
#define ROS_DEBUG_FILTER(filter, ...) ROS_LOG_FILTER(filter, ros::console:: | ||||
levels::Debug, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_DEBUG_STREAM_FILTER(filter, args) ROS_LOG_STREAM_FILTER(filter, | ||||
ros::console::levels::Debug, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_DEBUG_FILTER_NAMED(filter, name, ...) ROS_LOG_FILTER(filter, ro | ||||
s::console::levels::Debug, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name | ||||
, __VA_ARGS__) | ||||
#define ROS_DEBUG_STREAM_FILTER_NAMED(filter, name, args) ROS_LOG_STREAM_FI | ||||
LTER(filter, ros::console::levels::Debug, std::string(ROSCONSOLE_NAME_PREFI | ||||
X) + "." + name, args) | ||||
#endif | #endif | |||
#if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_INFO) | #if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_INFO) | |||
#define ROS_INFO(...) | #define ROS_INFO(...) | |||
#define ROS_INFO_STREAM(args) | #define ROS_INFO_STREAM(args) | |||
#define ROS_INFO_NAMED(name, ...) | #define ROS_INFO_NAMED(name, ...) | |||
#define ROS_INFO_STREAM_NAMED(name, args) | #define ROS_INFO_STREAM_NAMED(name, args) | |||
#define ROS_INFO_COND(cond, ...) | #define ROS_INFO_COND(cond, ...) | |||
#define ROS_INFO_STREAM_COND(cond, args) | #define ROS_INFO_STREAM_COND(cond, args) | |||
#define ROS_INFO_COND_NAMED(cond, name, ...) | #define ROS_INFO_COND_NAMED(cond, name, ...) | |||
#define ROS_INFO_STREAM_COND_NAMED(cond, name, args) | #define ROS_INFO_STREAM_COND_NAMED(cond, name, args) | |||
#define ROS_INFO_ONCE(...) | ||||
#define ROS_INFO_STREAM_ONCE(args) | ||||
#define ROS_INFO_ONCE_NAMED(name, ...) | ||||
#define ROS_INFO_STREAM_ONCE_NAMED(name, args) | ||||
#define ROS_INFO_THROTTLE(rate, ...) | ||||
#define ROS_INFO_STREAM_THROTTLE(rate, args) | ||||
#define ROS_INFO_THROTTLE_NAMED(rate, name, ...) | ||||
#define ROS_INFO_STREAM_THROTTLE_NAMED(rate, name, args) | ||||
#define ROS_INFO_FILTER(filter, ...) | ||||
#define ROS_INFO_STREAM_FILTER(filter, args) | ||||
#define ROS_INFO_FILTER_NAMED(filter, name, ...) | ||||
#define ROS_INFO_STREAM_FILTER_NAMED(filter, name, args) | ||||
#else | #else | |||
#define ROS_INFO(...) ROS_LOG(ros::console::levels::Info, ROSCONSOLE_DEFAUL T_NAME, __VA_ARGS__) | #define ROS_INFO(...) ROS_LOG(ros::console::levels::Info, ROSCONSOLE_DEFAUL T_NAME, __VA_ARGS__) | |||
#define ROS_INFO_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Info, RO SCONSOLE_DEFAULT_NAME, args) | #define ROS_INFO_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Info, RO SCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_INFO_NAMED(name, ...) ROS_LOG(ros::console::levels::Info, std:: string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | #define ROS_INFO_NAMED(name, ...) ROS_LOG(ros::console::levels::Info, std:: string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | |||
#define ROS_INFO_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::leve ls::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_INFO_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::leve ls::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_INFO_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels::I nfo, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | #define ROS_INFO_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels::I nfo, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | |||
#define ROS_INFO_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::con sole::levels::Info, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_INFO_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::con sole::levels::Info, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_INFO_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::consol e::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARG S__) | #define ROS_INFO_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::consol e::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARG S__) | |||
#define ROS_INFO_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(co nd, ros::console::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_INFO_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(co nd, ros::console::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_INFO_ONCE(...) ROS_LOG_ONCE(ros::console::levels::Info, ROSCONS | ||||
OLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_INFO_STREAM_ONCE(args) ROS_LOG_STREAM_ONCE(ros::console::levels | ||||
::Info, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_INFO_ONCE_NAMED(name, ...) ROS_LOG_ONCE(ros::console::levels::I | ||||
nfo, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | ||||
#define ROS_INFO_STREAM_ONCE_NAMED(name, args) ROS_LOG_STREAM_ONCE(ros::con | ||||
sole::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | ||||
#define ROS_INFO_THROTTLE(rate, ...) ROS_LOG_THROTTLE(rate, ros::console::l | ||||
evels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_INFO_STREAM_THROTTLE(rate, args) ROS_LOG_STREAM_THROTTLE(rate, | ||||
ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_INFO_THROTTLE_NAMED(rate, name, ...) ROS_LOG_THROTTLE(rate, ros | ||||
::console::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, | ||||
__VA_ARGS__) | ||||
#define ROS_INFO_STREAM_THROTTLE_NAMED(rate, name, args) ROS_LOG_STREAM_THR | ||||
OTTLE(rate, ros::console::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) | ||||
+ "." + name, args) | ||||
#define ROS_INFO_FILTER(filter, ...) ROS_LOG_FILTER(filter, ros::console::l | ||||
evels::Info, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_INFO_STREAM_FILTER(filter, args) ROS_LOG_STREAM_FILTER(filter, | ||||
ros::console::levels::Info, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_INFO_FILTER_NAMED(filter, name, ...) ROS_LOG_FILTER(filter, ros | ||||
::console::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, | ||||
__VA_ARGS__) | ||||
#define ROS_INFO_STREAM_FILTER_NAMED(filter, name, args) ROS_LOG_STREAM_FIL | ||||
TER(filter, ros::console::levels::Info, std::string(ROSCONSOLE_NAME_PREFIX) | ||||
+ "." + name, args) | ||||
#endif | #endif | |||
#if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_WARN) | #if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_WARN) | |||
#define ROS_WARN(...) | #define ROS_WARN(...) | |||
#define ROS_WARN_STREAM(args) | #define ROS_WARN_STREAM(args) | |||
#define ROS_WARN_NAMED(name, ...) | #define ROS_WARN_NAMED(name, ...) | |||
#define ROS_WARN_STREAM_NAMED(name, args) | #define ROS_WARN_STREAM_NAMED(name, args) | |||
#define ROS_WARN_COND(cond, ...) | #define ROS_WARN_COND(cond, ...) | |||
#define ROS_WARN_STREAM_COND(cond, args) | #define ROS_WARN_STREAM_COND(cond, args) | |||
#define ROS_WARN_COND_NAMED(cond, name, ...) | #define ROS_WARN_COND_NAMED(cond, name, ...) | |||
#define ROS_WARN_STREAM_COND_NAMED(cond, name, args) | #define ROS_WARN_STREAM_COND_NAMED(cond, name, args) | |||
#define ROS_WARN_ONCE(...) | ||||
#define ROS_WARN_STREAM_ONCE(args) | ||||
#define ROS_WARN_ONCE_NAMED(name, ...) | ||||
#define ROS_WARN_STREAM_ONCE_NAMED(name, args) | ||||
#define ROS_WARN_THROTTLE(rate, ...) | ||||
#define ROS_WARN_STREAM_THROTTLE(rate, args) | ||||
#define ROS_WARN_THROTTLE_NAMED(rate, name, ...) | ||||
#define ROS_WARN_STREAM_THROTTLE_NAMED(rate, name, args) | ||||
#define ROS_WARN_FILTER(filter, ...) | ||||
#define ROS_WARN_STREAM_FILTER(filter, args) | ||||
#define ROS_WARN_FILTER_NAMED(filter, name, ...) | ||||
#define ROS_WARN_STREAM_FILTER_NAMED(filter, name, args) | ||||
#else | #else | |||
#define ROS_WARN(...) ROS_LOG(ros::console::levels::Warn, ROSCONSOLE_DEFAUL T_NAME, __VA_ARGS__) | #define ROS_WARN(...) ROS_LOG(ros::console::levels::Warn, ROSCONSOLE_DEFAUL T_NAME, __VA_ARGS__) | |||
#define ROS_WARN_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Warn, RO SCONSOLE_DEFAULT_NAME, args) | #define ROS_WARN_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Warn, RO SCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_WARN_NAMED(name, ...) ROS_LOG(ros::console::levels::Warn, std:: string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | #define ROS_WARN_NAMED(name, ...) ROS_LOG(ros::console::levels::Warn, std:: string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | |||
#define ROS_WARN_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::leve ls::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_WARN_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::leve ls::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_WARN_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels::W arn, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | #define ROS_WARN_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels::W arn, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | |||
#define ROS_WARN_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::con sole::levels::Warn, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_WARN_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::con sole::levels::Warn, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_WARN_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::consol e::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARG S__) | #define ROS_WARN_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::consol e::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARG S__) | |||
#define ROS_WARN_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(co nd, ros::console::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_WARN_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(co nd, ros::console::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_WARN_ONCE(...) ROS_LOG_ONCE(ros::console::levels::Warn, ROSCONS | ||||
OLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_WARN_STREAM_ONCE(args) ROS_LOG_STREAM_ONCE(ros::console::levels | ||||
::Warn, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_WARN_ONCE_NAMED(name, ...) ROS_LOG_ONCE(ros::console::levels::W | ||||
arn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | ||||
#define ROS_WARN_STREAM_ONCE_NAMED(name, args) ROS_LOG_STREAM_ONCE(ros::con | ||||
sole::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | ||||
#define ROS_WARN_THROTTLE(rate, ...) ROS_LOG_THROTTLE(rate, ros::console::l | ||||
evels::Warn, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_WARN_STREAM_THROTTLE(rate, args) ROS_LOG_STREAM_THROTTLE(rate, | ||||
ros::console::levels::Warn, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_WARN_THROTTLE_NAMED(rate, name, ...) ROS_LOG_THROTTLE(rate, ros | ||||
::console::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, | ||||
__VA_ARGS__) | ||||
#define ROS_WARN_STREAM_THROTTLE_NAMED(rate, name, args) ROS_LOG_STREAM_THR | ||||
OTTLE(rate, ros::console::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) | ||||
+ "." + name, args) | ||||
#define ROS_WARN_FILTER(filter, ...) ROS_LOG_FILTER(filter, ros::console::l | ||||
evels::Warn, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_WARN_STREAM_FILTER(filter, args) ROS_LOG_STREAM_FILTER(filter, | ||||
ros::console::levels::Warn, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_WARN_FILTER_NAMED(filter, name, ...) ROS_LOG_FILTER(filter, ros | ||||
::console::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, | ||||
__VA_ARGS__) | ||||
#define ROS_WARN_STREAM_FILTER_NAMED(filter, name, args) ROS_LOG_STREAM_FIL | ||||
TER(filter, ros::console::levels::Warn, std::string(ROSCONSOLE_NAME_PREFIX) | ||||
+ "." + name, args) | ||||
#endif | #endif | |||
#if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_ERROR) | #if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_ERROR) | |||
#define ROS_ERROR(...) | #define ROS_ERROR(...) | |||
#define ROS_ERROR_STREAM(args) | #define ROS_ERROR_STREAM(args) | |||
#define ROS_ERROR_NAMED(name, ...) | #define ROS_ERROR_NAMED(name, ...) | |||
#define ROS_ERROR_STREAM_NAMED(name, args) | #define ROS_ERROR_STREAM_NAMED(name, args) | |||
#define ROS_ERROR_COND(cond, ...) | #define ROS_ERROR_COND(cond, ...) | |||
#define ROS_ERROR_STREAM_COND(cond, args) | #define ROS_ERROR_STREAM_COND(cond, args) | |||
#define ROS_ERROR_COND_NAMED(cond, name, ...) | #define ROS_ERROR_COND_NAMED(cond, name, ...) | |||
#define ROS_ERROR_STREAM_COND_NAMED(cond, name, args) | #define ROS_ERROR_STREAM_COND_NAMED(cond, name, args) | |||
#define ROS_ERROR_ONCE(...) | ||||
#define ROS_ERROR_STREAM_ONCE(args) | ||||
#define ROS_ERROR_ONCE_NAMED(name, ...) | ||||
#define ROS_ERROR_STREAM_ONCE_NAMED(name, args) | ||||
#define ROS_ERROR_THROTTLE(rate, ...) | ||||
#define ROS_ERROR_STREAM_THROTTLE(rate, args) | ||||
#define ROS_ERROR_THROTTLE_NAMED(rate, name, ...) | ||||
#define ROS_ERROR_STREAM_THROTTLE_NAMED(rate, name, args) | ||||
#define ROS_ERROR_FILTER(filter, ...) | ||||
#define ROS_ERROR_STREAM_FILTER(filter, args) | ||||
#define ROS_ERROR_FILTER_NAMED(filter, name, ...) | ||||
#define ROS_ERROR_STREAM_FILTER_NAMED(filter, name, args) | ||||
#else | #else | |||
#define ROS_ERROR(...) ROS_LOG(ros::console::levels::Error, ROSCONSOLE_DEFA ULT_NAME, __VA_ARGS__) | #define ROS_ERROR(...) ROS_LOG(ros::console::levels::Error, ROSCONSOLE_DEFA ULT_NAME, __VA_ARGS__) | |||
#define ROS_ERROR_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_ERROR_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_ERROR_NAMED(name, ...) ROS_LOG(ros::console::levels::Error, std ::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | #define ROS_ERROR_NAMED(name, ...) ROS_LOG(ros::console::levels::Error, std ::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | |||
#define ROS_ERROR_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::lev els::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_ERROR_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::lev els::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_ERROR_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels:: Error, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | #define ROS_ERROR_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels:: Error, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | |||
#define ROS_ERROR_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::co nsole::levels::Error, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_ERROR_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::co nsole::levels::Error, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_ERROR_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::conso le::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_A RGS__) | #define ROS_ERROR_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::conso le::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_A RGS__) | |||
#define ROS_ERROR_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(c ond, ros::console::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_ERROR_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(c ond, ros::console::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_ERROR_ONCE(...) ROS_LOG_ONCE(ros::console::levels::Error, ROSCO | ||||
NSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_ERROR_STREAM_ONCE(args) ROS_LOG_STREAM_ONCE(ros::console::level | ||||
s::Error, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_ERROR_ONCE_NAMED(name, ...) ROS_LOG_ONCE(ros::console::levels:: | ||||
Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | ||||
#define ROS_ERROR_STREAM_ONCE_NAMED(name, args) ROS_LOG_STREAM_ONCE(ros::co | ||||
nsole::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, arg | ||||
s) | ||||
#define ROS_ERROR_THROTTLE(rate, ...) ROS_LOG_THROTTLE(rate, ros::console:: | ||||
levels::Error, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_ERROR_STREAM_THROTTLE(rate, args) ROS_LOG_STREAM_THROTTLE(rate, | ||||
ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_ERROR_THROTTLE_NAMED(rate, name, ...) ROS_LOG_THROTTLE(rate, ro | ||||
s::console::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name | ||||
, __VA_ARGS__) | ||||
#define ROS_ERROR_STREAM_THROTTLE_NAMED(rate, name, args) ROS_LOG_STREAM_TH | ||||
ROTTLE(rate, ros::console::levels::Error, std::string(ROSCONSOLE_NAME_PREFI | ||||
X) + "." + name, args) | ||||
#define ROS_ERROR_FILTER(filter, ...) ROS_LOG_FILTER(filter, ros::console:: | ||||
levels::Error, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_ERROR_STREAM_FILTER(filter, args) ROS_LOG_STREAM_FILTER(filter, | ||||
ros::console::levels::Error, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_ERROR_FILTER_NAMED(filter, name, ...) ROS_LOG_FILTER(filter, ro | ||||
s::console::levels::Error, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name | ||||
, __VA_ARGS__) | ||||
#define ROS_ERROR_STREAM_FILTER_NAMED(filter, name, args) ROS_LOG_STREAM_FI | ||||
LTER(filter, ros::console::levels::Error, std::string(ROSCONSOLE_NAME_PREFI | ||||
X) + "." + name, args) | ||||
#endif | #endif | |||
#if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_FATAL) | #if (ROSCONSOLE_MIN_SEVERITY > ROSCONSOLE_SEVERITY_FATAL) | |||
#define ROS_FATAL(...) | #define ROS_FATAL(...) | |||
#define ROS_FATAL_STREAM(args) | #define ROS_FATAL_STREAM(args) | |||
#define ROS_FATAL_NAMED(name, ...) | #define ROS_FATAL_NAMED(name, ...) | |||
#define ROS_FATAL_STREAM_NAMED(name, args) | #define ROS_FATAL_STREAM_NAMED(name, args) | |||
#define ROS_FATAL_COND(cond, ...) | #define ROS_FATAL_COND(cond, ...) | |||
#define ROS_FATAL_STREAM_COND(cond, args) | #define ROS_FATAL_STREAM_COND(cond, args) | |||
#define ROS_FATAL_COND_NAMED(cond, name, ...) | #define ROS_FATAL_COND_NAMED(cond, name, ...) | |||
#define ROS_FATAL_STREAM_COND_NAMED(cond, name, args) | #define ROS_FATAL_STREAM_COND_NAMED(cond, name, args) | |||
#define ROS_FATAL_ONCE(...) | ||||
#define ROS_FATAL_STREAM_ONCE(args) | ||||
#define ROS_FATAL_ONCE_NAMED(name, ...) | ||||
#define ROS_FATAL_STREAM_ONCE_NAMED(name, args) | ||||
#define ROS_FATAL_THROTTLE(rate, ...) | ||||
#define ROS_FATAL_STREAM_THROTTLE(rate, args) | ||||
#define ROS_FATAL_THROTTLE_NAMED(rate, name, ...) | ||||
#define ROS_FATAL_STREAM_THROTTLE_NAMED(rate, name, args) | ||||
#define ROS_FATAL_FILTER(filter, ...) | ||||
#define ROS_FATAL_STREAM_FILTER(filter, args) | ||||
#define ROS_FATAL_FILTER_NAMED(filter, name, ...) | ||||
#define ROS_FATAL_STREAM_FILTER_NAMED(filter, name, args) | ||||
#else | #else | |||
#define ROS_FATAL(...) ROS_LOG(ros::console::levels::Fatal, ROSCONSOLE_DEFA ULT_NAME, __VA_ARGS__) | #define ROS_FATAL(...) ROS_LOG(ros::console::levels::Fatal, ROSCONSOLE_DEFA ULT_NAME, __VA_ARGS__) | |||
#define ROS_FATAL_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_FATAL_STREAM(args) ROS_LOG_STREAM(ros::console::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_FATAL_NAMED(name, ...) ROS_LOG(ros::console::levels::Fatal, std ::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | #define ROS_FATAL_NAMED(name, ...) ROS_LOG(ros::console::levels::Fatal, std ::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | |||
#define ROS_FATAL_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::lev els::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_FATAL_STREAM_NAMED(name, args) ROS_LOG_STREAM(ros::console::lev els::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_FATAL_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels:: Fatal, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | #define ROS_FATAL_COND(cond, ...) ROS_LOG_COND(cond, ros::console::levels:: Fatal, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | |||
#define ROS_FATAL_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::co nsole::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | #define ROS_FATAL_STREAM_COND(cond, args) ROS_LOG_STREAM_COND(cond, ros::co nsole::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | |||
#define ROS_FATAL_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::conso le::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_A RGS__) | #define ROS_FATAL_COND_NAMED(cond, name, ...) ROS_LOG_COND(cond, ros::conso le::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_A RGS__) | |||
#define ROS_FATAL_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(c ond, ros::console::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | #define ROS_FATAL_STREAM_COND_NAMED(cond, name, args) ROS_LOG_STREAM_COND(c ond, ros::console::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, args) | |||
#define ROS_FATAL_ONCE(...) ROS_LOG_ONCE(ros::console::levels::Fatal, ROSCO | ||||
NSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_FATAL_STREAM_ONCE(args) ROS_LOG_STREAM_ONCE(ros::console::level | ||||
s::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_FATAL_ONCE_NAMED(name, ...) ROS_LOG_ONCE(ros::console::levels:: | ||||
Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, __VA_ARGS__) | ||||
#define ROS_FATAL_STREAM_ONCE_NAMED(name, args) ROS_LOG_STREAM_ONCE(ros::co | ||||
nsole::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name, arg | ||||
s) | ||||
#define ROS_FATAL_THROTTLE(rate, ...) ROS_LOG_THROTTLE(rate, ros::console:: | ||||
levels::Fatal, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_FATAL_STREAM_THROTTLE(rate, args) ROS_LOG_STREAM_THROTTLE(rate, | ||||
ros::console::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_FATAL_THROTTLE_NAMED(rate, name, ...) ROS_LOG_THROTTLE(rate, ro | ||||
s::console::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name | ||||
, __VA_ARGS__) | ||||
#define ROS_FATAL_STREAM_THROTTLE_NAMED(rate, name, args) ROS_LOG_STREAM_TH | ||||
ROTTLE(rate, ros::console::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFI | ||||
X) + "." + name, args) | ||||
#define ROS_FATAL_FILTER(filter, ...) ROS_LOG_FILTER(filter, ros::console:: | ||||
levels::Fatal, ROSCONSOLE_DEFAULT_NAME, __VA_ARGS__) | ||||
#define ROS_FATAL_STREAM_FILTER(filter, args) ROS_LOG_STREAM_FILTER(filter, | ||||
ros::console::levels::Fatal, ROSCONSOLE_DEFAULT_NAME, args) | ||||
#define ROS_FATAL_FILTER_NAMED(filter, name, ...) ROS_LOG_FILTER(filter, ro | ||||
s::console::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFIX) + "." + name | ||||
, __VA_ARGS__) | ||||
#define ROS_FATAL_STREAM_FILTER_NAMED(filter, name, args) ROS_LOG_STREAM_FI | ||||
LTER(filter, ros::console::levels::Fatal, std::string(ROSCONSOLE_NAME_PREFI | ||||
X) + "." + name, args) | ||||
#endif | #endif | |||
End of changes. 10 change blocks. | ||||
0 lines changed or deleted | 203 lines changed or added | |||
master.h | master.h | |||
---|---|---|---|---|
skipping to change at line 87 | skipping to change at line 87 | |||
* @returns true if the master is available, false otherwise. | * @returns true if the master is available, false otherwise. | |||
*/ | */ | |||
bool check(); | bool check(); | |||
/** | /** | |||
* \brief Contains information retrieved from the master about a topic | * \brief Contains information retrieved from the master about a topic | |||
*/ | */ | |||
struct TopicInfo | struct TopicInfo | |||
{ | { | |||
TopicInfo() {} | TopicInfo() {} | |||
TopicInfo(const std::string& _name, const std::string& _datatype, const s td::string& _md5sum) | TopicInfo(const std::string& _name, const std::string& _datatype /*, cons t std::string& _md5sum*/) | |||
: name(_name) | : name(_name) | |||
, datatype(_datatype) | , datatype(_datatype) | |||
, md5sum(_md5sum) | //, md5sum(_md5sum) | |||
{} | {} | |||
std::string name; ///< Name of the topic | std::string name; ///< Name of the topic | |||
std::string datatype; ///< Datatype of the topic | std::string datatype; ///< Datatype of the topic | |||
std::string md5sum; ///< md5sum of the topic | ||||
// not possible yet unfortunately (master does not have this information) | ||||
//std::string md5sum; ///< md5sum of the topic | ||||
}; | }; | |||
typedef std::vector<TopicInfo> V_TopicInfo; | typedef std::vector<TopicInfo> V_TopicInfo; | |||
/** @brief Get the list of topics that are being published by all nodes. | /** @brief Get the list of topics that are being published by all nodes. | |||
* | * | |||
* This method communicates with the master to retrieve the list of all | * This method communicates with the master to retrieve the list of all | |||
* currently advertised topics. | * currently advertised topics. | |||
* | * | |||
* @param topics A place to store the resulting list. Each item in the | * @param topics A place to store the resulting list. Each item in the | |||
* list is a pair <string topic, string type>. The type is represented | * list is a pair <string topic, string type>. The type is represented | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 5 lines changed or added | |||
message_deserializer.h | message_deserializer.h | |||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_MESSAGE_DESERIALIZER_H | #ifndef ROSCPP_MESSAGE_DESERIALIZER_H | |||
#define ROSCPP_MESSAGE_DESERIALIZER_H | #define ROSCPP_MESSAGE_DESERIALIZER_H | |||
#include "subscription_message_helper.h" | #include "forwards.h" | |||
#include "message.h" | #include "message.h" | |||
#include <ros/serialized_message.h> | ||||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/shared_array.hpp> | #include <boost/shared_array.hpp> | |||
namespace ros | namespace ros | |||
{ | { | |||
class SubscriptionCallbackHelper; | ||||
typedef boost::shared_ptr<SubscriptionCallbackHelper> SubscriptionCallbackH | ||||
elperPtr; | ||||
class MessageDeserializer | class MessageDeserializer | |||
{ | { | |||
public: | public: | |||
MessageDeserializer(const SubscriptionMessageHelperPtr& helper, const boo st::shared_array<uint8_t>& buffer, size_t num_bytes, bool buffer_includes_s ize_header, const boost::shared_ptr<M_string>& connection_header); | MessageDeserializer(const SubscriptionCallbackHelperPtr& helper, const Se rializedMessage& m, const boost::shared_ptr<M_string>& connection_header); | |||
MessagePtr deserialize(); | VoidConstPtr deserialize(); | |||
const boost::shared_ptr<M_string>& getConnectionHeader() { return connect | ||||
ion_header_; } | ||||
private: | private: | |||
SubscriptionMessageHelperPtr helper_; | SubscriptionCallbackHelperPtr helper_; | |||
boost::shared_array<uint8_t> buffer_; | SerializedMessage serialized_message_; | |||
uint32_t num_bytes_; | ||||
bool buffer_includes_size_header_; | ||||
boost::shared_ptr<M_string> connection_header_; | boost::shared_ptr<M_string> connection_header_; | |||
boost::mutex mutex_; | boost::mutex mutex_; | |||
MessagePtr msg_; | VoidConstPtr msg_; | |||
}; | }; | |||
typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr; | typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr; | |||
} | } | |||
#endif // ROSCPP_MESSAGE_DESERIALIZER_H | #endif // ROSCPP_MESSAGE_DESERIALIZER_H | |||
End of changes. 7 change blocks. | ||||
8 lines changed or deleted | 13 lines changed or added | |||
network.h | network.h | |||
---|---|---|---|---|
skipping to change at line 44 | skipping to change at line 44 | |||
{ | { | |||
/** | /** | |||
* \brief internal | * \brief internal | |||
*/ | */ | |||
namespace network | namespace network | |||
{ | { | |||
bool splitURI(const std::string& uri, std::string& host, uint32_t& port); | bool splitURI(const std::string& uri, std::string& host, uint32_t& port); | |||
const std::string& getHost(); | const std::string& getHost(); | |||
uint16_t getTCPROSPort(); | ||||
} // namespace network | } // namespace network | |||
} // namespace ros | } // namespace ros | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 1 lines changed or added | |||
node_handle.h | node_handle.h | |||
---|---|---|---|---|
skipping to change at line 38 | skipping to change at line 38 | |||
#ifndef ROSCPP_NODE_HANDLE_H | #ifndef ROSCPP_NODE_HANDLE_H | |||
#define ROSCPP_NODE_HANDLE_H | #define ROSCPP_NODE_HANDLE_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/publisher.h" | #include "ros/publisher.h" | |||
#include "ros/subscriber.h" | #include "ros/subscriber.h" | |||
#include "ros/service_server.h" | #include "ros/service_server.h" | |||
#include "ros/service_client.h" | #include "ros/service_client.h" | |||
#include "ros/timer.h" | #include "ros/timer.h" | |||
#include "ros/wall_timer.h" | #include "ros/wall_timer.h" | |||
#include "ros/subscription_message_helper.h" | ||||
#include "ros/service_message_helper.h" | ||||
#include "ros/advertise_options.h" | #include "ros/advertise_options.h" | |||
#include "ros/advertise_service_options.h" | #include "ros/advertise_service_options.h" | |||
#include "ros/subscribe_options.h" | #include "ros/subscribe_options.h" | |||
#include "ros/service_client_options.h" | #include "ros/service_client_options.h" | |||
#include "ros/timer_options.h" | #include "ros/timer_options.h" | |||
#include "ros/wall_timer_options.h" | #include "ros/wall_timer_options.h" | |||
#include "ros/spinner.h" | #include "ros/spinner.h" | |||
#include "ros/init.h" | #include "ros/init.h" | |||
#include <boost/bind.hpp> | #include <boost/bind.hpp> | |||
skipping to change at line 267 | skipping to change at line 265 | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the topic name begins with a tilde, or is an otherwise invalid graph resource name | * \throws InvalidNameException If the topic name begins with a tilde, or is an otherwise invalid graph resource name | |||
*/ | */ | |||
template <class M> | template <class M> | |||
Publisher advertise(const std::string& topic, uint32_t queue_size, | Publisher advertise(const std::string& topic, uint32_t queue_size, | |||
const SubscriberStatusCallback& connect_cb, | const SubscriberStatusCallback& connect_cb, | |||
const SubscriberStatusCallback& disconnect_cb = SubscriberStatusCallback(), | const SubscriberStatusCallback& disconnect_cb = SubscriberStatusCallback(), | |||
const VoidPtr& tracked_object = VoidPtr(), | const VoidConstPtr& tracked_object = VoidConstP tr(), | |||
bool latch = false) | bool latch = false) | |||
{ | { | |||
AdvertiseOptions ops; | AdvertiseOptions ops; | |||
ops.template init<M>(topic, queue_size, connect_cb, disconnect_cb); | ops.template init<M>(topic, queue_size, connect_cb, disconnect_cb); | |||
ops.tracked_object = tracked_object; | ops.tracked_object = tracked_object; | |||
ops.latch = latch; | ops.latch = latch; | |||
return advertise(ops); | return advertise(ops); | |||
} | } | |||
/** | /** | |||
skipping to change at line 322 | skipping to change at line 320 | |||
* This version of subscribe is a convenience function for using member f unctions, and can be used like so: | * This version of subscribe is a convenience function for using member f unctions, and can be used like so: | |||
\verbatim | \verbatim | |||
void Foo::callback(const std_msgs::Empty::ConstPtr& message) | void Foo::callback(const std_msgs::Empty::ConstPtr& message) | |||
{ | { | |||
} | } | |||
Foo foo_object; | Foo foo_object; | |||
ros::Subscriber sub = handle.subscribe("my_topic", 1, &Foo::callback, &foo_ object); | ros::Subscriber sub = handle.subscribe("my_topic", 1, &Foo::callback, &foo_ object); | |||
\endverbatim | \endverbatim | |||
* | * | |||
* \param M [template] M here is the callback parameter type (e.g. const boost::shared_ptr<M const>& or const M&), \b not the message type, and shou ld almost always be deduced | ||||
* \param topic Topic to subscribe to | * \param topic Topic to subscribe to | |||
* \param queue_size Number of incoming messages to queue up for | * \param queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param fp Member function pointer to call when a message has arrived | * \param fp Member function pointer to call when a message has arrived | |||
* \param obj Object to call fp on | * \param obj Object to call fp on | |||
* \param transport_hints a TransportHints structure which defines variou s transport-related options | * \param transport_hints a TransportHints structure which defines variou s transport-related options | |||
* \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | * \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | |||
* On failure, an empty Subscriber which can be checked with: | * On failure, an empty Subscriber which can be checked with: | |||
\verbatim | \verbatim | |||
if (handle) | if (handle) | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | * \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | |||
* \throws ConflictingSubscriptionException If this node is already subs | ||||
cribed to the same topic with a different datatype | ||||
*/ | ||||
template<class M, class T> | ||||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( | ||||
T::*fp)(M), T* obj, const TransportHints& transport_hints = TransportHints( | ||||
)) | ||||
{ | ||||
SubscribeOptions ops; | ||||
ops.template initByFullCallbackType<M>(topic, queue_size, boost::bind(f | ||||
p, obj, _1)); | ||||
ops.transport_hints = transport_hints; | ||||
return subscribe(ops); | ||||
} | ||||
/** | ||||
* \brief Subscribe to a topic, version for class member function with ba | ||||
re pointer | ||||
* | ||||
* This method connects to the master to register interest in a given | ||||
* topic. The node will automatically be connected with publishers on | ||||
* this topic. On each message receipt, fp is invoked and passed a share | ||||
d pointer | ||||
* to the message received. This message should \b not be changed in pla | ||||
ce, as it | ||||
* is shared with any other subscriptions to this topic. | ||||
* | ||||
* This version of subscribe is a convenience function for using member f | ||||
unctions, and can be used like so: | ||||
\verbatim | ||||
void Foo::callback(const std_msgs::Empty::ConstPtr& message) | ||||
{ | ||||
} | ||||
Foo foo_object; | ||||
ros::Subscriber sub = handle.subscribe("my_topic", 1, &Foo::callback, &foo_ | ||||
object); | ||||
\endverbatim | ||||
* | ||||
* \param M [template] M here is the message type | ||||
* \param topic Topic to subscribe to | ||||
* \param queue_size Number of incoming messages to queue up for | ||||
* processing (messages in excess of this queue capacity will be | ||||
* discarded). | ||||
* \param fp Member function pointer to call when a message has arrived | ||||
* \param obj Object to call fp on | ||||
* \param transport_hints a TransportHints structure which defines variou | ||||
s transport-related options | ||||
* \return On success, a Subscriber that, when all copies of it go out of | ||||
scope, will unsubscribe from this topic. | ||||
* On failure, an empty Subscriber which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the topic name begins with a tilde, o | ||||
r is an otherwise invalid graph resource name | ||||
* \throws ConflictingSubscriptionException If this node is already subs | ||||
cribed to the same topic with a different datatype | ||||
*/ | */ | |||
template<class M, class T> | template<class M, class T> | |||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( T::*fp)(const boost::shared_ptr<M const>&), T* obj, const TransportHints& t ransport_hints = TransportHints()) | Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( T::*fp)(const boost::shared_ptr<M const>&), T* obj, const TransportHints& t ransport_hints = TransportHints()) | |||
{ | { | |||
SubscribeOptions ops; | SubscribeOptions ops; | |||
ops.template init<M>(topic, queue_size, boost::bind(fp, obj, _1)); | ops.template init<M>(topic, queue_size, boost::bind(fp, obj, _1)); | |||
ops.transport_hints = transport_hints; | ops.transport_hints = transport_hints; | |||
return subscribe(ops); | return subscribe(ops); | |||
} | } | |||
skipping to change at line 367 | skipping to change at line 414 | |||
* This version of subscribe is a convenience function for using member f unctions on a shared_ptr: | * This version of subscribe is a convenience function for using member f unctions on a shared_ptr: | |||
\verbatim | \verbatim | |||
void Foo::callback(const std_msgs::Empty::ConstPtr& message) | void Foo::callback(const std_msgs::Empty::ConstPtr& message) | |||
{ | { | |||
} | } | |||
boost::shared_ptr<Foo> foo_object(new Foo); | boost::shared_ptr<Foo> foo_object(new Foo); | |||
ros::Subscriber sub = handle.subscribe("my_topic", 1, &Foo::callback, foo_o bject); | ros::Subscriber sub = handle.subscribe("my_topic", 1, &Foo::callback, foo_o bject); | |||
\endverbatim | \endverbatim | |||
* | * | |||
* \param M [template] M here is the callback parameter type (e.g. const | ||||
boost::shared_ptr<M const>& or const M&), \b not the message type, and shou | ||||
ld almost always be deduced | ||||
* \param topic Topic to subscribe to | ||||
* \param queue_size Number of incoming messages to queue up for | ||||
* processing (messages in excess of this queue capacity will be | ||||
* discarded). | ||||
* \param fp Member function pointer to call when a message has arrived | ||||
* \param obj Object to call fp on. Since this is a shared pointer, the | ||||
object will automatically be tracked with a weak_ptr | ||||
* so that if it is deleted before the Subscriber goes out of scope the c | ||||
allback will no longer be called (and therefore will not crash). | ||||
* \param transport_hints a TransportHints structure which defines variou | ||||
s transport-related options | ||||
* \return On success, a Subscriber that, when all copies of it go out of | ||||
scope, will unsubscribe from this topic. | ||||
* On failure, an empty Subscriber which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the topic name begins with a tilde, o | ||||
r is an otherwise invalid graph resource name | ||||
* \throws ConflictingSubscriptionException If this node is already subs | ||||
cribed to the same topic with a different datatype | ||||
*/ | ||||
template<class M, class T> | ||||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( | ||||
T::*fp)(M), const boost::shared_ptr<T>& obj, const TransportHints& transpor | ||||
t_hints = TransportHints()) | ||||
{ | ||||
SubscribeOptions ops; | ||||
ops.template initByFullCallbackType<M>(topic, queue_size, boost::bind(f | ||||
p, obj.get(), _1)); | ||||
ops.tracked_object = obj; | ||||
ops.transport_hints = transport_hints; | ||||
return subscribe(ops); | ||||
} | ||||
/** | ||||
* \brief Subscribe to a topic, version for class member function with sh | ||||
ared_ptr | ||||
* | ||||
* This method connects to the master to register interest in a given | ||||
* topic. The node will automatically be connected with publishers on | ||||
* this topic. On each message receipt, fp is invoked and passed a share | ||||
d pointer | ||||
* to the message received. This message should \b not be changed in pla | ||||
ce, as it | ||||
* is shared with any other subscriptions to this topic. | ||||
* | ||||
* This version of subscribe is a convenience function for using member f | ||||
unctions on a shared_ptr: | ||||
\verbatim | ||||
void Foo::callback(const std_msgs::Empty::ConstPtr& message) | ||||
{ | ||||
} | ||||
boost::shared_ptr<Foo> foo_object(new Foo); | ||||
ros::Subscriber sub = handle.subscribe("my_topic", 1, &Foo::callback, foo_o | ||||
bject); | ||||
\endverbatim | ||||
* | ||||
* \param M [template] M here is the message type | ||||
* \param topic Topic to subscribe to | * \param topic Topic to subscribe to | |||
* \param queue_size Number of incoming messages to queue up for | * \param queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param fp Member function pointer to call when a message has arrived | * \param fp Member function pointer to call when a message has arrived | |||
* \param obj Object to call fp on. Since this is a shared pointer, the object will automatically be tracked with a weak_ptr | * \param obj Object to call fp on. Since this is a shared pointer, the object will automatically be tracked with a weak_ptr | |||
* so that if it is deleted before the Subscriber goes out of scope the c allback will no longer be called (and therefore will not crash). | * so that if it is deleted before the Subscriber goes out of scope the c allback will no longer be called (and therefore will not crash). | |||
* \param transport_hints a TransportHints structure which defines variou s transport-related options | * \param transport_hints a TransportHints structure which defines variou s transport-related options | |||
* \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | * \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | |||
* On failure, an empty Subscriber which can be checked with: | * On failure, an empty Subscriber which can be checked with: | |||
\verbatim | \verbatim | |||
if (handle) | if (handle) | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | * \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | |||
* \throws ConflictingSubscriptionException If this node is already subs cribed to the same topic with a different datatype | ||||
*/ | */ | |||
template<class M, class T> | template<class M, class T> | |||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( T::*fp)(const boost::shared_ptr<M const>&), const boost::shared_ptr<T>& obj , const TransportHints& transport_hints = TransportHints()) | Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( T::*fp)(const boost::shared_ptr<M const>&), const boost::shared_ptr<T>& obj , const TransportHints& transport_hints = TransportHints()) | |||
{ | { | |||
SubscribeOptions ops; | SubscribeOptions ops; | |||
ops.template init<M>(topic, queue_size, boost::bind(fp, obj.get(), _1)) ; | ops.template init<M>(topic, queue_size, boost::bind(fp, obj.get(), _1)) ; | |||
ops.tracked_object = obj; | ops.tracked_object = obj; | |||
ops.transport_hints = transport_hints; | ops.transport_hints = transport_hints; | |||
return subscribe(ops); | return subscribe(ops); | |||
} | } | |||
skipping to change at line 413 | skipping to change at line 511 | |||
* | * | |||
* This version of subscribe is a convenience function for using bare fun ctions, and can be used like so: | * This version of subscribe is a convenience function for using bare fun ctions, and can be used like so: | |||
\verbatim | \verbatim | |||
void callback(const std_msgs::Empty::ConstPtr& message) | void callback(const std_msgs::Empty::ConstPtr& message) | |||
{ | { | |||
} | } | |||
ros::Subscriber sub = handle.subscribe("my_topic", 1, callback); | ros::Subscriber sub = handle.subscribe("my_topic", 1, callback); | |||
\endverbatim | \endverbatim | |||
* | * | |||
* \param M [template] M here is the callback parameter type (e.g. const boost::shared_ptr<M const>& or const M&), \b not the message type, and shou ld almost always be deduced | ||||
* \param topic Topic to subscribe to | * \param topic Topic to subscribe to | |||
* \param queue_size Number of incoming messages to queue up for | * \param queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param fp Function pointer to call when a message has arrived | * \param fp Function pointer to call when a message has arrived | |||
* \param transport_hints a TransportHints structure which defines variou s transport-related options | * \param transport_hints a TransportHints structure which defines variou s transport-related options | |||
* \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | * \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | |||
* On failure, an empty Subscriber which can be checked with: | * On failure, an empty Subscriber which can be checked with: | |||
\verbatim | \verbatim | |||
if (handle) | if (handle) | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | * \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | |||
* \throws ConflictingSubscriptionException If this node is already subs | ||||
cribed to the same topic with a different datatype | ||||
*/ | ||||
template<class M> | ||||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( | ||||
*fp)(M), const TransportHints& transport_hints = TransportHints()) | ||||
{ | ||||
SubscribeOptions ops; | ||||
ops.template initByFullCallbackType<M>(topic, queue_size, fp); | ||||
ops.transport_hints = transport_hints; | ||||
return subscribe(ops); | ||||
} | ||||
/** | ||||
* \brief Subscribe to a topic, version for bare function | ||||
* | ||||
* This method connects to the master to register interest in a given | ||||
* topic. The node will automatically be connected with publishers on | ||||
* this topic. On each message receipt, fp is invoked and passed a share | ||||
d pointer | ||||
* to the message received. This message should \b not be changed in pla | ||||
ce, as it | ||||
* is shared with any other subscriptions to this topic. | ||||
* | ||||
* This version of subscribe is a convenience function for using bare fun | ||||
ctions, and can be used like so: | ||||
\verbatim | ||||
void callback(const std_msgs::Empty::ConstPtr& message) | ||||
{ | ||||
} | ||||
ros::Subscriber sub = handle.subscribe("my_topic", 1, callback); | ||||
\endverbatim | ||||
* | ||||
* \param M [template] M here is the message type | ||||
* \param topic Topic to subscribe to | ||||
* \param queue_size Number of incoming messages to queue up for | ||||
* processing (messages in excess of this queue capacity will be | ||||
* discarded). | ||||
* \param fp Function pointer to call when a message has arrived | ||||
* \param transport_hints a TransportHints structure which defines variou | ||||
s transport-related options | ||||
* \return On success, a Subscriber that, when all copies of it go out of | ||||
scope, will unsubscribe from this topic. | ||||
* On failure, an empty Subscriber which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the topic name begins with a tilde, o | ||||
r is an otherwise invalid graph resource name | ||||
* \throws ConflictingSubscriptionException If this node is already subs | ||||
cribed to the same topic with a different datatype | ||||
*/ | */ | |||
template<class M> | template<class M> | |||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( *fp)(const boost::shared_ptr<M const>&), const TransportHints& transport_hi nts = TransportHints()) | Subscriber subscribe(const std::string& topic, uint32_t queue_size, void( *fp)(const boost::shared_ptr<M const>&), const TransportHints& transport_hi nts = TransportHints()) | |||
{ | { | |||
SubscribeOptions ops; | SubscribeOptions ops; | |||
ops.template init<M>(topic, queue_size, boost::function<void(const boos t::shared_ptr<M>&)>(fp)); | ops.template init<M>(topic, queue_size, fp); | |||
ops.transport_hints = transport_hints; | ops.transport_hints = transport_hints; | |||
return subscribe(ops); | return subscribe(ops); | |||
} | } | |||
/** | /** | |||
* \brief Subscribe to a topic, version for arbitrary boost::function obj ect | * \brief Subscribe to a topic, version for arbitrary boost::function obj ect | |||
* | * | |||
* This method connects to the master to register interest in a given | * This method connects to the master to register interest in a given | |||
* topic. The node will automatically be connected with publishers on | * topic. The node will automatically be connected with publishers on | |||
* this topic. On each message receipt, callback is invoked and passed a shared pointer | * this topic. On each message receipt, callback is invoked and passed a shared pointer | |||
* to the message received. This message should \b not be changed in pla ce, as it | * to the message received. This message should \b not be changed in pla ce, as it | |||
* is shared with any other subscriptions to this topic. | * is shared with any other subscriptions to this topic. | |||
* | * | |||
* This version of subscribe allows anything bindable to a boost::functio n object | * This version of subscribe allows anything bindable to a boost::functio n object | |||
* | * | |||
* \param M [template] M here is the message type | ||||
* \param topic Topic to subscribe to | * \param topic Topic to subscribe to | |||
* \param queue_size Number of incoming messages to queue up for | * \param queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param callback Callback to call when a message has arrived | * \param callback Callback to call when a message has arrived | |||
* \param tracked_object A shared pointer to an object to track for these callbacks. If set, the a weak_ptr will be created to this object, | * \param tracked_object A shared pointer to an object to track for these callbacks. If set, the a weak_ptr will be created to this object, | |||
* and if the reference count goes to 0 the subscriber callbacks will not get called. | * and if the reference count goes to 0 the subscriber callbacks will not get called. | |||
* Note that setting this will cause a new reference to be added to the o bject before the | * Note that setting this will cause a new reference to be added to the o bject before the | |||
* callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | * callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | |||
* thread) that the callback is invoked from. | * thread) that the callback is invoked from. | |||
* \param transport_hints a TransportHints structure which defines variou s transport-related options | * \param transport_hints a TransportHints structure which defines variou s transport-related options | |||
* \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | * \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | |||
* On failure, an empty Subscriber which can be checked with: | * On failure, an empty Subscriber which can be checked with: | |||
\verbatim | \verbatim | |||
if (handle) | if (handle) | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | * \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | |||
* \throws ConflictingSubscriptionException If this node is already subs cribed to the same topic with a different datatype | ||||
*/ | */ | |||
template<class M> | template<class M> | |||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, const boost::function<void (const boost::shared_ptr<M const>&)>& callback, | Subscriber subscribe(const std::string& topic, uint32_t queue_size, const boost::function<void (const boost::shared_ptr<M const>&)>& callback, | |||
const VoidPtr& tracked_object = VoidPtr(), con st TransportHints& transport_hints = TransportHints()) | const VoidConstPtr& tracked_object = VoidConst Ptr(), const TransportHints& transport_hints = TransportHints()) | |||
{ | { | |||
SubscribeOptions ops; | SubscribeOptions ops; | |||
ops.template init<M>(topic, queue_size, callback); | ops.template init<M>(topic, queue_size, callback); | |||
ops.tracked_object = tracked_object; | ops.tracked_object = tracked_object; | |||
ops.transport_hints = transport_hints; | ops.transport_hints = transport_hints; | |||
return subscribe(ops); | return subscribe(ops); | |||
} | } | |||
/** | /** | |||
* \brief Subscribe to a topic, version for arbitrary boost::function obj | ||||
ect | ||||
* | ||||
* This method connects to the master to register interest in a given | ||||
* topic. The node will automatically be connected with publishers on | ||||
* this topic. On each message receipt, callback is invoked and passed a | ||||
shared pointer | ||||
* to the message received. This message should \b not be changed in pla | ||||
ce, as it | ||||
* is shared with any other subscriptions to this topic. | ||||
* | ||||
* This version of subscribe allows anything bindable to a boost::functio | ||||
n object | ||||
* | ||||
* \param M [template] the message type | ||||
* \param C [template] the callback parameter type (e.g. const boost::sha | ||||
red_ptr<M const>& or const M&) | ||||
* \param topic Topic to subscribe to | ||||
* \param queue_size Number of incoming messages to queue up for | ||||
* processing (messages in excess of this queue capacity will be | ||||
* discarded). | ||||
* \param callback Callback to call when a message has arrived | ||||
* \param tracked_object A shared pointer to an object to track for these | ||||
callbacks. If set, the a weak_ptr will be created to this object, | ||||
* and if the reference count goes to 0 the subscriber callbacks will not | ||||
get called. | ||||
* Note that setting this will cause a new reference to be added to the o | ||||
bject before the | ||||
* callback, and for it to go out of scope (and potentially be deleted) i | ||||
n the code path (and therefore | ||||
* thread) that the callback is invoked from. | ||||
* \param transport_hints a TransportHints structure which defines variou | ||||
s transport-related options | ||||
* \return On success, a Subscriber that, when all copies of it go out of | ||||
scope, will unsubscribe from this topic. | ||||
* On failure, an empty Subscriber which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the topic name begins with a tilde, o | ||||
r is an otherwise invalid graph resource name | ||||
* \throws ConflictingSubscriptionException If this node is already subs | ||||
cribed to the same topic with a different datatype | ||||
*/ | ||||
template<class M, class C> | ||||
Subscriber subscribe(const std::string& topic, uint32_t queue_size, const | ||||
boost::function<void (C)>& callback, | ||||
const VoidConstPtr& tracked_object = VoidConst | ||||
Ptr(), const TransportHints& transport_hints = TransportHints()) | ||||
{ | ||||
SubscribeOptions ops; | ||||
ops.template initByFullCallbackType<C>(topic, queue_size, callback); | ||||
ops.tracked_object = tracked_object; | ||||
ops.transport_hints = transport_hints; | ||||
return subscribe(ops); | ||||
} | ||||
/** | ||||
* \brief Subscribe to a topic, version with full range of SubscribeOptio ns | * \brief Subscribe to a topic, version with full range of SubscribeOptio ns | |||
* | * | |||
* This method connects to the master to register interest in a given | * This method connects to the master to register interest in a given | |||
* topic. The node will automatically be connected with publishers on | * topic. The node will automatically be connected with publishers on | |||
* this topic. On each message receipt, fp is invoked and passed a share d pointer | * this topic. On each message receipt, fp is invoked and passed a share d pointer | |||
* to the message received. This message should \b not be changed in pla ce, as it | * to the message received. This message should \b not be changed in pla ce, as it | |||
* is shared with any other subscriptions to this topic. | * is shared with any other subscriptions to this topic. | |||
* | * | |||
* This version of subscribe allows the full range of options, exposed th rough the SubscribeOptions class | * This version of subscribe allows the full range of options, exposed th rough the SubscribeOptions class | |||
* | * | |||
* \param ops Subscribe options | * \param ops Subscribe options | |||
* \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | * \return On success, a Subscriber that, when all copies of it go out of scope, will unsubscribe from this topic. | |||
* On failure, an empty Subscriber which can be checked with: | * On failure, an empty Subscriber which can be checked with: | |||
\verbatim | \verbatim | |||
if (handle) | if (handle) | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | * \throws InvalidNameException If the topic name begins with a tilde, o r is an otherwise invalid graph resource name | |||
* \throws ConflictingSubscriptionException If this node is already subs cribed to the same topic with a different datatype | ||||
*/ | */ | |||
Subscriber subscribe(SubscribeOptions& ops); | Subscriber subscribe(SubscribeOptions& ops); | |||
///////////////////////////////////////////////////////////////////////// ///////////////////////////////////// | ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////// | |||
// Versions of advertiseService() | // Versions of advertiseService() | |||
///////////////////////////////////////////////////////////////////////// ///////////////////////////////////// | ///////////////////////////////////////////////////////////////////////// ///////////////////////////////////// | |||
/** | /** | |||
* \brief Advertise a service, version for class member function with bar e pointer | * \brief Advertise a service, version for class member function with bar e pointer | |||
* | * | |||
* This call connects to the master to publicize that the node will be | * This call connects to the master to publicize that the node will be | |||
skipping to change at line 547 | skipping to change at line 741 | |||
*/ | */ | |||
template<class T, class MReq, class MRes> | template<class T, class MReq, class MRes> | |||
ServiceServer advertiseService(const std::string& service, bool(T::*srv_f unc)(MReq &, MRes &), T *obj) | ServiceServer advertiseService(const std::string& service, bool(T::*srv_f unc)(MReq &, MRes &), T *obj) | |||
{ | { | |||
AdvertiseServiceOptions ops; | AdvertiseServiceOptions ops; | |||
ops.template init<MReq, MRes>(service, boost::bind(srv_func, obj, _1, _ 2)); | ops.template init<MReq, MRes>(service, boost::bind(srv_func, obj, _1, _ 2)); | |||
return advertiseService(ops); | return advertiseService(ops); | |||
} | } | |||
/** | /** | |||
* \brief Advertise a service, version for class member function with bar | ||||
e pointer using ros::ServiceEvent as the callback parameter type | ||||
* | ||||
* This call connects to the master to publicize that the node will be | ||||
* offering an RPC service with the given name. | ||||
* | ||||
* This is a convenience function for using member functions, and can be | ||||
used like so: | ||||
\verbatim | ||||
bool Foo::callback(ros::ServiceEvent<std_srvs::Empty::Request, std_srvs::Em | ||||
pty::Response>& event) | ||||
{ | ||||
return true; | ||||
} | ||||
Foo foo_object; | ||||
ros::ServiceServer service = handle.advertiseService("my_service", &Foo::ca | ||||
llback, &foo_object); | ||||
\endverbatim | ||||
* | ||||
* \param service Service name to advertise on | ||||
* \param srv_func Member function pointer to call when a message has arr | ||||
ived | ||||
* \param obj Object to call srv_func on | ||||
* \return On success, a ServiceServer that, when all copies of it go out | ||||
of scope, will unadvertise this service. | ||||
* On failure, an empty ServiceServer which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the service name begins with a tilde, | ||||
or is an otherwise invalid graph resource name, or is an otherwise invalid | ||||
graph resource name | ||||
*/ | ||||
template<class T, class MReq, class MRes> | ||||
ServiceServer advertiseService(const std::string& service, bool(T::*srv_f | ||||
unc)(ServiceEvent<MReq, MRes>&), T *obj) | ||||
{ | ||||
AdvertiseServiceOptions ops; | ||||
ops.template initBySpecType<ServiceEvent<MReq, MRes> >(service, boost:: | ||||
bind(srv_func, obj, _1)); | ||||
return advertiseService(ops); | ||||
} | ||||
/** | ||||
* \brief Advertise a service, version for class member function with sha red_ptr | * \brief Advertise a service, version for class member function with sha red_ptr | |||
* | * | |||
* This call connects to the master to publicize that the node will be | * This call connects to the master to publicize that the node will be | |||
* offering an RPC service with the given name. | * offering an RPC service with the given name. | |||
* | * | |||
* This is a convenience function for using member functions on shared po inters, and can be used like so: | * This is a convenience function for using member functions on shared po inters, and can be used like so: | |||
\verbatim | \verbatim | |||
bool Foo::callback(std_srvs::Empty& request, std_srvs::Empty& response) | bool Foo::callback(std_srvs::Empty& request, std_srvs::Empty& response) | |||
{ | { | |||
return true; | return true; | |||
skipping to change at line 587 | skipping to change at line 819 | |||
template<class T, class MReq, class MRes> | template<class T, class MReq, class MRes> | |||
ServiceServer advertiseService(const std::string& service, bool(T::*srv_f unc)(MReq &, MRes &), const boost::shared_ptr<T>& obj) | ServiceServer advertiseService(const std::string& service, bool(T::*srv_f unc)(MReq &, MRes &), const boost::shared_ptr<T>& obj) | |||
{ | { | |||
AdvertiseServiceOptions ops; | AdvertiseServiceOptions ops; | |||
ops.template init<MReq, MRes>(service, boost::bind(srv_func, obj.get(), _1, _2)); | ops.template init<MReq, MRes>(service, boost::bind(srv_func, obj.get(), _1, _2)); | |||
ops.tracked_object = obj; | ops.tracked_object = obj; | |||
return advertiseService(ops); | return advertiseService(ops); | |||
} | } | |||
/** | /** | |||
* \brief Advertise a service, version for class member function with sha | ||||
red_ptr using ros::ServiceEvent as the callback parameter type | ||||
* | ||||
* This call connects to the master to publicize that the node will be | ||||
* offering an RPC service with the given name. | ||||
* | ||||
* This is a convenience function for using member functions on shared po | ||||
inters, and can be used like so: | ||||
\verbatim | ||||
bool Foo::callback(ros::ServiceEvent<std_srvs::Empty, std_srvs::Empty>& eve | ||||
nt) | ||||
{ | ||||
return true; | ||||
} | ||||
boost::shared_ptr<Foo> foo_object(new Foo); | ||||
ros::ServiceServer service = handle.advertiseService("my_service", &Foo::ca | ||||
llback, foo_object); | ||||
\endverbatim | ||||
* | ||||
* \param service Service name to advertise on | ||||
* \param srv_func Member function pointer to call when a message has arr | ||||
ived | ||||
* \param obj Object to call srv_func on. Since this is a shared_ptr, it | ||||
will automatically be tracked with a weak_ptr, | ||||
* and if the object is deleted the service callback will stop being call | ||||
ed (and therefore will not crash). | ||||
* \return On success, a ServiceServer that, when all copies of it go out | ||||
of scope, will unadvertise this service. | ||||
* On failure, an empty ServiceServer which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the service name begins with a tilde, | ||||
or is an otherwise invalid graph resource name | ||||
*/ | ||||
template<class T, class MReq, class MRes> | ||||
ServiceServer advertiseService(const std::string& service, bool(T::*srv_f | ||||
unc)(ServiceEvent<MReq, MRes>&), const boost::shared_ptr<T>& obj) | ||||
{ | ||||
AdvertiseServiceOptions ops; | ||||
ops.template initBySpecType<ServiceEvent<MReq, MRes> >(service, boost:: | ||||
bind(srv_func, obj.get(), _1)); | ||||
ops.tracked_object = obj; | ||||
return advertiseService(ops); | ||||
} | ||||
/** | ||||
* \brief Advertise a service, version for bare function | * \brief Advertise a service, version for bare function | |||
* | * | |||
* This call connects to the master to publicize that the node will be | * This call connects to the master to publicize that the node will be | |||
* offering an RPC service with the given name. | * offering an RPC service with the given name. | |||
* | * | |||
* This is a convenience function for using bare functions, and can be us ed like so: | * This is a convenience function for using bare functions, and can be us ed like so: | |||
\verbatim | \verbatim | |||
bool callback(std_srvs::Empty& request, std_srvs::Empty& response) | bool callback(std_srvs::Empty& request, std_srvs::Empty& response) | |||
{ | { | |||
return true; | return true; | |||
skipping to change at line 618 | skipping to change at line 890 | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the service name begins with a tilde, or is an otherwise invalid graph resource name | * \throws InvalidNameException If the service name begins with a tilde, or is an otherwise invalid graph resource name | |||
*/ | */ | |||
template<class MReq, class MRes> | template<class MReq, class MRes> | |||
ServiceServer advertiseService(const std::string& service, bool(*srv_func )(MReq&, MRes&)) | ServiceServer advertiseService(const std::string& service, bool(*srv_func )(MReq&, MRes&)) | |||
{ | { | |||
AdvertiseServiceOptions ops; | AdvertiseServiceOptions ops; | |||
ops.template init<MReq, MRes>(service, boost::function<bool(MReq&, MRes | ops.template init<MReq, MRes>(service, srv_func); | |||
&)>(srv_func)); | return advertiseService(ops); | |||
} | ||||
/** | ||||
* \brief Advertise a service, version for bare function using ros::Servi | ||||
ceEvent as the callback parameter type | ||||
* | ||||
* This call connects to the master to publicize that the node will be | ||||
* offering an RPC service with the given name. | ||||
* | ||||
* This is a convenience function for using bare functions, and can be us | ||||
ed like so: | ||||
\verbatim | ||||
bool callback(ros::ServiceEvent<std_srvs::Empty, std_srvs::Empty>& event) | ||||
{ | ||||
return true; | ||||
} | ||||
ros::ServiceServer service = handle.advertiseService("my_service", callback | ||||
); | ||||
\endverbatim | ||||
* | ||||
* \param service Service name to advertise on | ||||
* \param srv_func function pointer to call when a message has arrived | ||||
* \return On success, a ServiceServer that, when all copies of it go out | ||||
of scope, will unadvertise this service. | ||||
* On failure, an empty ServiceServer which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the service name begins with a tilde, | ||||
or is an otherwise invalid graph resource name | ||||
*/ | ||||
template<class MReq, class MRes> | ||||
ServiceServer advertiseService(const std::string& service, bool(*srv_func | ||||
)(ServiceEvent<MReq, MRes>&)) | ||||
{ | ||||
AdvertiseServiceOptions ops; | ||||
ops.template initBySpecType<ServiceEvent<MReq, MRes> >(service, srv_fun | ||||
c); | ||||
return advertiseService(ops); | return advertiseService(ops); | |||
} | } | |||
/** | /** | |||
* \brief Advertise a service, version for arbitrary boost::function obje ct | * \brief Advertise a service, version for arbitrary boost::function obje ct | |||
* | * | |||
* This call connects to the master to publicize that the node will be | * This call connects to the master to publicize that the node will be | |||
* offering an RPC service with the given name. | * offering an RPC service with the given name. | |||
* | * | |||
* This version of advertiseService allows non-class functions, as well a s functor objects and boost::bind (along with anything | * This version of advertiseService allows non-class functions, as well a s functor objects and boost::bind (along with anything | |||
skipping to change at line 649 | skipping to change at line 957 | |||
* On failure, an empty ServiceServer which can be checked with: | * On failure, an empty ServiceServer which can be checked with: | |||
\verbatim | \verbatim | |||
if (handle) | if (handle) | |||
{ | { | |||
... | ... | |||
} | } | |||
\endverbatim | \endverbatim | |||
* \throws InvalidNameException If the service name begins with a tilde, or is an otherwise invalid graph resource name | * \throws InvalidNameException If the service name begins with a tilde, or is an otherwise invalid graph resource name | |||
*/ | */ | |||
template<class MReq, class MRes> | template<class MReq, class MRes> | |||
ServiceServer advertiseService(const std::string& service, const boost::f unction<bool(MReq&, MRes&)>& callback, const VoidPtr& tracked_object = Void Ptr()) | ServiceServer advertiseService(const std::string& service, const boost::f unction<bool(MReq&, MRes&)>& callback, const VoidConstPtr& tracked_object = VoidConstPtr()) | |||
{ | { | |||
AdvertiseServiceOptions ops; | AdvertiseServiceOptions ops; | |||
ops.template init<MReq, MRes>(service, callback); | ops.template init<MReq, MRes>(service, callback); | |||
ops.tracked_object = tracked_object; | ops.tracked_object = tracked_object; | |||
return advertiseService(ops); | return advertiseService(ops); | |||
} | } | |||
/** | /** | |||
* \brief Advertise a service, version for arbitrary boost::function obje | ||||
ct using ros::ServiceEvent as the callback parameter type | ||||
* | ||||
* Note that the template parameter S is the full event type, e.g. ros::S | ||||
erviceEvent<Req, Res> | ||||
* | ||||
* This call connects to the master to publicize that the node will be | ||||
* offering an RPC service with the given name. | ||||
* | ||||
* This version of advertiseService allows non-class functions, as well a | ||||
s functor objects and boost::bind (along with anything | ||||
* else boost::function supports). | ||||
* | ||||
* \param service Service name to advertise on | ||||
* \param callback Callback to call when the service is called | ||||
* \param tracked_object A shared pointer to an object to track for these | ||||
callbacks. If set, the a weak_ptr will be created to this object, | ||||
* and if the reference count goes to 0 the subscriber callbacks will not | ||||
get called. | ||||
* Note that setting this will cause a new reference to be added to the o | ||||
bject before the | ||||
* callback, and for it to go out of scope (and potentially be deleted) i | ||||
n the code path (and therefore | ||||
* thread) that the callback is invoked from. | ||||
* \return On success, a ServiceServer that, when all copies of it go out | ||||
of scope, will unadvertise this service. | ||||
* On failure, an empty ServiceServer which can be checked with: | ||||
\verbatim | ||||
if (handle) | ||||
{ | ||||
... | ||||
} | ||||
\endverbatim | ||||
* \throws InvalidNameException If the service name begins with a tilde, | ||||
or is an otherwise invalid graph resource name | ||||
*/ | ||||
template<class S> | ||||
ServiceServer advertiseService(const std::string& service, const boost::f | ||||
unction<bool(S&)>& callback, const VoidConstPtr& tracked_object = VoidConst | ||||
Ptr()) | ||||
{ | ||||
AdvertiseServiceOptions ops; | ||||
ops.template initBySpecType<S>(service, callback); | ||||
ops.tracked_object = tracked_object; | ||||
return advertiseService(ops); | ||||
} | ||||
/** | ||||
* \brief Advertise a service, with full range of AdvertiseServiceOptions | * \brief Advertise a service, with full range of AdvertiseServiceOptions | |||
* | * | |||
* This call connects to the master to publicize that the node will be | * This call connects to the master to publicize that the node will be | |||
* offering an RPC service with the given name. | * offering an RPC service with the given name. | |||
* | * | |||
* This version of advertiseService allows the full set of options, expos ed through the AdvertiseServiceOptions class | * This version of advertiseService allows the full set of options, expos ed through the AdvertiseServiceOptions class | |||
* | * | |||
* \param ops Advertise options | * \param ops Advertise options | |||
* \return On success, a ServiceServer that, when all copies of it go out of scope, will unadvertise this service. | * \return On success, a ServiceServer that, when all copies of it go out of scope, will unadvertise this service. | |||
* On failure, an empty ServiceServer which can be checked with: | * On failure, an empty ServiceServer which can be checked with: | |||
skipping to change at line 745 | skipping to change at line 1090 | |||
* | * | |||
* When the Timer (and all copies of it) returned goes out of scope, the timer will automatically | * When the Timer (and all copies of it) returned goes out of scope, the timer will automatically | |||
* be stopped, and the callback will no longer be called. | * be stopped, and the callback will no longer be called. | |||
* | * | |||
* \param period The period at which to call the callback | * \param period The period at which to call the callback | |||
* \param callback The method to call | * \param callback The method to call | |||
* \param obj The object to call the method on | * \param obj The object to call the method on | |||
* \param oneshot If true, this timer will only fire once | * \param oneshot If true, this timer will only fire once | |||
*/ | */ | |||
template<class T> | template<class T> | |||
Timer createTimer(Duration period, void(T::*callback)(const TimerEvent&) | ||||
const, T* obj, bool oneshot = false) const | ||||
{ | ||||
return createTimer(period, boost::bind(callback, obj, _1), oneshot); | ||||
} | ||||
/** | ||||
* \brief Create a timer which will call a callback at the specified rate | ||||
. This variant takes | ||||
* a class member function, and a bare pointer to the object to call the | ||||
method on. | ||||
* | ||||
* When the Timer (and all copies of it) returned goes out of scope, the | ||||
timer will automatically | ||||
* be stopped, and the callback will no longer be called. | ||||
* | ||||
* \param period The period at which to call the callback | ||||
* \param callback The method to call | ||||
* \param obj The object to call the method on | ||||
* \param oneshot If true, this timer will only fire once | ||||
*/ | ||||
template<class T> | ||||
Timer createTimer(Duration period, void(T::*callback)(const TimerEvent&), T* obj, bool oneshot = false) const | Timer createTimer(Duration period, void(T::*callback)(const TimerEvent&), T* obj, bool oneshot = false) const | |||
{ | { | |||
return createTimer(period, boost::bind(callback, obj, _1), oneshot); | return createTimer(period, boost::bind(callback, obj, _1), oneshot); | |||
} | } | |||
/** | /** | |||
* \brief Create a timer which will call a callback at the specified rate . This variant takes | * \brief Create a timer which will call a callback at the specified rate . This variant takes | |||
* a class member function, and a shared pointer to the object to call th e method on. | * a class member function, and a shared pointer to the object to call th e method on. | |||
* | * | |||
* When the Timer (and all copies of it) returned goes out of scope, the timer will automatically | * When the Timer (and all copies of it) returned goes out of scope, the timer will automatically | |||
skipping to change at line 1103 | skipping to change at line 1466 | |||
/** \brief Check whether it's time to exit. | /** \brief Check whether it's time to exit. | |||
* | * | |||
* This method checks to see if both ros::ok() is true and shutdown() has not been called on this NodeHandle, to see whether it's yet time | * This method checks to see if both ros::ok() is true and shutdown() has not been called on this NodeHandle, to see whether it's yet time | |||
* to exit. ok() is false once either ros::shutdown() or NodeHandle::shu tdown() have been called | * to exit. ok() is false once either ros::shutdown() or NodeHandle::shu tdown() have been called | |||
* | * | |||
* \return true if we're still OK, false if it's time to exit | * \return true if we're still OK, false if it's time to exit | |||
*/ | */ | |||
bool ok() const; | bool ok() const; | |||
/** \brief Get the hostname where the master runs. | ||||
* | ||||
* \return The master's hostname, as a string | ||||
*/ | ||||
const std::string &getMasterHost() const; | ||||
/** \brief Get the port where the master runs. | ||||
* | ||||
* \return The master's port. | ||||
*/ | ||||
int getMasterPort() const; | ||||
private: | private: | |||
void construct(); | void construct(); | |||
void destruct(); | void destruct(); | |||
void initRemappings(const M_string& remappings); | void initRemappings(const M_string& remappings); | |||
std::string remapName(const std::string& name) const; | std::string remapName(const std::string& name) const; | |||
std::string namespace_; | std::string namespace_; | |||
std::string unresolved_namespace_; | std::string unresolved_namespace_; | |||
End of changes. 21 change blocks. | ||||
19 lines changed or deleted | 466 lines changed or added | |||
poll_set.h | poll_set.h | |||
---|---|---|---|---|
skipping to change at line 143 | skipping to change at line 143 | |||
TransportPtr transport_; | TransportPtr transport_; | |||
SocketUpdateFunc func_; | SocketUpdateFunc func_; | |||
int fd_; | int fd_; | |||
int events_; | int events_; | |||
}; | }; | |||
typedef std::map<int, SocketInfo> M_SocketInfo; | typedef std::map<int, SocketInfo> M_SocketInfo; | |||
M_SocketInfo socket_info_; | M_SocketInfo socket_info_; | |||
boost::mutex socket_info_mutex_; | boost::mutex socket_info_mutex_; | |||
bool sockets_changed_; | bool sockets_changed_; | |||
boost::mutex just_deleted_mutex_; | ||||
typedef std::vector<int> V_int; | ||||
V_int just_deleted_; | ||||
std::vector<struct pollfd> ufds_; | std::vector<struct pollfd> ufds_; | |||
boost::mutex signal_mutex_; | boost::mutex signal_mutex_; | |||
int signal_pipe_[2]; | int signal_pipe_[2]; | |||
}; | }; | |||
} | } | |||
#endif // ROSCPP_POLL_SET_H | #endif // ROSCPP_POLL_SET_H | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 4 lines changed or added | |||
publication.h | publication.h | |||
---|---|---|---|---|
skipping to change at line 61 | skipping to change at line 61 | |||
* \brief A Publication manages an advertised topic | * \brief A Publication manages an advertised topic | |||
*/ | */ | |||
class Publication | class Publication | |||
{ | { | |||
public: | public: | |||
Publication(const std::string &name, | Publication(const std::string &name, | |||
const std::string& datatype, | const std::string& datatype, | |||
const std::string& _md5sum, | const std::string& _md5sum, | |||
const std::string& message_definition, | const std::string& message_definition, | |||
size_t max_queue, | size_t max_queue, | |||
bool latch); | bool latch, | |||
bool has_header); | ||||
~Publication(); | ~Publication(); | |||
void addCallbacks(const SubscriberCallbacksPtr& callbacks); | void addCallbacks(const SubscriberCallbacksPtr& callbacks); | |||
void removeCallbacks(const SubscriberCallbacksPtr& callbacks); | void removeCallbacks(const SubscriberCallbacksPtr& callbacks); | |||
/** | /** | |||
* \brief queues an outgoing message into each of the publishers, so that it gets sent to every subscriber | * \brief queues an outgoing message into each of the publishers, so that it gets sent to every subscriber | |||
*/ | */ | |||
bool enqueueMessage(const SerializedMessage& m); | bool enqueueMessage(const SerializedMessage& m); | |||
skipping to change at line 88 | skipping to change at line 89 | |||
*/ | */ | |||
XmlRpc::XmlRpcValue getStats(); | XmlRpc::XmlRpcValue getStats(); | |||
/** | /** | |||
* \brief Get the accumulated info for this publication | * \brief Get the accumulated info for this publication | |||
*/ | */ | |||
void getInfo(XmlRpc::XmlRpcValue& info); | void getInfo(XmlRpc::XmlRpcValue& info); | |||
/** | /** | |||
* \brief Returns whether or not this publication has any subscribers | * \brief Returns whether or not this publication has any subscribers | |||
*/ | */ | |||
bool hasSubscribers() { return !subscriber_links_.empty(); } | bool hasSubscribers(); | |||
/** | /** | |||
* \brief Returns the number of subscribers this publication has | * \brief Returns the number of subscribers this publication has | |||
*/ | */ | |||
int getNumSubscribers() { return (int)subscriber_links_.size(); } | uint32_t getNumSubscribers(); | |||
void getPublishTypes(bool& serialize, bool& nocopy, const std::type_info& | ||||
ti); | ||||
/** | /** | |||
* \brief Returns the name of the topic this publication broadcasts to | * \brief Returns the name of the topic this publication broadcasts to | |||
*/ | */ | |||
const std::string& getName() const { return name_; } | const std::string& getName() const { return name_; } | |||
/** | /** | |||
* \brief Returns the data type of the message published by this publicat ion | * \brief Returns the data type of the message published by this publicat ion | |||
*/ | */ | |||
const std::string& getDataType() const { return datatype_; } | const std::string& getDataType() const { return datatype_; } | |||
/** | /** | |||
skipping to change at line 115 | skipping to change at line 118 | |||
const std::string& getMD5Sum() const { return md5sum_; } | const std::string& getMD5Sum() const { return md5sum_; } | |||
/** | /** | |||
* \brief Returns the full definition of the message published by this pu blication | * \brief Returns the full definition of the message published by this pu blication | |||
*/ | */ | |||
const std::string& getMessageDefinition() const { return message_definiti on_; } | const std::string& getMessageDefinition() const { return message_definiti on_; } | |||
/** | /** | |||
* \brief Returns the sequence number | * \brief Returns the sequence number | |||
*/ | */ | |||
uint32_t getSequence() { return seq_; } | uint32_t getSequence() { return seq_; } | |||
bool isLatched() { return latch_; } | ||||
/** | /** | |||
* \brief Adds a publisher to our list | * \brief Adds a publisher to our list | |||
*/ | */ | |||
void addSubscriberLink(const SubscriberLinkPtr& sub_link); | void addSubscriberLink(const SubscriberLinkPtr& sub_link); | |||
/** | /** | |||
* \brief Removes a publisher from our list (deleting it if it's the last reference) | * \brief Removes a publisher from our list (deleting it if it's the last reference) | |||
*/ | */ | |||
void removeSubscriberLink(const SubscriberLinkPtr& sub_link); | void removeSubscriberLink(const SubscriberLinkPtr& sub_link); | |||
/** | /** | |||
* \brief Drop this publication. Disconnects all publishers. | * \brief Drop this publication. Disconnects all publishers. | |||
*/ | */ | |||
void drop(); | void drop(); | |||
/** | /** | |||
* \brief Returns if this publication is valid or not | * \brief Returns if this publication is valid or not | |||
*/ | */ | |||
bool isDropped() { return dropped_; } | bool isDropped() { return dropped_; } | |||
void incrementSequence() { ++seq_; } | uint32_t incrementSequence(); | |||
size_t getNumCallbacks(); | size_t getNumCallbacks(); | |||
bool isLatching() { return latch_; } | bool isLatching() { return latch_; } | |||
void publish(SerializedMessage& m); | ||||
void processPublishQueue(); | ||||
bool validateHeader(const Header& h, std::string& error_msg); | ||||
private: | private: | |||
void dropAllConnections(); | void dropAllConnections(); | |||
/** | /** | |||
* \brief Called when a new peer has connected. Calls the connection call back | * \brief Called when a new peer has connected. Calls the connection call back | |||
*/ | */ | |||
void peerConnect(const SubscriberLinkPtr& sub_link); | void peerConnect(const SubscriberLinkPtr& sub_link); | |||
/** | /** | |||
* \brief Called when a peer has disconnected. Calls the disconnection ca llback | * \brief Called when a peer has disconnected. Calls the disconnection ca llback | |||
*/ | */ | |||
void peerDisconnect(const SubscriberLinkPtr& sub_link); | void peerDisconnect(const SubscriberLinkPtr& sub_link); | |||
std::string name_; | std::string name_; | |||
std::string datatype_; | std::string datatype_; | |||
std::string md5sum_; | std::string md5sum_; | |||
std::string message_definition_; | std::string message_definition_; | |||
size_t max_queue_; | size_t max_queue_; | |||
uint32_t seq_; | uint32_t seq_; | |||
boost::mutex seq_mutex_; | ||||
typedef std::vector<SubscriberCallbacksPtr> V_Callback; | typedef std::vector<SubscriberCallbacksPtr> V_Callback; | |||
V_Callback callbacks_; | V_Callback callbacks_; | |||
boost::mutex callbacks_mutex_; | boost::mutex callbacks_mutex_; | |||
V_SubscriberLink subscriber_links_; | V_SubscriberLink subscriber_links_; | |||
// We use a recursive mutex here for the rare case that a publish call ca uses another one (like in the case of a rosconsole call) | // We use a recursive mutex here for the rare case that a publish call ca uses another one (like in the case of a rosconsole call) | |||
boost::mutex subscriber_links_mutex_; | boost::mutex subscriber_links_mutex_; | |||
bool dropped_; | bool dropped_; | |||
bool latch_; | bool latch_; | |||
bool has_header_; | ||||
SerializedMessage last_message_; | SerializedMessage last_message_; | |||
uint32_t intraprocess_subscriber_count_; | ||||
typedef std::vector<SerializedMessage> V_SerializedMessage; | ||||
V_SerializedMessage publish_queue_; | ||||
boost::mutex publish_queue_mutex_; | ||||
}; | }; | |||
} | } | |||
#endif // ROSCPP_PUBLICATION_H | #endif // ROSCPP_PUBLICATION_H | |||
End of changes. 9 change blocks. | ||||
4 lines changed or deleted | 23 lines changed or added | |||
publisher.h | publisher.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_PUBLISHER_HANDLE_H | #ifndef ROSCPP_PUBLISHER_HANDLE_H | |||
#define ROSCPP_PUBLISHER_HANDLE_H | #define ROSCPP_PUBLISHER_HANDLE_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/common.h" | ||||
#include "ros/message.h" | #include "ros/message.h" | |||
#include "ros/serialization.h" | ||||
#include <boost/bind.hpp> | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Manages an advertisement on a specific topic. | * \brief Manages an advertisement on a specific topic. | |||
* | * | |||
* A Publisher should always be created through a call to NodeHandle::adver tise(), or copied from one | * A Publisher should always be created through a call to NodeHandle::adver tise(), or copied from one | |||
* that was. Once all copies of a specific | * that was. Once all copies of a specific | |||
* Publisher go out of scope, any subscriber status callbacks associated wi th that handle will stop | * Publisher go out of scope, any subscriber status callbacks associated wi th that handle will stop | |||
skipping to change at line 60 | skipping to change at line 63 | |||
~Publisher(); | ~Publisher(); | |||
/** | /** | |||
* \brief Publish a message on the topic associated with this Publisher. | * \brief Publish a message on the topic associated with this Publisher. | |||
* | * | |||
* This version of publish will allow fast intra-process message-passing in the future, | * This version of publish will allow fast intra-process message-passing in the future, | |||
* so you may not mutate the message after it has been passed in here (si nce it will be | * so you may not mutate the message after it has been passed in here (si nce it will be | |||
* passed directly into a callback function) | * passed directly into a callback function) | |||
* | * | |||
*/ | */ | |||
void publish(const Message::ConstPtr& message) const; | template<typename M> | |||
void publish(const boost::shared_ptr<M>& message) const | ||||
{ | ||||
using namespace serialization; | ||||
if (!impl_) | ||||
{ | ||||
ROS_ASSERT_MSG(false, "Call to publish() on an invalid Publisher (top | ||||
ic [%s])", impl_->topic_.c_str()); | ||||
return; | ||||
} | ||||
if (!impl_->isValid()) | ||||
{ | ||||
ROS_ASSERT_MSG(false, "Call to publish() on an invalid Publisher (top | ||||
ic [%s])", impl_->topic_.c_str()); | ||||
return; | ||||
} | ||||
SerializedMessage m; | ||||
m.type_info = &typeid(M); | ||||
m.message = message; | ||||
publish(boost::bind(serializeMessage<M>, boost::ref(*message)), m); | ||||
} | ||||
/** | /** | |||
* \brief Publish a message on the topic associated with this Publisher. | * \brief Publish a message on the topic associated with this Publisher. | |||
*/ | */ | |||
void publish(const Message& message) const; | template<typename M> | |||
void publish(const M& message) const | ||||
{ | ||||
using namespace serialization; | ||||
if (!impl_) | ||||
{ | ||||
ROS_ASSERT_MSG(false, "Call to publish() on an invalid Publisher (top | ||||
ic [%s])", impl_->topic_.c_str()); | ||||
return; | ||||
} | ||||
if (!impl_->isValid()) | ||||
{ | ||||
ROS_ASSERT_MSG(false, "Call to publish() on an invalid Publisher (top | ||||
ic [%s])", impl_->topic_.c_str()); | ||||
return; | ||||
} | ||||
SerializedMessage m; | ||||
publish(boost::bind(serializeMessage<M>, boost::ref(message)), m); | ||||
} | ||||
/** | /** | |||
* \brief Shutdown the advertisement associated with this Publisher | * \brief Shutdown the advertisement associated with this Publisher | |||
* | * | |||
* This method usually does not need to be explicitly called, as automati c shutdown happens when | * This method usually does not need to be explicitly called, as automati c shutdown happens when | |||
* all copies of this Publisher go out of scope | * all copies of this Publisher go out of scope | |||
* | * | |||
* This method overrides the automatic reference counted unadvertise, and does so immediately. | * This method overrides the automatic reference counted unadvertise, and does so immediately. | |||
* \note Note that if multiple advertisements were made through NodeHandl e::advertise(), this will | * \note Note that if multiple advertisements were made through NodeHandl e::advertise(), this will | |||
* only remove the one associated with this Publisher | * only remove the one associated with this Publisher | |||
skipping to change at line 88 | skipping to change at line 133 | |||
/** | /** | |||
* \brief Returns the topic that this Publisher will publish on. | * \brief Returns the topic that this Publisher will publish on. | |||
*/ | */ | |||
std::string getTopic() const; | std::string getTopic() const; | |||
/** | /** | |||
* \brief Returns the number of subscribers that are currently connected to this Publisher | * \brief Returns the number of subscribers that are currently connected to this Publisher | |||
*/ | */ | |||
uint32_t getNumSubscribers() const; | uint32_t getNumSubscribers() const; | |||
/** | ||||
* \brief Returns whether or not this topic is latched | ||||
*/ | ||||
bool isLatched() const; | ||||
operator void*() const { return (impl_ && impl_->isValid()) ? (void*)1 : (void*)0; } | operator void*() const { return (impl_ && impl_->isValid()) ? (void*)1 : (void*)0; } | |||
bool operator<(const Publisher& rhs) const | bool operator<(const Publisher& rhs) const | |||
{ | { | |||
return impl_ < rhs.impl_; | return impl_ < rhs.impl_; | |||
} | } | |||
bool operator==(const Publisher& rhs) const | bool operator==(const Publisher& rhs) const | |||
{ | { | |||
return impl_ == rhs.impl_; | return impl_ == rhs.impl_; | |||
} | } | |||
bool operator!=(const Publisher& rhs) const | bool operator!=(const Publisher& rhs) const | |||
{ | { | |||
return impl_ != rhs.impl_; | return impl_ != rhs.impl_; | |||
} | } | |||
private: | private: | |||
Publisher(const std::string& topic, const NodeHandle& node_handle, const SubscriberCallbacksPtr& callbacks); | Publisher(const std::string& topic, const NodeHandle& node_handle, const SubscriberCallbacksPtr& callbacks); | |||
void publish(const boost::function<SerializedMessage(void)>& serfunc, Ser | ||||
ializedMessage& m) const; | ||||
void incrementSequence() const; | ||||
class Impl | class Impl | |||
{ | { | |||
public: | public: | |||
Impl(); | Impl(); | |||
~Impl(); | ~Impl(); | |||
void unadvertise(); | void unadvertise(); | |||
bool isValid() const; | bool isValid() const; | |||
std::string topic_; | std::string topic_; | |||
End of changes. 6 change blocks. | ||||
2 lines changed or deleted | 60 lines changed or added | |||
publisher_link.h | publisher_link.h | |||
---|---|---|---|---|
skipping to change at line 81 | skipping to change at line 81 | |||
const std::string& getPublisherXMLRPCURI(); | const std::string& getPublisherXMLRPCURI(); | |||
int getConnectionID() const { return connection_id_; } | int getConnectionID() const { return connection_id_; } | |||
const std::string& getCallerID() { return caller_id_; } | const std::string& getCallerID() { return caller_id_; } | |||
bool isLatched() { return latched_; } | bool isLatched() { return latched_; } | |||
bool setHeader(const Header& header); | bool setHeader(const Header& header); | |||
/** | /** | |||
* \brief Handles handing off a received message to the subscription, whe re it will be deserialized and called back | * \brief Handles handing off a received message to the subscription, whe re it will be deserialized and called back | |||
*/ | */ | |||
virtual void handleMessage(const boost::shared_array<uint8_t>& buffer, si ze_t num_bytes) = 0; | virtual void handleMessage(const SerializedMessage& m, bool ser, bool noc opy) = 0; | |||
virtual std::string getTransportType() = 0; | virtual std::string getTransportType() = 0; | |||
virtual void drop() = 0; | virtual void drop() = 0; | |||
const std::string& getMD5Sum(); | ||||
protected: | protected: | |||
SubscriptionWPtr parent_; | SubscriptionWPtr parent_; | |||
unsigned int connection_id_; | unsigned int connection_id_; | |||
std::string publisher_xmlrpc_uri_; | std::string publisher_xmlrpc_uri_; | |||
Stats stats_; | Stats stats_; | |||
TransportHints transport_hints_; | TransportHints transport_hints_; | |||
bool latched_; | bool latched_; | |||
std::string caller_id_; | std::string caller_id_; | |||
Header header_; | Header header_; | |||
std::string md5sum_; | ||||
}; | }; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_PUBLISHER_LINK_H | #endif // ROSCPP_PUBLISHER_LINK_H | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 4 lines changed or added | |||
rospack.h | rospack.h | |||
---|---|---|---|---|
skipping to change at line 181 | skipping to change at line 181 | |||
std::string manifest_path(); | std::string manifest_path(); | |||
std::string flags(std::string lang, std::string attrib); | std::string flags(std::string lang, std::string attrib); | |||
std::string rosdep(); | std::string rosdep(); | |||
std::string versioncontrol(); | std::string versioncontrol(); | |||
std::vector<std::pair<std::string, std::string> > plugins(); | std::vector<std::pair<std::string, std::string> > plugins(); | |||
VecPkg descendants1(); | VecPkg descendants1(); | |||
const std::vector<Package *> &descendants(int depth=0); | const std::vector<Package *> &descendants(int depth=0); | |||
TiXmlElement *manifest_root(); | TiXmlElement *manifest_root(); | |||
void accumulate_deps(AccList& acc_list, Package* to); | void accumulate_deps(AccList& acc_list, Package* to); | |||
/** | ||||
* \brief Returns the message flags for this package. If the path/msg or | ||||
path/srv directories exist, | ||||
* adds appropriate compile/link flags depending on what is requested | ||||
* \param cflags Whether or not to include compile flags | ||||
* \param lflags Whether or not to include link flags | ||||
*/ | ||||
std::string cpp_message_flags(bool cflags, bool lflags); | ||||
private: | private: | |||
bool deps_calculated, direct_deps_calculated, descendants_calculated; | bool deps_calculated, direct_deps_calculated, descendants_calculated; | |||
std::vector<Package *> _deps, _direct_deps, _descendants; | std::vector<Package *> _deps, _direct_deps, _descendants; | |||
TiXmlDocument manifest; | TiXmlDocument manifest; | |||
bool manifest_loaded; | bool manifest_loaded; | |||
Package(const Package &p) { } // just override the default public one | Package(const Package &p) { } // just override the default public one | |||
bool has_parent(std::string pkg); | bool has_parent(std::string pkg); | |||
const std::vector<Package *> &direct_deps(bool missing_pkg_as_warning=fal se); | const std::vector<Package *> &direct_deps(bool missing_pkg_as_warning=fal se); | |||
skipping to change at line 223 | skipping to change at line 231 | |||
int cmd_depends_why(); | int cmd_depends_why(); | |||
int cmd_find(); | int cmd_find(); | |||
int cmd_deps(); | int cmd_deps(); | |||
int cmd_depsindent(Package* pkg, int indent); | int cmd_depsindent(Package* pkg, int indent); | |||
int cmd_deps_manifests(); | int cmd_deps_manifests(); | |||
int cmd_deps_msgsrv(); | ||||
int cmd_deps1(); | int cmd_deps1(); | |||
/* | /* | |||
int cmd_predeps(char **args, int args_len); | int cmd_predeps(char **args, int args_len); | |||
*/ | */ | |||
std::string snarf_libs(std::string flags, bool invert=false); | std::string snarf_libs(std::string flags, bool invert=false); | |||
std::string snarf_flags(std::string flags, std::string token, bool invert =false); | std::string snarf_flags(std::string flags, std::string token, bool invert =false); | |||
skipping to change at line 301 | skipping to change at line 310 | |||
int opt_profile_length; | int opt_profile_length; | |||
// only display zombie directories in profile? | // only display zombie directories in profile? | |||
bool opt_profile_zombie_only; | bool opt_profile_zombie_only; | |||
// display warnings about missing dependencies? | // display warnings about missing dependencies? | |||
bool opt_warn_on_missing_deps; | bool opt_warn_on_missing_deps; | |||
private: | private: | |||
bool cache_lock_failed; | bool cache_lock_failed; | |||
bool crawled; | bool crawled; | |||
std::string getCachePath(); | std::string getCachePath(); | |||
// Add package, filtering out duplicates. | ||||
Package* add_package(std::string path); | ||||
/** tests if the cache exists, is new enough, and is valid */ | /** tests if the cache exists, is new enough, and is valid */ | |||
bool cache_is_good(); | bool cache_is_good(); | |||
/** returns a double representing the seconds since the Epoch */ | /** returns a double representing the seconds since the Epoch */ | |||
static double time_since_epoch(); | static double time_since_epoch(); | |||
/** returns env[ROS_BINDEPS_PATH] if specified, otherwise /opt/ros */ | ||||
std::string getBinDepPath(); | ||||
/** returns true if env[ROS_BINDEPS_PATH] exists or /opt/ros exists */ | ||||
bool useBinDepPath(); | ||||
/** remove trailing slashes */ | /** remove trailing slashes */ | |||
void sanitize_rppvec(std::vector<std::string> &rppvec); | void sanitize_rppvec(std::vector<std::string> &rppvec); | |||
// Output accumulates here | // Output accumulates here | |||
std::string output_acc; | std::string output_acc; | |||
// A place to store heap-allocated argv, in case we were passed a | // A place to store heap-allocated argv, in case we were passed a | |||
// std::string in run(). It'll be freed on destruction. | // std::string in run(). It'll be freed on destruction. | |||
int my_argc; | int my_argc; | |||
char** my_argv; | char** my_argv; | |||
void freeArgv(); | void freeArgv(); | |||
// Total number of packages found, including duplicates. Used in | // Total number of packages found, including duplicates. Used in | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 12 lines changed or added | |||
rosstack.h | rosstack.h | |||
---|---|---|---|---|
skipping to change at line 137 | skipping to change at line 137 | |||
int cmd_print_packages(); | int cmd_print_packages(); | |||
void crawl_for_stacks(bool force_crawl = false); | void crawl_for_stacks(bool force_crawl = false); | |||
std::string lookup_owner(std::string pkg_name, bool just_owner_name); | std::string lookup_owner(std::string pkg_name, bool just_owner_name); | |||
void deleteCache(); | void deleteCache(); | |||
private: | private: | |||
bool crawled; | bool crawled; | |||
/** tests if the cache exists, is new enough, and is valid */ | /** tests if the cache exists, is new enough, and is valid */ | |||
void createROSHomeDirectory(); | void createROSHomeDirectory(); | |||
std::string getCachePath(); | std::string getCachePath(); | |||
// Add stack, filtering out duplicates. | ||||
Stack* add_stack(std::string path); | ||||
bool cache_is_good(); | bool cache_is_good(); | |||
/** returns a double representing the seconds since the Epoch */ | /** returns a double representing the seconds since the Epoch */ | |||
static double time_since_epoch(); | static double time_since_epoch(); | |||
/** remove trailing slashes */ | /** remove trailing slashes */ | |||
void sanitize_rppvec(std::vector<std::string> &rppvec); | void sanitize_rppvec(std::vector<std::string> &rppvec); | |||
}; | }; | |||
} | } | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 2 lines changed or added | |||
service.h | service.h | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
*/ | */ | |||
#ifndef ROSCPP_SERVICE_H | #ifndef ROSCPP_SERVICE_H | |||
#define ROSCPP_SERVICE_H | #define ROSCPP_SERVICE_H | |||
#include <string> | #include <string> | |||
#include "ros/common.h" | #include "ros/common.h" | |||
#include "ros/message.h" | #include "ros/message.h" | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/node_handle.h" | #include "ros/node_handle.h" | |||
#include "ros/service_traits.h" | ||||
#include "ros/names.h" | ||||
#include <boost/shared_ptr.hpp> | #include <boost/shared_ptr.hpp> | |||
namespace ros | namespace ros | |||
{ | { | |||
class ServiceServerLink; | class ServiceServerLink; | |||
typedef boost::shared_ptr<ServiceServerLink> ServiceServerLinkPtr; | typedef boost::shared_ptr<ServiceServerLink> ServiceServerLinkPtr; | |||
/** | /** | |||
skipping to change at line 65 | skipping to change at line 67 | |||
* | * | |||
* @param service_name The name of the service. | * @param service_name The name of the service. | |||
* @param req The request message. | * @param req The request message. | |||
* @param[out] res Storage for the response message. | * @param[out] res Storage for the response message. | |||
* | * | |||
* @return true on success, false otherwise. | * @return true on success, false otherwise. | |||
*/ | */ | |||
template<class MReq, class MRes> | template<class MReq, class MRes> | |||
bool call(const std::string& service_name, MReq& req, MRes& res) | bool call(const std::string& service_name, MReq& req, MRes& res) | |||
{ | { | |||
namespace st = service_traits; | ||||
NodeHandle nh; | NodeHandle nh; | |||
ServiceClientOptions ops(service_name, req.__getServerMD5Sum(), false, M_ string()); | ServiceClientOptions ops(ros::names::resolve(service_name), st::md5sum(re q), false, M_string()); | |||
ServiceClient client = nh.serviceClient(ops); | ServiceClient client = nh.serviceClient(ops); | |||
return client.call(req, res); | return client.call(req, res); | |||
} | } | |||
/** @brief Invoke an RPC service. | /** @brief Invoke an RPC service. | |||
* | * | |||
* This method invokes an RPC service on a remote server, looking up the | * This method invokes an RPC service on a remote server, looking up the | |||
* service location first via the master. | * service location first via the master. | |||
* | * | |||
* @param service_name The name of the service. | * @param service_name The name of the service. | |||
* @param service The service class that contains the request and response messages | * @param service The service class that contains the request and response messages | |||
* | * | |||
* @return true on success, false otherwise. | * @return true on success, false otherwise. | |||
*/ | */ | |||
template<class Service> | template<class Service> | |||
bool call(const std::string& service_name, Service& service) | bool call(const std::string& service_name, Service& service) | |||
{ | { | |||
namespace st = service_traits; | ||||
NodeHandle nh; | NodeHandle nh; | |||
ServiceClientOptions ops(service_name, service.getMD5Sum(), false, M_stri ng()); | ServiceClientOptions ops(ros::names::resolve(service_name), st::md5sum(se rvice), false, M_string()); | |||
ServiceClient client = nh.serviceClient(ops); | ServiceClient client = nh.serviceClient(ops); | |||
return client.call(service.request, service.response); | return client.call(service.request, service.response); | |||
} | } | |||
/** | /** | |||
* \brief Wait for a service to be advertised and available. Blocks until it is. | * \brief Wait for a service to be advertised and available. Blocks until it is. | |||
* \param service_name Name of the service to wait for. | * \param service_name Name of the service to wait for. | |||
* \param timeout The amount of time to wait for, in milliseconds. If time out is -1, | * \param timeout The amount of time to wait for, in milliseconds. If time out is -1, | |||
* waits until the node is shutdown | * waits until the node is shutdown | |||
* \return true on success, false otherwise | * \return true on success, false otherwise | |||
skipping to change at line 131 | skipping to change at line 136 | |||
* @param service_name The name of the service to connect to | * @param service_name The name of the service to connect to | |||
* @param persistent Whether this connection should persist. Persistent se rvices keep the connection to the remote host active | * @param persistent Whether this connection should persist. Persistent se rvices keep the connection to the remote host active | |||
* so that subsequent calls will happen faster. In general persiste nt services are discouraged, as they are not as | * so that subsequent calls will happen faster. In general persiste nt services are discouraged, as they are not as | |||
* robust to node failure as non-persistent services. | * robust to node failure as non-persistent services. | |||
* @param header_values Key/value pairs you'd like to send along in the con nection handshake | * @param header_values Key/value pairs you'd like to send along in the con nection handshake | |||
*/ | */ | |||
template<class MReq, class MRes> | template<class MReq, class MRes> | |||
ServiceClient createClient(const std::string& service_name, bool persistent = false, const M_string& header_values = M_string()) | ServiceClient createClient(const std::string& service_name, bool persistent = false, const M_string& header_values = M_string()) | |||
{ | { | |||
NodeHandle nh; | NodeHandle nh; | |||
ServiceClient client = nh.template serviceClient<MReq, MRes>(service_name , persistent, header_values); | ServiceClient client = nh.template serviceClient<MReq, MRes>(ros::names:: resolve(service_name), persistent, header_values); | |||
return client; | return client; | |||
} | } | |||
/** @brief Create a client for a service. | /** @brief Create a client for a service. | |||
* | * | |||
* When the last handle reference of a persistent connection is cleared, th e connection will automatically close. | * When the last handle reference of a persistent connection is cleared, th e connection will automatically close. | |||
* | * | |||
* @param service_name The name of the service to connect to | * @param service_name The name of the service to connect to | |||
* @param persistent Whether this connection should persist. Persistent se rvices keep the connection to the remote host active | * @param persistent Whether this connection should persist. Persistent se rvices keep the connection to the remote host active | |||
* so that subsequent calls will happen faster. In general persiste nt services are discouraged, as they are not as | * so that subsequent calls will happen faster. In general persiste nt services are discouraged, as they are not as | |||
* robust to node failure as non-persistent services. | * robust to node failure as non-persistent services. | |||
* @param header_values Key/value pairs you'd like to send along in the con nection handshake | * @param header_values Key/value pairs you'd like to send along in the con nection handshake | |||
*/ | */ | |||
template<class Service> | template<class Service> | |||
ServiceClient createClient(const std::string& service_name, bool persistent = false, const M_string& header_values = M_string()) | ServiceClient createClient(const std::string& service_name, bool persistent = false, const M_string& header_values = M_string()) | |||
{ | { | |||
NodeHandle nh; | NodeHandle nh; | |||
ServiceClient client = nh.template serviceClient<Service>(service_name, p ersistent, header_values); | ServiceClient client = nh.template serviceClient<Service>(ros::names::res olve(service_name), persistent, header_values); | |||
return client; | return client; | |||
} | } | |||
} | } | |||
} | } | |||
#endif // ROSCPP_SERVICE_H | #endif // ROSCPP_SERVICE_H | |||
End of changes. 7 change blocks. | ||||
4 lines changed or deleted | 9 lines changed or added | |||
service_client.h | service_client.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SERVICE_CLIENT_H | #ifndef ROSCPP_SERVICE_CLIENT_H | |||
#define ROSCPP_SERVICE_CLIENT_H | #define ROSCPP_SERVICE_CLIENT_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/message.h" | #include "ros/common.h" | |||
#include "ros/service_traits.h" | ||||
#include "ros/serialization.h" | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* @brief Provides a handle-based interface to service client connections | * @brief Provides a handle-based interface to service client connections | |||
*/ | */ | |||
class ServiceClient | class ServiceClient | |||
{ | { | |||
public: | public: | |||
skipping to change at line 55 | skipping to change at line 57 | |||
ServiceClient(const ServiceClient& rhs); | ServiceClient(const ServiceClient& rhs); | |||
~ServiceClient(); | ~ServiceClient(); | |||
/** | /** | |||
* @brief Call the service aliased by this handle with the specified requ est/response messages. | * @brief Call the service aliased by this handle with the specified requ est/response messages. | |||
* @note The request/response message types must match the types specifie d in the templated call to NodeHandle::serviceClient()/service::createClien t() | * @note The request/response message types must match the types specifie d in the templated call to NodeHandle::serviceClient()/service::createClien t() | |||
*/ | */ | |||
template<class MReq, class MRes> | template<class MReq, class MRes> | |||
bool call(MReq& req, MRes& res) | bool call(MReq& req, MRes& res) | |||
{ | { | |||
namespace st = service_traits; | ||||
if (!isValid()) | if (!isValid()) | |||
{ | { | |||
return false; | return false; | |||
} | } | |||
if (req.__getServerMD5Sum() != res.__getServerMD5Sum()) | if (strcmp(st::md5sum(req), st::md5sum(res))) | |||
{ | { | |||
ROS_FATAL("woah! the request and response parameters to the server " | ROS_ERROR("The request and response parameters to the service " | |||
"callback function must be autogenerated from the same " | "call must be autogenerated from the same " | |||
"server definition file (.srv). your service call " | "server definition file (.srv). your service call " | |||
"for %s appeared to use request/response types " | "for %s appeared to use request/response types " | |||
"from different .srv files.", impl_->name_.c_str()); | "from different .srv files. (%s vs. %s)", impl_->name_.c_s | |||
ROS_BREAK(); | tr(), st::md5sum(req), st::md5sum(res)); | |||
return false; | ||||
} | } | |||
return call(req, res, req.__getServerMD5Sum()); | return call(req, res, st::md5sum(req)); | |||
} | } | |||
/** | /** | |||
* @brief Call the service aliased by this handle with the specified serv ice request/response | * @brief Call the service aliased by this handle with the specified serv ice request/response | |||
*/ | */ | |||
template<class Service> | template<class Service> | |||
bool call(Service& service) | bool call(Service& service) | |||
{ | { | |||
namespace st = service_traits; | ||||
if (!isValid()) | if (!isValid()) | |||
{ | { | |||
return false; | return false; | |||
} | } | |||
return call(service.request, service.response, service.getMD5Sum()); | return call(service.request, service.response, st::md5sum(service)); | |||
} | } | |||
/** | /** | |||
* \brief Mostly for internal use, the templated versions of call() just call into this one | * \brief Mostly for internal use, the other templated versions of call() just call into this one | |||
*/ | */ | |||
bool call(Message& req, Message& resp, const std::string& service_md5sum) | template<typename MReq, typename MRes> | |||
; | bool call(const MReq& req, MRes& resp, const std::string& service_md5sum) | |||
{ | ||||
namespace ser = serialization; | ||||
SerializedMessage ser_req = ser::serializeMessage(req); | ||||
SerializedMessage ser_resp; | ||||
bool ok = call(ser_req, ser_resp, service_md5sum); | ||||
if (!ok) | ||||
{ | ||||
return false; | ||||
} | ||||
try | ||||
{ | ||||
ser::deserializeMessage(ser_resp, resp); | ||||
} | ||||
catch (std::exception& e) | ||||
{ | ||||
deserializeFailed(e); | ||||
return false; | ||||
} | ||||
return true; | ||||
} | ||||
bool call(const SerializedMessage& req, SerializedMessage& resp, const st | ||||
d::string& service_md5sum); | ||||
/** | /** | |||
* \brief Returns whether or not this handle is valid. For a persistent service, this becomes false when the connection has dropped. | * \brief Returns whether or not this handle is valid. For a persistent service, this becomes false when the connection has dropped. | |||
* Non-persistent service handles are always valid. | * Non-persistent service handles are always valid. | |||
*/ | */ | |||
bool isValid() const; | bool isValid() const; | |||
/** | /** | |||
* \brief Shutdown the connection associated with this ServiceClient | * \brief Shutdown the connection associated with this ServiceClient | |||
* | * | |||
skipping to change at line 144 | skipping to change at line 175 | |||
{ | { | |||
return impl_ == rhs.impl_; | return impl_ == rhs.impl_; | |||
} | } | |||
bool operator!=(const ServiceClient& rhs) const | bool operator!=(const ServiceClient& rhs) const | |||
{ | { | |||
return impl_ != rhs.impl_; | return impl_ != rhs.impl_; | |||
} | } | |||
private: | private: | |||
// This works around a problem with the OSX linker that causes the static | ||||
variable declared by | ||||
// ROS_ERROR to error with missing symbols when it's used directly in the | ||||
templated call() method above | ||||
// This for some reason only showed up in the rxtools package | ||||
void deserializeFailed(const std::exception& e) | ||||
{ | ||||
ROS_ERROR("Exception thrown while while deserializing service call: %s" | ||||
, e.what()); | ||||
} | ||||
struct Impl | struct Impl | |||
{ | { | |||
Impl(); | Impl(); | |||
~Impl(); | ~Impl(); | |||
void shutdown(); | void shutdown(); | |||
bool isValid() const; | bool isValid() const; | |||
ServiceServerLinkPtr server_link_; | ServiceServerLinkPtr server_link_; | |||
std::string name_; | std::string name_; | |||
End of changes. 10 change blocks. | ||||
13 lines changed or deleted | 56 lines changed or added | |||
service_client_link.h | service_client_link.h | |||
---|---|---|---|---|
skipping to change at line 36 | skipping to change at line 36 | |||
*/ | */ | |||
#ifndef ROSCPP_SERVICE_CLIENT_LINK_H | #ifndef ROSCPP_SERVICE_CLIENT_LINK_H | |||
#define ROSCPP_SERVICE_CLIENT_LINK_H | #define ROSCPP_SERVICE_CLIENT_LINK_H | |||
#include "ros/common.h" | #include "ros/common.h" | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/shared_array.hpp> | #include <boost/shared_array.hpp> | |||
#include <boost/enable_shared_from_this.hpp> | #include <boost/enable_shared_from_this.hpp> | |||
#include <boost/signals/connection.hpp> | ||||
#include <queue> | #include <queue> | |||
namespace ros | namespace ros | |||
{ | { | |||
class Header; | class Header; | |||
class Message; | ||||
typedef boost::shared_ptr<Message> MessagePtr; | ||||
class ServicePublication; | class ServicePublication; | |||
typedef boost::weak_ptr<ServicePublication> ServicePublicationWPtr; | typedef boost::weak_ptr<ServicePublication> ServicePublicationWPtr; | |||
typedef boost::shared_ptr<ServicePublication> ServicePublicationPtr; | typedef boost::shared_ptr<ServicePublication> ServicePublicationPtr; | |||
class Connection; | class Connection; | |||
typedef boost::shared_ptr<Connection> ConnectionPtr; | typedef boost::shared_ptr<Connection> ConnectionPtr; | |||
/** | /** | |||
* \brief Handles a connection to a single incoming service client. | * \brief Handles a connection to a single incoming service client. | |||
*/ | */ | |||
class ServiceClientLink : public boost::enable_shared_from_this<ServiceClie ntLink> | class ServiceClientLink : public boost::enable_shared_from_this<ServiceClie ntLink> | |||
skipping to change at line 68 | skipping to change at line 67 | |||
// | // | |||
bool initialize(const ConnectionPtr& connection); | bool initialize(const ConnectionPtr& connection); | |||
bool handleHeader(const Header& header); | bool handleHeader(const Header& header); | |||
/** | /** | |||
* \brief Writes a response to the current request. | * \brief Writes a response to the current request. | |||
* \param ok Whether the callback was successful or not | * \param ok Whether the callback was successful or not | |||
* \param resp The message response. ServiceClientLink will delete this | * \param resp The message response. ServiceClientLink will delete this | |||
*/ | */ | |||
void processResponse(bool ok, const MessagePtr& resp); | void processResponse(bool ok, const SerializedMessage& res); | |||
const ConnectionPtr& getConnection() { return connection_; } | const ConnectionPtr& getConnection() { return connection_; } | |||
private: | private: | |||
void onConnectionDropped(const ConnectionPtr& conn); | void onConnectionDropped(const ConnectionPtr& conn); | |||
void onHeaderWritten(const ConnectionPtr& conn); | void onHeaderWritten(const ConnectionPtr& conn); | |||
void onRequestLength(const ConnectionPtr& conn, const boost::shared_array <uint8_t>& buffer, uint32_t size, bool success); | void onRequestLength(const ConnectionPtr& conn, const boost::shared_array <uint8_t>& buffer, uint32_t size, bool success); | |||
void onRequest(const ConnectionPtr& conn, const boost::shared_array<uint8 _t>& buffer, uint32_t size, bool success); | void onRequest(const ConnectionPtr& conn, const boost::shared_array<uint8 _t>& buffer, uint32_t size, bool success); | |||
void onResponseWritten(const ConnectionPtr& conn); | void onResponseWritten(const ConnectionPtr& conn); | |||
ConnectionPtr connection_; | ConnectionPtr connection_; | |||
ServicePublicationWPtr parent_; | ServicePublicationWPtr parent_; | |||
bool persistent_; | ||||
boost::signals::connection dropped_conn_; | ||||
}; | }; | |||
typedef boost::shared_ptr<ServiceClientLink> ServiceClientLinkPtr; | typedef boost::shared_ptr<ServiceClientLink> ServiceClientLinkPtr; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_PUBLISHER_DATA_HANDLER_H | #endif // ROSCPP_PUBLISHER_DATA_HANDLER_H | |||
End of changes. 4 change blocks. | ||||
3 lines changed or deleted | 4 lines changed or added | |||
service_client_options.h | service_client_options.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SERVICE_CLIENT_OPTIONS_H | #ifndef ROSCPP_SERVICE_CLIENT_OPTIONS_H | |||
#define ROSCPP_SERVICE_CLIENT_OPTIONS_H | #define ROSCPP_SERVICE_CLIENT_OPTIONS_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/service_traits.h" | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Encapsulates all options available for creating a ServiceClient | * \brief Encapsulates all options available for creating a ServiceClient | |||
*/ | */ | |||
struct ServiceClientOptions | struct ServiceClientOptions | |||
{ | { | |||
ServiceClientOptions() | ServiceClientOptions() | |||
skipping to change at line 71 | skipping to change at line 72 | |||
* \brief Templated helper method, preventing you from needing to manuall y get the service md5sum | * \brief Templated helper method, preventing you from needing to manuall y get the service md5sum | |||
* \param MReq [template] Request message type | * \param MReq [template] Request message type | |||
* \param MRes [template] Response message type | * \param MRes [template] Response message type | |||
* \param _service Name of the service to connect to | * \param _service Name of the service to connect to | |||
* \param _persistent Whether or not to keep the connection open to the s ervice for future calls | * \param _persistent Whether or not to keep the connection open to the s ervice for future calls | |||
* \param _header Any extra values to be passed along in the connection h eader | * \param _header Any extra values to be passed along in the connection h eader | |||
*/ | */ | |||
template <class MReq, class MRes> | template <class MReq, class MRes> | |||
void init(const std::string& _service, bool _persistent, const M_string& _header) | void init(const std::string& _service, bool _persistent, const M_string& _header) | |||
{ | { | |||
namespace st = service_traits; | ||||
service = _service; | service = _service; | |||
md5sum = MReq::__s_getServerMD5Sum(); | md5sum = st::md5sum<MReq>(); | |||
persistent = _persistent; | persistent = _persistent; | |||
header = _header; | header = _header; | |||
} | } | |||
/* | /* | |||
* \brief Templated helper method, preventing you from needing to manuall y get the service md5sum | * \brief Templated helper method, preventing you from needing to manuall y get the service md5sum | |||
* \param Service [template] Service type | * \param Service [template] Service type | |||
* \param _service Name of the service to connect to | * \param _service Name of the service to connect to | |||
* \param _persistent Whether or not to keep the connection open to the s ervice for future calls | * \param _persistent Whether or not to keep the connection open to the s ervice for future calls | |||
* \param _header Any extra values to be passed along in the connection h eader | * \param _header Any extra values to be passed along in the connection h eader | |||
*/ | */ | |||
template <class Service> | template <class Service> | |||
void init(const std::string& _service, bool _persistent, const M_string& _header) | void init(const std::string& _service, bool _persistent, const M_string& _header) | |||
{ | { | |||
namespace st = service_traits; | ||||
service = _service; | service = _service; | |||
md5sum = Service::getMD5Sum(); | md5sum = st::md5sum<Service>(); | |||
persistent = _persistent; | persistent = _persistent; | |||
header = _header; | header = _header; | |||
} | } | |||
std::string service; ///< Service to connect to | std::string service; ///< Service to connect to | |||
std::string md5sum; ///< Service md5sum | std::string md5sum; ///< Service md5sum | |||
bool persistent; ///< Whether or not the connection should persist | bool persistent; ///< Whether or not the connection should persist | |||
M_string header; ///< Extra key/value pairs to add to the connection header | M_string header; ///< Extra key/value pairs to add to the connection header | |||
}; | }; | |||
End of changes. 5 change blocks. | ||||
2 lines changed or deleted | 7 lines changed or added | |||
service_manager.h | service_manager.h | |||
---|---|---|---|---|
skipping to change at line 37 | skipping to change at line 37 | |||
#ifndef ROSCPP_SERVICE_MANAGER_H | #ifndef ROSCPP_SERVICE_MANAGER_H | |||
#define ROSCPP_SERVICE_MANAGER_H | #define ROSCPP_SERVICE_MANAGER_H | |||
#include "forwards.h" | #include "forwards.h" | |||
#include "common.h" | #include "common.h" | |||
#include "advertise_service_options.h" | #include "advertise_service_options.h" | |||
#include "service_client_options.h" | #include "service_client_options.h" | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/thread/recursive_mutex.hpp> | ||||
namespace ros | namespace ros | |||
{ | { | |||
class ServiceManager; | class ServiceManager; | |||
typedef boost::shared_ptr<ServiceManager> ServiceManagerPtr; | typedef boost::shared_ptr<ServiceManager> ServiceManagerPtr; | |||
class PollManager; | class PollManager; | |||
typedef boost::shared_ptr<PollManager> PollManagerPtr; | typedef boost::shared_ptr<PollManager> PollManagerPtr; | |||
skipping to change at line 135 | skipping to change at line 136 | |||
bool isShuttingDown() { return shutting_down_; } | bool isShuttingDown() { return shutting_down_; } | |||
L_ServicePublication service_publications_; | L_ServicePublication service_publications_; | |||
boost::mutex service_publications_mutex_; | boost::mutex service_publications_mutex_; | |||
L_ServiceServerLink service_server_links_; | L_ServiceServerLink service_server_links_; | |||
boost::mutex service_server_links_mutex_; | boost::mutex service_server_links_mutex_; | |||
volatile bool shutting_down_; | volatile bool shutting_down_; | |||
boost::mutex shutting_down_mutex_; | boost::recursive_mutex shutting_down_mutex_; | |||
PollManagerPtr poll_manager_; | PollManagerPtr poll_manager_; | |||
ConnectionManagerPtr connection_manager_; | ConnectionManagerPtr connection_manager_; | |||
XMLRPCManagerPtr xmlrpc_manager_; | XMLRPCManagerPtr xmlrpc_manager_; | |||
}; | }; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_SERVICE_MANAGER_H | #endif // ROSCPP_SERVICE_MANAGER_H | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 2 lines changed or added | |||
service_publication.h | service_publication.h | |||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SERVICE_PUBLICATION_H | #ifndef ROSCPP_SERVICE_PUBLICATION_H | |||
#define ROSCPP_SERVICE_PUBLICATION_H | #define ROSCPP_SERVICE_PUBLICATION_H | |||
#include "ros/service_message_helper.h" | #include "ros/service_callback_helper.h" | |||
#include "XmlRpc.h" | #include "XmlRpc.h" | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/shared_ptr.hpp> | #include <boost/shared_ptr.hpp> | |||
#include <boost/shared_array.hpp> | #include <boost/shared_array.hpp> | |||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | |||
#include <boost/enable_shared_from_this.hpp> | #include <boost/enable_shared_from_this.hpp> | |||
skipping to change at line 65 | skipping to change at line 65 | |||
/** | /** | |||
* \brief Manages an advertised service. | * \brief Manages an advertised service. | |||
* | * | |||
* ServicePublication manages all incoming service requests. If its thread pool size is not 0, it will queue the requests | * ServicePublication manages all incoming service requests. If its thread pool size is not 0, it will queue the requests | |||
* into a number of threads, calling the callback from within those threads . Otherwise it immediately calls the callback | * into a number of threads, calling the callback from within those threads . Otherwise it immediately calls the callback | |||
*/ | */ | |||
class ServicePublication : public boost::enable_shared_from_this<ServicePub lication> | class ServicePublication : public boost::enable_shared_from_this<ServicePub lication> | |||
{ | { | |||
public: | public: | |||
ServicePublication(const std::string& name, const std::string &md5sum, co nst std::string& data_type, const std::string& request_data_type, | ServicePublication(const std::string& name, const std::string &md5sum, co nst std::string& data_type, const std::string& request_data_type, | |||
const std::string& response_data_type, const ServiceMessage | const std::string& response_data_type, const ServiceCallbac | |||
HelperPtr& helper, CallbackQueueInterface* queue, | kHelperPtr& helper, CallbackQueueInterface* queue, | |||
const VoidPtr& tracked_object); | const VoidConstPtr& tracked_object); | |||
~ServicePublication(); | ~ServicePublication(); | |||
/** | /** | |||
* \brief Adds a request to the queue if our thread pool size is not 0, o therwise immediately calls the callback | * \brief Adds a request to the queue if our thread pool size is not 0, o therwise immediately calls the callback | |||
*/ | */ | |||
void processRequest(boost::shared_array<uint8_t> buf, size_t num_bytes, c onst ServiceClientLinkPtr& link); | void processRequest(boost::shared_array<uint8_t> buf, size_t num_bytes, c onst ServiceClientLinkPtr& link); | |||
/** | /** | |||
* \brief Adds a service link for us to manage | * \brief Adds a service link for us to manage | |||
*/ | */ | |||
skipping to change at line 106 | skipping to change at line 106 | |||
const std::string& getName() { return name_; } | const std::string& getName() { return name_; } | |||
private: | private: | |||
void dropAllConnections(); | void dropAllConnections(); | |||
std::string name_; | std::string name_; | |||
std::string md5sum_; | std::string md5sum_; | |||
std::string data_type_; | std::string data_type_; | |||
std::string request_data_type_; | std::string request_data_type_; | |||
std::string response_data_type_; | std::string response_data_type_; | |||
ServiceMessageHelperPtr helper_; | ServiceCallbackHelperPtr helper_; | |||
V_ServiceClientLink client_links_; | V_ServiceClientLink client_links_; | |||
boost::mutex client_links_mutex_; | boost::mutex client_links_mutex_; | |||
bool dropped_; | bool dropped_; | |||
CallbackQueueInterface* callback_queue_; | CallbackQueueInterface* callback_queue_; | |||
bool has_tracked_object_; | bool has_tracked_object_; | |||
VoidWPtr tracked_object_; | VoidConstWPtr tracked_object_; | |||
}; | }; | |||
typedef boost::shared_ptr<ServicePublication> ServicePublicationPtr; | typedef boost::shared_ptr<ServicePublication> ServicePublicationPtr; | |||
} | } | |||
#endif // ROSCPP_SERVICE_PUBLICATION_H | #endif // ROSCPP_SERVICE_PUBLICATION_H | |||
End of changes. 4 change blocks. | ||||
6 lines changed or deleted | 6 lines changed or added | |||
service_server_link.h | service_server_link.h | |||
---|---|---|---|---|
skipping to change at line 63 | skipping to change at line 63 | |||
/** | /** | |||
* \brief Handles a connection to a service. If it's a non-persistent clie nt, automatically disconnects | * \brief Handles a connection to a service. If it's a non-persistent clie nt, automatically disconnects | |||
* when its first service call has finished. | * when its first service call has finished. | |||
*/ | */ | |||
class ServiceServerLink : public boost::enable_shared_from_this<ServiceServ erLink> | class ServiceServerLink : public boost::enable_shared_from_this<ServiceServ erLink> | |||
{ | { | |||
private: | private: | |||
struct CallInfo | struct CallInfo | |||
{ | { | |||
Message* req_; | SerializedMessage req_; | |||
Message* resp_; | SerializedMessage* resp_; | |||
bool finished_; | bool finished_; | |||
boost::condition_variable finished_condition_; | boost::condition_variable finished_condition_; | |||
boost::mutex finished_mutex_; | boost::mutex finished_mutex_; | |||
boost::thread::id caller_thread_id_; | boost::thread::id caller_thread_id_; | |||
bool success_; | bool success_; | |||
bool call_finished_; | bool call_finished_; | |||
}; | }; | |||
typedef boost::shared_ptr<CallInfo> CallInfoPtr; | typedef boost::shared_ptr<CallInfo> CallInfoPtr; | |||
skipping to change at line 106 | skipping to change at line 106 | |||
const std::string& getServiceName() const { return service_name_; } | const std::string& getServiceName() const { return service_name_; } | |||
const std::string& getRequestMD5Sum() const { return request_md5sum_; } | const std::string& getRequestMD5Sum() const { return request_md5sum_; } | |||
const std::string& getResponseMD5Sum() const { return response_md5sum_; } | const std::string& getResponseMD5Sum() const { return response_md5sum_; } | |||
/** | /** | |||
* \brief Blocking call the service this client is connected to | * \brief Blocking call the service this client is connected to | |||
* | * | |||
* If there is already a call happening in another thread, this will queu e up the call and still block until | * If there is already a call happening in another thread, this will queu e up the call and still block until | |||
* it has finished. | * it has finished. | |||
*/ | */ | |||
bool call(Message* req, Message* resp); | bool call(const SerializedMessage& req, SerializedMessage& resp); | |||
private: | private: | |||
void onConnectionDropped(const ConnectionPtr& conn); | void onConnectionDropped(const ConnectionPtr& conn); | |||
bool onHeaderReceived(const ConnectionPtr& conn, const Header& header); | bool onHeaderReceived(const ConnectionPtr& conn, const Header& header); | |||
/** | /** | |||
* \brief Called when the currently queued call has finished. Clears out the current call, notifying it that it | * \brief Called when the currently queued call has finished. Clears out the current call, notifying it that it | |||
* has finished, then calls processNextCall() | * has finished, then calls processNextCall() | |||
*/ | */ | |||
void callFinished(); | void callFinished(); | |||
End of changes. 2 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added | |||
single_subscriber_publisher.h | single_subscriber_publisher.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SINGLE_SUBSCRIBER_PUBLISHER_H | #ifndef ROSCPP_SINGLE_SUBSCRIBER_PUBLISHER_H | |||
#define ROSCPP_SINGLE_SUBSCRIBER_PUBLISHER_H | #define ROSCPP_SINGLE_SUBSCRIBER_PUBLISHER_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/message.h" | #include "ros/message.h" | |||
#include "ros/serialization.h" | ||||
#include <boost/utility.hpp> | #include <boost/utility.hpp> | |||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Allows publication of a message to a single subscriber. Only avai lable inside subscriber connection callbacks | * \brief Allows publication of a message to a single subscriber. Only avai lable inside subscriber connection callbacks | |||
*/ | */ | |||
class SingleSubscriberPublisher : public boost::noncopyable | class SingleSubscriberPublisher : public boost::noncopyable | |||
skipping to change at line 56 | skipping to change at line 57 | |||
~SingleSubscriberPublisher(); | ~SingleSubscriberPublisher(); | |||
/** | /** | |||
* \brief Publish a message on the topic associated with this Publisher. | * \brief Publish a message on the topic associated with this Publisher. | |||
* | * | |||
* This version of publish will allow fast intra-process message-passing in the future, | * This version of publish will allow fast intra-process message-passing in the future, | |||
* so you may not mutate the message after it has been passed in here (si nce it will be | * so you may not mutate the message after it has been passed in here (si nce it will be | |||
* passed directly into a callback function) | * passed directly into a callback function) | |||
* | * | |||
*/ | */ | |||
void publish(const Message::ConstPtr& message) const; | template<class M> | |||
void publish(const boost::shared_ptr<M const>& message) const | ||||
{ | ||||
publish(*message); | ||||
} | ||||
/** | /** | |||
* \brief Publish a message on the topic associated with this Publisher. | * \brief Publish a message on the topic associated with this Publisher. | |||
* | ||||
* This version of publish will allow fast intra-process message-passing | ||||
in the future, | ||||
* so you may not mutate the message after it has been passed in here (si | ||||
nce it will be | ||||
* passed directly into a callback function) | ||||
* | ||||
*/ | */ | |||
void publish(const Message& message) const; | template<class M> | |||
void publish(const boost::shared_ptr<M>& message) const | ||||
{ | ||||
publish(*message); | ||||
} | ||||
/** | ||||
* \brief Publish a message on the topic associated with this Publisher. | ||||
*/ | ||||
template<class M> | ||||
void publish(const M& message) const | ||||
{ | ||||
using namespace serialization; | ||||
SerializedMessage m = serializeMessage(message); | ||||
publish(m); | ||||
} | ||||
/** | /** | |||
* \brief Returns the topic this publisher publishes on | * \brief Returns the topic this publisher publishes on | |||
*/ | */ | |||
std::string getTopic() const; | std::string getTopic() const; | |||
/** | /** | |||
* \brief Returns the name of the subscriber node | * \brief Returns the name of the subscriber node | |||
*/ | */ | |||
std::string getSubscriberName() const; | std::string getSubscriberName() const; | |||
private: | private: | |||
void publish(const SerializedMessage& m) const; | ||||
SubscriberLinkPtr link_; | SubscriberLinkPtr link_; | |||
}; | }; | |||
} | } | |||
#endif // ROSCPP_PUBLISHER_HANDLE_H | #endif // ROSCPP_PUBLISHER_HANDLE_H | |||
End of changes. 5 change blocks. | ||||
2 lines changed or deleted | 31 lines changed or added | |||
subscribe_options.h | subscribe_options.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SUBSCRIBE_OPTIONS_H | #ifndef ROSCPP_SUBSCRIBE_OPTIONS_H | |||
#define ROSCPP_SUBSCRIBE_OPTIONS_H | #define ROSCPP_SUBSCRIBE_OPTIONS_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/transport_hints.h" | #include "ros/transport_hints.h" | |||
#include "subscription_message_helper.h" | #include "ros/message_traits.h" | |||
#include "subscription_callback_helper.h" | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Encapsulates all options available for creating a Subscriber | * \brief Encapsulates all options available for creating a Subscriber | |||
*/ | */ | |||
struct SubscribeOptions | struct SubscribeOptions | |||
{ | { | |||
/** | /** | |||
* | * | |||
*/ | */ | |||
SubscribeOptions() | SubscribeOptions() | |||
: queue_size(1) | : queue_size(1) | |||
, callback_queue(0) | , callback_queue(0) | |||
, allow_concurrent_callbacks(false) | ||||
{ | { | |||
} | } | |||
/** | /** | |||
* \brief Constructor | * \brief Constructor | |||
* \param _topic Topic to subscribe on | * \param _topic Topic to subscribe on | |||
* \param _queue_size Number of incoming messages to queue up for | * \param _queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param _helper Helper object used to get create messages and call call | * \param _md5sum | |||
backs | * \param _datatype | |||
*/ | */ | |||
SubscribeOptions(const std::string& _topic, uint32_t _queue_size, const S ubscriptionMessageHelperPtr& _helper) | SubscribeOptions(const std::string& _topic, uint32_t _queue_size, const s td::string& _md5sum, const std::string& _datatype) | |||
: topic(_topic) | : topic(_topic) | |||
, queue_size(_queue_size) | , queue_size(_queue_size) | |||
, md5sum(_helper->getMD5Sum()) | , md5sum(_md5sum) | |||
, datatype(_helper->getDataType()) | , datatype(_datatype) | |||
, helper(_helper) | ||||
, callback_queue(0) | , callback_queue(0) | |||
, allow_concurrent_callbacks(false) | ||||
{} | {} | |||
/** | /** | |||
* \brief Constructor | * \brief Templated initialization, templated on callback parameter type. Supports any callback parameters supported by the SubscriptionCallbackAda pter | |||
* \param _topic Topic to subscribe on | * \param _topic Topic to subscribe on | |||
* \param _queue_size Number of incoming messages to queue up for | * \param _queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param _md5sum | * \param _callback Callback to call when a message arrives on this topic | |||
* \param _datatype | ||||
*/ | */ | |||
SubscribeOptions(const std::string& _topic, uint32_t _queue_size, const s | template<class P> | |||
td::string& _md5sum, const std::string& _datatype) | void initByFullCallbackType(const std::string& _topic, uint32_t _queue_si | |||
: topic(_topic) | ze, | |||
, queue_size(_queue_size) | const boost::function<void (P)>& _callback, | |||
, md5sum(_md5sum) | const boost::function<boost::shared_ptr<typename ParameterAdapter<P> | |||
, datatype(_datatype) | ::Message>(void)>& factory_fn = defaultMessageCreateFunction<typename Param | |||
, callback_queue(0) | eterAdapter<P>::Message>) | |||
{} | { | |||
typedef typename ParameterAdapter<P>::Message MessageType; | ||||
topic = _topic; | ||||
queue_size = _queue_size; | ||||
md5sum = message_traits::md5sum<MessageType>(); | ||||
datatype = message_traits::datatype<MessageType>(); | ||||
helper = SubscriptionCallbackHelperPtr(new SubscriptionCallbackHelperT< | ||||
P>(_callback, factory_fn)); | ||||
} | ||||
/** | /** | |||
* \brief Templated initialization | * \brief Templated initialization, templated on message type. Only supp orts "const boost::shared_ptr<M const>&" callback types | |||
* \param _topic Topic to subscribe on | * \param _topic Topic to subscribe on | |||
* \param _queue_size Number of incoming messages to queue up for | * \param _queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param _callback Callback to call when a message arrives on this topic | * \param _callback Callback to call when a message arrives on this topic | |||
*/ | */ | |||
template<class M> | template<class M> | |||
void init(const std::string& _topic, uint32_t _queue_size, | void init(const std::string& _topic, uint32_t _queue_size, | |||
const boost::function<void (const boost::shared_ptr<M>&)>& _callback | const boost::function<void (const boost::shared_ptr<M const>&)>& _ca | |||
) | llback, | |||
const boost::function<boost::shared_ptr<M>(void)>& factory_fn = defa | ||||
ultMessageCreateFunction<M>) | ||||
{ | { | |||
typedef typename ParameterAdapter<M>::Message MessageType; | ||||
topic = _topic; | topic = _topic; | |||
queue_size = _queue_size; | queue_size = _queue_size; | |||
md5sum = M::__s_getMD5Sum(); | md5sum = message_traits::md5sum<MessageType>(); | |||
datatype = M::__s_getDataType(); | datatype = message_traits::datatype<MessageType>(); | |||
helper = SubscriptionMessageHelperPtr(new SubscriptionMessageHelperT<M> | helper = SubscriptionCallbackHelperPtr(new SubscriptionCallbackHelperT< | |||
(_callback)); | const boost::shared_ptr<MessageType const>&>(_callback, factory_fn)); | |||
} | } | |||
std::string topic; ///< To pic to subscribe to | std::string topic; ///< To pic to subscribe to | |||
uint32_t queue_size; ///< Nu mber of incoming messages to queue up for processing (messages in excess of this queue capacity will be discarded). | uint32_t queue_size; ///< Nu mber of incoming messages to queue up for processing (messages in excess of this queue capacity will be discarded). | |||
std::string md5sum; ///< MD 5 of the message datatype | std::string md5sum; ///< MD 5 of the message datatype | |||
std::string datatype; ///< Da tatype of the message we'd like to subscribe as | std::string datatype; ///< Da tatype of the message we'd like to subscribe as | |||
SubscriptionMessageHelperPtr helper; ///< He lper object used to get create messages and call callbacks | SubscriptionCallbackHelperPtr helper; ///< H elper object used to get create messages and call callbacks | |||
CallbackQueueInterface* callback_queue; ///< Qu eue to add callbacks to. If NULL, the global callback queue will be used | CallbackQueueInterface* callback_queue; ///< Qu eue to add callbacks to. If NULL, the global callback queue will be used | |||
/// By default subscription callbacks are guaranteed to arrive in-order, | ||||
with only one callback happening for this subscription at any given | ||||
/// time. Setting this to true allows you to receive multiple messages o | ||||
n the same topic from multiple threads at the same time | ||||
bool allow_concurrent_callbacks; | ||||
/** | /** | |||
* \brief An object whose destruction will prevent the callback associate d with this subscription | * \brief An object whose destruction will prevent the callback associate d with this subscription | |||
* | * | |||
* A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | * A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | |||
* and if the reference count goes to 0 the subscriber callbacks will not get called. | * and if the reference count goes to 0 the subscriber callbacks will not get called. | |||
* | * | |||
* \note Note that setting this will cause a new reference to be added to the object before the | * \note Note that setting this will cause a new reference to be added to the object before the | |||
* callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | * callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | |||
* thread) that the callback is invoked from. | * thread) that the callback is invoked from. | |||
*/ | */ | |||
VoidPtr tracked_object; | VoidConstPtr tracked_object; | |||
TransportHints transport_hints; ///< Hi nts for transport type and options | TransportHints transport_hints; ///< Hi nts for transport type and options | |||
/** | /** | |||
* \brief Templated helper function for creating an AdvertiseServiceOptio ns with most of its options | * \brief Templated helper function for creating an AdvertiseServiceOptio ns with most of its options | |||
* \param topic Topic name to subscribe to | * \param topic Topic name to subscribe to | |||
* \param queue_size Number of incoming messages to queue up for | * \param queue_size Number of incoming messages to queue up for | |||
* processing (messages in excess of this queue capacity will be | * processing (messages in excess of this queue capacity will be | |||
* discarded). | * discarded). | |||
* \param callback The callback to invoke when a message is received on t his topic | * \param callback The callback to invoke when a message is received on t his topic | |||
* \param tracked_object The tracked object to use (see SubscribeOptions: :tracked_object) | * \param tracked_object The tracked object to use (see SubscribeOptions: :tracked_object) | |||
* \param queue The callback queue to use (see SubscribeOptions::callback _queue) | * \param queue The callback queue to use (see SubscribeOptions::callback _queue) | |||
*/ | */ | |||
template<class M> | template<class M> | |||
static SubscribeOptions create(const std::string& topic, uint32_t queue_s ize, | static SubscribeOptions create(const std::string& topic, uint32_t queue_s ize, | |||
const boost::function<void (const boost::s | const boost::function<void (const boost::s | |||
hared_ptr<M>&)>& callback, | hared_ptr<M const>&)>& callback, | |||
const VoidPtr& tracked_object, CallbackQue | const VoidConstPtr& tracked_object, Callba | |||
ueInterface* queue) | ckQueueInterface* queue) | |||
{ | { | |||
SubscribeOptions ops; | SubscribeOptions ops; | |||
ops.init<M>(topic, queue_size, callback); | ops.init<M>(topic, queue_size, callback); | |||
ops.tracked_object = tracked_object; | ops.tracked_object = tracked_object; | |||
ops.callback_queue = queue; | ops.callback_queue = queue; | |||
return ops; | return ops; | |||
} | } | |||
}; | }; | |||
} | } | |||
End of changes. 17 change blocks. | ||||
31 lines changed or deleted | 49 lines changed or added | |||
subscriber.h | subscriber.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SUBSCRIBER_HANDLE_H | #ifndef ROSCPP_SUBSCRIBER_HANDLE_H | |||
#define ROSCPP_SUBSCRIBER_HANDLE_H | #define ROSCPP_SUBSCRIBER_HANDLE_H | |||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/subscription_message_helper.h" | #include "ros/subscription_callback_helper.h" | |||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief Manages an subscription callback on a specific topic. | * \brief Manages an subscription callback on a specific topic. | |||
* | * | |||
* A Subscriber should always be created through a call to NodeHandle::subs cribe(), or copied from one | * A Subscriber should always be created through a call to NodeHandle::subs cribe(), or copied from one | |||
* that was. Once all copies of a specific | * that was. Once all copies of a specific | |||
* Subscriber go out of scope, the subscription callback associated with th at handle will stop | * Subscriber go out of scope, the subscription callback associated with th at handle will stop | |||
skipping to change at line 88 | skipping to change at line 88 | |||
{ | { | |||
return impl_ == rhs.impl_; | return impl_ == rhs.impl_; | |||
} | } | |||
bool operator!=(const Subscriber& rhs) const | bool operator!=(const Subscriber& rhs) const | |||
{ | { | |||
return impl_ != rhs.impl_; | return impl_ != rhs.impl_; | |||
} | } | |||
private: | private: | |||
Subscriber(const std::string& topic, const NodeHandle& node_handle, const SubscriptionMessageHelperPtr& helper); | Subscriber(const std::string& topic, const NodeHandle& node_handle, const SubscriptionCallbackHelperPtr& helper); | |||
class Impl | class Impl | |||
{ | { | |||
public: | public: | |||
Impl(); | Impl(); | |||
~Impl(); | ~Impl(); | |||
void unsubscribe(); | void unsubscribe(); | |||
bool isValid() const; | bool isValid() const; | |||
std::string topic_; | std::string topic_; | |||
NodeHandlePtr node_handle_; | NodeHandlePtr node_handle_; | |||
SubscriptionMessageHelperPtr helper_; | SubscriptionCallbackHelperPtr helper_; | |||
bool unsubscribed_; | bool unsubscribed_; | |||
double constructed_; | double constructed_; | |||
}; | }; | |||
typedef boost::shared_ptr<Impl> ImplPtr; | typedef boost::shared_ptr<Impl> ImplPtr; | |||
typedef boost::weak_ptr<Impl> ImplWPtr; | typedef boost::weak_ptr<Impl> ImplWPtr; | |||
ImplPtr impl_; | ImplPtr impl_; | |||
friend class NodeHandle; | friend class NodeHandle; | |||
friend class NodeHandleBackingCollection; | friend class NodeHandleBackingCollection; | |||
End of changes. 3 change blocks. | ||||
3 lines changed or deleted | 3 lines changed or added | |||
subscriber_link.h | subscriber_link.h | |||
---|---|---|---|---|
skipping to change at line 70 | skipping to change at line 70 | |||
SubscriberLink(); | SubscriberLink(); | |||
virtual ~SubscriberLink(); | virtual ~SubscriberLink(); | |||
const std::string& getTopic() const { return topic_; } | const std::string& getTopic() const { return topic_; } | |||
const Stats &getStats() { return stats_; } | const Stats &getStats() { return stats_; } | |||
const std::string &getDestinationCallerID() const { return destination_ca ller_id_; } | const std::string &getDestinationCallerID() const { return destination_ca ller_id_; } | |||
int getConnectionID() const { return connection_id_; } | int getConnectionID() const { return connection_id_; } | |||
/** | /** | |||
* \brief Publish a message directly to our subscriber. Useful for publi | ||||
cation connection callbacks | ||||
* to publish directly to the new subscriber and no-one else | ||||
*/ | ||||
virtual bool publish(const Message& m) = 0; | ||||
/** | ||||
* \brief Queue up a message for publication. Throws out old messages if we've reached our Publication's max queue size | * \brief Queue up a message for publication. Throws out old messages if we've reached our Publication's max queue size | |||
*/ | */ | |||
virtual void enqueueMessage(const SerializedMessage& m) = 0; | virtual void enqueueMessage(const SerializedMessage& m, bool nocopy, bool ser) = 0; | |||
virtual void drop() = 0; | virtual void drop() = 0; | |||
virtual std::string getTransportType() = 0; | virtual std::string getTransportType() = 0; | |||
virtual bool isIntraprocess() { return false; } | ||||
virtual void getPublishTypes(bool& ser, bool& nocopy, const std::type_inf | ||||
o& ti) { ser = true; nocopy = false; } | ||||
const std::string& getMD5Sum(); | ||||
const std::string& getDataType(); | ||||
const std::string& getMessageDefinition(); | ||||
protected: | protected: | |||
bool verifyDatatype(const std::string &datatype); | bool verifyDatatype(const std::string &datatype); | |||
PublicationWPtr parent_; | PublicationWPtr parent_; | |||
unsigned int connection_id_; | unsigned int connection_id_; | |||
std::string destination_caller_id_; | std::string destination_caller_id_; | |||
Stats stats_; | Stats stats_; | |||
std::string topic_; | std::string topic_; | |||
}; | }; | |||
End of changes. 3 change blocks. | ||||
7 lines changed or deleted | 9 lines changed or added | |||
subscription.h | subscription.h | |||
---|---|---|---|---|
skipping to change at line 34 | skipping to change at line 34 | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SUBSCRIPTION_H | #ifndef ROSCPP_SUBSCRIPTION_H | |||
#define ROSCPP_SUBSCRIPTION_H | #define ROSCPP_SUBSCRIPTION_H | |||
#include <queue> | #include <queue> | |||
#include "ros/common.h" | #include "ros/common.h" | |||
#include "ros/header.h" | #include "ros/header.h" | |||
#include "ros/subscription_message_helper.h" | ||||
#include "ros/forwards.h" | #include "ros/forwards.h" | |||
#include "ros/transport_hints.h" | #include "ros/transport_hints.h" | |||
#include "ros/xmlrpc_manager.h" | #include "ros/xmlrpc_manager.h" | |||
#include "XmlRpc.h" | #include "XmlRpc.h" | |||
#include <boost/thread.hpp> | #include <boost/thread.hpp> | |||
#include <boost/shared_ptr.hpp> | #include <boost/shared_ptr.hpp> | |||
#include <boost/enable_shared_from_this.hpp> | #include <boost/enable_shared_from_this.hpp> | |||
namespace ros | namespace ros | |||
skipping to change at line 59 | skipping to change at line 58 | |||
class SubscriptionCallback; | class SubscriptionCallback; | |||
typedef boost::shared_ptr<SubscriptionCallback> SubscriptionCallbackPtr; | typedef boost::shared_ptr<SubscriptionCallback> SubscriptionCallbackPtr; | |||
class SubscriptionQueue; | class SubscriptionQueue; | |||
typedef boost::shared_ptr<SubscriptionQueue> SubscriptionQueuePtr; | typedef boost::shared_ptr<SubscriptionQueue> SubscriptionQueuePtr; | |||
class MessageDeserializer; | class MessageDeserializer; | |||
typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr; | typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr; | |||
class SubscriptionCallbackHelper; | ||||
typedef boost::shared_ptr<SubscriptionCallbackHelper> SubscriptionCallbackH | ||||
elperPtr; | ||||
/** | /** | |||
* \brief Manages a subscription on a single topic. | * \brief Manages a subscription on a single topic. | |||
*/ | */ | |||
class Subscription : public boost::enable_shared_from_this<Subscription> | class Subscription : public boost::enable_shared_from_this<Subscription> | |||
{ | { | |||
public: | public: | |||
Subscription(const std::string &name, const std::string& md5sum, const st d::string& datatype, const TransportHints& transport_hints); | Subscription(const std::string &name, const std::string& md5sum, const st d::string& datatype, const TransportHints& transport_hints); | |||
virtual ~Subscription(); | virtual ~Subscription(); | |||
/** | /** | |||
skipping to change at line 96 | skipping to change at line 98 | |||
void addLocalConnection(const PublicationPtr& pub); | void addLocalConnection(const PublicationPtr& pub); | |||
/** | /** | |||
* \brief Returns whether this Subscription has been dropped or not | * \brief Returns whether this Subscription has been dropped or not | |||
*/ | */ | |||
bool isDropped() { return dropped_; } | bool isDropped() { return dropped_; } | |||
XmlRpc::XmlRpcValue getStats(); | XmlRpc::XmlRpcValue getStats(); | |||
void getInfo(XmlRpc::XmlRpcValue& info); | void getInfo(XmlRpc::XmlRpcValue& info); | |||
bool addCallback(const SubscriptionMessageHelperPtr& helper, CallbackQueu | bool addCallback(const SubscriptionCallbackHelperPtr& helper, const std:: | |||
eInterface* queue, int32_t queue_size, const VoidPtr& tracked_object); | string& md5sum, CallbackQueueInterface* queue, int32_t queue_size, const Vo | |||
void removeCallback(const SubscriptionMessageHelperPtr& helper); | idConstPtr& tracked_object, bool allow_concurrent_callbacks); | |||
void removeCallback(const SubscriptionCallbackHelperPtr& helper); | ||||
typedef std::map<std::string, std::string> M_string; | typedef std::map<std::string, std::string> M_string; | |||
/** | /** | |||
* \brief Called to notify that a new message has arrived from a publishe r. | * \brief Called to notify that a new message has arrived from a publishe r. | |||
* Schedules the callback for invokation with the callback queue | * Schedules the callback for invokation with the callback queue | |||
*/ | */ | |||
uint32_t handleMessage(const boost::shared_array<uint8_t>& buffer, size_t num_bytes, bool buffer_includes_size_header, const boost::shared_ptr<M_str ing>& connection_header, const PublisherLinkPtr& link); | uint32_t handleMessage(const SerializedMessage& m, bool ser, bool nocopy, const boost::shared_ptr<M_string>& connection_header, const PublisherLinkP tr& link); | |||
const std::string datatype(); | const std::string datatype(); | |||
const std::string md5sum(); | const std::string md5sum(); | |||
/** | /** | |||
* \brief Removes a subscriber from our list | * \brief Removes a subscriber from our list | |||
*/ | */ | |||
void removePublisherLink(const PublisherLinkPtr& pub_link); | void removePublisherLink(const PublisherLinkPtr& pub_link); | |||
const std::string& getName() const { return name_; } | const std::string& getName() const { return name_; } | |||
skipping to change at line 179 | skipping to change at line 181 | |||
private: | private: | |||
XmlRpc::XmlRpcClient* client_; | XmlRpc::XmlRpcClient* client_; | |||
TransportUDPPtr udp_transport_; | TransportUDPPtr udp_transport_; | |||
SubscriptionWPtr parent_; | SubscriptionWPtr parent_; | |||
std::string remote_uri_; | std::string remote_uri_; | |||
}; | }; | |||
typedef boost::shared_ptr<PendingConnection> PendingConnectionPtr; | typedef boost::shared_ptr<PendingConnection> PendingConnectionPtr; | |||
void pendingConnectionDone(const PendingConnectionPtr& pending_conn, XmlR pc::XmlRpcValue& result); | void pendingConnectionDone(const PendingConnectionPtr& pending_conn, XmlR pc::XmlRpcValue& result); | |||
void getPublishTypes(bool& ser, bool& nocopy, const std::type_info& ti); | ||||
void headerReceived(const PublisherLinkPtr& link, const Header& h); | ||||
private: | private: | |||
Subscription(const Subscription &); // not copyable | Subscription(const Subscription &); // not copyable | |||
Subscription &operator =(const Subscription &); // nor assignable | Subscription &operator =(const Subscription &); // nor assignable | |||
void dropAllConnections(); | void dropAllConnections(); | |||
void addPublisherLink(const PublisherLinkPtr& link); | ||||
struct CallbackInfo | struct CallbackInfo | |||
{ | { | |||
CallbackQueueInterface* callback_queue_; | CallbackQueueInterface* callback_queue_; | |||
// Only used if callback_queue_ is non-NULL (NodeHandle API) | // Only used if callback_queue_ is non-NULL (NodeHandle API) | |||
SubscriptionMessageHelperPtr helper_; | SubscriptionCallbackHelperPtr helper_; | |||
SubscriptionQueuePtr subscription_queue_; | SubscriptionQueuePtr subscription_queue_; | |||
bool has_tracked_object_; | bool has_tracked_object_; | |||
VoidWPtr tracked_object_; | VoidConstWPtr tracked_object_; | |||
}; | }; | |||
typedef boost::shared_ptr<CallbackInfo> CallbackInfoPtr; | typedef boost::shared_ptr<CallbackInfo> CallbackInfoPtr; | |||
typedef std::vector<CallbackInfoPtr> V_CallbackInfo; | typedef std::vector<CallbackInfoPtr> V_CallbackInfo; | |||
std::string name_; | std::string name_; | |||
boost::mutex md5sum_mutex_; | ||||
std::string md5sum_; | std::string md5sum_; | |||
std::string datatype_; | std::string datatype_; | |||
boost::mutex callbacks_mutex_; | boost::mutex callbacks_mutex_; | |||
V_CallbackInfo callbacks_; | V_CallbackInfo callbacks_; | |||
uint32_t nonconst_callbacks_; | ||||
bool dropped_; | bool dropped_; | |||
bool shutting_down_; | bool shutting_down_; | |||
boost::mutex shutdown_mutex_; | boost::mutex shutdown_mutex_; | |||
typedef std::set<PendingConnectionPtr> S_PendingConnection; | typedef std::set<PendingConnectionPtr> S_PendingConnection; | |||
S_PendingConnection pending_connections_; | S_PendingConnection pending_connections_; | |||
boost::mutex pending_connections_mutex_; | boost::mutex pending_connections_mutex_; | |||
typedef std::vector<PublisherLinkPtr> V_PublisherLink; | typedef std::vector<PublisherLinkPtr> V_PublisherLink; | |||
V_PublisherLink publisher_links_; | V_PublisherLink publisher_links_; | |||
boost::mutex publisher_links_mutex_; | boost::mutex publisher_links_mutex_; | |||
TransportHints transport_hints_; | TransportHints transport_hints_; | |||
typedef std::map<PublisherLinkPtr, MessageDeserializerPtr> M_PublisherLin | struct LatchInfo | |||
kToDeserializer; | { | |||
M_PublisherLinkToDeserializer latched_messages_; | SerializedMessage message; | |||
PublisherLinkPtr link; | ||||
boost::shared_ptr<std::map<std::string, std::string> > connection_heade | ||||
r; | ||||
ros::Time receipt_time; | ||||
}; | ||||
typedef std::map<PublisherLinkPtr, LatchInfo> M_PublisherLinkToLatchInfo; | ||||
M_PublisherLinkToLatchInfo latched_messages_; | ||||
typedef std::vector<std::pair<const std::type_info*, MessageDeserializerP | ||||
tr> > V_TypeAndDeserializer; | ||||
V_TypeAndDeserializer cached_deserializers_; | ||||
}; | }; | |||
} | } | |||
#endif | #endif | |||
End of changes. 11 change blocks. | ||||
10 lines changed or deleted | 34 lines changed or added | |||
subscription_queue.h | subscription_queue.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_SUBSCRIPTION_QUEUE_H | #ifndef ROSCPP_SUBSCRIPTION_QUEUE_H | |||
#define ROSCPP_SUBSCRIPTION_QUEUE_H | #define ROSCPP_SUBSCRIPTION_QUEUE_H | |||
#include "forwards.h" | #include "forwards.h" | |||
#include "subscription_message_helper.h" | #include "message_event.h" | |||
#include "callback_queue_interface.h" | #include "callback_queue_interface.h" | |||
#include <boost/thread/recursive_mutex.hpp> | #include <boost/thread/recursive_mutex.hpp> | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/enable_shared_from_this.hpp> | #include <boost/enable_shared_from_this.hpp> | |||
#include <list> | #include <deque> | |||
namespace ros | namespace ros | |||
{ | { | |||
class MessageDeserializer; | class MessageDeserializer; | |||
typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr; | typedef boost::shared_ptr<MessageDeserializer> MessageDeserializerPtr; | |||
class SubscriptionQueue : public boost::enable_shared_from_this<Subscriptio | class SubscriptionCallbackHelper; | |||
nQueue> | typedef boost::shared_ptr<SubscriptionCallbackHelper> SubscriptionCallbackH | |||
elperPtr; | ||||
class SubscriptionQueue : public CallbackInterface, public boost::enable_sh | ||||
ared_from_this<SubscriptionQueue> | ||||
{ | { | |||
private: | private: | |||
struct Item | struct Item | |||
{ | { | |||
SubscriptionMessageHelperPtr helper; | SubscriptionCallbackHelperPtr helper; | |||
MessageDeserializerPtr deserializer; | MessageDeserializerPtr deserializer; | |||
bool has_tracked_object; | bool has_tracked_object; | |||
VoidWPtr tracked_object; | VoidConstWPtr tracked_object; | |||
uint64_t id; | bool nonconst_need_copy; | |||
ros::Time receipt_time; | ||||
}; | }; | |||
typedef std::list<Item> L_Item; | typedef std::deque<Item> D_Item; | |||
public: | public: | |||
SubscriptionQueue(const std::string& topic, int32_t queue_size); | SubscriptionQueue(const std::string& topic, int32_t queue_size, bool allo w_concurrent_callbacks); | |||
~SubscriptionQueue(); | ~SubscriptionQueue(); | |||
uint64_t push(const SubscriptionMessageHelperPtr& helper, const MessageDe serializerPtr& deserializer, bool has_tracked_object, const VoidWPtr& track ed_object); | void push(const SubscriptionCallbackHelperPtr& helper, const MessageDeser ializerPtr& deserializer, bool has_tracked_object, const VoidConstWPtr& tra cked_object, bool nonconst_need_copy, ros::Time receipt_time = ros::Time(), bool* was_full = 0); | |||
void clear(); | void clear(); | |||
CallbackInterface::CallResult call(uint64_t id); | ||||
bool ready(uint64_t id); | virtual CallbackInterface::CallResult call(); | |||
virtual bool ready(); | ||||
bool full(); | bool full(); | |||
void remove(uint64_t id); | ||||
private: | private: | |||
bool fullNoLock(); | bool fullNoLock(); | |||
std::string topic_; | std::string topic_; | |||
int32_t size_; | int32_t size_; | |||
bool full_; | bool full_; | |||
uint64_t id_counter_; | ||||
boost::mutex queue_mutex_; | boost::mutex queue_mutex_; | |||
L_Item queue_; | D_Item queue_; | |||
uint32_t queue_size_; | uint32_t queue_size_; | |||
bool allow_concurrent_callbacks_; | ||||
boost::recursive_mutex callback_mutex_; | boost::recursive_mutex callback_mutex_; | |||
}; | }; | |||
} | } | |||
#endif // ROSCPP_SUBSCRIPTION_QUEUE_H | #endif // ROSCPP_SUBSCRIPTION_QUEUE_H | |||
End of changes. 14 change blocks. | ||||
15 lines changed or deleted | 20 lines changed or added | |||
time.h | time.h | |||
---|---|---|---|---|
skipping to change at line 39 | skipping to change at line 39 | |||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*********************************************************************/ | *********************************************************************/ | |||
#ifndef ROS_TIME_H | #ifndef ROS_TIME_H | |||
#define ROS_TIME_H | #define ROS_TIME_H | |||
#include "duration.h" | #include "duration.h" | |||
#include "exception.h" | ||||
#include <iostream> | #include <iostream> | |||
#include <math.h> | #include <math.h> | |||
//Ros types also needs to be moved out of roscpp... | //Ros types also needs to be moved out of roscpp... | |||
//#include "ros/types.h" | //#include "ros/types.h" | |||
#ifdef WIN32 | #ifdef WIN32 | |||
#include <windows.h> | #include <windows.h> | |||
#endif | #endif | |||
namespace ros | namespace ros | |||
{ | { | |||
class TimeNotInitializedException : public Exception | ||||
{ | ||||
public: | ||||
TimeNotInitializedException() | ||||
: Exception("Cannot use ros::Time::now() before the first NodeHandle has | ||||
been created or ros::start() has been called. " | ||||
"If this is a standalone app or test that just uses ros::Time | ||||
and does not communicate over ROS, you may also call ros::Time::init()") | ||||
{} | ||||
}; | ||||
inline void normalizeSecNSec(uint64_t& sec, uint64_t& nsec) | inline void normalizeSecNSec(uint64_t& sec, uint64_t& nsec) | |||
{ | { | |||
uint64_t nsec_part = nsec % 1000000000UL; | uint64_t nsec_part = nsec % 1000000000UL; | |||
uint64_t sec_part = nsec / 1000000000UL; | uint64_t sec_part = nsec / 1000000000UL; | |||
if (sec_part > UINT_MAX) | if (sec_part > UINT_MAX) | |||
throw std::runtime_error("Time is out of dual 32-bit range"); | throw std::runtime_error("Time is out of dual 32-bit range"); | |||
sec += sec_part; | sec += sec_part; | |||
nsec = nsec_part; | nsec = nsec_part; | |||
skipping to change at line 169 | skipping to change at line 179 | |||
*/ | */ | |||
static Time now(); | static Time now(); | |||
/** | /** | |||
* \brief Sleep until a specific time has been reached. | * \brief Sleep until a specific time has been reached. | |||
*/ | */ | |||
static bool sleepUntil(const Time& end); | static bool sleepUntil(const Time& end); | |||
static void init(); | static void init(); | |||
static void shutdown(); | static void shutdown(); | |||
static void setNow(const Time& new_now); | static void setNow(const Time& new_now); | |||
static bool useSystemTime() { return use_system_time_; } | static bool useSystemTime(); | |||
private: | static bool isSimTime(); | |||
static Time sim_time_; | ||||
static bool use_system_time_; | /** | |||
* \brief Returns whether or not the current time is valid. Time is vali | ||||
d if it is non-zero. | ||||
*/ | ||||
static bool isValid(); | ||||
/** | ||||
* \brief Wait for time to become valid | ||||
*/ | ||||
static bool waitForValid(); | ||||
/** | ||||
* \brief Wait for time to become valid, with timeout | ||||
*/ | ||||
static bool waitForValid(const ros::WallDuration& timeout); | ||||
}; | }; | |||
extern const Time TIME_MAX; | extern const Time TIME_MAX; | |||
extern const Time TIME_MIN; | extern const Time TIME_MIN; | |||
/** | /** | |||
* \brief Time representation. Always wall-clock time. | * \brief Time representation. Always wall-clock time. | |||
* | * | |||
* ros::TimeBase provides most of its functionality. | * ros::TimeBase provides most of its functionality. | |||
*/ | */ | |||
End of changes. 3 change blocks. | ||||
4 lines changed or deleted | 28 lines changed or added | |||
timer.h | timer.h | |||
---|---|---|---|---|
skipping to change at line 67 | skipping to change at line 67 | |||
* \brief Stop the timer. Once this call returns, no more callbacks will be called. Does | * \brief Stop the timer. Once this call returns, no more callbacks will be called. Does | |||
* nothing if the timer is already stopped. | * nothing if the timer is already stopped. | |||
*/ | */ | |||
void stop(); | void stop(); | |||
/** | /** | |||
* \brief Returns whether or not the timer has any pending events to call . | * \brief Returns whether or not the timer has any pending events to call . | |||
*/ | */ | |||
bool hasPending(); | bool hasPending(); | |||
/** | ||||
* \brief Set the period of this timer | ||||
*/ | ||||
void setPeriod(const Duration& period); | ||||
bool isValid() { return impl_ && impl_->isValid(); } | bool isValid() { return impl_ && impl_->isValid(); } | |||
operator void*() { return isValid() ? (void*)1 : (void*)0; } | operator void*() { return isValid() ? (void*)1 : (void*)0; } | |||
bool operator<(const Timer& rhs) | bool operator<(const Timer& rhs) | |||
{ | { | |||
return impl_ < rhs.impl_; | return impl_ < rhs.impl_; | |||
} | } | |||
bool operator==(const Timer& rhs) | bool operator==(const Timer& rhs) | |||
{ | { | |||
skipping to change at line 96 | skipping to change at line 101 | |||
Timer(const TimerOptions& ops); | Timer(const TimerOptions& ops); | |||
class Impl | class Impl | |||
{ | { | |||
public: | public: | |||
Impl(); | Impl(); | |||
~Impl(); | ~Impl(); | |||
bool isValid(); | bool isValid(); | |||
bool hasPending(); | bool hasPending(); | |||
void setPeriod(const Duration& period); | ||||
void start(); | void start(); | |||
void stop(); | void stop(); | |||
bool started_; | bool started_; | |||
int32_t timer_handle_; | int32_t timer_handle_; | |||
Duration period_; | Duration period_; | |||
TimerCallback callback_; | TimerCallback callback_; | |||
CallbackQueueInterface* callback_queue_; | CallbackQueueInterface* callback_queue_; | |||
VoidWPtr tracked_object_; | VoidConstWPtr tracked_object_; | |||
bool has_tracked_object_; | bool has_tracked_object_; | |||
double constructed_; | double constructed_; | |||
bool oneshot_; | bool oneshot_; | |||
}; | }; | |||
typedef boost::shared_ptr<Impl> ImplPtr; | typedef boost::shared_ptr<Impl> ImplPtr; | |||
typedef boost::weak_ptr<Impl> ImplWPtr; | typedef boost::weak_ptr<Impl> ImplWPtr; | |||
ImplPtr impl_; | ImplPtr impl_; | |||
friend class NodeHandle; | friend class NodeHandle; | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 7 lines changed or added | |||
timer_manager.h | timer_manager.h | |||
---|---|---|---|---|
skipping to change at line 43 | skipping to change at line 43 | |||
#include "ros/file_log.h" | #include "ros/file_log.h" | |||
#include <boost/thread/thread.hpp> | #include <boost/thread/thread.hpp> | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/thread/recursive_mutex.hpp> | #include <boost/thread/recursive_mutex.hpp> | |||
#include <boost/thread/condition_variable.hpp> | #include <boost/thread/condition_variable.hpp> | |||
#include "ros/assert.h" | #include "ros/assert.h" | |||
#include "ros/callback_queue_interface.h" | #include "ros/callback_queue_interface.h" | |||
#include <vector> | ||||
#include <list> | ||||
namespace ros | namespace ros | |||
{ | { | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
class TimerManager | class TimerManager | |||
{ | { | |||
private: | private: | |||
struct TimerInfo | struct TimerInfo | |||
{ | { | |||
int32_t handle; | int32_t handle; | |||
D period; | D period; | |||
boost::function<void(const E&)> callback; | boost::function<void(const E&)> callback; | |||
boost::recursive_mutex callback_mutex; | ||||
CallbackQueueInterface* callback_queue; | CallbackQueueInterface* callback_queue; | |||
WallDuration last_cb_duration; | WallDuration last_cb_duration; | |||
T last_expected; | T last_expected; | |||
T next_expected; | T next_expected; | |||
T last_real; | T last_real; | |||
bool removed; | bool removed; | |||
VoidWPtr tracked_object; | VoidConstWPtr tracked_object; | |||
bool has_tracked_object; | bool has_tracked_object; | |||
// TODO: atomicize | ||||
boost::mutex waiting_mutex; | ||||
uint32_t waiting_callbacks; | uint32_t waiting_callbacks; | |||
bool oneshot; | bool oneshot; | |||
// debugging info | // debugging info | |||
uint32_t total_calls; | uint32_t total_calls; | |||
}; | }; | |||
typedef boost::shared_ptr<TimerInfo> TimerInfoPtr; | typedef boost::shared_ptr<TimerInfo> TimerInfoPtr; | |||
typedef boost::weak_ptr<TimerInfo> TimerInfoWPtr; | typedef boost::weak_ptr<TimerInfo> TimerInfoWPtr; | |||
typedef std::vector<TimerInfoPtr> V_TimerInfo; | typedef std::vector<TimerInfoPtr> V_TimerInfo; | |||
typedef std::list<int32_t> L_int32; | ||||
public: | public: | |||
TimerManager(); | TimerManager(); | |||
~TimerManager(); | ~TimerManager(); | |||
int32_t add(const D& period, const boost::function<void(const E&)>& callb ack, CallbackQueueInterface* callback_queue, const VoidPtr& tracked_object, bool oneshot); | int32_t add(const D& period, const boost::function<void(const E&)>& callb ack, CallbackQueueInterface* callback_queue, const VoidConstPtr& tracked_ob ject, bool oneshot); | |||
void remove(int32_t handle); | void remove(int32_t handle); | |||
bool hasPending(int32_t handle); | bool hasPending(int32_t handle); | |||
void setPeriod(int32_t handle, const D& period); | ||||
static TimerManager& global() | static TimerManager& global() | |||
{ | { | |||
static TimerManager<T, D, E> global; | static TimerManager<T, D, E> global; | |||
return global; | return global; | |||
} | } | |||
private: | private: | |||
void threadFunc(); | void threadFunc(); | |||
bool timerCompare(const TimerInfoPtr& lhs, const TimerInfoPtr& rhs); | bool waitingCompare(int32_t lhs, int32_t rhs); | |||
TimerInfoPtr findTimer(int32_t handle); | TimerInfoPtr findTimer(int32_t handle); | |||
void schedule(const TimerInfoPtr& info); | ||||
void updateNext(const TimerInfoPtr& info, const T& current_time); | ||||
V_TimerInfo timers_; | V_TimerInfo timers_; | |||
boost::mutex timers_mutex_; | boost::mutex timers_mutex_; | |||
boost::condition_variable timers_cond_; | boost::condition_variable timers_cond_; | |||
volatile bool new_timer_; | volatile bool new_timer_; | |||
boost::mutex waiting_mutex_; | ||||
L_int32 waiting_; | ||||
uint32_t id_counter_; | uint32_t id_counter_; | |||
boost::mutex id_mutex_; | boost::mutex id_mutex_; | |||
bool thread_started_; | bool thread_started_; | |||
boost::thread thread_; | boost::thread thread_; | |||
bool quit_; | bool quit_; | |||
class TimerQueueCallback : public CallbackInterface | class TimerQueueCallback : public CallbackInterface | |||
{ | { | |||
public: | public: | |||
TimerQueueCallback(const TimerInfoPtr& info, T last_expected, T last_re | TimerQueueCallback(TimerManager<T, D, E>* parent, const TimerInfoPtr& i | |||
al, T current_expected) : | nfo, T last_expected, T last_real, T current_expected) | |||
info_(info), last_expected_(last_expected), last_real_(last_real), cu | : parent_(parent) | |||
rrent_expected_(current_expected), called_(false) | , info_(info) | |||
, last_expected_(last_expected) | ||||
, last_real_(last_real) | ||||
, current_expected_(current_expected) | ||||
, called_(false) | ||||
{ | { | |||
boost::recursive_mutex::scoped_lock lock(info->callback_mutex); | boost::mutex::scoped_lock lock(info->waiting_mutex); | |||
++info->waiting_callbacks; | ++info->waiting_callbacks; | |||
} | } | |||
~TimerQueueCallback() | ~TimerQueueCallback() | |||
{ | { | |||
TimerInfoPtr info = info_.lock(); | TimerInfoPtr info = info_.lock(); | |||
if (info) | if (info) | |||
{ | { | |||
boost::recursive_mutex::scoped_lock lock(info->callback_mutex); | boost::mutex::scoped_lock lock(info->waiting_mutex); | |||
--info->waiting_callbacks; | --info->waiting_callbacks; | |||
} | } | |||
} | } | |||
CallResult call() | CallResult call() | |||
{ | { | |||
TimerInfoPtr info = info_.lock(); | TimerInfoPtr info = info_.lock(); | |||
if (!info) | if (!info) | |||
{ | { | |||
return Invalid; | return Invalid; | |||
} | } | |||
{ | { | |||
boost::recursive_mutex::scoped_lock lock(info->callback_mutex); | ||||
++info->total_calls; | ++info->total_calls; | |||
called_ = true; | called_ = true; | |||
if (info->removed) | VoidConstPtr tracked; | |||
{ | ||||
return Invalid; | ||||
} | ||||
VoidPtr tracked; | ||||
if (info->has_tracked_object) | if (info->has_tracked_object) | |||
{ | { | |||
tracked = info->tracked_object.lock(); | tracked = info->tracked_object.lock(); | |||
if (!tracked) | if (!tracked) | |||
{ | { | |||
return Invalid; | return Invalid; | |||
} | } | |||
} | } | |||
E event; | E event; | |||
skipping to change at line 179 | skipping to change at line 189 | |||
event.current_expected = current_expected_; | event.current_expected = current_expected_; | |||
event.current_real = T::now(); | event.current_real = T::now(); | |||
event.profile.last_duration = info->last_cb_duration; | event.profile.last_duration = info->last_cb_duration; | |||
WallTime cb_start = WallTime::now(); | WallTime cb_start = WallTime::now(); | |||
info->callback(event); | info->callback(event); | |||
WallTime cb_end = WallTime::now(); | WallTime cb_end = WallTime::now(); | |||
info->last_cb_duration = cb_end - cb_start; | info->last_cb_duration = cb_end - cb_start; | |||
info->last_real = event.current_real; | info->last_real = event.current_real; | |||
parent_->schedule(info); | ||||
} | } | |||
return Success; | return Success; | |||
} | } | |||
private: | private: | |||
TimerManager<T, D, E>* parent_; | ||||
TimerInfoWPtr info_; | TimerInfoWPtr info_; | |||
T last_expected_; | T last_expected_; | |||
T last_real_; | T last_real_; | |||
T current_expected_; | T current_expected_; | |||
bool called_; | bool called_; | |||
}; | }; | |||
}; | }; | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
skipping to change at line 212 | skipping to change at line 225 | |||
TimerManager<T, D, E>::~TimerManager() | TimerManager<T, D, E>::~TimerManager() | |||
{ | { | |||
quit_ = true; | quit_ = true; | |||
if (thread_started_) | if (thread_started_) | |||
{ | { | |||
thread_.join(); | thread_.join(); | |||
} | } | |||
} | } | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
bool TimerManager<T, D, E>::timerCompare(const TimerInfoPtr& lhs, const Tim erInfoPtr& rhs) | bool TimerManager<T, D, E>::waitingCompare(int32_t lhs, int32_t rhs) | |||
{ | { | |||
return lhs->next_expected < rhs->next_expected; | TimerInfoPtr infol = findTimer(lhs); | |||
TimerInfoPtr infor = findTimer(rhs); | ||||
if (!infol || !infor) | ||||
{ | ||||
return infol < infor; | ||||
} | ||||
return infol->next_expected < infor->next_expected; | ||||
} | } | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
typename TimerManager<T, D, E>::TimerInfoPtr TimerManager<T, D, E>::findTim er(int32_t handle) | typename TimerManager<T, D, E>::TimerInfoPtr TimerManager<T, D, E>::findTim er(int32_t handle) | |||
{ | { | |||
typename V_TimerInfo::iterator it = timers_.begin(); | typename V_TimerInfo::iterator it = timers_.begin(); | |||
typename V_TimerInfo::iterator end = timers_.end(); | typename V_TimerInfo::iterator end = timers_.end(); | |||
for (; it != end; ++it) | for (; it != end; ++it) | |||
{ | { | |||
if ((*it)->handle == handle) | if ((*it)->handle == handle) | |||
skipping to change at line 246 | skipping to change at line 266 | |||
boost::mutex::scoped_lock lock(timers_mutex_); | boost::mutex::scoped_lock lock(timers_mutex_); | |||
TimerInfoPtr info = findTimer(handle); | TimerInfoPtr info = findTimer(handle); | |||
if (!info) | if (!info) | |||
{ | { | |||
return false; | return false; | |||
} | } | |||
if (info->has_tracked_object) | if (info->has_tracked_object) | |||
{ | { | |||
VoidPtr tracked = info->tracked_object.lock(); | VoidConstPtr tracked = info->tracked_object.lock(); | |||
if (!tracked) | if (!tracked) | |||
{ | { | |||
return false; | return false; | |||
} | } | |||
} | } | |||
boost::mutex::scoped_lock lock2(info->waiting_mutex); | ||||
return info->next_expected <= T::now() || info->waiting_callbacks != 0; | return info->next_expected <= T::now() || info->waiting_callbacks != 0; | |||
} | } | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
int32_t TimerManager<T, D, E>::add(const D& period, const boost::function<v oid(const E&)>& callback, CallbackQueueInterface* callback_queue, | int32_t TimerManager<T, D, E>::add(const D& period, const boost::function<v oid(const E&)>& callback, CallbackQueueInterface* callback_queue, | |||
const VoidPtr& tracked_object, bool ones hot) | const VoidConstPtr& tracked_object, bool oneshot) | |||
{ | { | |||
TimerInfoPtr info(new TimerInfo); | TimerInfoPtr info(new TimerInfo); | |||
info->period = period; | info->period = period; | |||
info->callback = callback; | info->callback = callback; | |||
info->callback_queue = callback_queue; | info->callback_queue = callback_queue; | |||
info->last_expected = T::now(); | info->last_expected = T::now(); | |||
info->next_expected = info->last_expected + period; | info->next_expected = info->last_expected + period; | |||
info->removed = false; | info->removed = false; | |||
info->has_tracked_object = false; | info->has_tracked_object = false; | |||
info->waiting_callbacks = 0; | info->waiting_callbacks = 0; | |||
skipping to change at line 282 | skipping to change at line 303 | |||
{ | { | |||
info->tracked_object = tracked_object; | info->tracked_object = tracked_object; | |||
info->has_tracked_object = true; | info->has_tracked_object = true; | |||
} | } | |||
{ | { | |||
boost::mutex::scoped_lock lock(id_mutex_); | boost::mutex::scoped_lock lock(id_mutex_); | |||
info->handle = id_counter_++; | info->handle = id_counter_++; | |||
} | } | |||
boost::mutex::scoped_lock lock(timers_mutex_); | { | |||
timers_.push_back(info); | boost::mutex::scoped_lock lock(timers_mutex_); | |||
std::sort(timers_.begin(), timers_.end(), boost::bind(&TimerManager::time | timers_.push_back(info); | |||
rCompare, this, _1, _2)); | ||||
if (!thread_started_) | ||||
{ | ||||
thread_ = boost::thread(boost::bind(&TimerManager::threadFunc, this)) | ||||
; | ||||
thread_started_ = true; | ||||
} | ||||
} | ||||
if (!thread_started_) | ||||
{ | { | |||
thread_ = boost::thread(boost::bind(&TimerManager::threadFunc, this)); | boost::mutex::scoped_lock lock(waiting_mutex_); | |||
thread_started_ = true; | waiting_.push_back(info->handle); | |||
waiting_.sort(boost::bind(&TimerManager::waitingCompare, this, _1, _2)) | ||||
; | ||||
} | } | |||
new_timer_ = true; | new_timer_ = true; | |||
timers_cond_.notify_all(); | timers_cond_.notify_all(); | |||
return info->handle; | return info->handle; | |||
} | } | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
void TimerManager<T, D, E>::remove(int32_t handle) | void TimerManager<T, D, E>::remove(int32_t handle) | |||
{ | { | |||
boost::mutex::scoped_lock lock(timers_mutex_); | boost::mutex::scoped_lock lock(timers_mutex_); | |||
typename V_TimerInfo::iterator it = timers_.begin(); | typename V_TimerInfo::iterator it = timers_.begin(); | |||
typename V_TimerInfo::iterator end = timers_.end(); | typename V_TimerInfo::iterator end = timers_.end(); | |||
for (; it != end; ++it) | for (; it != end; ++it) | |||
{ | { | |||
const TimerInfoPtr& info = *it; | const TimerInfoPtr& info = *it; | |||
if (info->handle == handle) | if (info->handle == handle) | |||
{ | { | |||
{ | info->removed = true; | |||
boost::recursive_mutex::scoped_lock lock(info->callback_mutex); | info->callback_queue->removeByID((uint64_t)info.get()); | |||
info->removed = true; | ||||
info->callback_queue->removeByID((uint64_t)info.get()); | ||||
} | ||||
timers_.erase(it); | timers_.erase(it); | |||
break; | break; | |||
} | } | |||
} | } | |||
{ | ||||
boost::mutex::scoped_lock lock2(waiting_mutex_); | ||||
// Remove from the waiting list if it's in it | ||||
L_int32::iterator it = std::find(waiting_.begin(), waiting_.end(), hand | ||||
le); | ||||
if (it != waiting_.end()) | ||||
{ | ||||
waiting_.erase(it); | ||||
} | ||||
} | ||||
} | ||||
template<class T, class D, class E> | ||||
void TimerManager<T, D, E>::schedule(const TimerManager<T, D, E>::TimerInfo | ||||
Ptr& info) | ||||
{ | ||||
{ | ||||
boost::mutex::scoped_lock lock(waiting_mutex_); | ||||
if (info->removed) | ||||
{ | ||||
return; | ||||
} | ||||
updateNext(info, T::now()); | ||||
waiting_.push_back(info->handle); | ||||
waiting_.sort(boost::bind(&TimerManager::waitingCompare, this, _1, _2)) | ||||
; | ||||
} | ||||
new_timer_ = true; | ||||
timers_cond_.notify_one(); | ||||
} | ||||
template<class T, class D, class E> | ||||
void TimerManager<T, D, E>::updateNext(const TimerManager<T, D, E>::TimerIn | ||||
foPtr& info, const T& current_time) | ||||
{ | ||||
if (info->oneshot) | ||||
{ | ||||
info->next_expected = T(INT_MAX, 999999999); | ||||
} | ||||
else | ||||
{ | ||||
// Protect against someone having called setPeriod() | ||||
// If the next expected time is already past the current time | ||||
// don't update it | ||||
if (info->next_expected <= current_time) | ||||
{ | ||||
info->last_expected = info->next_expected; | ||||
info->next_expected += info->period; | ||||
} | ||||
// detect time jumping forward, as well as callbacks that are too slow | ||||
if (info->next_expected + info->period < current_time) | ||||
{ | ||||
ROS_DEBUG("Time jumped forward by [%f] for timer of period [%f], rese | ||||
tting timer (current=%f, next_expected=%f)", (current_time - info->next_exp | ||||
ected).toSec(), info->period.toSec(), current_time.toSec(), info->next_expe | ||||
cted.toSec()); | ||||
info->next_expected = current_time; | ||||
} | ||||
} | ||||
} | ||||
template<class T, class D, class E> | ||||
void TimerManager<T, D, E>::setPeriod(int32_t handle, const D& period) | ||||
{ | ||||
boost::mutex::scoped_lock lock(timers_mutex_); | ||||
TimerInfoPtr info = findTimer(handle); | ||||
if (!info) | ||||
{ | ||||
return; | ||||
} | ||||
{ | ||||
boost::mutex::scoped_lock lock(waiting_mutex_); | ||||
info->period = period; | ||||
info->next_expected = T::now() + period; | ||||
waiting_.sort(boost::bind(&TimerManager::waitingCompare, this, _1, _2)) | ||||
; | ||||
} | ||||
new_timer_ = true; | ||||
timers_cond_.notify_one(); | ||||
} | } | |||
template<class T, class D, class E> | template<class T, class D, class E> | |||
void TimerManager<T, D, E>::threadFunc() | void TimerManager<T, D, E>::threadFunc() | |||
{ | { | |||
T current; | T current; | |||
while (!quit_) | while (!quit_) | |||
{ | { | |||
T sleep_end; | T sleep_end; | |||
skipping to change at line 355 | skipping to change at line 460 | |||
if (current < info->last_expected) | if (current < info->last_expected) | |||
{ | { | |||
info->last_expected = current; | info->last_expected = current; | |||
info->next_expected = current + info->period; | info->next_expected = current + info->period; | |||
} | } | |||
} | } | |||
} | } | |||
current = T::now(); | current = T::now(); | |||
if (timers_.empty()) | ||||
{ | { | |||
sleep_end = current + D(0.1); | boost::mutex::scoped_lock waitlock(waiting_mutex_); | |||
} | ||||
else | ||||
{ | ||||
TimerInfoPtr info = timers_.front(); | ||||
while (info->next_expected <= current) | if (waiting_.empty()) | |||
{ | { | |||
current = T::now(); | sleep_end = current + D(0.1); | |||
} | ||||
ROS_DEBUG("Scheduling timer callback for timer of period [%f]", inf | else | |||
o->period.toSec()); | { | |||
CallbackInterfacePtr cb(new TimerQueueCallback(info, info->last_exp | TimerInfoPtr info = findTimer(waiting_.front()); | |||
ected, info->last_real, info->next_expected)); | ||||
info->callback_queue->addCallback(cb, (uint64_t)info.get()); | ||||
if (info->oneshot) | while (!waiting_.empty() && info && info->next_expected <= current) | |||
{ | ||||
info->next_expected = T(INT_MAX, 999999999); | ||||
} | ||||
else | ||||
{ | { | |||
info->last_expected = info->next_expected; | current = T::now(); | |||
info->next_expected += info->period; | ||||
// detect time jumping forward, as well as callbacks that are too | //ROS_DEBUG("Scheduling timer callback for timer [%d] of period [ | |||
slow | %f], [%f] off expected", info->handle, info->period.toSec(), (current - inf | |||
if (info->next_expected + info->period < current) | o->next_expected).toSec()); | |||
CallbackInterfacePtr cb(new TimerQueueCallback(this, info, info-> | ||||
last_expected, info->last_real, info->next_expected)); | ||||
info->callback_queue->addCallback(cb, (uint64_t)info.get()); | ||||
waiting_.pop_front(); | ||||
if (waiting_.empty()) | ||||
{ | { | |||
//ROSCPP_LOG_DEBUG("Time jumped forward by [%f] for timer of pe | break; | |||
riod [%f], resetting timer (current=%f, next_expected=%f)", (current - info | ||||
->next_expected).toSec(), info->period.toSec(), current.toSec(), info->next | ||||
_expected.toSec()); | ||||
info->next_expected = current; | ||||
} | } | |||
} | ||||
std::sort(timers_.begin(), timers_.end(), boost::bind(&TimerManager | ||||
::timerCompare, this, _1, _2)); | ||||
info = timers_.front(); | ||||
} | ||||
if (info) | info = findTimer(waiting_.front()); | |||
{ | } | |||
sleep_end = info->next_expected; | ||||
} | ||||
else | ||||
{ | ||||
if (info) | ||||
{ | ||||
sleep_end = info->next_expected; | ||||
} | ||||
} | } | |||
} | } | |||
while (!new_timer_ && T::now() < sleep_end && !quit_) | while (!new_timer_ && T::now() < sleep_end && !quit_) | |||
{ | { | |||
// detect backwards jumps in time | // detect backwards jumps in time | |||
if (T::now() < current) | if (T::now() < current) | |||
{ | { | |||
ROSCPP_LOG_DEBUG("Time jumped backwards, breaking out of sleep"); | ROSCPP_LOG_DEBUG("Time jumped backwards, breaking out of sleep"); | |||
End of changes. 38 change blocks. | ||||
75 lines changed or deleted | 173 lines changed or added | |||
timer_options.h | timer_options.h | |||
---|---|---|---|---|
skipping to change at line 72 | skipping to change at line 72 | |||
CallbackQueueInterface* callback_queue; ///< Qu eue to add callbacks to. If NULL, the global callback queue will be used | CallbackQueueInterface* callback_queue; ///< Qu eue to add callbacks to. If NULL, the global callback queue will be used | |||
/** | /** | |||
* A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | * A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | |||
* and if the reference count goes to 0 the subscriber callbacks will not get called. | * and if the reference count goes to 0 the subscriber callbacks will not get called. | |||
* | * | |||
* \note Note that setting this will cause a new reference to be added to the object before the | * \note Note that setting this will cause a new reference to be added to the object before the | |||
* callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | * callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | |||
* thread) that the callback is invoked from. | * thread) that the callback is invoked from. | |||
*/ | */ | |||
VoidPtr tracked_object; | VoidConstPtr tracked_object; | |||
bool oneshot; | bool oneshot; | |||
}; | }; | |||
} | } | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||
topic_manager.h | topic_manager.h | |||
---|---|---|---|---|
skipping to change at line 33 | skipping to change at line 33 | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_TOPIC_MANAGER_H | #ifndef ROSCPP_TOPIC_MANAGER_H | |||
#define ROSCPP_TOPIC_MANAGER_H | #define ROSCPP_TOPIC_MANAGER_H | |||
#include "forwards.h" | #include "forwards.h" | |||
#include "common.h" | #include "common.h" | |||
#include "subscribe_options.h" | #include "ros/serialization.h" | |||
#include "advertise_options.h" | ||||
#include "rosout_appender.h" | #include "rosout_appender.h" | |||
#include "XmlRpcValue.h" | #include "XmlRpcValue.h" | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/thread/recursive_mutex.hpp> | #include <boost/thread/recursive_mutex.hpp> | |||
namespace ros | namespace ros | |||
{ | { | |||
class Message; | class Message; | |||
class SubscribeOptions; | ||||
class AdvertiseOptions; | ||||
class TopicManager; | class TopicManager; | |||
typedef boost::shared_ptr<TopicManager> TopicManagerPtr; | typedef boost::shared_ptr<TopicManager> TopicManagerPtr; | |||
class PollManager; | class PollManager; | |||
typedef boost::shared_ptr<PollManager> PollManagerPtr; | typedef boost::shared_ptr<PollManager> PollManagerPtr; | |||
class XMLRPCManager; | class XMLRPCManager; | |||
typedef boost::shared_ptr<XMLRPCManager> XMLRPCManagerPtr; | typedef boost::shared_ptr<XMLRPCManager> XMLRPCManagerPtr; | |||
class ConnectionManager; | class ConnectionManager; | |||
typedef boost::shared_ptr<ConnectionManager> ConnectionManagerPtr; | typedef boost::shared_ptr<ConnectionManager> ConnectionManagerPtr; | |||
class SubscriptionCallbackHelper; | ||||
typedef boost::shared_ptr<SubscriptionCallbackHelper> SubscriptionCallbackH | ||||
elperPtr; | ||||
class TopicManager | class TopicManager | |||
{ | { | |||
public: | public: | |||
static const TopicManagerPtr& instance(); | static const TopicManagerPtr& instance(); | |||
TopicManager(); | TopicManager(); | |||
~TopicManager(); | ~TopicManager(); | |||
void start(); | void start(); | |||
void shutdown(); | void shutdown(); | |||
bool subscribe(const SubscribeOptions& ops); | bool subscribe(const SubscribeOptions& ops); | |||
bool unsubscribe(const std::string &_topic, const SubscriptionMessageHelp erPtr& helper); | bool unsubscribe(const std::string &_topic, const SubscriptionCallbackHel perPtr& helper); | |||
bool advertise(const AdvertiseOptions& ops, const SubscriberCallbacksPtr& callbacks); | bool advertise(const AdvertiseOptions& ops, const SubscriberCallbacksPtr& callbacks); | |||
bool unadvertise(const std::string &topic, const SubscriberCallbacksPtr& callbacks); | bool unadvertise(const std::string &topic, const SubscriberCallbacksPtr& callbacks); | |||
/** @brief Get the list of topics advertised by this node | /** @brief Get the list of topics advertised by this node | |||
* | * | |||
* @param[out] topics The advertised topics | * @param[out] topics The advertised topics | |||
*/ | */ | |||
void getAdvertisedTopics(V_string& topics); | void getAdvertisedTopics(V_string& topics); | |||
skipping to change at line 117 | skipping to change at line 121 | |||
size_t getNumSubscriptions(); | size_t getNumSubscriptions(); | |||
/** | /** | |||
* \brief Return the number of publishers connected to this node on a par ticular topic | * \brief Return the number of publishers connected to this node on a par ticular topic | |||
* | * | |||
* \param _topic the topic name to check | * \param _topic the topic name to check | |||
* \return the number of subscribers | * \return the number of subscribers | |||
*/ | */ | |||
size_t getNumPublishers(const std::string &_topic); | size_t getNumPublishers(const std::string &_topic); | |||
/** @brief Publish a message. | template<typename M> | |||
* | void publish(const std::string& topic, const M& message) | |||
* This method publishes a message on a topic, delivering it to any | { | |||
* currently connected subscribers. If no subscribers are connected, | using namespace serialization; | |||
* this call does nothing. | ||||
* | ||||
* You must have already called \ref advertise() | ||||
* on the topic you are trying to publish to, and the type supplied in | ||||
* the advertise() call must match the type of the message you are trying | ||||
* to publish. | ||||
* | ||||
* This method can be safely called from within a subscriber connection | ||||
* callback. | ||||
* | ||||
* @param _topic The topic to publish to. | ||||
* @param msg Message to be published. | ||||
*/ | ||||
void publish(const std::string &_topic, const Message& m); | ||||
void publish(const PublicationPtr& p, const Message& m); | SerializedMessage m; | |||
publish(topic, boost::bind(serializeMessage<M>, boost::ref(message)), m | ||||
); | ||||
} | ||||
void publish(const std::string &_topic, const boost::function<SerializedM | ||||
essage(void)>& serfunc, SerializedMessage& m); | ||||
void incrementSequence(const std::string &_topic); | ||||
bool isLatched(const std::string& topic); | ||||
private: | private: | |||
/** if it finds a pre-existing subscription to the same topic and of the | /** if it finds a pre-existing subscription to the same topic and of the | |||
* same message type, it appends the Functor to the callback vector for | * same message type, it appends the Functor to the callback vector for | |||
* that subscription. otherwise, it returns false, indicating that a new | * that subscription. otherwise, it returns false, indicating that a new | |||
* subscription needs to be created. | * subscription needs to be created. | |||
*/ | */ | |||
bool addSubCallback(const SubscribeOptions& ops); | bool addSubCallback(const SubscribeOptions& ops); | |||
/** @brief Request a topic | /** @brief Request a topic | |||
skipping to change at line 169 | skipping to change at line 166 | |||
// Must lock the advertised topics mutex before calling this function | // Must lock the advertised topics mutex before calling this function | |||
bool isTopicAdvertised(const std::string& topic); | bool isTopicAdvertised(const std::string& topic); | |||
bool registerSubscriber(const SubscriptionPtr& s, const std::string& data type); | bool registerSubscriber(const SubscriptionPtr& s, const std::string& data type); | |||
bool unregisterSubscriber(const std::string& topic); | bool unregisterSubscriber(const std::string& topic); | |||
bool unregisterPublisher(const std::string& topic); | bool unregisterPublisher(const std::string& topic); | |||
PublicationPtr lookupPublicationWithoutLock(const std::string &topic); | PublicationPtr lookupPublicationWithoutLock(const std::string &topic); | |||
void processPublishQueue(); | void processPublishQueues(); | |||
/** @brief Compute the statistics for the node's connectivity | /** @brief Compute the statistics for the node's connectivity | |||
* | * | |||
* This is the implementation of the xml-rpc getBusStats function; | * This is the implementation of the xml-rpc getBusStats function; | |||
* it populates the XmlRpcValue object sent to it with various statistics | * it populates the XmlRpcValue object sent to it with various statistics | |||
* about the node's connectivity, bandwidth utilization, etc. | * about the node's connectivity, bandwidth utilization, etc. | |||
*/ | */ | |||
void getBusStats(XmlRpc::XmlRpcValue &stats); | void getBusStats(XmlRpc::XmlRpcValue &stats); | |||
/** @brief Compute the info for the node's connectivity | /** @brief Compute the info for the node's connectivity | |||
skipping to change at line 214 | skipping to change at line 211 | |||
bool isShuttingDown() { return shutting_down_; } | bool isShuttingDown() { return shutting_down_; } | |||
boost::mutex subs_mutex_; | boost::mutex subs_mutex_; | |||
L_Subscription subscriptions_; | L_Subscription subscriptions_; | |||
boost::recursive_mutex advertised_topics_mutex_; | boost::recursive_mutex advertised_topics_mutex_; | |||
V_Publication advertised_topics_; | V_Publication advertised_topics_; | |||
std::list<std::string> advertised_topic_names_; | std::list<std::string> advertised_topic_names_; | |||
boost::mutex advertised_topic_names_mutex_; | boost::mutex advertised_topic_names_mutex_; | |||
typedef std::vector<std::pair<PublicationPtr, SerializedMessage> > V_Publ | ||||
icationAndSerializedMessagePair; | ||||
V_PublicationAndSerializedMessagePair publish_queue_; | ||||
boost::mutex publish_queue_mutex_; | ||||
volatile bool shutting_down_; | volatile bool shutting_down_; | |||
boost::mutex shutting_down_mutex_; | boost::mutex shutting_down_mutex_; | |||
PollManagerPtr poll_manager_; | PollManagerPtr poll_manager_; | |||
ConnectionManagerPtr connection_manager_; | ConnectionManagerPtr connection_manager_; | |||
XMLRPCManagerPtr xmlrpc_manager_; | XMLRPCManagerPtr xmlrpc_manager_; | |||
}; | }; | |||
} // namespace ros | } // namespace ros | |||
End of changes. 8 change blocks. | ||||
28 lines changed or deleted | 23 lines changed or added | |||
transport.h | transport.h | |||
---|---|---|---|---|
skipping to change at line 85 | skipping to change at line 85 | |||
/** | /** | |||
* \brief Enable writing on this transport. Allows derived classes to, f or example, enable write polling for asynchronous sockets | * \brief Enable writing on this transport. Allows derived classes to, f or example, enable write polling for asynchronous sockets | |||
*/ | */ | |||
virtual void enableWrite() = 0; | virtual void enableWrite() = 0; | |||
/** | /** | |||
* \brief Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets | * \brief Disable writing on this transport. Allows derived classes to, for example, disable write polling for asynchronous sockets | |||
*/ | */ | |||
virtual void disableWrite() = 0; | virtual void disableWrite() = 0; | |||
/** | /** | |||
* \brief Enable reading on this transport. Allows derived classes to, f | ||||
or example, enable read polling for asynchronous sockets | ||||
*/ | ||||
virtual void enableRead() = 0; | ||||
/** | ||||
* \brief Disable reading on this transport. Allows derived classes to, | ||||
for example, disable read polling for asynchronous sockets | ||||
*/ | ||||
virtual void disableRead() = 0; | ||||
/** | ||||
* \brief Close this transport. Once this call has returned, writing on this transport should always return an error. | * \brief Close this transport. Once this call has returned, writing on this transport should always return an error. | |||
*/ | */ | |||
virtual void close() = 0; | virtual void close() = 0; | |||
/** | /** | |||
* \brief Return a string that details the type of transport (Eg. TCPROS) | * \brief Return a string that details the type of transport (Eg. TCPROS) | |||
* \return The stringified transport type | * \return The stringified transport type | |||
*/ | */ | |||
virtual const char* getType() = 0; | virtual const char* getType() = 0; | |||
End of changes. 1 change blocks. | ||||
0 lines changed or deleted | 11 lines changed or added | |||
transport_publisher_link.h | transport_publisher_link.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_TRANSPORT_PUBLISHER_LINK_H | #ifndef ROSCPP_TRANSPORT_PUBLISHER_LINK_H | |||
#define ROSCPP_TRANSPORT_PUBLISHER_LINK_H | #define ROSCPP_TRANSPORT_PUBLISHER_LINK_H | |||
#include "publisher_link.h" | #include "publisher_link.h" | |||
#include "connection.h" | ||||
namespace ros | namespace ros | |||
{ | { | |||
class Header; | class Header; | |||
class Message; | class Message; | |||
class Subscription; | class Subscription; | |||
typedef boost::shared_ptr<Subscription> SubscriptionPtr; | typedef boost::shared_ptr<Subscription> SubscriptionPtr; | |||
typedef boost::weak_ptr<Subscription> SubscriptionWPtr; | typedef boost::weak_ptr<Subscription> SubscriptionWPtr; | |||
class Connection; | class Connection; | |||
typedef boost::shared_ptr<Connection> ConnectionPtr; | typedef boost::shared_ptr<Connection> ConnectionPtr; | |||
class WallTimerEvent; | ||||
/** | /** | |||
* \brief Handles a connection to a single publisher on a given topic. Rec eives messages from a publisher | * \brief Handles a connection to a single publisher on a given topic. Rec eives messages from a publisher | |||
* and hands them off to its parent Subscription | * and hands them off to its parent Subscription | |||
*/ | */ | |||
class TransportPublisherLink : public PublisherLink | class TransportPublisherLink : public PublisherLink | |||
{ | { | |||
public: | public: | |||
TransportPublisherLink(const SubscriptionPtr& parent, const std::string& xmlrpc_uri, const TransportHints& transport_hints); | TransportPublisherLink(const SubscriptionPtr& parent, const std::string& xmlrpc_uri, const TransportHints& transport_hints); | |||
virtual ~TransportPublisherLink(); | virtual ~TransportPublisherLink(); | |||
// | // | |||
bool initialize(const ConnectionPtr& connection); | bool initialize(const ConnectionPtr& connection); | |||
const ConnectionPtr& getConnection() { return connection_; } | const ConnectionPtr& getConnection() { return connection_; } | |||
virtual std::string getTransportType(); | virtual std::string getTransportType(); | |||
virtual void drop(); | virtual void drop(); | |||
private: | private: | |||
void onConnectionDropped(const ConnectionPtr& conn); | void onConnectionDropped(const ConnectionPtr& conn, Connection::DropReaso n reason); | |||
bool onHeaderReceived(const ConnectionPtr& conn, const Header& header); | bool onHeaderReceived(const ConnectionPtr& conn, const Header& header); | |||
/** | /** | |||
* \brief Handles handing off a received message to the subscription, whe re it will be deserialized and called back | * \brief Handles handing off a received message to the subscription, whe re it will be deserialized and called back | |||
*/ | */ | |||
virtual void handleMessage(const boost::shared_array<uint8_t>& buffer, si ze_t num_bytes); | virtual void handleMessage(const SerializedMessage& m, bool ser, bool noc opy); | |||
void onHeaderWritten(const ConnectionPtr& conn); | void onHeaderWritten(const ConnectionPtr& conn); | |||
void onMessageLength(const ConnectionPtr& conn, const boost::shared_array <uint8_t>& buffer, uint32_t size, bool success); | void onMessageLength(const ConnectionPtr& conn, const boost::shared_array <uint8_t>& buffer, uint32_t size, bool success); | |||
void onMessage(const ConnectionPtr& conn, const boost::shared_array<uint8 _t>& buffer, uint32_t size, bool success); | void onMessage(const ConnectionPtr& conn, const boost::shared_array<uint8 _t>& buffer, uint32_t size, bool success); | |||
void onRetryTimer(const ros::WallTimerEvent&); | ||||
ConnectionPtr connection_; | ConnectionPtr connection_; | |||
int32_t retry_timer_handle_; | ||||
bool needs_retry_; | ||||
WallDuration retry_period_; | ||||
WallTime next_retry_; | ||||
bool dropping_; | ||||
}; | }; | |||
typedef boost::shared_ptr<TransportPublisherLink> TransportPublisherLinkPtr ; | typedef boost::shared_ptr<TransportPublisherLink> TransportPublisherLinkPtr ; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_TRANSPORT_PUBLISHER_LINK_H | #endif // ROSCPP_TRANSPORT_PUBLISHER_LINK_H | |||
End of changes. 6 change blocks. | ||||
2 lines changed or deleted | 13 lines changed or added | |||
transport_subscriber_link.h | transport_subscriber_link.h | |||
---|---|---|---|---|
skipping to change at line 32 | skipping to change at line 32 | |||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF T HE | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_TRANSPORT_SUBSCRIBER_LINK_H | #ifndef ROSCPP_TRANSPORT_SUBSCRIBER_LINK_H | |||
#define ROSCPP_TRANSPORT_SUBSCRIBER_LINK_H | #define ROSCPP_TRANSPORT_SUBSCRIBER_LINK_H | |||
#include "subscriber_link.h" | #include "subscriber_link.h" | |||
#include <boost/signals/connection.hpp> | ||||
namespace ros | namespace ros | |||
{ | { | |||
/** | /** | |||
* \brief SubscriberLink handles broadcasting messages to a single subscrib er on a single topic | * \brief SubscriberLink handles broadcasting messages to a single subscrib er on a single topic | |||
*/ | */ | |||
class TransportSubscriberLink : public SubscriberLink | class TransportSubscriberLink : public SubscriberLink | |||
{ | { | |||
public: | public: | |||
TransportSubscriberLink(); | TransportSubscriberLink(); | |||
virtual ~TransportSubscriberLink(); | virtual ~TransportSubscriberLink(); | |||
// | // | |||
bool initialize(const ConnectionPtr& connection); | bool initialize(const ConnectionPtr& connection); | |||
bool handleHeader(const Header& header); | bool handleHeader(const Header& header); | |||
const ConnectionPtr& getConnection() { return connection_; } | const ConnectionPtr& getConnection() { return connection_; } | |||
virtual bool publish(const Message& m); | virtual void enqueueMessage(const SerializedMessage& m, bool ser, bool no | |||
virtual void enqueueMessage(const SerializedMessage& m); | copy); | |||
virtual void drop(); | virtual void drop(); | |||
virtual std::string getTransportType(); | virtual std::string getTransportType(); | |||
private: | private: | |||
void onConnectionDropped(const ConnectionPtr& conn); | void onConnectionDropped(const ConnectionPtr& conn); | |||
void onHeaderWritten(const ConnectionPtr& conn); | void onHeaderWritten(const ConnectionPtr& conn); | |||
void onMessageWritten(const ConnectionPtr& conn); | void onMessageWritten(const ConnectionPtr& conn); | |||
void startMessageWrite(bool immediate_write); | void startMessageWrite(bool immediate_write); | |||
bool writing_message_; | bool writing_message_; | |||
bool header_written_; | bool header_written_; | |||
ConnectionPtr connection_; | ConnectionPtr connection_; | |||
boost::signals::connection dropped_conn_; | ||||
std::queue<SerializedMessage> outbox_; | std::queue<SerializedMessage> outbox_; | |||
boost::mutex outbox_mutex_; | boost::mutex outbox_mutex_; | |||
bool queue_full_; | bool queue_full_; | |||
}; | }; | |||
typedef boost::shared_ptr<TransportSubscriberLink> TransportSubscriberLinkP tr; | typedef boost::shared_ptr<TransportSubscriberLink> TransportSubscriberLinkP tr; | |||
} // namespace ros | } // namespace ros | |||
#endif // ROSCPP_TRANSPORT_SUBSCRIBER_LINK_H | #endif // ROSCPP_TRANSPORT_SUBSCRIBER_LINK_H | |||
End of changes. 3 change blocks. | ||||
2 lines changed or deleted | 5 lines changed or added | |||
transport_tcp.h | transport_tcp.h | |||
---|---|---|---|---|
skipping to change at line 103 | skipping to change at line 103 | |||
*/ | */ | |||
TransportTCPPtr accept(); | TransportTCPPtr accept(); | |||
/** | /** | |||
* \brief Returns the port this transport is listening on | * \brief Returns the port this transport is listening on | |||
*/ | */ | |||
int getServerPort() { return server_port_; } | int getServerPort() { return server_port_; } | |||
void setNoDelay(bool nodelay); | void setNoDelay(bool nodelay); | |||
void setKeepAlive(bool use, uint32_t idle, uint32_t interval, uint32_t co unt); | void setKeepAlive(bool use, uint32_t idle, uint32_t interval, uint32_t co unt); | |||
const std::string& getConnectedHost() { return connected_host_; } | ||||
int getConnectedPort() { return connected_port_; } | ||||
// overrides from Transport | // overrides from Transport | |||
virtual int32_t read(uint8_t* buffer, uint32_t size); | virtual int32_t read(uint8_t* buffer, uint32_t size); | |||
virtual int32_t write(uint8_t* buffer, uint32_t size); | virtual int32_t write(uint8_t* buffer, uint32_t size); | |||
virtual void enableWrite(); | virtual void enableWrite(); | |||
virtual void disableWrite(); | virtual void disableWrite(); | |||
virtual void enableRead(); | ||||
virtual void disableRead(); | ||||
virtual void close(); | virtual void close(); | |||
virtual std::string getTransportInfo(); | virtual std::string getTransportInfo(); | |||
virtual void parseHeader(const Header& header); | virtual void parseHeader(const Header& header); | |||
virtual const char* getType() { return "TCPROS"; } | virtual const char* getType() { return "TCPROS"; } | |||
private: | private: | |||
/** | /** | |||
* \brief Initializes the assigned socket -- sets it to non-blocking and enables reading | * \brief Initializes the assigned socket -- sets it to non-blocking and enables reading | |||
*/ | */ | |||
bool initializeSocket(); | bool initializeSocket(); | |||
bool setNonBlocking(); | ||||
/** | /** | |||
* \brief Set the socket to be used by this transport | * \brief Set the socket to be used by this transport | |||
* \param sock A valid TCP socket | * \param sock A valid TCP socket | |||
* \return Whether setting the socket was successful | * \return Whether setting the socket was successful | |||
*/ | */ | |||
bool setSocket(int sock); | bool setSocket(int sock); | |||
/** | ||||
* \brief Enables reading on our socket | ||||
*/ | ||||
void enableRead(); | ||||
void socketUpdate(int events); | void socketUpdate(int events); | |||
int sock_; | int sock_; | |||
bool closed_; | bool closed_; | |||
boost::recursive_mutex close_mutex_; | boost::recursive_mutex close_mutex_; | |||
bool expecting_read_; | bool expecting_read_; | |||
bool expecting_write_; | bool expecting_write_; | |||
bool is_server_; | bool is_server_; | |||
sockaddr_in server_address_; | sockaddr_in server_address_; | |||
int server_port_; | int server_port_; | |||
AcceptCallback accept_cb_; | AcceptCallback accept_cb_; | |||
std::string cached_remote_host_; | std::string cached_remote_host_; | |||
PollSet* poll_set_; | PollSet* poll_set_; | |||
int flags_; | int flags_; | |||
std::string connected_host_; | ||||
int connected_port_; | ||||
}; | }; | |||
} | } | |||
#endif // ROSCPP_TRANSPORT_TCP_H | #endif // ROSCPP_TRANSPORT_TCP_H | |||
End of changes. 5 change blocks. | ||||
5 lines changed or deleted | 10 lines changed or added | |||
transport_udp.h | transport_udp.h | |||
---|---|---|---|---|
skipping to change at line 42 | skipping to change at line 42 | |||
* POSSIBILITY OF SUCH DAMAGE. | * POSSIBILITY OF SUCH DAMAGE. | |||
*/ | */ | |||
#ifndef ROSCPP_TRANSPORT_UDP_H | #ifndef ROSCPP_TRANSPORT_UDP_H | |||
#define ROSCPP_TRANSPORT_UDP_H | #define ROSCPP_TRANSPORT_UDP_H | |||
#include <ros/types.h> | #include <ros/types.h> | |||
#include <ros/transport/transport.h> | #include <ros/transport/transport.h> | |||
#include <boost/thread/mutex.hpp> | #include <boost/thread/mutex.hpp> | |||
#include <boost/random.hpp> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | |||
namespace ros | namespace ros | |||
{ | { | |||
class TransportUDP; | class TransportUDP; | |||
typedef boost::shared_ptr<TransportUDP> TransportUDPPtr; | typedef boost::shared_ptr<TransportUDP> TransportUDPPtr; | |||
class PollSet; | class PollSet; | |||
skipping to change at line 106 | skipping to change at line 105 | |||
bool createIncoming(int port, bool is_server); | bool createIncoming(int port, bool is_server); | |||
/** | /** | |||
* \brief Create a connection to a server socket. | * \brief Create a connection to a server socket. | |||
*/ | */ | |||
TransportUDPPtr createOutgoing(std::string host, int port, int conn_id, i nt max_datagram_size); | TransportUDPPtr createOutgoing(std::string host, int port, int conn_id, i nt max_datagram_size); | |||
/** | /** | |||
* \brief Returns the port this transport is listening on | * \brief Returns the port this transport is listening on | |||
*/ | */ | |||
int getServerPort() const {return server_port_;} | int getServerPort() const {return server_port_;} | |||
/** | ||||
* \brief Get a unique connection ID | ||||
*/ | ||||
int generateConnectionId() {return gen_();} | ||||
// overrides from Transport | // overrides from Transport | |||
virtual int32_t read(uint8_t* buffer, uint32_t size); | virtual int32_t read(uint8_t* buffer, uint32_t size); | |||
virtual int32_t write(uint8_t* buffer, uint32_t size); | virtual int32_t write(uint8_t* buffer, uint32_t size); | |||
virtual void enableWrite(); | virtual void enableWrite(); | |||
virtual void disableWrite(); | virtual void disableWrite(); | |||
virtual void enableRead(); | ||||
virtual void disableRead(); | ||||
virtual void close(); | virtual void close(); | |||
virtual std::string getTransportInfo(); | virtual std::string getTransportInfo(); | |||
virtual bool requiresHeader() {return false;} | virtual bool requiresHeader() {return false;} | |||
virtual const char* getType() {return "UDPROS";} | virtual const char* getType() {return "UDPROS";} | |||
int getMaxDatagramSize() const {return max_datagram_size_;} | int getMaxDatagramSize() const {return max_datagram_size_;} | |||
skipping to change at line 141 | skipping to change at line 137 | |||
*/ | */ | |||
bool initializeSocket(); | bool initializeSocket(); | |||
/** | /** | |||
* \brief Set the socket to be used by this transport | * \brief Set the socket to be used by this transport | |||
* \param sock A valid UDP socket | * \param sock A valid UDP socket | |||
* \return Whether setting the socket was successful | * \return Whether setting the socket was successful | |||
*/ | */ | |||
bool setSocket(int sock); | bool setSocket(int sock); | |||
/** | ||||
* \brief Enables reading on our socket | ||||
*/ | ||||
void enableRead(); | ||||
void socketUpdate(int events); | void socketUpdate(int events); | |||
int sock_; | int sock_; | |||
bool closed_; | bool closed_; | |||
boost::mutex close_mutex_; | boost::mutex close_mutex_; | |||
bool expecting_read_; | bool expecting_read_; | |||
bool expecting_write_; | bool expecting_write_; | |||
bool is_server_; | bool is_server_; | |||
sockaddr_in server_address_; | sockaddr_in server_address_; | |||
int server_port_; | int server_port_; | |||
std::string cached_remote_host_; | std::string cached_remote_host_; | |||
PollSet* poll_set_; | PollSet* poll_set_; | |||
int flags_; | int flags_; | |||
boost::rand48 gen_; | ||||
uint32_t connection_id_; | uint32_t connection_id_; | |||
uint8_t current_message_id_; | uint8_t current_message_id_; | |||
uint16_t total_blocks_; | uint16_t total_blocks_; | |||
uint16_t last_block_; | uint16_t last_block_; | |||
uint32_t max_datagram_size_; | uint32_t max_datagram_size_; | |||
uint8_t *reorder_buffer_; | uint8_t* data_buffer_; | |||
uint8_t* data_start_; | ||||
uint32_t data_filled_; | ||||
uint8_t* reorder_buffer_; | ||||
uint8_t* reorder_start_; | ||||
TransportUDPHeader reorder_header_; | TransportUDPHeader reorder_header_; | |||
uint32_t reorder_bytes_; | uint32_t reorder_bytes_; | |||
}; | }; | |||
} | } | |||
#endif // ROSCPP_TRANSPORT_UDP_H | #endif // ROSCPP_TRANSPORT_UDP_H | |||
End of changes. 6 change blocks. | ||||
14 lines changed or deleted | 8 lines changed or added | |||
wall_timer.h | wall_timer.h | |||
---|---|---|---|---|
skipping to change at line 67 | skipping to change at line 67 | |||
* \brief Stop the timer. Once this call returns, no more callbacks will be called. Does | * \brief Stop the timer. Once this call returns, no more callbacks will be called. Does | |||
* nothing if the timer is already stopped. | * nothing if the timer is already stopped. | |||
*/ | */ | |||
void stop(); | void stop(); | |||
/** | /** | |||
* \brief Returns whether or not the timer has any pending events to call . | * \brief Returns whether or not the timer has any pending events to call . | |||
*/ | */ | |||
bool hasPending(); | bool hasPending(); | |||
/** | ||||
* \brief Set the period of this timer | ||||
*/ | ||||
void setPeriod(const WallDuration& period); | ||||
bool isValid() { return impl_ && impl_->isValid(); } | bool isValid() { return impl_ && impl_->isValid(); } | |||
operator void*() { return isValid() ? (void*)1 : (void*)0; } | operator void*() { return isValid() ? (void*)1 : (void*)0; } | |||
bool operator<(const WallTimer& rhs) | bool operator<(const WallTimer& rhs) | |||
{ | { | |||
return impl_ < rhs.impl_; | return impl_ < rhs.impl_; | |||
} | } | |||
bool operator==(const WallTimer& rhs) | bool operator==(const WallTimer& rhs) | |||
{ | { | |||
skipping to change at line 96 | skipping to change at line 101 | |||
WallTimer(const WallTimerOptions& ops); | WallTimer(const WallTimerOptions& ops); | |||
class Impl | class Impl | |||
{ | { | |||
public: | public: | |||
Impl(); | Impl(); | |||
~Impl(); | ~Impl(); | |||
bool isValid(); | bool isValid(); | |||
bool hasPending(); | bool hasPending(); | |||
void setPeriod(const WallDuration& period); | ||||
void start(); | void start(); | |||
void stop(); | void stop(); | |||
bool started_; | bool started_; | |||
int32_t timer_handle_; | int32_t timer_handle_; | |||
WallDuration period_; | WallDuration period_; | |||
WallTimerCallback callback_; | WallTimerCallback callback_; | |||
CallbackQueueInterface* callback_queue_; | CallbackQueueInterface* callback_queue_; | |||
VoidWPtr tracked_object_; | VoidConstWPtr tracked_object_; | |||
bool has_tracked_object_; | bool has_tracked_object_; | |||
double constructed_; | double constructed_; | |||
bool oneshot_; | bool oneshot_; | |||
}; | }; | |||
typedef boost::shared_ptr<Impl> ImplPtr; | typedef boost::shared_ptr<Impl> ImplPtr; | |||
typedef boost::weak_ptr<Impl> ImplWPtr; | typedef boost::weak_ptr<Impl> ImplWPtr; | |||
ImplPtr impl_; | ImplPtr impl_; | |||
friend class NodeHandle; | friend class NodeHandle; | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 7 lines changed or added | |||
wall_timer_options.h | wall_timer_options.h | |||
---|---|---|---|---|
skipping to change at line 72 | skipping to change at line 72 | |||
CallbackQueueInterface* callback_queue; ///< Qu eue to add callbacks to. If NULL, the global callback queue will be used | CallbackQueueInterface* callback_queue; ///< Qu eue to add callbacks to. If NULL, the global callback queue will be used | |||
/** | /** | |||
* A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | * A shared pointer to an object to track for these callbacks. If set, t he a weak_ptr will be created to this object, | |||
* and if the reference count goes to 0 the subscriber callbacks will not get called. | * and if the reference count goes to 0 the subscriber callbacks will not get called. | |||
* | * | |||
* \note Note that setting this will cause a new reference to be added to the object before the | * \note Note that setting this will cause a new reference to be added to the object before the | |||
* callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | * callback, and for it to go out of scope (and potentially be deleted) i n the code path (and therefore | |||
* thread) that the callback is invoked from. | * thread) that the callback is invoked from. | |||
*/ | */ | |||
VoidPtr tracked_object; | VoidConstPtr tracked_object; | |||
bool oneshot; | bool oneshot; | |||
}; | }; | |||
} | } | |||
#endif | #endif | |||
End of changes. 1 change blocks. | ||||
1 lines changed or deleted | 1 lines changed or added | |||