Program Listing for File analyzer_group.hpp
↰ Return to documentation for file (/tmp/ws/src/diagnostics/diagnostic_aggregator/include/diagnostic_aggregator/analyzer_group.hpp
)
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2009, Willow Garage, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
#ifndef DIAGNOSTIC_AGGREGATOR__ANALYZER_GROUP_HPP_
#define DIAGNOSTIC_AGGREGATOR__ANALYZER_GROUP_HPP_
#include <algorithm>
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "diagnostic_aggregator/analyzer.hpp"
#include "diagnostic_aggregator/status_item.hpp"
#include "diagnostic_aggregator/visibility_control.hpp"
#include "diagnostic_msgs/msg/diagnostic_status.hpp"
#include "diagnostic_msgs/msg/key_value.hpp"
#include "pluginlib/class_list_macros.hpp"
#include "pluginlib/class_loader.hpp"
#include "rclcpp/rclcpp.hpp"
namespace diagnostic_aggregator
{
class AnalyzerGroup : public Analyzer
{
public:
DIAGNOSTIC_AGGREGATOR_PUBLIC
AnalyzerGroup();
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual ~AnalyzerGroup();
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual bool init(
const std::string & base_path, const std::string & breadcrumb,
const rclcpp::Node::SharedPtr node);
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual bool addAnalyzer(std::shared_ptr<Analyzer> & analyzer);
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual bool removeAnalyzer(std::shared_ptr<Analyzer> & analyzer);
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual bool match(const std::string & name);
DIAGNOSTIC_AGGREGATOR_PUBLIC
void resetMatches();
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual bool analyze(const std::shared_ptr<StatusItem> item);
DIAGNOSTIC_AGGREGATOR_PUBLIC
virtual std::vector<std::shared_ptr<diagnostic_msgs::msg::DiagnosticStatus>> report();
virtual std::string getPath() const {return path_;}
virtual std::string getName() const {return nice_name_;}
private:
std::string path_;
std::string nice_name_;
std::string breadcrumb_;
pluginlib::ClassLoader<Analyzer> analyzer_loader_;
rclcpp::Logger logger_;
std::vector<std::shared_ptr<StatusItem>> aux_items_;
std::vector<std::shared_ptr<Analyzer>> analyzers_;
/*
*\brief The map of names to matchings is stored internally.
*/
std::map<const std::string, std::vector<bool>> matched_;
};
} // namespace diagnostic_aggregator
#endif // DIAGNOSTIC_AGGREGATOR__ANALYZER_GROUP_HPP_