bool RosoutTextFilter::doFilter(const rosgraph_msgs::LogConstPtr& msg) const
{
  if (text_.empty())
  {
    return true;
  }

  bool match = false;

  if (field_mask_ & Message)
  {
    match = match || filterString(msg->msg);
  }

  if (field_mask_ & Node)
  {
    match = match || filterString(msg->name);
  }

  if (field_mask_ & Location)
  {
    if (!match)
    {
      std::stringstream ss;
      ss << msg->file << ":" << msg->function << ":" << msg->line;
      match = match || filterString(ss.str());
    }
  }

  if (field_mask_ & Topics)
  {
    match = match || filterVector(msg->topics);
  }

  return type_ == Include ? match : !match;
}
Пример #2
0
void filterVector(std::vector<T>& v, const std::vector<bool>& valid)
{
    std::vector<T> out;
    filterVector(v, valid, out);
    v = out;
};