Program Listing for File bi_tdgraph.hpp
↰ Return to documentation for file (cosm/ta/ds/bi_tdgraph.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include <algorithm>
#include <list>
#include <string>
#include "cosm/ta/ds/bi_tab.hpp"
#include "cosm/ta/bi_tab_sel_probability.hpp"
#include "cosm/ta/config/task_alloc_config.hpp"
#include "cosm/ta/ds/tdgraph.hpp"
#include "rcppsw/math/rng.hpp"
/*******************************************************************************
* Namespaces/Decls
******************************************************************************/
namespace cosm::ta::ds {
/*******************************************************************************
* Class Definitions
******************************************************************************/
class bi_tdgraph final : public tdgraph, public rer::client<bi_tdgraph> {
public:
static inline const std::string kTABInitRoot = "root";
static inline const std::string kTABInitRandom = "random";
static inline const std::string kTABInitMaxDepth = "max_depth";
explicit bi_tdgraph(const config::task_alloc_config* config);
/* Necessary for use in std::variant */
bi_tdgraph(const bi_tdgraph&) = default;
bi_tdgraph& operator=(const bi_tdgraph&) = delete;
status_t install_tab(polled_task* parent,
tdgraph::vertex_vector children,
rmath::rng* rng);
status_t install_tab(const std::string& parent,
tdgraph::vertex_vector children,
rmath::rng* rng);
void active_tab_update(const polled_task* current_task,
rmath::rng* rng);
const bi_tab* active_tab(void) const { return m_active_tab; }
bi_tab* active_tab(void) { return m_active_tab; }
void active_tab(bi_tab* active_tab) { m_active_tab = active_tab; }
RCPPSW_PURE int active_tab_id(void) const {
auto it = std::find_if(m_tabs.begin(),
m_tabs.end(), [this](const auto& tab) {
return &tab == m_active_tab;
});
if (m_tabs.end() != it) {
return std::distance(m_tabs.begin(), it);
} else {
return -1;
}
}
const bi_tab* tab_parent(const bi_tab* tab) const;
const bi_tab* root_tab(void) const;
bi_tab* root_tab(void);
bi_tab* tab_child(const bi_tab* tab,
const polled_task* current_task) RCPPSW_PURE;
void active_tab_init(const std::string& method,
rmath::rng* rng);
private:
using tdgraph::set_children;
void active_tab_init_root(void);
void active_tab_init_random(rmath::rng* rng);
void active_tab_init_max_depth(rmath::rng* rng);
bi_tab* tab_parent(const bi_tab* tab);
bool tab_parent_verify(const bi_tab* tab) const RCPPSW_PURE;
/* clang-format off */
const config::task_alloc_config mc_config;
std::list<bi_tab> m_tabs{};
bi_tab * m_active_tab{nullptr};
bi_tab_sel_probability m_tab_sw_prob;
/* clang-format on */
};
} /* namespace cosm::ta::ds */