Program Listing for File msg_tracking_map.hpp

Return to documentation for file (cosm/ros/metrics/msg_tracking_map.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include <map>
#include <vector>
#include <string>

#include "rcppsw/patterns/decorator/decorator.hpp"
#include "rcppsw/er/client.hpp"
#include "rcppsw/types/timestep.hpp"

#include "cosm/cosm.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace cosm::ros::metrics {

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
struct msg_tracking_map_value {
  std::vector<int> missing{};
  size_t n_received{};
  int expected_seq{0};
  size_t interval_index{0};

  bool flushed_collector{false};
  rtypes::timestep flush_ts{rtypes::constants::kNoTime};
};

class msg_tracking_map
    : public rer::client<msg_tracking_map>,
      private rpdecorator::decorator<std::map<std::string,
                                              msg_tracking_map_value>
                                     > {
 public:
  msg_tracking_map(void)
      : ER_CLIENT_INIT("cosm.ros.metrics.msg_tracking_map") {}

  RCPPSW_DECORATE_DECLDEF(operator[]);

  void update_on_receive(const std::string& key, int recived_seq);
  void init(const std::string& key);
  void reset(const std::string& key);
};

} /* namespace cosm::ros::metrics */