bool Recorder::ShouldSubscribeToTopic()

in rosbag_cloud_recorders/src/utils/recorder.cpp [227:255]


bool Recorder::ShouldSubscribeToTopic(std::string const& topic, bool from_node) {
    // ignore already known topics
    if (IsSubscribed(topic)) {
        return false;
    }

    // subtract exclusion regex, if any
    if(options_.do_exclude && boost::regex_match(topic, options_.exclude_regex)) {
        return false;
    }

    if(options_.record_all || from_node) {
        return true;
    }
    
    if (options_.regex) {
        // Treat the topics as regular expressions
  return std::any_of(
            std::begin(options_.topics), std::end(options_.topics),
            [&topic] (string const& regex_str){
                boost::regex e(regex_str);
                boost::smatch what;
                return boost::regex_match(topic, what, e, boost::match_extra);
            });
    }

    return std::find(std::begin(options_.topics), std::end(options_.topics), topic)
      != std::end(options_.topics);
}