time_processor.cpp
Go to the documentation of this file.
1 
26 
27 #include <boost/assign/list_of.hpp>
28 #include <string>
29 
30 namespace message_relay
31 {
32 
33 const boost::unordered_map<std::string, TimeProcessor::Operation> TimeProcessor::operation_name_map_ =
34  boost::assign::map_list_of("", TimeProcessor::NONE)("add_offset", TimeProcessor::ADD_OFFSET)
35  ("remove_offset", TimeProcessor::REMOVE_OFFSET);
36 
37 const boost::unordered_map<TimeProcessor::Operation, TimeProcessor::Operation> TimeProcessor::operation_inverse_map_ =
38  boost::assign::map_list_of(TimeProcessor::NONE, TimeProcessor::NONE)
41 
42 TimeProcessor::ConstPtr TimeProcessor::create(std::string offset_operation_string, ros::Duration offset)
43 {
44  try
45  {
46  TimeProcessor::Operation offset_operation = operation_name_map_.at(offset_operation_string);
47  return TimeProcessor::create(offset_operation, offset);
48  }
49  catch (const std::out_of_range &ex)
50  {
51  ROS_FATAL_STREAM("Invalid time offset operation " << offset_operation_string << " specified");
52  throw ex;
53  }
54 }
55 
57 {
58  return TimeProcessor::ConstPtr(new const TimeProcessor(offset_operation, offset));
59 }
60 
62 {
63  if (processor)
64  {
66  processor->offset_operation_), processor->offset_));
67  }
68  else
69  {
70  return TimeProcessor::ConstPtr();
71  }
72 }
73 
75  : offset_operation_(offset_operation), offset_(offset)
76 { }
77 
79 {
80  switch (offset_operation_)
81  {
83  break;
84 
86  time += offset_;
87  break;
88 
90  time -= offset_;
91  break;
92 
93  default:
94  ROS_ASSERT_MSG(false, "Invalid time offset operation");
95  }
96 }
97 
98 } // namespace message_relay
boost::shared_ptr< const TimeProcessor > ConstPtr
static const boost::unordered_map< Operation, Operation > operation_inverse_map_
void process(ros::Time &time) const
static ConstPtr inverse(const ConstPtr &processor)
#define ROS_FATAL_STREAM(args)
static ConstPtr create(std::string offset_operation_string, ros::Duration offset=ros::Duration(0.0))
#define ROS_ASSERT_MSG(cond,...)
static const boost::unordered_map< std::string, Operation > operation_name_map_
TimeProcessor(Operation offset_operation, ros::Duration offset)


message_relay
Author(s):
autogenerated on Wed Jul 17 2019 03:27:53