Program Listing for File conflict_checker.hpp

Return to documentation for file (cosm/spatial/common/conflict_checker.hpp)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include <boost/optional.hpp>
#include <functional>

#include "rcppsw/math/vector2.hpp"

#include "cosm/cosm.hpp"

/*******************************************************************************
 * Namespaces/Decls
 ******************************************************************************/
namespace cosm::arena {
class base_arena_map;
class caching_arena_map;
} /* namespace cosm::arena */

namespace cosm::repr {
class sim_block3D;
class entity2D;
class entity3D;
} /* namespace cosm::repr */

namespace cosm::spatial {

/*******************************************************************************
 * Class Definitions
 ******************************************************************************/
class conflict_checker {
 public:
  struct status {
    bool x{ false };
    bool y{ false };

    status& operator|=(const status& other) {
      x |= other.x;
      y |= other.y;
      return *this;
    }
  };
  using map_cb_type = std::function<status(const crepr::sim_block3D* const block,
                                           const rmath::vector2d& loc)>;

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

  static status placement2D(const carena::base_arena_map* map,
                            const crepr::sim_block3D* block,
                            const rmath::vector2d& loc);

  static status placement2D(const carena::caching_arena_map* map,
                            const crepr::sim_block3D* block,
                            const rmath::vector2d& loc);

  static status placement2D(const rmath::vector2d& ent1_anchor,
                            const rmath::vector2d& ent1_dims,
                            const crepr::entity2D* ent2);

  static status placement2D(const rmath::vector2d& ent1_anchor,
                            const rmath::vector2d& ent1_dims,
                            const crepr::entity3D* entity);
};

} /* namespace cosm::spatial */