From 6650af0d25be56833d8e98a7acf6df8b8bb93b48 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Wed, 29 Nov 2023 20:18:43 +0100 Subject: [PATCH] Adapt generator to latest statemachine changes --- Statemachine Test/src-gen/IoArHandler.cxx | 19 +- .../src-gen/IoArHandlerMainDeclaration.hxx | 45 ++- .../src-gen/IoArHandlerMainHandlers.hxx | 229 ------------- .../src-gen/IoArHandlerMainInstance.hxx | 305 ++++++++++++++++-- .../src-gen/IoArHandlerMainPrototypes.hxx | 45 --- .../site.xml | 2 +- .../build.properties | 2 +- .../gen/cpp/main/StatemachineDeclarations.mtl | 22 +- .../uml/gen/cpp/main/StatemachineHandlers.mtl | 86 ----- .../uml/gen/cpp/main/StatemachineInstance.mtl | 81 ++++- .../gen/cpp/main/StatemachinePrototypes.mtl | 31 -- .../uml/gen/cpp/main/StatemachineQueries.mtl | 4 + .../uml/gen/cpp/main/generate.mtl | 4 - 13 files changed, 431 insertions(+), 444 deletions(-) delete mode 100644 Statemachine Test/src-gen/IoArHandlerMainHandlers.hxx delete mode 100644 Statemachine Test/src-gen/IoArHandlerMainPrototypes.hxx delete mode 100644 net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineHandlers.mtl delete mode 100644 net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachinePrototypes.mtl diff --git a/Statemachine Test/src-gen/IoArHandler.cxx b/Statemachine Test/src-gen/IoArHandler.cxx index fd2e186..9bcf389 100644 --- a/Statemachine Test/src-gen/IoArHandler.cxx +++ b/Statemachine Test/src-gen/IoArHandler.cxx @@ -1,6 +1,7 @@ -#include #include +#include + enum class EEvent { S_PNS_ArOpend_ind, @@ -63,8 +64,6 @@ class IoArHandler } private: -#include "IoArHandlerMainPrototypes.hxx" - bool ready_ = false; bool CheckApplicationReady(IoArHandlerMain::Event) { @@ -112,15 +111,15 @@ class IoArHandler { std::cout << __FUNCTION__ << std::endl; } - void StartWaitApplicationReadyTimer(IoArHandlerMain::StateRef) + void StartWaitApplicationReadyTimer() { std::cout << __FUNCTION__ << std::endl; } - void StopWaitApplicationReadyTimer(IoArHandlerMain::StateRef) + void StopWaitApplicationReadyTimer() { std::cout << __FUNCTION__ << std::endl; } - void SendApplicationReady(IoArHandlerMain::StateRef) + void SendApplicationReady() { std::cout << __FUNCTION__ << std::endl; } @@ -136,11 +135,11 @@ class IoArHandler { std::cout << __FUNCTION__ << std::endl; } - void StartDynReconfTimer(IoArHandlerMain::StateRef) + void StartDynReconfTimer() { std::cout << __FUNCTION__ << std::endl; } - void StopDynReconfTimer(IoArHandlerMain::StateRef) + void StopDynReconfTimer() { std::cout << __FUNCTION__ << std::endl; } @@ -158,12 +157,10 @@ class IoArHandler } }; -#include "IoArHandlerMainInstance.hxx" - #define IoArHandlerMain_GET_INSTANCE_EVENT_ID(e) e #define IoArHandlerMain_GET_STATIC_EVENT_ID(e) EEvent::e -#include "IoArHandlerMainHandlers.hxx" +#include "IoArHandlerMainInstance.hxx" void TestIoArHandler() { diff --git a/Statemachine Test/src-gen/IoArHandlerMainDeclaration.hxx b/Statemachine Test/src-gen/IoArHandlerMainDeclaration.hxx index 738a5ea..2ae0365 100644 --- a/Statemachine Test/src-gen/IoArHandlerMainDeclaration.hxx +++ b/Statemachine Test/src-gen/IoArHandlerMainDeclaration.hxx @@ -2,8 +2,8 @@ // Include this file in .hxx before implementation declaration // // Before including this header, add the following using declaration in your file: -// class MyClassContainingThisStatemachine; -// using IoArHandlerMainBase = cpp_event_framework::Statemachine; +// class IoArHandlerMainImpl; +// using IoArHandlerMainBase = cpp_event_framework::Statemachine; #pragma once @@ -117,4 +117,45 @@ public: + +// State Closed +static IoArHandlerMain::Transition ClosedHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State Open +static IoArHandlerMain::Transition OpenHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State Parameterizing +static IoArHandlerMain::Transition ParameterizingHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State WaitApplicationReady +static IoArHandlerMain::Transition WaitApplicationReadyHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State WaitApplicationReadyCnf +static IoArHandlerMain::Transition WaitApplicationReadyCnfHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State ApplicationReady +static IoArHandlerMain::Transition ApplicationReadyHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State Ready +static IoArHandlerMain::Transition ReadyHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State DynamicReconfigurationRunning +static IoArHandlerMain::Transition DynamicReconfigurationRunningHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State DrWaitPullCnf +static IoArHandlerMain::Transition DrWaitPullCnfHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State DrWaitApplicationReadyCnfPlugSubmodule +static IoArHandlerMain::Transition DrWaitApplicationReadyCnfPlugSubmoduleHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State DrWaitApplicationReadyPlugSubmodule +static IoArHandlerMain::Transition DrWaitApplicationReadyPlugSubmoduleHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State DrPlugPrmSequence +static IoArHandlerMain::Transition DrPlugPrmSequenceHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + +// State DrWaitPlugCnf +static IoArHandlerMain::Transition DrWaitPlugCnfHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event); + + }; diff --git a/Statemachine Test/src-gen/IoArHandlerMainHandlers.hxx b/Statemachine Test/src-gen/IoArHandlerMainHandlers.hxx deleted file mode 100644 index e2e7eab..0000000 --- a/Statemachine Test/src-gen/IoArHandlerMainHandlers.hxx +++ /dev/null @@ -1,229 +0,0 @@ -// Statemachine IoArHandlerMain handlers -// Include this file in .cxx or in .hxx below implementation declaration - -#pragma once - -// Override the following defines according to your needs if you are not using cpp_event_framework: - -#ifndef IoArHandlerMain_GET_INSTANCE_EVENT_ID -#define IoArHandlerMain_GET_INSTANCE_EVENT_ID(event_instance) event_instance->Id() -#endif - -#ifndef IoArHandlerMain_GET_STATIC_EVENT_ID -#define IoArHandlerMain_GET_STATIC_EVENT_ID(event_name) event_name::kId -#endif - -// State Closed -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainClosedHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArOpend_ind): - return IoArHandlerMain::kClosedToOpenByS_PNS_ArOpend_ind; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq): - return IoArHandlerMain::kClosedToClosedByS_PNS_WriteReq; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ReadReq): - return IoArHandlerMain::kClosedToClosedByS_PNS_ReadReq; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestBackup): - return IoArHandlerMain::kClosedToClosedByS_PNS_SwitchoverRequestBackup; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary): - return IoArHandlerMain::kClosedToClosedByS_PNS_SwitchoverRequestPrimary; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State Open -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainOpenHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq): - return IoArHandlerMain::kOpenToOpenByS_PNS_WriteReq; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_CheckModuleDiff): - return IoArHandlerMain::kOpenToOpenByS_PNS_CheckModuleDiff; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ReadReq): - return IoArHandlerMain::kOpenToOpenByS_PNS_ReadReq; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestBackup): - return IoArHandlerMain::kOpenToOpenByS_PNS_SwitchoverRequestBackup; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary): - return IoArHandlerMain::kOpenToOpenByS_PNS_SwitchoverRequestPrimary; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArClosed_ind): - return IoArHandlerMain::kOpenToClosedByS_PNS_ArClosed_ind; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State Parameterizing -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainParameterizingHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ParamEndInd): - if (FirstInArSetOrPrimary(event)) - { - return IoArHandlerMain::kParameterizingToWaitApplicationReadyByS_PNS_ParamEndInd; - } - return IoArHandlerMain::kParameterizingToWaitApplicationReadyCnfByS_PNS_ParamEndInd; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State WaitApplicationReady -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainWaitApplicationReadyHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(SPnpbAppTimeout): - if (CheckApplicationReady(event)) - { - return IoArHandlerMain::kWaitApplicationReadyToWaitApplicationReadyCnfBySPnpbAppTimeout; - } - return IoArHandlerMain::kWaitApplicationReadyToWaitApplicationReadyBySPnpbAppTimeout; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State WaitApplicationReadyCnf -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainWaitApplicationReadyCnfHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ApplicationReady_cnf): - if (success(event)) - { - return IoArHandlerMain::kWaitApplicationReadyCnfToApplicationReadyByS_PNS_ApplicationReady_cnf; - } - - return IoArHandlerMain::kWaitApplicationReadyCnfToWaitApplicationReadyCnfByS_PNS_ApplicationReady_cnf; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State ApplicationReady -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainApplicationReadyHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State Ready -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainReadyHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPull): - return IoArHandlerMain::kReadyToDrWaitPullCnfByS_PNS_DynReconfPull; - - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPlug): - return IoArHandlerMain::kReadyToDrWaitPlugCnfByS_PNS_DynReconfPlug; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State DynamicReconfigurationRunning -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainDynamicReconfigurationRunningHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(SPnioAppTimeoutDynReconf): - return IoArHandlerMain::kDynamicReconfigurationRunningToDynamicReconfigurationRunningBySPnioAppTimeoutDynReconf; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State DrWaitPullCnf -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainDrWaitPullCnfHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PullSubmodule_cnf): - return IoArHandlerMain::kDrWaitPullCnfToReadyByS_PNS_PullSubmodule_cnf; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State DrWaitApplicationReadyCnfPlugSubmodule -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainDrWaitApplicationReadyCnfPlugSubmoduleHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PlugApplicationReady_cnf): - return IoArHandlerMain::kDrWaitApplicationReadyCnfPlugSubmoduleToReadyByS_PNS_PlugApplicationReady_cnf; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State DrWaitApplicationReadyPlugSubmodule -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainDrWaitApplicationReadyPlugSubmoduleHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(SPnpbAppTimeout): - if (CheckApplicationReady(event)) - { - return IoArHandlerMain::kDrWaitApplicationReadyPlugSubmoduleToDrWaitApplicationReadyCnfPlugSubmoduleBySPnpbAppTimeout; - } - return IoArHandlerMain::kDrWaitApplicationReadyPlugSubmoduleToDrWaitApplicationReadyPlugSubmoduleBySPnpbAppTimeout; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State DrPlugPrmSequence -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainDrPlugPrmSequenceHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PlugParamEndInd): - return IoArHandlerMain::kDrPlugPrmSequenceToDrWaitApplicationReadyPlugSubmoduleByS_PNS_PlugParamEndInd; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - -// State DrWaitPlugCnf -IoArHandlerMain::Transition IoArHandlerMain::Impl::IoArHandlerMainDrWaitPlugCnfHandler(IoArHandlerMain::StateRef /* state */, IoArHandlerMain::Event event) -{ - switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) - { - case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PlugSubmodule_cnf): - return IoArHandlerMain::kDrWaitPlugCnfToDrPlugPrmSequenceByS_PNS_PlugSubmodule_cnf; - - default: - return IoArHandlerMain::UnhandledEvent(); - } -} - - diff --git a/Statemachine Test/src-gen/IoArHandlerMainInstance.hxx b/Statemachine Test/src-gen/IoArHandlerMainInstance.hxx index 47e124e..d4a45db 100644 --- a/Statemachine Test/src-gen/IoArHandlerMainInstance.hxx +++ b/Statemachine Test/src-gen/IoArHandlerMainInstance.hxx @@ -6,14 +6,22 @@ // are either public OR IoArHandlerMain must be a friend class of IoArHandlerMain::Impl (add "friend class IoArHandlerMain;" in your class) // ******* -#pragma once +// Override the following defines according to your needs if you are not using cpp_event_framework: + +#ifndef IoArHandlerMain_GET_INSTANCE_EVENT_ID +#define IoArHandlerMain_GET_INSTANCE_EVENT_ID(event_instance) event_instance->Id() +#endif + +#ifndef IoArHandlerMain_GET_STATIC_EVENT_ID +#define IoArHandlerMain_GET_STATIC_EVENT_ID(event_name) event_name::kId +#endif // Initial state const IoArHandlerMain::StatePtr IoArHandlerMain::kInitialState = &IoArHandlerMain::kClosed; // State Closed const IoArHandlerMain::State IoArHandlerMain::kClosed("Closed", - &IoArHandlerMain::Impl::IoArHandlerMainClosedHandler, // Handler + &ClosedHandler, // Handler nullptr, // Parent nullptr, // Initial nullptr, // Entry @@ -32,9 +40,9 @@ const IoArHandlerMain::Transition IoArHandlerMain::kClosedToClosedByS_PNS_Switch // State Open const IoArHandlerMain::State IoArHandlerMain::kOpen("Open", - &IoArHandlerMain::Impl::IoArHandlerMainOpenHandler, // Handler + &OpenHandler, // Handler nullptr, // Parent - &IoArHandlerMain::kParameterizing, // Initial + &kParameterizing, // Initial nullptr, // Entry nullptr); // Exit const IoArHandlerMain::Transition::ActionType IoArHandlerMain::kOpenToClosedByS_PNS_ArClosed_indActions[] = {&IoArHandlerMain::Impl::ArClosed}; @@ -59,8 +67,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kOpenToOpenByS_PNS_Switchover // State Parameterizing const IoArHandlerMain::State IoArHandlerMain::kParameterizing("Parameterizing", - &IoArHandlerMain::Impl::IoArHandlerMainParameterizingHandler, // Handler - &IoArHandlerMain::kOpen, // Parent + &ParameterizingHandler, // Handler + &kOpen, // Parent nullptr, // Initial nullptr, // Entry nullptr); // Exit @@ -73,8 +81,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kParameterizingToWaitApplicat // State WaitApplicationReady const IoArHandlerMain::State IoArHandlerMain::kWaitApplicationReady("WaitApplicationReady", - &IoArHandlerMain::Impl::IoArHandlerMainWaitApplicationReadyHandler, // Handler - &IoArHandlerMain::kOpen, // Parent + &WaitApplicationReadyHandler, // Handler + &kOpen, // Parent nullptr, // Initial &IoArHandlerMain::Impl::StartWaitApplicationReadyTimer, // Entry &IoArHandlerMain::Impl::StopWaitApplicationReadyTimer); // Exit @@ -86,8 +94,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kWaitApplicationReadyToWaitAp // State WaitApplicationReadyCnf const IoArHandlerMain::State IoArHandlerMain::kWaitApplicationReadyCnf("WaitApplicationReadyCnf", - &IoArHandlerMain::Impl::IoArHandlerMainWaitApplicationReadyCnfHandler, // Handler - &IoArHandlerMain::kOpen, // Parent + &WaitApplicationReadyCnfHandler, // Handler + &kOpen, // Parent nullptr, // Initial &IoArHandlerMain::Impl::SendApplicationReady, // Entry nullptr); // Exit @@ -100,9 +108,9 @@ const IoArHandlerMain::Transition IoArHandlerMain::kWaitApplicationReadyCnfToWai // State ApplicationReady const IoArHandlerMain::State IoArHandlerMain::kApplicationReady("ApplicationReady", - &IoArHandlerMain::Impl::IoArHandlerMainApplicationReadyHandler, // Handler - &IoArHandlerMain::kOpen, // Parent - &IoArHandlerMain::kReady, // Initial + &ApplicationReadyHandler, // Handler + &kOpen, // Parent + &kReady, // Initial nullptr, // Entry nullptr); // Exit @@ -110,8 +118,8 @@ const IoArHandlerMain::State IoArHandlerMain::kApplicationReady("ApplicationRead // State Ready const IoArHandlerMain::State IoArHandlerMain::kReady("Ready", - &IoArHandlerMain::Impl::IoArHandlerMainReadyHandler, // Handler - &IoArHandlerMain::kApplicationReady, // Parent + &ReadyHandler, // Handler + &kApplicationReady, // Parent nullptr, // Initial nullptr, // Entry nullptr); // Exit @@ -124,9 +132,9 @@ const IoArHandlerMain::Transition IoArHandlerMain::kReadyToDrWaitPullCnfByS_PNS_ // State DynamicReconfigurationRunning const IoArHandlerMain::State IoArHandlerMain::kDynamicReconfigurationRunning("DynamicReconfigurationRunning", - &IoArHandlerMain::Impl::IoArHandlerMainDynamicReconfigurationRunningHandler, // Handler - &IoArHandlerMain::kApplicationReady, // Parent - &IoArHandlerMain::kDrWaitPlugCnf, // Initial + &DynamicReconfigurationRunningHandler, // Handler + &kApplicationReady, // Parent + &kDrWaitPlugCnf, // Initial &IoArHandlerMain::Impl::StartDynReconfTimer, // Entry &IoArHandlerMain::Impl::StopDynReconfTimer); // Exit @@ -137,8 +145,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kDynamicReconfigurationRunnin // State DrWaitPullCnf const IoArHandlerMain::State IoArHandlerMain::kDrWaitPullCnf("DrWaitPullCnf", - &IoArHandlerMain::Impl::IoArHandlerMainDrWaitPullCnfHandler, // Handler - &IoArHandlerMain::kDynamicReconfigurationRunning, // Parent + &DrWaitPullCnfHandler, // Handler + &kDynamicReconfigurationRunning, // Parent nullptr, // Initial nullptr, // Entry nullptr); // Exit @@ -149,8 +157,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kDrWaitPullCnfToReadyByS_PNS_ // State DrWaitApplicationReadyCnfPlugSubmodule const IoArHandlerMain::State IoArHandlerMain::kDrWaitApplicationReadyCnfPlugSubmodule("DrWaitApplicationReadyCnfPlugSubmodule", - &IoArHandlerMain::Impl::IoArHandlerMainDrWaitApplicationReadyCnfPlugSubmoduleHandler, // Handler - &IoArHandlerMain::kDynamicReconfigurationRunning, // Parent + &DrWaitApplicationReadyCnfPlugSubmoduleHandler, // Handler + &kDynamicReconfigurationRunning, // Parent nullptr, // Initial nullptr, // Entry nullptr); // Exit @@ -161,8 +169,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kDrWaitApplicationReadyCnfPlu // State DrWaitApplicationReadyPlugSubmodule const IoArHandlerMain::State IoArHandlerMain::kDrWaitApplicationReadyPlugSubmodule("DrWaitApplicationReadyPlugSubmodule", - &IoArHandlerMain::Impl::IoArHandlerMainDrWaitApplicationReadyPlugSubmoduleHandler, // Handler - &IoArHandlerMain::kDynamicReconfigurationRunning, // Parent + &DrWaitApplicationReadyPlugSubmoduleHandler, // Handler + &kDynamicReconfigurationRunning, // Parent nullptr, // Initial &IoArHandlerMain::Impl::StartWaitApplicationReadyTimer, // Entry &IoArHandlerMain::Impl::StopWaitApplicationReadyTimer); // Exit @@ -174,8 +182,8 @@ const IoArHandlerMain::Transition IoArHandlerMain::kDrWaitApplicationReadyPlugSu // State DrPlugPrmSequence const IoArHandlerMain::State IoArHandlerMain::kDrPlugPrmSequence("DrPlugPrmSequence", - &IoArHandlerMain::Impl::IoArHandlerMainDrPlugPrmSequenceHandler, // Handler - &IoArHandlerMain::kDynamicReconfigurationRunning, // Parent + &DrPlugPrmSequenceHandler, // Handler + &kDynamicReconfigurationRunning, // Parent nullptr, // Initial nullptr, // Entry nullptr); // Exit @@ -186,9 +194,250 @@ const IoArHandlerMain::Transition IoArHandlerMain::kDrPlugPrmSequenceToDrWaitApp // State DrWaitPlugCnf const IoArHandlerMain::State IoArHandlerMain::kDrWaitPlugCnf("DrWaitPlugCnf", - &IoArHandlerMain::Impl::IoArHandlerMainDrWaitPlugCnfHandler, // Handler - &IoArHandlerMain::kDynamicReconfigurationRunning, // Parent + &DrWaitPlugCnfHandler, // Handler + &kDynamicReconfigurationRunning, // Parent nullptr, // Initial nullptr, // Entry nullptr); // Exit const IoArHandlerMain::Transition IoArHandlerMain::kDrWaitPlugCnfToDrPlugPrmSequenceByS_PNS_PlugSubmodule_cnf(kDrPlugPrmSequence); + +// State Closed +IoArHandlerMain::Transition IoArHandlerMain::ClosedHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ReadReq): + return IoArHandlerMain::kClosedToClosedByS_PNS_ReadReq; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq): + return IoArHandlerMain::kClosedToClosedByS_PNS_WriteReq; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestBackup): + return IoArHandlerMain::kClosedToClosedByS_PNS_SwitchoverRequestBackup; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArOpend_ind): + return IoArHandlerMain::kClosedToOpenByS_PNS_ArOpend_ind; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary): + return IoArHandlerMain::kClosedToClosedByS_PNS_SwitchoverRequestPrimary; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State Open +IoArHandlerMain::Transition IoArHandlerMain::OpenHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ReadReq): + return IoArHandlerMain::kOpenToOpenByS_PNS_ReadReq; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_WriteReq): + return IoArHandlerMain::kOpenToOpenByS_PNS_WriteReq; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestBackup): + return IoArHandlerMain::kOpenToOpenByS_PNS_SwitchoverRequestBackup; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_SwitchoverRequestPrimary): + return IoArHandlerMain::kOpenToOpenByS_PNS_SwitchoverRequestPrimary; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ArClosed_ind): + return IoArHandlerMain::kOpenToClosedByS_PNS_ArClosed_ind; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_CheckModuleDiff): + return IoArHandlerMain::kOpenToOpenByS_PNS_CheckModuleDiff; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State Parameterizing +IoArHandlerMain::Transition IoArHandlerMain::ParameterizingHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ParamEndInd): + if (impl->FirstInArSetOrPrimary(event)) + { + return IoArHandlerMain::kParameterizingToWaitApplicationReadyByS_PNS_ParamEndInd; + } + return IoArHandlerMain::kParameterizingToWaitApplicationReadyCnfByS_PNS_ParamEndInd; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State WaitApplicationReady +IoArHandlerMain::Transition IoArHandlerMain::WaitApplicationReadyHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(SPnpbAppTimeout): + if (impl->CheckApplicationReady(event)) + { + return IoArHandlerMain::kWaitApplicationReadyToWaitApplicationReadyCnfBySPnpbAppTimeout; + } + return IoArHandlerMain::kWaitApplicationReadyToWaitApplicationReadyBySPnpbAppTimeout; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State WaitApplicationReadyCnf +IoArHandlerMain::Transition IoArHandlerMain::WaitApplicationReadyCnfHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_ApplicationReady_cnf): + if (impl->success(event)) + { + return IoArHandlerMain::kWaitApplicationReadyCnfToApplicationReadyByS_PNS_ApplicationReady_cnf; + } + + return IoArHandlerMain::kWaitApplicationReadyCnfToWaitApplicationReadyCnfByS_PNS_ApplicationReady_cnf; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State ApplicationReady +IoArHandlerMain::Transition IoArHandlerMain::ApplicationReadyHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State Ready +IoArHandlerMain::Transition IoArHandlerMain::ReadyHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPlug): + return IoArHandlerMain::kReadyToDrWaitPlugCnfByS_PNS_DynReconfPlug; + + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_DynReconfPull): + return IoArHandlerMain::kReadyToDrWaitPullCnfByS_PNS_DynReconfPull; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State DynamicReconfigurationRunning +IoArHandlerMain::Transition IoArHandlerMain::DynamicReconfigurationRunningHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(SPnioAppTimeoutDynReconf): + return IoArHandlerMain::kDynamicReconfigurationRunningToDynamicReconfigurationRunningBySPnioAppTimeoutDynReconf; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State DrWaitPullCnf +IoArHandlerMain::Transition IoArHandlerMain::DrWaitPullCnfHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PullSubmodule_cnf): + return IoArHandlerMain::kDrWaitPullCnfToReadyByS_PNS_PullSubmodule_cnf; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State DrWaitApplicationReadyCnfPlugSubmodule +IoArHandlerMain::Transition IoArHandlerMain::DrWaitApplicationReadyCnfPlugSubmoduleHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PlugApplicationReady_cnf): + return IoArHandlerMain::kDrWaitApplicationReadyCnfPlugSubmoduleToReadyByS_PNS_PlugApplicationReady_cnf; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State DrWaitApplicationReadyPlugSubmodule +IoArHandlerMain::Transition IoArHandlerMain::DrWaitApplicationReadyPlugSubmoduleHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(SPnpbAppTimeout): + if (impl->CheckApplicationReady(event)) + { + return IoArHandlerMain::kDrWaitApplicationReadyPlugSubmoduleToDrWaitApplicationReadyCnfPlugSubmoduleBySPnpbAppTimeout; + } + return IoArHandlerMain::kDrWaitApplicationReadyPlugSubmoduleToDrWaitApplicationReadyPlugSubmoduleBySPnpbAppTimeout; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State DrPlugPrmSequence +IoArHandlerMain::Transition IoArHandlerMain::DrPlugPrmSequenceHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PlugParamEndInd): + return IoArHandlerMain::kDrPlugPrmSequenceToDrWaitApplicationReadyPlugSubmoduleByS_PNS_PlugParamEndInd; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + +// State DrWaitPlugCnf +IoArHandlerMain::Transition IoArHandlerMain::DrWaitPlugCnfHandler(IoArHandlerMain::ImplPtr impl, IoArHandlerMain::Event event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch(IoArHandlerMain_GET_INSTANCE_EVENT_ID(event)) + { + case IoArHandlerMain_GET_STATIC_EVENT_ID(S_PNS_PlugSubmodule_cnf): + return IoArHandlerMain::kDrWaitPlugCnfToDrPlugPrmSequenceByS_PNS_PlugSubmodule_cnf; + + default: + return IoArHandlerMain::UnhandledEvent(); + } +} + + diff --git a/Statemachine Test/src-gen/IoArHandlerMainPrototypes.hxx b/Statemachine Test/src-gen/IoArHandlerMainPrototypes.hxx deleted file mode 100644 index 642ecb3..0000000 --- a/Statemachine Test/src-gen/IoArHandlerMainPrototypes.hxx +++ /dev/null @@ -1,45 +0,0 @@ -// Statemachine IoArHandlerMain prototypes -// Include this file in your class declaration - -#pragma once - -// State Closed -IoArHandlerMain::Transition IoArHandlerMainClosedHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State Open -IoArHandlerMain::Transition IoArHandlerMainOpenHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State Parameterizing -IoArHandlerMain::Transition IoArHandlerMainParameterizingHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State WaitApplicationReady -IoArHandlerMain::Transition IoArHandlerMainWaitApplicationReadyHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State WaitApplicationReadyCnf -IoArHandlerMain::Transition IoArHandlerMainWaitApplicationReadyCnfHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State ApplicationReady -IoArHandlerMain::Transition IoArHandlerMainApplicationReadyHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State Ready -IoArHandlerMain::Transition IoArHandlerMainReadyHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State DynamicReconfigurationRunning -IoArHandlerMain::Transition IoArHandlerMainDynamicReconfigurationRunningHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State DrWaitPullCnf -IoArHandlerMain::Transition IoArHandlerMainDrWaitPullCnfHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State DrWaitApplicationReadyCnfPlugSubmodule -IoArHandlerMain::Transition IoArHandlerMainDrWaitApplicationReadyCnfPlugSubmoduleHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State DrWaitApplicationReadyPlugSubmodule -IoArHandlerMain::Transition IoArHandlerMainDrWaitApplicationReadyPlugSubmoduleHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State DrPlugPrmSequence -IoArHandlerMain::Transition IoArHandlerMainDrPlugPrmSequenceHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - -// State DrWaitPlugCnf -IoArHandlerMain::Transition IoArHandlerMainDrWaitPlugCnfHandler(IoArHandlerMain::StateRef state, IoArHandlerMain::Event event); - - diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp.updatesite/site.xml b/net.ziegelmeier.statemachine.uml.gen.cpp.updatesite/site.xml index 82e96b6..9cc20d4 100644 --- a/net.ziegelmeier.statemachine.uml.gen.cpp.updatesite/site.xml +++ b/net.ziegelmeier.statemachine.uml.gen.cpp.updatesite/site.xml @@ -3,7 +3,7 @@ - + diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/build.properties b/net.ziegelmeier.statemachine.uml.gen.cpp/build.properties index 43abb87..de1edf6 100644 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/build.properties +++ b/net.ziegelmeier.statemachine.uml.gen.cpp/build.properties @@ -4,4 +4,4 @@ bin.includes = META-INF/,\ .,\ bin/net/ziegelmeier/statemachine/uml/gen/cpp/main/ jre.compilation.profile = JavaSE-17 -src.includes = bin/net/ziegelmeier/statemachine/uml/gen/cpp/main/ +src.includes = bin/net/ziegelmeier/statemachine/uml/gen/cpp/main/ \ No newline at end of file diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineDeclarations.mtl b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineDeclarations.mtl index 48cc690..0c6019c 100644 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineDeclarations.mtl +++ b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineDeclarations.mtl @@ -9,8 +9,8 @@ // Include this file in .hxx before implementation declaration // // Before including this header, add the following using declaration in your file: -// class MyClassContainingThisStatemachine; -// using [aStatemachine.name/]Base = cpp_event_framework::Statemachine; +// class [aStatemachine.name/]Impl; +// using [aStatemachine.name/]Base = cpp_event_framework::Statemachine<[aStatemachine.name/]Impl, const cpp_event_framework::Signal::SPtr&>; #pragma once @@ -20,6 +20,8 @@ public: static const StatePtr kInitialState; [aStatemachine.region.generateRegion()/] + +[aStatemachine.region.generateHandlerPrototypes(aStatemachine)/] }; [/file] [/template] @@ -57,3 +59,19 @@ public: static const Transition [aTransition.getTransitionVariable(aTransition)/]; [/template] + +[comment --------------------------------------------------- /] + +[template private generateHandlerPrototypes(aRegion : Region, aStatemachine : StateMachine)] +[aRegion.eContents(Vertex).generateVertex(aStatemachine)/] +[/template] + +[template private generateVertex(aState : Vertex, aStatemachine : StateMachine)] +[/template] + +[template private generateVertex(aState : State, aStatemachine : StateMachine)] +// State [aState.name/] +static [aStatemachine.getTransitionType()/] [aState.name/]Handler([aStatemachine.getImplPtrType()/] impl, [aStatemachine.getEventType()/] event); + +[aState.eContents(Region).generateHandlerPrototypes(aStatemachine)/] +[/template] diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineHandlers.mtl b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineHandlers.mtl deleted file mode 100644 index 513e2fa..0000000 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineHandlers.mtl +++ /dev/null @@ -1,86 +0,0 @@ -[comment encoding = UTF-8 /] -[module StatemachineHandlers('http://www.eclipse.org/uml2/5.0.0/UML')] - -[import net::ziegelmeier::statemachine::uml::gen::cpp::main::StatemachineQueries/] - -[template public generateHandlers(aStatemachine : StateMachine)] -[file (aStatemachine.name.concat('Handlers.hxx'), false, 'UTF-8')] -// Statemachine [aStatemachine.name/] handlers -// Include this file in .cxx or in .hxx below implementation declaration - -#pragma once - -// Override the following defines according to your needs if you are not using cpp_event_framework: - -#ifndef [aStatemachine.name/]_GET_INSTANCE_EVENT_ID -#define [aStatemachine.name/]_GET_INSTANCE_EVENT_ID(event_instance) event_instance->Id() -#endif - -#ifndef [aStatemachine.name/]_GET_STATIC_EVENT_ID -#define [aStatemachine.name/]_GET_STATIC_EVENT_ID(event_name) event_name::kId -#endif - -[aStatemachine.region.generateRegion(aStatemachine)/] -[/file] -[/template] - -[comment --------------------------------------------------- /] - -[template private generateRegion(aRegion : Region, aStatemachine : StateMachine)] -[aRegion.eContents(Vertex).generateVertex(aStatemachine)/] -[/template] - -[template private generateVertex(aState : Vertex, aStatemachine : StateMachine)] -[/template] - -[template private generateVertex(aState : State, aStatemachine : StateMachine)] -// State [aState.name/] -[let aFunctionName : String = aStatemachine.name + aState.name + 'Handler'] -[aStatemachine.getTransitionType()/] [aStatemachine.getImplType()/]::[aFunctionName/]([aStatemachine.getStateRefType()/] /* state */, [aStatemachine.getEventType()/] event) -{ - switch([aStatemachine.name/]_GET_INSTANCE_EVENT_ID(event)) - { - [let allEvents : Set(Event) = aState.outgoing->collect(getEvent())->asSet()] - [for (anEvent : Event | allEvents)] - case [aStatemachine.name/]_GET_STATIC_EVENT_ID([anEvent.name/]): - [let allTransitions : Sequence(Transition) = aState.outgoing->select(t | t.getEvent().name = anEvent.name)->asSequence()->sortedBy(guard.oclIsUndefined() or (guard.name = 'else'))] - [for (aTrans : Transition | allTransitions)] - [aTrans.generateTransition(aTrans, aStatemachine)/] - [/for] - [/let] - [/for] - [/let] - default: - return [aStatemachine.name/]::UnhandledEvent(); - } -} -[/let] - -[aState.eContents(Region).generateRegion(aStatemachine)/] -[/template] - -[template private generateTransition(aTransition : Transition, aStartTransition : Transition, aStatemachine : StateMachine)] -[if (aTransition.target.oclIsKindOf(State))] -[if (aTransition.guard.oclIsUndefined() or (aTransition.guard.name = 'else'))] -return [aStatemachine.name/]::[aTransition.getTransitionVariable(aStartTransition)/]; -[else] -if ([aTransition.guard.name/](event)) -{ - return [aStatemachine.name/]::[aTransition.getTransitionVariable(aStartTransition)/]; -} -[/if] -[elseif (aTransition.target.oclIsTypeOf(Pseudostate) and aTransition.target.oclAsType(Pseudostate).kind = PseudostateKind::choice)] -[if (not aTransition.guard.oclIsUndefined() and not (aTransition.guard.name = 'else'))] -if ([aTransition.guard.name/](event)) -{ - [generateTransitionRecursive(aStartTransition, aStatemachine)/] -} -[else] -[generateTransitionRecursive(aStartTransition, aStatemachine)/] -[/if] -[/if] -[/template] - -[template private generateTransitionRecursive(aTransition : Transition, aStartTransition : Transition, aStatemachine : StateMachine) post (trim())] -[aTransition.target.oclAsType(Pseudostate).outgoing->asSequence()->sortedBy(guard.oclIsUndefined() or (guard.name = 'else')).generateTransition(aStartTransition, aStatemachine)/] -[/template] diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineInstance.mtl b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineInstance.mtl index df555d9..dad8923 100644 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineInstance.mtl +++ b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineInstance.mtl @@ -13,11 +13,21 @@ // are either public OR [aStatemachine.name/] must be a friend class of [aStatemachine.getImplType()/] (add "friend class [aStatemachine.name/];" in your class) // ******* -#pragma once +// Override the following defines according to your needs if you are not using cpp_event_framework: + +#ifndef [aStatemachine.name/]_GET_INSTANCE_EVENT_ID +#define [aStatemachine.name/]_GET_INSTANCE_EVENT_ID(event_instance) event_instance->Id() +#endif + +#ifndef [aStatemachine.name/]_GET_STATIC_EVENT_ID +#define [aStatemachine.name/]_GET_STATIC_EVENT_ID(event_name) event_name::kId +#endif [aStatemachine.region->asSequence()->first().generateInitialState(aStatemachine)/] [aStatemachine.region->asSequence()->first().generateRegion(aStatemachine)/] + +[aStatemachine.region.generateHandlers(aStatemachine)/] [/file] [/template] @@ -38,7 +48,7 @@ const [aStatemachine.getStatePtrType()/] [aStatemachine.name/]::kInitialState = [template private generateVertex(aState : State, aStatemachine : StateMachine)] // State [aState.name/] const [aState.generateStateType(aStatemachine)/] [aStatemachine.name/]::[aState.getStateVariable()/]("[aState.name/]", - &[aStatemachine.getImplType()/]::[aStatemachine.name/][aState.name/]Handler, // Handler + &[aState.name/]Handler, // Handler [generateParent(aState, aStatemachine)/], // Parent [generateInitial(aState, aStatemachine)/], // Initial [generateEntryExit(aState.entry, aStatemachine)/], // Entry @@ -61,7 +71,7 @@ nullptr [if (aState.container.state.oclIsUndefined())] nullptr [else] -&[aStatemachine.name/]::k[aState.container.state.name/] +&k[aState.container.state.name/] [/if] [/template] @@ -69,7 +79,7 @@ nullptr [if (aState.getSubRegion().getInitialPseudoState().getInitialState().oclIsUndefined())] nullptr [else] -&[aStatemachine.name/]::k[aState.getSubRegion().getInitialPseudoState().getInitialState().name/] +&k[aState.getSubRegion().getInitialPseudoState().getInitialState().name/] [/if] [/template] @@ -111,3 +121,66 @@ const [aStatemachine.getTransitionType()/] [aStatemachine.name/]::[aTransition.g [/if] [/template] + +[comment --------------------------------------------------- /] + +[template private generateHandlers(aRegion : Region, aStatemachine : StateMachine)] +[aRegion.eContents(Vertex).generateHandlersVertex(aStatemachine)/] +[/template] + +[template private generateHandlersVertex(aState : Vertex, aStatemachine : StateMachine)] +[/template] + +[template private generateHandlersVertex(aState : State, aStatemachine : StateMachine)] +// State [aState.name/] +[let aFunctionName : String = aState.name + 'Handler'] +[aStatemachine.getTransitionType()/] [aStatemachine.name/]::[aFunctionName/]([aStatemachine.getImplPtrType()/] impl, [aStatemachine.getEventType()/] event) +{ + (void)impl; // impl parameter is unused when there is no guard function being called in here + + switch([aStatemachine.name/]_GET_INSTANCE_EVENT_ID(event)) + { + [let allEvents : Set(Event) = aState.outgoing->collect(getEvent())->asSet()] + [for (anEvent : Event | allEvents)] + case [aStatemachine.name/]_GET_STATIC_EVENT_ID([anEvent.name/]): + [let allTransitions : Sequence(Transition) = aState.outgoing->select(t | t.getEvent().name = anEvent.name)->asSequence()->sortedBy(guard.oclIsUndefined() or (guard.name = 'else'))] + [for (aTrans : Transition | allTransitions)] + [aTrans.generateTransition(aTrans, aStatemachine)/] + [/for] + [/let] + [/for] + [/let] + default: + return [aStatemachine.name/]::UnhandledEvent(); + } +} +[/let] + +[aState.eContents(Region).generateHandlers(aStatemachine)/] +[/template] + +[template private generateTransition(aTransition : Transition, aStartTransition : Transition, aStatemachine : StateMachine)] +[if (aTransition.target.oclIsKindOf(State))] +[if (aTransition.guard.oclIsUndefined() or (aTransition.guard.name = 'else'))] +return [aStatemachine.name/]::[aTransition.getTransitionVariable(aStartTransition)/]; +[else] +if (impl->[aTransition.guard.name/](event)) +{ + return [aStatemachine.name/]::[aTransition.getTransitionVariable(aStartTransition)/]; +} +[/if] +[elseif (aTransition.target.oclIsTypeOf(Pseudostate) and aTransition.target.oclAsType(Pseudostate).kind = PseudostateKind::choice)] +[if (not aTransition.guard.oclIsUndefined() and not (aTransition.guard.name = 'else'))] +if (impl->[aTransition.guard.name/](event)) +{ + [generateTransitionRecursive(aStartTransition, aStatemachine)/] +} +[else] +[generateTransitionRecursive(aStartTransition, aStatemachine)/] +[/if] +[/if] +[/template] + +[template private generateTransitionRecursive(aTransition : Transition, aStartTransition : Transition, aStatemachine : StateMachine) post (trim())] +[aTransition.target.oclAsType(Pseudostate).outgoing->asSequence()->sortedBy(guard.oclIsUndefined() or (guard.name = 'else')).generateTransition(aStartTransition, aStatemachine)/] +[/template] diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachinePrototypes.mtl b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachinePrototypes.mtl deleted file mode 100644 index ca0edc5..0000000 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachinePrototypes.mtl +++ /dev/null @@ -1,31 +0,0 @@ -[comment encoding = UTF-8 /] -[module StatemachinePrototypes('http://www.eclipse.org/uml2/5.0.0/UML')] - -[import net::ziegelmeier::statemachine::uml::gen::cpp::main::StatemachineQueries/] - -[template public generatePrototypes(aStatemachine : StateMachine)] -[file (aStatemachine.name.concat('Prototypes.hxx'), false, 'UTF-8')] -// Statemachine [aStatemachine.name/] prototypes -// Include this file in your class declaration - -#pragma once - -[aStatemachine.region.generateRegion(aStatemachine)/] -[/file] -[/template] - -[comment --------------------------------------------------- /] - -[template private generateRegion(aRegion : Region, aStatemachine : StateMachine)] -[aRegion.eContents(Vertex).generateVertex(aStatemachine)/] -[/template] - -[template private generateVertex(aState : Vertex, aStatemachine : StateMachine)] -[/template] - -[template private generateVertex(aState : State, aStatemachine : StateMachine)] -// State [aState.name/] -[aStatemachine.getTransitionType()/] [aStatemachine.name/][aState.name/]Handler([aStatemachine.getStateRefType()/] state, [aStatemachine.getEventType()/] event); - -[aState.eContents(Region).generateRegion(aStatemachine)/] -[/template] diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineQueries.mtl b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineQueries.mtl index cb87fd8..dc09a95 100644 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineQueries.mtl +++ b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/StatemachineQueries.mtl @@ -31,6 +31,10 @@ k[aState.name/] [aStatemachine.name/]::StatePtr [/template] +[template public getImplPtrType(aStatemachine : StateMachine) post(trim())] +[aStatemachine.name/]::ImplPtr +[/template] + [template public getStateRefType(aStatemachine : StateMachine) post(trim())] [aStatemachine.name/]::StateRef [/template] diff --git a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/generate.mtl b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/generate.mtl index cd951bf..e00e27f 100644 --- a/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/generate.mtl +++ b/net.ziegelmeier.statemachine.uml.gen.cpp/src/net/ziegelmeier/statemachine/uml/gen/cpp/main/generate.mtl @@ -2,9 +2,7 @@ [module generate('http://www.eclipse.org/uml2/5.0.0/UML')] [import net::ziegelmeier::statemachine::uml::gen::cpp::main::StatemachineDeclarations/] -[import net::ziegelmeier::statemachine::uml::gen::cpp::main::StatemachinePrototypes/] [import net::ziegelmeier::statemachine::uml::gen::cpp::main::StatemachineInstance/] -[import net::ziegelmeier::statemachine::uml::gen::cpp::main::StatemachineHandlers/] [template public generateElement(aModel : Model)] [comment @main/] @@ -13,7 +11,5 @@ [template public generateElement(aStatemachine : StateMachine)] [aStatemachine.generateDeclaration()/] -[aStatemachine.generatePrototypes()/] [aStatemachine.generateInstance()/] -[aStatemachine.generateHandlers()/] [/template]