Program Listing for File base_collector.hpp

Return to documentation for file (rcppsw/metrics/base_collector.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include <memory>
#include <list>

#include "rcppsw/er/client.hpp"
#include "rcppsw/types/timestep.hpp"
#include "rcppsw/metrics/write_status.hpp"
#include "rcppsw/metrics/base_data.hpp"
#include "rcppsw/metrics/base_sink.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace rcppsw::metrics {
class base_metrics;

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class base_collector : public er::client<base_collector> {
 public:
  explicit base_collector(std::unique_ptr<base_sink> sink);

  virtual ~base_collector(void) = default;

  virtual void collect(const rcppsw::metrics::base_metrics& metrics) = 0;

  void initialize(void);

  void finalize(void);

  write_status flush(const rtypes::timestep& t);

  void interval_reset(const rtypes::timestep& t);

  virtual const rmetrics::base_data* data(void) const = 0;

 protected:
  virtual void reset_after_interval(void) {}

 private:
  /* clang-format off */
  std::unique_ptr<base_sink> m_sink;
  /* clang-format on */

 public:
  RCPPSW_WRAP_DECLDEF(output_mode, *m_sink, const);
  RCPPSW_WRAP_DECLDEF(ready_to_flush, *m_sink, const);
};

} /* namespace rcppsw::metrics */