1#ifndef PER_TASK_INFORMATION_H
2#define PER_TASK_INFORMATION_H
4#include "downward/task_proxy.h"
6#include "downward/algorithms/subscriber.h"
8#include "downward/utils/hash.h"
24class PerTaskInformation :
public subscriber::Subscriber<PlanningTask> {
33 using EntryConstructor =
34 std::function<std::unique_ptr<Entry>(
const PlanningTaskProxy&)>;
35 EntryConstructor entry_constructor;
36 utils::HashMap<TaskID, std::unique_ptr<Entry>> entries;
45 : entry_constructor([](const PlanningTaskProxy& task_proxy) {
46 return std::make_unique<Entry>(task_proxy);
51 explicit PerTaskInformation(EntryConstructor entry_constructor)
52 : entry_constructor(entry_constructor)
56 Entry& operator[](
const PlanningTaskProxy& task_proxy)
58 TaskID
id = task_proxy.get_id();
59 const auto& it = entries.find(
id);
60 if (it == entries.end()) {
61 entries[id] = entry_constructor(task_proxy);
62 task_proxy.subscribe_to_task_destruction(
this);
67 virtual void notify_service_destroyed(
const PlanningTask* task)
override
69 TaskID
id = PlanningTaskProxy(*task).get_id();