Program Listing for File Bundle.hpp
↰ Return to documentation for file (include/rmf_task_sequence/events/Bundle.hpp
)
/*
* Copyright (C) 2021 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef RMF_TASK_SEQUENCE__EVENTS__BUNDLE_HPP
#define RMF_TASK_SEQUENCE__EVENTS__BUNDLE_HPP
#include <rmf_task_sequence/Event.hpp>
#include <rmf_task/events/SimpleEventState.hpp>
#include <vector>
#include <optional>
namespace rmf_task_sequence {
namespace events {
//==============================================================================
class Bundle : public Event
{
public:
enum Type
{
Sequence,
// (Not implemented yet)
// ParallelAll,
// (Not implemented yet)
// ParallelAny
};
class Description;
static void add(const Event::InitializerPtr& initializer);
static void add(
Event::Initializer& add_to,
const Event::ConstInitializerPtr& initialize_from);
template<typename OtherDesc>
using UnfoldDescription =
std::function<Bundle::Description(const OtherDesc&)>;
template<typename OtherDesc>
static void unfold(
const UnfoldDescription<OtherDesc>& unfold_description,
Event::Initializer& add_to,
const Event::ConstInitializerPtr& initialize_from);
using UpdateFn = std::function<void()>;
using DependencySpecifiers = std::vector<std::function<StandbyPtr(UpdateFn)>>;
static StandbyPtr standby(
Type type,
const DependencySpecifiers& dependencies,
rmf_task::events::SimpleEventStatePtr state,
std::function<void()> update);
static Event::StandbyPtr initiate(
const Event::Initializer& initializer,
const Event::AssignIDPtr& id,
const std::function<rmf_task::State()>& get_state,
const ConstParametersPtr& parameters,
const Bundle::Description& description,
std::function<void()> update);
static Event::ActivePtr restore(
const Event::Initializer& initializer,
const Event::AssignIDPtr& id,
const std::function<rmf_task::State()>& get_state,
const ConstParametersPtr& parameters,
const Bundle::Description& description,
const std::string& backup,
std::function<void()> update,
std::function<void()> checkpoint,
std::function<void()> finished);
};
//==============================================================================
class Bundle::Description : public Event::Description
{
public:
using Dependencies = std::vector<Event::ConstDescriptionPtr>;
Description(
Dependencies dependencies,
Type type,
std::optional<std::string> category = std::nullopt,
std::optional<std::string> detail = std::nullopt);
const Dependencies& dependencies() const;
Description& dependencies(Dependencies new_elements);
Type type() const;
Description& type(Type new_type);
const std::optional<std::string>& category() const;
Description& category(std::optional<std::string> new_category);
const std::optional<std::string>& detail() const;
Description& detail(std::optional<std::string> new_detail);
// Documentation inherited
Activity::ConstModelPtr make_model(
rmf_task::State invariant_initial_state,
const Parameters& parameters) const final;
// Documentation inherited
Header generate_header(
const rmf_task::State& initial_state,
const Parameters& parameters) const final;
class Implementation;
private:
rmf_utils::impl_ptr<Implementation> _pimpl;
};
} // namespace events
} // namespace rmf_task_sequence
#include <rmf_task_sequence/events/detail/impl_Bundle.hpp>
#endif // RMF_TASK_SEQUENCE__EVENTS__BUNDLE_HPP