Program Listing for File block_carrying_controller.hpp

Return to documentation for file (cosm/controller/block_carrying_controller.hpp)

#pragma once

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

#include "cosm/cosm.hpp"
#include "cosm/controller/block_detect_context.hpp"
#include "cosm/spatial/strategy/blocks/metrics/drop_metrics.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace cosm::repr {
class base_block3D;
} /* namespace cosm::repr */

namespace cosm::controller {

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class block_carrying_controller : public cssblocks::metrics::drop_metrics {
 public:
  block_carrying_controller(void) = default;
  virtual ~block_carrying_controller(void);

  /* Not copy constructable/assignable by default */
  block_carrying_controller(const block_carrying_controller&) = delete;
  const block_carrying_controller&
  operator=(const block_carrying_controller&) = delete;

  bool is_carrying_block(void) const { return nullptr != m_block; }

  void block(std::unique_ptr<crepr::base_block3D> block);

  std::unique_ptr<crepr::base_block3D> block_release(void);

  void reset(void) RCPPSW_COLD;

  const crepr::base_block3D* block(void) const { return m_block.get(); }
  crepr::base_block3D* block(void) { return m_block.get(); }

  virtual bool block_detect(const block_detect_context& context) = 0;

 private:
  /* clang-format off */
  std::unique_ptr<crepr::base_block3D>  m_block{nullptr};
  /* clang-format on */
};

} /* namespace cosm::controller */