13#ifndef RTCTK_EXAMPLECUSTOM_CUSTOMLIFECYCLE_HPP
14#define RTCTK_EXAMPLECUSTOM_CUSTOMLIFECYCLE_HPP
24namespace cfw = componentFramework;
26template <
typename Super>
28 static_assert(std::is_base_of_v<cfw::RtcComponent, Super>,
29 "'CustomLifeCycle' requires 'RtcComponent'");
41 using Super::InputStage::InputStage;
44 Super::InputStage::Start();
62 this->m_engine.PostEvent(std::make_unique<events::CustomDone>());
66 this->m_engine.PostEvent(std::make_unique<events::CustomError>(std::move(eptr)));
83 "ActionFooFailed", [
this](
auto const& ev) {
84 auto const& eptr = ev.GetPayload();
103 "ActionBarFailed", [
this](
auto const& ev) {
104 auto const& eptr = ev.GetPayload();
116 static_cast<BizLogicIf&
>(this->m_logic).ActivityFoo(stop_token);
126 static_cast<BizLogicIf&
>(this->m_logic).ActivityBar(stop_token, arg);
145 this->mm.ModStateType(
"On::Operational",
Parallel);
147 this->mm.AddState(
Composite,
"On::Operational:Custom",
"On::Operational");
148 this->mm.AddState(
Initial,
"On::Operational:Custom:Initial",
"On::Operational:Custom");
149 this->mm.AddState(
Simple,
"On::Operational:Custom:Idle",
"On::Operational:Custom");
150 this->mm.AddState(
Simple,
"On::Operational:Custom:Foo",
"On::Operational:Custom",
"ActivityFoo" ,
"ActionFooEntry");
151 this->mm.AddState(
Simple,
"On::Operational:Custom:Bar",
"On::Operational:Custom",
"ActivityBar" ,
"ActionBarEntry");
153 this->mm.AddTrans(
"On::Operational:Custom:Initial" ,
"On::Operational:Custom:Idle");
154 this->mm.AddTrans(
"On::Operational:Custom:Idle" ,
"On::Operational:Custom:Foo" ,
"events.Foo" ,
"");
155 this->mm.AddTrans(
"On::Operational:Custom:Foo" ,
"On::Operational:Custom:Idle" ,
"events.CustomDone" ,
"" ,
"ActionFooDone" );
156 this->mm.AddTrans(
"On::Operational:Custom:Foo" ,
"On::Operational:Custom:Idle" ,
"events.CustomError" ,
"" ,
"ActionFooFailed" );
157 this->mm.AddTrans(
"On::Operational:Custom:Idle" ,
"On::Operational:Custom:Bar" ,
"events.Bar" ,
"");
158 this->mm.AddTrans(
"On::Operational:Custom:Bar" ,
"On::Operational:Custom:Idle" ,
"events.CustomDone" ,
"" ,
"ActionBarDone" );
159 this->mm.AddTrans(
"On::Operational:Custom:Bar" ,
"On::Operational:Custom:Idle" ,
"events.CustomError" ,
"" ,
"ActionBarFailed" );
Adapter object intended to be used in contexts without direct access to the output-stream object.
Definition: exceptions.hpp:185
std::string Str() const
Convenience function for constructing a std::string from the exception.
Definition: exceptions.hpp:203
Thrown if the command was accepted but the task to run failed.
Definition: rtcComponent.hpp:53
Thrown if a command is not allowed in current state or guard.
Definition: rtcComponent.hpp:40
Definition: stateMachineEngine.hpp:35
void RegisterRejectHandler(std::string const &id, RejectMethod reject)
Register reject handler.
Definition: stateMachineEngine.cpp:131
void RegisterActivity(std::string const &id, ActivityMethod activity, SuccessMethod on_success, FailureMethod on_failure)
Register activity.
Definition: stateMachineEngine.cpp:123
void RegisterActionStatic(std::string const &id, std::function< void(Event const &)> action)
Register action for statically known event type.
Definition: stateMachineEngine.hpp:93
static void Register(cfw::CommandReplier &replier, cfw::StateMachineEngine &engine)
Definition: customCmdsImpl.hpp:32
Definition: customLifeCycle.hpp:31
virtual void ActivityBar(cfw::StopToken st, cfw::JsonPayload const &args)
Definition: customLifeCycle.hpp:35
virtual void ActivityFoo(cfw::StopToken st)
Definition: customLifeCycle.hpp:33
Definition: customLifeCycle.hpp:139
ModelBuilder(cfw::StateMachineEngine &engine)
Definition: customLifeCycle.hpp:141
Definition: customLifeCycle.hpp:50
std::optional< rad::cii::Request< std::string, std::string > > m_tmp_bar_request
Definition: customLifeCycle.hpp:134
OutputStage(cfw::StateMachineEngine &engine, BizLogicIf &bl)
Definition: customLifeCycle.hpp:52
std::function< void()> m_custom_success_handler
Definition: customLifeCycle.hpp:135
std::optional< rad::cii::Request< std::string > > m_tmp_foo_request
Definition: customLifeCycle.hpp:133
std::function< void(std::exception_ptr)> m_custom_error_handler
Definition: customLifeCycle.hpp:136
Implementation of custom MAL commands.
Provides macros and utilities for exception handling.
Defines the JSON payload type JsonPayload.
Definition: commandReplier.cpp:22
const std::string STD_OK_REPLY
Definition: stdComponent.hpp:86
nlohmann::json JsonPayload
Type requirements:
Definition: jsonPayload.hpp:25
rad::StopToken StopToken
Definition: stopToken.hpp:20
@ Simple
Definition: model.hpp:22
@ Composite
Definition: model.hpp:22
@ Parallel
Definition: model.hpp:22
@ Initial
Definition: model.hpp:22
Definition: businessLogic.cpp:23
Lifecycle of a basic 'RtcComponent'.
Definition: customLifeCycle.hpp:27