Go to the documentation of this file.
12 #ifndef RTCTK_EXAMPLECUSTOM_CUSTOMLIFECYCLE_HPP
13 #define RTCTK_EXAMPLECUSTOM_CUSTOMLIFECYCLE_HPP
23 namespace cfw = componentFramework;
25 template <
typename Super>
27 static_assert(std::is_base_of_v<cfw::RtcComponent, Super>,
28 "'CustomLifeCycle' requires 'RtcComponent'");
40 using Super::InputStage::InputStage;
43 Super::InputStage::Start();
61 this->m_engine.PostEvent(std::make_unique<events::CustomDone>());
65 this->m_engine.PostEvent(std::make_unique<events::CustomError>(eptr));
71 [
this](
auto const& ev) {
84 [
this](
auto const& ev) {
85 auto const& eptr = ev.GetPayload();
88 RequestFailed(NestedExceptionPrinter(eptr).Str()));
93 [
this](
auto const& ev) {
106 [
this](
auto const& ev) {
107 auto const& eptr = ev.GetPayload();
110 RequestFailed(NestedExceptionPrinter(eptr).Str()));
118 static_cast<BizLogicIf&
>(this->m_logic).ActivityFoo(stop_token);
125 static_cast<BizLogicIf&
>(this->m_logic).ActivityBar(stop_token, arg);
141 this->RegisterLayer({
"CustomLifeCycle", {}});
143 this->mm.AddState(
Composite,
"On.Operational.RegionCustom",
"On.Operational");
144 this->mm.AddState(
Initial,
"On.Operational.CustomInitial",
"On.Operational.RegionCustom");
145 this->mm.AddState(
Simple,
"On.Operational.CustomIdle",
"On.Operational.RegionCustom");
146 this->mm.AddState(
Simple,
"On.Operational.CustomFoo",
"On.Operational.RegionCustom",
"ActivityFoo" ,
"ActionFooEntry");
147 this->mm.AddState(
Simple,
"On.Operational.CustomBar",
"On.Operational.RegionCustom",
"ActivityBar" ,
"ActionBarEntry");
149 this->mm.AddTrans(
"On.Operational.CustomInitial" ,
"On.Operational.CustomIdle");
150 this->mm.AddTrans(
"On.Operational.CustomIdle" ,
"On.Operational.CustomFoo" ,
"events.Foo" ,
"");
151 this->mm.AddTrans(
"On.Operational.CustomFoo" ,
"On.Operational.CustomIdle" ,
"events.CustomDone" ,
"" ,
"ActionFooDone" );
152 this->mm.AddTrans(
"On.Operational.CustomFoo" ,
"On.Operational.CustomIdle" ,
"events.CustomError" ,
"" ,
"ActionFooFailed" );
153 this->mm.AddTrans(
"On.Operational.CustomIdle" ,
"On.Operational.CustomBar" ,
"events.Bar" ,
"");
154 this->mm.AddTrans(
"On.Operational.CustomBar" ,
"On.Operational.CustomIdle" ,
"events.CustomDone" ,
"" ,
"ActionBarDone" );
155 this->mm.AddTrans(
"On.Operational.CustomBar" ,
"On.Operational.CustomIdle" ,
"events.CustomError" ,
"" ,
"ActionBarFailed" );
@ Simple
Definition: model.hpp:23
Provides macros and utilities for exception handling.
static void Register(cfw::CommandReplier &replier, cfw::StateMachineEngine &engine)
Definition: customCmdsImpl.hpp:31
Definition: customLifeCycle.hpp:26
std::optional< rad::cii::Request< std::string > > m_tmp_foo_request
Definition: customLifeCycle.hpp:130
Definition: customLifeCycle.hpp:136
virtual void ActivityFoo(cfw::StopToken st)
Definition: customLifeCycle.hpp:32
Runnable< RtcComponent > Super
Definition: rtcSupervisor.hpp:31
const std::string STD_OK_REPLY
Definition: stdComponent.hpp:36
rad::StopToken StopToken
Definition: stopToken.hpp:19
void RegisterActionStatic(std::string const &id, std::function< void(Event const &)> action)
Register action for statically known event type.
Definition: stateMachineEngine.hpp:79
Definition: stateMachineEngine.hpp:31
virtual void ActivityBar(cfw::StopToken st, cfw::JsonPayload const &args)
Definition: customLifeCycle.hpp:34
Definition: customLifeCycle.hpp:49
Definition: customLifeCycle.hpp:30
Defines the JSON payload type JsonPayload.
void RegisterRejectHandler(std::string const &id, RejectMethod reject)
Register reject handler.
Definition: stateMachineEngine.cpp:95
Definition: businessLogic.cpp:22
@ Initial
Definition: model.hpp:26
std::function< void(std::exception_ptr)> m_custom_error_handler
Definition: customLifeCycle.hpp:133
ModelBuilder(cfw::StateMachineEngine &engine)
Definition: customLifeCycle.hpp:138
Lifecycle of a basic 'RtcComponent'.
Implementation of custom MAL commands.
std::optional< rad::cii::Request< std::string, std::string > > m_tmp_bar_request
Definition: customLifeCycle.hpp:131
@ Composite
Definition: model.hpp:25
OutputStage(cfw::StateMachineEngine &engine, BizLogicIf &bl)
Definition: customLifeCycle.hpp:51
void RegisterActivity(std::string const &id, ActivityMethod activity, SuccessMethod on_success, FailureMethod on_failure)
Register activity.
Definition: stateMachineEngine.cpp:87
nlohmann::json JsonPayload
Type requirements:
Definition: jsonPayload.hpp:24
std::function< void()> m_custom_success_handler
Definition: customLifeCycle.hpp:132