Program Listing for File TestAlgorithm.hpp¶
↰ Return to documentation for file (src/mimir/algorithm/TestAlgorithm.hpp
)
#pragma once
#include <atomic>
#include <chrono>
#include <cinttypes>
#include <memory>
#include <boost/statechart/detail/memory.hpp>
#include <boost/statechart/fifo_scheduler.hpp>
#include <boost/statechart/event_base.hpp>
#include <yaml-cpp/yaml.h>
#ifdef _MSC_VER
#pragma warning(push, 0)
#endif
#include <dds/pub/Publisher.hpp>
#include <dds/sub/Subscriber.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include <mimir/IAlgorithm.hpp>
namespace mimir
{
namespace algorithm
{
class TestAlgorithm : public IAlgorithm
{
public:
explicit TestAlgorithm(
const YAML::Node& config,
boost::statechart::fifo_scheduler<>& scheduler,
boost::statechart::fifo_scheduler<>::processor_handle machine,
dds::pub::Publisher publisher,
dds::sub::Subscriber subscriber);
virtual ~TestAlgorithm();
virtual void solve(const std::atomic<bool>& cancel_token);
virtual void initialize(const std::atomic<bool>& cancel_token);
virtual void timer(const std::atomic<bool>& cancel_token);
virtual inline const char* name(){ return "TestAlgorithm"; }
void event(boost::statechart::event_base * const event);
private:
inline void step_time() { m_next_step += m_time_step; }
TestAlgorithm() = delete;
class Impl;
std::unique_ptr<Impl> m_impl;
boost::statechart::fifo_scheduler<> & m_scheduler;
boost::statechart::fifo_scheduler<>::processor_handle m_stateMachine;
const std::chrono::milliseconds m_time_step;
std::chrono::steady_clock::time_point m_next_step;
const YAML::Node m_config;
};
}
}