Fawkes API Fawkes Development Version
sleep_action_executor.h
1/***************************************************************************
2 * sleep_action_executor.h - A simple sleep action
3 *
4 * Created: Tue 12 Nov 2019 14:09:55 CET 14:09
5 * Copyright 2019 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#pragma once
22
23#include "action_executor.h"
24
25#include <condition_variable>
26#include <future>
27#include <list>
28#include <mutex>
29
30namespace fawkes {
31
32namespace gpp {
33
35{
36public:
38 virtual ~SleepActionExecutor();
39 void start(std::shared_ptr<gologpp::Activity> activity) override;
40 void stop(std::shared_ptr<gologpp::Grounding<gologpp::Action>> activity) override;
41 bool can_execute_activity(std::shared_ptr<gologpp::Activity> activity) const override;
42
43private:
44 std::list<std::future<void>> running_sleeps_;
45 std::mutex cancel_mutex_;
46 std::condition_variable wait_cond_;
47};
48
49} // namespace gpp
50} // namespace fawkes
Interface for logging.
Definition: logger.h:42
Abstract class to execute a Golog++ activity.
A Golog++ action executor that just sleeps for a certain amount of time.
void start(std::shared_ptr< gologpp::Activity > activity) override
Start the given activity.
void stop(std::shared_ptr< gologpp::Grounding< gologpp::Action > > activity) override
Stop the given activity.
bool can_execute_activity(std::shared_ptr< gologpp::Activity > activity) const override
Determine if this executor can execute the given activity.
SleepActionExecutor(Logger *logger)
Constructor.
Fawkes library namespace.