Program Listing for File entities_oracle.hpp
↰ Return to documentation for file (cosm/oracle/entities_oracle.hpp
)
#pragma once
/*******************************************************************************
* Includes
******************************************************************************/
#include <numeric>
#include <string>
#include <vector>
#include "cosm/cosm.hpp"
/*******************************************************************************
* Namespaces
******************************************************************************/
namespace cosm::oracle {
/*******************************************************************************
* Class Definitions
******************************************************************************/
template <class TEntity>
class entities_oracle {
public:
using knowledge_type = std::vector<TEntity*>;
static std::string knowledge_to_string(const std::string& prefix,
const knowledge_type& v) {
auto lambda = [&](const std::string& a, const auto& ent) {
return a + prefix + rcppsw::to_string(ent->id()) + ",";
};
return std::accumulate(v.begin(), v.end(), std::string(), lambda);
}
const knowledge_type& ask(void) const { return m_knowledge; }
void set_knowledge(const knowledge_type& k) { m_knowledge = k; }
private:
/* clang-format off */
knowledge_type m_knowledge{};
/* clang-format on */
};
} /* namespace cosm::oracle */